mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-24 03:47:18 +02:00
- Fix for hero specialties (creature type limiters)
- Improved handling of new heroes / arts, check forum for fresh mod packages :)
This commit is contained in:
parent
1cab54b87a
commit
fff7909958
@ -752,7 +752,7 @@ std::vector<ui32> BattleInfo::calculateResistedStacks(const CSpell * sp, const C
|
||||
if( (*it)->hasBonusOfType(Bonus::SPELL_IMMUNITY, sp->id) //100% sure spell immunity
|
||||
|| ( (*it)->count - 1 ) * (*it)->MaxHealth() + (*it)->firstHPleft
|
||||
>
|
||||
usedSpellPower * 25 + sp->powers[spellLevel]
|
||||
usedSpellPower * 25 + sp->powers[spellLevel] //TODO: allow 'damage' bonus for hypnotize
|
||||
)
|
||||
{
|
||||
ret.push_back((*it)->ID);
|
||||
|
@ -383,12 +383,11 @@ void CArtHandler::load(const JsonNode & node)
|
||||
if (!entry.second.isNull()) // may happens if mod removed creature by setting json entry to null
|
||||
{
|
||||
CArtifact * art = loadArtifact(entry.second);
|
||||
art->setName (entry.first);
|
||||
art->id = artifacts.size();
|
||||
|
||||
artifacts.push_back(art);
|
||||
tlog5 << "Added artifact: " << entry.first << "\n";
|
||||
VLC->modh->identifiers.registerObject (std::string("artifact.") + art->Name(), art->id);
|
||||
VLC->modh->identifiers.registerObject (std::string("artifact.") + entry.first, art->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -925,6 +925,8 @@ void CGHeroInstance::initObj() //TODO: use bonus system
|
||||
{
|
||||
blockVisit = true;
|
||||
HeroSpecial * hs = new HeroSpecial();
|
||||
hs->setNodeType(CBonusSystemNode::specialty);
|
||||
attachTo(hs); //do we ever need to detach it?
|
||||
|
||||
if(!type)
|
||||
return; //TODO: support prison
|
||||
@ -956,7 +958,7 @@ void CGHeroInstance::initObj() //TODO: use bonus system
|
||||
}
|
||||
}
|
||||
|
||||
bonus->additionalInfo = spec.additionalinfo; //creature id
|
||||
//bonus->additionalInfo = spec.additionalinfo; //creature id, should not be used again - this works only with limiter
|
||||
bonus->limiter.reset(new CCreatureTypeLimiter (specCreature, true)); //with upgrades
|
||||
bonus->type = Bonus::PRIMARY_SKILL;
|
||||
bonus->valType = Bonus::ADDITIVE_VALUE;
|
||||
@ -1102,13 +1104,13 @@ void CGHeroInstance::initObj() //TODO: use bonus system
|
||||
tlog2 << "Unexpected hero specialty " << type <<'\n';
|
||||
}
|
||||
}
|
||||
hs->setNodeType(CBonusSystemNode::specialty);
|
||||
attachTo(hs); //do we ever need to detach it?
|
||||
specialty.push_back(hs); //will it work?
|
||||
|
||||
BOOST_FOREACH (auto hs2, type->specialty) //copy active (probably growing) bonuses from hero prootype to hero object
|
||||
{
|
||||
HeroSpecial * hs = new HeroSpecial();
|
||||
attachTo(hs); //do we ever need to detach it?
|
||||
|
||||
hs->setNodeType(CBonusSystemNode::specialty);
|
||||
BOOST_FOREACH (auto bonus, hs2.bonuses)
|
||||
{
|
||||
@ -1116,7 +1118,6 @@ void CGHeroInstance::initObj() //TODO: use bonus system
|
||||
}
|
||||
hs->growsWithLevel = hs2.growsWithLevel;
|
||||
|
||||
attachTo(hs); //do we ever need to detach it?
|
||||
specialty.push_back(hs); //will it work?
|
||||
}
|
||||
|
||||
@ -1145,16 +1146,18 @@ void CGHeroInstance::Updatespecialty() //TODO: calculate special value of bonuse
|
||||
break; //use only hero skills as bonuses to avoid feedback loop
|
||||
case Bonus::PRIMARY_SKILL: //for creatures, that is
|
||||
{
|
||||
const CCreature * cre = NULL;
|
||||
int creLevel = 0;
|
||||
if (auto creatureLimiter = std::dynamic_pointer_cast<CCreatureTypeLimiter>(b->limiter)) //TODO: more general eveluation of bonuses?
|
||||
{
|
||||
creLevel = creatureLimiter->creature->level;
|
||||
if(!creLevel)
|
||||
cre = creatureLimiter->creature;
|
||||
creLevel = cre->level;
|
||||
if (!creLevel)
|
||||
{
|
||||
creLevel = 5; //treat ballista as tier 5
|
||||
}
|
||||
}
|
||||
else
|
||||
else //no creature found, can't calculate value
|
||||
{
|
||||
tlog2 << "Primary skill specialty growth supported only with creature type limiters\n";
|
||||
break;
|
||||
@ -1165,13 +1168,13 @@ void CGHeroInstance::Updatespecialty() //TODO: calculate special value of bonuse
|
||||
switch (b->subtype)
|
||||
{
|
||||
case PrimarySkill::ATTACK:
|
||||
param = creatures[b->additionalInfo]->Attack();
|
||||
param = cre->Attack();
|
||||
break;
|
||||
case PrimarySkill::DEFENSE:
|
||||
param = creatures[b->additionalInfo]->Defense();
|
||||
param = cre->Defense();
|
||||
break;
|
||||
default:
|
||||
param = 0;
|
||||
continue;
|
||||
}
|
||||
b->val = ceil(param * (1 + primSkillModifier)) - param; //yep, overcomplicated but matches original
|
||||
break;
|
||||
@ -1514,6 +1517,11 @@ bool CGHeroInstance::hasSpellbook() const
|
||||
void CGHeroInstance::deserializationFix()
|
||||
{
|
||||
artDeserializationFix(this);
|
||||
|
||||
//BOOST_FOREACH (auto hs, specialty)
|
||||
//{
|
||||
// attachTo (hs);
|
||||
//}
|
||||
}
|
||||
|
||||
CBonusSystemNode * CGHeroInstance::whereShouldBeAttached(CGameState *gs)
|
||||
|
@ -292,6 +292,7 @@ struct DLL_LINKAGE Bonus
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & duration & type & subtype & source & val & sid & description & additionalInfo & turnsRemain & valType & effectRange & limiter & propagator;
|
||||
h & calculator;
|
||||
}
|
||||
|
||||
static bool compareByAdditionalInfo(const Bonus *a, const Bonus *b)
|
||||
|
@ -991,9 +991,7 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
|
||||
if (!value->isNull())
|
||||
b->valType = parseByMap(bonusValueMap, value, "value type ");
|
||||
|
||||
value = &ability["additionalInfo"];
|
||||
if (!value->isNull())
|
||||
b->additionalInfo = value->Float();
|
||||
resolveIdentifier (b->additionalInfo, ability, "addInfo");
|
||||
|
||||
value = &ability["turns"];
|
||||
if (!value->isNull())
|
||||
|
Loading…
x
Reference in New Issue
Block a user