Hi I need to access the children of an entity and free them before I free the entity itself so I can make sure no-one is chasing any of the children,
here is my function which calls itself:
it works o.k. for entities that have turrets attached but not for other children that use the s\parent field.
here is my function which calls itself:
Function set_childs_target_to_zero(ship) For s.ship=Each ship If s\turret_attached=ship set_childs_target_to_zero(s\ship_handle) Set_Target_To_Zero(s\ship_handle) FreeEntity s\ship_handle Delete s EndIf Next For s.ship=Each ship If s\parent=ship set_childs_target_to_zero(s\ship_handle) Set_Target_To_Zero(s\ship_handle) FreeEntity s\ship_handle Delete s EndIf Next End Function
it works o.k. for entities that have turrets attached but not for other children that use the s\parent field.