mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Several fixes for Whirlpool and stack removal.
Sea Captain's Hat is also supported.
This commit is contained in:
		| @@ -2869,19 +2869,21 @@ void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const | |||||||
| 				if (!h->hasBonusOfType(Bonus::WHIRLPOOL_PROTECTION)) | 				if (!h->hasBonusOfType(Bonus::WHIRLPOOL_PROTECTION)) | ||||||
| 				{ | 				{ | ||||||
| 					CCreatureSet army = h->getArmy(); | 					CCreatureSet army = h->getArmy(); | ||||||
| 					int targetstack = army.Slots().size()-1; | 					if (army.Slots().size() > 1 || army.Slots().begin()->second.count > 1) | ||||||
| 					for(TSlots::const_reverse_iterator i = army.Slots().rbegin(); i != army.Slots().rend(); i++) | 					{ //we can't remove last unit | ||||||
| 					{ | 						int targetstack = army.Slots().begin()->first; //slot numbers may vary | ||||||
| 						if (army.getPower(targetstack) > army.getPower(i->first)) | 						for(TSlots::const_reverse_iterator i = army.Slots().rbegin(); i != army.Slots().rend(); i++) | ||||||
| 						{ | 						{ | ||||||
| 							targetstack = (i->first); | 							if (army.getPower(targetstack) > army.getPower(i->first)) | ||||||
|  | 							{ | ||||||
|  | 								targetstack = (i->first); | ||||||
|  | 							} | ||||||
| 						} | 						} | ||||||
| 					} | 						CCreatureSet ourArmy; | ||||||
| 					CCreatureSet ourArmy; | 						ourArmy.addStack (targetstack, army.getStack(targetstack)); | ||||||
| 					ourArmy.addStack (targetstack, army.getStack(targetstack)); | 						TQuantity tq = (double)(ourArmy.getAmount(targetstack))*0.5; | ||||||
| 					TQuantity tq = (TQuantity)((double)(ourArmy.getAmount(targetstack))*0.3); | 						amax (tq, 1); | ||||||
| 					if (tq) //casualties > 0 |  | ||||||
| 					{ |  | ||||||
| 						ourArmy.setStackCount (targetstack, tq); | 						ourArmy.setStackCount (targetstack, tq); | ||||||
| 						InfoWindow iw; | 						InfoWindow iw; | ||||||
| 						iw.player = h->tempOwner; | 						iw.player = h->tempOwner; | ||||||
| @@ -2928,7 +2930,10 @@ 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(), true); | 	if (ID == 111) | ||||||
|  | 		cb->moveHero (h->id,CGHeroInstance::convertPosition(cb->getObj(destinationid)->pos,true) + (h->pos - pos) - int3(1,0,0), true); | ||||||
|  | 	else | ||||||
|  | 		cb->moveHero (h->id,CGHeroInstance::convertPosition(cb->getObj(destinationid)->pos,true) - getVisitableOffset(), true); | ||||||
| } | } | ||||||
|  |  | ||||||
| void CGTeleport::initObj() | void CGTeleport::initObj() | ||||||
|   | |||||||
| @@ -1893,14 +1893,15 @@ void CGameHandler::takeCreatures (int objid, TSlots creatures) //probably we cou | |||||||
| 		return; | 		return; | ||||||
| 	const CArmedInstance* obj = static_cast<const CArmedInstance*>(getObj(objid)); | 	const CArmedInstance* obj = static_cast<const CArmedInstance*>(getObj(objid)); | ||||||
| 	CCreatureSet newArmy = obj->getArmy(); | 	CCreatureSet newArmy = obj->getArmy(); | ||||||
| 	while (creatures.size() > 0) | 	while (creatures.size()) | ||||||
| 	{ | 	{ | ||||||
| 		int slot = newArmy.getSlotFor(creatures.begin()->second.type->idNumber); | 		int slot = newArmy.getSlotFor(creatures.begin()->second.type->idNumber); | ||||||
| 		if (slot < 0) | 		if (slot < 0) | ||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 		newArmy.slots[slot].type = creatures.begin()->second.type; | 		newArmy.slots[slot].type = creatures.begin()->second.type; | ||||||
| 		newArmy.slots[slot].count -= creatures.begin()->second.count; | 		newArmy.slots[slot].count -= creatures.begin()->second.count; | ||||||
|  | 		if (newArmy.getStack(slot).count < 1) | ||||||
|  | 			newArmy.eraseStack(slot); | ||||||
| 		creatures.erase (creatures.begin()); | 		creatures.erase (creatures.begin()); | ||||||
| 	} | 	} | ||||||
| 	SetGarrisons sg; | 	SetGarrisons sg; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user