$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

src/spell/spells.cpp File Reference

#include "stratagus.h"
#include "spells.h"
#include "commands.h"
#include "map.h"
#include "sound.h"
#include "unit.h"
#include "unit_find.h"
#include "upgrade.h"

spells.cpp - The spell cast action.

std::vector< SpellType * > SpellTypeTable
static TargetNewTargetUnit (CUnit &unit)
static bool PassCondition (const CUnit &caster, const SpellType &spell, const CUnit *target, const Vec2i &, const ConditionInfo *condition)
static TargetSelectTargetUnitsOfAutoCast (CUnit &caster, const SpellType &spell)
void InitSpells ()
 init spell tables
SpellTypeSpellTypeByIdent (const std::string &ident)
 return spell type by ident string
bool SpellIsAvailable (const CPlayer &player, int spellid)
 return 1 if spell is availible, 0 if not (must upgrade)
bool CanCastSpell (const CUnit &caster, const SpellType &spell, const CUnit *target, const Vec2i &goalPos)
int AutoCastSpell (CUnit &caster, const SpellType &spell)
 auto cast the spell if possible
int SpellCast (CUnit &caster, const SpellType &spell, CUnit *target, const Vec2i &goalPos)
void CleanSpells ()
 done spell tables

Function Documentation

int AutoCastSpell ( CUnit caster,
const SpellType spell 
)

auto cast the spell if possible

Check if the spell can be auto cast and cast it.

Parameters:
caster Unit who can cast the spell.
spell Spell-type pointer.
Returns:
1 if spell is casted, 0 if not.

bool CanCastSpell ( const CUnit caster,
const SpellType spell,
const CUnit target,
const Vec2i goalPos 
)

Check if unit can cast the spell.

Parameters:
caster Unit that casts the spell
spell Spell-type pointer
target Target unit that spell is addressed to
goalPos coord of target spot when/if target does not exist
Returns:
=!0 if spell should/can casted, 0 if not
Note:
caster must know the spell, and spell must be researched.

void CleanSpells (  ) 

done spell tables

Cleanup the spell subsystem.

void InitSpells (  ) 

init spell tables

Spells constructor, inits spell id's and sounds

static Target* NewTargetUnit ( CUnit unit  )  [static]

Target constructor for unit.

Parameters:
unit Target unit.
Returns:
the new target.

static bool PassCondition ( const CUnit caster,
const SpellType spell,
const CUnit target,
const Vec2i ,
const ConditionInfo condition 
) [static]

Check the condition.

Parameters:
caster Pointer to caster unit.
spell Pointer to the spell to cast.
target Pointer to target unit, or 0 if it is a position spell.
goalPos position, or {-1, -1} if it is a unit spell.
condition Pointer to condition info.
Returns:
true if passed, false otherwise.

static Target* SelectTargetUnitsOfAutoCast ( CUnit caster,
const SpellType spell 
) [static]

Select the target for the autocast.

Parameters:
caster Unit who would cast the spell.
spell Spell-type pointer.
Returns:
Target* chosen target or Null if spell can't be cast.
Todo:
FIXME: should be global (for AI) ???
Todo:
FIXME: write for position target.

int SpellCast ( CUnit caster,
const SpellType spell,
CUnit target,
const Vec2i goalPos 
)

Spell cast!

Parameters:
caster Unit that casts the spell
spell Spell-type pointer
target Target unit that spell is addressed to
goalPos coord of target spot when/if target does not exist
Returns:
!=0 if spell should/can continue or 0 to stop

bool SpellIsAvailable ( const CPlayer player,
int  spellid 
)

return 1 if spell is availible, 0 if not (must upgrade)

Check if spell is research for player player.

Parameters:
player player for who we want to know if he knows the spell.
spellid id of the spell to check.
Returns:
0 if spell is not available, else no null.

SpellType* SpellTypeByIdent ( const std::string &  ident  ) 

return spell type by ident string

Get spell-type struct pointer by string identifier.

Parameters:
ident Spell identifier.
Returns:
spell-type struct pointer.


Variable Documentation

std::vector<SpellType *> SpellTypeTable

Define the names and effects of all im play available spells.

(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.