Adding auto turrets onto destroyable objects

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
kiprobin
First Lance Corporal
First Lance Corporal
Posts: 120
Joined: Wed Dec 11, 2019 3:52 pm
Projects :: Trench War
Games I'm Playing :: Swbf2
xbox live or psn: No gamertag set

Adding auto turrets onto destroyable objects

Post by kiprobin »

I added a destroyable frigate ship onto a ground map, and i put some auto turrets on it. Everything works fine, except when the frigate is destroyed, the auto turrets I put on it are still floating there. Does anyone know how to make it so that the auto turrets are destroyed when the frigate they're attached to is destroyed?
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: Adding auto turrets onto destroyable objects

Post by AnthonyBF2 »

Code: Select all

OnObjectKillName(
		function(object, killer)
			KillObject("imptur1")
			KillObject("imptur2")
			KillObject("imptur3")
			KillObject("imptur4")
		end,
		"impturretmain"
	)
Paste this code in your map script after ScriptPostLoad()
impturretmain = change to the name of your frigate object (instance name, not ODF name)
Add or remove more KillObject() lines to match the number of items you want to kill, with each line targeting another turret's instance name.
kiprobin
First Lance Corporal
First Lance Corporal
Posts: 120
Joined: Wed Dec 11, 2019 3:52 pm
Projects :: Trench War
Games I'm Playing :: Swbf2
xbox live or psn: No gamertag set

Re: Adding auto turrets onto destroyable objects

Post by kiprobin »

Works like a charm! Thank you very much!
Post Reply