mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
* minor cleanup
This commit is contained in:
parent
ea03273c8e
commit
efedb1a55a
@ -41,7 +41,7 @@ ui8 side; //who made this action: false - left, true - right player
|
|||||||
/**
|
/**
|
||||||
* Implementation of CBattleLogic class.
|
* Implementation of CBattleLogic class.
|
||||||
*/
|
*/
|
||||||
CBattleLogic::CBattleLogic(ICallback *cb, const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side) :
|
CBattleLogic::CBattleLogic(ICallback *cb, const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) :
|
||||||
m_iCurrentTurn(-2),
|
m_iCurrentTurn(-2),
|
||||||
m_bIsAttacker(!side),
|
m_bIsAttacker(!side),
|
||||||
m_cb(cb),
|
m_cb(cb),
|
||||||
|
@ -63,7 +63,7 @@ private:
|
|||||||
int leftHitPoint_for_min; // scenario
|
int leftHitPoint_for_min; // scenario
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
CBattleLogic(ICallback *cb, const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side);
|
CBattleLogic(ICallback *cb, const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side);
|
||||||
~CBattleLogic();
|
~CBattleLogic();
|
||||||
|
|
||||||
void SetCurrentTurn(int turn);
|
void SetCurrentTurn(int turn);
|
||||||
@ -80,8 +80,8 @@ private:
|
|||||||
const CCreatureSet *m_army1;
|
const CCreatureSet *m_army1;
|
||||||
const CCreatureSet *m_army2;
|
const CCreatureSet *m_army2;
|
||||||
int3 m_tile;
|
int3 m_tile;
|
||||||
CGHeroInstance *m_hero1;
|
const CGHeroInstance *m_hero1;
|
||||||
CGHeroInstance *m_hero2;
|
const CGHeroInstance *m_hero2;
|
||||||
bool m_side;
|
bool m_side;
|
||||||
|
|
||||||
// statistics
|
// statistics
|
||||||
|
@ -1253,7 +1253,7 @@ void CGeniusAI::battleStacksAttacked(std::set<BattleStackAttacked>& bsa)
|
|||||||
/**
|
/**
|
||||||
* called by engine when battle starts; side=0 - left, side=1 - right
|
* called by engine when battle starts; side=0 - left, side=1 - right
|
||||||
*/
|
*/
|
||||||
void CGeniusAI::battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side)
|
void CGeniusAI::battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side)
|
||||||
{
|
{
|
||||||
// TODO: Battle logic what...
|
// TODO: Battle logic what...
|
||||||
assert(!m_battleLogic);
|
assert(!m_battleLogic);
|
||||||
@ -1331,11 +1331,11 @@ void CGeniusAI::battleSpellCast(BattleSpellCast *sc)
|
|||||||
/**
|
/**
|
||||||
* called when battlefield is prepared, prior the battle beginning
|
* called when battlefield is prepared, prior the battle beginning
|
||||||
*/
|
*/
|
||||||
void CGeniusAI::battlefieldPrepared(int battlefieldType,
|
// void CGeniusAI::battlefieldPrepared(int battlefieldType,
|
||||||
std::vector<CObstacle*> obstacles)
|
// std::vector<CObstacle*> obstacles)
|
||||||
{
|
// {
|
||||||
DbgBox("CGeniusAI::battlefieldPrepared");
|
// DbgBox("CGeniusAI::battlefieldPrepared");
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,8 +207,8 @@ public:
|
|||||||
virtual void battleNewRound(int round); //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
|
virtual void battleNewRound(int round); //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
|
||||||
virtual void battleStackMoved(int ID, int dest, int distance, bool end);
|
virtual void battleStackMoved(int ID, int dest, int distance, bool end);
|
||||||
virtual void battleSpellCast(BattleSpellCast *sc);
|
virtual void battleSpellCast(BattleSpellCast *sc);
|
||||||
virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right
|
virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right
|
||||||
virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles); //called when battlefield is prepared, prior the battle beginning
|
//virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles); //called when battlefield is prepared, prior the battle beginning
|
||||||
//
|
//
|
||||||
virtual void battleStackMoved(int ID, int dest, bool startMoving, bool endMoving);
|
virtual void battleStackMoved(int ID, int dest, bool startMoving, bool endMoving);
|
||||||
virtual void battleStackAttacking(int ID, int dest);
|
virtual void battleStackAttacking(int ID, int dest);
|
||||||
|
@ -120,8 +120,8 @@ public:
|
|||||||
virtual void battleStackMoved(int ID, int dest, int distance, bool end){};
|
virtual void battleStackMoved(int ID, int dest, int distance, bool end){};
|
||||||
virtual void battleSpellCast(BattleSpellCast *sc){};
|
virtual void battleSpellCast(BattleSpellCast *sc){};
|
||||||
virtual void battleStacksEffectsSet(SetStackEffect & sse){};//called when a specific effect is set to stacks
|
virtual void battleStacksEffectsSet(SetStackEffect & sse){};//called when a specific effect is set to stacks
|
||||||
virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side){}; //called by engine when battle starts; side=0 - left, side=1 - right
|
virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side){}; //called by engine when battle starts; side=0 - left, side=1 - right
|
||||||
virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles){}; //called when battlefield is prepared, prior the battle beginning
|
//virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles){}; //called when battlefield is prepared, prior the battle beginning
|
||||||
virtual void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom){}; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp
|
virtual void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom){}; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp
|
||||||
virtual void battleNewStackAppeared(int stackID){}; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
|
virtual void battleNewStackAppeared(int stackID){}; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
|
||||||
virtual void battleObstaclesRemoved(const std::set<si32> & removedObstacles){}; //called when a certain set of obstacles is removed from batlefield; IDs of them are given
|
virtual void battleObstaclesRemoved(const std::set<si32> & removedObstacles){}; //called when a certain set of obstacles is removed from batlefield; IDs of them are given
|
||||||
|
@ -2819,7 +2819,7 @@ void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
|
|||||||
void CBattleInterface::castThisSpell(int spellID)
|
void CBattleInterface::castThisSpell(int spellID)
|
||||||
{
|
{
|
||||||
BattleAction * ba = new BattleAction;
|
BattleAction * ba = new BattleAction;
|
||||||
ba->actionType = 1;
|
ba->actionType = BattleAction::HERO_SPELL;
|
||||||
ba->additionalInfo = spellID; //spell number
|
ba->additionalInfo = spellID; //spell number
|
||||||
ba->destinationTile = -1;
|
ba->destinationTile = -1;
|
||||||
ba->stackNumber = (attackingHeroInstance->tempOwner == curInt->playerID) ? -1 : -2;
|
ba->stackNumber = (attackingHeroInstance->tempOwner == curInt->playerID) ? -1 : -2;
|
||||||
@ -3009,7 +3009,7 @@ void CBattleInterface::showAliveStack(int ID, const std::map<int, CStack> & stac
|
|||||||
if(curStack.count > 0 //don't print if stack is not alive
|
if(curStack.count > 0 //don't print if stack is not alive
|
||||||
&& (!curInt->curAction
|
&& (!curInt->curAction
|
||||||
|| (curInt->curAction->stackNumber != ID //don't print if stack is currently taking an action
|
|| (curInt->curAction->stackNumber != ID //don't print if stack is currently taking an action
|
||||||
&& (curInt->curAction->actionType != 6 || curStack.position != curInt->curAction->additionalInfo) //nor if it's an object of attack
|
&& (curInt->curAction->actionType != BattleAction::WALK_AND_ATTACK || curStack.position != curInt->curAction->additionalInfo) //nor if it's an object of attack
|
||||||
&& (curInt->curAction->destinationTile != curStack.position) //nor if it's on destination tile for current action
|
&& (curInt->curAction->destinationTile != curStack.position) //nor if it's on destination tile for current action
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -3227,18 +3227,18 @@ void CBattleInterface::endAction(const BattleAction* action)
|
|||||||
// {
|
// {
|
||||||
// activate();
|
// activate();
|
||||||
// }
|
// }
|
||||||
if(action->actionType == 1)
|
if(action->actionType == BattleAction::HERO_SPELL)
|
||||||
{
|
{
|
||||||
if(action->side)
|
if(action->side)
|
||||||
defendingHero->setPhase(0);
|
defendingHero->setPhase(0);
|
||||||
else
|
else
|
||||||
attackingHero->setPhase(0);
|
attackingHero->setPhase(0);
|
||||||
}
|
}
|
||||||
if(action->actionType == 2 && creAnims[action->stackNumber]->getType() != 2) //walk or walk & attack
|
if(action->actionType == BattleAction::WALK && creAnims[action->stackNumber]->getType() != 2) //walk or walk & attack
|
||||||
{
|
{
|
||||||
pendingAnims.push_back(std::make_pair(new CBattleMoveEnd(this, action->stackNumber, action->destinationTile), false));
|
pendingAnims.push_back(std::make_pair(new CBattleMoveEnd(this, action->stackNumber, action->destinationTile), false));
|
||||||
}
|
}
|
||||||
if(action->actionType == 9) //catapult
|
if(action->actionType == BattleAction::CATAPULT) //catapult
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
queue->update();
|
queue->update();
|
||||||
@ -3280,11 +3280,11 @@ void CBattleInterface::startAction(const BattleAction* action)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(action->actionType == 1); //only cast spell is valid action without acting stack number
|
assert(action->actionType == BattleAction::HERO_SPELL); //only cast spell is valid action without acting stack number
|
||||||
}
|
}
|
||||||
|
|
||||||
if(action->actionType == 2
|
if(action->actionType == BattleAction::WALK
|
||||||
|| (action->actionType == 6 && action->destinationTile != stack->position))
|
|| (action->actionType == BattleAction::WALK_AND_ATTACK && action->destinationTile != stack->position))
|
||||||
{
|
{
|
||||||
moveStarted = true;
|
moveStarted = true;
|
||||||
if(creAnims[action->stackNumber]->framesInGroup(20))
|
if(creAnims[action->stackNumber]->framesInGroup(20))
|
||||||
@ -3298,7 +3298,7 @@ void CBattleInterface::startAction(const BattleAction* action)
|
|||||||
|
|
||||||
char txt[400];
|
char txt[400];
|
||||||
|
|
||||||
if(action->actionType == 1) //when hero casts spell
|
if(action->actionType == BattleAction::HERO_SPELL) //when hero casts spell
|
||||||
{
|
{
|
||||||
if(action->side)
|
if(action->side)
|
||||||
defendingHero->setPhase(4);
|
defendingHero->setPhase(4);
|
||||||
@ -3339,7 +3339,7 @@ void CBattleInterface::startAction(const BattleAction* action)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//displaying heal animation
|
//displaying heal animation
|
||||||
if (action->actionType == 12)
|
if (action->actionType == BattleAction::STACK_HEAL)
|
||||||
{
|
{
|
||||||
displayEffect(50, action->destinationTile);
|
displayEffect(50, action->destinationTile);
|
||||||
}
|
}
|
||||||
|
@ -537,7 +537,7 @@ void CPlayerInterface::buildChanged(const CGTownInstance *town, int buildingID,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayerInterface::battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side)
|
void CPlayerInterface::battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side)
|
||||||
{
|
{
|
||||||
if(LOCPLINT != this)
|
if(LOCPLINT != this)
|
||||||
{ //another local interface should do this
|
{ //another local interface should do this
|
||||||
@ -552,9 +552,6 @@ void CPlayerInterface::battleStart(const CCreatureSet *army1, const CCreatureSet
|
|||||||
GH.pushInt(battleInt);
|
GH.pushInt(battleInt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayerInterface::battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles) //called when battlefield is prepared, prior the battle beginning
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CPlayerInterface::battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom)
|
void CPlayerInterface::battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom)
|
||||||
{
|
{
|
||||||
|
@ -212,8 +212,7 @@ public:
|
|||||||
void battleSpellCast(BattleSpellCast *sc);
|
void battleSpellCast(BattleSpellCast *sc);
|
||||||
void battleStacksEffectsSet(SetStackEffect & sse); //called when a specific effect is set to stacks
|
void battleStacksEffectsSet(SetStackEffect & sse); //called when a specific effect is set to stacks
|
||||||
void battleStacksAttacked(std::vector<BattleStackAttacked> & bsa);
|
void battleStacksAttacked(std::vector<BattleStackAttacked> & bsa);
|
||||||
void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right
|
void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right
|
||||||
void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles); //called when battlefield is prepared, prior the battle beginning
|
|
||||||
void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom); //called when stacks are healed / resurrected
|
void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom); //called when stacks are healed / resurrected
|
||||||
void battleNewStackAppeared(int stackID); //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
|
void battleNewStackAppeared(int stackID); //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
|
||||||
void battleObstaclesRemoved(const std::set<si32> & removedObstacles); //called when a certain set of obstacles is removed from batlefield; IDs of them are given
|
void battleObstaclesRemoved(const std::set<si32> & removedObstacles); //called when a certain set of obstacles is removed from batlefield; IDs of them are given
|
||||||
|
@ -15,6 +15,10 @@ struct BattleAction
|
|||||||
{
|
{
|
||||||
ui8 side; //who made this action: false - left, true - right player
|
ui8 side; //who made this action: false - left, true - right player
|
||||||
ui32 stackNumber;//stack ID, -1 left hero, -2 right hero,
|
ui32 stackNumber;//stack ID, -1 left hero, -2 right hero,
|
||||||
|
enum ActionType
|
||||||
|
{
|
||||||
|
NO_ACTION = 0, HERO_SPELL, WALK, DEFEND, RETREAT, SURRENDER, WALK_AND_ATTACK, SHOOT, WAIT, CATAPULT, MONSTER_SPELL, BAD_MORALE, STACK_HEAL
|
||||||
|
};
|
||||||
ui8 actionType; // 0 = No action; 1 = Hero cast a spell 2 = Walk 3 = Defend 4 = Retreat from the battle
|
ui8 actionType; // 0 = No action; 1 = Hero cast a spell 2 = Walk 3 = Defend 4 = Retreat from the battle
|
||||||
//5 = Surrender 6 = Walk and Attack 7 = Shoot 8 = Wait 9 = Catapult
|
//5 = Surrender 6 = Walk and Attack 7 = Shoot 8 = Wait 9 = Catapult
|
||||||
//10 = Monster casts a spell (i.e. Faerie Dragons) 11 - Bad morale freeze 12 - stacks heals another stack
|
//10 = Monster casts a spell (i.e. Faerie Dragons) 11 - Bad morale freeze 12 - stacks heals another stack
|
||||||
|
@ -901,18 +901,20 @@ DLL_EXPORT void StartAction::applyGs( CGameState *gs )
|
|||||||
{
|
{
|
||||||
CStack *st = gs->curB->getStack(ba.stackNumber);
|
CStack *st = gs->curB->getStack(ba.stackNumber);
|
||||||
|
|
||||||
if(ba.actionType != 1) //don't check for stack if it's custom action by hero
|
if(ba.actionType != BattleAction::HERO_SPELL) //don't check for stack if it's custom action by hero
|
||||||
assert(st);
|
assert(st);
|
||||||
|
|
||||||
switch(ba.actionType)
|
switch(ba.actionType)
|
||||||
{
|
{
|
||||||
case 3:
|
case BattleAction::DEFEND:
|
||||||
st->state.insert(DEFENDING);
|
st->state.insert(DEFENDING);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case BattleAction::WAIT:
|
||||||
st->state.insert(WAITING);
|
st->state.insert(WAITING);
|
||||||
return;
|
return;
|
||||||
case 0: case 2: case 6: case 7: case 9: case 10: case 11: case 12:
|
case BattleAction::NO_ACTION: case BattleAction::WALK: case BattleAction::WALK_AND_ATTACK:
|
||||||
|
case BattleAction::SHOOT: case BattleAction::CATAPULT: case BattleAction::MONSTER_SPELL:
|
||||||
|
case BattleAction::BAD_MORALE: case BattleAction::STACK_HEAL:
|
||||||
st->state.insert(MOVED);
|
st->state.insert(MOVED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -347,16 +347,15 @@ void CGameHandler::startBattle(const CArmedInstance *army1, const CArmedInstance
|
|||||||
setupBattle(curB, tile, army1, army2, hero1, hero2, creatureBank, town); //initializes stacks, places creatures on battlefield, blocks and informs player interfaces
|
setupBattle(curB, tile, army1, army2, hero1, hero2, creatureBank, town); //initializes stacks, places creatures on battlefield, blocks and informs player interfaces
|
||||||
}
|
}
|
||||||
|
|
||||||
NEW_ROUND;
|
|
||||||
//TODO: pre-tactic stuff, call scripts etc.
|
//TODO: pre-tactic stuff, call scripts etc.
|
||||||
|
|
||||||
//tactic round
|
//tactic round
|
||||||
{
|
{
|
||||||
NEW_ROUND;
|
|
||||||
if( (hero1 && hero1->getSecSkillLevel(19)>0) ||
|
if( (hero1 && hero1->getSecSkillLevel(19)>0) ||
|
||||||
( hero2 && hero2->getSecSkillLevel(19)>0) )//someone has tactics
|
( hero2 && hero2->getSecSkillLevel(19)>0) )//someone has tactics
|
||||||
{
|
{
|
||||||
//TODO: tactic round (round -1)
|
//TODO: tactic round (round -1)
|
||||||
|
NEW_ROUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +401,7 @@ void CGameHandler::startBattle(const CArmedInstance *army1, const CArmedInstance
|
|||||||
{
|
{
|
||||||
//unit loses its turn - empty freeze action
|
//unit loses its turn - empty freeze action
|
||||||
BattleAction ba;
|
BattleAction ba;
|
||||||
ba.actionType = 11;
|
ba.actionType = BattleAction::BAD_MORALE;
|
||||||
ba.additionalInfo = 1;
|
ba.additionalInfo = 1;
|
||||||
ba.side = !next->attackerOwned;
|
ba.side = !next->attackerOwned;
|
||||||
ba.stackNumber = next->ID;
|
ba.stackNumber = next->ID;
|
||||||
@ -419,7 +418,7 @@ void CGameHandler::startBattle(const CArmedInstance *army1, const CArmedInstance
|
|||||||
if(attackInfo.first != NULL)
|
if(attackInfo.first != NULL)
|
||||||
{
|
{
|
||||||
BattleAction attack;
|
BattleAction attack;
|
||||||
attack.actionType = 6;
|
attack.actionType = BattleAction::WALK_AND_ATTACK;
|
||||||
attack.side = !next->attackerOwned;
|
attack.side = !next->attackerOwned;
|
||||||
attack.stackNumber = next->ID;
|
attack.stackNumber = next->ID;
|
||||||
|
|
||||||
@ -430,6 +429,10 @@ void CGameHandler::startBattle(const CArmedInstance *army1, const CArmedInstance
|
|||||||
|
|
||||||
checkForBattleEnd(stacks);
|
checkForBattleEnd(stacks);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
makeStackDoNothing(next);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,7 +442,7 @@ void CGameHandler::startBattle(const CArmedInstance *army1, const CArmedInstance
|
|||||||
|| (next->type->idNumber == 146 && (!curOwner || curOwner->getSecSkillLevel(20) == 0))) //ballista, hero has no artillery
|
|| (next->type->idNumber == 146 && (!curOwner || curOwner->getSecSkillLevel(20) == 0))) //ballista, hero has no artillery
|
||||||
{
|
{
|
||||||
BattleAction attack;
|
BattleAction attack;
|
||||||
attack.actionType = 7;
|
attack.actionType = BattleAction::SHOOT;
|
||||||
attack.side = !next->attackerOwned;
|
attack.side = !next->attackerOwned;
|
||||||
attack.stackNumber = next->ID;
|
attack.stackNumber = next->ID;
|
||||||
|
|
||||||
@ -464,7 +467,7 @@ void CGameHandler::startBattle(const CArmedInstance *army1, const CArmedInstance
|
|||||||
static const int wallHexes[] = {50, 183, 182, 130, 62, 29, 12, 95};
|
static const int wallHexes[] = {50, 183, 182, 130, 62, 29, 12, 95};
|
||||||
|
|
||||||
attack.destinationTile = wallHexes[ rand()%ARRAY_COUNT(wallHexes) ];
|
attack.destinationTile = wallHexes[ rand()%ARRAY_COUNT(wallHexes) ];
|
||||||
attack.actionType = 9;
|
attack.actionType = BattleAction::CATAPULT;
|
||||||
attack.additionalInfo = 0;
|
attack.additionalInfo = 0;
|
||||||
attack.side = !next->attackerOwned;
|
attack.side = !next->attackerOwned;
|
||||||
attack.stackNumber = next->ID;
|
attack.stackNumber = next->ID;
|
||||||
@ -490,21 +493,15 @@ void CGameHandler::startBattle(const CArmedInstance *army1, const CArmedInstance
|
|||||||
if(possibleStacks.size() == 0)
|
if(possibleStacks.size() == 0)
|
||||||
{
|
{
|
||||||
//nothing to heal
|
//nothing to heal
|
||||||
BattleAction doNothing;
|
makeStackDoNothing(next);
|
||||||
doNothing.actionType = 0;
|
|
||||||
doNothing.additionalInfo = 0;
|
|
||||||
doNothing.destinationTile = -1;
|
|
||||||
doNothing.side = !next->attackerOwned;
|
|
||||||
doNothing.stackNumber = next->ID;
|
|
||||||
sendAndApply(&StartAction(doNothing));
|
|
||||||
sendAndApply(&EndAction());
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//heal random creature
|
//heal random creature
|
||||||
const CStack * toBeHealed = possibleStacks[ rand()%possibleStacks.size() ];
|
const CStack * toBeHealed = possibleStacks[ rand()%possibleStacks.size() ];
|
||||||
heal.actionType = 12;
|
heal.actionType = BattleAction::STACK_HEAL;
|
||||||
heal.additionalInfo = 0;
|
heal.additionalInfo = 0;
|
||||||
heal.destinationTile = toBeHealed->position;
|
heal.destinationTile = toBeHealed->position;
|
||||||
heal.side = !next->attackerOwned;
|
heal.side = !next->attackerOwned;
|
||||||
@ -5317,3 +5314,15 @@ bool CGameHandler::sacrificeArtifact(const IMarket * m, const CGHeroInstance * h
|
|||||||
changePrimSkill(hero->id, 4, expToGive);
|
changePrimSkill(hero->id, 4, expToGive);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGameHandler::makeStackDoNothing(const CStack * next)
|
||||||
|
{
|
||||||
|
BattleAction doNothing;
|
||||||
|
doNothing.actionType = 0;
|
||||||
|
doNothing.additionalInfo = 0;
|
||||||
|
doNothing.destinationTile = -1;
|
||||||
|
doNothing.side = !next->attackerOwned;
|
||||||
|
doNothing.stackNumber = next->ID;
|
||||||
|
sendAndApply(&StartAction(doNothing));
|
||||||
|
sendAndApply(&EndAction());
|
||||||
|
}
|
||||||
|
@ -76,6 +76,8 @@ public:
|
|||||||
|
|
||||||
class CGameHandler : public IGameCallback
|
class CGameHandler : public IGameCallback
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
void makeStackDoNothing(const CStack * next);
|
||||||
public:
|
public:
|
||||||
CVCMIServer *s;
|
CVCMIServer *s;
|
||||||
std::map<int,CConnection*> connections; //player color -> connection to client with interface of that player
|
std::map<int,CConnection*> connections; //player color -> connection to client with interface of that player
|
||||||
@ -229,3 +231,5 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif // __CGAMEHANDLER_H__
|
#endif // __CGAMEHANDLER_H__
|
||||||
|
|
||||||
|
void makeStackDoNothing();
|
Loading…
Reference in New Issue
Block a user