Playing an animation after a timer ends (Solved)
Posted: Tue Dec 30, 2008 8:21 pm
by ThePanda
I've tried my hand at creating a timer that triggers an animation upon ending. I've taken a look through the scripting system document, and compared it with some shipped scripts, but I've not got anywhere.
Help would be appreciated
Area highlighted in blue. Also, have I added in an extra end in there somewhere? My objectives don't seem to continue after I take the CP anymore.
Help would be appreciated
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
-- SPAX - Clone Wars Template Assault File
--
ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("KY1c_cmn")
---- load the gametype script
ScriptCB_DoFile("ObjectiveConquest")-- This is about capturing CP's
ScriptCB_DoFile("MultiObjectiveContainer")-- I'm not sure what this is for, but it is included in Almost all the Campaign missions
ScriptCB_DoFile("ObjectiveGoto")-- well this speaks for it'selve
ScriptCB_DoFile("ObjectiveAssault")-- something to do with killing units?
ScriptCB_SetGameRules("campaign")
-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
-- These variables do not change
ATT = REP;
DEF = CIS;
myGameMode = "KY1_CW-Assault"
function myScriptInit()
ClearWalkers()
AddWalkerType(3, 1)
SetMemoryPoolSize("CommandFlyer", 2)
SetMemoryPoolSize("CommandWalker", 1)
end
function ScriptPostLoad()
ScriptCB_SetGameRules("campaign")-- Here you can see a script being used; The script to define the gameRules(of wich I don't really know what they do EXACTLY)
SetAIDifficulty(0, 0, "medium")-- I'd say this influences the dumbness of the A.I. to compensate for difficult maps.
DisableAIAutoBalance()--Help requested on explaining this
OnEnterRegion(
function(regIn,character)
MoveEntityToNode(character,"teleportnodes")
end,
"accteleport"
)
ActivateRegion("accteleport")
KillObject("rep-cp4-acc3")
SetProperty("cis-cp2", "Team", "2")
SetProperty("rep-cp2-acc", "Team", "1")
SetProperty("cis-cp2", "Value_ATK_Republic", "1000")
SetProperty("rep-cp1", "AISpawnWeight", "3")
SetProperty("rep-cp4-acc3", "AISpawnWeight", "3")
SetProperty("rep-cp2-acc", "AISpawnWeight", "1000")
SetProperty("rep-cp3-acc2", "AISpawnWeight", "3")
--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "rep-cp1"}
cp2 = CommandPost:New{name = "cis-cp1"}
cp3 = CommandPost:New{name = "rep-cp2-acc"}
--cp5 = CommandPost:New{name = "cis-cp2"}
cp4 = CommandPost:New{name = "rep-cp2"}
cp6 = CommandPost:New{name = "rep-cp3-acc2"}
cp7 = CommandPost:New{name = "rep-cp4-acc3"}
--cp5 = CommandPost:New{name = "rep-cp3"}
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
objectives_timer = CreateTimer("objectives_timer")
SetTimerValue(objectives_timer, 2)
StartTimer(objectives_timer)
begin_objectives = OnTimerElapse(
function(timer)
StartObjectives ()
ScriptCB_EnableCommandPostVO(0)
end,
objectives_timer
)
end
end
)
--Go to the Acclamator Hangar
Objective1 = ObjectiveGoto:New{TeamATT = ATT, TeamDEF = DEF,
text = "level.KY1.objectives.campaign.2", popupText = "level.KY1.objectives.popup.2",
regionName = "rep-cp2-acc-con", mapIcon = "hud_objective_icon_circle", AIGoalWeight = 0}
Objective1:AddHint("level.spa2.objectives.popup.2a")
Objective1:AddHint("level.spa2.objectives.popup.2b")
Objective1:AddHint("level.spa2.objectives.popup.2c")
Objective1.OnStart = function(self)
att_obj1_aigoal = AddAIGoal(ATT, "Deathmatch", 100)
def_obj1_aigoal = AddAIGoal(DEF, "Deathmatch", 100)
end
Objective1.OnComplete = function(self)
DeleteAIGoal(att_obj1_aigoal)
DeleteAIGoal(def_obj1_aigoal)
ShowMessageText("game.objectives.complete", ATT)
SetProperty("cis-cp2", "Team", "2")
SetUnitCount(REP, 50)
SetUnitCount(CIS, 32)
RespawnObject("rep-cp4-acc3")
end
--Take the CIS CP
Objective2CP = CommandPost:New{name = "cis-cp2"}
Objective2 = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, text = "level.KY1.objectives.campaign.3", popupText = "level.KY1.objectives.popup.3", AIGoalWeight = 0}
Objective2:AddCommandPost(Objective2CP)
Objective2:AddHint("level.geo1.hints.capture_cp")
Objective2.OnStart = function(self)
AICanCaptureCP("cis-cp2", ATT, true)
AICanCaptureCP("cis-cp2", DEF, false)
SetProperty("cis-cp2", "Value_DEF_CIS", "0")
SetProperty("cis-cp2", "Value_ATK_Republic", "1000")
SetProperty("rep-cp1", "SpawnPath", "rep-cp1spawn")
att_obj2_aigoal = AddAIGoal(ATT, "Defend", 50, "cis-cp2")
def_obj2_aigoal = AddAIGoal(DEF, "Defend", 10, "cis-cp2")
att_obj2_aigoal2 = AddAIGoal(ATT, "Deathmatch", 100)
def_obj2_aigoal2 = AddAIGoal(DEF, "Deathmatch", 100)
shipleave = CreateTimer("shipleave")
SetTimerValue(shipleave, 120)
StartTimer(shipleave)
shipretreat = OnTimerElapse(
function(timer)
if GetTimerValue(shipleave) == "0" then
PlayAnimationGroup("shipretreat")
end
end
)
end
Objective2.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
DeleteAIGoal(att_obj2_aigoal)
DeleteAIGoal(att_obj2_aigoal2)
DeleteAIGoal(def_obj2_aigoal)
DeleteAIGoal(def_obj2_aigoal2)
SetProperty("cis-cp2", "Team", 1)
SetProperty("cis-cp2", "CaptureRegion", "")
end
--Kill 5 fighters
ship_count = 5
objective4Ships = {"cis_fly_droidfighter_sc_auto", "cis_fly_tridroidfighter_auto", "cis_fly_fanblade_auto"}
Objective4= Objective:New{teamATT = ATT, teamDEF = DEF,
text = "level.KY1.objectives.campaign.4", popupText = "level.KY1.objectives.popup.4"}
Objective4.OnStart = function(self)
ScriptCB_SndPlaySound("SPA2_obj_58")
Objective4ShipKillStart(objective4Ships)
end
Objective4.OnComplete = function(self)
DeleteAIGoal(Objective4.Dclass_cpGoal1)
DeleteAIGoal(Objective4.Dclass_cpGoal2)
end
--Land back in the hangar
Objective5 = ObjectiveGoto:New{TeamATT = ATT, TeamDEF = DEF,
text = "level.KY1.objectives.campaign.5", popupText = "level.KY1.objectives.popup.5",
regionName = "rep-cp2-acc-con", mapIcon = "hud_objective_icon_circle", AIGoalWeight = 0}
Objective5:AddHint("level.geo1.hints.movement")
Objective5:AddHint("level.geo1.hints.obj_markers")
Objective5:AddHint("level.geo1.hints.review_objectives")
Objective5:AddHint("level.geo1.hints.sprint")
Objective5.OnStart = function(self)
att_obj5_aigoal = AddAIGoal(ATT, "Deathmatch", 100)
def_obj5_aigoal = AddAIGoal(DEF, "Deathmatch", 100)
MapAddEntityMarker("waz_rep_acc_hangar", "hud_objective_icon_circle", 3.0, 1, "YELLOW", true)
end
Objective5.OnComplete = function(self)
DeleteAIGoal(att_obj5_aigoal)
DeleteAIGoal(def_obj5_aigoal)
ShowMessageText("game.objectives.complete", ATT)
MapRemoveEntityMarker("waz_rep_acc_hangar")
end
--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamDEF = DEF,
textDEF = "game.modes.con2",
multiplayerRules = true}
--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
--conquest:AddCommandPost(cp5)
conquest:AddCommandPost(cp6)
conquest:AddCommandPost(cp7)
conquest:Start()
SetUberMode(1);
EnableSPHeroRules()
end
function StartObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 4.0 }
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2)
objectiveSequence:AddObjectiveSet(Objective4)
objectiveSequence:AddObjectiveSet(Objective5)
objectiveSequence:Start()
end
function Objective4ShipKillStart(shipClasses)
Objective4ShipKill = {} --reminder: don't reuse this variable name (it's global!)
for i, ship in ipairs (shipClasses) do
Objective4ShipKill = OnObjectKillClass (
function (object, killer)
if killer and IsCharacterHuman (killer) then
ship_count = ship_count - 1
if ship_count > 0 then
ShowMessageText("level.spa.count." .. ship_count, 1)
elseif ship_count == 0 then
Objective4:Complete (ATT)
--release all the "kill" event responses
for i, func in pairs(Objective4ShipKill) do
ReleaseObjectKill(func)
end
end
end
end,
ship
)
end
end
function MoveEntityToNode(entIn,pathIn,nodeIn)
if not entIn then
print("Warning!: Entity not specified for move")
return false
elseif not pathIn then
print("Warning!: Path not specified for Entity " .. entIn .. " move")
return false
end
local node
if nodeIn then
node = nodeIn
else
node = 0
end
local locDest = GetPathPoint(pathIn,node)
local charUnit = GetCharacterUnit(entIn)
if charUnit then
SetEntityMatrix(charUnit,locDest)
return true
end
return false
end
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
-- SPAX - Clone Wars Template Assault File
--
ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("KY1c_cmn")
---- load the gametype script
ScriptCB_DoFile("ObjectiveConquest")-- This is about capturing CP's
ScriptCB_DoFile("MultiObjectiveContainer")-- I'm not sure what this is for, but it is included in Almost all the Campaign missions
ScriptCB_DoFile("ObjectiveGoto")-- well this speaks for it'selve
ScriptCB_DoFile("ObjectiveAssault")-- something to do with killing units?
ScriptCB_SetGameRules("campaign")
-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
-- These variables do not change
ATT = REP;
DEF = CIS;
myGameMode = "KY1_CW-Assault"
function myScriptInit()
ClearWalkers()
AddWalkerType(3, 1)
SetMemoryPoolSize("CommandFlyer", 2)
SetMemoryPoolSize("CommandWalker", 1)
end
function ScriptPostLoad()
ScriptCB_SetGameRules("campaign")-- Here you can see a script being used; The script to define the gameRules(of wich I don't really know what they do EXACTLY)
SetAIDifficulty(0, 0, "medium")-- I'd say this influences the dumbness of the A.I. to compensate for difficult maps.
DisableAIAutoBalance()--Help requested on explaining this
OnEnterRegion(
function(regIn,character)
MoveEntityToNode(character,"teleportnodes")
end,
"accteleport"
)
ActivateRegion("accteleport")
KillObject("rep-cp4-acc3")
SetProperty("cis-cp2", "Team", "2")
SetProperty("rep-cp2-acc", "Team", "1")
SetProperty("cis-cp2", "Value_ATK_Republic", "1000")
SetProperty("rep-cp1", "AISpawnWeight", "3")
SetProperty("rep-cp4-acc3", "AISpawnWeight", "3")
SetProperty("rep-cp2-acc", "AISpawnWeight", "1000")
SetProperty("rep-cp3-acc2", "AISpawnWeight", "3")
--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "rep-cp1"}
cp2 = CommandPost:New{name = "cis-cp1"}
cp3 = CommandPost:New{name = "rep-cp2-acc"}
--cp5 = CommandPost:New{name = "cis-cp2"}
cp4 = CommandPost:New{name = "rep-cp2"}
cp6 = CommandPost:New{name = "rep-cp3-acc2"}
cp7 = CommandPost:New{name = "rep-cp4-acc3"}
--cp5 = CommandPost:New{name = "rep-cp3"}
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
objectives_timer = CreateTimer("objectives_timer")
SetTimerValue(objectives_timer, 2)
StartTimer(objectives_timer)
begin_objectives = OnTimerElapse(
function(timer)
StartObjectives ()
ScriptCB_EnableCommandPostVO(0)
end,
objectives_timer
)
end
end
)
--Go to the Acclamator Hangar
Objective1 = ObjectiveGoto:New{TeamATT = ATT, TeamDEF = DEF,
text = "level.KY1.objectives.campaign.2", popupText = "level.KY1.objectives.popup.2",
regionName = "rep-cp2-acc-con", mapIcon = "hud_objective_icon_circle", AIGoalWeight = 0}
Objective1:AddHint("level.spa2.objectives.popup.2a")
Objective1:AddHint("level.spa2.objectives.popup.2b")
Objective1:AddHint("level.spa2.objectives.popup.2c")
Objective1.OnStart = function(self)
att_obj1_aigoal = AddAIGoal(ATT, "Deathmatch", 100)
def_obj1_aigoal = AddAIGoal(DEF, "Deathmatch", 100)
end
Objective1.OnComplete = function(self)
DeleteAIGoal(att_obj1_aigoal)
DeleteAIGoal(def_obj1_aigoal)
ShowMessageText("game.objectives.complete", ATT)
SetProperty("cis-cp2", "Team", "2")
SetUnitCount(REP, 50)
SetUnitCount(CIS, 32)
RespawnObject("rep-cp4-acc3")
end
--Take the CIS CP
Objective2CP = CommandPost:New{name = "cis-cp2"}
Objective2 = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, text = "level.KY1.objectives.campaign.3", popupText = "level.KY1.objectives.popup.3", AIGoalWeight = 0}
Objective2:AddCommandPost(Objective2CP)
Objective2:AddHint("level.geo1.hints.capture_cp")
Objective2.OnStart = function(self)
AICanCaptureCP("cis-cp2", ATT, true)
AICanCaptureCP("cis-cp2", DEF, false)
SetProperty("cis-cp2", "Value_DEF_CIS", "0")
SetProperty("cis-cp2", "Value_ATK_Republic", "1000")
SetProperty("rep-cp1", "SpawnPath", "rep-cp1spawn")
att_obj2_aigoal = AddAIGoal(ATT, "Defend", 50, "cis-cp2")
def_obj2_aigoal = AddAIGoal(DEF, "Defend", 10, "cis-cp2")
att_obj2_aigoal2 = AddAIGoal(ATT, "Deathmatch", 100)
def_obj2_aigoal2 = AddAIGoal(DEF, "Deathmatch", 100)
shipleave = CreateTimer("shipleave")
SetTimerValue(shipleave, 120)
StartTimer(shipleave)
shipretreat = OnTimerElapse(
function(timer)
if GetTimerValue(shipleave) == "0" then
PlayAnimationGroup("shipretreat")
end
end
)
end
Objective2.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
DeleteAIGoal(att_obj2_aigoal)
DeleteAIGoal(att_obj2_aigoal2)
DeleteAIGoal(def_obj2_aigoal)
DeleteAIGoal(def_obj2_aigoal2)
SetProperty("cis-cp2", "Team", 1)
SetProperty("cis-cp2", "CaptureRegion", "")
end
--Kill 5 fighters
ship_count = 5
objective4Ships = {"cis_fly_droidfighter_sc_auto", "cis_fly_tridroidfighter_auto", "cis_fly_fanblade_auto"}
Objective4= Objective:New{teamATT = ATT, teamDEF = DEF,
text = "level.KY1.objectives.campaign.4", popupText = "level.KY1.objectives.popup.4"}
Objective4.OnStart = function(self)
ScriptCB_SndPlaySound("SPA2_obj_58")
Objective4ShipKillStart(objective4Ships)
end
Objective4.OnComplete = function(self)
DeleteAIGoal(Objective4.Dclass_cpGoal1)
DeleteAIGoal(Objective4.Dclass_cpGoal2)
end
--Land back in the hangar
Objective5 = ObjectiveGoto:New{TeamATT = ATT, TeamDEF = DEF,
text = "level.KY1.objectives.campaign.5", popupText = "level.KY1.objectives.popup.5",
regionName = "rep-cp2-acc-con", mapIcon = "hud_objective_icon_circle", AIGoalWeight = 0}
Objective5:AddHint("level.geo1.hints.movement")
Objective5:AddHint("level.geo1.hints.obj_markers")
Objective5:AddHint("level.geo1.hints.review_objectives")
Objective5:AddHint("level.geo1.hints.sprint")
Objective5.OnStart = function(self)
att_obj5_aigoal = AddAIGoal(ATT, "Deathmatch", 100)
def_obj5_aigoal = AddAIGoal(DEF, "Deathmatch", 100)
MapAddEntityMarker("waz_rep_acc_hangar", "hud_objective_icon_circle", 3.0, 1, "YELLOW", true)
end
Objective5.OnComplete = function(self)
DeleteAIGoal(att_obj5_aigoal)
DeleteAIGoal(def_obj5_aigoal)
ShowMessageText("game.objectives.complete", ATT)
MapRemoveEntityMarker("waz_rep_acc_hangar")
end
--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamDEF = DEF,
textDEF = "game.modes.con2",
multiplayerRules = true}
--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
--conquest:AddCommandPost(cp5)
conquest:AddCommandPost(cp6)
conquest:AddCommandPost(cp7)
conquest:Start()
SetUberMode(1);
EnableSPHeroRules()
end
function StartObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 4.0 }
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2)
objectiveSequence:AddObjectiveSet(Objective4)
objectiveSequence:AddObjectiveSet(Objective5)
objectiveSequence:Start()
end
function Objective4ShipKillStart(shipClasses)
Objective4ShipKill = {} --reminder: don't reuse this variable name (it's global!)
for i, ship in ipairs (shipClasses) do
Objective4ShipKill = OnObjectKillClass (
function (object, killer)
if killer and IsCharacterHuman (killer) then
ship_count = ship_count - 1
if ship_count > 0 then
ShowMessageText("level.spa.count." .. ship_count, 1)
elseif ship_count == 0 then
Objective4:Complete (ATT)
--release all the "kill" event responses
for i, func in pairs(Objective4ShipKill) do
ReleaseObjectKill(func)
end
end
end
end,
ship
)
end
end
function MoveEntityToNode(entIn,pathIn,nodeIn)
if not entIn then
print("Warning!: Entity not specified for move")
return false
elseif not pathIn then
print("Warning!: Path not specified for Entity " .. entIn .. " move")
return false
end
local node
if nodeIn then
node = nodeIn
else
node = 0
end
local locDest = GetPathPoint(pathIn,node)
local charUnit = GetCharacterUnit(entIn)
if charUnit then
SetEntityMatrix(charUnit,locDest)
return true
end
return false
end
Area highlighted in blue. Also, have I added in an extra end in there somewhere? My objectives don't seem to continue after I take the CP anymore.