Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

source/disaster.c File Reference

routines associated with disasters More...

#include <config.h>
#include <handler.h>
#include <drawing.h>
#include <zakdef.h>
#include <logging.h>
#include <locking.h>
#include <ui.h>
#include <globals.h>
#include <build.h>
#include <disaster.h>
#include <simulation.h>
#include <stdio.h>

Go to the source code of this file.

Functions

void FireSpread (UInt16 x, UInt16 y) DISASTER_SECTION
 Cause a fire to spread out from the point chosen.

void CreateWaste (UInt16 x, UInt16 y) DISASTER_SECTION
 Turn the zone into wasteland.

UInt16 GetDefenceValue (UInt16 xpos, UInt16 ypos) DISASTER_SECTION
 Get the value of the defence fields around this point.

UInt16 ContainsDefence (UInt16 x, UInt16 y) DISASTER_SECTION
 check if the node has a defence position within it.

void MonsterCheckSurrounded (UInt16 i) DISASTER_SECTION
 Check if a monster is surrounded by defensive units.

void CreateMeteor (UInt16 x, UInt16 y, Int16 size) DISASTER_SECTION
 Create a waste zone for the meteor.

void DoCommitmentNasties (void)
 perform nasties to zones if they are not being completely funded

void DoNastyStuffTo (welem_t type, UInt16 probability, UInt8 purge)
 Do nasty things to a location.

void DoRandomDisaster (void)
 Do a random disaster.

void DoSpecificDisaster (disaster_t disaster)
 Deliberately cause a disaster.

Int16 UpdateDisasters (void)
 Make sure the disasters are still happening.

Int16 BurnField (UInt16 x, UInt16 y, Int16 forceit)
 burn the field specified.

Int16 CreateMonster (UInt16 x, UInt16 y)
 Create a 'zilla at the location specified.

Int16 CreateDragon (UInt16 x, UInt16 y)
 Create a dragon at the location.

void MoveAllObjects (void)
 Move all the moveable elements around the screen.

Int16 MeteorDisaster (UInt16 x, UInt16 y)
 We've had a meteor strike on the map at that location.


Detailed Description

routines associated with disasters

This module contains functions that are used to create disasters in the simulation.

Definition in file disaster.c.


Function Documentation

Int16 BurnField UInt16    x,
UInt16    y,
Int16    forceit
 

burn the field specified.

Can be forced to burn.

Parameters:
x  position on horizontal of map to spread fire
y  position on vertical of map to spread fire
forceit  force the field to burn
Returns:
true if field was burned.

Definition at line 233 of file disaster.c.

References bc_fire, Build_Destroy(), ContainsDefence(), DrawCross(), getWorld(), Int16, LockZone(), lz_flags, lz_world, setWorldAndFlag(), UInt16, UnlockZone(), welem_t, and WORLDPOS.

Referenced by CreateMeteor(), DoSpecificDisaster(), FireSpread(), and MoveAllObjects().

UInt16 ContainsDefence UInt16    x,
UInt16    y
[static]
 

check if the node has a defence position within it.

If it does, return the value of that defence.

Parameters:
x  horizontal location
y  vertical location
Returns:
the level of defence that this node provides.

Definition at line 356 of file disaster.c.

References NUM_OF_UNITS, and UInt16.

Referenced by BurnField(), and GetDefenceValue().

Int16 CreateDragon UInt16    x,
UInt16    y
 

Create a dragon at the location.

Parameters:
x  position on horizontal of map to spread fire
y  position on vertical of map to spread fire
Returns:
true if dragon was created

Definition at line 288 of file disaster.c.

References DrawField(), GetRandomNumber(), getWorld(), LockZone(), lz_flags, lz_world, obj_dragon, UInt16, UnlockZone(), welem_t, and WORLDPOS.

Referenced by DoSpecificDisaster().

void CreateMeteor UInt16    x,
UInt16    y,
Int16    size
[static]
 

Create a waste zone for the meteor.

Parameters:
x  horizontal position
y  vertical position
size  size of the meteor

Definition at line 489 of file disaster.c.

References Build_Destroy(), BurnField(), CreateWaste(), getMapHeight, getMapWidth, GetRandomNumber(), getWorld(), Int16, LockZone(), lz_flags, lz_world, RedrawAllFields(), setWorldAndFlag(), UILockScreen(), UInt16, UIUnlockScreen(), UnlockZone(), and WORLDPOS.

Referenced by MeteorDisaster().

Int16 CreateMonster UInt16    x,
UInt16    y
 

Create a 'zilla at the location specified.

Parameters:
x  position on horizontal of map to spread fire
y  position on vertical of map to spread fire
Returns:
true if monster was created

Definition at line 266 of file disaster.c.

References DrawField(), GetRandomNumber(), getWorld(), LockZone(), lz_flags, lz_world, obj_monster, UInt16, UnlockZone(), welem_t, and WORLDPOS.

Referenced by DoSpecificDisaster().

void CreateWaste UInt16    x,
UInt16    y
[static]
 

Turn the zone into wasteland.

Parameters:
x  x position to affect
y  y position to affect

Definition at line 532 of file disaster.c.

References bc_waste, Build_Destroy(), diPlantExplosion, DrawCross(), FireSpread(), getWorld(), IsRoadBridge(), LockZone(), lz_flags, lz_world, setWorldAndFlag(), UInt16, UnlockZone(), welem_t, and WORLDPOS.

Referenced by CreateMeteor(), DoNastyStuffTo(), MoveAllObjects(), and UpdateDisasters().

void DoNastyStuffTo welem_t    type,
UInt16    probability,
UInt8    purge
 

Do nasty things to a location.

turns a zone into wasteland based on the normalized probability.

Parameters:
type  of zone that can be affected
probability  the normalized probability of something bad happens
purge  remove a tile if it's found

Definition at line 58 of file disaster.c.

References Build_Destroy(), CreateWaste(), getMapWidth, GetRandomNumber(), getWorld(), LockZone(), lz_flags, lz_world, MapMul, UInt16, UInt32, UInt8, UnlockZone(), and welem_t.

Referenced by DoUpkeep().

void DoSpecificDisaster disaster_t    disaster
 

Deliberately cause a disaster.

Parameters:
disaster  the type of the disaster to cause.

Definition at line 132 of file disaster.c.

References BurnField(), CreateDragon(), CreateMonster(), diDragon, diFireOutbreak, diMeteor, diMonster, diPlantExplosion, disaster_t, getMapHeight, getMapWidth, GetRandomNumber(), Goto(), Int16, MapHasJumped(), MapMul, MeteorDisaster(), UInt16, and UInt32.

Referenced by DoRandomDisaster().

void FireSpread UInt16    x,
UInt16    y
[static]
 

Cause a fire to spread out from the point chosen.

Parameters:
x  position on horizontal of map to spread fire
y  position on vertical of map to spread fire

Definition at line 220 of file disaster.c.

References BurnField(), getMapHeight, getMapWidth, and UInt16.

Referenced by CreateWaste(), and UpdateDisasters().

UInt16 GetDefenceValue UInt16    xpos,
UInt16    ypos
[static]
 

Get the value of the defence fields around this point.

Parameters:
xpos  horizontal location
ypos  vertical location
Returns:
the 'level' of the defence surrounding the position.

Definition at line 330 of file disaster.c.

References ContainsDefence(), and UInt16.

Referenced by MonsterCheckSurrounded(), and UpdateDisasters().

Int16 MeteorDisaster UInt16    x,
UInt16    y
 

We've had a meteor strike on the map at that location.

Parameters:
x  horizontal position
y  vertical position
Returns:
always happens (true)

Definition at line 473 of file disaster.c.

References CreateMeteor(), GetRandomNumber(), Int16, and UInt16.

Referenced by DoSpecificDisaster().

void MonsterCheckSurrounded UInt16    i [static]
 

Check if a monster is surrounded by defensive units.

Parameters:
i  index of monster to check.

Definition at line 314 of file disaster.c.

References GetDefenceValue(), GetRandomNumber(), and UInt16.

Referenced by MoveAllObjects().

Int16 UpdateDisasters void   
 

Make sure the disasters are still happening.

Causes all disasters to go to their next stage.

Returns:
true if zone was affected.

Definition at line 171 of file disaster.c.

References CreateWaste(), FireSpread(), GetDefenceValue(), getMapHeight, getMapWidth, GetRandomNumber(), getWorld(), LockZone(), lz_flags, lz_world, setWorldAndFlag(), UInt16, UnlockZone(), welem_t, and WORLDPOS.

Referenced by mainloop_callback().


Generated on Mon Aug 30 19:44:18 2004 for pocketcity by doxygen1.2.18