Skip to content

Commit

Permalink
Fix: Aliens were not correctly specified on levels 11 and 12. Fixes i…
Browse files Browse the repository at this point in the history
…ssues 983 and 900.

Fix: The wrong amount of money was refunded when removing a room. It is now better, but still not optimal. Thanks Mark L!
Fix: Adviser priorities didn't always work with old savegames.
Fix: The VIP could sometimes permanently block a door. Now he doesn't block doors at all, mimicking the behaviour in TH97.
Fix: Patients always went to the nearest reception desk, now they also consider queues.

Added: A bunch of new awards at year end. Note that these may not be available until you start a new game depending on which original TH files you use.
  • Loading branch information
Lego3 committed Mar 8, 2012
1 parent c21ca8c commit c173ff5
Show file tree
Hide file tree
Showing 18 changed files with 560 additions and 176 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ CorsixTH/Levels/demo.level -text
CorsixTH/Levels/example.level -text
CorsixTH/Levels/original05.level -text
CorsixTH/Levels/original07.level -text
CorsixTH/Levels/original11.level -text
CorsixTH/Levels/original12.level -text
CorsixTH/Lua/dialogs/fullscreen/annual_report.lua -text
CorsixTH/Lua/dialogs/fullscreen/graphs.lua -text
CorsixTH/Lua/dialogs/resizables/calls_dispatcher.lua -text
Expand All @@ -91,6 +93,7 @@ CorsixTH/Lua/humanoid_actions/pee.lua -text
CorsixTH/Lua/humanoid_actions/shake_fist.lua -text
CorsixTH/Lua/humanoid_actions/sweep_floor.lua -text
CorsixTH/Lua/humanoid_actions/tap_foot.lua -text
CorsixTH/Lua/humanoid_actions/vip_go_to_next_room.lua -text
CorsixTH/Lua/humanoid_actions/vomit.lua -text
CorsixTH/Lua/humanoid_actions/yawn.lua -text
CorsixTH/Lua/languages/czech.lua -text
Expand Down
26 changes: 26 additions & 0 deletions CorsixTH/Levels/original11.level
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2012 Edvin "Lego3" Linge

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-- This is an extra configuration file loaded at level 11 from the original game.
-- For some reason Alien DNA is set to be unavailable at this level even though
-- it evidently should be.

-- Make it available after 12 months.
#visuals[6] 10 I_ALIEN
26 changes: 26 additions & 0 deletions CorsixTH/Levels/original12.level
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2012 Edvin "Lego3" Linge

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-- This is an extra configuration file loaded at level 12 from the original game.
-- For some reason Alien DNA is set to be unavailable at this level even though
-- it evidently should be.

-- Make it available after 12 months.
#visuals[6] 10 I_ALIEN
2 changes: 1 addition & 1 deletion CorsixTH/Lua/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ local assert, io, type, dofile, loadfile, pcall, tonumber, print, setmetatable

-- Increment each time a savegame break would occur
-- and add compatibility code in afterLoad functions
local SAVEGAME_VERSION = 49
local SAVEGAME_VERSION = 50

class "App"

Expand Down
2 changes: 2 additions & 0 deletions CorsixTH/Lua/base_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ local configuration = {
TrophyReputationBonus = 2000,
-- Bonus to money for NO DEATHS in the year (MONEY BONUS)
TrophyDeathBonus = 10000,
-- Bonus to reputation for pleasing VIPs in the year (REPUTATION BONUS)
TrophyMayorBonus = 5,


------------------- Award win/loss criteria -------------------
Expand Down
8 changes: 5 additions & 3 deletions CorsixTH/Lua/dialogs/adviser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ function UIAdviser:talk()
self.number_frames = 45
-- Fetch the next message from the queue.
local best = 1
for i = 1, #self.queued_messages do
if best ~= i and self.queued_messages[best].priority < self.queued_messages[i].priority then
best = i
if self.queued_messages[1].priority then
for i = 1, #self.queued_messages do
if best ~= i and self.queued_messages[best].priority < self.queued_messages[i].priority then
best = i
end
end
end
local speech = self.queued_messages[best].speech
Expand Down
2 changes: 1 addition & 1 deletion CorsixTH/Lua/dialogs/edit_room.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function UIEditRoom:abortRoom()
for obj, num in pairs(self.room.room_info.objects_needed) do
-- Get how much this item costs.
local obj_cost = self.ui.hospital:getObjectBuildCost(obj)

cost = cost - math.floor(obj_cost)/2
valueChange = valueChange - num * obj_cost
end
self.ui.hospital:receiveMoney(cost, _S.transactions.sell_object, valueChange)
Expand Down
117 changes: 92 additions & 25 deletions CorsixTH/Lua/dialogs/fullscreen/annual_report.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,48 +156,115 @@ end

--! Finds out which awards and/or trophies the player has been awarded this year.
function UIAnnualReport:checkTrophiesAndAwards(world)
local hosp = self.ui.hospital

local hosp = self.ui.hospital
local prices = world.map.level_config.awards_trophies

-- Check CuresAward so that we know the new config settings are available
if hosp.win_awards and prices.HospValueAward then
if hosp.win_awards and prices.TrophyMayorBonus then
local won_amount = 0

-- The three trophies available at this time
local rep_amount = 0


-- The trophies and certificated awards/penalties available at this time --


-------------------------------- Trophies ---------------------------------


-- Coke sales
if hosp.sodas_sold > prices.CansofCoke then
self:addTrophy(_S.trophy_room.sold_drinks.trophies[math.random(1, 3)], "money", prices.CansofCokeBonus)
won_amount = prices.CansofCokeBonus
won_amount = win_amount + prices.CansofCokeBonus
end

-- Impressive VIP visits
if hosp.num_vips_ty > 0 and hosp.pleased_vips_ty == hosp.num_vips_ty then
-- added some here so you get odd amounts as in TH!
local win_value = (prices.TrophyMayorBonus * hosp.pleased_vips_ty) + math.random(1, 5)
self:addTrophy(_S.trophy_room.happy_vips.trophies[math.random(1, 3)], "reputation", win_value)
rep_amount = rep_amount + win_value
end
-- Impressive Reputation in the year (above a threshold throughout the year)
if hosp.reputation_above_threshold then
self:addTrophy(_S.trophy_room.high_rep.awards[math.random(1, 2)], "money", prices.TrophyReputationBonus)
self:addTrophy(_S.trophy_room.consistant_rep.trophies[math.random(1, 2)], "money", prices.TrophyReputationBonus)
won_amount = won_amount + prices.TrophyReputationBonus
elseif hosp.reputation > prices.ReputationAward then
-- One of the two related awards that are only given
-- if the corresponding trophy was not won this year?
--won_amount += prices.AwardReputationBonus
elseif hosp.reputation < prices.ReputationPoor then
--won_amount += prices.AwardReputationPenalty
end

-- No deaths or around a 100% Cure rate in the year
if hosp.num_deaths_this_year == 0 then
self:addTrophy(_S.trophy_room.no_deaths.trophies[math.random(1, 2)], "money", prices.TrophyDeathBonus)
self:addTrophy(_S.trophy_room.no_deaths.trophies[math.random(1, 3)], "money", prices.TrophyDeathBonus)
won_amount = won_amount + prices.TrophyDeathBonus
elseif hosp.num_deaths_this_year < prices.DeathsAward then
-- One of the two related awards that are only given
-- if the corresponding trophy was not won this year?
--won_amount += prices.DeathsBonus
elseif hosp.num_deaths_this_year > prices.DeathsAward then
--won_amount += prices.DeathsPenalty
elseif hosp.num_cured_ty > (hosp.not_cured_ty * 0.9) then
self:addTrophy(_S.trophy_room.many_cured.trophies[math.random(1, 3)], "money", prices.TrophyCuresBonus)
won_amount = won_amount + prices.TrophyCuresBonus
end


-------------------- Certificate Awards or Penalties ---------------------


-- Reputation
if hosp.reputation > prices.ReputationAward then
self:addAward(_S.trophy_room.high_rep.awards[math.random(1, 2)], "money", prices.AwardReputationBonus)
won_amount = won_amount + prices.AwardReputationBonus
elseif hosp.reputation < prices.ReputationPoor then
self:addAward(_S.trophy_room.high_rep.penalty[math.random(1, 2)], "money", prices.AwardReputationPenalty)
won_amount = won_amount + prices.AwardReputationPenalty
end

---------------- Insert other awards the player can get, both good and bad. ---------------------------
-- Check out base_config.lua for a lot of values to use.
-- Example: self:addAward("Too bad!", "reputation", prices.PopulationPercentagePenalty)
-- Hospital Value
if hosp.value > prices.HospValueAward then
-- added some here so you get odd amounts as in TH!
local win_value = prices.HospValueBonus * math.random(1, 15)
self:addAward(_S.trophy_room.hosp_value.awards[1], "reputation", win_value)
rep_amount = rep_amount + win_value
elseif hosp.value < prices.HospValuePoor then
-- added some here so you get odd amounts as in TH!
local lose_value = prices.HospValuePenalty * math.random(1, 15)
self:addAward(_S.trophy_room.hosp_value.penalty[1], "reputation", lose_value)
rep_amount = rep_amount + lose_value
end

-- Should these next few be linked so that you can only get one or should you get more than one if you met the targets?

-- Cures
if hosp.num_cured_ty > prices.CuresAward then
self:addAward(_S.trophy_room.many_cured.awards[math.random(1, 2)], "money", prices.CuresBonus)
won_amount = won_amount + prices.CuresBonus
elseif hosp.num_cured_ty < prices.CuresPoor then
self:addAward(_S.trophy_room.many_cured.penalty[math.random(1, 2)], "money", prices.CuresPenalty)
won_amount = won_amount + prices.CuresPenalty
end

-- Deaths
if hosp.num_deaths_this_year < prices.DeathsAward then
self:addAward(_S.trophy_room.no_deaths.awards[math.random(1, 2)], "money", prices.DeathsBonus)
won_amount = won_amount + prices.DeathsBonus
elseif hosp.num_deaths_this_year > prices.DeathsPoor then
self:addAward(_S.trophy_room.no_deaths.penalty[math.random(1, 2)], "money", prices.DeathsPenalty)
won_amount = won_amount + prices.DeathsPenalty
end

-- Cures V Deaths
-- This value is not really a ratio since the level files cannot contain decimal values.
local cure_ratio = 100
if hosp.num_deaths_this_year > 0 then
cure_ratio = hosp.num_cured_ty / hosp.num_deaths_this_year
end
if cure_ratio > prices.CuresVDeathsAward then
self:addAward(_S.trophy_room.curesvdeaths.awards[1], "money", prices.CuresVDeathsBonus)
won_amount = won_amount + prices.CuresVDeathsBonus
elseif cure_ratio <= prices.CuresVDeathsPoor then
self:addAward(_S.trophy_room.curesvdeaths.penalty[1], "money", prices.CuresVDeathsPenalty)
won_amount = won_amount + prices.CuresVDeathsPenalty
end

-- Now apply the won/lost values.
if won_amount ~= 0 then
hosp:receiveMoney(won_amount, _S.transactions.eoy_trophy_bonus)
end
if rep_amount ~= 0 then
hosp:changeReputation("year_end", nil, math.floor(rep_amount))
end
end
end

Expand Down Expand Up @@ -454,7 +521,7 @@ function UIAnnualReport:draw(canvas, x, y)
self.stone_font:draw(canvas, "+" .. info.amount, x + 220, y + 355, 200, 0)
elseif self.award_motivation then
local info = self.awards[self.award_motivation].info
self.write_font:drawWrapped(canvas, info.text, x + 225, y + 125, 185, "center")
self.write_font:drawWrapped(canvas, info.text, x + 235, y + 125, 165, "center")
-- Type of award
local award_type = _S.trophy_room.cash
if info.award_type == "reputation" then
Expand Down
2 changes: 2 additions & 0 deletions CorsixTH/Lua/entities/patient.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function Patient:treated() -- If a drug was used we also need to pay for this
self.world.ui.adviser:say(_A.information.first_cure)
end
self.hospital.num_cured = hospital.num_cured + 1
self.hospital.num_cured_ty = hospital.num_cured_ty + 1
local casebook = hospital.disease_casebook[self.disease.id]
casebook.recoveries = casebook.recoveries + 1
if self.is_emergency then
Expand Down Expand Up @@ -421,6 +422,7 @@ function Patient:goHome(cured)
if not self.is_debug then
hosp:changeReputation("kicked", self.disease)
self.hospital.not_cured = hosp.not_cured + 1
self.hospital.not_cured_ty = hosp.not_cured_ty + 1
local casebook = self.hospital.disease_casebook[self.disease.id]
casebook.turned_away = casebook.turned_away + 1
end
Expand Down
Loading

0 comments on commit c173ff5

Please sign in to comment.