s2r222
4th Mar 09, 5:58 PM
Deciding that I want to have all the squads deploy into a mission, I started to dig though the scar files to find an easy way to do so.
After some digging I found this in campaign.scar :
function Campaign.GetHumanStartingUnits()
if(Campaign.IsEnabled())then
--fatal("Starting Units from the campaign is not setup yet")
local unitTable = {}
for i = 0, Campaign_GetSquadCount() - 1 do
local squad = Campaign_GetSquadAt(i)
if(squad.locked == false and squad.deployed ~= false)then
local unit = Campaign_GetSquadAt(i)
unit.offset = Campaign.StartingUnitOffsets[i]
table.insert(unitTable, unit)
end
end
return unitTable
else
local humanUnits = {}
for k, v in pairs(SPIKE.startingUnits)do
if(SPIKE.players[v.player].type == "human")then
table.insert(humanUnits, v)
end
end
if(SPIKE.usePersist)then
Campaign.HeroesSwapPersist( humanUnits )
end
return humanUnits
end
end
The line that I found interesting here is this one:
if(squad.locked == false and squad.deployed ~= false)then
Assuming I am reading this correctly, This part of the scar file looks at first if our squad is locked, and if we do not have it deployed. If either of these are true, we do not add it to the unitTable, that I am reading as unit that we are deploying to the mission.
However just making the line read
if(squad.locked == false)then
So that we get all squads into the unitTable that are not locked. This however just causes a scar error when the drop pod should drop in. I am going to work at it some more, but I was wondering if anyone here has got this working yet?
EDIT:
After much digging ( and not finding the Campaign_GetSquadCount() function ), i looked at the error message and found that it was not complaing about the number of squads but was in fact compaing that the player index was invalid.
and the scar file is failing around here:
function Campaign.GetPlayer(id)
if(Campaign.IsEnabled())then
return World_GetPlayerAt(id)
else
if(SPIKE.players[id] == nil or SPIKE.players[id].id == nil)then
fatal("Player ID is invalid")
end
return SPIKE.players[id].id
end
end
EDIT2:
Well, I think I am getting somewhere, after examing the LUA files I noticed that all squads expect the FC are set to owner id 0 when you finish SS3_SEP3.lua. I think what Is happening is that the addtional squad are tryin to drop in but then they have an invalid player controling them ( player id = 0 ) that would be in line with the error message I got. Now to find out where the Player ID get set when you select squads.
After some digging I found this in campaign.scar :
function Campaign.GetHumanStartingUnits()
if(Campaign.IsEnabled())then
--fatal("Starting Units from the campaign is not setup yet")
local unitTable = {}
for i = 0, Campaign_GetSquadCount() - 1 do
local squad = Campaign_GetSquadAt(i)
if(squad.locked == false and squad.deployed ~= false)then
local unit = Campaign_GetSquadAt(i)
unit.offset = Campaign.StartingUnitOffsets[i]
table.insert(unitTable, unit)
end
end
return unitTable
else
local humanUnits = {}
for k, v in pairs(SPIKE.startingUnits)do
if(SPIKE.players[v.player].type == "human")then
table.insert(humanUnits, v)
end
end
if(SPIKE.usePersist)then
Campaign.HeroesSwapPersist( humanUnits )
end
return humanUnits
end
end
The line that I found interesting here is this one:
if(squad.locked == false and squad.deployed ~= false)then
Assuming I am reading this correctly, This part of the scar file looks at first if our squad is locked, and if we do not have it deployed. If either of these are true, we do not add it to the unitTable, that I am reading as unit that we are deploying to the mission.
However just making the line read
if(squad.locked == false)then
So that we get all squads into the unitTable that are not locked. This however just causes a scar error when the drop pod should drop in. I am going to work at it some more, but I was wondering if anyone here has got this working yet?
EDIT:
After much digging ( and not finding the Campaign_GetSquadCount() function ), i looked at the error message and found that it was not complaing about the number of squads but was in fact compaing that the player index was invalid.
and the scar file is failing around here:
function Campaign.GetPlayer(id)
if(Campaign.IsEnabled())then
return World_GetPlayerAt(id)
else
if(SPIKE.players[id] == nil or SPIKE.players[id].id == nil)then
fatal("Player ID is invalid")
end
return SPIKE.players[id].id
end
end
EDIT2:
Well, I think I am getting somewhere, after examing the LUA files I noticed that all squads expect the FC are set to owner id 0 when you finish SS3_SEP3.lua. I think what Is happening is that the addtional squad are tryin to drop in but then they have an invalid player controling them ( player id = 0 ) that would be in line with the error message I got. Now to find out where the Player ID get set when you select squads.