Trigger animation on destruction of object? (FAQ)

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
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Trigger animation on destruction of object?

Post by Maveritchell »

Code: Select all

animateobja = OnObjectKill(
	function(object, killer)
		if GetEntityName(object) == "objectBnameinZeroEditor" then
			PlayAnimation("whateveranimationgroup")
		end
	end
)
Edit: And here's that part about giving points when you kill an object:

Code: Select all

killobjc = OnObjectKill(
	function(object, killer)
		if killer and IsCharacterHuman(killer) and GetEntityName(object) == "objectbeingkillednameinZeroEditor" then
			AddAssaultDestroyPoints(killer)
		end
	end
)
That first part ("killobjc") is the variable name assigned to this event. It can be whatever (unrelated) name you want, so long as you don't use the same name for another event or variable. The line "if...etc." is the conditional statement for giving points. "if killer" is checking to see whether the killer exists. Always add this before you add the line IsCharacterHuman(killer), to prevent crashes if a human kills themselves. "IsCharacterHuman(killer)" checks to see whether the killer was human. This way only humans will recieve points for killing the object. Remove this if you want. The last part of the if statement checks to make sure that the object-being-killed's "name" matches the name you assigned in ZE. This is not the name of the .odf, but the name you assigned in ZE. Sometimes they are the same but not always.
User avatar
ps2owner
Corporal
Corporal
Posts: 155
Joined: Wed Jun 23, 2010 8:25 pm

Re: Trigger animation on destruction of object? (FAQ)

Post by ps2owner »

sorry for the bumb but how would you rewind a animation when you fix an object
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: Trigger animation on destruction of object? (FAQ)

Post by DarthD.U.C.K. »

my guess:

Code: Select all

repairobja = OnObjectRepair(
   function(object, repairer/characterId?!)
      if GetEntityName(object) == "objectBnameinZeroEditor" then
         RespawnObject("reappearingobject")
         RewindAnimation("whateveranimationgroup")
      end
   end
)
Last edited by DarthD.U.C.K. on Sun Sep 19, 2010 5:40 am, edited 1 time in total.
User avatar
ps2owner
Corporal
Corporal
Posts: 155
Joined: Wed Jun 23, 2010 8:25 pm

Re: Trigger animation on destruction of object? (FAQ)

Post by ps2owner »

wouldn't it be
repairobja = OnObjectRepair(
function(object, repairer/characterId?!)
if GetEntityName(object) == "objectBnameinZeroEditor" then
RespawnObject("reappearingobject")
RewindAnimation("whateveranimationgroup")
end
end
)
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: Trigger animation on destruction of object? (FAQ)

Post by DarthD.U.C.K. »

yeah, you are right. i changed the code, thanks
User avatar
ps2owner
Corporal
Corporal
Posts: 155
Joined: Wed Jun 23, 2010 8:25 pm

Re: Trigger animation on destruction of object? (FAQ)

Post by ps2owner »

just to check is objectBnameinZeroEditor the object you repair and is
reappearingobject the object with the animation?
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: Trigger animation on destruction of object? (FAQ)

Post by DarthD.U.C.K. »

its the object you repair
User avatar
ps2owner
Corporal
Corporal
Posts: 155
Joined: Wed Jun 23, 2010 8:25 pm

Re: Trigger animation on destruction of object? (FAQ)

Post by ps2owner »

Sorry for the bump, but where and what file do I put this in.
(I got it working once, but I deleted that map, so I can't look through source files)
AQT
Gametoast Staff
Gametoast Staff
Posts: 4910
Joined: Sat Nov 03, 2007 4:55 pm
Location: SoCal, USA

Re: Trigger animation on destruction of object? (FAQ)

Post by AQT »

In the game mode LUA file after

Code: Select all

function ScriptPostLoad()
but before

Code: Select all

function ScriptInit()
Post Reply