Because you spend last charge, if you block it, game would not remove your item.
Probably most correct way to do it is set `medikit_action_type` to zero if you are prevented doing any thing.
Could you give me an example?
What I need:
I check some condition through "if ... else ... end".
If the condition is "true", the medikit should disappear and the soldier should spend TU and energy to use the medikit (according to the "costUse" block of the item).
If the condition is "false", nothing should happen, the soldier should not waste TU and energy on using the medikit.
What I've done:
If the condition is "true" the medikit is used according to the rules of the game - it disappears, and the soldier spends TU and energy.
If the condition is "false", I restore the charge to the medikit and return the spent TU and energy to the soldier:
healUnit:
- offset: 1
code: |
var int CurrEnergy 0;
var int CurrTU 0;
...
if ...
...
else ...
actor.getEnergy CurrEnergy;
actor.getTimeUnits CurrTU;
add CurrEnergy 10;
add CurrTU 40;
item.setStimulantQuantity 1;
actor.setEnergy CurrEnergy;
actor.setTimeUnits CurrTU;
end;