Ambushing running after a timer has elapsed
Posted: Fri Aug 07, 2009 3:29 pm
by YaNkFaN
I'm trying to make an ambush run on once a timer and the .lua isn't liking it i've tried just the plain function Ambush() with the right parameters in the "()" so here is my script or the relavent pieces
Hidden/Spoiler:
[code]SetupAmbushTrigger("dropshipambush", "dropship_spawn", 6, dropshipspawn)
DeactivateRegion("dropshipambush")--this part is further up before the objectives are run
Objective2 = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF, text = "level.IC0.obj.2", popupText = "level.IC0.obj.pop.2"}
Objective2:AddTarget(Mainframe01)
Objective2:AddTarget(Mainframe02)
Objective2.OnSingleTargetDestroyed = function(self, target)
local numTargets = self:GetNumSingleTargets()
if numTargets > 0 then
ShowMessageText(MainframeString .. (numTargets + 1), 1)
ScriptCB_SndPlaySound("MYG_obj_04")
end
end
Objective2.OnStart = function(self)
SetProperty("turret1", "MaxHealth", 1000)
SetProperty("turret1", "CurHealth", 1000)
SetProperty("turret2", "MaxHealth", 1000)
SetProperty("turret2", "CurHealth", 1000)
Objective2.atkGoal1 = AddAIGoal(ATT, "Destroy", 3000, "turret1")
Objective2.atkGoal2 = AddAIGoal(ATT, "Destroy", 3000, "turret2")
Objective2.defGoal1 = AddAIGoal(DEF, "Defend", 3000, "turret1")
Objective2.defGoal2 = AddAIGoal(DEF, "Defend", 3000, "turret2")
ShowMessageText("level.IC0.obj.c2c", 1)
dropship_land = CreateTimer("land")
SetTimerValue(land, 30)
end
Objective2.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
ShowMessageText("level.IC0.obj.c2c", 1)
PlayAnimationFromTo("dropshipnew",0.0,30)
StartTimer(land)
OnTimerElapse(
function(timer)
ActivateRegion("dropshipambush")
ShowTimer(nil)
end,
land
)
--Deleting Goals
DeleteAIGoal(Objective2.atkGoal1)
DeleteAIGoal(Objective2.atkGoal2)
DeleteAIGoal(Objective2.defGoal1)
DeleteAIGoal(Objective2.defGoal2)
ATT_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATT_ReinforcementCount + 20)
if self.winningTeam == DEF then
ScriptCB_SndPlaySound("MYG_obj_15")
else
ScriptCB_SndPlaySound("MYG_obj_18")
end
end[/code]
DeactivateRegion("dropshipambush")--this part is further up before the objectives are run
Objective2 = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF, text = "level.IC0.obj.2", popupText = "level.IC0.obj.pop.2"}
Objective2:AddTarget(Mainframe01)
Objective2:AddTarget(Mainframe02)
Objective2.OnSingleTargetDestroyed = function(self, target)
local numTargets = self:GetNumSingleTargets()
if numTargets > 0 then
ShowMessageText(MainframeString .. (numTargets + 1), 1)
ScriptCB_SndPlaySound("MYG_obj_04")
end
end
Objective2.OnStart = function(self)
SetProperty("turret1", "MaxHealth", 1000)
SetProperty("turret1", "CurHealth", 1000)
SetProperty("turret2", "MaxHealth", 1000)
SetProperty("turret2", "CurHealth", 1000)
Objective2.atkGoal1 = AddAIGoal(ATT, "Destroy", 3000, "turret1")
Objective2.atkGoal2 = AddAIGoal(ATT, "Destroy", 3000, "turret2")
Objective2.defGoal1 = AddAIGoal(DEF, "Defend", 3000, "turret1")
Objective2.defGoal2 = AddAIGoal(DEF, "Defend", 3000, "turret2")
ShowMessageText("level.IC0.obj.c2c", 1)
dropship_land = CreateTimer("land")
SetTimerValue(land, 30)
end
Objective2.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
ShowMessageText("level.IC0.obj.c2c", 1)
PlayAnimationFromTo("dropshipnew",0.0,30)
StartTimer(land)
OnTimerElapse(
function(timer)
ActivateRegion("dropshipambush")
ShowTimer(nil)
end,
land
)
--Deleting Goals
DeleteAIGoal(Objective2.atkGoal1)
DeleteAIGoal(Objective2.atkGoal2)
DeleteAIGoal(Objective2.defGoal1)
DeleteAIGoal(Objective2.defGoal2)
ATT_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATT_ReinforcementCount + 20)
if self.winningTeam == DEF then
ScriptCB_SndPlaySound("MYG_obj_15")
else
ScriptCB_SndPlaySound("MYG_obj_18")
end
end[/code]