We have this bug where if units lose maximum health somehow overland, they keep the same amount of damage, but the number of figures get recalculated and as damage>total health, it'll end up with zero (or negative) figures.
One of the causes of this is the Lion Heart item power. It's buggy and only grants the health bonus in combat.
I've looked into it but it cannot be fixed in a reasonably easy way, at least I can't do it.
The problem is caused by the procedure applying health only having access to the overland unit data, which is bad because items abilities are only in the "battle" unit data. Overland data only contains the ID of the hero, and the hero data contains the items, and the item data contains the enchantment.
There are two possible ways of solution I can think of.
-If enough space can be freed up in code in the same code segment anywhere (probably around 50+ bytes which are a LOT), it's possible to check for the item through the above mentioned data and apply the effect. This would most likely be a huge amount of work, and I actually don't know where the equipment of heroes are stored so I can't do it at the moment even if I do manage to make this much room.
-The other, the procedure that applies the item effects into the battle data is actually at near range and can be called...but I don't understand the required parameters well enough to even try that. We would also need to create a blank "dummy" battle data of a unit for this.
Either way, the "ghost unit" bug can be caused by other reasons, especially units losing the enchantment that grants the buff. As this cannot be avoided (and isn't even a bug), whether someone manages to fix Lionheart or not, the ghost bug needs to be fixed separately.
Which is where I'd like to ask if anyone has any idea how to handle this?
I think we would need to inject code somewhere that checks if the unit has more damage than health, and reduce the damage to the effective health minus one. Problem is..where. I know close to nothing about how the game handles overland damage and adding it to the wrong place would either not guarantee that the unit gets fixed before it is used or targeted by something, or it might even make it invincible to death through damage (if we put it before the game checks for leathal damage to delete dead units).
I definitely do not want my heroes or other units to enter battle with negative health...or to even exist like that considering in might have unexpected consequences that destabilize the game from division by zero to doing negative damage and whatnot.
...now that I think about it, we cannot even do "damage=max health-1"...as we don't know the max health, it isn't stored on the unit
Which pretty much leaves the unit's natural healing process, which needs to know the maximum health, the only place where this can be done...but that won't help units that get into combat between the disenchant and the end of that turn.
..or not...ghost units don't naturally heal as far as I know.
I'm out of ideas.
One of the causes of this is the Lion Heart item power. It's buggy and only grants the health bonus in combat.
I've looked into it but it cannot be fixed in a reasonably easy way, at least I can't do it.
The problem is caused by the procedure applying health only having access to the overland unit data, which is bad because items abilities are only in the "battle" unit data. Overland data only contains the ID of the hero, and the hero data contains the items, and the item data contains the enchantment.
There are two possible ways of solution I can think of.
-If enough space can be freed up in code in the same code segment anywhere (probably around 50+ bytes which are a LOT), it's possible to check for the item through the above mentioned data and apply the effect. This would most likely be a huge amount of work, and I actually don't know where the equipment of heroes are stored so I can't do it at the moment even if I do manage to make this much room.
-The other, the procedure that applies the item effects into the battle data is actually at near range and can be called...but I don't understand the required parameters well enough to even try that. We would also need to create a blank "dummy" battle data of a unit for this.
Either way, the "ghost unit" bug can be caused by other reasons, especially units losing the enchantment that grants the buff. As this cannot be avoided (and isn't even a bug), whether someone manages to fix Lionheart or not, the ghost bug needs to be fixed separately.
Which is where I'd like to ask if anyone has any idea how to handle this?
I think we would need to inject code somewhere that checks if the unit has more damage than health, and reduce the damage to the effective health minus one. Problem is..where. I know close to nothing about how the game handles overland damage and adding it to the wrong place would either not guarantee that the unit gets fixed before it is used or targeted by something, or it might even make it invincible to death through damage (if we put it before the game checks for leathal damage to delete dead units).
I definitely do not want my heroes or other units to enter battle with negative health...or to even exist like that considering in might have unexpected consequences that destabilize the game from division by zero to doing negative damage and whatnot.
...now that I think about it, we cannot even do "damage=max health-1"...as we don't know the max health, it isn't stored on the unit
Which pretty much leaves the unit's natural healing process, which needs to know the maximum health, the only place where this can be done...but that won't help units that get into combat between the disenchant and the end of that turn.
..or not...ghost units don't naturally heal as far as I know.
I'm out of ideas.