mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Support for Whirlpool
This commit is contained in:
@@ -2849,9 +2849,40 @@ void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
else
|
else
|
||||||
tlog2 << "Cannot find corresponding exit monolith for "<< id << std::endl;
|
tlog2 << "Cannot find corresponding exit monolith for "<< id << std::endl;
|
||||||
break;
|
break;
|
||||||
case 45: //two way monolith - pick any other one
|
case 45://two way monolith - pick any other one
|
||||||
if(vstd::contains(objs,45) && vstd::contains(objs[45],subID) && objs[45][subID].size()>1)
|
case 111: //Whirlpool
|
||||||
while ((destinationid = objs[45][subID][rand()%objs[45][subID].size()])==id);
|
if(vstd::contains(objs,ID) && vstd::contains(objs[ID],subID) && objs[ID][subID].size()>1)
|
||||||
|
{
|
||||||
|
while ((destinationid = objs[ID][subID][rand()%objs[ID][subID].size()]) == id); //choose another exit
|
||||||
|
if (ID == 111)
|
||||||
|
{
|
||||||
|
if (!h->hasBonusOfType(Bonus::WHIRLPOOL_PROTECTION))
|
||||||
|
{
|
||||||
|
CCreatureSet army = h->getArmy();
|
||||||
|
int targetstack = army.Slots().size()-1;
|
||||||
|
for(TSlots::const_reverse_iterator i = army.Slots().rbegin(); i != army.Slots().rend(); i++)
|
||||||
|
{
|
||||||
|
if (army.getPower(targetstack) > army.getPower(i->first))
|
||||||
|
{
|
||||||
|
targetstack = (i->first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CCreatureSet ourArmy;
|
||||||
|
ourArmy.addStack (targetstack, army.getStack(targetstack));
|
||||||
|
TQuantity tq = (TQuantity)((double)(ourArmy.getAmount(targetstack))*0.3);
|
||||||
|
if (tq) //casualties > 0
|
||||||
|
{
|
||||||
|
ourArmy.setStackCount (targetstack, tq);
|
||||||
|
InfoWindow iw;
|
||||||
|
iw.player = h->tempOwner;
|
||||||
|
iw.text.addTxt (MetaString::ADVOB_TXT, 168);
|
||||||
|
iw.components.push_back (Component(ourArmy.getStack(targetstack)));
|
||||||
|
cb->showInfoDialog(&iw);
|
||||||
|
cb->takeCreatures (h->id, ourArmy.Slots());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
tlog2 << "Cannot find corresponding exit monolith for "<< id << std::endl;
|
tlog2 << "Cannot find corresponding exit monolith for "<< id << std::endl;
|
||||||
break;
|
break;
|
||||||
@@ -2876,7 +2907,7 @@ void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
{
|
{
|
||||||
InfoWindow iw;
|
InfoWindow iw;
|
||||||
iw.player = h->tempOwner;
|
iw.player = h->tempOwner;
|
||||||
iw.text.addTxt(MetaString::ADVOB_TXT, 153); //Just inside the entrance you find a large pile of rubble blocking the tunnel. You leave discouraged.
|
iw.text.addTxt(MetaString::ADVOB_TXT, 153);//Just inside the entrance you find a large pile of rubble blocking the tunnel. You leave discouraged.
|
||||||
cb->sendAndApply(&iw);
|
cb->sendAndApply(&iw);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2887,16 +2918,23 @@ void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
tlog2 << "Cannot find exit... (obj at " << pos << ") :( \n";
|
tlog2 << "Cannot find exit... (obj at " << pos << ") :( \n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cb->moveHero(h->id,CGHeroInstance::convertPosition(cb->getObj(destinationid)->pos,true) - getVisitableOffset(),
|
cb->moveHero (h->id,CGHeroInstance::convertPosition(cb->getObj(destinationid)->pos,true) - getVisitableOffset(), true);
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGTeleport::initObj()
|
void CGTeleport::initObj()
|
||||||
{
|
{
|
||||||
int si = subID;
|
int si = subID;
|
||||||
if(ID == 103) //ignore subterranean gates subid
|
switch (ID)
|
||||||
si = 0;
|
{
|
||||||
|
case 103://ignore subterranean gates subid
|
||||||
|
case 111:
|
||||||
|
{
|
||||||
|
si = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
objs[ID][si].push_back(id);
|
objs[ID][si].push_back(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -600,6 +600,7 @@ int Mapa::loadSeerHut( const unsigned char * bufor, int i, CGObjectInstance *& n
|
|||||||
}
|
}
|
||||||
else //RoE
|
else //RoE
|
||||||
{
|
{
|
||||||
|
hut->isCustom = false;
|
||||||
int artID = bufor[i]; ++i;
|
int artID = bufor[i]; ++i;
|
||||||
if(artID!=255) //not none quest
|
if(artID!=255) //not none quest
|
||||||
{
|
{
|
||||||
@@ -1461,6 +1462,7 @@ void Mapa::readObjects( const unsigned char * bufor, int &i)
|
|||||||
case 44: //teleport
|
case 44: //teleport
|
||||||
case 45: //teleport
|
case 45: //teleport
|
||||||
case 103://subterranean gate
|
case 103://subterranean gate
|
||||||
|
case 111://Whirlpool
|
||||||
{
|
{
|
||||||
nobj = new CGTeleport();
|
nobj = new CGTeleport();
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user