Author Topic: [Suggestion] Let scripted HP/Stun changes trigger damageSpecialUnit Hook  (Read 2614 times)

Offline Buscher

  • Colonel
  • ****
  • Posts: 168
    • View Profile
Currently I try to write a script for the Dune mod that does the following:

If anything with Laser damage type hits a unit with a personal shield equipped, the game rolls a chance to either explode the attacker, the target or both. Target works well as I use specabs together with damageSpecialUnit ("explode on Death"). Right now I am trying to kill the attacker with script commands including setHealth 0, setStun 999 or setSpawnUnit and neither trigger damageSpecialUnit (or damageUnit for that matter). Maybe there is a different solution but right now I feel like it would help if scripted based HP/stun/damage changes would also trigger damageSpecialUnit.

Could scripted HP changes be introduced and appended to this list from the Changelog for 7.4.2?

Thanks for reading and possible consideration.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
No, script damage is separated from normal damage handling.
You should consider it "raw" change of unit stats.
It will be hard to add option for this as `damageSpecialUnit` could damage same unit too, and we will have infinite loop.
There could be solution for this but this would require lot of work, and for now I simply prevent logic like this.

For problem at hand, this will be tricky as current scripts simply expose engine behaviors that exists before, adding options for attacker to explode require some
new code to handle it in engine. I will look on this but I do not give any guarantees that will be any solution for this.

Offline Buscher

  • Colonel
  • ****
  • Posts: 168
    • View Profile
Yeah, when sleeping over this again I also figured that you could turn this into a recursive loop or have some unexpected JMP instruction (setHealth -> function in damageSpecialUnit -> Continue). I can totally understand that this is not the desired solution as the error handling for it will be a pain.

As for writing code in the engine, this has no priority right now. It is a play-thing for the Land of Sand (Dune) mod. I can also do a crazy solution like putting an item in everyone's inventory which is primed and explodes next turn. Maybe this is another way: add a new trigger to 'fuseTriggerEvents' called something like 'fallOutOfInventoryExplode'  so when a primed item falls to the ground due to the unit dying, it would also explode. Is that approach more viable?

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Yes, some thing like this is possible, I once have tried to expand on fuse "Triggers" as was request to expand grenade explosions. When I have some time I will try back to it and see what would be easy to add.

Offline Buscher

  • Colonel
  • ****
  • Posts: 168
    • View Profile
That would be awesome.
In the meanwhile I settled for the attacker to die now and explode on the next turn. If you are curious you can take a peek here.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9092
    • View Profile
just FYI, this is not on my todolist, I leave it to Yankes