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

       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"

spells.h File Reference

The Spells. More...

#include <string>
#include <vector>
#include "unitsound.h"

Go to the source code of this file.

Classes

class  SpellActionMissileLocation
class  SpellActionTypeAdjustVariable
class  SpellActionType
class  AreaAdjustVitals
class  SpawnMissile
class  Demolish
class  AreaBombardment
class  SpawnPortal
class  AdjustVariable
class  AdjustVitals
class  Polymorph
class  Summon
class  Capture
class  Target
class  ConditionInfoVariable
class  ConditionInfo
class  AutoCastInfo
class  SpellType

Defines

#define CONDITION_FALSE   1
#define CONDITION_TRUE   0
#define CONDITION_ONLY   2
#define INFINITE_RANGE   0xFFFFFFF

Enumerations

enum  TargetType { TargetSelf, TargetPosition, TargetUnit }
enum  LocBaseType { LocBaseCaster, LocBaseTarget }

Functions

void SpellCclRegister (void)
 < register fonction.
void InitSpells (void)
 done spell tables
void CleanSpells (void)
 return 1 if spell is availible, 0 if not (must upgrade)
bool SpellIsAvailable (const CPlayer *player, int SpellId)
 returns true if spell can be casted (enough mana, valid target)
bool CanCastSpell (const CUnit *caster, const SpellType *spell, const CUnit *target, int x, int y)
 cast spell on target unit or place at x,y
int SpellCast (CUnit *caster, const SpellType *spell, CUnit *target, int x, int y)
 auto cast the spell if possible
int AutoCastSpell (CUnit *caster, const SpellType *spell)
 return spell type by ident string
SpellTypeSpellTypeByIdent (const std::string &ident)
 return 0, 1, 2 for true, only, false.
char Ccl2Condition (lua_State *l, const char *value)

Variables

std::vector< SpellType * > SpellTypeTable


Detailed Description

The Spells.

Definition in file spells.h.


Define Documentation

#define CONDITION_FALSE   1

Definition at line 311 of file spells.h.

Referenced by Ccl2Condition().

#define CONDITION_ONLY   2

Definition at line 313 of file spells.h.

Referenced by Ccl2Condition(), PassCondition(), and SelectTargetUnitsOfAutoCast().

#define CONDITION_TRUE   0

Definition at line 312 of file spells.h.

Referenced by Ccl2Condition(), PassCondition(), and SelectTargetUnitsOfAutoCast().

#define INFINITE_RANGE   0xFFFFFFF

Definition at line 366 of file spells.h.

Referenced by CclDefineSpell(), and HandleActionSpellCast().


Enumeration Type Documentation

Different targets.

Enumerator:
LocBaseCaster 
LocBaseTarget 

Definition at line 69 of file spells.h.

enum TargetType

Different targets.

Enumerator:
TargetSelf 
TargetPosition 
TargetUnit 

Definition at line 60 of file spells.h.


Function Documentation

int AutoCastSpell ( CUnit caster,
const SpellType spell 
)

return spell type by ident string

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.

Definition at line 1036 of file spells.cpp.

References CommandSpellCast(), FlushCommands, MANA_INDEX, SpellType::ManaCost, CUnit::Player, SelectTargetUnitsOfAutoCast(), SpellType::Slot, SpellIsAvailable(), Target::Unit, CVariable::Value, CUnit::Variable, Target::X, and Target::Y.

Referenced by AiCheckMagic(), AutoCast(), CButtonPanel::DoClicked(), GetButtonStatus(), and CUnit::Init().

bool CanCastSpell ( const CUnit caster,
const SpellType spell,
const CUnit target,
int  x,
int  y 
)

cast spell on target unit or place at x,y

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
x X coord of target spot when/if target does not exist
y Y 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 available.

Definition at line 1019 of file spells.cpp.

References SpellType::Condition, PassCondition(), SpellType::Target, and TargetUnit.

Referenced by AreaAdjustVitals::Cast(), CclDefineSpell(), HandleActionSpellCast(), and SpellCast().

char Ccl2Condition ( lua_State *  l,
const char *  value 
)

Get a condition value from a scm object.

Parameters:
l Lua state.
value scm value to convert.
Returns:
CONDITION_TRUE, CONDITION_FALSE, CONDITION_ONLY or -1 on error.
Note:
This is a helper function to make CclSpellCondition shorter and easier to understand.

Definition at line 477 of file script_spell.cpp.

References _C_, CONDITION_FALSE, CONDITION_ONLY, CONDITION_TRUE, and LuaError.

Referenced by CclSpellAutocast(), and CclSpellCondition().

void CleanSpells ( void   ) 

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

Cleanup the spell subsystem.

Definition at line 1157 of file spells.cpp.

References DebugPrint, and SpellTypeTable.

Referenced by CleanModules().

void InitSpells ( void   ) 

done spell tables

Spells constructor, inits spell id's and sounds

Definition at line 967 of file spells.cpp.

Referenced by CreateGame(), and InitModules().

int SpellCast ( CUnit caster,
const SpellType spell,
CUnit target,
int  x,
int  y 
)

auto cast the spell if possible

Spell cast!

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

Definition at line 1069 of file spells.cpp.

References _C_, SpellType::Action, CanCastSpell(), DebugPrint, SpellType::Ident, MANA_INDEX, SpellType::ManaCost, MaxSampleVolume, CUnitType::Name, PlayGameSound(), SpellType::RepeatCast, SoundConfig::Sound, SpellType::SoundWhenCast, SpellType::Target, TargetSelf, CUnit::Type, CVariable::Value, CUnit::Variable, CUnit::X, and CUnit::Y.

Referenced by HandleActionSpellCast(), and UnitShowAnimationScaled().

void SpellCclRegister ( void   ) 

< register fonction.

init spell tables

Register CCL features for Spell.

Definition at line 753 of file script_spell.cpp.

References CclDefineSpell(), and Lua.

Referenced by InitCcl().

bool SpellIsAvailable ( const CPlayer player,
int  spellid 
)

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

Check if spell is available 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.

Definition at line 999 of file spells.cpp.

References SpellTypeTable.

Referenced by AiCheckMagic(), AutoCastSpell(), and IsButtonAllowed().

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

return 0, 1, 2 for true, only, false.

Get spell-type struct pointer by string identifier.

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

Definition at line 978 of file spells.cpp.

References SpellTypeTable.

Referenced by AddButton(), CclDefineSpell(), CclDefineUnitType(), CclParseOrder(), and CclUnit().


Variable Documentation

std::vector<SpellType *> SpellTypeTable

Define the names and effects of all available spells.

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

Definition at line 70 of file spells.cpp.

Referenced by AiCheckMagic(), AutoCast(), CclDefineSpell(), CclDefineUnitType(), CclUnit(), CleanSpells(), CButtonPanel::DoClicked(), DoRightButton(), CUnit::Init(), ParseCommand(), SaveUnit(), SendCommandSpellCast(), SpellIsAvailable(), SpellTypeByIdent(), and UpdateStatusLineForButton().


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