Skip to content

Commit

Permalink
Add alliedUnitsSatisfy to campaign bonus objectives.
Browse files Browse the repository at this point in the history
  • Loading branch information
GoogleFrog committed Jan 17, 2025
1 parent 25b0ebd commit d6f35c9
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions LuaRules/Gadgets/mission_galaxy_campaign_battle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ local function DoPeriodicBonusObjectiveUpdate(gameSeconds)
--DebugPrintBonusObjective()
end

local function AddBonusObjectiveUnit(unitID, bonusObjectiveID, allyTeamID, isCapture)
local function AddBonusObjectiveUnit(unitID, bonusObjectiveID, allyTeamID, isCapture, isPlayerAiAlly)
if gameIsOver then
return
end
Expand All @@ -429,6 +429,9 @@ local function AddBonusObjectiveUnit(unitID, bonusObjectiveID, allyTeamID, isCap
if isCapture and not objectiveData.capturedUnitsSatisfy then
return
end
if isPlayerAiAlly and not objectiveData.alliedUnitsSatisfy then
return
end
objectiveData.units = objectiveData.units or {}
objectiveData.units[unitID] = allyTeamID or Spring.GetUnitAllyTeam(unitID)
if objectiveData.lockUnitsOnSatisfy then
Expand Down Expand Up @@ -502,12 +505,12 @@ local function InitializeBonusObjectives()
end
end

local function AddUnitToBonusObjectiveList(unitID, objectiveList, isCapture)
local function AddUnitToBonusObjectiveList(unitID, objectiveList, isCapture, isPlayerAiAlly)
if not objectiveList then
return
end
for i = 1, #objectiveList do
AddBonusObjectiveUnit(unitID, objectiveList[i], nil, isCapture)
AddBonusObjectiveUnit(unitID, objectiveList[i], nil, isCapture, isPlayerAiAlly)
end
end

Expand All @@ -521,10 +524,12 @@ local function RemoveUnitFromBonusObjectiveList(unitID, objectiveList)
end

local function BonusObjectiveUnitCreated(unitID, unitDefID, teamID, isCapture)
if teamID == PLAYER_TEAM_ID then
AddUnitToBonusObjectiveList(unitID, myUnitDefBonusObj[unitDefID], isCapture)
elseif Spring.GetUnitAllyTeam(unitID) ~= PLAYER_ALLY_TEAM_ID then
AddUnitToBonusObjectiveList(unitID, enemyUnitDefBonusObj[unitDefID], isCapture)
local allyTeamID = Spring.GetUnitAllyTeam(unitID)
if allyTeamID == PLAYER_ALLY_TEAM_ID then
local isPlayerAiAlly = teamID ~= PLAYER_TEAM_ID
AddUnitToBonusObjectiveList(unitID, myUnitDefBonusObj[unitDefID], isCapture, isPlayerAiAlly)
else
AddUnitToBonusObjectiveList(unitID, enemyUnitDefBonusObj[unitDefID], isCapture, false)
end
end

Expand Down

0 comments on commit d6f35c9

Please sign in to comment.