aliens

Author Topic: Option for alien morale loses based on rank  (Read 2202 times)

Online Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3360
    • View Profile
Option for alien morale loses based on rank
« on: April 24, 2023, 01:59:28 pm »
Allows aliens to have similar mechanic to xcom where when you kill leader you see big morale lose spike.
Currently in OXCE only aliens number affect theirs morale change.

Offline MaxMahem

  • Captain
  • ***
  • Posts: 60
    • View Profile
Re: Option for alien morale loses based on rank
« Reply #1 on: April 24, 2023, 03:12:54 pm »
Maybe best handled as a script hook? So arbitrary transformations could be performed. Something like, "OnAliedUnitDeath" or even "OnDeath." Which is called for every unit on the battlefield when a unit is killed.

Looking through BattlescapeGame::checkForCasualties, where most of this logic happens, a lot is happening here (and this method might be better broken up into smaller methods). But a script hook could be dropped around line 817 after most of the statistic work has been done, and the C++ code has determined who is dying and who the murderer might be.

Currently, there are two branches here, one to give the possible murderer a moral adjustment and one that iterates through all units and applies a moral adjustment to those units. But for purposes of a script, they could be unified into one hook since the possible murderer would be included in the set of all units anyways. I'm thinking the hook would look something like...

`OnDeath(const SaveBattleGame save, BattleUnit unit, int murderId, int victimFaction, const BattleUnit victim)`

The current logic could be transformed into a default script, or the hook could return a bool or some other object indicating whether the default logic should be run for this unit or not. This would allow both the current logic to be overridden and for arbitrary transformations to be done beyond just moral losses following a fixed formula.

I don't know how far you are in to doing this, but I'd be up for taking a crack at this if you like.

Online Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3360
    • View Profile
Re: Option for alien morale loses based on rank
« Reply #2 on: April 24, 2023, 05:24:12 pm »
This is probably too general and basic to make it script, this too need some fixes in engine anyway as current logic have inconsistencies.