Lua problem
Posted: Sat Aug 30, 2014 2:02 pm
Hello guys, I'm trying to create a simple mission, basically it's just a base vs base situation.
Ofc I want the Allies to attack me a bit, but they don't. They build the units I tell them to, so the first part works, but they don't attack me like they are supposed to, but instead just stand around in their base, doing nothing.
My Lua code:
I am pretty sure this is just a simple misunderstanding by me, but nevertheless I can't figure out the reason.
Thanks in advance!
Ofc I want the Allies to attack me a bit, but they don't. They build the units I tell them to, so the first part works, but they don't attack me like they are supposed to, but instead just stand around in their base, doing nothing.
My Lua code:
Code: Select all
ParatrooperReinforcements = { "e1", "e1", "e4", "e4", "e4", "e4" }
Attack1Template = { {AlliedBarracks, {"e1", "e1", "e1", "e3", "e3"}} }
Attack2Template = { {AlliedWaFa, {"jeep", "1tnk"}} }
Attack3Template = { {AlliedWaFa, {"2tnk", "2tnk"}} }
RunInitialActivities = function()
Actor.Harvest(harv1)
Actor.Harvest(harv2)
Actor.Harvest(harvsov)
Team.Do(InitialAttackers, function(c)
Actor.Hunt(c)
end)
end
HQDestroyed = function(self, e)
MissionFailed()
end
BuildAttack1 = function()
Production.BuildTeamFromTemplate(allies, Attack1Template, function(team)
Team.Do(team, function(actor)
Actor.OnIdle(actor, Actor.Hunt)
end)
Team.AddEventHandler(team.OnAllKilled, BuildAttack1)
end)
end
BuildAttack2 = function()
Production.BuildTeamFromTemplate(allies, Attack2Template, function(team)
Team.Do(team, function(actor)
Actor.OnIdle(actor, Actor.Hunt)
end)
Team.AddEventHandler(team.OnAllKilled, BuildAttack2)
end)
end
BuildAttack3 = function()
Production.BuildTeamFromTemplate(allies, Attack3Template, function(team)
Team.Do(team, function(actor)
Actor.OnIdle(actor, Actor.Hunt)
end)
Team.AddEventHandler(team.OnAllKilled, BuildAttack3)
end)
end
MissionAccomplished = function()
Mission.MissionOver({ player }, nil, false)
end
MissionFailed = function()
Mission.MissionOver(nil, { player }, false)
end
WorldLoaded = function()
player = OpenRA.GetPlayer("USSR")
greece = OpenRA.GetPlayer("Greece")
allies = OpenRA.GetPlayer("Allies")
Actor.OnKilled(SovietHQ, HQDestroyed)
InitialAttackers = Team.New({ Inf1, Inf2, Inf3, Inf4, Inf5, Inf6, Inf7 })
RunInitialActivities()
OpenRA.RunAfterDelay(2, BuildAttack1)
OpenRA.RunAfterDelay(2, BuildAttack2)
OpenRA.RunAfterDelay(2, BuildAttack3)
OpenRA.RunAfterDelay(CameraDelay, function() Actor.Create("camera", { Owner = player, Location = camstart.Location }) end)
OpenRA.SetViewportCenterPosition(camstart.CenterPosition)
Media.PlayRandomMusic()
end
Tick = function()
if Mission.RequiredUnitsAreDestroyed(allies) then
MissionAccomplished()
end
end
Thanks in advance!
