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

Classes
spells.cpp File Reference
#include "stratagus.h"
#include "spells.h"
#include "actions.h"
#include "commands.h"
#include "map.h"
#include "sound.h"
#include "unit.h"
#include "unit_find.h"
#include "upgrade.h"

Classes

class  AutoCastPrioritySort
 

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 &goalPos, const ConditionInfo *condition)
 
static TargetSelectTargetUnitsOfAutoCast (CUnit &caster, const SpellType &spell)
 
void InitSpells ()
 init spell tables More...
 
SpellTypeSpellTypeByIdent (const std::string &ident)
 return spell type by ident string More...
 
bool SpellIsAvailable (const CPlayer &player, int spellid)
 return 1 if spell is available, 0 if not (must upgrade) More...
 
bool CanCastSpell (const CUnit &caster, const SpellType &spell, const CUnit *target, const Vec2i &goalPos)
 returns true if spell can be casted (enough mana, valid target) More...
 
int AutoCastSpell (CUnit &caster, const SpellType &spell)
 auto cast the spell if possible More...
 
int SpellCast (CUnit &caster, const SpellType &spell, CUnit *target, const Vec2i &goalPos)
 cast spell on target unit or place at x,y More...
 
void CleanSpells ()
 done spell tables More...
 

Function Documentation

◆ AutoCastSpell()

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
casterUnit who can cast the spell.
spellSpell-type pointer.
Returns
1 if spell is casted, 0 if not.

◆ CanCastSpell()

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

returns true if spell can be casted (enough mana, valid target)

Check if unit can cast the spell.

Parameters
casterUnit that casts the spell
spellSpell-type pointer
targetTarget unit that spell is addressed to
goalPoscoord 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.

◆ CleanSpells()

void CleanSpells ( )

done spell tables

Cleanup the spell subsystem.

◆ InitSpells()

void InitSpells ( )

init spell tables

Spells constructor, inits spell id's and sounds

◆ NewTargetUnit()

static Target* NewTargetUnit ( CUnit unit)
static

Target constructor for unit.

Parameters
unitTarget unit.
Returns
the new target.

◆ PassCondition()

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

Check the condition.

Parameters
casterPointer to caster unit.
spellPointer to the spell to cast.
targetPointer to target unit, or 0 if it is a position spell.
goalPosposition, or {-1, -1} if it is a unit spell.
conditionPointer to condition info.
Returns
true if passed, false otherwise.

◆ SelectTargetUnitsOfAutoCast()

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

Select the target for the autocast.

Parameters
casterUnit who would cast the spell.
spellSpell-type pointer.
Returns
Target* chosen target or Null if spell can't be cast.
Todo:

FIXME: should be global (for AI) ???

FIXME: write for position target.

◆ SpellCast()

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

cast spell on target unit or place at x,y

Spell cast!

Parameters
casterUnit that casts the spell
spellSpell-type pointer
targetTarget unit that spell is addressed to
goalPoscoord of target spot when/if target does not exist
Returns
!=0 if spell should/can continue or 0 to stop

◆ SpellIsAvailable()

bool SpellIsAvailable ( const CPlayer player,
int  spellid 
)

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

Check if spell is research for player player.

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

◆ SpellTypeByIdent()

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

return spell type by ident string

Get spell-type struct pointer by string identifier.

Parameters
identSpell identifier.
Returns
spell-type struct pointer.

Variable Documentation

◆ SpellTypeTable

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.