The_Space_Cows
Chieftain
- Joined
- Mar 18, 2023
- Messages
- 19
I have a mod feature I've been working on where tiles improvements that provide defensive bonuses (forts, citadels and chateaus) give and additional +2 culture if there is a unit in the tile. When the unit leaves the tile by any means or the tile improvement is changed, the culture yield is removed from the tile.
I can detect when a unit moves using GameEvents.UnitSetXY, I can detect when a unit is killed using GameEvents.UnitPreKill (an event hook from another mod, DLL - Various Mod Components).
But if the player manually destroys the unit using the menu options, neither UnitSetXY nor UnitPreKill will trigger.
There is an event in the base game, Events.SerialEventUnitDestroyed which does trigger, but unfortunately the plot coordinates are not passed into the function. I could go the super inefficient route of checking every single tile within that player's borders for a tile improvement producing culture that it shouldn't be, but I thought maybe there was a better solution and I thought I'd ask.
Does anyone know of a better solution, involving less bashing my head against my keyboard?
I can detect when a unit moves using GameEvents.UnitSetXY, I can detect when a unit is killed using GameEvents.UnitPreKill (an event hook from another mod, DLL - Various Mod Components).
But if the player manually destroys the unit using the menu options, neither UnitSetXY nor UnitPreKill will trigger.
There is an event in the base game, Events.SerialEventUnitDestroyed which does trigger, but unfortunately the plot coordinates are not passed into the function. I could go the super inefficient route of checking every single tile within that player's borders for a tile improvement producing culture that it shouldn't be, but I thought maybe there was a better solution and I thought I'd ask.
Does anyone know of a better solution, involving less bashing my head against my keyboard?