1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-17 20:58:07 +02:00

Fix components problem

This commit is contained in:
nordsoft 2023-09-17 16:04:34 +02:00
parent 44d72dce51
commit e3538f24ab
4 changed files with 13 additions and 12 deletions

View File

@ -51,11 +51,6 @@ void CRewardableConstructor::configureObject(CGObjectInstance * object, CRandomG
{
bonus.source = BonusSource::OBJECT;
bonus.sid = rewardableObject->ID;
//TODO: bonus.description = object->getObjectName();
if (bonus.type == BonusType::MORALE)
rewardInfo.reward.extraComponents.emplace_back(Component::EComponentType::MORALE, 0, bonus.val, 0);
if (bonus.type == BonusType::LUCK)
rewardInfo.reward.extraComponents.emplace_back(Component::EComponentType::LUCK, 0, bonus.val, 0);
}
}
assert(!rewardableObject->configuration.info.empty());

View File

@ -307,10 +307,6 @@ void CTownRewardableBuilding::initObj(CRandomGenerator & rand)
{
bonus.source = BonusSource::TOWN_STRUCTURE;
bonus.sid = bID;
if (bonus.type == BonusType::MORALE)
rewardInfo.reward.extraComponents.emplace_back(Component::EComponentType::MORALE, 0, bonus.val, 0);
if (bonus.type == BonusType::LUCK)
rewardInfo.reward.extraComponents.emplace_back(Component::EComponentType::LUCK, 0, bonus.val, 0);
}
}
}

View File

@ -1024,8 +1024,10 @@ void CMapLoaderH3M::readBoxContent(CGPandoraBox * object, const int3 & mapPositi
reward.heroExperience = reader->readUInt32();
reward.manaDiff = reader->readInt32();
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, reader->readUInt8(), idToBeGiven);
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, reader->readUInt8(), idToBeGiven);
if(auto val = reader->readUInt8())
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, val, idToBeGiven);
if(auto val = reader->readUInt8())
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, val, idToBeGiven);
reader->readResourses(reward.resources);
for(int x = 0; x < GameConstants::PRIMARY_SKILLS; ++x)

View File

@ -61,7 +61,15 @@ void Rewardable::Reward::loadComponents(std::vector<Component> & comps,
{
for (auto comp : extraComponents)
comps.push_back(comp);
for (auto & bonus : bonuses)
{
if (bonus.type == BonusType::MORALE)
comps.emplace_back(Component::EComponentType::MORALE, 0, bonus.val, 0);
if (bonus.type == BonusType::LUCK)
comps.emplace_back(Component::EComponentType::LUCK, 0, bonus.val, 0);
}
if (heroExperience)
{
comps.emplace_back(Component::EComponentType::EXPERIENCE, 0, static_cast<si32>(h->calculateXp(heroExperience)), 0);