new disaster framework

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
dev_null42
Engineer
Engineer
Posts: 4
Joined: 13 Jun 2007 02:36

new disaster framework

Post by dev_null42 »

One of the things that has bugged me about TTDP / OpenTTD is how disasters are done in the game. Whereas the game tries to be fairly realistic, disasters are very un-realistic. There are UFO landings, but no trail derailments or floodings. I realize that the game is not supposed to be like SimCity; nonetheless adding more disasters will bring variety to yet another fix-my-rail-line-after-XCom-strike.

I would like to implement a new framework to account for all of the suggestions for disasters:
My idea is thus:

1. Divide disasters into four categories.

Code: Select all

enum DisasterType {
  DISASTER_NATURAL = 0,
  DISASTER_VEHICLE,
  DISASTER_INDUSTRY,
  DISASTER_OTHER,
  DISASTER_MAX
};
(This will go into openttd.h)

Natural disasters would be forest fire, earthquake, floods, avalanche, and so forth. Currently none exist within the game.

Vehicle disasters would be plane crash upon landing, zepplin crash, broken train signal, train brake failure, road vehicle brake failure, and ship running aground. Only the first two currently exist.

Industry disasters would be oil refinery explosion, factory explosion, coal mine collapse, insect plague at farms, etc. The first three already exist.

Other disasters would be submarine attack and UFO landings. These are the disasters that I personally hate.

2. Each disaster type has an independent, customizable frequency.

The _opt structure contains a single variable that completely disables or enables all disasters. It would become an array of delay counters:

Code: Select all

struct GameDifficulty {
  // ...
  int disasters[DISASTER_MAX];
  // ...
};
Somewhere (I do not know where) there is a way for the user to adjust each of the four disaster frequency. To simplify things, each disaster type has four possible values: Frequent, Occasional, Rare, and Disabled.

3. Each disaster has its own delay loop.

In disaster_cmd.cpp there is a single counter, _disaster_delay, that governs when the next disaster occurs, with air crashes are treated differently. The proposal is to have four counters, each with a varying delay amount (ResetDisasterDelay()). Each counter will then trigger an appropriate disaster when it reaches zero.

I would like some comments before I implement these changes. Thanks.

Disclaimer: I am a long-time player of OpenTTD and have wanted to join development of the program. When I downloaded the source code I was pleasantly surprised at how well documented it was, as compared to other open source projects.
Chicago Rail Authority
Traffic Manager
Traffic Manager
Posts: 134
Joined: 09 Nov 2006 23:38

Post by Chicago Rail Authority »

Vehicle disasters would be plane crash upon landing, zepplin crash, broken train signal, train brake failure, road vehicle brake failure, and ship running aground. Only the first two currently exist.
I would really like to see train brake failures in the game... One question, though - would the train remain at speed until it hits something (or until a counter times-out), or would it coast to a stop (running through red-lights as it goes)?
Industry Disasters
Perhaps some type of disaster related to a power plant? In that scenario, if the power plant fails then perhaps all electrified rails (trams, eRails, etc.) could fail - bringing transit to a standstill for a specified period of time...

Sounds intersting, though... Good luck!
Welcome!!
Welcome to the forums, btw
Many thanks to those who make OTTD and TTDP possible.
kaan
Route Supervisor
Route Supervisor
Posts: 399
Joined: 02 Apr 2007 20:13
Location: Nørup, Denmark

Post by kaan »

Welcome to the forums :)
I think this sounds like a brilliant idea, please go ahead and implement it.
One thing you forgot is road vehicles being blown up by trains at road crossings.

Edit: and of course the common train collision.

Code: Select all

if (YouAreHappyAndYouKnowIt) {
    ClapYourHands();
}
G. Stephenson
Engineer
Engineer
Posts: 2
Joined: 13 Mar 2017 17:39

Re:

Post by G. Stephenson »

I was looking for more NewGrf and I found this post. I think it's an amazing idea but I don't know how to program it. Can someone try to add these ideas to the game? I would love that...

Pd: please excuse my poor English, Spanish is my main language...
Kruemelchen
Transport Coordinator
Transport Coordinator
Posts: 287
Joined: 18 Feb 2017 17:47

Re: new disaster framework

Post by Kruemelchen »

I'd be great to have to deal with strikes, as to
A) certain random vehicle type go to the nearest depot and remain for some time
B) certain random industry doesn't produce and accept cargo for some time
C) certain random train station / airport / port doesn't allow trains / ships / airplanes to drive in / land / stop for some time

Though I don't know how difficult such an implementation would be. Probably easier than flooding, I guess?

Anyways, it's great someone is looking into the disaster feature! UFO strikes etc. always bugged me, so I'm welcoming your attempt to separate the different disaster types!
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: new disaster framework

Post by Alberth »

You're about a decade late to the party.
Being a retired OpenTTD developer does not mean I know what I am doing.
G. Stephenson
Engineer
Engineer
Posts: 2
Joined: 13 Mar 2017 17:39

Re: new disaster framework

Post by G. Stephenson »

Alberth wrote:You're about a decade late to the party.
But, the idea is a good idea... And I downloaded a recent version that had the current disasters... I think it will be great to have more disasters... And more common.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: new disaster framework

Post by Alberth »

The OP last posts were in 2010, to publish a patch for this idea in viewtopic.php?f=33&t=51458&hilit=disaster+framework
There seem quite a few open-ended points in that thread.
There is also a patch submitted for inclusion in trunk at https://bugs.openttd.org/task/4286 but that suffers from the same problem, it's not finished.

Since the OP hasn't posted since, I suspect he has gone or at least he has no intentions of finishing this patch any more. Feel free to pick where he left off, or perhaps simpler, learn from this attempt, and make something better.
Being a retired OpenTTD developer does not mean I know what I am doing.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 53 guests