$treeview $search $mathjax
Stratagus  2.2.7
$projectbrief
$projectbrief
$searchbox
-->
         _________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

Missile Class Reference

Missile on the map. More...

#include <missile.h>

Inheritance diagram for Missile:

MissileClipToTarget MissileCycleOnce MissileDeathCoil MissileFire MissileFlameShield MissileHit MissileLandMine MissileNone MissileParabolic MissilePointToPoint MissilePointToPointBounce MissilePointToPointCycleOnce MissilePointToPointWithHit MissileStay MissileTracer MissileWhirlwind

List of all members.


missile.cpp - The missiles.

static unsigned int Count = 0
 unique number for draw level.
 Missile ()
virtual ~Missile ()
void DrawMissile (const CViewport &vp) const
void SaveMissile (CFile &file) const
void MissileHit (CUnit *unit=NULL)
bool NextMissileFrame (char sign, char longAnimation)
void NextMissileFrameCycle ()
void MissileNewHeadingFromXY (const PixelPos &delta)
static MissileInit (const MissileType &mtype, const PixelPos &startPos, const PixelPos &destPos)

Public Member Functions

virtual void Action ()=0

Public Attributes

PixelPos source
PixelPos position
 Missile source position.
PixelPos destination
 missile pixel position
const MissileTypeType
 missile pixel destination
int SpriteFrame
 missile-type pointer
int State
 sprite frame counter
int AnimWait
 state
int Wait
 Animation wait.
int Delay
 delay between frames
CUnitPtr SourceUnit
 delay to show up
CUnitPtr TargetUnit
 unit that fires (could be killed)
std::vector< CUnit * > PiercedUnits
 target unit, used for spells
int Damage
 Units which are already pierced by this missile.
int TTL
 direct damage that missile applies
int Hidden
 time to live (ticks) used for spells
int CurrentStep
 If this is 1 then the missile is invisible.
int TotalStep
 Current step (0 <= x < TotalStep).
unsigned Local: 1
 Total step.
unsigned int Slot
 missile is a local 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::position

Missile current map position in pixels.

Missile::source

Missile original map position in pixels.

Missile::destination

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.


Constructor & Destructor Documentation

Missile::Missile (  )  [protected]

Constructor

Missile::~Missile (  )  [virtual]

Missile destructior.


Member Function Documentation

Missile * Missile::Init ( const MissileType mtype,
const PixelPos startPos,
const PixelPos destPos 
) [static]

Initialize a new made missile.

Parameters:
mtype Type pointer of missile.
sourcePos Missile start point in pixel.
destPos Missile destination point in pixel.
Returns:
created missile.

void Missile::DrawMissile ( const CViewport vp  )  const

Draw missile.

void Missile::SaveMissile ( CFile file  )  const

Save the state of a missile to file.

Parameters:
file Output file.

void Missile::MissileHit ( CUnit unit = NULL  ) 

Work for missile hit.

bool Missile::NextMissileFrame ( char  sign,
char  longAnimation 
)

Pass to the next frame for animation.

Parameters:
sign 1 for next frame, -1 for previous frame.
longAnimation 1 if Frame is conditioned by covered distance, 0 else.
Returns:
true if animation is finished, false else.

void Missile::NextMissileFrameCycle (  ) 

Pass the next frame of the animation. This animation goes from start to finish ONCE on the way

void Missile::MissileNewHeadingFromXY ( const PixelPos delta  ) 

Change missile heading from x,y.

Parameters:
delta Delta movement


Member Data Documentation

missile pixel position

missile pixel destination

missile-type pointer

sprite frame counter

state

delay between frames

delay to show up

unit that fires (could be killed)

std::vector<CUnit *> Missile::PiercedUnits

target unit, used for spells

Units which are already pierced by this missile.

direct damage that missile applies

time to live (ticks) used for spells

If this is 1 then the missile is invisible.

Current step (0 <= x < TotalStep).

unsigned Missile::Local

Total step.

unsigned int Missile::Slot

missile is a local missile

unsigned int Missile::Count = 0 [static]

unique number for draw level.


The documentation for this class was generated from the following files:
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.