1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Support for special upgrades (like Gelu).

This commit is contained in:
DjWarmonger
2010-07-17 06:49:16 +00:00
parent eecfa0f2bd
commit 112ac29fc0
3 changed files with 23 additions and 12 deletions

View File

@@ -155,10 +155,10 @@
144 12 2 0 0
145 11 14 0 0
146 1 0 0 4
147 9 8 0 136
147 9 34 0 136
148 9 2 0 137
148 9 18 0 137
147 9 0 8 136
147 9 0 34 136
148 9 0 2 137
148 9 0 18 137
149 4 5 1 96
149 4 5 2 96
149 4 10 3 96

View File

@@ -1085,13 +1085,15 @@ void CGHeroInstance::initObj()
{
std::vector<CCreature*>* creatures = &VLC->creh->creatures;
bonus.type = Bonus::SPECIAL_UPGRADE;
bonus.additionalInfo = it->additionalinfo;
bonus.subtype = it->subtype; //base id
bonus.additionalInfo = it->additionalinfo; //target id
speciality.bonuses.push_back (bonus);
for (std::set<ui32>::iterator i = (*creatures)[it->val]->upgrades.begin();
i != (*creatures)[it->val]->upgrades.end(); i++)
for (std::set<ui32>::iterator i = (*creatures)[it->subtype]->upgrades.begin();
i != (*creatures)[it->subtype]->upgrades.end(); i++)
{
bonus.val = *i;
speciality.bonuses.push_back (bonus); //propagate for regular upgrades of base creature
bonus.subtype = *i; //propagate for regular upgrades of base creature
speciality.bonuses.push_back (bonus);
}
break;
}

View File

@@ -1746,8 +1746,19 @@ UpgradeInfo CGameState::getUpgradeInfo(const CStackInstance &stack)
if(stack.armyObj->ID == TOWNI_TYPE)
t = static_cast<const CGTownInstance *>(stack.armyObj);
else if(h)
{ //TODO: check if hero specialty makes some upgrades possible
BonusList lista = h->speciality.getBonuses(Selector::typeSybtype(Bonus::SPECIAL_UPGRADE, base->idNumber));
for (BonusList::iterator it = lista.begin(); it != lista.end(); it++)
{
ui16 nid = it->additionalInfo;
if (nid != base->idNumber) //sharpshooter appears to be default upgrade of minor creatures (?)
{
ret.newID.push_back(nid);
ret.cost.push_back(costDiff(VLC->creh->creatures[nid]->cost, base->cost));
}
}
t = h->visitedTown;
}
if(t)
{
BOOST_FOREACH(si32 bid, t->builtBuildings)
@@ -1777,8 +1788,6 @@ UpgradeInfo CGameState::getUpgradeInfo(const CStackInstance &stack)
}
}
//TODO: check if hero specialty makes some upgrades possible
if(ret.newID.size())
ret.oldID = base->idNumber;