Enemy Variable Battle System
Hello Everyone, I wanted to make a battle system, where the engine takes the player's variables, like number of fighter, health, speed, etc., all variables that would affect the outcome of a battle between one player and an enemy squadron already assigned. So, if the player had 200 fighters and 1 frigate, and the enemy had 120 fighters, the player would win. I want the engine to be versatile, kind of like as seen in http://answers.unity3d.com/questions/214657/enemy-database-for-rpg-battle-system.html I just don't understand how. If I could see an example script or two, any level of length, I would greatly appreciate it. Or, if someone could explain it in relatively simple terms, that would also be appreciated. Thank you, and have a nice day.
P.S. I use c#, but could, with some trouble, learn javascript
@Wolfshadow If you have all the variables you would just have to come up with a good equation to calculate the damage.
What I would do: Sum up all the individual variables into a gathered e.g. "allSpeed" variable.
Use something like: float totalDamage = allSpeed * allStrength;
Then calculate how much HP is left: float HPleft = allHP - totalDamage;
Now you should figure out how many units this correlates to. What you could do is iterate over all your units and do this: if(HPLeft > 0){ HPleft -= unitHP; Destroy(unit);}
Here you have to decide which units should die first, should low cost units die before high cost? Should you select them randomly? You should also use a if(HPLeft < unitHP){unitHP -= HPLeft;} so that you do not destroy a whole unit just because HPleft = 1 :P