(December 21st, 2022, 05:32)Anskiy Wrote: Someone came up with some suggestions for optimizing scripts exposed to modding, I hope Seravy finds them useful: https://www.realmsbeyond.net/forums/show...#pid819433
It pretty much already works like that - unit data is stored as base values and current values both.
Recalculation is done (including script) only on trigger conditions which can be one of two categories - either all units on a specific map tile are recalculated (for effects that affect a tile or a single unit - due to abilities like Holy Bonus the entire tile needs to be calculated either way) - or every unit in the game (for global effects). (There is also a third category, recalculate every unit in combat but that's pretty much the same as doing it for the tile where the combat takes place)
However trigger conditions are numerous so it has to be done often anyway. For example, anyone moves a unit, the source and destination tile needs to be recalculated. Anyone casts or cancels a global enchantment, every unit has to, etc