mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* further changes in stack's bonus code
This commit is contained in:
parent
f960208729
commit
8a32855900
@ -8,6 +8,7 @@
|
||||
#endif
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include "lib/StackFeature.h"
|
||||
#ifdef _WIN32
|
||||
#include <tchar.h>
|
||||
#else
|
||||
|
94
global.h
94
global.h
@ -47,102 +47,8 @@ enum Ecolor {RED, BLUE, TAN, GREEN, ORANGE, PURPLE, TEAL, PINK}; //player's colo
|
||||
enum EvictoryConditions {artifact, gatherTroop, gatherResource, buildCity, buildGrail, beatHero,
|
||||
captureCity, beatMonster, takeDwellings, takeMines, transportItem, winStandard=255};
|
||||
enum ElossCon {lossCastle, lossHero, timeExpires, lossStandard=255};
|
||||
//enum EAbilities {DOUBLE_WIDE, FLYING, SHOOTER, TWO_HEX_ATTACK, SIEGE_ABILITY, SIEGE_WEAPON,
|
||||
// KING1, KING2, KING3, MIND_IMMUNITY, NO_OBSTACLE_PENALTY, NO_CLOSE_COMBAT_PENALTY,
|
||||
// JOUSTING, FIRE_IMMUNITY, TWICE_ATTACK, NO_ENEMY_RETALIATION, NO_MORAL_PENALTY,
|
||||
// UNDEAD, MULTI_HEAD_ATTACK, EXTENDED_RADIOUS_SHOOTER, GHOST, RAISES_MORALE,
|
||||
// LOWERS_MORALE, DRAGON, STRIKE_AND_RETURN, FEARLESS, REBIRTH, NOT_ACTIVE}; //some flags are used only for battles
|
||||
enum ECombatInfo{ALIVE = 180, SUMMONED, CLONED, HAD_MORALE, WAITING, MOVED, DEFENDING};
|
||||
|
||||
struct StackFeature
|
||||
{
|
||||
//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, HATE /*eg. angels hate devils*/,
|
||||
KING1,
|
||||
KING2, KING3, MAGIC_RESISTANCE /*in %*/,
|
||||
CHANGES_SPELL_COST /*in mana points, eg. pegasus or mage*/,
|
||||
SPELL_AFTER_ATTACK /* subtype - spell id, value - spell level, aditional info - chance in %; eg. dendroids*/,
|
||||
SPELL_RESISTANCE_AURA /*eg. unicorns, value - resistance bonus in % for adjacent creatures*/,
|
||||
LEVEL_SPELL_IMMUNITY /*creature is immune to all spell with level below 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_SPELLCASTER, BLOCKS_RETAILATION /*eg. naga*/,
|
||||
SPELL_IMMUNITY /*value - spell id*/,
|
||||
MANA_CHANNELING /*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, ENEMY_LUCK_DECREASING, UNDEAD, REGENERATION, MANA_DRAIN, LIFE_DRAIN,
|
||||
DOUBLE_DAMAGE_CHANCE /*in %, eg. dread knight*/,
|
||||
RETURN_AFTER_STRIKE, SELF_MORALE /*eg. minotaur*/,
|
||||
SPELLCASTER /*value - spell id*/, CATAPULT,
|
||||
ENEMY_DEFENCE_REDUCTION /*in %, 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, DEFENCE_BONUS, SPEED_BONUS, HP_BONUS, ENCHANTER, HEALER, SIEGE_WEAPON, LUCK_BONUS, MORALE_BONUS, HYPNOTIZED, ADDITIONAL_RETAILATION,
|
||||
MAGIC_MIRROR /* value - chance of redirecting in %*/,
|
||||
SUMMONED, ALWAYS_MINUMUM_DAMAGE /*unit does its minimum damage from range; -1 - any attack, 0 - melee, 1 - ranged*/,
|
||||
ALWAYS_MAXIMUM_DAMAGE /*eg. bless effect, -1 - any attack, 0 - melee, 1 - ranged*/,
|
||||
ATTACKS_NEAREST_CREATURE /*while in berserk*/, IN_FRENZY,
|
||||
SLAYER /*value - level*/,
|
||||
FORGETFULL /*forgetfullnes spell effect*/,
|
||||
CLONED, NOT_ACTIVE
|
||||
};
|
||||
|
||||
enum EDuration
|
||||
{
|
||||
WHOLE_BATTLE,
|
||||
N_TURNS,
|
||||
UNITL_BEING_ATTACKED,/*removed after attack and counterattacks are performed*/
|
||||
UNTIL_ATTACK /*removed after attack and counterattacks are performed*/
|
||||
};
|
||||
|
||||
ECombatFeatures type;
|
||||
EDuration duration;
|
||||
ui16 turnsRemain; //if duration is N_TURNS it describes how long the effect will last
|
||||
si16 subtype; //subtype of bonus/feature
|
||||
si32 value;
|
||||
si32 additionalInfo;
|
||||
|
||||
inline bool operator == (const ECombatFeatures & cf) const
|
||||
{
|
||||
return type == cf;
|
||||
}
|
||||
StackFeature() : type(NO_TYPE)
|
||||
{}
|
||||
StackFeature(const ECombatFeatures & cf) : type(cf), duration(WHOLE_BATTLE)
|
||||
{}
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & type & duration & turnsRemain & subtype & value & additionalInfo;
|
||||
}
|
||||
};
|
||||
|
||||
//generates StackFeature from given data
|
||||
inline StackFeature makeFeature(StackFeature::ECombatFeatures type, StackFeature::EDuration duration, si16 subtype, si32 value, ui16 turnsRemain = 0, si32 additionalInfo = 0)
|
||||
{
|
||||
StackFeature sf;
|
||||
sf.type = type;
|
||||
sf.duration = duration;
|
||||
sf.turnsRemain = turnsRemain;
|
||||
sf.subtype = subtype;
|
||||
sf.value = value;
|
||||
sf.additionalInfo = additionalInfo;
|
||||
|
||||
return sf;
|
||||
}
|
||||
|
||||
class CGameInfo;
|
||||
extern CGameInfo* CGI;
|
||||
|
||||
|
@ -338,19 +338,19 @@ void CCreatureHandler::loadCreatures()
|
||||
ncre.abilityRefs = buf.substr(befi, i-befi);
|
||||
i+=2;
|
||||
if(boost::algorithm::find_first(ncre.abilityRefs, "DOUBLE_WIDE"))
|
||||
ncre.abilities.push_back(StackFeature::DOUBLE_WIDE);
|
||||
ncre.abilities.push_back(makeFeature(StackFeature::DOUBLE_WIDE, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY));
|
||||
if(boost::algorithm::find_first(ncre.abilityRefs, "FLYING_ARMY"))
|
||||
ncre.abilities.push_back(StackFeature::FLYING);
|
||||
ncre.abilities.push_back(makeFeature(StackFeature::FLYING, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY));
|
||||
if(boost::algorithm::find_first(ncre.abilityRefs, "SHOOTING_ARMY"))
|
||||
ncre.abilities.push_back(StackFeature::SHOOTER);
|
||||
ncre.abilities.push_back(makeFeature(StackFeature::SHOOTER, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY));
|
||||
if(boost::algorithm::find_first(ncre.abilityRefs, "SIEGE_WEAPON"))
|
||||
ncre.abilities.push_back(StackFeature::SIEGE_WEAPON);
|
||||
ncre.abilities.push_back(makeFeature(StackFeature::SIEGE_WEAPON, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY));
|
||||
if(boost::algorithm::find_first(ncre.abilityRefs, "const_two_attacks"))
|
||||
ncre.abilities.push_back(makeFeature(StackFeature::ADDITIONAL_ATTACK, StackFeature::WHOLE_BATTLE, 0, 1));
|
||||
ncre.abilities.push_back(makeFeature(StackFeature::ADDITIONAL_ATTACK, StackFeature::WHOLE_BATTLE, 0, 1, StackFeature::CREATURE_ABILITY));
|
||||
if(boost::algorithm::find_first(ncre.abilityRefs, "const_free_attack"))
|
||||
ncre.abilities.push_back(StackFeature::BLOCKS_RETAILATION);
|
||||
ncre.abilities.push_back(makeFeature(StackFeature::BLOCKS_RETAILATION, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY));
|
||||
if(boost::algorithm::find_first(ncre.abilityRefs, "IS_UNDEAD"))
|
||||
ncre.abilities.push_back(StackFeature::UNDEAD);
|
||||
ncre.abilities.push_back(makeFeature(StackFeature::UNDEAD, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY));
|
||||
if(ncre.nameSing!=std::string("") && ncre.namePl!=std::string(""))
|
||||
{
|
||||
ncre.idNumber = creatures.size();
|
||||
@ -485,22 +485,22 @@ void CCreatureHandler::loadCreatures()
|
||||
inp2.close();
|
||||
|
||||
//TODO: create a tidy configuration file to control fixing unit abilities
|
||||
creatures[115].abilities.push_back(StackFeature::DOUBLE_WIDE);//water elemental should be treated as double-wide
|
||||
creatures[123].abilities.push_back(StackFeature::DOUBLE_WIDE);//ice elemental should be treated as double-wide
|
||||
creatures[140].abilities.push_back(StackFeature::DOUBLE_WIDE);//boar should be treated as double-wide
|
||||
creatures[142].abilities.push_back(StackFeature::DOUBLE_WIDE);//nomads should be treated as double-wide
|
||||
creatures[115].abilities.push_back(makeFeature(StackFeature::DOUBLE_WIDE, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY));//water elemental should be treated as double-wide
|
||||
creatures[123].abilities.push_back(makeFeature(StackFeature::DOUBLE_WIDE, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY));//ice elemental should be treated as double-wide
|
||||
creatures[140].abilities.push_back(makeFeature(StackFeature::DOUBLE_WIDE, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY));//boar should be treated as double-wide
|
||||
creatures[142].abilities.push_back(makeFeature(StackFeature::DOUBLE_WIDE, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY));//nomads should be treated as double-wide
|
||||
|
||||
creatures[46].abilities -= StackFeature::FLYING; //hell hound
|
||||
creatures[47].abilities -= StackFeature::FLYING; //cerberus
|
||||
creatures[52].abilities += StackFeature::FLYING; //Efreeti
|
||||
creatures[53].abilities += StackFeature::FLYING; //Efreet Sultan
|
||||
creatures[52].abilities += makeFeature(StackFeature::FLYING, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY); //Efreeti
|
||||
creatures[53].abilities += makeFeature(StackFeature::FLYING, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY); //Efreet Sultan
|
||||
|
||||
creatures[47].abilities += StackFeature::THREE_HEADED_ATTACK; //cerberus
|
||||
creatures[47].abilities += makeFeature(StackFeature::THREE_HEADED_ATTACK, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY); //cerberus
|
||||
|
||||
creatures[87].abilities += makeFeature(StackFeature::ADDITIONAL_ATTACK, StackFeature::WHOLE_BATTLE, 0, 1); //wolf raider
|
||||
creatures[87].abilities += makeFeature(StackFeature::ADDITIONAL_ATTACK, StackFeature::WHOLE_BATTLE, 0, 1, StackFeature::CREATURE_ABILITY); //wolf raider
|
||||
|
||||
creatures[147].abilities += StackFeature::NOT_ACTIVE; //First Aid Tent //TODO: remove when support is added
|
||||
creatures[148].abilities += StackFeature::NOT_ACTIVE; //Ammo Cart
|
||||
creatures[147].abilities += makeFeature(StackFeature::NOT_ACTIVE, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY); //First Aid Tent //TODO: remove when support is added
|
||||
creatures[148].abilities += makeFeature(StackFeature::NOT_ACTIVE, StackFeature::WHOLE_BATTLE, 0, 0, StackFeature::CREATURE_ABILITY); //Ammo Cart
|
||||
}
|
||||
|
||||
void CCreatureHandler::loadAnimationInfo()
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <set>
|
||||
|
||||
#include "CSoundBase.h"
|
||||
#include "lib/StackFeature.h"
|
||||
|
||||
/*
|
||||
* CCreatureHandler.h, part of VCMI engine
|
||||
|
Loading…
Reference in New Issue
Block a user