Page 1 of 1

Lua problem

Posted: Sat Aug 30, 2014 2:02 pm
by SethXXX
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:

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
I am pretty sure this is just a simple misunderstanding by me, but nevertheless I can't figure out the reason.

Thanks in advance! :)

Posted: Sat Aug 30, 2014 3:48 pm
by abcdefg30
I think you missed something in line 22, 31, and 40.
This

Code: Select all

Actor.OnIdle(actor, Actor.Hunt)
has to be replaced with

Code: Select all

Actor.OnIdle(actor, function() Actor.Hunt(actor) end)

Posted: Sun Aug 31, 2014 7:51 am
by SethXXX
Sadly, this didn't work either, same problem still appears, the teams get built, but don't move anywhere... Maybe I should try using waypoints or Attack Move?

Posted: Sun Aug 31, 2014 4:32 pm
by abcdefg30
SethXXX wrote: Sadly, this didn't work either, same problem still appears, the teams get built, but don't move anywhere... Maybe I should try using waypoints or Attack Move?
Strange, but then try with attackmoves.

Posted: Wed Sep 03, 2014 5:13 pm
by aria
This is what i pulled from my notes, not sure if it helps but give it a try.

Try adding this to

Production.EventHandlers.Setup(HOUSE)

House being the name the team to build for

;example

SetupWorld = function()
--this below needs to be on for teams to do actions in the team.do loop
Production.EventHandlers.Setup(HOUSE)
end

WorldLoaded = function()
SetupWorld()
end