aliens

Author Topic: PSI defence & attack formula?  (Read 346 times)

Offline sirmik

  • Sergeant
  • **
  • Posts: 20
    • View Profile
PSI defence & attack formula?
« on: November 13, 2024, 05:25:58 pm »
Does anyone happen to know the actual formula for psi defense and attack? In the original version, I found something like this:

Quote
Attack Strength (AS) = (Psi Strength * Psi Skill / 50) - (Distance / 2) + Random Number(0 to 55)   
Defense Strength (DS) = Psi Strength + (Psi Skill / 5 ) + Difficulty 

   If AS > DS then psi attack is successful
   
   Where:
      Distance is the number of tiles between the attacker and defender.
      Random Number is a dice roll that produces a value between 0 and 55
      Difficulty represents the difficulty of the attack mode. Mind Control = 30, Panic = 1

However, I have some doubts—armor stats list it differently (taking psi skill, morale, bravery into account for defense)... In short, how should resistance to attacks versus attack strength be calculated?

Recently, some random cultist took mind control over a soldier with PSI STR >70 (though only lightly trained with 30 BRV and nome PSI Skil but full morale).

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9079
    • View Profile
Re: PSI defence & attack formula?
« Reply #1 on: November 13, 2024, 05:58:33 pm »
The default unmodded formula is the same.

Mods can decide to change the "psiDefence" per armor (of the victim) from "Psi Strength + (Psi Skill / 5 )" to anything else.
Mods can decide to change the "accuracyMultiplier" per weapon (of the attacker) from "(Psi Strength * Psi Skill / 50)" to anything else.
Mods can decide to change the Difficulty per weapon.
Mods can decide to modify the dropoff by range per weapon.
And if that is not enough, mods can decide to ignore everything and create their own formula by a script.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9079
    • View Profile
Re: PSI defence & attack formula?
« Reply #2 on: November 14, 2024, 12:08:02 am »
Also "(Distance / 2)" in that formula should be just "Distance".

People who documented or decompiled or both, were a bit hasty here.
The original code does say something like "getDistance(parameters) / 2", but the getDistance function doesn't return the actual distance, it returns double the distance.
And double the distance divided by two, is just distance.

Lastly, you copypasted it incorrectly... the constant for Panic is 10, not 1

Offline Stone Lake

  • Colonel
  • ****
  • Posts: 183
    • View Profile
Re: PSI defence & attack formula?
« Reply #3 on: November 14, 2024, 05:52:19 am »
(for most chars, sans demons and robots)
PSATK = 0.02 * PSK * PST + bonus + RNG[0, 55] – distance
PSDEF = PST + 0.4 PSK + 0.33 Morale + 0.2 Bravery
PSATK's 0.02 is replaced by 0.14/0.24 for hybrid psi / multiphase amp, and IIRC, for skulljack's PSATK it's different altogether.

You can view weapon accuracy / nearly actual PSI attack value while selecting action in battlescape and holding ALT (or is it now always displayed?). IIRC, the indicator assumes and subtracts 30 PSDEF, so there's a bit of an error.

Quote
Recently, some random cultist took mind control over a soldier with PSI STR >70 (though only lightly trained with 30 BRV and nome PSI Skil but full morale).
...What? What cult? Never saw this happen. Generally, 70 PST is hard to control for Ethereals, much less random cultists.
« Last Edit: November 14, 2024, 05:56:30 am by Stone Lake »

Offline sirmik

  • Sergeant
  • **
  • Posts: 20
    • View Profile
Re: PSI defence & attack formula?
« Reply #4 on: November 14, 2024, 01:34:39 pm »
(for most chars, sans demons and robots)
PSATK = 0.02 * PSK * PST + bonus + RNG[0, 55] – distance
PSDEF = PST + 0.4 PSK + 0.33 Morale + 0.2 Bravery
PSATK's 0.02 is replaced by 0.14/0.24 for hybrid psi / multiphase amp, and IIRC, for skulljack's PSATK it's different altogether.

You can view weapon accuracy / nearly actual PSI attack value while selecting action in battlescape and holding ALT (or is it now always displayed?). IIRC, the indicator assumes and subtracts 30 PSDEF, so there's a bit of an error.
...What? What cult? Never saw this happen. Generally, 70 PST is hard to control for Ethereals, much less random cultists.

THX!

I was also surprised. The 'cultist warehouse' mission—I assume it's those in the red-bordered robes Dagon guys —previously they also took control of a soldier with around 50 PSI, but I figured it was just a fluke. Maybe it’s a matter of sub-mods, as I’m playing with random enemy stats, but the ranges and bad luck with RNG would have to be dreadful


Offline psavola

  • Commander
  • *****
  • Posts: 827
    • View Profile
Re: PSI defence & attack formula?
« Reply #5 on: November 14, 2024, 04:14:16 pm »
PSATK = 0.02 * PSK * PST + bonus + RNG[0, 55] – distance
...
PSATK's 0.02 is replaced by 0.14/0.24 for hybrid psi / multiphase amp, and IIRC, for skulljack's PSATK it's different altogether.

A small typo here. You mean 0.024 for multiphase anp and 0.014 for hybrid psi. Otherwise multiphase would be over an order of magnitude more potent than the regular psi-amp. So the multi-phased psi-amp is slightly more effective than the regular one (and hybrid internal less effective). But the cost of using multiphased psi-amp probably offsets that benefit and it is more preferable to use the regular one when you can.


Offline Stone Lake

  • Colonel
  • ****
  • Posts: 183
    • View Profile
Re: PSI defence & attack formula?
« Reply #6 on: November 14, 2024, 05:08:56 pm »
Quote
I was also surprised. The 'cultist warehouse' mission—I assume it's those in the red-bordered robes Dagon guys —previously they also took control of a soldier with around 50 PSI, but I figured it was just a fluke. Maybe it’s a matter of sub-mods, as I’m playing with random enemy stats, but the ranges and bad luck with RNG would have to be dreadful
I guess sorcerers then? They have psi. And somewhat strong at that, albeit I've never seen them using it.
https://xcf.trigramreactor.net/master/article/STR_SORCERER_OF_DAGON


Quote
So the multi-phased psi-amp is slightly more effective than the regular one (and hybrid internal less effective).
Well, "slightly more effective" AND no los requirement kinda goes a long way here. So I tend to prefer multiphase in most cases.