Make the coop players spawningThe coop players will spawn the same way as the first player.
Mission 01 is special : it spawn through a gate. This is probably the more complicate case.
In case of mission 01, the spawning is done in IntroNISPart2.
You can find where quite easily by searching "ScenarioInfo.PlayerCDR = ScenarioUtils.CreateArmyUnit('Player'
NO ALTERATION BELOW, JUST EXPLANATIONS
- Code: Select all
if(Faction == 'cybran') then
ScenarioInfo.PlayerCDR = ScenarioUtils.CreateArmyUnit('Player', 'CybranPlayer')
elseif(Faction == 'uef') then
ScenarioInfo.PlayerCDR = ScenarioUtils.CreateArmyUnit('Player', 'UEFPlayer')
elseif(Faction == 'aeon') then
ScenarioInfo.PlayerCDR = ScenarioUtils.CreateArmyUnit('Player', 'AeonPlayer')
end
This create the ACU of the player.
Then some code to give him the current base, settings patrols, ...
- Code: Select all
local cmd = IssueMove({ScenarioInfo.PlayerCDR}, ScenarioUtils.MarkerToPosition('CDRWarp'))
This order the ACU of the player to move to a map marker (CDRWarp)
- Code: Select all
ScenarioFramework.FakeGateInUnit(ScenarioInfo.PlayerCDR)
This is purely cosmetic : It does a fake gating in effect around the ACU.
Really make the coop players spawningSo, for each coop player, we need to:
- Create a ACU
- Move them to the marker
- Create a effect for gating in.
- Code: Select all
ScenarioInfo.PlayerCDR:SetCustomName(LOC '{i CDR_Player}')
ScenarioInfo.CoopCDR = {}
local tblArmy = ListArmies()
coop = 1
for iArmy, strArmy in pairs(tblArmy) do
if iArmy >= ScenarioInfo.Coop1 then
factionIdx = GetArmyBrain(strArmy):GetFactionIndex()
if(factionIdx == 1) then
ScenarioInfo.CoopCDR[coop] = ScenarioUtils.CreateArmyUnit(strArmy, 'UEFPlayer')
elseif(factionIdx == 2) then
ScenarioInfo.CoopCDR[coop] = ScenarioUtils.CreateArmyUnit(strArmy, 'AeonPlayer')
else
ScenarioInfo.CoopCDR[coop] = ScenarioUtils.CreateArmyUnit(strArmy, 'CybranPlayer')
end
IssueMove({ScenarioInfo.CoopCDR[coop]}, ScenarioUtils.MarkerToPosition('CDRWarp'))
ScenarioFramework.FakeGateInUnit(ScenarioInfo.CoopCDR[coop])
coop = coop + 1
WaitSeconds(2)
end
end
- Code: Select all
ScenarioInfo.PlayerCDR:SetCustomName(LOC '{i CDR_Player}')
ScenarioInfo.CoopCDR = {}
We are preparing a table in ScenarioInfo that will contains all Coop ACUs.
- Code: Select all
local tblArmy = ListArmies()
coop = 1
Same as before, we will iterate over all the armies.
We also set a variable that will increase for all coop players added.
- Code: Select all
for iArmy, strArmy in pairs(tblArmy) do
if iArmy >= ScenarioInfo.Coop1 then
Same as before, if the army is equal or above ScenarioInfo.Coop1, it's a coop player.
- Code: Select all
factionIdx = GetArmyBrain(strArmy):GetFactionIndex()
if(factionIdx == 1) then
ScenarioInfo.CoopCDR[coop] = ScenarioUtils.CreateArmyUnit(strArmy, 'UEFPlayer')
elseif(factionIdx == 2) then
ScenarioInfo.CoopCDR[coop] = ScenarioUtils.CreateArmyUnit(strArmy, 'AeonPlayer')
else
ScenarioInfo.CoopCDR[coop] = ScenarioUtils.CreateArmyUnit(strArmy, 'CybranPlayer')
end
As with the unlock, we take the faction of the army and spawn the appropriate ACU type (no further than Cybran - no seraphim or nomads).
We put that in the ScenarioInfo.CoopCDR table, at the position of the coop variable.
- Code: Select all
IssueMove({ScenarioInfo.CoopCDR[coop]}, ScenarioUtils.MarkerToPosition('CDRWarp'))
We ask that ACU to move to the spawn point.
- Code: Select all
ScenarioFramework.FakeGateInUnit(ScenarioInfo.CoopCDR[coop])
coop = coop + 1
We are adding the fake effect, and we increase the coop variable.
- Code: Select all
WaitSeconds(2)
In order to not have all the ACU to spawn at the same time, we are asking to wait 2 seconds before spawning the next one.
The gate won't be destroyed until the last one spawn, so we are good visually.