- Joined
- Jul 31, 2020
- Messages
- 103
Hi.
Probably sounds like a hot topic that comes up every now and then. I tried searching for a good answer, but, unfortunately, found nothing that could work in my situation.
Anyway, to explain what I'm talking about. Simply put: removed units. A bit more precisely, units which get removed over time after bone decay runs its course. Now, to the insightful, I don't have to explain what the problem is now, but to people who haven't encountered an issue like this before... Basically, once a unit fully decays, it's removed from the game, but not from unit groups. You might think, running a simple ForGroup or FirstOfGroup loop and hitting them with the old trusty GetUnitTypeId(GetEnumUnit()) == 0 would work. It won't. The reason for it is straightforward: neither loop will actually execute anything on these units since they're removed, therefore even FirstOfGroup would just return null once it finds them inside the group.
The other idea I entertained was hooking into RemoveUnit, and doing my thing there. Won't work either as the game doesn't actually call RemoveUnit from what I've observed when bone decay ends. I can't say how exactly the unit is removed in this case, but unluckily, I can't leverage RemoveUnit in this situation either.
I cannot use a unit indexer. Yes, I do understand -although I haven't seen it because it feels impossible to find one like it- they have something like onUnitDeindex or something similar. I vaguely remember reading this once. Now, if that somehow manages to catch a unit just as it's getting removed, and executes whatever code; that's what I'm looking for. How do we go about doing that?
Probably sounds like a hot topic that comes up every now and then. I tried searching for a good answer, but, unfortunately, found nothing that could work in my situation.
Anyway, to explain what I'm talking about. Simply put: removed units. A bit more precisely, units which get removed over time after bone decay runs its course. Now, to the insightful, I don't have to explain what the problem is now, but to people who haven't encountered an issue like this before... Basically, once a unit fully decays, it's removed from the game, but not from unit groups. You might think, running a simple ForGroup or FirstOfGroup loop and hitting them with the old trusty GetUnitTypeId(GetEnumUnit()) == 0 would work. It won't. The reason for it is straightforward: neither loop will actually execute anything on these units since they're removed, therefore even FirstOfGroup would just return null once it finds them inside the group.
The other idea I entertained was hooking into RemoveUnit, and doing my thing there. Won't work either as the game doesn't actually call RemoveUnit from what I've observed when bone decay ends. I can't say how exactly the unit is removed in this case, but unluckily, I can't leverage RemoveUnit in this situation either.
I cannot use a unit indexer. Yes, I do understand -although I haven't seen it because it feels impossible to find one like it- they have something like onUnitDeindex or something similar. I vaguely remember reading this once. Now, if that somehow manages to catch a unit just as it's getting removed, and executes whatever code; that's what I'm looking for. How do we go about doing that?