Game Development Reference
In-Depth Information
Assigning agent teams
So far, our agents fend for themselves in a free-for-all style; now, we'll assign teams to util-
ize team-based communication as well as the beginnings of cooperative strategy. By chan-
ging the initialization of the agent, we can assign the agent to either team1 or team2 and
assign a different character model accordingly:
IndirectSoldierAgent.lua :
function Agent_Initialize(agent)
Soldier_InitializeAgent(agent);
agent:SetTeam("team" .. (agent:GetId() % 2 + 1));
soldierUserData = {};
if (agent:GetTeam() == "team1") then
soldierUserData.soldier =
Soldier_CreateSoldier(agent);
else
soldierUserData.soldier =
Soldier_CreateLightSoldier(agent);
end
...
end
Even with a team assigned to each agent, it will still behave in a free-for-all manner, as en-
emy selection is solely based on the distance. Going forward, we'll change our agent's be-
haviors to take these new team assignments into account.
Search WWH ::




Custom Search