Page **1** of **1**

### Combat mechanics

Posted: **Sat Feb 03, 2018 5:54 am**

by **Sphinx**

So.. how does it exactly work?

Stats, MP per attack, square HP and crit. Whats the formula?

I understand, that high mp per attack deals more "damage", but what do the stats do? Crit increases the mp per attack?

### Re: Combat mechanics

Posted: **Tue Feb 06, 2018 12:48 am**

by **Mike**

Basically:

The server chooses the most effective of the 3 stats for the attacker to attack with, and for the defender to defend with. The attacker's stat value is multiplied by 2 if it's a critical hit. The defender's stat value is multiplied by either 0.5, 1 or 2 depending on the rock/paper/scissors relationship between the attack and defense stats. Once the final attack and defense stat value have been determined, the ratio of attack/defense is computed, and multiplied by a random number in the range 0.5->1.5. This attack ratio is then multiplied by the attacker's manpower per attack to determine how many hit points will be taken away from the defending square.

Here's a more detailed version:

Outline of the combat formula:

1) Based on the stats of the attacking and defending nations, two numbers are determined: the attackVal and the defenseVal.

2) The attackRatio is (attackVal / defenseVal). It is a number in the range of 0 to infinity, where a low value means the defender does well, a high value means the attacker does well, and 1.0 means they're evenly matched.

3) A random number in the range 0.5 to 1.5 is generated and multiplied into the attackRatio.

4) The amount of hit points taken away from the defending square is equal to the attacker's manpowerPerAttack, multiplied by the attackRatio. (If that number of hit points is greater than the square has, then the square is defeated and no more of the attacker's manpowerPerAttack is used up than is needed).

Here are the details about how the nations' stats are used to determine the attackVal and defenseVal:

1) Nine possible attackVal and defenseVal pairs are determined, corresponding to the 9 possible attack and defense stat combinations (eg tech->tech, tech->bio, etc.). The value of each pair is:

attackVal: the attacker's value in the attack stat, multiplied by 2 if this is a critical hit.

defenseVal: the defender's value in the defense stat, multiplied by 0.5, 1.0 or 2.0 depending on the rock/paper/scissors relationship of the particular attack and defense stats.

2) For each pair, the ratio of attackVal / defenseVal is looked at to determine which attack stat and defense stat will be used for the attack. For each attack stat the defense stat is chosen that produces the lowest ratio (best result for defender). Then, given that, the attack stat is chosen that produces the highest ratio (best result for attacker). The result is that the attacker and defender both choose to use their stat that works to their own greatest advantage.

Note that during the several seconds that an attack takes, the square is also gaining hit points at whatever that nation's hit point restore rate is. So, the attack needs to take away more hit points during those seconds than the nation restores, in order to do any damage.

### Re: Combat mechanics

Posted: **Tue Feb 06, 2018 5:01 am**

by **Sphinx**

Thanks, much clearer now.

### Re: Combat mechanics

Posted: **Fri Oct 19, 2018 4:59 pm**

by **Mike**

I was asked to give an example of how the attacker and defender's stats are chosen in an attack. Here's a walk through of those steps (described above).

Say that nation 1 is attacking nation 2, and they have these stats:

Tech Bio Psi

Nation 1 300 300 20

Nation 2 300 20 300

First it looks at the 9 possible attack stat/defense stat combinations, and multiplies the defense stat by 0.5, 1, or 2 depending on the rock/paper/scissor relationship between the two stats. For each pair it then takes the attacker stat and divides it by the (modified) defender stat to determine the attack ratio for that pair:

Tech (300) vs Tech (300 * 1.0 = 300) ratio: 300/300 = 1.0

Tech (300) vs Bio (20* 0.5 = 10) ratio: 300/10 = 30.0

Tech (300) vs Psi (300 * 2.0 = 600) ratio: 300/600 = 0.5

Bio (300) vs Tech (300 * 2.0 = 150) ratio: 300 / 150 = 0.5

Bio (300) vs Bio (20 * 1.0 = 20) ratio: 300 / 20 = 15.0

Bio (300) vs Psi (300 * 0.5 = 600) ratio: 300/600 = 0.5

Psi (20) vs Tech (300 * 0.5 = 150) ratio: 20/150 = 0.133

Psi (20) vs Bio (20 * 2.0 = 40) ratio: 20/40 = 0.5

Psi (20) vs Psi (300 * 1.0 = 300) ratio: 20 / 300 = 0.067

Next, based on the attack ratio of each possible attack-stat to defense-stat pair, one pair has to be chosen. The attacker wants to choose the pair with the highest ratio, while the defender would prefer the pair with the lowest ratio. So, say the attacker attacked with Tech. The defender would then defend with Psi, because that would produce the lowest ratio (0.5). If the attacker attacked with Bio, the defender would defend with Tech or Psi, because either of those would produce the lowest ratio (0.5). If the attacker attacked with Psi, then the defender would defend with Psi to produce the lowest ratio (0.067). So here's the ratio that would result from each stat the attacker could attack with, given that the defender would choose their own stat to defend as best they could:

Tech: 0.5

Bio: 0.5

Psi: 0.067

Given these choices, the attacker would definitely not want to attack with Psi, since that would result in the lowest ratio. The attacker would choose either Tech or Bio, since either one would result in the highest attack ratio, 0.5. There is a tie in this case because the nations had the same values for multiple stats, but usually there is a single clear winner.