Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for arrow cart at bank fights #560

Merged
merged 1 commit into from Mar 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 19 additions & 6 deletions lib/CStack.cpp
Expand Up @@ -304,17 +304,30 @@ int32_t CStack::unitBaseAmount() const

bool CStack::unitHasAmmoCart(const battle::Unit * unit) const
{
bool hasAmmoCart = false;

for(const CStack * st : battle->stacks)
{
if(battle->battleMatchOwner(st, unit, true) && st->getCreature()->idNumber == CreatureID::AMMO_CART && st->alive())
if(battle->battleMatchOwner(st, unit, true) && st->getCreature()->idNumber == CreatureID::AMMO_CART)
{
if(st->alive())
{
return true;
}
else
{
return false;
}
}
}
//ammo cart works during creature bank battle while not on battlefield
auto ownerHero = battle->battleGetOwnerHero(unit);
if(ownerHero && ownerHero->artifactsWorn.find(ArtifactPosition::MACH2) != ownerHero->artifactsWorn.end())
{
if(battle->battleGetOwnerHero(unit)->artifactsWorn.at(ArtifactPosition::MACH2).artifact->artType->id == ArtifactID::AMMO_CART)
{
hasAmmoCart = true;
break;
return true;
}
}
return hasAmmoCart;
return false; //will be always false if trying to examine enemy hero in "special battle"
}

PlayerColor CStack::unitEffectiveOwner(const battle::Unit * unit) const
Expand Down