| 50 | } |
| 51 | |
| 52 | static int getPsiAttackChance(int psiAttack, int psiDefense, PsiStatus status, bool isAttack) |
| 53 | { |
| 54 | // Psi chance as per Wong's Guide, confirmed by Mell |
| 55 | /* |
| 56 | 100*attack*(100-defense) |
| 57 | success rate = -------------------------------------- |
| 58 | attack*(100-defense) + 100*defense |
| 59 | |
| 60 | psiattack rating * 40 |
| 61 | attack = --------------------------- |
| 62 | initiation cost of action |
| 63 | |
| 64 | Note: As tested by Mell, Probe is min 20% |
| 65 | */ |
| 66 | int cost = getPsiCost(status, isAttack); |
| 67 | int attack = psiAttack * 40 / cost; |
| 68 | int defense = psiDefense; |
| 69 | int chance = 0; |
| 70 | if (attack != 0 || defense != 0) |
| 71 | { |
| 72 | chance = (100 * attack * (100 - defense)) / (attack * (100 - defense) + 100 * defense); |
| 73 | } |
| 74 | if (status == PsiStatus::Probe && attack != 0) |
| 75 | { |
| 76 | chance = std::max(20, chance); |
| 77 | } |
| 78 | return chance; |
| 79 | } |
| 80 | |
| 81 | namespace |
| 82 | { |
no test coverage detected