mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Support for Castle Stables. These are compatible with advMap Stables.
This commit is contained in:
@@ -1584,11 +1584,16 @@ void CGTownInstance::initObj()
|
|||||||
}
|
}
|
||||||
switch (subID)
|
switch (subID)
|
||||||
{ //add new visitable objects
|
{ //add new visitable objects
|
||||||
|
case 0:
|
||||||
|
bonusingBuildings.push_back (new COPWBonus(21, this)); //Stables
|
||||||
|
break;
|
||||||
case 2: case 3: case 5: case 6:
|
case 2: case 3: case 5: case 6:
|
||||||
bonusingBuildings.push_back (new CTownBonus(23, this));
|
bonusingBuildings.push_back (new CTownBonus(23, this));
|
||||||
|
if (subID == 5)
|
||||||
|
bonusingBuildings.push_back (new COPWBonus(18, this)); //Vortex
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
bonusingBuildings.push_back (new CTownBonus(17, this));
|
bonusingBuildings.push_back (new CTownBonus(17, this));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (getOwner() != 255)
|
if (getOwner() != 255)
|
||||||
@@ -1965,6 +1970,53 @@ void CGVisitableOPH::schoolSelected(int heroID, ui32 which) const
|
|||||||
cb->changePrimSkill(heroID, base + which-1, +1); //give appropriate skill
|
cb->changePrimSkill(heroID, base + which-1, +1); //give appropriate skill
|
||||||
}
|
}
|
||||||
|
|
||||||
|
COPWBonus::COPWBonus (int index, CGTownInstance *TOWN)
|
||||||
|
{
|
||||||
|
ID = index;
|
||||||
|
town = TOWN;
|
||||||
|
id = town->bonusingBuildings.size();
|
||||||
|
}
|
||||||
|
void COPWBonus::setProperty(ui8 what, ui32 val)
|
||||||
|
{
|
||||||
|
switch (what)
|
||||||
|
{
|
||||||
|
case 4:
|
||||||
|
visitors.insert(val);
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
visitors.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void COPWBonus::onHeroVisit (const CGHeroInstance * h) const
|
||||||
|
{
|
||||||
|
int heroID = h->id;
|
||||||
|
if (town->builtBuildings.find(ID) != town->builtBuildings.end())
|
||||||
|
{
|
||||||
|
InfoWindow iw;
|
||||||
|
iw.player = h->tempOwner;
|
||||||
|
switch (ID)
|
||||||
|
{
|
||||||
|
case 18: //Mana Vortex
|
||||||
|
if (visitors.size())
|
||||||
|
{
|
||||||
|
cb->setObjProperty (town->id, 11, id); //add to visitors
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 21: //Stables
|
||||||
|
if (!h->getBonus(HeroBonus::OBJECT, 94)) //no advMap Stables
|
||||||
|
{
|
||||||
|
GiveBonus gb;
|
||||||
|
gb.bonus = HeroBonus(HeroBonus::ONE_WEEK, HeroBonus::LAND_MOVEMENT, HeroBonus::OBJECT, 600, 94, VLC->generaltexth->arraytxt[100]);
|
||||||
|
gb.hid = heroID;
|
||||||
|
cb->giveHeroBonus(&gb);
|
||||||
|
iw.text << std::pair<ui8,ui32>(11, 137);
|
||||||
|
cb->showInfoDialog(&iw);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
CTownBonus::CTownBonus (int index, CGTownInstance *TOWN)
|
CTownBonus::CTownBonus (int index, CGTownInstance *TOWN)
|
||||||
{
|
{
|
||||||
ID = index;
|
ID = index;
|
||||||
|
@@ -371,6 +371,21 @@ public:
|
|||||||
h & ID & id;
|
h & ID & id;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
class DLL_EXPORT COPWBonus : public CGTownBuilding
|
||||||
|
{///used for OPW bonusing structures
|
||||||
|
public:
|
||||||
|
std::set<si32> visitors;
|
||||||
|
void setProperty(ui8 what, ui32 val);
|
||||||
|
void onHeroVisit (const CGHeroInstance * h) const;
|
||||||
|
|
||||||
|
COPWBonus (int index, CGTownInstance *TOWN);
|
||||||
|
COPWBonus (){ID = 0; town = NULL;};
|
||||||
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
|
{
|
||||||
|
h & static_cast<CGTownBuilding&>(*this);
|
||||||
|
h & visitors;
|
||||||
|
}
|
||||||
|
};
|
||||||
class DLL_EXPORT CTownBonus : public CGTownBuilding
|
class DLL_EXPORT CTownBonus : public CGTownBuilding
|
||||||
{
|
{
|
||||||
///used for one-time bonusing structures
|
///used for one-time bonusing structures
|
||||||
|
@@ -23,6 +23,7 @@ void registerTypes1(Serializer &s)
|
|||||||
s.template registerType<CGHeroInstance>();
|
s.template registerType<CGHeroInstance>();
|
||||||
s.template registerType<CGTownInstance>();
|
s.template registerType<CGTownInstance>();
|
||||||
s.template registerType<CTownBonus>();
|
s.template registerType<CTownBonus>();
|
||||||
|
s.template registerType<COPWBonus>();
|
||||||
s.template registerType<CGPandoraBox>();
|
s.template registerType<CGPandoraBox>();
|
||||||
s.template registerType<CGEvent>();
|
s.template registerType<CGEvent>();
|
||||||
s.template registerType<CGDwelling>();
|
s.template registerType<CGDwelling>();
|
||||||
|
Reference in New Issue
Block a user