mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-21 21:17:49 +02:00
end with auto combat
This commit is contained in:
parent
4d0c0f10a9
commit
e8c541f873
client
@ -60,6 +60,7 @@ BattleWindow::BattleWindow(BattleInterface & owner):
|
||||
addShortcut(EShortcut::BATTLE_SURRENDER, std::bind(&BattleWindow::bSurrenderf, this));
|
||||
addShortcut(EShortcut::BATTLE_RETREAT, std::bind(&BattleWindow::bFleef, this));
|
||||
addShortcut(EShortcut::BATTLE_AUTOCOMBAT, std::bind(&BattleWindow::bAutofightf, this));
|
||||
addShortcut(EShortcut::BATTLE_END_WITH_AUTOCOMBAT, std::bind(&BattleWindow::endWithAutocombat, this));
|
||||
addShortcut(EShortcut::BATTLE_CAST_SPELL, std::bind(&BattleWindow::bSpellf, this));
|
||||
addShortcut(EShortcut::BATTLE_WAIT, std::bind(&BattleWindow::bWaitf, this));
|
||||
addShortcut(EShortcut::BATTLE_DEFEND, std::bind(&BattleWindow::bDefencef, this));
|
||||
@ -722,6 +723,7 @@ void BattleWindow::blockUI(bool on)
|
||||
setShortcutBlocked(EShortcut::BATTLE_DEFEND, on || owner.tacticsMode);
|
||||
setShortcutBlocked(EShortcut::BATTLE_SELECT_ACTION, on || owner.tacticsMode);
|
||||
setShortcutBlocked(EShortcut::BATTLE_AUTOCOMBAT, owner.actionsController->spellcastingModeActive());
|
||||
setShortcutBlocked(EShortcut::BATTLE_END_WITH_AUTOCOMBAT, on || owner.tacticsMode);
|
||||
setShortcutBlocked(EShortcut::BATTLE_TACTICS_END, on && owner.tacticsMode);
|
||||
setShortcutBlocked(EShortcut::BATTLE_TACTICS_NEXT, on && owner.tacticsMode);
|
||||
setShortcutBlocked(EShortcut::BATTLE_CONSOLE_DOWN, on && !owner.tacticsMode);
|
||||
@ -733,6 +735,27 @@ std::optional<uint32_t> BattleWindow::getQueueHoveredUnitId()
|
||||
return queue->getHoveredUnitIdIfAny();
|
||||
}
|
||||
|
||||
void BattleWindow::endWithAutocombat()
|
||||
{
|
||||
close();
|
||||
|
||||
auto ai = CDynLibHandler::getNewBattleAI(settings["server"]["friendlyAI"].String());
|
||||
|
||||
AutocombatPreferences autocombatPreferences = AutocombatPreferences();
|
||||
autocombatPreferences.enableSpellsUsage = settings["battle"]["enableAutocombatSpells"].Bool();
|
||||
|
||||
ai->initBattleInterface(owner.curInt->env, owner.curInt->cb, autocombatPreferences);
|
||||
ai->battleStart(owner.getBattleID(), owner.army1, owner.army2, int3(0,0,0), owner.attackingHeroInstance, owner.defendingHeroInstance, owner.getBattle()->battleGetMySide(), false);
|
||||
|
||||
owner.curInt->isAutoFightOn = true;
|
||||
owner.curInt->cb->registerBattleInterface(ai);
|
||||
owner.curInt->autofightingAI = ai;
|
||||
|
||||
owner.requestAutofightingAIToTakeAction();
|
||||
|
||||
owner.curInt->battleInt.reset();
|
||||
}
|
||||
|
||||
void BattleWindow::showAll(Canvas & to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
|
@ -125,5 +125,8 @@ public:
|
||||
|
||||
/// Set possible alternative options. If more than 1 - the last will be considered as default option
|
||||
void setAlternativeActions(const std::list<PossiblePlayerBattleAction> &);
|
||||
|
||||
/// ends battle with autocombat
|
||||
void endWithAutocombat();
|
||||
};
|
||||
|
||||
|
@ -125,6 +125,7 @@ enum class EShortcut
|
||||
BATTLE_SURRENDER,
|
||||
BATTLE_RETREAT,
|
||||
BATTLE_AUTOCOMBAT,
|
||||
BATTLE_END_WITH_AUTOCOMBAT,
|
||||
BATTLE_CAST_SPELL,
|
||||
BATTLE_WAIT,
|
||||
BATTLE_DEFEND,
|
||||
|
@ -124,6 +124,7 @@ std::vector<EShortcut> ShortcutHandler::translateKeycode(SDL_Keycode key) const
|
||||
{SDLK_s, EShortcut::BATTLE_SURRENDER },
|
||||
{SDLK_r, EShortcut::BATTLE_RETREAT },
|
||||
{SDLK_a, EShortcut::BATTLE_AUTOCOMBAT },
|
||||
{SDLK_e, EShortcut::BATTLE_END_WITH_AUTOCOMBAT},
|
||||
{SDLK_c, EShortcut::BATTLE_CAST_SPELL },
|
||||
{SDLK_w, EShortcut::BATTLE_WAIT },
|
||||
{SDLK_d, EShortcut::BATTLE_DEFEND },
|
||||
@ -265,6 +266,7 @@ EShortcut ShortcutHandler::findShortcut(const std::string & identifier ) const
|
||||
{"battleSurrender", EShortcut::BATTLE_SURRENDER },
|
||||
{"battleRetreat", EShortcut::BATTLE_RETREAT },
|
||||
{"battleAutocombat", EShortcut::BATTLE_AUTOCOMBAT },
|
||||
{"battleAutocombatEnd", EShortcut::BATTLE_END_WITH_AUTOCOMBAT},
|
||||
{"battleCastSpell", EShortcut::BATTLE_CAST_SPELL },
|
||||
{"battleWait", EShortcut::BATTLE_WAIT },
|
||||
{"battleDefend", EShortcut::BATTLE_DEFEND },
|
||||
|
Loading…
x
Reference in New Issue
Block a user