Skip to content

Commit

Permalink
Fix:[AI] Corrected situation priority calculation for "roomboard task…
Browse files Browse the repository at this point in the history
…" (reset after sign switching). Report: DannyF
  • Loading branch information
GWRon committed Apr 12, 2017
1 parent 91e1bf0 commit 73f27c1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion res/ai/DefaultAIPlayer/AIEngine.lua
Expand Up @@ -425,7 +425,8 @@ function AITask:RecalcPriority()

self.CurrentPriority = math.max(timePriority, ticksPriority)

-- debugMsg("Task: " .. self:typename() .. " - Prio: " .. self.CurrentPriority .. " - TimeDiff:" .. TimeDiff .. " TicksDiff:" .. TicksDiff.." (c: " .. calcPriority .. ")")
--debugMsg("Task: " .. self:typename() .. " - BasePriority: " .. self.BasePriority .." - SituationPriority: " .. self:getSituationPriority() .. " - Ran1 : " .. Ran1 .. " RequisitionPriority: " .. requisitionPriority)
--debugMsg("Task: " .. self:typename() .. " - Prio: " .. self.CurrentPriority .. " (time: " .. timePriority .." | ticks: " .. ticksPriority ..") - TimeDiff:" .. TimeDiff .. " TicksDiff:" .. TicksDiff.." (tF: " ..timeFactor .." | cP: " .. calcPriority .. ")")
end

function AITask:TooMuchTicks()
Expand Down
7 changes: 6 additions & 1 deletion res/ai/DefaultAIPlayer/TaskNewsAgency.lua
Expand Up @@ -152,7 +152,12 @@ function JobCheckEventNews:Tick()
if player.TaskList[TASK_ROOMBOARD] ~= nil then
local roomBoardTask = player.TaskList[TASK_ROOMBOARD]
if terrorLevel >= 2 then
roomBoardTask.SituationPriority = terrorLevel * terrorLevel
roomBoardTask.SituationPriority = terrorLevel * terrorLevel
end

-- mark the situation of a soon happening attack
if terrorLevel >= 1 then
roomBoardTask.RecognizedTerrorLevel = true
end

roomBoardTask.FRDubanTerrorLevel = TVT.ne_getTerroristAggressionLevel(0) --FR Duban Terroristen
Expand Down
18 changes: 17 additions & 1 deletion res/ai/DefaultAIPlayer/TaskRoomBoard.lua
Expand Up @@ -8,7 +8,8 @@ _G["TaskRoomBoard"] = class(AITask, function(c)
c.BasePriority = 0
c.NeededInvestmentBudget = 0
c.InvestmentPriority = 0


c.RecognizedTerrorLevel = false
c.FRDubanTerrorLevel = 0 --FR Duban Terroristen
c.VRDubanTerrorLevel = 0 --VR Duban Terroristen
end)
Expand All @@ -33,6 +34,17 @@ function TaskRoomBoard:GetNextJobInTargetRoom()
end

function TaskRoomBoard:getSituationPriority()
-- situation is normal if we do not know about terror (needs
-- visit of the news agency and a higher level)
if (not self.RecognizedTerrorLevel) then
return 0
end

-- fix broken savegames (got one with values of 40.000.000)
-- which therefor get unbelievable high priorities
self.FRDubanTerrorLevel = math.clamp(self.FRDubanTerrorLevel, -10, 10)
self.VRDubanTerrorLevel = math.clamp(self.VRDubanTerrorLevel, -10, 10)

local maxTerrorLevel = math.max(self.FRDubanTerrorLevel, self.VRDubanTerrorLevel)
if maxTerrorLevel >= 3 then
self.SituationPriority = math.max(self.SituationPriority, maxTerrorLevel * 8)
Expand Down Expand Up @@ -95,6 +107,10 @@ function JobChangeRoomSigns:Tick()
TVT.rb_SwitchSigns(sign, roomSign)
kiMsg("Verschiebe VRDuban-Schild auf Raum " .. roomId .. " (" .. roomSign.GetOwnerName() ..") des Spielers " .. enemyId )
end

-- handled the situation "for now"
self.Task.SituationPriority = 0
self.Task.RecognizedTerrorLevel = false

self.Status = JOB_STATUS_DONE
end
Expand Down

0 comments on commit 73f27c1

Please sign in to comment.