My favorites | Sign in
Project Home Downloads Wiki Issues
New issue   Search
  Advanced search   Search tips   Subscriptions
Issue 1241: Earthquakes patch submission
9 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Oct 2012

Sign in to add a comment
Reported by, May 3, 2012
This is a patch which adds earthquake functionality to the game. This patch randomly generates a date when an earthquake will take place, and when the hospital reaches that date and provided that the user is on at least level 5 of the game, then the receptionist announces a warning that an earthquake is about to take place.

The screen will then shake from side to side and up and down as the earthquake is in progress. At the end of every day that the earthquake is happening, random damage (can be equal to 0) is given to machines in the hospital. Any machines damaged too greatly will blow up, and the room will become unusable.

The greater the earthquake on the Richter scale, the longer the earthquake will continue for (maximum 3 days) and so the higher the probability that machines will become severely damaged. In addition, the greater the earthquake, the more violently the user's screen will shake around. If the earthquake is above 7 on the Richter scale, the adviser will pop up and point that out as per the original.

Patients randomly falling down is *not* implemented in this patch. I've taken a look at that and using some available code for this written (Patient:falling()) starts blowing up action queues for patients in a variety of fun ways. This functionality is intended to be added in a subsequent patch.

Have a look through and let me know if you have any questions/comments etc. Cheers!

9.3 KB   View   Download
May 4, 2012
Project Member #1
Nice. Will try to test this tonight!

Just a question:
Is the date drawn at the start of each level?
Can there be several earthquakes at one level? Is there a possibility that there will be no earthquake at a level (above level 5)?

May 4, 2012
Yes, at the start of the level a date is drawn where an earthquake will take place. There can be several earthquakes in one level as after an earthquake finishes, a new date is drawn where the next earthquake will take place.

Earthquakes are currently generated at the same random frequency as VIP visits. It's not really possible for the user to finish a level >= 5 without an earthquake occurring, as to do so they would need to complete the level within about 7-8 months.
May 4, 2012
Project Member #3
nice job with the quakes, there is one thing I have noticed with the screen movement, should your screen position return to where it was before the quake started? I ended up on the edge of the map.

there may be a bug in the room or machine code as the tongue cutter is still around but cleary has exploded with all the soot on the walls.

288 KB   View   Download
May 4, 2012
Project Member #4
Something else I just noticed is the damaged machines are not calling to be repaired.  This maybe an issue with the calls dispatcher or it maybe you intended this, but I would have expected with the machine usage going up like that there would be an handyman on the way - even an announcement on those lines.
May 4, 2012
Thanks for the comments!

I wonder about the screen movement returning to its original position. I don't think it did in the original if memory serves (can anyone verify this?), but that's certainly something I could add in there. I guess I could just jump the user back to whatever they were looking at before the earthquake began.

Indeed there may be a bug with the tongue cutter, it may be worth filing a separate bug for that as that behavior won't be limited to the this patch (I'm just calling the Room:crashRoom() function for that).

The handyman stuff isn't working I agree, it seems that they will wander around for an infinite amount of time while a machine is on its last legs. Perhaps it would be better instead of doing what I'm doing at the moment (updating the times_used, then crashing the room if it's too high) to call the Machine:machineUsed() function which will call out for handymen if the machines have to be repaired? That seems like a better solution and would solve this problem.
May 5, 2012
Project Member #7
I agree on calling machineUsed. An addition you can look at if you want is to read quake dates from the level files. They work in much the same way as emergencies. It's called "quake_control". The combination of being able to specify exact dates or possibly just let it be random on custom levels is best in my opinion. This is also possible for emergencies.
Status: Started
Labels: -Priority-Medium Priority-High
May 5, 2012
Project Member #8
With regard to the screen movement, I will try to verify one way or the other at some point this week.  I suspect that it was not so obvious in TH as your view was somewhat limited, so you were not able to see much beyond any of the buildings.

Something I think you have missed - but I will need to verify this too - is the tremor.  I seem to remember that before any quake there would be a slight tremor first, then the warnings from either the adviser or an announcement (maybe it was both) that there was an earthquake on the way - or something like that.   It would then be followed days later by the actual earthquake.
May 5, 2012
Project Member #9
I might be wrong, but I think tremors happened only for some quakes, and possibly only for the big ones so that you had some time to prepare your machines.
May 6, 2012
Just a quick update from me, for anyone who is trying out earthquakes, please do try out this new patch instead of the old one (updates: pausing during earthquakes will pause the screen shaking, quake_control in level configs in adhered to (thanks Edvin!), machineUsed() is now called (so handymen will attend to machines when they are in need of repair), earthquakes now work on custom levels). Still on the todo list are returning the screen to the original position and having a minor quake before a big one (I'll code this up once we find out if they're verified) and patients falling down.

Edvin, thanks for bringing quake_control to my attention, I've modified the patch to take this into account. I made it so that once we run out of earthquake date information from the level files they become random.
11.3 KB   View   Download
May 7, 2012
Did some testing on TH, i can confirm that:

1. There's a small quake/shake before the big quake. 

2. An "Attention, earthquake reported" announcement is made and the eathquake lasts about a day.

3. 6 to 9 days after the small quake (the period seems to vary), the big one happens and an "Warning earthquake imminent" announcement is made. The big quake lasts 2-3 days.

4. The screen does not return to the original position.
May 7, 2012
I have a question.
How can I try a the patch for earthquakes?
I can't find something in the wiki.
May 7, 2012
Hi. Just echoing the last comment. Could someone please indicate where to place the file to get the patch to work. In the theme hospital or corsix folder... Thanks this would be a big help.
May 7, 2012
Here you go just put those lua files in your Corsix directory. As always back up the old ones and get the latest revision
56.8 KB   Download
May 7, 2012
By the way I did a quick game it seems to be working as intended.
May 7, 2012
Project Member #16
I can confirm that there is a tremor before the main quake in TH.
The view does not return to where it started, but it does not move too far either.
something that I did think odd was the adviser reports it as being 8 on the richter scale, but the severity in the level files was not 8.  I seem to think he says the same each time, it was always an 8 even when it shook your machines to dust.  Anyone seen a different number?
May 8, 2012
But how can you open a .diff file or an other patch?

May 8, 2012
Project Member #18
You can for example use the program "Tortoise SVN" if you use Windows.
May 8, 2012
And after the opening how can I apply the patch?
He is saying something about that it isn't a copy.
May 8, 2012
Project Member #20
@ john

As the screen shaking is greater in your patch than TH (this maybe down to the fact we can see more of the screen in CTH) I wondered whether you could either make it return to or close to the starting position or retrict it to the hospital only?
As I said in an earlier comment I ended up off the map and as time could be limited in finding damaged machines, valuable time could be lost finding your hospital as it is now.  Especially if you were zoomed in at the time; as I was!
As an alternative having an hot key say H return you to the main door area would/could help.
May 9, 2012
#21 boltie
You don't want it to return to where you were when the earthquake started. Otherwise, you could move around the hospital during the quake and when it ends you suddenly jump across the map. You just need it to offset the view of the users current position changing the offset with 3 or 4 different values each second or so.
May 23, 2012
Project Member #22
@20: "As an alternative having an hot key say H return you to the main door area would/could help." I like this Idea. Maybe pressing H would take you to the helipad?

May 27, 2012
Just a quick ping to say I am still alive, things have become suddenly very busy at the moment. I'll come back around to this when my supervisor stops giving me stacks of papers to read, my first year viva is approaching and is eating all my time. Alas! :-(
May 31, 2012
Project Member #24
I finally have some time to spare on this project again. :-) I've had a look at your code and have a few comments:

1. I think the createEarthquake function is better off in world.lua. The difference compared to emergencies is that an emergency goes to a specific hospital whereas an earthquake affects the whole world. I know that there are other things in the wrong place too, but I'm trying to move things around now and then to make it more logical.

2. There are a few tabs here and there, nothing to worry about, but just mentioning it. :-)

3. There might exist a more descriptive name for the function "earthquake"? Like tickEarthquake or something.
Jul 15, 2012
Project Member #25
Is there a chance this could make it to the next release? :)
Jul 15, 2012
Depends when the next release is planned for, is there a date set? My viva is this coming week so the earliest I could work on this would be sometime in the week after
Jul 15, 2012
Project Member #27
No, as far as I know there isn't set a date.

I just asked because I got some questions on Facebook.
Focus on your viva. And good luck! :)
Aug 8, 2012
Project Member #28
How is this coming about? Any updates jpirie23?
Aug 8, 2012
I finished all my viva stuff now, I'm hoping to get some time to work on corsix-th this weekend and subsequent weekends. Good times!

I might get an evening free this week to work on this, time is much better for me now. When we hit mid-september I might suddenly get very busy again, but I expect earthquakes to be done by that point at least.
Aug 16, 2012
Project Member #30
I would really love to have this added in the next release, and I don't think there's much left to do, mostly some tweaks, for example some of the things in Comment 24 maybe.

Looking forward to a fresh patch. :-D
Labels: Milestone-0.10
Aug 16, 2012
Everything in comment 24 his been done I think, I just have a few more things to do. I hope to have another patch submitted this weekend with any luck. :-)
Aug 20, 2012
Just a quick update from me. The earthquake now doesn't shake the user off into some corner of the map, there is an imaginary box around the point where the earthquake starts, and the user won't be shaken outside of that imaginary box. I still have to make a small quake before the bigger quake, then I'll do some light testing and send in a patch. I'm hoping to get some time for that in the next day or two, depends how quickly I solve some pesky phd problems.... :o)
Aug 21, 2012
#33 boltie
I haven't tried any earthquake version yet, but from what you state above it sounds like you won't be able to move outside that box even if you moved to the edge of the screen during the quake? Am I correct or does the box move with the users position?
Aug 27, 2012
Hi all, an updated patch from me is attached. I think this should cover everything that's been mentioned but if you spot anything let me know. Play around with it if you manage to find some time and let me know what you think. :-)

boltie: the imaginary box with move with the user if they try to move so that shouldn't be a problem.
12.9 KB   View   Download
Aug 29, 2012
Project Member #35
I have added it to trunk now.
Sep 11, 2012
Project Member #36
Got an error when playing normally on level 5.
Game freezes (no green box in-game, and I can exit as usual, but game can't run).
Added a savegame right before I got the error.

A stack trace is included below, and the handler has been disconnected.
C:\Games\CorsixTH\CorsixTH\Lua\audio.lua:287: attempt to call method 'soundExist
s' (a nil value)
stack traceback:
        C:\Games\CorsixTH\CorsixTH\Lua\audio.lua:287: in function 'soundExists'
        C:\Games\CorsixTH\CorsixTH\Lua\world.lua:560: in function 'tickEarthquak
        C:\Games\CorsixTH\CorsixTH\Lua\world.lua:904: in function 'onTick'
        C:\Games\CorsixTH\CorsixTH\Lua\app.lua:710: in function <C:\Games\Corsix
        (tail call): ?
        C:\Games\CorsixTH\CorsixTH\Lua\app.lua:612: in function <C:\Games\Corsix

307 KB   Download
Sep 11, 2012
Project Member #37
As you might have guessed, this happens just before an earthquake (I hear the lady announce it).
Sep 11, 2012
Project Member #38
Have you compiled the game recently?
Sep 12, 2012
Project Member #39
The point of api_version.lua is to warn against that, is it out of date?
Sep 12, 2012
Project Member #40
I recently reinstalled v0.01b, and updated it with the newest revision.
Sep 12, 2012
Project Member #41
How did you update it with the newest revision? Only the Lua files? And it still doesn't say "Your binary is out of date" in the console?

api_version.lua is up to date.
Sep 17, 2012
Project Member #42
I got to test it again now. And I get this in the start:

Consider replacing Lua with LuaJIT to improve performance. Note that there is no
t currently a 64 bit version of LuaJIT.
Warning: Compiled binary is out of date. CorsixTH will likely fail to run until
you recompile the binary.

Sep 23, 2012
Project Member #43
I just tested it with v0.10RC, and the error isn't happening! :)
Sep 30, 2012
Hi, I think there is a problem with earthquake functionality - after an earthquake the game is mostly unplayalbe:
a) game freezes
b) or show dialog with recovery option. Either action (yes/no) allows game to run but nothing cannot be clicked
This happens most of the time. When I am lucky and no machine is destroyed, game runs smoothly
Sep 30, 2012
I'm having the same problem "46" has after a quake.

When a machine is destroyed and a patient is trying to knock on the room or a repairman is trying to enter the room to do repair work the game stops and I get the recovery dialog option. If more than one machine is broken the recovery dialog will pop up again with the same error. Here's the excerpt from the log:

D:\Games\CorsixTH\Lua\humanoid_actions\walk.lua:219: attempt to index field 'queue' (a nil value)
stack traceback:
	D:\Games\CorsixTH\Lua\humanoid_actions\walk.lua:219: in function <D:\Games\CorsixTH\Lua\humanoid_actions\walk.lua:201>
	(tail call): ?
	D:\Games\CorsixTH\Lua\humanoid_actions\walk.lua:179: in function 'timer_function'
	D:\Games\CorsixTH\Lua\entity.lua:165: in function 'tick'
	D:\Games\CorsixTH\Lua\entities\staff.lua:146: in function 'tick'
	D:\Games\CorsixTH\Lua\world.lua:958: in function 'onTick'
	D:\Games\CorsixTH\Lua\app.lua:734: in function <D:\Games\CorsixTH\Lua\app.lua:732>
	(tail call): ?
	D:\Games\CorsixTH\Lua\app.lua:636: in function 

If no machine is destroyed after a quake the game works just fine.

Oct 1, 2012
It looks like what happens here is that when a room is destroyed but someone is already interacting with the door (or perhaps walking to it? But this should be handled already (see Room:deactivate())?) the game throws an exception because they are then interacting with an object which doesn't exist.

I see some code there to set the door's user (line 622 of room.lua) to nil, though I think this will only catch cases when people are leaving the room rather than entering it (someone else might know the specifics of that).

I'm guessing this probably hasn't been caught before because the only way that a room could blow up before was if it was being used, and in that case no-one would be trying to enter anyway.

The fix may just be as simple as adding a 'if door.queue' statement, but I'll have to test this...
Oct 2, 2012
I've attached a patch which fixes the case where when a user is knocking on the door and the room is destroyed, and the game dies. I've also applied this to when the user is walking to the room, as I detected that blew up too.
856 bytes   View   Download
Oct 2, 2012
I used your update and while it did stop the game from crashing, it's now causing the repairman to walk trough the door of the broken room without opening it and continue to walk in a straight line trough walls and objects.

Here's a save I have, I tried it a few times and a very big earthquake always happen after about 3 or 4 minutes of play, destroying most of the machines. I think it could be useful for testing.
378 KB   Download
Oct 2, 2012
Thanks for this save file! It will be useful indeed, I'll look into that.

If anyone familiar with handyman code wants to take a peek also that might be nice.
Oct 3, 2012
Project Member #52
I think that part of the problem is that the handymen are trying to clean the soot from the exploded machine. If you manage to click on any of them before they get to the door you will see that cleaning is their next task.
I have tried to make soot a type of litter that is not cleanable, but annoyingly they then ignore all the litter.  (it is that long since I looked at lua I am no doubt doing something wrong)
I am sure that you will see a way around it though :)
Oct 5, 2012
I've had a quick stab at it with the few minutes I had this evening. This problem extends to all rooms which have exploded so I'm going to open a new bug for this.

A quick-hack patch to stop Lua from exploding and handymen walking off never to be seen again is attached in the new bug report. Note that the handymen will keep coming back to the room which has exploded (I'm resetting their action queue), so this is not a full fix. New bug id is #1322.
Oct 9, 2012
hi im wondering what to do with the diff files do i need to put them somewhere or extract them
Oct 9, 2012
Project Member #55
I would do nothing with this one as the issue has been fixed and earthquakes work fine now.
Oct 9, 2012
oh ok thanks
Oct 16, 2012
Project Member #57
 Issue 1337  has been merged into this issue.
Oct 16, 2012
Project Member #58
I have merged  issue 1337  as it seems that if the sound-0 file is missing the game crashes at the point of the quake.  The game does not crash for other sounds though when this file is missing, maybe you can see why jpirie23?
Oct 16, 2012
Project Member #62
with regard to  issue 1337 .  I think I have tracked down the problem.  In world.lua there is a comment against tick sound that the rumble sound has different names depending on the language, so I have used the position number instead as it is always in the same position.
764 bytes   View   Download
Oct 16, 2012
Project Member #63
 Issue 1337  is now resolved with this patch! It works now with and without the sound-o.dat-file!
Oct 16, 2012
Project Member #64
This issue was closed by revision r1670.
Status: Fixed
Oct 16, 2012
Project Member #65
Someone posted about the problem in 1337 somewhere a few weeks ago, but I seem to have forgotten to commit the fix... :-P
I've closed this issue now since I believe most bugs regarding earthquakes have been fixed.
Oct 16, 2012
Project Member #66
I can remember the issue, but I can't find it either 
Oct 16, 2012
Project Member #67
Is it  issue 1149 ?
Oct 16, 2012
Project Member #68
Or is it  issue 1246 ?
Sign in to add a comment

Powered by Google Project Hosting