mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Fix identifiers resolving for stack experience bonuses
This commit is contained in:
parent
00e9cef19f
commit
fc750d0917
@ -963,9 +963,6 @@ void CCreatureHandler::loadStackExperience(CCreature * creature, const JsonNode
|
||||
{
|
||||
for (const JsonNode &exp : input.Vector())
|
||||
{
|
||||
auto bonus = JsonUtils::parseBonus (exp["bonus"]);
|
||||
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)
|
||||
@ -974,8 +971,14 @@ void CCreatureHandler::loadStackExperience(CCreature * creature, const JsonNode
|
||||
{
|
||||
if(val.Bool())
|
||||
{
|
||||
// parse each bonus separately
|
||||
// we can not create copies since identifiers resolution does not tracks copies
|
||||
// leading to unset identifier values in copies
|
||||
auto bonus = JsonUtils::parseBonus (exp["bonus"]);
|
||||
bonus->source = Bonus::STACK_EXPERIENCE;
|
||||
bonus->duration = Bonus::PERMANENT;
|
||||
bonus->limiter = std::make_shared<RankRangeLimiter>(RankRangeLimiter(lowerLimit));
|
||||
creature->addNewBonus (std::make_shared<Bonus>(*bonus)); //bonuses must be unique objects
|
||||
creature->addNewBonus (bonus);
|
||||
break; //TODO: allow bonuses to turn off?
|
||||
}
|
||||
++lowerLimit;
|
||||
@ -988,9 +991,14 @@ void CCreatureHandler::loadStackExperience(CCreature * creature, const JsonNode
|
||||
{
|
||||
if (val.Float() != lastVal)
|
||||
{
|
||||
bonus->val = static_cast<int>(val.Float()) - lastVal;
|
||||
JsonNode bonusInput = exp["bonus"];
|
||||
bonusInput["val"].Float() = static_cast<int>(val.Float()) - lastVal;
|
||||
|
||||
auto bonus = JsonUtils::parseBonus (bonusInput);
|
||||
bonus->source = Bonus::STACK_EXPERIENCE;
|
||||
bonus->duration = Bonus::PERMANENT;
|
||||
bonus->limiter.reset (new RankRangeLimiter(lowerLimit));
|
||||
creature->addNewBonus (std::make_shared<Bonus>(*bonus));
|
||||
creature->addNewBonus (bonus);
|
||||
}
|
||||
lastVal = static_cast<int>(val.Float());
|
||||
++lowerLimit;
|
||||
|
Loading…
Reference in New Issue
Block a user