[Tutorial] Triggering an object animation through LUA

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
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

[Tutorial] Triggering an object animation through LUA

Post by DarthD.U.C.K. »

its easy to trigger a animation made in zero editor through lua but there is no such command to trigger animations of objects that were created in xsi.
the workaround is pretty easy but i decided to post it nonetheless. you can do really cool things with it, especially in combination with ze-animation, e.g. landing ships with deploying landinggear.

what you do is making an object with a deathanimation that you kill through lua to trigger the animation.
what you need first is a working animationset for the object. you need two animations:
-the idle animation, with the object in the pose before the triggered animation. e.g. the ship flying
-the death animation, the animation that you want to trigger. e.g. the ship with the ladinggear deploying
in the msh.file should have the object in the pose after the triggered animation. e.g. the ship with the landinggear deployed.

here is an example odf for the object:

Code: Select all

[GameObjectClass]       
ClassLabel      =   "animatedbuilding"
GeometryName    =   "ship.msh"

[Properties]        
GeometryName	=   "ship"
DestroyedGeometryName = "ship"
MaxHealth 		= "1000"		//the value doesnt matter

AnimationName   =   "ship"		//the name of the animset
IdleAnimation   =   "flying"	//the first animation
DeathAnimation  =   "landing"	//animation that will be triggered

AINoRepair      = "1"			//necessary, if the ai is able to reach it

HideHealthBar	= "1"			//these two values prevent the player from
IsNotTargetableByPlayer = "1"	//recognizing this as an destroyable object

FoleyFXGroup    = "metal_foley"
now to the lua, under scriptpostload you should add these lines to prevent the object from being killed before you trigger the animation:

Code: Select all

	--ship setup--
	SetProperty("ship", "MaxHealth", 1e+37) --give the object an infinite healthlimit
    SetProperty("ship", "CurHealth", 1e+37)	--and unlimited health
	SetAIDamageThreshold("ship", 0.0) --preventing the ai from damaging it, just to be sure
now all you have to do to play the animation is putting this line in the event that should trigger the animation, like:

Code: Select all

	OnWhatever(
        function(something)
			SetProperty("ship", "CurHealth", "0") --trigger the animation
        end,
        somename
    )
thats all you have to do, if you have trouble with the destroyed model(like animated pieces missing or at 0.0.0), make a seperate model for the destroyed geometry.

i hope this will be helpfull to somebody sometime..
Last edited by DarthD.U.C.K. on Mon Nov 21, 2011 6:37 pm, edited 3 times in total.
THEWULFMAN
Space Ranger
Posts: 5557
Joined: Tue Aug 17, 2010 3:30 pm
Projects :: Evolved 2
Location: Columbus, Ohio
Contact:

Re: [Tutorial] Triggering an object animation through LUAaaa

Post by THEWULFMAN »

Awesome workaround. I think Firefang and I had toyed with a similar idea, but we never got around to really testing anything. Nice job. :thumbs:
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: [Tutorial] Triggering an object animation through LUA

Post by kinetosimpetus »

*adds to bookmarks*
User avatar
naru1305
Major General
Major General
Posts: 657
Joined: Fri Jan 07, 2011 4:57 pm
Games I'm Playing :: SWBF2
Location: Germany
Contact:

Re: [Tutorial] Triggering an object animation through LUA

Post by naru1305 »

aha, you figured it out, thx man, it will be verry helpful for me :D
DarthD.U.C.K. wrote:e.g. landing ships with deploying landinggear.
yeah, yeah, my acclamator and coreship anim...
Post Reply