____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include "unittype.h"
#include "unit_cache.h"
#include "spells.h"
#include "sound.h"
#include "missile.h"
#include "map.h"
#include "ui.h"
#include "actions.h"
Go to the source code of this file.
Functions | |
| static void | EvaluateMissileLocation (const SpellActionMissileLocation *location, CUnit *caster, CUnit *target, int x, int y, int *resx, int *resy) |
| static Target * | NewTargetUnit (CUnit *unit) |
| static bool | PassCondition (const CUnit *caster, const SpellType *spell, const CUnit *target, int x, int y, const ConditionInfo *condition) |
| static Target * | SelectTargetUnitsOfAutoCast (CUnit *caster, const SpellType *spell) |
| void | InitSpells (void) |
| done spell tables | |
| SpellType * | SpellTypeByIdent (const std::string &ident) |
| return 0, 1, 2 for true, only, false. | |
| 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 | AutoCastSpell (CUnit *caster, const SpellType *spell) |
| return spell type by ident string | |
| int | SpellCast (CUnit *caster, const SpellType *spell, CUnit *target, int x, int y) |
| auto cast the spell if possible | |
| void | CleanSpells (void) |
| return 1 if spell is availible, 0 if not (must upgrade) | |
Variables | |
| std::vector< SpellType * > | SpellTypeTable |
Definition in file spells.cpp.
return spell type by ident string
Check if the spell can be auto cast and cast it.
| caster | Unit who can cast the spell. | |
| spell | Spell-type pointer. |
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.
| 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 |
Definition at line 1019 of file spells.cpp.
References SpellType::Condition, PassCondition(), SpellType::Target, and TargetUnit.
Referenced by AreaAdjustVitals::Cast(), CclDefineSpell(), HandleActionSpellCast(), and SpellCast().
| 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().
| static void EvaluateMissileLocation | ( | const SpellActionMissileLocation * | location, | |
| CUnit * | caster, | |||
| CUnit * | target, | |||
| int | x, | |||
| int | y, | |||
| int * | resx, | |||
| int * | resy | |||
| ) | [static] |
Evaluate missile location description.
| location | Parameters for location. | |
| caster | Unit that casts the spell | |
| 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 | |
| resx | pointer to X coord of the result | |
| resy | pointer to Y coord of the result |
Definition at line 303 of file spells.cpp.
References SpellActionMissileLocation::AddRandX, SpellActionMissileLocation::AddRandY, SpellActionMissileLocation::AddX, SpellActionMissileLocation::AddY, SpellActionMissileLocation::Base, LocBaseCaster, SyncRand(), TileSizeX, TileSizeY, CUnit::X, and CUnit::Y.
Referenced by SpawnMissile::Cast().
| 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().
Target constructor for unit.
| unit | Target unit. |
Definition at line 710 of file spells.cpp.
References TargetUnit.
Referenced by SelectTargetUnitsOfAutoCast().
| static bool PassCondition | ( | const CUnit * | caster, | |
| const SpellType * | spell, | |||
| const CUnit * | target, | |||
| int | x, | |||
| int | y, | |||
| const ConditionInfo * | condition | |||
| ) | [static] |
Check the condition.
| 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. | |
| x | X position, or -1 if it is a unit spell. | |
| y | Y position, or -1 if it is a unit spell. | |
| condition | Pointer to condition info. |
Definition at line 746 of file spells.cpp.
References ConditionInfo::Alliance, CUnitType::Building, ConditionInfo::Building, CONDITION_ONLY, CONDITION_TRUE, ConditionInfoVariable::ConditionApplyOnCaster, CUnit::Destroyed, CVariable::Enable, ConditionInfoVariable::Enable, CUnit::IsAllied(), CUnit::IsEnemy(), MANA_INDEX, SpellType::ManaCost, CVariable::Max, ConditionInfoVariable::MaxValue, ConditionInfoVariable::MaxValuePercent, ConditionInfoVariable::MinMax, ConditionInfoVariable::MinValue, ConditionInfoVariable::MinValuePercent, CUnitTypeVar::NumberVariable, ConditionInfo::Opponent, CUnit::Orders, CUnitType::Organic, ConditionInfo::Organic, CUnit::Player, SpellType::Target, ConditionInfo::TargetSelf, TargetUnit, CUnit::Type, UnitActionDie, UnitTypeVar, CVariable::Value, ConditionInfo::Variable, and CUnit::Variable.
Referenced by CanCastSpell(), and SelectTargetUnitsOfAutoCast().
Select the target for the autocast.
| caster | Unit who would cast the spell. | |
| spell | Spell-type pointer. |
Definition at line 846 of file spells.cpp.
References SpellType::AICast, CPlayer::AiEnabled, Assert, SpellType::AutoCast, AutoCastInfo::Combat, AutoCastInfo::Condition, SpellType::Condition, CONDITION_ONLY, CONDITION_TRUE, CUnitType::Coward, DebugPrint, CUnit::IsEnemy(), NewTargetUnit(), PassCondition(), CUnit::Player, AutoCastInfo::Range, CUnitCache::Select(), SyncRand(), SpellType::Target, TargetPosition, TargetSelf, TargetUnit, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitCache, UnitMax, CUnit::X, CUnit::Y, and y.
Referenced by AutoCastSpell().
auto cast the spell if possible
Spell cast!
| 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 |
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().
| 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.
| player | player for who we want to know if he knows the spell. | |
| spellid | id of the spell to check. |
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.
| ident | Spell identifier. |
Definition at line 978 of file spells.cpp.
References SpellTypeTable.
Referenced by AddButton(), CclDefineSpell(), CclDefineUnitType(), CclParseOrder(), and CclUnit().
| std::vector<SpellType*> SpellTypeTable |
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().
1.5.6