2011-12-14 00:23:17 +03:00
|
|
|
#include "StdInc.h"
|
2007-06-08 22:56:35 +03:00
|
|
|
#include "CCreatureHandler.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
|
2012-08-25 11:44:51 +03:00
|
|
|
#include "CGeneralTextHandler.h"
|
2012-08-01 15:02:54 +03:00
|
|
|
#include "Filesystem/CResourceLoader.h"
|
2012-08-25 11:44:51 +03:00
|
|
|
#include "VCMI_Lib.h"
|
|
|
|
#include "CGameState.h"
|
2012-09-05 15:49:23 +03:00
|
|
|
#include "CTownHandler.h"
|
2012-08-24 12:37:52 +03:00
|
|
|
#include "CModHandler.h"
|
2009-04-15 17:03:31 +03:00
|
|
|
|
2008-08-30 00:41:32 +03:00
|
|
|
using namespace boost::assign;
|
2009-04-15 17:03:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CCreatureHandler.cpp, 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
|
|
|
|
*
|
|
|
|
*/
|
2013-02-24 01:48:22 +03:00
|
|
|
|
|
|
|
static inline void registerCreature(const std::string &name, const si32 id)
|
|
|
|
{
|
|
|
|
const std::string fullname = "creature." + name;
|
|
|
|
VLC->modh->identifiers.registerObject(fullname,id);
|
|
|
|
}
|
|
|
|
|
|
|
|
///CCreatureHandler
|
2009-04-15 17:03:31 +03:00
|
|
|
|
2008-06-17 20:48:32 +03:00
|
|
|
CCreatureHandler::CCreatureHandler()
|
|
|
|
{
|
|
|
|
VLC->creh = this;
|
2009-08-24 20:40:20 +03:00
|
|
|
|
2011-07-13 21:39:02 +03:00
|
|
|
allCreatures.setDescription("All creatures");
|
|
|
|
creaturesOfLevel[0].setDescription("Creatures of unnormalized tier");
|
2011-02-10 15:12:53 +02:00
|
|
|
for(int i = 1; i < ARRAY_COUNT(creaturesOfLevel); i++)
|
2011-07-13 21:39:02 +03:00
|
|
|
creaturesOfLevel[i].setDescription("Creatures of tier " + boost::lexical_cast<std::string>(i));
|
2008-06-17 20:48:32 +03:00
|
|
|
}
|
2009-08-24 20:40:20 +03:00
|
|
|
|
2008-09-24 19:25:14 +03:00
|
|
|
int CCreature::getQuantityID(const int & quantity)
|
2008-02-25 01:06:27 +02:00
|
|
|
{
|
|
|
|
if (quantity<5)
|
|
|
|
return 1;
|
2012-06-13 16:04:06 +03:00
|
|
|
if (quantity<10)
|
2008-02-25 01:06:27 +02:00
|
|
|
return 2;
|
2012-06-13 16:04:06 +03:00
|
|
|
if (quantity<20)
|
2008-02-25 01:06:27 +02:00
|
|
|
return 3;
|
2012-06-13 16:04:06 +03:00
|
|
|
if (quantity<50)
|
2008-02-25 01:06:27 +02:00
|
|
|
return 4;
|
2012-06-13 16:04:06 +03:00
|
|
|
if (quantity<100)
|
2008-02-25 01:06:27 +02:00
|
|
|
return 5;
|
2012-06-13 16:04:06 +03:00
|
|
|
if (quantity<250)
|
2008-02-25 01:06:27 +02:00
|
|
|
return 6;
|
2012-06-13 16:04:06 +03:00
|
|
|
if (quantity<500)
|
2008-02-25 01:06:27 +02:00
|
|
|
return 7;
|
2012-06-13 16:04:06 +03:00
|
|
|
if (quantity<1000)
|
|
|
|
return 8;
|
|
|
|
return 9;
|
2008-02-25 01:06:27 +02:00
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
int CCreature::estimateCreatureCount(ui32 countID)
|
2011-08-25 18:24:37 +03:00
|
|
|
{
|
2012-06-13 16:04:06 +03:00
|
|
|
static const int creature_count[] = { 0, 3, 8, 15, 35, 75, 175, 375, 750, 2500 };
|
2011-08-27 05:15:58 +03:00
|
|
|
|
2012-06-13 16:04:06 +03:00
|
|
|
if (countID > 9)
|
2011-08-25 18:24:37 +03:00
|
|
|
assert("Wrong countID!");
|
2011-08-27 05:15:58 +03:00
|
|
|
|
|
|
|
return creature_count[countID];
|
2011-08-25 18:24:37 +03:00
|
|
|
}
|
|
|
|
|
2008-09-24 19:25:14 +03:00
|
|
|
bool CCreature::isDoubleWide() const
|
2008-04-14 21:24:46 +03:00
|
|
|
{
|
2010-05-02 21:20:26 +03:00
|
|
|
return doubleWide;
|
2008-04-14 21:24:46 +03:00
|
|
|
}
|
|
|
|
|
2008-09-24 19:25:14 +03:00
|
|
|
bool CCreature::isFlying() const
|
2008-04-14 21:24:46 +03:00
|
|
|
{
|
2010-11-19 00:06:56 +02:00
|
|
|
return hasBonusOfType(Bonus::FLYING);
|
2008-04-14 21:24:46 +03:00
|
|
|
}
|
2009-05-08 19:55:04 +03:00
|
|
|
|
2008-09-24 19:25:14 +03:00
|
|
|
bool CCreature::isShooting() const
|
2008-08-02 18:08:03 +03:00
|
|
|
{
|
2010-11-19 00:06:56 +02:00
|
|
|
return hasBonusOfType(Bonus::SHOOTER);
|
2008-08-02 18:08:03 +03:00
|
|
|
}
|
2009-05-08 19:55:04 +03:00
|
|
|
|
2009-04-16 17:01:27 +03:00
|
|
|
bool CCreature::isUndead() const
|
|
|
|
{
|
2010-11-19 00:06:56 +02:00
|
|
|
return hasBonusOfType(Bonus::UNDEAD);
|
2009-04-16 17:01:27 +03:00
|
|
|
}
|
2009-05-08 19:55:04 +03:00
|
|
|
|
2009-08-24 20:40:20 +03:00
|
|
|
/**
|
|
|
|
* Determines if the creature is of a good alignment.
|
|
|
|
* @return true if the creture is good, false otherwise.
|
|
|
|
*/
|
|
|
|
bool CCreature::isGood () const
|
|
|
|
{
|
2012-10-05 16:11:26 +03:00
|
|
|
return VLC->townh->factions[faction].alignment == EAlignment::GOOD;
|
2009-08-24 20:40:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if the creature is of an evil alignment.
|
|
|
|
* @return true if the creature is evil, false otherwise.
|
|
|
|
*/
|
|
|
|
bool CCreature::isEvil () const
|
|
|
|
{
|
2012-10-05 16:11:26 +03:00
|
|
|
return VLC->townh->factions[faction].alignment == EAlignment::EVIL;
|
2009-08-24 20:40:20 +03:00
|
|
|
}
|
|
|
|
|
2008-08-01 14:21:15 +03:00
|
|
|
si32 CCreature::maxAmount(const std::vector<si32> &res) const //how many creatures can be bought
|
2008-05-12 08:46:04 +03:00
|
|
|
{
|
|
|
|
int ret = 2147483645;
|
|
|
|
int resAmnt = std::min(res.size(),cost.size());
|
|
|
|
for(int i=0;i<resAmnt;i++)
|
|
|
|
if(cost[i])
|
2008-08-01 14:21:15 +03:00
|
|
|
ret = std::min(ret,(int)(res[i]/cost[i]));
|
2008-05-12 08:46:04 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2008-04-14 21:24:46 +03:00
|
|
|
|
2010-05-02 21:20:26 +03:00
|
|
|
CCreature::CCreature()
|
|
|
|
{
|
|
|
|
doubleWide = false;
|
2011-07-13 21:39:02 +03:00
|
|
|
setNodeType(CBonusSystemNode::CREATURE);
|
2010-05-02 21:20:26 +03:00
|
|
|
}
|
2013-02-16 17:03:47 +03:00
|
|
|
void CCreature::addBonus(int val, Bonus::BonusType type, int subtype /*= -1*/)
|
2010-05-02 21:20:26 +03:00
|
|
|
{
|
2010-11-20 02:03:31 +02:00
|
|
|
Bonus *added = new Bonus(Bonus::PERMANENT, type, Bonus::CREATURE_ABILITY, val, idNumber, subtype, Bonus::BASE_NUMBER);
|
2010-11-19 00:06:56 +02:00
|
|
|
addNewBonus(added);
|
2010-05-02 21:20:26 +03:00
|
|
|
}
|
2010-11-13 22:26:15 +02:00
|
|
|
// void CCreature::getParents(TCNodes &out, const CBonusSystemNode *root /*= NULL*/) const
|
|
|
|
// {
|
|
|
|
// out.insert (VLC->creh->globalEffects);
|
|
|
|
// }
|
2010-07-12 13:20:25 +03:00
|
|
|
bool CCreature::isMyUpgrade(const CCreature *anotherCre) const
|
|
|
|
{
|
|
|
|
//TODO upgrade of upgrade?
|
|
|
|
return vstd::contains(upgrades, anotherCre->idNumber);
|
|
|
|
}
|
|
|
|
|
2010-11-27 22:17:28 +02:00
|
|
|
bool CCreature::valid() const
|
|
|
|
{
|
|
|
|
return this == VLC->creh->creatures[idNumber];
|
|
|
|
}
|
|
|
|
|
2010-12-29 23:04:22 +02:00
|
|
|
std::string CCreature::nodeName() const
|
|
|
|
{
|
2011-02-10 15:12:53 +02:00
|
|
|
return "\"" + namePl + "\"";
|
2010-12-29 23:04:22 +02:00
|
|
|
}
|
|
|
|
|
2012-05-18 23:50:16 +03:00
|
|
|
bool CCreature::isItNativeTerrain(int terrain) const
|
|
|
|
{
|
2012-09-29 18:10:56 +03:00
|
|
|
return VLC->townh->factions[faction].nativeTerrain == terrain;
|
2009-06-28 16:49:39 +03:00
|
|
|
}
|
|
|
|
|
2011-09-01 06:39:53 +03:00
|
|
|
static void AddAbility(CCreature *cre, const JsonVector &ability_vec)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2011-09-01 06:39:53 +03:00
|
|
|
Bonus *nsf = new Bonus();
|
|
|
|
std::string type = ability_vec[0].String();
|
2009-06-28 16:49:39 +03:00
|
|
|
|
2013-02-25 15:18:45 +03:00
|
|
|
auto it = bonusNameMap.find(type);
|
2009-06-28 16:49:39 +03:00
|
|
|
|
2011-09-01 06:39:53 +03:00
|
|
|
if (it == bonusNameMap.end()) {
|
|
|
|
if (type == "DOUBLE_WIDE")
|
|
|
|
cre->doubleWide = true;
|
|
|
|
else if (type == "ENEMY_MORALE_DECREASING") {
|
|
|
|
cre->addBonus(-1, Bonus::MORALE);
|
|
|
|
cre->getBonusList().back()->effectRange = Bonus::ONLY_ENEMY_ARMY;
|
|
|
|
}
|
|
|
|
else if (type == "ENEMY_LUCK_DECREASING") {
|
|
|
|
cre->addBonus(-1, Bonus::LUCK);
|
|
|
|
cre->getBonusList().back()->effectRange = Bonus::ONLY_ENEMY_ARMY;
|
|
|
|
} else
|
2013-02-24 01:48:22 +03:00
|
|
|
tlog1 << "Error: invalid ability type " << type << " in creatures config" << std::endl;
|
2011-09-01 06:39:53 +03:00
|
|
|
|
|
|
|
return;
|
2009-06-28 16:49:39 +03:00
|
|
|
}
|
2011-09-01 06:39:53 +03:00
|
|
|
|
|
|
|
nsf->type = it->second;
|
2013-02-25 15:18:45 +03:00
|
|
|
|
|
|
|
JsonUtils::parseTypedBonusShort(ability_vec,nsf);
|
2011-09-01 06:39:53 +03:00
|
|
|
|
|
|
|
nsf->source = Bonus::CREATURE_ABILITY;
|
|
|
|
nsf->sid = cre->idNumber;
|
2013-02-25 15:18:45 +03:00
|
|
|
|
2011-09-01 06:39:53 +03:00
|
|
|
cre->addNewBonus(nsf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void RemoveAbility(CCreature *cre, const JsonNode &ability)
|
|
|
|
{
|
2013-02-25 15:18:45 +03:00
|
|
|
const std::string type = ability.String();
|
2011-09-01 06:39:53 +03:00
|
|
|
|
2013-02-25 15:18:45 +03:00
|
|
|
auto it = bonusNameMap.find(type);
|
2011-09-01 06:39:53 +03:00
|
|
|
|
|
|
|
if (it == bonusNameMap.end()) {
|
|
|
|
if (type == "DOUBLE_WIDE")
|
|
|
|
cre->doubleWide = false;
|
|
|
|
else
|
2013-02-24 01:48:22 +03:00
|
|
|
tlog1 << "Error: invalid ability type " << type << " in creatures config" << std::endl;
|
2011-09-01 06:39:53 +03:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-25 15:18:45 +03:00
|
|
|
const int typeNo = it->second;
|
2011-09-01 06:39:53 +03:00
|
|
|
|
|
|
|
Bonus::BonusType ecf = static_cast<Bonus::BonusType>(typeNo);
|
|
|
|
|
2012-09-20 19:55:21 +03:00
|
|
|
Bonus *b = cre->getBonusLocalFirst(Selector::type(ecf));
|
2011-09-01 06:39:53 +03:00
|
|
|
cre->removeBonus(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCreatureHandler::loadCreatures()
|
|
|
|
{
|
2013-02-25 15:18:45 +03:00
|
|
|
tlog5 << "\t\tReading ZCRTRAIT.TXT" << std::endl;
|
2009-06-28 16:49:39 +03:00
|
|
|
|
|
|
|
////////////reading ZCRTRAIT.TXT ///////////////////
|
2012-09-26 16:13:39 +03:00
|
|
|
CLegacyConfigParser parser("DATA/ZCRTRAIT.TXT");
|
|
|
|
|
|
|
|
parser.endLine(); // header
|
|
|
|
parser.endLine();
|
2007-06-10 21:04:15 +03:00
|
|
|
|
2012-09-26 16:13:39 +03:00
|
|
|
do
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2012-09-26 16:13:39 +03:00
|
|
|
//loop till non-empty line
|
|
|
|
while (parser.isNextEntryEmpty())
|
|
|
|
parser.endLine();
|
|
|
|
|
2010-05-02 21:20:26 +03:00
|
|
|
CCreature &ncre = *new CCreature;
|
2013-02-11 02:24:57 +03:00
|
|
|
ncre.idNumber = CreatureID(creatures.size());
|
2011-12-14 00:23:17 +03:00
|
|
|
ncre.cost.resize(GameConstants::RESOURCE_QUANTITY);
|
2008-02-05 05:56:45 +02:00
|
|
|
ncre.level=0;
|
2012-09-22 18:10:15 +03:00
|
|
|
ncre.iconIndex = ncre.idNumber + 2; // +2 for empty\selection images
|
2009-04-26 02:31:39 +03:00
|
|
|
|
2012-09-26 16:13:39 +03:00
|
|
|
ncre.nameSing = parser.readString();
|
|
|
|
ncre.namePl = parser.readString();
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2009-06-28 16:49:39 +03:00
|
|
|
for(int v=0; v<7; ++v)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2012-09-26 16:13:39 +03:00
|
|
|
ncre.cost[v] = parser.readNumber();
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2012-09-26 16:13:39 +03:00
|
|
|
ncre.fightValue = parser.readNumber();
|
|
|
|
ncre.AIValue = parser.readNumber();
|
|
|
|
ncre.growth = parser.readNumber();
|
|
|
|
ncre.hordeGrowth = parser.readNumber();
|
|
|
|
|
|
|
|
ncre.addBonus(parser.readNumber(), Bonus::STACK_HEALTH);
|
|
|
|
ncre.addBonus(parser.readNumber(), Bonus::STACKS_SPEED);
|
|
|
|
ncre.addBonus(parser.readNumber(), Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK);
|
|
|
|
ncre.addBonus(parser.readNumber(), Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE);
|
|
|
|
ncre.addBonus(parser.readNumber(), Bonus::CREATURE_DAMAGE, 1);
|
|
|
|
ncre.addBonus(parser.readNumber(), Bonus::CREATURE_DAMAGE, 2);
|
|
|
|
ncre.addBonus(parser.readNumber(), Bonus::SHOTS);
|
2012-08-30 17:57:24 +03:00
|
|
|
|
|
|
|
//spells - not used?
|
2012-09-26 16:13:39 +03:00
|
|
|
parser.readNumber();
|
|
|
|
ncre.ammMin = parser.readNumber();
|
|
|
|
ncre.ammMax = parser.readNumber();
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2012-09-26 16:13:39 +03:00
|
|
|
ncre.abilityText = parser.readString();
|
|
|
|
ncre.abilityRefs = parser.readString();
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2009-06-28 16:49:39 +03:00
|
|
|
{ //adding abilities from ZCRTRAIT.TXT
|
2013-02-25 15:18:45 +03:00
|
|
|
static const std::pair < std::string,Bonus::BonusType> abilityMap [] =
|
|
|
|
{{"FLYING_ARMY", Bonus::FLYING},
|
|
|
|
{"SHOOTING_ARMY", Bonus::SHOOTER},
|
|
|
|
{"SIEGE_WEAPON", Bonus::SIEGE_WEAPON},
|
|
|
|
{"const_free_attack", Bonus::BLOCKS_RETALIATION},
|
|
|
|
{"IS_UNDEAD", Bonus::UNDEAD},
|
|
|
|
{"const_no_melee_penalty",Bonus::NO_MELEE_PENALTY},
|
|
|
|
{"const_jousting",Bonus::JOUSTING},
|
|
|
|
{"KING_1",Bonus::KING1},
|
|
|
|
{"KING_2",Bonus::KING2},
|
|
|
|
{"KING_3",Bonus::KING3},
|
|
|
|
{"const_no_wall_penalty",Bonus::NO_WALL_PENALTY},
|
|
|
|
{"CATAPULT",Bonus::CATAPULT},
|
|
|
|
{"MULTI_HEADED",Bonus::ATTACKS_ALL_ADJACENT},
|
|
|
|
{"IMMUNE_TO_MIND_SPELLS",Bonus::MIND_IMMUNITY},
|
|
|
|
{"IMMUNE_TO_FIRE_SPELLS",Bonus::FIRE_IMMUNITY},
|
|
|
|
{"IMMUNE_TO_FIRE_SPELLS",Bonus::FIRE_IMMUNITY},
|
|
|
|
{"HAS_EXTENDED_ATTACK",Bonus::TWO_HEX_ATTACK_BREATH}};
|
2013-02-24 01:48:22 +03:00
|
|
|
|
|
|
|
auto hasAbility = [&ncre](const std::string name) -> bool
|
|
|
|
{
|
|
|
|
return boost::algorithm::find_first(ncre.abilityRefs,name);
|
|
|
|
};
|
|
|
|
BOOST_FOREACH(auto a, abilityMap)
|
|
|
|
{
|
|
|
|
if(hasAbility(a.first))
|
|
|
|
ncre.addBonus(0, a.second);
|
|
|
|
}
|
|
|
|
if(hasAbility("DOUBLE_WIDE"))
|
2010-05-02 21:20:26 +03:00
|
|
|
ncre.doubleWide = true;
|
2013-02-24 01:48:22 +03:00
|
|
|
if(hasAbility("const_raises_morale"))
|
2010-05-02 21:20:26 +03:00
|
|
|
{
|
|
|
|
ncre.addBonus(+1, Bonus::MORALE);;
|
2012-03-06 19:59:55 +03:00
|
|
|
ncre.getBonusList().back()->addPropagator(make_shared<CPropagatorNodeType>(CBonusSystemNode::HERO));
|
2010-05-02 21:20:26 +03:00
|
|
|
}
|
2013-02-24 01:48:22 +03:00
|
|
|
if(hasAbility("const_lowers_morale"))
|
2010-05-02 21:20:26 +03:00
|
|
|
{
|
|
|
|
ncre.addBonus(-1, Bonus::MORALE);;
|
2011-07-13 21:39:02 +03:00
|
|
|
ncre.getBonusList().back()->effectRange = Bonus::ONLY_ENEMY_ARMY;
|
2010-05-02 21:20:26 +03:00
|
|
|
}
|
2009-05-15 15:07:55 +03:00
|
|
|
}
|
2012-09-26 16:13:39 +03:00
|
|
|
creatures.push_back(&ncre);
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2012-09-26 16:13:39 +03:00
|
|
|
while (parser.endLine());
|
2009-06-28 16:49:39 +03:00
|
|
|
|
2011-08-21 00:53:03 +03:00
|
|
|
// loading creatures properties
|
2012-12-22 19:47:12 +03:00
|
|
|
tlog5 << "\t\tReading creatures json configs" << std::endl;
|
2008-11-01 00:41:22 +02:00
|
|
|
|
2012-12-22 19:47:12 +03:00
|
|
|
const JsonNode gameConf(ResourceID("config/gameConfig.json"));
|
|
|
|
const JsonNode config(JsonUtils::assembleFromFiles(gameConf["creatures"].convertTo<std::vector<std::string> >()));
|
|
|
|
|
|
|
|
BOOST_FOREACH(auto & node, config.Struct())
|
2012-04-22 16:28:46 +03:00
|
|
|
{
|
2012-12-23 13:23:41 +03:00
|
|
|
int creatureID = node.second["id"].Float();
|
2011-08-21 00:53:03 +03:00
|
|
|
CCreature *c = creatures[creatureID];
|
2012-12-03 19:00:17 +03:00
|
|
|
|
2012-12-23 13:23:41 +03:00
|
|
|
BOOST_FOREACH(const JsonNode &ability, node.second["ability_remove"].Vector())
|
2012-05-13 18:04:21 +03:00
|
|
|
{
|
2012-12-23 13:23:41 +03:00
|
|
|
RemoveAbility(c, ability);
|
2012-05-13 18:04:21 +03:00
|
|
|
}
|
2012-12-23 13:23:41 +03:00
|
|
|
BOOST_FOREACH(const JsonNode &ability, node.second["abilities"].Vector())
|
2012-04-22 16:28:46 +03:00
|
|
|
{
|
2013-02-08 12:22:10 +03:00
|
|
|
if (ability.getType() == JsonNode::DATA_VECTOR)
|
|
|
|
AddAbility(c, ability.Vector());
|
|
|
|
else
|
|
|
|
c->addNewBonus(JsonUtils::parseBonus(ability));
|
2011-08-30 09:19:07 +03:00
|
|
|
}
|
|
|
|
|
2012-12-23 13:23:41 +03:00
|
|
|
loadCreatureJson(c, node.second);
|
2012-12-22 19:47:12 +03:00
|
|
|
|
|
|
|
// Main reference name, e.g. royalGriffin
|
|
|
|
c->nameRef = node.first;
|
2013-02-24 01:48:22 +03:00
|
|
|
registerCreature(node.first, c->idNumber);
|
2012-12-19 20:24:53 +03:00
|
|
|
|
2012-12-22 19:47:12 +03:00
|
|
|
// Alternative names, if any
|
2012-12-23 13:23:41 +03:00
|
|
|
BOOST_FOREACH(const JsonNode &name, node.second["extraNames"].Vector())
|
2012-12-03 19:00:17 +03:00
|
|
|
{
|
2013-02-24 01:48:22 +03:00
|
|
|
registerCreature(name.String(), c->idNumber);
|
2012-12-03 19:00:17 +03:00
|
|
|
}
|
2008-08-02 18:08:03 +03:00
|
|
|
}
|
2009-09-05 17:10:26 +03:00
|
|
|
|
2011-08-21 00:53:03 +03:00
|
|
|
loadAnimationInfo();
|
2011-02-02 20:49:48 +02:00
|
|
|
|
|
|
|
//reading creature ability names
|
2012-08-02 14:03:26 +03:00
|
|
|
const JsonNode config2(ResourceID("config/bonusnames.json"));
|
2011-08-21 01:31:59 +03:00
|
|
|
|
2012-04-22 16:28:46 +03:00
|
|
|
BOOST_FOREACH(const JsonNode &bonus, config2["bonuses"].Vector())
|
|
|
|
{
|
2013-02-25 15:18:45 +03:00
|
|
|
const std::string bonusID = bonus["id"].String();
|
2011-08-21 01:31:59 +03:00
|
|
|
|
2013-02-25 15:18:45 +03:00
|
|
|
auto it_map = bonusNameMap.find(bonusID);
|
2012-04-22 16:28:46 +03:00
|
|
|
if (it_map != bonusNameMap.end())
|
2011-08-21 01:31:59 +03:00
|
|
|
stackBonuses[it_map->second] = std::pair<std::string, std::string>(bonus["name"].String(), bonus["description"].String());
|
2012-04-22 16:28:46 +03:00
|
|
|
else
|
2011-08-21 01:31:59 +03:00
|
|
|
tlog2 << "Bonus " << bonusID << " not recognized, ignoring\n";
|
2011-02-02 20:49:48 +02:00
|
|
|
}
|
2011-08-21 01:31:59 +03:00
|
|
|
|
2011-06-18 13:58:46 +03:00
|
|
|
//handle magic resistance secondary skill premy, potentialy may be buggy
|
2013-02-16 17:03:47 +03:00
|
|
|
//std::map<Bonus::BonusType, std::pair<std::string, std::string> >::iterator it = stackBonuses.find(Bonus::MAGIC_RESISTANCE);
|
2011-10-20 14:03:04 +03:00
|
|
|
//stackBonuses[Bonus::SECONDARY_SKILL_PREMY] = std::pair<std::string, std::string>(it->second.first, it->second.second);
|
2011-02-03 14:58:46 +02:00
|
|
|
|
2012-08-24 12:37:52 +03:00
|
|
|
if (VLC->modh->modules.STACK_EXP) //reading default stack experience bonuses
|
2011-02-03 14:58:46 +02:00
|
|
|
{
|
2012-08-25 11:44:51 +03:00
|
|
|
CLegacyConfigParser parser("DATA/CREXPBON.TXT");
|
|
|
|
|
2011-02-11 10:20:26 +02:00
|
|
|
Bonus b; //prototype with some default properties
|
2011-02-03 14:58:46 +02:00
|
|
|
b.source = Bonus::STACK_EXPERIENCE;
|
2011-02-13 15:16:41 +02:00
|
|
|
b.duration = Bonus::PERMANENT;
|
2011-02-11 10:20:26 +02:00
|
|
|
b.valType = Bonus::ADDITIVE_VALUE;
|
2011-02-13 15:16:41 +02:00
|
|
|
b.effectRange = Bonus::NO_LIMIT;
|
2011-02-08 13:34:34 +02:00
|
|
|
b.additionalInfo = 0;
|
2011-02-14 23:08:29 +02:00
|
|
|
b.turnsRemain = 0;
|
2011-02-11 10:20:26 +02:00
|
|
|
BonusList bl;
|
2011-02-03 14:58:46 +02:00
|
|
|
|
2012-08-25 11:44:51 +03:00
|
|
|
parser.endLine();
|
2011-02-11 10:20:26 +02:00
|
|
|
|
2012-08-25 11:44:51 +03:00
|
|
|
parser.readString(); //ignore index
|
|
|
|
loadStackExp(b, bl, parser);
|
2011-02-11 10:20:26 +02:00
|
|
|
BOOST_FOREACH(Bonus * b, bl)
|
|
|
|
addBonusForAllCreatures(b); //health bonus is common for all
|
2012-08-25 11:44:51 +03:00
|
|
|
parser.endLine();
|
2011-02-11 10:20:26 +02:00
|
|
|
|
2012-09-26 16:13:39 +03:00
|
|
|
for (int i = 1; i < 7; ++i)
|
2011-02-03 14:58:46 +02:00
|
|
|
{
|
|
|
|
for (int j = 0; j < 4; ++j) //four modifiers common for tiers
|
|
|
|
{
|
2012-08-25 11:44:51 +03:00
|
|
|
parser.readString(); //ignore index
|
2011-02-11 10:20:26 +02:00
|
|
|
bl.clear();
|
2012-08-25 11:44:51 +03:00
|
|
|
loadStackExp(b, bl, parser);
|
2011-02-11 10:20:26 +02:00
|
|
|
BOOST_FOREACH(Bonus * b, bl)
|
|
|
|
addBonusForTier(i, b);
|
2012-08-25 11:44:51 +03:00
|
|
|
parser.endLine();
|
2011-02-03 14:58:46 +02:00
|
|
|
}
|
|
|
|
}
|
2011-02-13 21:46:16 +02:00
|
|
|
for (int j = 0; j < 4; ++j) //tier 7
|
|
|
|
{
|
2012-08-25 11:44:51 +03:00
|
|
|
parser.readString(); //ignore index
|
2011-02-13 21:46:16 +02:00
|
|
|
bl.clear();
|
2012-08-25 11:44:51 +03:00
|
|
|
loadStackExp(b, bl, parser);
|
2011-02-13 21:46:16 +02:00
|
|
|
BOOST_FOREACH(Bonus * b, bl)
|
|
|
|
{
|
|
|
|
addBonusForTier(7, b);
|
|
|
|
creaturesOfLevel[0].addNewBonus(b); //bonuses from level 7 are given to high-level creatures
|
|
|
|
}
|
2012-08-25 11:44:51 +03:00
|
|
|
parser.endLine();
|
2011-02-13 21:46:16 +02:00
|
|
|
}
|
2011-02-03 14:58:46 +02:00
|
|
|
do //parse everything that's left
|
|
|
|
{
|
2012-08-25 11:44:51 +03:00
|
|
|
b.sid = parser.readNumber(); //id = this particular creature ID
|
|
|
|
loadStackExp(b, creatures[b.sid]->getBonusList(), parser); //add directly to CCreature Node
|
|
|
|
}
|
|
|
|
while (parser.endLine());
|
2011-02-06 10:32:05 +02:00
|
|
|
|
2011-02-11 10:20:26 +02:00
|
|
|
//Calculate rank exp values, formula appears complicated bu no parsing needed
|
|
|
|
expRanks.resize(8);
|
|
|
|
int dif = 0;
|
2012-08-25 11:44:51 +03:00
|
|
|
int it = 8000; //ignore name of this variable
|
2011-02-11 10:20:26 +02:00
|
|
|
expRanks[0].push_back(it);
|
|
|
|
for (int j = 1; j < 10; ++j) //used for tiers 8-10, and all other probably
|
|
|
|
{
|
2011-02-12 18:21:48 +02:00
|
|
|
expRanks[0].push_back(expRanks[0][j-1] + it + dif);
|
2011-02-11 10:20:26 +02:00
|
|
|
dif += it/5;
|
|
|
|
}
|
2012-09-26 16:13:39 +03:00
|
|
|
for (int i = 1; i < 8; ++i)
|
2011-02-11 10:20:26 +02:00
|
|
|
{
|
|
|
|
dif = 0;
|
|
|
|
it = 1000 * i;
|
|
|
|
expRanks[i].push_back(it);
|
|
|
|
for (int j = 1; j < 10; ++j)
|
|
|
|
{
|
2011-02-12 18:21:48 +02:00
|
|
|
expRanks[i].push_back(expRanks[i][j-1] + it + dif);
|
2011-02-11 10:20:26 +02:00
|
|
|
dif += it/5;
|
|
|
|
}
|
|
|
|
}
|
2011-02-10 15:12:53 +02:00
|
|
|
|
2012-08-25 11:44:51 +03:00
|
|
|
CLegacyConfigParser expBonParser("DATA/CREXPMOD.TXT");
|
|
|
|
|
|
|
|
expBonParser.endLine(); //header
|
2011-02-12 18:21:48 +02:00
|
|
|
|
|
|
|
maxExpPerBattle.resize(8);
|
2012-09-26 16:13:39 +03:00
|
|
|
for (int i = 1; i < 8; ++i)
|
2011-02-12 18:21:48 +02:00
|
|
|
{
|
2012-08-25 11:44:51 +03:00
|
|
|
expBonParser.readString(); //index
|
|
|
|
expBonParser.readString(); //float multiplier -> hardcoded
|
|
|
|
expBonParser.readString(); //ignore upgrade mod? ->hardcoded
|
|
|
|
expBonParser.readString(); //already calculated
|
|
|
|
|
|
|
|
maxExpPerBattle[i] = expBonParser.readNumber();
|
|
|
|
expRanks[i].push_back(expRanks[i].back() + expBonParser.readNumber());
|
|
|
|
|
|
|
|
expBonParser.endLine();
|
2011-02-12 18:21:48 +02:00
|
|
|
}
|
|
|
|
//skeleton gets exp penalty
|
|
|
|
creatures[56].get()->addBonus(-50, Bonus::EXP_MULTIPLIER, -1);
|
|
|
|
creatures[57].get()->addBonus(-50, Bonus::EXP_MULTIPLIER, -1);
|
|
|
|
//exp for tier >7, rank 11
|
2011-02-13 21:46:16 +02:00
|
|
|
expRanks[0].push_back(147000);
|
2011-02-12 18:21:48 +02:00
|
|
|
expAfterUpgrade = 75; //percent
|
2011-02-13 21:46:16 +02:00
|
|
|
maxExpPerBattle[0] = maxExpPerBattle[7];
|
2011-02-12 18:21:48 +02:00
|
|
|
|
2011-02-11 10:20:26 +02:00
|
|
|
}//end of Stack Experience
|
2012-04-22 16:28:46 +03:00
|
|
|
|
|
|
|
tlog5 << "\t\tReading config/commanders.json" << std::endl;
|
2012-08-02 14:03:26 +03:00
|
|
|
const JsonNode config3(ResourceID("config/commanders.json"));
|
2012-04-22 16:28:46 +03:00
|
|
|
|
|
|
|
BOOST_FOREACH (auto bonus, config3["bonusPerLevel"].Vector())
|
|
|
|
{
|
2012-12-02 15:21:44 +03:00
|
|
|
commanderLevelPremy.push_back(JsonUtils::parseBonus (bonus.Vector()));
|
2012-04-22 16:28:46 +03:00
|
|
|
}
|
|
|
|
|
2012-09-26 16:13:39 +03:00
|
|
|
int i = 0;
|
2012-04-22 16:28:46 +03:00
|
|
|
BOOST_FOREACH (auto skill, config3["skillLevels"].Vector())
|
|
|
|
{
|
2012-05-18 17:02:27 +03:00
|
|
|
skillLevels.push_back (std::vector<ui8>());
|
|
|
|
BOOST_FOREACH (auto skillLevel, skill["levels"].Vector())
|
2012-04-22 16:28:46 +03:00
|
|
|
{
|
|
|
|
skillLevels[i].push_back (skillLevel.Float());
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_FOREACH (auto ability, config3["abilityRequirements"].Vector())
|
|
|
|
{
|
|
|
|
std::pair <Bonus, std::pair <ui8, ui8> > a;
|
2012-12-02 15:21:44 +03:00
|
|
|
a.first = *JsonUtils::parseBonus (ability["ability"].Vector());
|
2012-04-22 16:28:46 +03:00
|
|
|
a.second.first = ability["skills"].Vector()[0].Float();
|
|
|
|
a.second.second = ability["skills"].Vector()[1].Float();
|
|
|
|
skillRequirements.push_back (a);
|
|
|
|
}
|
2007-10-15 23:59:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCreatureHandler::loadAnimationInfo()
|
|
|
|
{
|
2012-09-22 18:10:15 +03:00
|
|
|
CLegacyConfigParser parser("DATA/CRANIM.TXT");
|
2007-06-18 13:49:06 +03:00
|
|
|
|
2012-09-22 18:10:15 +03:00
|
|
|
parser.endLine(); // header
|
|
|
|
parser.endLine();
|
2009-06-28 17:57:00 +03:00
|
|
|
|
2012-09-22 18:10:15 +03:00
|
|
|
for(int dd=0; dd<creatures.size(); ++dd)
|
2007-06-18 13:49:06 +03:00
|
|
|
{
|
2012-09-22 18:10:15 +03:00
|
|
|
while (parser.isNextEntryEmpty() && parser.endLine()) // skip empty lines
|
|
|
|
;
|
2007-06-18 13:49:06 +03:00
|
|
|
|
2012-09-22 18:10:15 +03:00
|
|
|
loadUnitAnimInfo(*creatures[dd], parser);
|
2007-06-18 13:49:06 +03:00
|
|
|
}
|
2012-09-22 18:10:15 +03:00
|
|
|
}
|
2007-06-18 13:49:06 +03:00
|
|
|
|
2012-09-22 18:10:15 +03:00
|
|
|
void CCreatureHandler::loadUnitAnimInfo(CCreature & unit, CLegacyConfigParser & parser)
|
|
|
|
{
|
|
|
|
unit.timeBetweenFidgets = parser.readNumber();
|
|
|
|
unit.walkAnimationTime = parser.readNumber();
|
|
|
|
unit.attackAnimationTime = parser.readNumber();
|
|
|
|
unit.flightAnimationDistance = parser.readNumber();
|
2007-06-18 13:49:06 +03:00
|
|
|
///////////////////////
|
|
|
|
|
2012-09-22 18:10:15 +03:00
|
|
|
unit.upperRightMissleOffsetX = parser.readNumber();
|
|
|
|
unit.upperRightMissleOffsetY = parser.readNumber();
|
|
|
|
unit.rightMissleOffsetX = parser.readNumber();
|
|
|
|
unit.rightMissleOffsetY = parser.readNumber();
|
|
|
|
unit.lowerRightMissleOffsetX = parser.readNumber();
|
|
|
|
unit.lowerRightMissleOffsetY = parser.readNumber();
|
2007-06-18 13:49:06 +03:00
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
|
|
|
|
for(int jjj=0; jjj<12; ++jjj)
|
|
|
|
{
|
2012-09-22 18:10:15 +03:00
|
|
|
unit.missleFrameAngles[jjj] = parser.readNumber();
|
2007-06-18 13:49:06 +03:00
|
|
|
}
|
|
|
|
|
2012-09-22 18:10:15 +03:00
|
|
|
unit.troopCountLocationOffset= parser.readNumber();
|
|
|
|
unit.attackClimaxFrame = parser.readNumber();
|
2007-06-18 13:49:06 +03:00
|
|
|
|
2012-09-22 18:10:15 +03:00
|
|
|
parser.endLine();
|
2008-08-02 18:08:03 +03:00
|
|
|
}
|
2009-01-11 00:08:18 +02:00
|
|
|
|
2012-11-13 14:52:23 +03:00
|
|
|
void CCreatureHandler::load(const JsonNode & node)
|
|
|
|
{
|
|
|
|
BOOST_FOREACH(auto & entry, node.Struct())
|
|
|
|
{
|
|
|
|
if (!entry.second.isNull()) // may happens if mod removed creature by setting json entry to null
|
|
|
|
{
|
|
|
|
CCreature * creature = loadCreature(entry.second);
|
|
|
|
creature->nameRef = entry.first;
|
2013-02-11 02:24:57 +03:00
|
|
|
creature->idNumber = CreatureID(creatures.size());
|
2012-11-13 14:52:23 +03:00
|
|
|
|
|
|
|
creatures.push_back(creature);
|
2013-01-16 17:28:49 +03:00
|
|
|
tlog5 << "Added creature: " << entry.first << "\n";
|
2013-02-24 01:48:22 +03:00
|
|
|
registerCreature(creature->nameRef,creature->idNumber);
|
2012-11-13 14:52:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CCreature * CCreatureHandler::loadCreature(const JsonNode & node)
|
|
|
|
{
|
|
|
|
CCreature * cre = new CCreature();
|
|
|
|
|
|
|
|
const JsonNode & name = node["name"];
|
|
|
|
cre->nameSing = name["singular"].String();
|
|
|
|
cre->namePl = name["plural"].String();
|
|
|
|
|
|
|
|
cre->cost = Res::ResourceSet(node["cost"]);
|
|
|
|
|
|
|
|
cre->fightValue = node["fightValue"].Float();
|
|
|
|
cre->AIValue = node["aiValue"].Float();
|
|
|
|
cre->growth = node["growth"].Float();
|
|
|
|
cre->hordeGrowth = node["horde"].Float(); // Needed at least until configurable buildings
|
|
|
|
|
|
|
|
cre->addBonus(node["hitPoints"].Float(), Bonus::STACK_HEALTH);
|
|
|
|
cre->addBonus(node["speed"].Float(), Bonus::STACKS_SPEED);
|
|
|
|
cre->addBonus(node["attack"].Float(), Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK);
|
|
|
|
cre->addBonus(node["defense"].Float(), Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE);
|
|
|
|
const JsonNode & vec = node["damage"];
|
|
|
|
cre->addBonus(vec["min"].Float(), Bonus::CREATURE_DAMAGE, 1);
|
|
|
|
cre->addBonus(vec["max"].Float(), Bonus::CREATURE_DAMAGE, 2);
|
|
|
|
|
|
|
|
auto & amounts = node ["advMapAmount"];
|
|
|
|
cre->ammMin = amounts["min"].Float();
|
|
|
|
cre->ammMax = amounts["max"].Float();
|
|
|
|
|
|
|
|
if (!node["shots"].isNull())
|
|
|
|
cre->addBonus(node["shots"].Float(), Bonus::SHOTS);
|
|
|
|
|
|
|
|
if (node["spellPoints"].isNull())
|
|
|
|
cre->addBonus(node["spellPoints"].Float(), Bonus::CASTS);
|
|
|
|
|
|
|
|
cre->doubleWide = node["doubleWide"].Bool();
|
|
|
|
|
|
|
|
BOOST_FOREACH (const JsonNode &bonus, node["abilities"].Vector())
|
|
|
|
{
|
2012-12-02 15:21:44 +03:00
|
|
|
auto b = JsonUtils::parseBonus(bonus);
|
2012-11-13 14:52:23 +03:00
|
|
|
b->source = Bonus::CREATURE_ABILITY;
|
|
|
|
b->duration = Bonus::PERMANENT;
|
|
|
|
cre->addNewBonus(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_FOREACH (const JsonNode &exp, node["stackExperience"].Vector())
|
|
|
|
{
|
2012-12-02 15:21:44 +03:00
|
|
|
auto bonus = JsonUtils::parseBonus (exp["bonus"]);
|
2012-11-13 14:52:23 +03:00
|
|
|
bonus->source = Bonus::STACK_EXPERIENCE;
|
|
|
|
bonus->duration = Bonus::PERMANENT;
|
|
|
|
const JsonVector &values = exp["values"].Vector();
|
|
|
|
int lowerLimit = 1;//, upperLimit = 255;
|
|
|
|
if (values[0].getType() == JsonNode::JsonType::DATA_BOOL)
|
|
|
|
{
|
|
|
|
BOOST_FOREACH (const JsonNode &val, values)
|
|
|
|
{
|
|
|
|
if (val.Bool() == true)
|
|
|
|
{
|
|
|
|
bonus->limiter = make_shared<RankRangeLimiter>(RankRangeLimiter(lowerLimit));
|
|
|
|
cre->addNewBonus (new Bonus(*bonus)); //bonuses must be unique objects
|
|
|
|
break; //TODO: allow bonuses to turn off?
|
|
|
|
}
|
|
|
|
++lowerLimit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int lastVal = 0;
|
|
|
|
BOOST_FOREACH (const JsonNode &val, values)
|
|
|
|
{
|
|
|
|
if (val.Float() != lastVal)
|
|
|
|
{
|
|
|
|
bonus->val = val.Float() - lastVal;
|
|
|
|
bonus->limiter.reset (new RankRangeLimiter(lowerLimit));
|
|
|
|
cre->addNewBonus (new Bonus(*bonus));
|
|
|
|
}
|
|
|
|
lastVal = val.Float();
|
|
|
|
++lowerLimit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//graphics
|
|
|
|
|
|
|
|
const JsonNode & graphics = node["graphics"];
|
|
|
|
cre->timeBetweenFidgets = graphics["timeBetweenFidgets"].Float();
|
|
|
|
cre->troopCountLocationOffset = graphics["troopCountLocationOffset"].Float();
|
|
|
|
cre->attackClimaxFrame = graphics["attackClimaxFrame"].Float();
|
|
|
|
|
|
|
|
const JsonNode & animationTime = graphics["animationTime"];
|
|
|
|
cre->walkAnimationTime = animationTime["walk"].Float();
|
|
|
|
cre->attackAnimationTime = animationTime["attack"].Float();
|
|
|
|
cre->flightAnimationDistance = animationTime["flight"].Float(); //?
|
|
|
|
|
2012-12-23 13:23:41 +03:00
|
|
|
const JsonNode & missile = graphics["missile"];
|
2012-11-13 14:52:23 +03:00
|
|
|
const JsonNode & offsets = missile["offset"];
|
|
|
|
cre->upperRightMissleOffsetX = offsets["upperX"].Float();
|
|
|
|
cre->upperRightMissleOffsetY = offsets["upperY"].Float();
|
|
|
|
cre->rightMissleOffsetX = offsets["middleX"].Float();
|
|
|
|
cre->rightMissleOffsetY = offsets["middleY"].Float();
|
|
|
|
cre->lowerRightMissleOffsetX = offsets["lowerX"].Float();
|
|
|
|
cre->lowerRightMissleOffsetY = offsets["lowerY"].Float();
|
|
|
|
int i = 0;
|
|
|
|
BOOST_FOREACH (auto & angle, missile["frameAngles"].Vector())
|
|
|
|
{
|
|
|
|
cre->missleFrameAngles[i++] = angle.Float();
|
|
|
|
}
|
|
|
|
cre->advMapDef = graphics["map"].String();
|
|
|
|
cre->iconIndex = graphics["iconIndex"].Float();
|
|
|
|
|
2012-12-23 13:23:41 +03:00
|
|
|
loadCreatureJson(cre, node);
|
|
|
|
return cre;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & config)
|
|
|
|
{
|
|
|
|
creature->level = config["level"].Float();
|
|
|
|
creature->animDefName = config["graphics"]["animation"].String();
|
2012-11-13 14:52:23 +03:00
|
|
|
|
2012-12-23 13:23:41 +03:00
|
|
|
VLC->modh->identifiers.requestIdentifier(std::string("faction.") + config["faction"].String(), [=](si32 faction)
|
|
|
|
{
|
|
|
|
creature->faction = faction;
|
|
|
|
});
|
|
|
|
|
|
|
|
BOOST_FOREACH(const JsonNode &value, config["upgrades"].Vector())
|
|
|
|
{
|
|
|
|
VLC->modh->identifiers.requestIdentifier(std::string("creature.") + value.String(), [=](si32 identifier)
|
|
|
|
{
|
2013-02-11 02:24:57 +03:00
|
|
|
creature->upgrades.insert(CreatureID(identifier));
|
2012-12-23 13:23:41 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-02-07 20:34:50 +03:00
|
|
|
if(config["hasDoubleWeek"].Bool())
|
|
|
|
doubledCreatures.insert(creature->idNumber);
|
|
|
|
|
2012-12-23 13:23:41 +03:00
|
|
|
creature->projectile = config["graphics"]["missile"]["projectile"].String();
|
|
|
|
creature->projectileSpin = config["graphics"]["missile"]["spinning"].Bool();
|
|
|
|
|
|
|
|
creature->special = config["special"].Bool();
|
|
|
|
if ( creature->special )
|
|
|
|
notUsedMonsters.insert(creature->idNumber);
|
|
|
|
|
|
|
|
const JsonNode & sounds = config["sound"];
|
|
|
|
|
|
|
|
#define GET_SOUND_VALUE(value_name) creature->sounds.value_name = sounds[#value_name].String()
|
2012-11-13 14:52:23 +03:00
|
|
|
GET_SOUND_VALUE(attack);
|
|
|
|
GET_SOUND_VALUE(defend);
|
|
|
|
GET_SOUND_VALUE(killed);
|
|
|
|
GET_SOUND_VALUE(move);
|
|
|
|
GET_SOUND_VALUE(shoot);
|
|
|
|
GET_SOUND_VALUE(wince);
|
|
|
|
GET_SOUND_VALUE(ext1);
|
|
|
|
GET_SOUND_VALUE(ext2);
|
|
|
|
GET_SOUND_VALUE(startMoving);
|
|
|
|
GET_SOUND_VALUE(endMoving);
|
|
|
|
#undef GET_SOUND_VALUE
|
|
|
|
}
|
|
|
|
|
2012-08-25 11:44:51 +03:00
|
|
|
void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigParser & parser) //help function for parsing CREXPBON.txt
|
2011-02-13 21:46:16 +02:00
|
|
|
{
|
2011-02-11 10:20:26 +02:00
|
|
|
bool enable = false; //some bonuses are activated with values 2 or 1
|
2012-08-25 11:44:51 +03:00
|
|
|
std::string buf = parser.readString();
|
|
|
|
std::string mod = parser.readString();
|
2011-02-11 10:20:26 +02:00
|
|
|
|
2011-02-03 14:58:46 +02:00
|
|
|
switch (buf[0])
|
|
|
|
{
|
2011-02-06 10:32:05 +02:00
|
|
|
case 'H':
|
|
|
|
b.type = Bonus::STACK_HEALTH;
|
2011-02-11 10:20:26 +02:00
|
|
|
b.valType = Bonus::PERCENT_TO_BASE;
|
2011-02-06 10:32:05 +02:00
|
|
|
break;
|
|
|
|
case 'A':
|
|
|
|
b.type = Bonus::PRIMARY_SKILL;
|
|
|
|
b.subtype = PrimarySkill::ATTACK;
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
b.type = Bonus::PRIMARY_SKILL;
|
|
|
|
b.subtype = PrimarySkill::DEFENSE;
|
|
|
|
break;
|
|
|
|
case 'M': //Max damage
|
|
|
|
b.type = Bonus::CREATURE_DAMAGE;
|
|
|
|
b.subtype = 2;
|
|
|
|
break;
|
|
|
|
case 'm': //Min damage
|
|
|
|
b.type = Bonus::CREATURE_DAMAGE;
|
|
|
|
b.subtype = 1;
|
|
|
|
break;
|
2011-02-08 13:34:34 +02:00
|
|
|
case 'S':
|
2011-02-13 21:46:16 +02:00
|
|
|
b.type = Bonus::STACKS_SPEED; break;
|
2011-04-12 11:59:18 +03:00
|
|
|
case 'O':
|
|
|
|
b.type = Bonus::SHOTS; break;
|
2011-02-08 13:34:34 +02:00
|
|
|
case 'b':
|
|
|
|
b.type = Bonus::ENEMY_DEFENCE_REDUCTION; break;
|
|
|
|
case 'C':
|
|
|
|
b.type = Bonus::CHANGES_SPELL_COST_FOR_ALLY; break;
|
2011-07-16 19:40:38 +03:00
|
|
|
case 'd':
|
|
|
|
b.type = Bonus::DEFENSIVE_STANCE; break;
|
2011-02-08 13:34:34 +02:00
|
|
|
case 'e':
|
2012-09-26 22:02:44 +03:00
|
|
|
b.type = Bonus::DOUBLE_DAMAGE_CHANCE;
|
|
|
|
b.subtype = 0;
|
|
|
|
break;
|
2011-04-23 20:10:54 +03:00
|
|
|
case 'E':
|
|
|
|
b.type = Bonus::DEATH_STARE;
|
|
|
|
b.subtype = 0; //Gorgon
|
|
|
|
break;
|
2012-12-06 22:03:47 +03:00
|
|
|
case 'F':
|
|
|
|
b.type = Bonus::FEAR; break;
|
2011-02-08 13:34:34 +02:00
|
|
|
case 'g':
|
2011-03-08 09:40:14 +02:00
|
|
|
b.type = Bonus::SPELL_DAMAGE_REDUCTION;
|
|
|
|
b.subtype = -1; //all magic schools
|
|
|
|
break;
|
2011-05-15 09:37:57 +03:00
|
|
|
case 'P':
|
|
|
|
b.type = Bonus::CASTS; break;
|
2011-02-09 16:58:15 +02:00
|
|
|
case 'R':
|
|
|
|
b.type = Bonus::ADDITIONAL_RETALIATION; break;
|
2011-05-13 20:51:12 +03:00
|
|
|
case 'W':
|
|
|
|
b.type = Bonus::MAGIC_RESISTANCE;
|
2011-05-15 09:37:57 +03:00
|
|
|
b.subtype = 0; //otherwise creature window goes crazy
|
2011-05-13 20:51:12 +03:00
|
|
|
break;
|
2011-02-08 13:34:34 +02:00
|
|
|
case 'f': //on-off skill
|
2011-02-11 10:20:26 +02:00
|
|
|
enable = true; //sometimes format is: 2 -> 0, 1 -> 1
|
2011-02-08 13:34:34 +02:00
|
|
|
switch (mod[0])
|
|
|
|
{
|
|
|
|
case 'A':
|
|
|
|
b.type = Bonus::ATTACKS_ALL_ADJACENT; break;
|
|
|
|
case 'b':
|
|
|
|
b.type = Bonus::RETURN_AFTER_STRIKE; break;
|
|
|
|
case 'B':
|
|
|
|
b.type = Bonus::TWO_HEX_ATTACK_BREATH; break;
|
|
|
|
case 'c':
|
|
|
|
b.type = Bonus::JOUSTING; break;
|
|
|
|
case 'D':
|
|
|
|
b.type = Bonus::ADDITIONAL_ATTACK; break;
|
|
|
|
case 'f':
|
|
|
|
b.type = Bonus::FEARLESS; break;
|
|
|
|
case 'F':
|
|
|
|
b.type = Bonus::FLYING; break;
|
|
|
|
case 'm':
|
|
|
|
b.type = Bonus::SELF_MORALE; break;
|
|
|
|
case 'M':
|
|
|
|
b.type = Bonus::NO_MORALE; break;
|
|
|
|
case 'p': //Mind spells
|
|
|
|
case 'P':
|
2012-01-27 10:25:29 +03:00
|
|
|
b.type = Bonus::MIND_IMMUNITY; break;
|
2011-07-10 12:03:46 +03:00
|
|
|
case 'r':
|
|
|
|
b.type = Bonus::REBIRTH; //on/off? makes sense?
|
|
|
|
b.subtype = 0;
|
|
|
|
b.val = 20; //arbitrary value
|
2011-02-08 13:34:34 +02:00
|
|
|
break;
|
|
|
|
case 'R':
|
|
|
|
b.type = Bonus::BLOCKS_RETALIATION; break;
|
|
|
|
case 's':
|
|
|
|
b.type = Bonus::FREE_SHOOTING; break;
|
|
|
|
case 'u':
|
|
|
|
b.type = Bonus::SPELL_RESISTANCE_AURA; break;
|
|
|
|
case 'U':
|
|
|
|
b.type = Bonus::UNDEAD; break;
|
|
|
|
default:
|
2012-12-01 21:30:03 +03:00
|
|
|
tlog5 << "Not parsed bonus " << buf << mod << "\n";
|
2011-02-14 23:08:29 +02:00
|
|
|
return;
|
2011-02-08 13:34:34 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2011-02-09 16:58:15 +02:00
|
|
|
case 'w': //specific spell immunities, enabled/disabled
|
2011-02-11 10:20:26 +02:00
|
|
|
enable = true;
|
2011-02-09 16:58:15 +02:00
|
|
|
switch (mod[0])
|
|
|
|
{
|
|
|
|
case 'B': //Blind
|
|
|
|
b.type = Bonus::SPELL_IMMUNITY;
|
2013-02-24 01:48:22 +03:00
|
|
|
b.subtype = SpellID::BLIND;
|
2011-02-09 16:58:15 +02:00
|
|
|
break;
|
|
|
|
case 'H': //Hypnotize
|
|
|
|
b.type = Bonus::SPELL_IMMUNITY;
|
2013-02-24 01:48:22 +03:00
|
|
|
b.subtype = SpellID::HYPNOTIZE;
|
2011-02-09 16:58:15 +02:00
|
|
|
break;
|
|
|
|
case 'I': //Implosion
|
|
|
|
b.type = Bonus::SPELL_IMMUNITY;
|
2013-02-24 01:48:22 +03:00
|
|
|
b.subtype = SpellID::IMPLOSION;
|
2011-02-09 16:58:15 +02:00
|
|
|
break;
|
|
|
|
case 'K': //Berserk
|
|
|
|
b.type = Bonus::SPELL_IMMUNITY;
|
2013-02-24 01:48:22 +03:00
|
|
|
b.subtype = SpellID::BERSERK;
|
2011-02-09 16:58:15 +02:00
|
|
|
break;
|
|
|
|
case 'M': //Meteor Shower
|
|
|
|
b.type = Bonus::SPELL_IMMUNITY;
|
2013-02-24 01:48:22 +03:00
|
|
|
b.subtype = SpellID::METEOR_SHOWER;
|
2011-02-09 16:58:15 +02:00
|
|
|
break;
|
2011-05-28 08:34:40 +03:00
|
|
|
case 'N': //dispell beneficial spells
|
|
|
|
b.type = Bonus::SPELL_IMMUNITY;
|
2013-02-24 01:48:22 +03:00
|
|
|
b.subtype = SpellID::DISPEL_HELPFUL_SPELLS;
|
2011-05-28 08:34:40 +03:00
|
|
|
break;
|
2011-02-09 16:58:15 +02:00
|
|
|
case 'R': //Armageddon
|
|
|
|
b.type = Bonus::SPELL_IMMUNITY;
|
2013-02-24 01:48:22 +03:00
|
|
|
b.subtype = SpellID::ARMAGEDDON;
|
2011-02-09 16:58:15 +02:00
|
|
|
break;
|
|
|
|
case 'S': //Slow
|
|
|
|
b.type = Bonus::SPELL_IMMUNITY;
|
2013-02-24 01:48:22 +03:00
|
|
|
b.subtype = SpellID::SLOW;
|
2011-02-09 16:58:15 +02:00
|
|
|
break;
|
2011-02-13 21:46:16 +02:00
|
|
|
case '6':
|
2011-02-09 16:58:15 +02:00
|
|
|
case '7':
|
|
|
|
case '8':
|
|
|
|
case '9':
|
2011-05-21 10:07:07 +03:00
|
|
|
b.type = Bonus::LEVEL_SPELL_IMMUNITY;
|
2011-02-09 16:58:15 +02:00
|
|
|
b.val = std::atoi(mod.c_str()) - 5;
|
|
|
|
break;
|
|
|
|
case ':':
|
|
|
|
b.type = Bonus::LEVEL_SPELL_IMMUNITY;
|
2011-12-14 00:23:17 +03:00
|
|
|
b.val = GameConstants::SPELL_LEVELS; //in case someone adds higher level spells?
|
2011-02-09 16:58:15 +02:00
|
|
|
break;
|
2011-05-13 20:51:12 +03:00
|
|
|
case 'F':
|
|
|
|
b.type = Bonus::FIRE_IMMUNITY;
|
|
|
|
b.subtype = 1; //not positive
|
|
|
|
break;
|
|
|
|
case 'O':
|
|
|
|
b.type = Bonus::FIRE_IMMUNITY;
|
|
|
|
b.subtype = 2; //only direct damage
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
b.type = Bonus::FIRE_IMMUNITY;
|
|
|
|
b.subtype = 0; //all
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
b.type = Bonus::WATER_IMMUNITY;
|
|
|
|
b.subtype = 1; //not positive
|
|
|
|
break;
|
|
|
|
case 'W':
|
|
|
|
b.type = Bonus::WATER_IMMUNITY;
|
|
|
|
b.subtype = 2; //only direct damage
|
|
|
|
break;
|
|
|
|
case 'w':
|
|
|
|
b.type = Bonus::WATER_IMMUNITY;
|
|
|
|
b.subtype = 0; //all
|
|
|
|
break;
|
|
|
|
case 'E':
|
|
|
|
b.type = Bonus::EARTH_IMMUNITY;
|
|
|
|
b.subtype = 2; //only direct damage
|
|
|
|
break;
|
|
|
|
case 'e':
|
|
|
|
b.type = Bonus::EARTH_IMMUNITY;
|
|
|
|
b.subtype = 0; //all
|
|
|
|
break;
|
|
|
|
case 'A':
|
|
|
|
b.type = Bonus::AIR_IMMUNITY;
|
|
|
|
b.subtype = 2; //only direct damage
|
|
|
|
break;
|
|
|
|
case 'a':
|
|
|
|
b.type = Bonus::AIR_IMMUNITY;
|
|
|
|
b.subtype = 0; //all
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
b.type = Bonus::DIRECT_DAMAGE_IMMUNITY;
|
|
|
|
break;
|
|
|
|
case '0':
|
|
|
|
b.type = Bonus::RECEPTIVE;
|
|
|
|
break;
|
2013-02-25 15:18:45 +03:00
|
|
|
case 'm':
|
|
|
|
b.type = Bonus::MIND_IMMUNITY;
|
|
|
|
break;
|
2011-02-09 16:58:15 +02:00
|
|
|
default:
|
2011-11-25 22:41:23 +03:00
|
|
|
tlog5 << "Not parsed bonus " << buf << mod << "\n";
|
2011-02-14 23:08:29 +02:00
|
|
|
return;
|
2011-02-09 16:58:15 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-02-08 13:34:34 +02:00
|
|
|
case 'i':
|
2011-02-11 10:20:26 +02:00
|
|
|
enable = true;
|
2011-02-08 13:34:34 +02:00
|
|
|
b.type = Bonus::NO_DISTANCE_PENALTY;
|
|
|
|
break;
|
|
|
|
case 'o':
|
2011-02-11 10:20:26 +02:00
|
|
|
enable = true;
|
2011-10-20 20:41:40 +03:00
|
|
|
b.type = Bonus::NO_WALL_PENALTY;
|
2011-02-08 13:34:34 +02:00
|
|
|
break;
|
2011-02-09 16:58:15 +02:00
|
|
|
|
|
|
|
case 'a':
|
2012-12-06 22:03:47 +03:00
|
|
|
case 'c':
|
|
|
|
case 'K':
|
|
|
|
case 'k':
|
2011-02-09 16:58:15 +02:00
|
|
|
b.type = Bonus::SPELL_AFTER_ATTACK;
|
2013-02-13 22:35:43 +03:00
|
|
|
b.subtype = stringToNumber(mod);
|
2011-02-09 16:58:15 +02:00
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
b.type= Bonus::HATE;
|
|
|
|
b.subtype = stringToNumber(mod);
|
|
|
|
break;
|
2011-07-16 09:42:44 +03:00
|
|
|
case 'p':
|
2012-12-06 22:03:47 +03:00
|
|
|
case 'J':
|
2011-07-16 09:42:44 +03:00
|
|
|
b.type = Bonus::SPELL_BEFORE_ATTACK;
|
|
|
|
b.subtype = stringToNumber(mod);
|
|
|
|
b.additionalInfo = 3; //always expert?
|
|
|
|
break;
|
2012-12-06 22:03:47 +03:00
|
|
|
case 'r':
|
|
|
|
b.type = Bonus::HP_REGENERATION;
|
|
|
|
b.val = stringToNumber(mod);
|
|
|
|
break;
|
2012-12-01 21:30:03 +03:00
|
|
|
case 's':
|
|
|
|
b.type = Bonus::ENCHANTED;
|
|
|
|
b.subtype = stringToNumber(mod);
|
|
|
|
b.valType = Bonus::INDEPENDENT_MAX;
|
|
|
|
break;
|
2011-02-08 13:34:34 +02:00
|
|
|
default:
|
2011-11-25 22:41:23 +03:00
|
|
|
tlog5 << "Not parsed bonus " << buf << mod << "\n";
|
2011-02-14 23:08:29 +02:00
|
|
|
return;
|
2011-02-08 13:34:34 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (mod[0])
|
|
|
|
{
|
|
|
|
case '+':
|
|
|
|
case '=': //should we allow percent values to stack or pick highest?
|
2011-02-11 10:20:26 +02:00
|
|
|
b.valType = Bonus::ADDITIVE_VALUE;
|
2011-02-08 13:34:34 +02:00
|
|
|
break;
|
2011-02-03 14:58:46 +02:00
|
|
|
}
|
2011-02-11 10:20:26 +02:00
|
|
|
|
|
|
|
//limiters, range
|
|
|
|
si32 lastVal, curVal, lastLev = 0;
|
|
|
|
|
|
|
|
if (enable) //0 and 2 means non-active, 1 - active
|
2011-02-03 14:58:46 +02:00
|
|
|
{
|
2011-07-10 12:03:46 +03:00
|
|
|
if (b.type != Bonus::REBIRTH)
|
|
|
|
b.val = 0; //on-off ability, no value specified
|
2012-08-25 11:44:51 +03:00
|
|
|
curVal = parser.readNumber();// 0 level is never active
|
2011-02-11 10:20:26 +02:00
|
|
|
for (int i = 1; i < 11; ++i)
|
|
|
|
{
|
2012-08-25 11:44:51 +03:00
|
|
|
curVal = parser.readNumber();
|
2011-02-11 10:20:26 +02:00
|
|
|
if (curVal == 1)
|
|
|
|
{
|
2011-02-12 18:12:48 +02:00
|
|
|
b.limiter.reset (new RankRangeLimiter(i));
|
2011-02-11 10:20:26 +02:00
|
|
|
bl.push_back(new Bonus(b));
|
|
|
|
break; //never turned off it seems
|
|
|
|
}
|
|
|
|
}
|
2011-02-03 14:58:46 +02:00
|
|
|
}
|
2011-02-11 10:20:26 +02:00
|
|
|
else
|
2011-02-08 13:34:34 +02:00
|
|
|
{
|
2012-08-25 11:44:51 +03:00
|
|
|
lastVal = parser.readNumber(); //basic value, not particularly useful but existent
|
2011-02-11 10:20:26 +02:00
|
|
|
for (int i = 1; i < 11; ++i)
|
2011-02-08 13:34:34 +02:00
|
|
|
{
|
2012-08-25 11:44:51 +03:00
|
|
|
curVal = parser.readNumber();
|
2011-03-06 14:12:22 +02:00
|
|
|
if (b.type == Bonus::HATE)
|
|
|
|
curVal *= 10; //odd fix
|
2011-02-13 15:16:41 +02:00
|
|
|
if (curVal > lastVal) //threshold, add new bonus
|
2011-02-11 10:20:26 +02:00
|
|
|
{
|
2011-02-13 15:16:41 +02:00
|
|
|
b.val = curVal - lastVal;
|
|
|
|
lastVal = curVal;
|
2011-02-12 18:12:48 +02:00
|
|
|
b.limiter.reset (new RankRangeLimiter(i));
|
2011-02-11 10:20:26 +02:00
|
|
|
bl.push_back(new Bonus(b));
|
|
|
|
lastLev = i; //start new range from here, i = previous rank
|
|
|
|
}
|
|
|
|
else if (curVal < lastVal)
|
|
|
|
{
|
|
|
|
b.val = lastVal;
|
|
|
|
b.limiter.reset (new RankRangeLimiter(lastLev, i));
|
|
|
|
}
|
2011-02-08 13:34:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-09 16:58:15 +02:00
|
|
|
int CCreatureHandler::stringToNumber(std::string & s)
|
|
|
|
{
|
|
|
|
boost::algorithm::replace_first(s,"#",""); //drop hash character
|
|
|
|
return std::atoi(s.c_str());
|
|
|
|
}
|
|
|
|
|
2009-01-11 00:08:18 +02:00
|
|
|
CCreatureHandler::~CCreatureHandler()
|
|
|
|
{
|
2009-05-24 01:57:39 +03:00
|
|
|
}
|
2010-07-24 00:05:49 +03:00
|
|
|
|
2013-02-11 02:24:57 +03:00
|
|
|
CreatureID CCreatureHandler::pickRandomMonster(const boost::function<int()> &randGen, int tier) const
|
2010-07-24 00:05:49 +03:00
|
|
|
{
|
|
|
|
int r = 0;
|
2011-02-10 15:12:53 +02:00
|
|
|
if(tier == -1) //pick any allowed creature
|
2010-07-24 00:05:49 +03:00
|
|
|
{
|
2013-02-13 22:35:43 +03:00
|
|
|
do
|
2011-02-10 15:12:53 +02:00
|
|
|
{
|
2013-02-04 15:32:53 +03:00
|
|
|
r = vstd::pickRandomElementOf(creatures, randGen)->idNumber;
|
2011-02-10 15:12:53 +02:00
|
|
|
} while (vstd::contains(VLC->creh->notUsedMonsters,r));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
assert(vstd::iswithin(tier, 1, 7));
|
2013-02-11 02:24:57 +03:00
|
|
|
std::vector<CreatureID> allowed;
|
2011-07-13 21:39:02 +03:00
|
|
|
BOOST_FOREACH(const CBonusSystemNode *b, creaturesOfLevel[tier].getChildrenNodes())
|
2011-02-10 15:12:53 +02:00
|
|
|
{
|
2011-07-13 21:39:02 +03:00
|
|
|
assert(b->getNodeType() == CBonusSystemNode::CREATURE);
|
2013-02-11 02:24:57 +03:00
|
|
|
CreatureID creid = static_cast<const CCreature*>(b)->idNumber;
|
2011-02-10 15:12:53 +02:00
|
|
|
if(!vstd::contains(notUsedMonsters, creid))
|
|
|
|
allowed.push_back(creid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!allowed.size())
|
|
|
|
{
|
|
|
|
tlog2 << "Cannot pick a random creature of tier " << tier << "!\n";
|
2013-02-07 20:34:50 +03:00
|
|
|
return CreatureID::NONE;
|
2011-02-10 15:12:53 +02:00
|
|
|
}
|
2010-07-24 00:05:49 +03:00
|
|
|
|
2013-02-04 15:32:53 +03:00
|
|
|
return vstd::pickRandomElementOf(allowed, randGen);
|
2011-02-10 15:12:53 +02:00
|
|
|
}
|
2013-02-11 02:24:57 +03:00
|
|
|
return CreatureID(r);
|
2011-02-10 15:12:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCreatureHandler::addBonusForTier(int tier, Bonus *b)
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
assert(vstd::iswithin(tier, 1, 7));
|
2011-02-10 15:12:53 +02:00
|
|
|
creaturesOfLevel[tier].addNewBonus(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCreatureHandler::addBonusForAllCreatures(Bonus *b)
|
|
|
|
{
|
|
|
|
allCreatures.addNewBonus(b);
|
2011-02-22 11:47:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCreatureHandler::buildBonusTreeForTiers()
|
|
|
|
{
|
|
|
|
BOOST_FOREACH(CCreature *c, creatures)
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if(vstd::isbetween(c->level, 0, ARRAY_COUNT(creaturesOfLevel)))
|
2011-02-22 11:47:25 +02:00
|
|
|
c->attachTo(&creaturesOfLevel[c->level]);
|
|
|
|
else
|
|
|
|
c->attachTo(&creaturesOfLevel[0]);
|
|
|
|
}
|
|
|
|
BOOST_FOREACH(CBonusSystemNode &b, creaturesOfLevel)
|
|
|
|
b.attachTo(&allCreatures);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCreatureHandler::deserializationFix()
|
|
|
|
{
|
|
|
|
buildBonusTreeForTiers();
|
2011-05-04 05:38:58 +03:00
|
|
|
}
|