mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +02:00
- No battle actions will be available during tactics phase
- Fixed moving stacks during tactics - Fixed Genie spell targeting - Fixed AI getting stuck at Tree of Knowledge when no resources
This commit is contained in:
@ -2666,6 +2666,12 @@ bool shouldVisit (const CGHeroInstance * h, const CGObjectInstance * obj)
|
||||
case Obj::LIBRARY_OF_ENLIGHTENMENT:
|
||||
if (h->level < 12)
|
||||
return false;
|
||||
case Obj::TREE_OF_KNOWLEDGE:
|
||||
{
|
||||
TResources myRes = ai->myCb->getResourceAmount();
|
||||
if (myRes[Res::GOLD] - GOLD_RESERVE < 2000 || myRes[Res::GEMS] < 10)
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1941,14 +1941,9 @@ void CBattleInterface::activateStack()
|
||||
{
|
||||
stackCanCastSpell = true;
|
||||
if(randomSpellcaster)
|
||||
creatureSpellToCast = -1;
|
||||
else
|
||||
creatureSpellToCast = curInt->cb->battleGetRandomStackSpell(s, CBattleInfoCallback::RANDOM_AIMED); //faerie dragon can cast only one spell until their next move
|
||||
else
|
||||
creatureSpellToCast = spellcaster->subtype;
|
||||
|
||||
if(creatureSpellToCast < 0) //TODO proper way of detecting casters of positive spells
|
||||
spellSelMode = FRIENDLY_CREATURE_SPELL;
|
||||
else
|
||||
spellSelMode = selectionTypeByPositiveness(*CGI->spellh->spells[creatureSpellToCast]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1996,6 +1991,12 @@ void CBattleInterface::endCastingSpell()
|
||||
void CBattleInterface::getPossibleActionsForStack(const CStack * stack)
|
||||
{
|
||||
possibleActions.clear();
|
||||
if (tacticsMode)
|
||||
{
|
||||
possibleActions += MOVE_TACTICS, CHOOSE_TACTICS_STACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
//first action will be prioritized over later ones
|
||||
if (stack->casts) //TODO: check for battlefield effects that prevent casting?
|
||||
{
|
||||
@ -2052,7 +2053,7 @@ void CBattleInterface::getPossibleActionsForStack(const CStack * stack)
|
||||
possibleActions.push_back (CATAPULT);
|
||||
if (stack->hasBonusOfType (Bonus::HEALER))
|
||||
possibleActions.push_back (HEAL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
|
||||
@ -2602,8 +2603,6 @@ void CBattleInterface::bTacticNextStack(const CStack *current /*= NULL*/)
|
||||
else
|
||||
stackActivated(stacksOfMine.front());
|
||||
|
||||
possibleActions.clear();
|
||||
possibleActions += MOVE_TACTICS, CHOOSE_TACTICS_STACK;
|
||||
}
|
||||
|
||||
CBattleInterface::PossibleActions CBattleInterface::selectionTypeByPositiveness(const CSpell & spell)
|
||||
@ -2702,17 +2701,14 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case MOVE_TACTICS:
|
||||
break;
|
||||
case CHOOSE_TACTICS_STACK:
|
||||
if (shere && ourStack)
|
||||
legalAction = true;
|
||||
break;
|
||||
case MOVE_TACTICS:
|
||||
case MOVE_STACK:
|
||||
{
|
||||
if (canStackMoveHere (sactive, myNumber))
|
||||
if (canStackMoveHere (sactive, myNumber) && !shere)
|
||||
legalAction = true;
|
||||
}
|
||||
break;
|
||||
case ATTACK:
|
||||
case WALK_AND_ATTACK:
|
||||
@ -2749,7 +2745,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
||||
break;
|
||||
case RANDOM_GENIE_SPELL:
|
||||
{
|
||||
if (shere)
|
||||
if (shere && ourStack && shere != sactive) //only positive spells for other allied creatures
|
||||
{
|
||||
int spellID = curInt->cb->battleGetRandomStackSpell(shere, CBattleInfoCallback::RANDOM_GENIE);
|
||||
if (spellID > -1)
|
||||
@ -2829,8 +2825,9 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
||||
consoleMsg = (boost::format(CGI->generaltexth->allTexts[481]) % shere->getName()).str(); //Select %s
|
||||
realizeAction = [=]{ stackActivated(shere); };
|
||||
break;
|
||||
case MOVE_TACTICS:
|
||||
case MOVE_STACK:
|
||||
if(activeStack->hasBonusOfType(Bonus::FLYING))
|
||||
if (activeStack->hasBonusOfType(Bonus::FLYING))
|
||||
{
|
||||
cursorFrame = ECursor::COMBAT_FLY;
|
||||
consoleMsg = (boost::format(CGI->generaltexth->allTexts[295]) % activeStack->getName()).str(); //Fly %s here
|
||||
@ -2843,7 +2840,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
||||
|
||||
realizeAction = [=]
|
||||
{
|
||||
if(activeStack->doubleWide())
|
||||
if (activeStack->doubleWide())
|
||||
{
|
||||
std::vector<BattleHex> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
|
||||
int shiftedDest = myNumber + (activeStack->attackerOwned ? 1 : -1);
|
||||
@ -2854,7 +2851,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
||||
}
|
||||
else
|
||||
{
|
||||
giveCommand(BattleAction::WALK, myNumber, activeStack->ID);
|
||||
giveCommand (BattleAction::WALK, myNumber, activeStack->ID);
|
||||
}
|
||||
};
|
||||
break;
|
||||
@ -2867,7 +2864,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
||||
realizeAction = [=]
|
||||
{
|
||||
BattleHex attackFromHex = fromWhichHexAttack(myNumber);
|
||||
if(attackFromHex >= 0) //we can be in this line when unreachable creature is L - clicked (as of revision 1308)
|
||||
if (attackFromHex >= 0) //we can be in this line when unreachable creature is L - clicked (as of revision 1308)
|
||||
{
|
||||
giveCommand(BattleAction::WALK_AND_ATTACK, attackFromHex, activeStack->ID, myNumber);
|
||||
}
|
||||
|
@ -959,7 +959,7 @@ CCommanderInstance::CCommanderInstance (TCreature id)
|
||||
name = "Commando"; //TODO - parse them
|
||||
}
|
||||
|
||||
void CCommanderInstance::init() //called only after CStackInstance::init was executed
|
||||
void CCommanderInstance::init()
|
||||
{
|
||||
alive = true;
|
||||
experience = 0;
|
||||
|
@ -205,6 +205,7 @@ namespace Obj
|
||||
SHIPWRECK = 85,
|
||||
STABLES = 94,
|
||||
TRADING_POST = 99,
|
||||
TREE_OF_KNOWLEDGE = 102,
|
||||
SUBTERRANEAN_GATE = 103,
|
||||
UNIVERSITY = 104,
|
||||
SCHOOL_OF_WAR = 107,
|
||||
|
Reference in New Issue
Block a user