Page 1 of 1

Add event for when a unit_group is destroyed

Posted: Sun Jul 02, 2023 9:19 pm
by asher_sky
TL;DR
The ability to know when a unit group is destroyed, via something like defines.events.on_unit_group_destroyed or register_on_unit_group_destroyed()
Why ?
When a cutscene target dies or is destroyed, the camera abruptly teleports to 0,0. In my trainsaver mod, to prevent this I register the cutscene target entities with register_on_entity_destroyed() and restart the cutscene as appropriate when triggered. However there does not appear to be any event for when a unit_group is destroyed. I can potentially write some on_tick check to ensure the target is still valid, but that adds additional complications, and still leaves the potential for the camera to go to 0,0, even for just 1 tick. It would be much more simple to just have an event to listen to.

Re: Add event for when a unit_group is destroyed

Posted: Tue Aug 29, 2023 10:28 pm
by heyqule
This would be useful for enemy AI mods.

Re: Add event for when a unit_group is destroyed

Posted: Mon Dec 04, 2023 3:09 pm
by boskid
TLDR part is implemented for 2.0 as there was "register_on_object_destroyed" implemented that supports unit groups. It may be slightly tricky because it has the same limitations as register_on_entity_destroyed - depending on when unit group is destroyed, the event may be raised in current or next tick and there are some implementation details about unit groups as they transition through a "dead" state before being destroyed causing them to be no longer valid but not yet destroyed. Lets consider this implemented for 2.0 but once it will be out and you see some issues just open new topic describing what is wrong.