____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

Missile Class Reference

< Missile on the map More...

#include <missile.h>

Inheritance diagram for Missile:

MissileCycleOnce MissileFire MissileHit MissileNone MissileParabolic MissilePointToPoint MissilePointToPointBounce MissilePointToPointCycleOnce MissilePointToPointWithHit MissileStay

List of all members.

Public Member Functions

virtual ~Missile ()
virtual void Action ()=0
void DrawMissile () const
void SaveMissile (CFile *file) const

Static Public Member Functions

static MissileInit (MissileType *mtype, int sx, int sy, int dx, int dy)

Public Attributes

int SourceX
 Missile Source X.
int SourceY
 Missile Source Y.
int X
 missile pixel position
int Y
 missile pixel position
int DX
 missile pixel destination
int DY
 missile pixel destination
MissileTypeType
 missile-type pointer
int SpriteFrame
 sprite frame counter
int State
 state
int AnimWait
 Animation wait.
int Wait
 delay between frames
int Delay
 delay to showup
CUnitSourceUnit
 unit that fires (could be killed)
CUnitTargetUnit
 target unit, used for spells
int Damage
 direct damage that missile applies
int TTL
 time to live (ticks) used for spells
int Hidden
 If this is 1 then the missile is invisible.
int CurrentStep
 Current step (0 <= x < TotalStep).
int TotalStep
 Total step.
unsigned Local:1
 missile is a local missile
unsigned int Slot
 unique number for draw level.

Static Public Attributes

static unsigned int Count = 0
 slot number generator.

Protected Member Functions

 Missile ()


Detailed Description

< Missile on the map

#include "missile.h"

This structure contains all information about a missile in game. A missile could have different effects, based on its missile-type. Missiles could be saved and stored with CCL. See (missile). Currently only a tile, a unit or a missile could be placed on the map.

The missile structure members:

Missile::X Missile::Y

Missile current map position in pixels. To convert a map tile position to pixel position use: (mapx * TileSizeX + TileSizeX / 2) and (mapy * TileSizeY + TileSizeY / 2)

Note:
TileSizeX % 2 == 0 && TileSizeY % 2 == 0
Missile::SourceX Missile::SourceY

Missile original map position in pixels. To convert a map tile position to pixel position use: (mapx*TileSizeX+TileSizeX/2) and (mapy*TileSizeY+TileSizeY/2)

Note:
TileSizeX2==0 && TileSizeY2==0 and TileSizeX, TileSizeY are currently fixed 32 pixels.
Missile::DX Missile::DY

Missile destination on the map in pixels. If Missile::X==MissileDX and Missile::Y==MissileDY the missile stays at its position. But the movement also depends on MissileType::Class.

Missile::Type

MissileType pointer of the missile, contains the shared informations of all missiles of the same type.

Missile::SpriteFrame

Current sprite frame of the missile. The range is from 0 to MissileType::SpriteFrames-1. The topmost bit (128) is used as flag to mirror the sprites in X direction. Animation scripts aren't currently supported for missiles, everything is handled by MissileType::Class

Note:
If wanted, we can add animation scripts support to the engine.
Missile::State

Current state of the missile. Used for a simple state machine.

Missile::AnimWait

Animation wait. Used internally by missile actions, to run the animation in parallel with the rest.

Missile::Wait

Wait this number of game cycles until the next state or animation of this missile is handled. This counts down from MissileType::Sleep to 0.

Missile::Delay

Number of game cycles the missile isn't shown on the map. This counts down from MissileType::StartDelay to 0, before this happens the missile isn't shown and has no effects.

Note:
This can also be used by MissileType::Class for temporary removement of the missile.
Missile::SourceUnit

The owner of the missile. Normally the one who fired the missile. Used to check units, to prevent hitting the owner when field MissileType::CanHitOwner==true. Also used for kill and experience points.

Missile::TargetUnit

The target of the missile. Normally the unit which should be hit by the missile.

Missile::Damage

Damage done by missile. See also MissileType::Range, which denoted the 100% damage in center.

Missile::TTL

Time to live in game cycles of the missile, if it reaches zero the missile is automatic removed from the map. If -1 the missile lives for ever and the lifetime is handled by Missile::Type:MissileType::Class

Missile::Hidden

When you set this to 1 the unit becomes hidden for a while.

Missile::CurrentStep

Movement step. Used for the different trajectories.

Missile::TotalStep

Maximum number of step. When CurrentStep >= TotalStep, the movement is finished.

Missile::Local

This is a local missile, which can be different on all computer in play. Used for the user interface (fe the green cross).

Missile::MissileSlot

Pointer to the slot of this missile. Used for faster freeing.

Definition at line 417 of file missile.h.


Constructor & Destructor Documentation

Missile::Missile (  )  [protected]

Constructor

Definition at line 142 of file missile.cpp.

References Count, and Slot.

virtual Missile::~Missile (  )  [inline, virtual]

Definition at line 422 of file missile.h.


Member Function Documentation

Missile * Missile::Init ( MissileType mtype,
int  sx,
int  sy,
int  dx,
int  dy 
) [static]

Initialize a new made missile.

Parameters:
mtype Type pointer of missile.
sx Missile x start point in pixel.
sy Missile y start point in pixel.
dx Missile x destination point in pixel.
dy Missile y destination point in pixel.
Returns:
created missile.

Definition at line 164 of file missile.cpp.

References MissileType::Class, Delay, DX, DY, MissileType::Height, MissileClassCycleOnce, MissileClassFire, MissileClassHit, MissileClassNone, MissileClassParabolic, MissileClassPointToPoint, MissileClassPointToPointBounce, MissileClassPointToPointCycleOnce, MissileClassPointToPointWithHit, MissileClassStay, MissileType::Sleep, SourceX, SourceY, MissileType::StartDelay, Type, Wait, MissileType::Width, X, and Y.

Referenced by MakeLocalMissile(), and MakeMissile().

virtual void Missile::Action (  )  [pure virtual]

void Missile::DrawMissile (  )  const

void Missile::SaveMissile ( CFile file  )  const

Save the state of a missile to file.

Parameters:
file Output file.

Definition at line 1057 of file missile.cpp.

References AnimWait, CurrentStep, Damage, Delay, DX, DY, Hidden, MissileType::Ident, Local, CFile::printf(), SourceUnit, SourceX, SourceY, SpriteFrame, State, TargetUnit, TotalStep, TTL, Type, UnitReference(), Wait, X, and Y.


Member Data Documentation

Animation wait.

Definition at line 440 of file missile.h.

Referenced by CclMissile(), and SaveMissile().

delay to showup

Definition at line 442 of file missile.h.

Referenced by CclMissile(), Init(), MissilesActionLoop(), and SaveMissile().

unit that fires (could be killed)

Definition at line 444 of file missile.h.

Referenced by MissileFire::Action(), CclMissile(), FireMissile(), FreeMissile(), HitUnit(), MissileHit(), MissileHitsGoal(), and SaveMissile().

target unit, used for spells

Definition at line 445 of file missile.h.

Referenced by CclMissile(), FireMissile(), FreeMissile(), MissileHit(), and SaveMissile().

direct damage that missile applies

Definition at line 447 of file missile.h.

Referenced by CclMissile(), DrawMissile(), HitUnit(), MissileHitsGoal(), and SaveMissile().

If this is 1 then the missile is invisible.

Definition at line 450 of file missile.h.

Referenced by CclMissile(), and SaveMissile().

Current step (0 <= x < TotalStep).

Definition at line 453 of file missile.h.

Referenced by CclMissile(), MissileInitMove(), ParabolicMissile(), PointToPointMissile(), and SaveMissile().

unsigned Missile::Local

missile is a local missile

Definition at line 456 of file missile.h.

Referenced by CclMissile(), MakeLocalMissile(), and SaveMissile().

unsigned int Missile::Slot

unique number for draw level.

Definition at line 457 of file missile.h.

Referenced by Missile(), and MissileDrawLevelCompare().

unsigned int Missile::Count = 0 [static]

slot number generator.

Definition at line 460 of file missile.h.

Referenced by Missile().


The documentation for this class was generated from the following files:

Generated on Sat Feb 21 00:28:25 2009 for Bos Wars by  doxygen 1.5.6