Scripting Animated Props(ex. retractable bridge)
Posted: Tue Jul 18, 2006 3:38 pm
I just don't understand how to animate props using the scripting system. I've looked at some examples(death star bridges, the kasyykk door), but it just doesn't make any sense how they work.
Here is how the problem lays out.
Sea Door on Kasyykkk
[GameObjectClass]
ClassLabel = "prop"
GeometryName = "kas2_prop_sea_walldoor.msh"
[Properties]
GeometryName = "kas2_prop_sea_walldoor"
The panel you shoot to raise the gate
[GameObjectClass]
ClassLabel = "destructablebuilding"
GeometryName = "kas2_prop_door_mech.msh"
[Properties]
GeometryName = "kas2_prop_door_mech"
DestroyedGeometryName = "kas2_prop_door_mech_destroyed"
ExplosionName = "com_inf_rechargedroid_exp"
MaxHealth = 120
TargetPointOffset = "0 -1 -1.8"
FoleyFXGroup = "metal_foley"
[InstanceProperties]
CaptureRegion = ""
ControlRegion = ""
KillRegion = ""
SpawnPath = ""
AllyPath = ""
AllyCount = 65536
Radius = 0.0
ValueBleed = 10
Value_ATK_Alliance = 0
Value_ATK_CIS = 1000
Value_ATK_Empire = 0
Value_ATK_Republic = 0
Value_DEF_Alliance = 0
Value_DEF_CIS = 1000
Value_DEF_Empire = 0
Value_DEF_Republic = 0
Value_DEF_Locals = 0
VO_All_AllCapture = ""
VO_All_AllLost = ""
VO_All_AllInDispute = ""
VO_All_AllSaved = ""
VO_All_AllInfo = ""
VO_All_ImpCapture = ""
VO_All_ImpLost = ""
VO_All_ImpInDispute = ""
VO_All_ImpSaved = ""
VO_All_ImpInfo = ""
VO_Imp_AllCapture = ""
VO_Imp_AllLost = ""
VO_Imp_AllInDispute = ""
VO_Imp_AllSaved = ""
VO_Imp_AllInfo = ""
VO_Imp_ImpCapture = ""
VO_Imp_ImpLost = ""
VO_Imp_ImpInDispute = ""
VO_Imp_ImpSaved = ""
VO_Imp_ImpInfo = ""
VO_Rep_RepCapture = ""
VO_Rep_RepLost = ""
VO_Rep_RepInDispute = ""
VO_Rep_RepSaved = ""
VO_Rep_RepInfo = ""
VO_Rep_CISCapture = ""
and finally info in the lua that makes it work
function ScriptPostLoad()
AddDeathRegion("deathregion")
AddDeathRegion("deathregion2")
EnableSPHeroRules()
--CP SETUP for CONQUEST
cp1 = CommandPost:New{name = "CP1CON"}
cp3 = CommandPost:New{name = "CP3CON"}
cp4 = CommandPost:New{name = "CP4CON"}
cp5 = CommandPost:New{name = "CP5CON"}
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, textATT = "game.modes.con", textDEF = "game.modes.con2", multiplayerRules = true}
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
conquest:AddCommandPost(cp5)
conquest.OnStart = function(self)
conquest.goal1 = AddAIGoal(REP, "Defend", 30, "gatepanel")
conquest.goal2 = AddAIGoal(CIS, "Destroy", 30, "gatepanel")
conquest.goal3 = AddAIGoal(CIS, "Destroy", 10, "woodl")
conquest.goal4 = AddAIGoal(CIS, "Destroy", 10, "woodc")
conquest.goal5 = AddAIGoal(CIS, "Destroy", 10, "woodr")
conquest.goal6 = AddAIGoal(REP, "Defend", 10, "woodl")
conquest.goal7 = AddAIGoal(REP, "Defend", 10, "woodc")
conquest.goal8 = AddAIGoal(REP, "Defend", 10, "woodr")
end
conquest:Start()
--Gate Stuff --
BlockPlanningGraphArcs("seawall1")
BlockPlanningGraphArcs("woodl")
BlockPlanningGraphArcs("woodc")
BlockPlanningGraphArcs("woodr")
DisableBarriers("disableme");
SetProperty("woodl", "MaxHealth", 15000)
SetProperty("woodl", "CurHealth", 15000)
SetProperty("woodr", "MaxHealth", 15000)
SetProperty("woodr", "CurHealth", 15000)
SetProperty("woodc", "MaxHealth", 15000)
SetProperty("woodc", "CurHealth", 15000)
SetProperty("gatepanel", "MaxHealth", 1000)
SetProperty("gatepanel", "CurHealth", 1000)
OnObjectKillName(PlayAnimDown, "gatepanel");
OnObjectRespawnName(PlayAnimUp, "gatepanel");
OnObjectKillName(woodl, "woodl");
OnObjectKillName(woodc, "woodc");
OnObjectKillName(woodr, "woodr");
OnObjectRespawnName(woodlr, "woodl");
OnObjectRespawnName(woodcr, "woodc");
OnObjectRespawnName(woodrr, "woodr");
end
function PlayAnimDown()
PauseAnimation("thegateup");
RewindAnimation("thegatedown");
PlayAnimation("thegatedown");
ShowMessageText("level.kas2.objectives.gateopen",1)
ScriptCB_SndPlaySound("KAS_obj_13")
SetProperty("gatepanel", "MaxHealth", 2200)
-- SetProperty("gatepanel", "CurHealth", 50000)
-- PlayAnimation("gatepanel");
--SetProperty("gatepanel", "MaxHealth", 1e+37)
--SetProperty("gatepanel", "CurHealth", 1e+37)
-- Allowing AI to run under gate
UnblockPlanningGraphArcs("seawall1");
DisableBarriers("seawalldoor1");
DisableBarriers("vehicleblocker");
end
function PlayAnimUp()
PauseAnimation("thegatedown");
RewindAnimation("thegateup");
PlayAnimation("thegateup");
-- Allowing AI to run under gate
BlockPlanningGraphArcs("seawall1");
EnableBarriers("seawalldoor1");
EnableBarriers("vehicleblocker");
SetProperty("gatepanel", "MaxHealth", 1000)
SetProperty("gatepanel", "CurHealth", 1000)
end
btw, ingame the gate is named "gate01", and the panel is named "gatepanel"
Now, I understand how the process works, like calling the different fuctions and the different entires. The problem is what's in green. Where did they get these animations? It's not listed in the gate odf, as well as there is nothing in the LUA that directly points to the gate and tells it to use that animation. Also, I was unable to find any animation file relating to the animations. Where did it come from? and how do I harness it for my own use? Hopefully there is some simple solution or i'm just overlooking something.
Here is how the problem lays out.
Sea Door on Kasyykkk
[GameObjectClass]
ClassLabel = "prop"
GeometryName = "kas2_prop_sea_walldoor.msh"
[Properties]
GeometryName = "kas2_prop_sea_walldoor"
The panel you shoot to raise the gate
[GameObjectClass]
ClassLabel = "destructablebuilding"
GeometryName = "kas2_prop_door_mech.msh"
[Properties]
GeometryName = "kas2_prop_door_mech"
DestroyedGeometryName = "kas2_prop_door_mech_destroyed"
ExplosionName = "com_inf_rechargedroid_exp"
MaxHealth = 120
TargetPointOffset = "0 -1 -1.8"
FoleyFXGroup = "metal_foley"
[InstanceProperties]
CaptureRegion = ""
ControlRegion = ""
KillRegion = ""
SpawnPath = ""
AllyPath = ""
AllyCount = 65536
Radius = 0.0
ValueBleed = 10
Value_ATK_Alliance = 0
Value_ATK_CIS = 1000
Value_ATK_Empire = 0
Value_ATK_Republic = 0
Value_DEF_Alliance = 0
Value_DEF_CIS = 1000
Value_DEF_Empire = 0
Value_DEF_Republic = 0
Value_DEF_Locals = 0
VO_All_AllCapture = ""
VO_All_AllLost = ""
VO_All_AllInDispute = ""
VO_All_AllSaved = ""
VO_All_AllInfo = ""
VO_All_ImpCapture = ""
VO_All_ImpLost = ""
VO_All_ImpInDispute = ""
VO_All_ImpSaved = ""
VO_All_ImpInfo = ""
VO_Imp_AllCapture = ""
VO_Imp_AllLost = ""
VO_Imp_AllInDispute = ""
VO_Imp_AllSaved = ""
VO_Imp_AllInfo = ""
VO_Imp_ImpCapture = ""
VO_Imp_ImpLost = ""
VO_Imp_ImpInDispute = ""
VO_Imp_ImpSaved = ""
VO_Imp_ImpInfo = ""
VO_Rep_RepCapture = ""
VO_Rep_RepLost = ""
VO_Rep_RepInDispute = ""
VO_Rep_RepSaved = ""
VO_Rep_RepInfo = ""
VO_Rep_CISCapture = ""
and finally info in the lua that makes it work
function ScriptPostLoad()
AddDeathRegion("deathregion")
AddDeathRegion("deathregion2")
EnableSPHeroRules()
--CP SETUP for CONQUEST
cp1 = CommandPost:New{name = "CP1CON"}
cp3 = CommandPost:New{name = "CP3CON"}
cp4 = CommandPost:New{name = "CP4CON"}
cp5 = CommandPost:New{name = "CP5CON"}
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, textATT = "game.modes.con", textDEF = "game.modes.con2", multiplayerRules = true}
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
conquest:AddCommandPost(cp5)
conquest.OnStart = function(self)
conquest.goal1 = AddAIGoal(REP, "Defend", 30, "gatepanel")
conquest.goal2 = AddAIGoal(CIS, "Destroy", 30, "gatepanel")
conquest.goal3 = AddAIGoal(CIS, "Destroy", 10, "woodl")
conquest.goal4 = AddAIGoal(CIS, "Destroy", 10, "woodc")
conquest.goal5 = AddAIGoal(CIS, "Destroy", 10, "woodr")
conquest.goal6 = AddAIGoal(REP, "Defend", 10, "woodl")
conquest.goal7 = AddAIGoal(REP, "Defend", 10, "woodc")
conquest.goal8 = AddAIGoal(REP, "Defend", 10, "woodr")
end
conquest:Start()
--Gate Stuff --
BlockPlanningGraphArcs("seawall1")
BlockPlanningGraphArcs("woodl")
BlockPlanningGraphArcs("woodc")
BlockPlanningGraphArcs("woodr")
DisableBarriers("disableme");
SetProperty("woodl", "MaxHealth", 15000)
SetProperty("woodl", "CurHealth", 15000)
SetProperty("woodr", "MaxHealth", 15000)
SetProperty("woodr", "CurHealth", 15000)
SetProperty("woodc", "MaxHealth", 15000)
SetProperty("woodc", "CurHealth", 15000)
SetProperty("gatepanel", "MaxHealth", 1000)
SetProperty("gatepanel", "CurHealth", 1000)
OnObjectKillName(PlayAnimDown, "gatepanel");
OnObjectRespawnName(PlayAnimUp, "gatepanel");
OnObjectKillName(woodl, "woodl");
OnObjectKillName(woodc, "woodc");
OnObjectKillName(woodr, "woodr");
OnObjectRespawnName(woodlr, "woodl");
OnObjectRespawnName(woodcr, "woodc");
OnObjectRespawnName(woodrr, "woodr");
end
function PlayAnimDown()
PauseAnimation("thegateup");
RewindAnimation("thegatedown");
PlayAnimation("thegatedown");
ShowMessageText("level.kas2.objectives.gateopen",1)
ScriptCB_SndPlaySound("KAS_obj_13")
SetProperty("gatepanel", "MaxHealth", 2200)
-- SetProperty("gatepanel", "CurHealth", 50000)
-- PlayAnimation("gatepanel");
--SetProperty("gatepanel", "MaxHealth", 1e+37)
--SetProperty("gatepanel", "CurHealth", 1e+37)
-- Allowing AI to run under gate
UnblockPlanningGraphArcs("seawall1");
DisableBarriers("seawalldoor1");
DisableBarriers("vehicleblocker");
end
function PlayAnimUp()
PauseAnimation("thegatedown");
RewindAnimation("thegateup");
PlayAnimation("thegateup");
-- Allowing AI to run under gate
BlockPlanningGraphArcs("seawall1");
EnableBarriers("seawalldoor1");
EnableBarriers("vehicleblocker");
SetProperty("gatepanel", "MaxHealth", 1000)
SetProperty("gatepanel", "CurHealth", 1000)
end
btw, ingame the gate is named "gate01", and the panel is named "gatepanel"
Now, I understand how the process works, like calling the different fuctions and the different entires. The problem is what's in green. Where did they get these animations? It's not listed in the gate odf, as well as there is nothing in the LUA that directly points to the gate and tells it to use that animation. Also, I was unable to find any animation file relating to the animations. Where did it come from? and how do I harness it for my own use? Hopefully there is some simple solution or i'm just overlooking something.