# disaster_cmd.cpp File Reference

All disaster/easter egg vehicles are handled here. More...

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "landscape.h"`
`#include "industry_map.h"`
`#include "station_map.h"`
`#include "command_func.h"`
`#include "tile_cmd.h"`
`#include "news.h"`
`#include "station.h"`
`#include "waypoint.h"`
`#include "town.h"`
`#include "industry.h"`
`#include "player_func.h"`
`#include "airport.h"`
`#include "variables.h"`
`#include "settings_type.h"`
`#include "strings_func.h"`
`#include "date_func.h"`
`#include "functions.h"`
`#include "vehicle_func.h"`
`#include "vehicle_base.h"`
`#include "sound_func.h"`
`#include "roadveh.h"`
`#include "table/strings.h"`
`#include "table/sprites.h"`

Go to the source code of this file.

## Typedefs
typedef void | DisasterVehicleTickProc (Vehicle *v)
typedef void | DisasterInitProc ()
## Enumerations
enum | DisasterSubType { ST_Zeppeliner, ST_Zeppeliner_Shadow, ST_Small_Ufo, ST_Small_Ufo_Shadow, ST_Airplane, ST_Airplane_Shadow, ST_Helicopter, ST_Helicopter_Shadow, ST_Helicopter_Rotors, ST_Big_Ufo, ST_Big_Ufo_Shadow, ST_Big_Ufo_Destroyer, ST_Big_Ufo_Destroyer_Shadow, ST_Small_Submarine, ST_Big_Submarine }
## Functions
static void | DisasterClearSquare (TileIndex tile)
static void | DisasterVehicleUpdateImage (Vehicle *v)
static void | InitializeDisasterVehicle (Vehicle *v, int x, int y, byte z, Direction direction, byte subtype)
| Initialize a disaster vehicle.
static void | DeleteDisasterVeh (Vehicle *v)
static void | SetDisasterVehiclePos (Vehicle *v, int x, int y, byte z)
static void | DisasterTick_Zeppeliner (Vehicle *v)
| Zeppeliner handling, v->current_order.dest states: 0: Zeppeliner initialization has found a small airport, go there and crash 1: Create crash and animate falling down for extra dramatic effect 2: Create more smoke and leave debris on ground 2: Clear the runway after some time and remove crashed zeppeliner If not airport was found, only state 0 is reached until zeppeliner leaves map.
static void | DisasterTick_Ufo (Vehicle *v)
| (Small) Ufo handling, v->current_order.dest states: 0: Fly around to the middle of the map, then randomly, after a while target a road vehicle 1: Home in on a road vehicle and crash it >:) If not road vehicle was found, only state 0 is used and Ufo disappears after a while
static void | DestructIndustry (Industry *i)
static void | DisasterTick_Airplane (Vehicle *v)
| Airplane handling, v->current_order.dest states: 0: Fly towards the targetted oil refinery 1: If within 15 tiles, fire away rockets and destroy industry 2: Refinery explosions 3: Fly out of the map If the industry was removed in the meantime just fly to the end of the map.
static void | DisasterTick_Helicopter (Vehicle *v)
| Helicopter handling, v->current_order.dest states: 0: Fly towards the targetted factory 1: If within 15 tiles, fire away rockets and destroy industry 2: Factory explosions 3: Fly out of the map.
static void | DisasterTick_Helicopter_Rotors (Vehicle *v)
| Helicopter rotor blades; keep these spinning.
static void | DisasterTick_Big_Ufo (Vehicle *v)
| (Big) Ufo handling, v->current_order.dest states: 0: Fly around to the middle of the map, then randomly for a while and home in on a piece of rail 1: Land there and breakdown all trains in a radius of 12 tiles; and now we wait.
static void | DisasterTick_Big_Ufo_Destroyer (Vehicle *v)
| Skyranger destroying (Big) Ufo handling, v->current_order.dest states: 0: Home in on landed Ufo and shoot it down.
static void | DisasterTick_Submarine (Vehicle *v)
| Submarine, v->current_order.dest states: Unused, just float around aimlessly and pop up at different places, turning around.
static void | DisasterTick_NULL (Vehicle *v)
static void | Disaster_Zeppeliner_Init ()
| Zeppeliner which crashes on a small airport if one found, otherwise crashes on a random tile.
static void | Disaster_Small_Ufo_Init ()
| Ufo which flies around aimlessly from the middle of the map a bit until it locates a road vehicle which it targets and then destroys.
static void | Disaster_Airplane_Init ()
static void | Disaster_Helicopter_Init ()
| Combat helicopter that destroys a factory.
static void | Disaster_Big_Ufo_Init ()
static void | Disaster_Small_Submarine_Init ()
static void | Disaster_Big_Submarine_Init ()
static void | Disaster_CoalMine_Init ()
| Coal mine catastrophe, destroys a stretch of 30 tiles of land in a certain direction.
static void | DoDisaster ()
static void | ResetDisasterDelay ()
void | DisasterDailyLoop ()
void | StartupDisasters ()
## Variables
static const SpriteID | _disaster_images_1 [] = {SPR_BLIMP, SPR_BLIMP, SPR_BLIMP, SPR_BLIMP, SPR_BLIMP, SPR_BLIMP, SPR_BLIMP, SPR_BLIMP}
static const SpriteID | _disaster_images_2 [] = {SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT, SPR_UFO_SMALL_SCOUT}
static const SpriteID | _disaster_images_3 [] = {SPR_F_15, SPR_F_15, SPR_F_15, SPR_F_15, SPR_F_15, SPR_F_15, SPR_F_15, SPR_F_15}
static const SpriteID | _disaster_images_4 [] = {SPR_SUB_SMALL_NE, SPR_SUB_SMALL_NE, SPR_SUB_SMALL_SE, SPR_SUB_SMALL_SE, SPR_SUB_SMALL_SW, SPR_SUB_SMALL_SW, SPR_SUB_SMALL_NW, SPR_SUB_SMALL_NW}
static const SpriteID | _disaster_images_5 [] = {SPR_SUB_LARGE_NE, SPR_SUB_LARGE_NE, SPR_SUB_LARGE_SE, SPR_SUB_LARGE_SE, SPR_SUB_LARGE_SW, SPR_SUB_LARGE_SW, SPR_SUB_LARGE_NW, SPR_SUB_LARGE_NW}
static const SpriteID | _disaster_images_6 [] = {SPR_UFO_HARVESTER, SPR_UFO_HARVESTER, SPR_UFO_HARVESTER, SPR_UFO_HARVESTER, SPR_UFO_HARVESTER, SPR_UFO_HARVESTER, SPR_UFO_HARVESTER, SPR_UFO_HARVESTER}
static const SpriteID | _disaster_images_7 [] = {SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER, SPR_XCOM_SKYRANGER}
static const SpriteID | _disaster_images_8 [] = {SPR_AH_64A, SPR_AH_64A, SPR_AH_64A, SPR_AH_64A, SPR_AH_64A, SPR_AH_64A, SPR_AH_64A, SPR_AH_64A}
static const SpriteID | _disaster_images_9 [] = {SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1}
static const SpriteID *const | _disaster_images []
static DisasterVehicleTickProc *const | _disastervehicle_tick_procs []
static DisasterInitProc *const | _disaster_initprocs []
struct {
Year min
Year max
} | _dis_years []

## Detailed Description

All disaster/easter egg vehicles are handled here.

The general flow of control for the disaster vehicles is as follows:

1. Initialize the disaster in a disaster specific way (eg start position, possible target, etc.) Disaster_XXX_Init() function
2. Add a subtype to a disaster, which is an index into the function array that handles the vehicle's ticks.
3. Run the disaster vehicles each tick until their target has been reached, this happens in the DisasterTick_XXX() functions. In here, a vehicle's state is kept by v->current_order.dest variable. Each achieved sub-target will increase this value, and the last one will remove the disaster itself

Definition in file disaster_cmd.cpp.

## Function Documentation

static void DisasterTick_Big_Ufo | ( | Vehicle * | v | ) | `[static]`

(Big) Ufo handling, v->current_order.dest states: 0: Fly around to the middle of the map, then randomly for a while and home in on a piece of rail 1: Land there and breakdown all trains in a radius of 12 tiles; and now we wait.

.. because as soon as the Ufo lands, a fighter jet, a Skyranger, is called to clear up the mess

Definition at line 566 of file disaster_cmd.cpp.

References AddNewsItem(), Delta(), DIR_SW, GetTileOwner(), InitializeDisasterVehicle(), IsPlainRailTile(), IsTileType(), MP_RAILWAY, NEWS_FLAGS, NF_TILE, NF_VIEWPORT, NM_THIN, NT_ACCIDENT, RandomTile, TILE_MASK, TILE_SIZE, TileX(), and TileY().

static void InitializeDisasterVehicle | ( | Vehicle * | v,
|  | int | x,
|  | int | y,
|  | byte | z,
|  | Direction | direction,
|  | byte | subtype |
| ) |  |  | `[static]`

Initialize a disaster vehicle.

These vehicles are of type VEH_DISASTER, are unclickable and owned by nobody

Definition at line 129 of file disaster_cmd.cpp.

References INVALID_DIR, MarkSingleVehicleDirty(), and OWNER_NONE.

Referenced by Disaster_Helicopter_Init(), Disaster_Small_Ufo_Init(), Disaster_Zeppeliner_Init(), and DisasterTick_Big_Ufo().

## Variable Documentation

const SpriteID* const _disaster_images[]`[static]`

Initial value:

     {
      _disaster_images_1, _disaster_images_1,
      _disaster_images_2, _disaster_images_2,
      _disaster_images_3, _disaster_images_3,
      _disaster_images_8, _disaster_images_8, _disaster_images_9,
      _disaster_images_6, _disaster_images_6,
      _disaster_images_7, _disaster_images_7,
      _disaster_images_4, _disaster_images_5,
    }

Definition at line 110 of file disaster_cmd.cpp.

DisasterInitProc* const _disaster_initprocs[]`[static]`

Initial value:

     {
      Disaster_Zeppeliner_Init,
      Disaster_Small_Ufo_Init,
      Disaster_Airplane_Init,
      Disaster_Helicopter_Init,
      Disaster_Big_Ufo_Init,
      Disaster_Small_Submarine_Init,
      Disaster_Big_Submarine_Init,
      Disaster_CoalMine_Init,
    }

Definition at line 1003 of file disaster_cmd.cpp.

DisasterVehicleTickProc* const _disastervehicle_tick_procs[]`[static]`

Initial value:

     {
      DisasterTick_Zeppeliner, DisasterTick_NULL,
      DisasterTick_Ufo,        DisasterTick_NULL,
      DisasterTick_Airplane,   DisasterTick_NULL,
      DisasterTick_Helicopter, DisasterTick_NULL, DisasterTick_Helicopter_Rotors,
      DisasterTick_Big_Ufo,    DisasterTick_NULL, DisasterTick_Big_Ufo_Destroyer,
      DisasterTick_NULL,
      DisasterTick_Submarine,
      DisasterTick_Submarine,
    }

Definition at line 739 of file disaster_cmd.cpp.