Jump to content

Triggering destroy() on the ON DESTROY event removes multiple units


Recommended Posts

I'm trying to remove objects from the map when that specific unit is destroyed using a script.

 

My trigger looks like this:

 

Trigger: 1 ONCE (remove object 1, ON DESTROY)

 

Condition: UNIT DEAD(Static object #1)

 

Action: DO SCRIPT(StaticObject.ge)

 

Script: StaticObject.getByName('Static object #1'):destroy()

 

I'm using multiple triggers like the one above for different static objects, and I'm wanting to remove only the unit that was destroyed, while keeping the others on the map. The issue I'm running into is that whenever anything gets destroyed, ALL the objects get destroyed. Any help or notice what I'm doing wrong?

Modules owned:

 

FC3, M-2000C, Mig-21bis, F-5E, AJS-37 Viggen, F/A-18C, KA-50, Mi-8, F-14A&B, JF-17

Link to post
Share on other sites

The on destroy event setting is limiting when that check will be run. Literally anytime someone is destroyed it'll run that check, not necessarily if that specific unit you are checking was killed. Also you can't remove the wrecks of any objects that are destroyed, so that script won't work. As for why it is removing other objects, that does sound weird. Make sure all the object names reference the individual object you actually want to remove and within the condition for each. Could add a message for each to see if they are getting triggered or if for some reason StaticObject.getByName('someObject'):destroy() is destroying other objects, then please attach the mission.

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...