| 1 |
--[[ Copyright (c) 2009 Peter "Corsix" Cawley |
| 2 |
|
| 3 |
Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 4 |
this software and associated documentation files (the "Software"), to deal in |
| 5 |
the Software without restriction, including without limitation the rights to |
| 6 |
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
| 7 |
of the Software, and to permit persons to whom the Software is furnished to do |
| 8 |
so, subject to the following conditions: |
| 9 |
|
| 10 |
The above copyright notice and this permission notice shall be included in all |
| 11 |
copies or substantial portions of the Software. |
| 12 |
|
| 13 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 19 |
SOFTWARE. --]] |
| 20 |
|
| 21 |
local room = {} |
| 22 |
room.id = "pharmacy" |
| 23 |
room.vip_must_visit = false |
| 24 |
room.level_config_id = 11 |
| 25 |
room.class = "PharmacyRoom" |
| 26 |
room.name = _S.rooms_short.pharmacy |
| 27 |
room.long_name = _S.rooms_long.pharmacy |
| 28 |
room.tooltip = _S.tooltip.rooms.pharmacy |
| 29 |
room.objects_additional = { "extinguisher", "radiator", "plant", "bin" } |
| 30 |
room.objects_needed = { pharmacy_cabinet = 1 } |
| 31 |
room.build_preview_animation = 5088 |
| 32 |
room.categories = { |
| 33 |
treatment = 4, |
| 34 |
} |
| 35 |
room.minimum_size = 4 |
| 36 |
room.wall_type = "white" |
| 37 |
room.floor_tile = 19 |
| 38 |
room.required_staff = { |
| 39 |
Nurse = 1, |
| 40 |
} |
| 41 |
room.maximum_staff = room.required_staff |
| 42 |
room.call_sound = "reqd012.wav" |
| 43 |
|
| 44 |
class "PharmacyRoom" (Room) |
| 45 |
|
| 46 |
---@type PharmacyRoom |
| 47 |
local PharmacyRoom = _G["PharmacyRoom"] |
| 48 |
|
| 49 |
function PharmacyRoom:PharmacyRoom(...) |
| 50 |
self:Room(...) |
| 51 |
end |
| 52 |
|
| 53 |
function PharmacyRoom:roomFinished() |
| 54 |
if self.hospital:countStaffOfCategory("Nurse", 1) == 0 then |
| 55 |
self.hospital:giveAdvice({ _A.room_requirements.pharmacy_need_nurse }) |
| 56 |
end |
| 57 |
return Room.roomFinished(self) |
| 58 |
end |
| 59 |
|
| 60 |
function PharmacyRoom:commandEnteringPatient(patient) |
| 61 |
local staff = self.staff_member |
| 62 |
local cabinet, stf_x, stf_y = self.world:findObjectNear(patient, "pharmacy_cabinet") |
| 63 |
local pat_x, pat_y |
| 64 |
local orientation = cabinet.object_type.orientations[cabinet.direction] |
| 65 |
pat_x = stf_x - orientation.use_position[1] + orientation.use_position_secondary[1] |
| 66 |
pat_y = stf_y - orientation.use_position[2] + orientation.use_position_secondary[2] |
| 67 |
|
| 68 |
local layer3 |
| 69 |
local patient_class = patient.humanoid_class |
| 70 |
if patient_class == "Standard Female Patient" or patient_class == "Transparent Female Patient" then |
| 71 |
-- Female patients cannot use flask colour 2, as in their idle animation, |
| 72 |
-- layer 3 item 2 is a bandage. |
| 73 |
layer3 = math.random(0, 1) * 4 |
| 74 |
else |
| 75 |
layer3 = math.random(0, 2) * 2 |
| 76 |
end |
| 77 |
|
| 78 |
patient:setNextAction(WalkAction(pat_x, pat_y)) |
| 79 |
patient:queueAction(IdleAction():setDirection(cabinet.direction == "north" and "east" or "south")) |
| 80 |
|
| 81 |
staff:setNextAction(WalkAction(stf_x, stf_y)) |
| 82 |
|
| 83 |
local after_use_pharmacy = --[[persistable:pharmacy_after_use]] function() |
| 84 |
--if we haven't tried to edit the room while she's animating, meander |
| 85 |
if #staff.action_queue == 1 then |
| 86 |
staff:setNextAction(MeanderAction()) |
| 87 |
end |
| 88 |
if patient_class == "Invisible Patient" or patient_class == "Transparent Male Patient" then |
| 89 |
patient:setType "Standard Male Patient" |
| 90 |
elseif patient_class == "Transparent Female Patient" then |
| 91 |
patient:setType "Standard Female Patient" |
| 92 |
end |
| 93 |
self:dealtWithPatient(patient) |
| 94 |
end |
| 95 |
|
| 96 |
staff:queueAction(MultiUseObjectAction(cabinet, patient):setAfterUse(after_use_pharmacy) |
| 97 |
:setLayer3(layer3)) |
| 98 |
|
| 99 |
return Room.commandEnteringPatient(self, patient) |
| 100 |
end |
| 101 |
|
| 102 |
return room |