Skip to content

Commit

Permalink
Rename canPeePukeOrFall (CorsixTH#2686)
Browse files Browse the repository at this point in the history
* Add new Luadoc, or change plain comment to Luadoc.

* Rename the parameter to express it is an action.

* Rename canPeePukeOrFall to atFullyEmptyTile
  • Loading branch information
Alberth289346 authored Oct 19, 2024
1 parent 70387a7 commit 8689cd6
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions CorsixTH/Lua/entities/humanoids/patient.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function Patient:setDiagnosed()
self:updateDynamicInfo()
end

-- Modifies the diagnosis progress of a patient.
--! Modifies the diagnosis progress of a patient.
-- incrementValue can be either positive or negative.
function Patient:modifyDiagnosisProgress(incrementValue)
self.diagnosis_progress = math.min(self.hospital.policies["stop_procedure"],
Expand All @@ -171,7 +171,7 @@ function Patient:modifyDiagnosisProgress(incrementValue)
self:updateDynamicInfo()
end

-- Updates the patients diagnostic progress based on the doctors skill
--! Updates the patients diagnostic progress based on the doctors skill
-- called when they are done using a diagnosis room
function Patient:completeDiagnosticStep(room)
-- Base: depending on difficulty of disease as set in sam file
Expand Down Expand Up @@ -204,7 +204,7 @@ function Patient:completeDiagnosticStep(room)
self:modifyDiagnosisProgress(diagnosis_base + (diagnosis_bonus * multiplier))
end

-- Sets the hospital for the patient - additionally removing them from a
--! Sets the hospital for the patient - additionally removing them from a
-- hospital if they already belong to one. For player hospitals, patients who
-- are not debug or emergency patients are made to seek a reception desk.
--!param hospital (Hospital): hospital to assign to patient
Expand Down Expand Up @@ -349,11 +349,15 @@ function Patient:die()
self:setDynamicInfoText(_S.dynamic_info.patient.actions.dying)
end

-- Actions we can interrupt for in the canPeePukeOrFall function
-- Actions we can interrupt when at a fully empty tile.
local good_actions = {walk=true, idle=true, seek_room=true, queue=true}

function Patient:canPeePukeOrFall(current)
if not good_actions[current.name] then return false end
--! Test whether the current tile of the patient is useful for inserting an
-- action that needs a fully empty tile in the hospital.
--!param cur_action Current action of the patient.
--!return Whether the tile can be used for inserting an action.
function Patient:atFullyEmptyTile(cur_action)
if not good_actions[cur_action.name] then return false end
if self.going_home then return false end

local th = self.world.map.th
Expand All @@ -369,7 +373,7 @@ end
function Patient:falling(player_init)
local current = self:getCurrentAction()
current.keep_reserved = true
if self.falling_anim and self:canPeePukeOrFall(current) and self.has_fallen == 1 then
if self.falling_anim and self:atFullyEmptyTile(current) and self.has_fallen == 1 then
self.has_fallen = 2
self:queueAction(FallingAction(), 1)
self:queueAction(OnGroundAction(), 2)
Expand Down Expand Up @@ -401,7 +405,7 @@ end
function Patient:vomit()
local current = self:getCurrentAction()
--Only vomit under these conditions. Maybe I should add a vomit for patients in queues too?
if self:canPeePukeOrFall(current) and self.has_vomitted == 0 then
if self:atFullyEmptyTile(current) and self.has_vomitted == 0 then
self:queueAction(VomitAction(), 1)
self:interruptAndRequeueAction(current, 2)
self.has_vomitted = self.has_vomitted + 1
Expand All @@ -414,7 +418,7 @@ end
function Patient:pee()
local current = self:getCurrentAction()
--Only pee under these conditions. As with vomit, should they also pee if in a queue?
if self:canPeePukeOrFall(current) then
if self:atFullyEmptyTile(current) then
self:queueAction(PeeAction(), 1)
self:interruptAndRequeueAction(current, 2)
self:setMood("poo", "deactivate")
Expand Down

0 comments on commit 8689cd6

Please sign in to comment.