2011-12-14 00:23:17 +03:00
# pragma once
2009-04-16 14:14:13 +03:00
2010-12-19 16:39:56 +02:00
# include "../lib/ConstTransitivePtr.h"
2011-12-14 00:23:17 +03:00
# include "int3.h"
# include "GameConstants.h"
2009-05-14 07:49:04 +03:00
2009-04-15 17:03:31 +03:00
/*
* CSpellHandler . h , part of VCMI engine
*
* Authors : listed in file AUTHORS in main folder
*
* License : GNU General Public License v2 .0 or later
* Full text of license available in license . txt file , in main folder
*
2009-04-16 14:14:13 +03:00
*/
2012-08-25 11:44:51 +03:00
class CLegacyConfigParser ;
2012-05-18 23:50:16 +03:00
struct BattleHex ;
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CSpell
2009-04-16 14:14:13 +03:00
{
public :
2011-02-21 18:53:23 +02:00
enum ETargetType { NO_TARGET , CREATURE , CREATURE_EXPERT_MASSIVE , OBSTACLE } ;
2012-02-17 00:19:07 +03:00
enum ESpellPositiveness { NEGATIVE = - 1 , NEUTRAL = 0 , POSITIVE = 1 } ;
2012-08-26 12:07:48 +03:00
TSpell id ;
2012-12-18 13:32:11 +03:00
std : : string identifier ;
2009-04-16 14:14:13 +03:00
std : : string name ;
std : : string abbName ; //abbreviated name
std : : vector < std : : string > descriptions ; //descriptions of spell for skill levels: 0 - none, 1 - basic, etc
si32 level ;
bool earth ;
bool water ;
bool fire ;
bool air ;
si32 power ; //spell's power
std : : vector < si32 > costs ; //per skill level: 0 - none, 1 - basic, etc
std : : vector < si32 > powers ; //[er skill level: 0 - none, 1 - basic, etc
2012-12-18 13:32:11 +03:00
std : : map < TFaction , si32 > probabilities ; //% chance to gain for castles
2009-04-16 14:14:13 +03:00
std : : vector < si32 > AIVals ; //AI values: per skill level: 0 - none, 1 - basic, etc
std : : string attributes ; //reference only attributes
bool combatSpell ; //is this spell combat (true) or adventure (false)
bool creatureAbility ; //if true, only creatures can use this spell
si8 positiveness ; //1 if spell is positive for influenced stacks, 0 if it is indifferent, -1 if it's negative
std : : vector < std : : string > range ; //description of spell's range in SRSL by magic school level
2012-09-14 02:41:03 +03:00
std : : vector < TSpell > counteredSpells ; //spells that are removed when effect of this spell is placed on creature (for bless-curse, haste-slow, and similar pairs)
2012-05-18 23:50:16 +03:00
std : : vector < BattleHex > rangeInHexes ( BattleHex centralHex , ui8 schoolLvl , ui8 side , bool * outDroppedHexes = NULL ) const ; //convert range to specific hexes; last optional out parameter is set to true, if spell would cover unavailable hexes (that are not included in ret)
2009-04-22 13:03:13 +03:00
si16 mainEffectAnim ; //main spell effect animation, in AC format (or -1 when none)
2011-02-21 18:53:23 +02:00
ETargetType getTargetType ( ) const ;
2009-04-16 14:14:13 +03:00
2012-02-17 00:19:07 +03:00
bool isPositive ( ) const ;
bool isNegative ( ) const ;
2012-03-31 00:36:07 +03:00
bool isRisingSpell ( ) const ;
2012-08-26 12:07:48 +03:00
bool isDamageSpell ( ) const ;
2012-02-17 00:19:07 +03:00
2009-04-16 14:14:13 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2012-12-18 13:32:11 +03:00
h & identifier & id & name & abbName & descriptions & level & earth & water & fire & air & power & costs
2012-09-14 02:41:03 +03:00
& powers & probabilities & AIVals & attributes & combatSpell & creatureAbility & positiveness & range & counteredSpells & mainEffectAnim ;
2009-04-16 14:14:13 +03:00
}
} ;
2010-03-21 00:17:19 +02:00
namespace Spells
{
2011-11-11 17:51:27 +03:00
enum
{
2012-05-18 20:35:46 +03:00
SUMMON_BOAT = 0 , SCUTTLE_BOAT = 1 , VISIONS = 2 , VIEW_EARTH = 3 , DISGUISE = 4 , VIEW_AIR = 5 ,
FLY = 6 , WATER_WALK = 7 , DIMENSION_DOOR = 8 , TOWN_PORTAL = 9 ,
2011-11-11 18:39:46 +03:00
2011-11-11 17:51:27 +03:00
QUICKSAND = 10 , LAND_MINE = 11 , FORCE_FIELD = 12 , FIRE_WALL = 13 , EARTHQUAKE = 14 ,
MAGIC_ARROW = 15 , ICE_BOLT = 16 , LIGHTNING_BOLT = 17 , IMPLOSION = 18 ,
CHAIN_LIGHTNING = 19 , FROST_RING = 20 , FIREBALL = 21 , INFERNO = 22 ,
METEOR_SHOWER = 23 , DEATH_RIPPLE = 24 , DESTROY_UNDEAD = 25 , ARMAGEDDON = 26 ,
SHIELD = 27 , AIR_SHIELD = 28 , FIRE_SHIELD = 29 , PROTECTION_FROM_AIR = 30 ,
PROTECTION_FROM_FIRE = 31 , PROTECTION_FROM_WATER = 32 ,
PROTECTION_FROM_EARTH = 33 , ANTI_MAGIC = 34 , DISPEL = 35 , MAGIC_MIRROR = 36 ,
CURE = 37 , RESURRECTION = 38 , ANIMATE_DEAD = 39 , SACRIFICE = 40 , BLESS = 41 ,
CURSE = 42 , BLOODLUST = 43 , PRECISION = 44 , WEAKNESS = 45 , STONE_SKIN = 46 ,
DISRUPTING_RAY = 47 , PRAYER = 48 , MIRTH = 49 , SORROW = 50 , FORTUNE = 51 ,
MISFORTUNE = 52 , HASTE = 53 , SLOW = 54 , SLAYER = 55 , FRENZY = 56 ,
TITANS_LIGHTNING_BOLT = 57 , COUNTERSTRIKE = 58 , BERSERK = 59 , HYPNOTIZE = 60 ,
FORGETFULNESS = 61 , BLIND = 62 , TELEPORT = 63 , REMOVE_OBSTACLE = 64 , CLONE = 65 ,
2011-11-11 18:39:46 +03:00
SUMMON_FIRE_ELEMENTAL = 66 , SUMMON_EARTH_ELEMENTAL = 67 , SUMMON_WATER_ELEMENTAL = 68 , SUMMON_AIR_ELEMENTAL = 69 ,
STONE_GAZE = 70 , POISON = 71 , BIND = 72 , DISEASE = 73 , PARALYZE = 74 , AGE = 75 , DEATH_CLOUD = 76 , THUNDERBOLT = 77 ,
DISPEL_HELPFUL_SPELLS = 78 , DEATH_STARE = 79 , ACID_BREATH_DEFENSE = 80 , ACID_BREATH_DAMAGE = 81
2011-11-11 17:51:27 +03:00
} ;
2010-03-21 00:17:19 +02:00
}
2011-12-14 00:23:17 +03:00
bool DLL_LINKAGE isInScreenRange ( const int3 & center , const int3 & pos ) ; //for spells like Dimension Door
2010-03-21 00:17:19 +02:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CSpellHandler
2009-04-16 14:14:13 +03:00
{
2012-08-25 11:44:51 +03:00
CSpell * loadSpell ( CLegacyConfigParser & parser ) ;
2009-04-16 14:14:13 +03:00
public :
2009-09-25 06:21:56 +03:00
CSpellHandler ( ) ;
2010-12-19 16:39:56 +02:00
std : : vector < ConstTransitivePtr < CSpell > > spells ;
2011-06-25 09:55:35 +03:00
std : : set < TSpell > damageSpells ; //they inflict damage and require particular threatment
2011-10-03 22:29:36 +03:00
std : : set < TSpell > risingSpells ; //they affect dead stacks and need special target selection
2012-01-27 10:25:29 +03:00
std : : set < TSpell > mindSpells ;
2009-04-16 14:14:13 +03:00
void loadSpells ( ) ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
2012-01-27 10:25:29 +03:00
h & spells & damageSpells & risingSpells & mindSpells ;
2009-04-16 14:14:13 +03:00
}
} ;