Hello. I am trying to do something similar to what I described in this post:
https://openxcom.org/forum/index.php/topic,7987.msg124573.html#msg124573I have gotten stuck trying to call the variable unit.getMorale and using it.
I have no idea why. it is being called and used only about 12 lines up in another script using a very similar hook.
unit.getMoraleMax seems to be working just fine.
these are the edits I'm trying to make:
from scripts_XCOMFILES.rul
newTurnUnit:
- offset: 1
code: |
#add morale and energy totals for calculating readiness
var int moraleLostTurn;
var int energySpentTurn;
var int currentMorale;
var int currentEnergy;
unit.getMoraleMax moraleLostTurn;
unit.getEnergyMax energySpentTurn;
unit.getMorale currentMorale;
unit.getEnergy currentEnergy;
sub moraleLostTurn unit.getMorale;
sub energySpentTurn unit.getEnergy;
unit.setTag Tag.UNIT_TOTAL_MORALE_LOST moraleLostTurn;
unit.setTag Tag.UNIT_TOTAL_ENERGY_SPENT energySpentTurn;
debug_log "Total Morale Lost is now" UNIT_TOTAL_MORALE_LOST;
debug_log "Total Energy Spent is now" UNIT_TOTAL_ENERGY_SPENT;
and this is the error message I get in the log file:
[16-03-2020_07-06-48] [ERROR] Unknown argument 'unit.getMorale'
[16-03-2020_07-06-48] [ERROR] Error in matching arguments for operator 'sub'
[16-03-2020_07-06-48] [ERROR] Error in parsing script 'newTurnUnit' for 'Global Event Script': invalid operation in line: 'sub moraleLostTurn unit.getMorale;'