This poison script created by Yankes looks very useful.
I have a few questions about how it is used.
(Question #1):
Which *.rul file does it need to be in to function?
Can I place it in its own PoisonScript.rul file or does it need to be in the same file as the *.rul that has the items: section in it?
No, only this part need be copy-pasted to any file that want interact with this script:
extended:
tags:
RuleItem:
POISON_STRENGTH: int
RuleArmor:
POISON_SUSCEPTIBILITY: int
BattleUnit:
POISON_LEVEL: int
(Question #2):
I'm guessing that the variable POISON_STRENGTH: on the item and POISON_SUSCEPTIBILITY: on the unit armor determine how much HP is lost by a poisoned unit per turn and either the number of turns the unit is poisoned or a resistance to the applied poison effect, I'm not sure exactly which from trying to read the code.
How do this work?
mul strength susceptibility;
div strength 10;
unit.getTag temp Tag.POISON_LEVEL;
if lt temp strength;
unit.setTag Tag.POISON_LEVEL strength;
end;
This part set current poison level on unit custom variable.
unit.getHealth hp;
sub hp poison;
unit.setHealth hp;
This part change unit HP of given unit.
Both part can be changes to fit your needs or balance (right now is dumb version where damage tick with 5,4,3,2,1 values).
(Question #3):
Although the above question may answer this, I'll ask directly as it would be odd to see mechanical tanks succumbing to the effects of poisoning.
Is it possible to prevent a unit from being able to be afflicted with the poison script's effects?
`POISON_SUSCEPTIBILITY` if it 0 it will make unit unit immune to poison, or you can add check if unit is 2x2 or some thing like that.
(Question #4):
If a unit is already poisoned and is afflicted with poison again, what happens?
. Does it overwrite the Poison with the new value?
. Does it overwrite the Poison with the highest value?
. Does increase the value of the Poison by combining both?
. Do the instances of Poison stack each running separately?
. Or can a unit already effected by poison not be poisoned further?
only one poison effect, and bigger win. Overall engine only allow fixed number of variables this mean you can't create in scripts multiple same effects that do work in parallel.
(Question #5):
The words recolorUnitSprite: seem to suggest that the poisoned unit will display its affliction by shifting colour to a greenish tint.
Is it possible to cause this effect to display as other colours? (Red/Blue/Yellow)
if gt poison 0;
set_color new_pixel 4; #green color
end;
set any value instead of `4` and you will have your color (see Ufo palettes to see what colors are available).
(Question #6):
Can a poisoned unit be cured of the poison effect, or must it run its course once inflicted?
For example by a medkit?
medkit? no, another bullet? yes.
Some script need set `unit.setTag Tag.POISON_LEVEL 0;`
As medkits are not scripted, they cant affect it, when someone add hooks for them then it will be able to do this.
(Question #7):
Is it possible to have several versions of this script running simultaneously if these three varables are renamed in an additional copy of the script which is also present in a *.rul file along side the original?
POISON_STRENGTH:
POISON_SUSCEPTIBILITY:
POISON_LEVEL:
For example:
POISON_STRENGTH_B:
POISON_SUSCEPTIBILITY_B:
POISON_LEVEL_B:
If that is possible and the scripts unit affliction display colour can be altered then one version of the script could cause an effected unit to become green coloured when hit while others could switch to different colours representing other damaging afflictions.
(Also they would both have separate instances of damage if applied to the same unit.)
This would be very useful.
If you copy paste it and replace variable names then yes. Probably easier would be alter current script and add logic to it to check for both version.
Overall it will be useful in `recolorUnitSprite` to reduce script competition for unit color, it could even check if unit have both poison types to even further change unit color.