1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Use ability name instead of number.

This commit is contained in:
Frank Zago 2009-07-07 03:34:23 +00:00
parent b551f6a72b
commit 02ddeb8e88
3 changed files with 106 additions and 63 deletions

View File

@ -1,13 +1,13 @@
//creatures' abilities description
//first line: use abilities from ZCRTRAIT.TXT [0 - no, 1 - yes]
//next lines: + [CREATURE_ID] [ABILITY_ID] [value] [subtype] [additional info] [comment to the end of line] /*adding ability*/
// or: - [CREATURE_ID] [ABILITY_ID] /*removing ability*/
//next lines: + [CREATURE_ID] [ABILITY] [value] [subtype] [additional info] [comment to the end of line] /*adding ability*/
// or: - [CREATURE_ID] [ABILITY] /*removing ability*/
// or: 0 /*end of ability descriptions*/
1
+ 115 1 0 0 0 //water elemental should be treated as double-wide
+ 123 1 0 0 0 //ice elemental should be treated as double-wide
+ 140 1 0 0 0 //boar should be treated as double-wide
+ 142 1 0 0 0 //nomads should be treated as double-wide
- 46 2 //hell hound doesn't fly
- 47 2 //cerberus doesn't fly
0
+ 115 DOUBLE_WIDE 0 0 0 //water elemental should be treated as double-wide
+ 123 DOUBLE_WIDE 0 0 0 //ice elemental should be treated as double-wide
+ 140 DOUBLE_WIDE 0 0 0 //boar should be treated as double-wide
+ 142 DOUBLE_WIDE 0 0 0 //nomads should be treated as double-wide
- 46 FLYING //hell hound doesn't fly
- 47 FLYING //cerberus doesn't fly
0

View File

@ -5,6 +5,7 @@
#include <sstream>
#include <boost/assign/std/set.hpp>
#include <boost/assign/std/vector.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/find.hpp>
#include <boost/algorithm/string/replace.hpp>
@ -278,6 +279,11 @@ void CCreatureHandler::loadCreatures()
}
}
// Map types names
#define VCMI_CREATURE_ABILITY_NAME(x) ( #x, StackFeature::x )
std::map<std::string, int> type_list = map_list_of VCMI_CREATURE_ABILITY_LIST;
#undef VCMI_CREATURE_ABILITY_NAME
////second part of reading cr_abils.txt////
bool contReading = true;
while(contReading) //main reading loop
@ -293,8 +299,18 @@ void CCreatureHandler::loadCreatures()
int creatureID;
StackFeature nsf;
si32 buf;
std::string type;
reader >> creatureID;
reader >> buf; nsf.type = buf; //it reads ui8 as byte, in file it has different format
reader >> type;
std::map<std::string, int>::iterator it = type_list.find(type);
if (it == type_list.end()) {
tlog1 << "Error: invalid type " << type << " in cr_abils.txt" << std::endl;
break;
}
nsf.type = it->second;
reader >> buf; nsf.value = buf;
reader >> buf; nsf.subtype = buf;
reader >> buf; nsf.additionalInfo = buf;

View File

@ -3,62 +3,89 @@
struct StackFeature
{
#define VCMI_CREATURE_ABILITY_LIST \
VCMI_CREATURE_ABILITY_NAME(NO_TYPE) \
VCMI_CREATURE_ABILITY_NAME(DOUBLE_WIDE) \
VCMI_CREATURE_ABILITY_NAME(FLYING) \
VCMI_CREATURE_ABILITY_NAME(SHOOTER) \
VCMI_CREATURE_ABILITY_NAME(CHARGE_IMMUNITY) \
VCMI_CREATURE_ABILITY_NAME(ADDITIONAL_ATTACK) \
VCMI_CREATURE_ABILITY_NAME(UNLIMITED_RETAILATIONS) \
VCMI_CREATURE_ABILITY_NAME(NO_MELEE_PENALTY) \
VCMI_CREATURE_ABILITY_NAME(JOUSTING) /*for champions*/ \
VCMI_CREATURE_ABILITY_NAME(RAISING_MORALE) /*value - how much raises*/ \
VCMI_CREATURE_ABILITY_NAME(HATE) /*eg. angels hate devils, subtype - ID of hated creature*/ \
VCMI_CREATURE_ABILITY_NAME(KING1) \
VCMI_CREATURE_ABILITY_NAME(KING2) \
VCMI_CREATURE_ABILITY_NAME(KING3) \
VCMI_CREATURE_ABILITY_NAME(MAGIC_RESISTANCE) /*in % (value)*/ \
VCMI_CREATURE_ABILITY_NAME(CHANGES_SPELL_COST_FOR_ALLY) /*in mana points (value) , eg. mage*/ \
VCMI_CREATURE_ABILITY_NAME(CHANGES_SPELL_COST_FOR_ENEMY) /*in mana points (value) , eg. pegasus */ \
VCMI_CREATURE_ABILITY_NAME(SPELL_AFTER_ATTACK) /* subtype - spell id, value - spell level, (aditional info)%100 - chance in %; eg. dendroids, (additional info)/100 -> [0 - all attacks, 1 - shot only, 2 - melee only*/ \
VCMI_CREATURE_ABILITY_NAME(SPELL_RESISTANCE_AURA) /*eg. unicorns, value - resistance bonus in % for adjacent creatures*/ \
VCMI_CREATURE_ABILITY_NAME(LEVEL_SPELL_IMMUNITY) /*creature is immune to all spell with level below or equal to value of this bonus*/ \
VCMI_CREATURE_ABILITY_NAME(TWO_HEX_ATTACK_BREATH) /*eg. dragons*/ \
VCMI_CREATURE_ABILITY_NAME(SPELL_DAMAGE_REDUCTION) /*eg. golems; value - reduction in %, subtype - spell school; -1 - all, 0 - air, 1 - fire, 2 - water, 3 - earth*/ \
VCMI_CREATURE_ABILITY_NAME(NO_WALL_PENALTY) \
VCMI_CREATURE_ABILITY_NAME(NON_LIVING) /*eg. gargoyle*/ \
VCMI_CREATURE_ABILITY_NAME(RANDOM_GENIE_SPELLCASTER) /*eg. master genie*/ \
VCMI_CREATURE_ABILITY_NAME(BLOCKS_RETAILATION) /*eg. naga*/ \
VCMI_CREATURE_ABILITY_NAME(SPELL_IMMUNITY) /*subid - spell id*/ \
VCMI_CREATURE_ABILITY_NAME(MANA_CHANNELING) /*value in %, eg. familiar*/ \
VCMI_CREATURE_ABILITY_NAME(SPELL_LIKE_ATTACK /*value - spell id; range is taken from spell, but damage from creature; eg. magog*/) \
VCMI_CREATURE_ABILITY_NAME(THREE_HEADED_ATTACK) /*eg. cerberus*/ \
VCMI_CREATURE_ABILITY_NAME(DEAMON_SUMMONING) /*pit lord*/ \
VCMI_CREATURE_ABILITY_NAME(FIRE_IMMUNITY) \
VCMI_CREATURE_ABILITY_NAME(FIRE_SHIELD) \
VCMI_CREATURE_ABILITY_NAME(ENEMY_MORALE_DECREASING) /*value - how much it decreases*/ \
VCMI_CREATURE_ABILITY_NAME(ENEMY_LUCK_DECREASING) \
VCMI_CREATURE_ABILITY_NAME(UNDEAD) \
VCMI_CREATURE_ABILITY_NAME(REGENERATION) \
VCMI_CREATURE_ABILITY_NAME(MANA_DRAIN) /*value - spell points per turn*/ \
VCMI_CREATURE_ABILITY_NAME(LIFE_DRAIN) \
VCMI_CREATURE_ABILITY_NAME(DOUBLE_DAMAGE_CHANCE) /*value in %, eg. dread knight*/ \
VCMI_CREATURE_ABILITY_NAME(RETURN_AFTER_STRIKE) \
VCMI_CREATURE_ABILITY_NAME(SELF_MORALE) /*eg. minotaur*/ \
VCMI_CREATURE_ABILITY_NAME(SPELLCASTER) /*subtype - spell id, value - level of school, additional info - spell power*/ \
VCMI_CREATURE_ABILITY_NAME(CATAPULT) \
VCMI_CREATURE_ABILITY_NAME(ENEMY_DEFENCE_REDUCTION) /*in % (value) eg. behemots*/ \
VCMI_CREATURE_ABILITY_NAME(GENERAL_DAMAGE_REDUCTION) /*eg. while stoned or blinded - in %, subtype: -1 - any damage, 0 - melee damage, 1 - ranged damage*/ \
VCMI_CREATURE_ABILITY_NAME(ATTACKS_ALL_ADAJCENT) /*eg. hydra*/ \
VCMI_CREATURE_ABILITY_NAME(MORE_DAMEGE_FROM_SPELL) /*value - damage increase in %, subtype - spell id*/ \
VCMI_CREATURE_ABILITY_NAME(CASTS_SPELL_WHEN_KILLED) /*similar to spell after attack*/ \
VCMI_CREATURE_ABILITY_NAME(FEAR) \
VCMI_CREATURE_ABILITY_NAME(FEARLESS) \
VCMI_CREATURE_ABILITY_NAME(NO_DISTANCE_PENALTY) \
VCMI_CREATURE_ABILITY_NAME(NO_OBSTACLES_PENALTY) \
VCMI_CREATURE_ABILITY_NAME(SELF_LUCK) /*halfling*/ \
VCMI_CREATURE_ABILITY_NAME(ATTACK_BONUS) /*subtype: -1 - any attack, 0 - melee, 1 - ranged*/ \
VCMI_CREATURE_ABILITY_NAME(DEFENCE_BONUS) /*subtype: -1 - any attack, 0 - melee, 1 - ranged*/ \
VCMI_CREATURE_ABILITY_NAME(SPEED_BONUS) /*additional info - percent of speed bonus applied after direct bonuses; >0 - added, <0 - substracted to this part*/ \
VCMI_CREATURE_ABILITY_NAME(HP_BONUS) \
VCMI_CREATURE_ABILITY_NAME(ENCHANTER) \
VCMI_CREATURE_ABILITY_NAME(HEALER) \
VCMI_CREATURE_ABILITY_NAME(SIEGE_WEAPON) \
VCMI_CREATURE_ABILITY_NAME(LUCK_BONUS) \
VCMI_CREATURE_ABILITY_NAME(MORALE_BONUS) \
VCMI_CREATURE_ABILITY_NAME(HYPNOTIZED) \
VCMI_CREATURE_ABILITY_NAME(ADDITIONAL_RETAILATION) /*value - number of additional retailations*/ \
VCMI_CREATURE_ABILITY_NAME(MAGIC_MIRROR) /* value - chance of redirecting in %*/ \
VCMI_CREATURE_ABILITY_NAME(SUMMONED) \
VCMI_CREATURE_ABILITY_NAME(ALWAYS_MINUMUM_DAMAGE) /*unit does its minimum damage from range; subtype: -1 - any attack, 0 - melee, 1 - ranged, value: additional damage, additional info - multiplicative anti-bonus for dmg in % [eg 20 means that creature will inflict 80% of normal dmg]*/ \
VCMI_CREATURE_ABILITY_NAME(ALWAYS_MAXIMUM_DAMAGE) /*eg. bless effect, subtype: -1 - any attack, 0 - melee, 1 - ranged, value: additional damage, additional info - multiplicative bonus for dmg in %*/ \
VCMI_CREATURE_ABILITY_NAME(ATTACKS_NEAREST_CREATURE) /*while in berserk*/ \
VCMI_CREATURE_ABILITY_NAME(IN_FRENZY) /*value - level*/ \
VCMI_CREATURE_ABILITY_NAME(SLAYER) /*value - level*/ \
VCMI_CREATURE_ABILITY_NAME(FORGETFULL) /*forgetfullnes spell effect, value - level*/ \
VCMI_CREATURE_ABILITY_NAME(CLONED) \
VCMI_CREATURE_ABILITY_NAME(NOT_ACTIVE)
//general list of stack abilities and effects
enum ECombatFeatures
{
NO_TYPE,
DOUBLE_WIDE, FLYING, SHOOTER, CHARGE_IMMUNITY, ADDITIONAL_ATTACK, UNLIMITED_RETAILATIONS,
NO_MELEE_PENALTY,
JOUSTING /*for champions*/,
RAISING_MORALE /*value - how much raises*/,
HATE /*eg. angels hate devils, subtype - ID of hated creature*/,
KING1,
KING2, KING3, MAGIC_RESISTANCE /*in % (value)*/,
CHANGES_SPELL_COST_FOR_ALLY /*in mana points (value) , eg. mage*/,
CHANGES_SPELL_COST_FOR_ENEMY /*in mana points (value) , eg. pegasus */,
SPELL_AFTER_ATTACK /* subtype - spell id, value - spell level, (aditional info)%100 - chance in %; eg. dendroids, (additional info)/100 -> [0 - all attacks, 1 - shot only, 2 - melee only*/,
SPELL_RESISTANCE_AURA /*eg. unicorns, value - resistance bonus in % for adjacent creatures*/,
LEVEL_SPELL_IMMUNITY /*creature is immune to all spell with level below or equal to value of this bonus*/,
TWO_HEX_ATTACK_BREATH /*eg. dragons*/,
SPELL_DAMAGE_REDUCTION /*eg. golems; value - reduction in %, subtype - spell school; -1 - all, 0 - air, 1 - fire, 2 - water, 3 - earth*/,
NO_WALL_PENALTY, NON_LIVING /*eg. gargoyle*/,
RANDOM_GENIE_SPELLCASTER /*eg. master genie*/,
BLOCKS_RETAILATION /*eg. naga*/,
SPELL_IMMUNITY /*subid - spell id*/,
MANA_CHANNELING /*value in %, eg. familiar*/,
SPELL_LIKE_ATTACK /*value - spell id; range is taken from spell, but damage from creature; eg. magog*/,
THREE_HEADED_ATTACK /*eg. cerberus*/,
DEAMON_SUMMONING /*pit lord*/,
FIRE_IMMUNITY, FIRE_SHIELD,
ENEMY_MORALE_DECREASING /*value - how much it decreases*/,
ENEMY_LUCK_DECREASING, UNDEAD,
REGENERATION, MANA_DRAIN /*value - spell points per turn*/,
LIFE_DRAIN,
DOUBLE_DAMAGE_CHANCE /*value in %, eg. dread knight*/,
RETURN_AFTER_STRIKE, SELF_MORALE /*eg. minotaur*/,
SPELLCASTER /*subtype - spell id, value - level of school, additional info - spell power*/,
CATAPULT,
ENEMY_DEFENCE_REDUCTION /*in % (value), eg. behemots*/,
GENERAL_DAMAGE_REDUCTION /*eg. while stoned or blinded - in %, subtype: -1 - any damage, 0 - melee damage, 1 - ranged damage*/,
ATTACKS_ALL_ADAJCENT /*eg. hydra*/,
MORE_DAMEGE_FROM_SPELL /*value - damage increase in %, subtype - spell id*/,
CASTS_SPELL_WHEN_KILLED /*similar to spell after attack*/,
FEAR, FEARLESS, NO_DISTANCE_PENALTY, NO_OBSTACLES_PENALTY,
SELF_LUCK /*halfling*/,
ATTACK_BONUS /*subtype: -1 - any attack, 0 - melee, 1 - ranged*/,
DEFENCE_BONUS /*subtype: -1 - any attack, 0 - melee, 1 - ranged*/,
SPEED_BONUS /*additional info - percent of speed bonus applied after direct bonuses; >0 - added, <0 - substracted to this part*/,
HP_BONUS, ENCHANTER, HEALER, SIEGE_WEAPON, LUCK_BONUS, MORALE_BONUS, HYPNOTIZED,
ADDITIONAL_RETAILATION /*value - number of additional retailations*/,
MAGIC_MIRROR /* value - chance of redirecting in %*/,
SUMMONED,
ALWAYS_MINUMUM_DAMAGE /*unit does its minimum damage from range; subtype: -1 - any attack, 0 - melee, 1 - ranged, value: additional damage, additional info - multiplicative anti-bonus for dmg in % [eg 20 means that creature will inflict 80% of normal dmg]*/,
ALWAYS_MAXIMUM_DAMAGE /*eg. bless effect, subtype: -1 - any attack, 0 - melee, 1 - ranged, value: additional damage, additional info - multiplicative bonus for dmg in %*/,
ATTACKS_NEAREST_CREATURE /*while in berserk*/,
IN_FRENZY /*value - level*/,
SLAYER /*value - level*/,
FORGETFULL /*forgetfullnes spell effect, value - level*/,
CLONED, NOT_ACTIVE
#define VCMI_CREATURE_ABILITY_NAME(x) x,
VCMI_CREATURE_ABILITY_LIST
#undef VCMI_CREATURE_ABILITY_NAME
};
enum EDuration