2017-07-13 10:26:03 +02: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
|
|
|
|
*
|
|
|
|
*/
|
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"
|
2013-07-28 17:49:50 +03:00
|
|
|
#include "filesystem/Filesystem.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"
|
2013-04-11 22:24:14 +03:00
|
|
|
#include "StringConstants.h"
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
#include "serializer/JsonDeserializer.h"
|
|
|
|
#include "serializer/JsonUpdater.h"
|
2014-06-05 19:52:14 +03:00
|
|
|
#include "mapObjects/CObjectClassesHandler.h"
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
int32_t CCreature::getIndex() const
|
|
|
|
{
|
|
|
|
return idNumber.toEnum();
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getIconIndex() const
|
|
|
|
{
|
|
|
|
return iconIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & CCreature::getName() const
|
|
|
|
{
|
|
|
|
return nameSing;//???
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & CCreature::getJsonKey() const
|
|
|
|
{
|
|
|
|
return identifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCreature::registerIcons(const IconRegistar & cb) const
|
|
|
|
{
|
|
|
|
cb(getIconIndex(), "CPRSMALL", smallIconName);
|
|
|
|
cb(getIconIndex(), "TWCRPORT", largeIconName);
|
|
|
|
}
|
|
|
|
|
|
|
|
CreatureID CCreature::getId() const
|
|
|
|
{
|
|
|
|
return idNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
const IBonusBearer * CCreature::accessBonuses() const
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t CCreature::getMaxHealth() const
|
|
|
|
{
|
|
|
|
return CBonusSystemNode::MaxHealth();
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & CCreature::getPluralName() const
|
|
|
|
{
|
|
|
|
return namePl;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string & CCreature::getSingularName() const
|
|
|
|
{
|
|
|
|
return nameSing;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getAdvMapAmountMin() const
|
|
|
|
{
|
|
|
|
return ammMin;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getAdvMapAmountMax() const
|
|
|
|
{
|
|
|
|
return ammMax;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getAIValue() const
|
|
|
|
{
|
|
|
|
return AIValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getFightValue() const
|
|
|
|
{
|
|
|
|
return fightValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getLevel() const
|
|
|
|
{
|
|
|
|
return level;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getGrowth() const
|
|
|
|
{
|
|
|
|
return growth;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getHorde() const
|
|
|
|
{
|
|
|
|
return hordeGrowth;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getFactionIndex() const
|
|
|
|
{
|
|
|
|
return faction;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getBaseAttack() const
|
|
|
|
{
|
|
|
|
static const auto SELECTOR = Selector::typeSubtype(Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK).And(Selector::sourceTypeSel(Bonus::CREATURE_ABILITY));
|
|
|
|
return getExportedBonusList().valOfBonuses(SELECTOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getBaseDefense() const
|
|
|
|
{
|
|
|
|
static const auto SELECTOR = Selector::typeSubtype(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE).And(Selector::sourceTypeSel(Bonus::CREATURE_ABILITY));
|
|
|
|
return getExportedBonusList().valOfBonuses(SELECTOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getBaseDamageMin() const
|
|
|
|
{
|
|
|
|
static const auto SELECTOR = Selector::typeSubtype(Bonus::CREATURE_DAMAGE, 1).And(Selector::sourceTypeSel(Bonus::CREATURE_ABILITY));
|
|
|
|
return getExportedBonusList().valOfBonuses(SELECTOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getBaseDamageMax() const
|
|
|
|
{
|
|
|
|
static const auto SELECTOR = Selector::typeSubtype(Bonus::CREATURE_DAMAGE, 2).And(Selector::sourceTypeSel(Bonus::CREATURE_ABILITY));
|
|
|
|
return getExportedBonusList().valOfBonuses(SELECTOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getBaseHitPoints() const
|
|
|
|
{
|
|
|
|
static const auto SELECTOR = Selector::type()(Bonus::STACK_HEALTH).And(Selector::sourceTypeSel(Bonus::CREATURE_ABILITY));
|
|
|
|
return getExportedBonusList().valOfBonuses(SELECTOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getBaseSpellPoints() const
|
|
|
|
{
|
|
|
|
static const auto SELECTOR = Selector::type()(Bonus::CASTS).And(Selector::sourceTypeSel(Bonus::CREATURE_ABILITY));
|
|
|
|
return getExportedBonusList().valOfBonuses(SELECTOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getBaseSpeed() const
|
|
|
|
{
|
|
|
|
static const auto SELECTOR = Selector::type()(Bonus::STACKS_SPEED).And(Selector::sourceTypeSel(Bonus::CREATURE_ABILITY));
|
|
|
|
return getExportedBonusList().valOfBonuses(SELECTOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getBaseShots() const
|
|
|
|
{
|
|
|
|
static const auto SELECTOR = Selector::type()(Bonus::SHOTS).And(Selector::sourceTypeSel(Bonus::CREATURE_ABILITY));
|
|
|
|
return getExportedBonusList().valOfBonuses(SELECTOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CCreature::getCost(int32_t resIndex) const
|
|
|
|
{
|
|
|
|
if(resIndex >= 0 && resIndex < cost.size())
|
|
|
|
return cost[resIndex];
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2016-11-24 19:34:37 +02:00
|
|
|
if(countID > 9)
|
|
|
|
{
|
|
|
|
logGlobal->error("Wrong countID %d!", countID);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
return (*VLC->townh)[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
|
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
return (*VLC->townh)[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;
|
2020-10-01 10:38:06 +02:00
|
|
|
int resAmnt = static_cast<int>(std::min(res.size(),cost.size()));
|
2008-05-12 08:46:04 +03:00
|
|
|
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()
|
|
|
|
{
|
2011-07-13 21:39:02 +03:00
|
|
|
setNodeType(CBonusSystemNode::CREATURE);
|
2016-11-27 21:07:01 +02:00
|
|
|
faction = 0;
|
|
|
|
level = 0;
|
|
|
|
fightValue = AIValue = growth = hordeGrowth = ammMin = ammMax = 0;
|
|
|
|
doubleWide = false;
|
|
|
|
special = true;
|
|
|
|
iconIndex = -1;
|
2010-05-02 21:20:26 +03:00
|
|
|
}
|
2016-11-27 21:07:01 +02:00
|
|
|
|
2017-07-15 13:08:20 +02:00
|
|
|
void CCreature::addBonus(int val, Bonus::BonusType type, int subtype)
|
2010-05-02 21:20:26 +03:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
auto selector = Selector::typeSubtype(type, subtype).And(Selector::source(Bonus::CREATURE_ABILITY, getIndex()));
|
|
|
|
BonusList & exported = getExportedBonusList();
|
|
|
|
|
|
|
|
BonusList existing;
|
|
|
|
exported.getBonuses(existing, selector, Selector::all);
|
|
|
|
|
|
|
|
if(existing.empty())
|
|
|
|
{
|
|
|
|
auto added = std::make_shared<Bonus>(Bonus::PERMANENT, type, Bonus::CREATURE_ABILITY, val, getIndex(), subtype, Bonus::BASE_NUMBER);
|
|
|
|
addNewBonus(added);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::shared_ptr<Bonus> b = existing[0];
|
|
|
|
b->val = val;
|
|
|
|
}
|
2010-05-02 21:20:26 +03:00
|
|
|
}
|
2013-03-06 21:49:56 +03:00
|
|
|
|
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
|
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
return this == VLC->creh->objects[idNumber];
|
2010-11-27 22:17:28 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-12-10 03:05:37 +02:00
|
|
|
bool CCreature::isItNativeTerrain(ETerrainType::EETerrainType terrain) const
|
2012-05-18 23:50:16 +03:00
|
|
|
{
|
2020-12-10 03:05:37 +02:00
|
|
|
auto native = getNativeTerrain();
|
|
|
|
return native == terrain || native == ETerrainType::ANY_TERRAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
ETerrainType::EETerrainType CCreature::getNativeTerrain() const
|
|
|
|
{
|
2022-05-15 10:39:06 +02:00
|
|
|
const std::string cachingStringBlocksRetaliation = "type_NO_TERRAIN_PENALTY";
|
|
|
|
static const auto selectorBlocksRetaliation = Selector::type()(Bonus::NO_TERRAIN_PENALTY);
|
|
|
|
|
2020-12-10 03:05:37 +02:00
|
|
|
//this code is used in the CreatureTerrainLimiter::limit to setup battle bonuses
|
|
|
|
//and in the CGHeroInstance::getNativeTerrain() to setup mevement bonuses or/and penalties.
|
2022-05-15 10:39:06 +02:00
|
|
|
return hasBonus(selectorBlocksRetaliation, selectorBlocksRetaliation)
|
|
|
|
? ETerrainType::ANY_TERRAIN
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
: (ETerrainType::EETerrainType)(*VLC->townh)[faction]->nativeTerrain;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCreature::updateFrom(const JsonNode & data)
|
|
|
|
{
|
|
|
|
JsonUpdater handler(nullptr, data);
|
|
|
|
|
|
|
|
{
|
|
|
|
auto configScope = handler.enterStruct("config");
|
|
|
|
|
|
|
|
const JsonNode & configNode = handler.getCurrent();
|
|
|
|
|
|
|
|
serializeJson(handler);
|
|
|
|
|
|
|
|
if(!configNode["hitPoints"].isNull())
|
|
|
|
addBonus(configNode["hitPoints"].Integer(), Bonus::STACK_HEALTH);
|
|
|
|
|
|
|
|
if(!configNode["speed"].isNull())
|
|
|
|
addBonus(configNode["speed"].Integer(), Bonus::STACKS_SPEED);
|
|
|
|
|
|
|
|
if(!configNode["attack"].isNull())
|
|
|
|
addBonus(configNode["attack"].Integer(), Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK);
|
|
|
|
|
|
|
|
if(!configNode["defense"].isNull())
|
|
|
|
addBonus(configNode["defense"].Integer(), Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE);
|
|
|
|
|
|
|
|
if(!configNode["damage"]["min"].isNull())
|
|
|
|
addBonus(configNode["damage"]["min"].Integer(), Bonus::CREATURE_DAMAGE, 1);
|
|
|
|
|
|
|
|
if(!configNode["damage"]["max"].isNull())
|
|
|
|
addBonus(configNode["damage"]["max"].Integer(), Bonus::CREATURE_DAMAGE, 2);
|
|
|
|
|
|
|
|
if(!configNode["shots"].isNull())
|
|
|
|
addBonus(configNode["shots"].Integer(), Bonus::SHOTS);
|
|
|
|
|
|
|
|
if(!configNode["spellPoints"].isNull())
|
|
|
|
addBonus(configNode["spellPoints"].Integer(), Bonus::CASTS);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handler.serializeBonuses("bonuses", this);
|
2009-06-28 16:49:39 +03:00
|
|
|
}
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
void CCreature::serializeJson(JsonSerializeFormat & handler)
|
2013-05-19 22:53:03 +03:00
|
|
|
{
|
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
auto nameNode = handler.enterStruct("name");
|
|
|
|
handler.serializeString("singular", nameSing);
|
|
|
|
handler.serializeString("plural", namePl);
|
|
|
|
}
|
|
|
|
|
|
|
|
handler.serializeInt("fightValue", fightValue);
|
|
|
|
handler.serializeInt("aiValue", AIValue);
|
|
|
|
handler.serializeInt("growth", growth);
|
|
|
|
handler.serializeInt("horde", hordeGrowth);// Needed at least until configurable buildings
|
|
|
|
|
|
|
|
{
|
|
|
|
auto advMapNode = handler.enterStruct("advMapAmount");
|
|
|
|
handler.serializeInt("min", ammMin);
|
|
|
|
handler.serializeInt("max", ammMax);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(handler.updating)
|
|
|
|
{
|
|
|
|
cost.serializeJson(handler, "cost");
|
|
|
|
handler.serializeInt("faction", faction);//TODO: unify with deferred resolve
|
|
|
|
}
|
|
|
|
|
|
|
|
handler.serializeInt("level", level);
|
|
|
|
handler.serializeBool("doubleWide", doubleWide);
|
|
|
|
|
|
|
|
if(!handler.saving)
|
|
|
|
{
|
|
|
|
if(ammMin > ammMax)
|
|
|
|
logMod->error("Invalid creature '%s' configuration, advMapAmount.min > advMapAmount.max", identifier);
|
2013-05-19 22:53:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-26 18:51:45 +02:00
|
|
|
void CCreature::fillWarMachine()
|
|
|
|
{
|
|
|
|
switch (idNumber)
|
|
|
|
{
|
|
|
|
case CreatureID::CATAPULT: //Catapult
|
|
|
|
warMachine = ArtifactID::CATAPULT;
|
|
|
|
break;
|
|
|
|
case CreatureID::BALLISTA: //Ballista
|
|
|
|
warMachine = ArtifactID::BALLISTA;
|
|
|
|
break;
|
|
|
|
case CreatureID::FIRST_AID_TENT: //First Aid tent
|
|
|
|
warMachine = ArtifactID::FIRST_AID_TENT;
|
|
|
|
break;
|
|
|
|
case CreatureID::AMMO_CART: //Ammo cart
|
|
|
|
warMachine = ArtifactID::AMMO_CART;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
warMachine = ArtifactID::NONE; //this creature is not artifact
|
|
|
|
}
|
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
CCreatureHandler::CCreatureHandler()
|
2016-08-18 23:13:12 +02:00
|
|
|
: expAfterUpgrade(0)
|
2011-09-01 06:39:53 +03:00
|
|
|
{
|
2013-04-11 22:24:14 +03:00
|
|
|
VLC->creh = this;
|
2011-09-01 06:39:53 +03:00
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
allCreatures.setDescription("All creatures");
|
2020-12-10 03:05:37 +02:00
|
|
|
allCreatures.setNodeType(CBonusSystemNode::ENodeTypes::ALL_CREATURES);
|
2013-04-11 22:24:14 +03:00
|
|
|
creaturesOfLevel[0].setDescription("Creatures of unnormalized tier");
|
2020-12-10 03:05:37 +02:00
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
for(int i = 1; i < ARRAY_COUNT(creaturesOfLevel); i++)
|
|
|
|
creaturesOfLevel[i].setDescription("Creatures of tier " + boost::lexical_cast<std::string>(i));
|
|
|
|
loadCommanders();
|
|
|
|
}
|
2011-09-01 06:39:53 +03:00
|
|
|
|
2016-01-15 19:24:17 +02:00
|
|
|
const CCreature * CCreatureHandler::getCreature(const std::string & scope, const std::string & identifier) const
|
|
|
|
{
|
|
|
|
boost::optional<si32> index = VLC->modh->identifiers.getIdentifier(scope, "creature", identifier);
|
|
|
|
|
|
|
|
if(!index)
|
|
|
|
throw std::runtime_error("Creature not found "+identifier);
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
return objects[*index];
|
2016-01-15 19:24:17 +02:00
|
|
|
}
|
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
void CCreatureHandler::loadCommanders()
|
|
|
|
{
|
2013-04-25 17:03:35 +03:00
|
|
|
JsonNode data(ResourceID("config/commanders.json"));
|
|
|
|
data.setMeta("core"); // assume that commanders are in core mod (for proper bonuses resolution)
|
|
|
|
|
|
|
|
const JsonNode & config = data; // switch to const data accessors
|
2011-09-01 06:39:53 +03:00
|
|
|
|
2013-06-29 16:05:48 +03:00
|
|
|
for (auto bonus : config["bonusPerLevel"].Vector())
|
2013-04-11 22:24:14 +03:00
|
|
|
{
|
2016-09-19 23:36:35 +02:00
|
|
|
commanderLevelPremy.push_back(JsonUtils::parseBonus(bonus.Vector()));
|
2013-04-11 22:24:14 +03:00
|
|
|
}
|
2011-09-01 06:39:53 +03:00
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
int i = 0;
|
2013-06-29 16:05:48 +03:00
|
|
|
for (auto skill : config["skillLevels"].Vector())
|
2013-04-11 22:24:14 +03:00
|
|
|
{
|
|
|
|
skillLevels.push_back (std::vector<ui8>());
|
2013-06-29 16:05:48 +03:00
|
|
|
for (auto skillLevel : skill["levels"].Vector())
|
2013-04-11 22:24:14 +03:00
|
|
|
{
|
2020-10-01 10:38:06 +02:00
|
|
|
skillLevels[i].push_back ((ui8)skillLevel.Float());
|
2013-04-11 22:24:14 +03:00
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
2011-09-01 06:39:53 +03:00
|
|
|
|
2013-06-29 16:05:48 +03:00
|
|
|
for (auto ability : config["abilityRequirements"].Vector())
|
2013-04-11 22:24:14 +03:00
|
|
|
{
|
2016-09-19 23:36:35 +02:00
|
|
|
std::pair <std::shared_ptr<Bonus>, std::pair <ui8, ui8> > a;
|
2013-06-17 18:45:55 +03:00
|
|
|
a.first = JsonUtils::parseBonus (ability["ability"].Vector());
|
2020-10-01 10:38:06 +02:00
|
|
|
a.second.first = static_cast<ui8>(ability["skills"].Vector()[0].Float());
|
|
|
|
a.second.second = static_cast<ui8>(ability["skills"].Vector()[1].Float());
|
2013-04-11 22:24:14 +03:00
|
|
|
skillRequirements.push_back (a);
|
|
|
|
}
|
2011-09-01 06:39:53 +03:00
|
|
|
}
|
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
void CCreatureHandler::loadBonuses(JsonNode & creature, std::string bonuses)
|
2013-03-02 19:55:51 +03:00
|
|
|
{
|
2013-04-11 22:24:14 +03:00
|
|
|
auto makeBonusNode = [&](std::string type) -> JsonNode
|
|
|
|
{
|
|
|
|
JsonNode ret;
|
|
|
|
ret["type"].String() = type;
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const std::map<std::string, JsonNode> abilityMap =
|
2014-10-02 18:43:46 +03:00
|
|
|
{
|
2016-03-12 03:41:27 +02:00
|
|
|
{"FLYING_ARMY", makeBonusNode("FLYING")},
|
|
|
|
{"SHOOTING_ARMY", makeBonusNode("SHOOTER")},
|
|
|
|
{"SIEGE_WEAPON", makeBonusNode("SIEGE_WEAPON")},
|
|
|
|
{"const_free_attack", makeBonusNode("BLOCKS_RETALIATION")},
|
|
|
|
{"IS_UNDEAD", makeBonusNode("UNDEAD")},
|
|
|
|
{"const_no_melee_penalty", makeBonusNode("NO_MELEE_PENALTY")},
|
|
|
|
{"const_jousting", makeBonusNode("JOUSTING")},
|
|
|
|
{"KING_1", makeBonusNode("KING1")},
|
|
|
|
{"KING_2", makeBonusNode("KING2")},
|
2014-10-02 18:43:46 +03:00
|
|
|
{"KING_3", makeBonusNode("KING3")},
|
|
|
|
{"const_no_wall_penalty", makeBonusNode("NO_WALL_PENALTY")},
|
|
|
|
{"CATAPULT", makeBonusNode("CATAPULT")},
|
|
|
|
{"MULTI_HEADED", makeBonusNode("ATTACKS_ALL_ADJACENT")},
|
|
|
|
{"IMMUNE_TO_MIND_SPELLS", makeBonusNode("MIND_IMMUNITY")},
|
|
|
|
{"HAS_EXTENDED_ATTACK", makeBonusNode("TWO_HEX_ATTACK_BREATH")}
|
|
|
|
};
|
2013-03-02 19:55:51 +03:00
|
|
|
|
|
|
|
auto hasAbility = [&](const std::string name) -> bool
|
|
|
|
{
|
|
|
|
return boost::algorithm::find_first(bonuses, name);
|
|
|
|
};
|
2013-04-11 22:24:14 +03:00
|
|
|
|
2013-06-29 16:05:48 +03:00
|
|
|
for(auto a : abilityMap)
|
2013-03-02 19:55:51 +03:00
|
|
|
{
|
|
|
|
if(hasAbility(a.first))
|
2013-04-11 22:24:14 +03:00
|
|
|
creature["abilities"][a.first] = a.second;
|
2013-03-02 19:55:51 +03:00
|
|
|
}
|
|
|
|
if(hasAbility("DOUBLE_WIDE"))
|
2013-04-11 22:24:14 +03:00
|
|
|
creature["doubleWide"].Bool() = true;
|
|
|
|
|
2013-03-02 19:55:51 +03:00
|
|
|
if(hasAbility("const_raises_morale"))
|
|
|
|
{
|
2013-04-11 22:24:14 +03:00
|
|
|
JsonNode node = makeBonusNode("MORALE");
|
|
|
|
node["val"].Float() = 1;
|
|
|
|
node["propagator"].String() = "HERO";
|
|
|
|
creature["abilities"]["const_raises_morale"] = node;
|
2013-03-02 19:55:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-21 15:49:26 +03:00
|
|
|
std::vector<JsonNode> CCreatureHandler::loadLegacyData(size_t dataSize)
|
2011-09-01 06:39:53 +03:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
objects.resize(dataSize);
|
2013-04-11 22:24:14 +03:00
|
|
|
std::vector<JsonNode> h3Data;
|
2013-04-21 15:49:26 +03:00
|
|
|
h3Data.reserve(dataSize);
|
2009-06-28 16:49:39 +03:00
|
|
|
|
2013-05-04 16:14:23 +03:00
|
|
|
CLegacyConfigParser parser("DATA/CRTRAITS.TXT");
|
2012-09-26 16:13:39 +03:00
|
|
|
|
|
|
|
parser.endLine(); // header
|
2013-06-23 22:35:54 +03:00
|
|
|
|
|
|
|
// this file is a bit different in some of Russian localisations:
|
|
|
|
//ENG: Singular Plural Wood ...
|
|
|
|
//RUS: Singular Plural Plural2 Wood ...
|
|
|
|
// Try to detect which version this is by header
|
|
|
|
// TODO: use 3rd name? Stand for "whose", e.g. pikemans'
|
|
|
|
size_t namesCount;
|
|
|
|
{
|
|
|
|
if ( parser.readString() != "Singular" || parser.readString() != "Plural" )
|
|
|
|
throw std::runtime_error("Incorrect format of CrTraits.txt");
|
|
|
|
|
|
|
|
if (parser.readString() == "Plural2")
|
|
|
|
namesCount = 3;
|
|
|
|
else
|
|
|
|
namesCount = 2;
|
|
|
|
|
|
|
|
parser.endLine();
|
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
|
2013-04-21 15:49:26 +03:00
|
|
|
for (size_t i=0; i<dataSize; i++)
|
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();
|
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
JsonNode data;
|
|
|
|
|
|
|
|
data["name"]["singular"].String() = parser.readString();
|
2013-06-23 22:35:54 +03:00
|
|
|
|
|
|
|
if (namesCount == 3)
|
|
|
|
parser.readString();
|
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
data["name"]["plural"].String() = 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)
|
2013-04-11 22:24:14 +03:00
|
|
|
data["cost"][GameConstants::RESOURCE_NAMES[v]].Float() = parser.readNumber();
|
|
|
|
|
|
|
|
data["fightValue"].Float() = parser.readNumber();
|
|
|
|
data["aiValue"].Float() = parser.readNumber();
|
|
|
|
data["growth"].Float() = parser.readNumber();
|
|
|
|
data["horde"].Float() = parser.readNumber();
|
|
|
|
|
|
|
|
data["hitPoints"].Float() = parser.readNumber();
|
|
|
|
data["speed"].Float() = parser.readNumber();
|
|
|
|
data["attack"].Float() = parser.readNumber();
|
|
|
|
data["defense"].Float() = parser.readNumber();
|
|
|
|
data["damage"]["min"].Float() = parser.readNumber();
|
|
|
|
data["damage"]["max"].Float() = parser.readNumber();
|
|
|
|
|
|
|
|
if (float shots = parser.readNumber())
|
|
|
|
data["shots"].Float() = shots;
|
|
|
|
|
|
|
|
if (float spells = parser.readNumber())
|
|
|
|
data["spellPoints"].Float() = spells;
|
|
|
|
|
|
|
|
data["advMapAmount"]["min"].Float() = parser.readNumber();
|
|
|
|
data["advMapAmount"]["max"].Float() = parser.readNumber();
|
|
|
|
|
|
|
|
data["abilityText"].String() = parser.readString();
|
|
|
|
loadBonuses(data, parser.readString()); //Attributes
|
|
|
|
|
|
|
|
h3Data.push_back(data);
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2009-06-28 16:49:39 +03:00
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
loadAnimationInfo(h3Data);
|
2008-11-01 00:41:22 +02:00
|
|
|
|
2013-04-21 15:49:26 +03:00
|
|
|
return h3Data;
|
|
|
|
}
|
2013-04-11 22:24:14 +03:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
CCreature * CCreatureHandler::loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index)
|
2013-04-21 15:49:26 +03:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
auto cre = new CCreature();
|
2013-04-11 22:24:14 +03:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
if(node["hasDoubleWeek"].Bool())
|
2015-11-14 15:50:29 +02:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
doubledCreatures.insert(CreatureID(index));
|
|
|
|
}
|
|
|
|
cre->idNumber = CreatureID(index);
|
|
|
|
cre->iconIndex = cre->getIndex() + 2;
|
|
|
|
cre->identifier = identifier;
|
2015-11-14 15:50:29 +02:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
JsonDeserializer handler(nullptr, node);
|
|
|
|
cre->serializeJson(handler);
|
2015-11-14 15:50:29 +02:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
cre->cost = Res::ResourceSet(node["cost"]);
|
2015-11-14 15:50:29 +02:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
cre->addBonus(node["hitPoints"].Integer(), Bonus::STACK_HEALTH);
|
|
|
|
cre->addBonus(node["speed"].Integer(), Bonus::STACKS_SPEED);
|
|
|
|
cre->addBonus(node["attack"].Integer(), Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK);
|
|
|
|
cre->addBonus(node["defense"].Integer(), Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE);
|
2012-12-03 19:00:17 +03:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
cre->addBonus(node["damage"]["min"].Integer(), Bonus::CREATURE_DAMAGE, 1);
|
|
|
|
cre->addBonus(node["damage"]["max"].Integer(), Bonus::CREATURE_DAMAGE, 2);
|
2012-12-22 19:47:12 +03:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
assert(node["damage"]["min"].Integer() <= node["damage"]["max"].Integer());
|
|
|
|
|
|
|
|
if(!node["shots"].isNull())
|
|
|
|
cre->addBonus(node["shots"].Integer(), Bonus::SHOTS);
|
|
|
|
|
|
|
|
if(!node["spellPoints"].isNull())
|
|
|
|
cre->addBonus(node["spellPoints"].Integer(), Bonus::CASTS);
|
|
|
|
|
|
|
|
loadStackExperience(cre, node["stackExperience"]);
|
|
|
|
loadJsonAnimation(cre, node["graphics"]);
|
|
|
|
loadCreatureJson(cre, node);
|
2013-04-11 22:24:14 +03:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
for(auto & extraName : node["extraNames"].Vector())
|
2013-04-23 20:29:16 +03:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
for(auto type_name : getTypeNames())
|
|
|
|
registerObject(scope, type_name, extraName.String(), cre->getIndex());
|
2013-04-23 20:29:16 +03:00
|
|
|
}
|
|
|
|
|
2015-11-14 15:50:29 +02:00
|
|
|
VLC->modh->identifiers.requestIdentifier(scope, "object", "monster", [=](si32 index)
|
|
|
|
{
|
|
|
|
JsonNode conf;
|
|
|
|
conf.setMeta(scope);
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
VLC->objtypeh->loadSubObject(cre->identifier, conf, Obj::MONSTER, cre->idNumber.num);
|
|
|
|
if (!cre->advMapDef.empty())
|
2015-11-14 15:50:29 +02:00
|
|
|
{
|
|
|
|
JsonNode templ;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
templ["animation"].String() = cre->advMapDef;
|
|
|
|
VLC->objtypeh->getHandlerFor(Obj::MONSTER, cre->idNumber.num)->addTemplate(templ);
|
2015-11-14 15:50:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// object does not have any templates - this is not usable object (e.g. pseudo-creature like Arrow Tower)
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
if (VLC->objtypeh->getHandlerFor(Obj::MONSTER, cre->idNumber.num)->getTemplates().empty())
|
|
|
|
VLC->objtypeh->removeSubObject(Obj::MONSTER, cre->idNumber.num);
|
2015-11-14 15:50:29 +02:00
|
|
|
});
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
return cre;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::vector<std::string> & CCreatureHandler::getTypeNames() const
|
|
|
|
{
|
|
|
|
static const std::vector<std::string> typeNames = { "creature" };
|
|
|
|
return typeNames;
|
2013-04-21 15:49:26 +03:00
|
|
|
}
|
2009-09-05 17:10:26 +03:00
|
|
|
|
2013-04-21 15:49:26 +03:00
|
|
|
std::vector<bool> CCreatureHandler::getDefaultAllowed() const
|
|
|
|
{
|
|
|
|
std::vector<bool> ret;
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
for(const CCreature * crea : objects)
|
2013-04-11 22:24:14 +03:00
|
|
|
{
|
2013-04-21 15:49:26 +03:00
|
|
|
ret.push_back(crea ? !crea->special : false);
|
2013-04-11 22:24:14 +03:00
|
|
|
}
|
2013-04-21 15:49:26 +03:00
|
|
|
return ret;
|
2013-04-11 22:24:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCreatureHandler::loadCrExpBon()
|
|
|
|
{
|
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);
|
2016-09-19 23:36:35 +02:00
|
|
|
for(auto b : bl)
|
2011-02-11 10:20:26 +02:00
|
|
|
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);
|
2016-09-19 23:36:35 +02:00
|
|
|
for(auto b : bl)
|
2011-02-11 10:20:26 +02:00
|
|
|
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);
|
2016-09-19 23:36:35 +02:00
|
|
|
for(auto b : bl)
|
2011-02-13 21:46:16 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
2020-10-06 01:15:52 +02:00
|
|
|
auto sid = static_cast<ui32>(parser.readNumber()); //id = this particular creature ID
|
|
|
|
|
2015-12-11 15:01:51 +02:00
|
|
|
b.sid = sid;
|
|
|
|
bl.clear();
|
|
|
|
loadStackExp(b, bl, parser);
|
2016-09-19 23:36:35 +02:00
|
|
|
for(auto b : bl)
|
2015-12-11 15:01:51 +02:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
objects[sid]->addNewBonus(b); //add directly to CCreature Node
|
2015-12-11 15:01:51 +02:00
|
|
|
}
|
2012-08-25 11:44:51 +03:00
|
|
|
}
|
|
|
|
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
|
|
|
|
|
2020-10-01 10:38:06 +02:00
|
|
|
maxExpPerBattle[i] = static_cast<ui32>(expBonParser.readNumber());
|
|
|
|
expRanks[i].push_back(expRanks[i].back() + (ui32)expBonParser.readNumber());
|
2012-08-25 11:44:51 +03:00
|
|
|
|
|
|
|
expBonParser.endLine();
|
2011-02-12 18:21:48 +02:00
|
|
|
}
|
|
|
|
//skeleton gets exp penalty
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
objects[56].get()->addBonus(-50, Bonus::EXP_MULTIPLIER, -1);
|
|
|
|
objects[57].get()->addBonus(-50, Bonus::EXP_MULTIPLIER, -1);
|
2011-02-12 18:21:48 +02:00
|
|
|
//exp for tier >7, rank 11
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
expRanks[0].push_back(147000);
|
|
|
|
expAfterUpgrade = 75; //percent
|
|
|
|
maxExpPerBattle[0] = maxExpPerBattle[7];
|
2011-02-12 18:21:48 +02:00
|
|
|
|
2011-02-11 10:20:26 +02:00
|
|
|
}//end of Stack Experience
|
2007-10-15 23:59:17 +03:00
|
|
|
}
|
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
void CCreatureHandler::loadAnimationInfo(std::vector<JsonNode> &h3Data)
|
2007-10-15 23:59:17 +03:00
|
|
|
{
|
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
|
|
|
|
2013-04-26 00:50:55 +03:00
|
|
|
for(int dd=0; dd<VLC->modh->settings.data["textData"]["creature"].Float(); ++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
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
loadUnitAnimInfo(h3Data[dd]["graphics"], parser);
|
|
|
|
parser.endLine();
|
2007-06-18 13:49:06 +03:00
|
|
|
}
|
2012-09-22 18:10:15 +03:00
|
|
|
}
|
2007-06-18 13:49:06 +03:00
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
void CCreatureHandler::loadUnitAnimInfo(JsonNode & graphics, CLegacyConfigParser & parser)
|
2012-09-22 18:10:15 +03:00
|
|
|
{
|
2013-04-11 22:24:14 +03:00
|
|
|
graphics["timeBetweenFidgets"].Float() = parser.readNumber();
|
2007-06-18 13:49:06 +03:00
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
JsonNode & animationTime = graphics["animationTime"];
|
|
|
|
animationTime["walk"].Float() = parser.readNumber();
|
|
|
|
animationTime["attack"].Float() = parser.readNumber();
|
|
|
|
animationTime["flight"].Float() = parser.readNumber();
|
2013-11-06 16:42:58 +03:00
|
|
|
animationTime["idle"].Float() = 10.0;
|
2007-06-18 13:49:06 +03:00
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
JsonNode & missile = graphics["missile"];
|
|
|
|
JsonNode & offsets = missile["offset"];
|
2007-06-18 13:49:06 +03:00
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
offsets["upperX"].Float() = parser.readNumber();
|
|
|
|
offsets["upperY"].Float() = parser.readNumber();
|
|
|
|
offsets["middleX"].Float() = parser.readNumber();
|
|
|
|
offsets["middleY"].Float() = parser.readNumber();
|
|
|
|
offsets["lowerX"].Float() = parser.readNumber();
|
|
|
|
offsets["lowerY"].Float() = parser.readNumber();
|
2007-06-18 13:49:06 +03:00
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
for(int i=0; i<12; i++)
|
|
|
|
{
|
|
|
|
JsonNode entry;
|
|
|
|
entry.Float() = parser.readNumber();
|
|
|
|
missile["frameAngles"].Vector().push_back(entry);
|
|
|
|
}
|
2007-06-18 13:49:06 +03:00
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
graphics["troopCountLocationOffset"].Float() = parser.readNumber();
|
|
|
|
|
|
|
|
missile["attackClimaxFrame"].Float() = parser.readNumber();
|
|
|
|
|
|
|
|
// assume that creature is not a shooter and should not have whole missile field
|
|
|
|
if (missile["frameAngles"].Vector()[0].Float() == 0 &&
|
|
|
|
missile["attackClimaxFrame"].Float() == 0)
|
|
|
|
graphics.Struct().erase("missile");
|
2008-08-02 18:08:03 +03:00
|
|
|
}
|
2009-01-11 00:08:18 +02:00
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
void CCreatureHandler::loadJsonAnimation(CCreature * cre, const JsonNode & graphics)
|
|
|
|
{
|
2013-03-02 19:55:51 +03:00
|
|
|
cre->animation.timeBetweenFidgets = graphics["timeBetweenFidgets"].Float();
|
2020-10-01 10:38:06 +02:00
|
|
|
cre->animation.troopCountLocationOffset = static_cast<int>(graphics["troopCountLocationOffset"].Float());
|
2012-11-13 14:52:23 +03:00
|
|
|
|
|
|
|
const JsonNode & animationTime = graphics["animationTime"];
|
2013-03-02 19:55:51 +03:00
|
|
|
cre->animation.walkAnimationTime = animationTime["walk"].Float();
|
2013-11-06 16:42:58 +03:00
|
|
|
cre->animation.idleAnimationTime = animationTime["idle"].Float();
|
2013-03-02 19:55:51 +03:00
|
|
|
cre->animation.attackAnimationTime = animationTime["attack"].Float();
|
|
|
|
cre->animation.flightAnimationDistance = animationTime["flight"].Float(); //?
|
2012-11-13 14:52:23 +03:00
|
|
|
|
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"];
|
2020-10-01 10:38:06 +02:00
|
|
|
cre->animation.upperRightMissleOffsetX = static_cast<int>(offsets["upperX"].Float());
|
|
|
|
cre->animation.upperRightMissleOffsetY = static_cast<int>(offsets["upperY"].Float());
|
|
|
|
cre->animation.rightMissleOffsetX = static_cast<int>(offsets["middleX"].Float());
|
|
|
|
cre->animation.rightMissleOffsetY = static_cast<int>(offsets["middleY"].Float());
|
|
|
|
cre->animation.lowerRightMissleOffsetX = static_cast<int>(offsets["lowerX"].Float());
|
|
|
|
cre->animation.lowerRightMissleOffsetY = static_cast<int>(offsets["lowerY"].Float());
|
|
|
|
|
|
|
|
cre->animation.attackClimaxFrame = static_cast<int>(missile["attackClimaxFrame"].Float());
|
2013-04-11 22:24:14 +03:00
|
|
|
cre->animation.missleFrameAngles = missile["frameAngles"].convertTo<std::vector<double> >();
|
2013-04-04 16:18:38 +03:00
|
|
|
|
2012-11-13 14:52:23 +03:00
|
|
|
cre->advMapDef = graphics["map"].String();
|
2013-04-22 22:51:22 +03:00
|
|
|
cre->smallIconName = graphics["iconSmall"].String();
|
|
|
|
cre->largeIconName = graphics["iconLarge"].String();
|
2012-12-23 13:23:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & config)
|
|
|
|
{
|
|
|
|
creature->animDefName = config["graphics"]["animation"].String();
|
2012-11-13 14:52:23 +03:00
|
|
|
|
2013-08-20 22:32:21 +03:00
|
|
|
//FIXME: MOD COMPATIBILITY
|
2017-11-26 23:18:18 +02:00
|
|
|
if (config["abilities"].getType() == JsonNode::JsonType::DATA_STRUCT)
|
2013-03-02 19:55:51 +03:00
|
|
|
{
|
2013-06-29 16:05:48 +03:00
|
|
|
for(auto &ability : config["abilities"].Struct())
|
2013-04-11 22:24:14 +03:00
|
|
|
{
|
|
|
|
if (!ability.second.isNull())
|
|
|
|
{
|
|
|
|
auto b = JsonUtils::parseBonus(ability.second);
|
|
|
|
b->source = Bonus::CREATURE_ABILITY;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
b->sid = creature->getIndex();
|
2013-04-11 22:24:14 +03:00
|
|
|
b->duration = Bonus::PERMANENT;
|
|
|
|
creature->addNewBonus(b);
|
|
|
|
}
|
|
|
|
}
|
2013-03-02 19:55:51 +03:00
|
|
|
}
|
2013-04-11 22:24:14 +03:00
|
|
|
else
|
2013-03-02 19:55:51 +03:00
|
|
|
{
|
2013-06-29 16:05:48 +03:00
|
|
|
for(const JsonNode &ability : config["abilities"].Vector())
|
2013-03-02 19:55:51 +03:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
if(ability.getType() == JsonNode::JsonType::DATA_VECTOR)
|
2013-05-04 16:14:23 +03:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
logMod->error("Ignored outdated creature ability format in %s", creature->getJsonKey());
|
2013-05-04 16:14:23 +03:00
|
|
|
}
|
2013-04-11 22:24:14 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
auto b = JsonUtils::parseBonus(ability);
|
|
|
|
b->source = Bonus::CREATURE_ABILITY;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
b->sid = creature->getIndex();
|
2013-04-11 22:24:14 +03:00
|
|
|
b->duration = Bonus::PERMANENT;
|
|
|
|
creature->addNewBonus(b);
|
|
|
|
}
|
2013-03-02 19:55:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-25 17:03:35 +03:00
|
|
|
VLC->modh->identifiers.requestIdentifier("faction", config["faction"], [=](si32 faction)
|
2012-12-23 13:23:41 +03:00
|
|
|
{
|
|
|
|
creature->faction = faction;
|
|
|
|
});
|
|
|
|
|
2013-06-29 16:05:48 +03:00
|
|
|
for(const JsonNode &value : config["upgrades"].Vector())
|
2012-12-23 13:23:41 +03:00
|
|
|
{
|
2013-04-25 17:03:35 +03:00
|
|
|
VLC->modh->identifiers.requestIdentifier("creature", value, [=](si32 identifier)
|
2012-12-23 13:23:41 +03:00
|
|
|
{
|
2013-02-11 02:24:57 +03:00
|
|
|
creature->upgrades.insert(CreatureID(identifier));
|
2012-12-23 13:23:41 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-03-02 19:55:51 +03:00
|
|
|
creature->animation.projectileImageName = config["graphics"]["missile"]["projectile"].String();
|
2012-12-23 13:23:41 +03:00
|
|
|
|
2013-04-11 22:24:14 +03:00
|
|
|
creature->special = config["special"].Bool() || config["disabled"].Bool();
|
2012-12-23 13:23:41 +03:00
|
|
|
|
|
|
|
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(startMoving);
|
|
|
|
GET_SOUND_VALUE(endMoving);
|
|
|
|
#undef GET_SOUND_VALUE
|
|
|
|
}
|
|
|
|
|
2013-03-02 19:55:51 +03:00
|
|
|
void CCreatureHandler::loadStackExperience(CCreature * creature, const JsonNode & input)
|
|
|
|
{
|
2013-06-29 16:05:48 +03:00
|
|
|
for (const JsonNode &exp : input.Vector())
|
2013-03-02 19:55:51 +03:00
|
|
|
{
|
2013-03-14 23:44:00 +03:00
|
|
|
auto bonus = JsonUtils::parseBonus (exp["bonus"]);
|
2013-03-02 19:55:51 +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)
|
|
|
|
{
|
2013-06-29 16:05:48 +03:00
|
|
|
for (const JsonNode &val : values)
|
2013-03-02 19:55:51 +03:00
|
|
|
{
|
|
|
|
if (val.Bool() == true)
|
|
|
|
{
|
2015-12-29 04:43:33 +02:00
|
|
|
bonus->limiter = std::make_shared<RankRangeLimiter>(RankRangeLimiter(lowerLimit));
|
2016-09-19 23:36:35 +02:00
|
|
|
creature->addNewBonus (std::make_shared<Bonus>(*bonus)); //bonuses must be unique objects
|
2013-03-02 19:55:51 +03:00
|
|
|
break; //TODO: allow bonuses to turn off?
|
|
|
|
}
|
|
|
|
++lowerLimit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int lastVal = 0;
|
2013-06-29 16:05:48 +03:00
|
|
|
for (const JsonNode &val : values)
|
2013-03-02 19:55:51 +03:00
|
|
|
{
|
|
|
|
if (val.Float() != lastVal)
|
|
|
|
{
|
2020-10-01 10:38:06 +02:00
|
|
|
bonus->val = (int)val.Float() - lastVal;
|
2013-03-02 19:55:51 +03:00
|
|
|
bonus->limiter.reset (new RankRangeLimiter(lowerLimit));
|
2016-09-19 23:36:35 +02:00
|
|
|
creature->addNewBonus (std::make_shared<Bonus>(*bonus));
|
2013-03-02 19:55:51 +03:00
|
|
|
}
|
2020-10-01 10:38:06 +02:00
|
|
|
lastVal = static_cast<int>(val.Float());
|
2013-03-02 19:55:51 +03:00
|
|
|
++lowerLimit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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:
|
2017-08-12 13:36:04 +02:00
|
|
|
logGlobal->trace("Not parsed bonus %s %s", buf, mod);
|
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;
|
2015-09-18 06:54:28 +02:00
|
|
|
b.additionalInfo = 0;//normal immunity
|
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;
|
2015-09-18 06:54:28 +02:00
|
|
|
b.additionalInfo = 0;//normal immunity
|
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;
|
2015-09-18 06:54:28 +02:00
|
|
|
b.additionalInfo = 0;//normal immunity
|
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;
|
2015-09-18 06:54:28 +02:00
|
|
|
b.additionalInfo = 0;//normal immunity
|
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;
|
2015-09-18 06:54:28 +02:00
|
|
|
b.additionalInfo = 0;//normal immunity
|
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;
|
2015-09-18 06:54:28 +02:00
|
|
|
b.additionalInfo = 0;//normal immunity
|
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;
|
2015-09-18 06:54:28 +02:00
|
|
|
b.additionalInfo = 0;//normal immunity
|
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;
|
2015-09-18 06:54:28 +02:00
|
|
|
b.additionalInfo = 0;//normal immunity
|
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:
|
2017-08-12 13:36:04 +02:00
|
|
|
logGlobal->trace("Not parsed bonus %s %s", buf, mod);
|
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:
|
2017-08-12 13:36:04 +02:00
|
|
|
logGlobal->trace("Not parsed bonus %s %s", buf, mod);
|
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
|
2020-10-01 10:38:06 +02:00
|
|
|
curVal = static_cast<si32>(parser.readNumber());// 0 level is never active
|
2011-02-11 10:20:26 +02:00
|
|
|
for (int i = 1; i < 11; ++i)
|
|
|
|
{
|
2020-10-01 10:38:06 +02:00
|
|
|
curVal = static_cast<si32>(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));
|
2016-09-19 23:36:35 +02:00
|
|
|
bl.push_back(std::make_shared<Bonus>(b));
|
2011-02-11 10:20:26 +02:00
|
|
|
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
|
|
|
{
|
2020-10-01 10:38:06 +02:00
|
|
|
lastVal = static_cast<si32>(parser.readNumber());
|
2013-10-12 21:23:01 +03:00
|
|
|
if (b.type == Bonus::HATE)
|
|
|
|
lastVal *= 10; //odd fix
|
|
|
|
//FIXME: value for zero level should be stored in our config files (independent of stack exp)
|
2011-02-11 10:20:26 +02:00
|
|
|
for (int i = 1; i < 11; ++i)
|
2011-02-08 13:34:34 +02:00
|
|
|
{
|
2020-10-01 10:38:06 +02:00
|
|
|
curVal = static_cast<si32>(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));
|
2016-09-19 23:36:35 +02:00
|
|
|
bl.push_back(std::make_shared<Bonus>(b));
|
2011-02-11 10:20:26 +02:00
|
|
|
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()
|
|
|
|
{
|
2016-08-22 12:27:25 +02:00
|
|
|
for(auto & p : skillRequirements)
|
2016-09-19 23:36:35 +02:00
|
|
|
p.first = nullptr;
|
2009-05-24 01:57:39 +03:00
|
|
|
}
|
2010-07-24 00:05:49 +03:00
|
|
|
|
2014-03-17 22:51:07 +03:00
|
|
|
CreatureID CCreatureHandler::pickRandomMonster(CRandomGenerator & rand, 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
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
r = (*RandomGeneratorUtil::nextItem(objects, rand))->idNumber;
|
|
|
|
} while (objects[r] && objects[r]->special); // find first "not special" creature
|
2011-02-10 15:12:53 +02:00
|
|
|
}
|
|
|
|
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;
|
2013-06-29 16:05:48 +03:00
|
|
|
for(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-03-02 19:55:51 +03:00
|
|
|
const CCreature * crea = dynamic_cast<const CCreature*>(b);
|
|
|
|
if(crea && !crea->special)
|
|
|
|
allowed.push_back(crea->idNumber);
|
2011-02-10 15:12:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!allowed.size())
|
|
|
|
{
|
2017-08-11 19:03:05 +02:00
|
|
|
logGlobal->warn("Cannot pick a random creature of tier %d!", tier);
|
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
|
|
|
|
2014-03-17 22:51:07 +03:00
|
|
|
return *RandomGeneratorUtil::nextItem(allowed, rand);
|
2011-02-10 15:12:53 +02:00
|
|
|
}
|
2013-04-23 20:29:16 +03:00
|
|
|
assert (r >= 0); //should always be, but it crashed
|
2013-02-11 02:24:57 +03:00
|
|
|
return CreatureID(r);
|
2011-02-10 15:12:53 +02:00
|
|
|
}
|
|
|
|
|
2021-02-05 00:56:21 +02:00
|
|
|
void CCreatureHandler::addBonusForTier(int tier, const std::shared_ptr<Bonus> & b)
|
2011-02-10 15:12:53 +02:00
|
|
|
{
|
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);
|
|
|
|
}
|
|
|
|
|
2021-02-05 00:56:21 +02:00
|
|
|
void CCreatureHandler::addBonusForAllCreatures(const std::shared_ptr<Bonus> & b)
|
2011-02-10 15:12:53 +02:00
|
|
|
{
|
2021-02-05 00:56:21 +02:00
|
|
|
const auto & exportedBonuses = allCreatures.getExportedBonusList();
|
|
|
|
for(const auto & bonus : exportedBonuses)
|
|
|
|
{
|
|
|
|
if(bonus->type == b->type && bonus->subtype == b->subtype)
|
|
|
|
return;
|
|
|
|
}
|
2011-02-10 15:12:53 +02:00
|
|
|
allCreatures.addNewBonus(b);
|
2011-02-22 11:47:25 +02:00
|
|
|
}
|
|
|
|
|
2020-12-10 03:05:37 +02:00
|
|
|
void CCreatureHandler::removeBonusesFromAllCreatures()
|
|
|
|
{
|
|
|
|
allCreatures.removeBonuses(Selector::all);
|
|
|
|
}
|
|
|
|
|
2021-01-14 00:02:13 +02:00
|
|
|
void CCreatureHandler::restoreAllCreaturesNodeType794()
|
|
|
|
{
|
|
|
|
allCreatures.setNodeType(CBonusSystemNode::ENodeTypes::ALL_CREATURES);
|
|
|
|
}
|
|
|
|
|
2011-02-22 11:47:25 +02:00
|
|
|
void CCreatureHandler::buildBonusTreeForTiers()
|
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
for(CCreature * c : objects)
|
2011-02-22 11:47:25 +02:00
|
|
|
{
|
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]);
|
|
|
|
}
|
2013-06-29 16:05:48 +03:00
|
|
|
for(CBonusSystemNode &b : creaturesOfLevel)
|
2011-02-22 11:47:25 +02:00
|
|
|
b.attachTo(&allCreatures);
|
|
|
|
}
|
|
|
|
|
2014-01-03 02:48:38 +03:00
|
|
|
void CCreatureHandler::afterLoadFinalization()
|
|
|
|
{
|
2014-06-04 14:15:58 +03:00
|
|
|
|
2014-01-03 02:48:38 +03:00
|
|
|
}
|
|
|
|
|
2011-02-22 11:47:25 +02:00
|
|
|
void CCreatureHandler::deserializationFix()
|
|
|
|
{
|
|
|
|
buildBonusTreeForTiers();
|
2011-05-04 05:38:58 +03:00
|
|
|
}
|