2017-07-13 10:26:03 +02:00
|
|
|
/*
|
|
|
|
* CEmptyAI.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2011-12-14 00:23:17 +03:00
|
|
|
#include "StdInc.h"
|
2007-10-17 01:41:45 +03:00
|
|
|
#include "CEmptyAI.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
|
2014-04-18 19:45:47 +03:00
|
|
|
#include "../../lib/CRandomGenerator.h"
|
2023-07-18 20:43:53 +02:00
|
|
|
#include "../../lib/CStack.h"
|
2023-08-17 18:18:14 +02:00
|
|
|
#include "../../lib/battle/BattleAction.h"
|
2014-04-10 20:11:09 +03:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
void CEmptyAI::saveGame(BinarySerializer & h, const int version)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CEmptyAI::loadGame(BinaryDeserializer & h, const int version)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-12-07 21:50:45 +02:00
|
|
|
void CEmptyAI::initGameInterface(std::shared_ptr<Environment> ENV, std::shared_ptr<CCallback> CB)
|
2007-10-21 19:45:13 +03:00
|
|
|
{
|
|
|
|
cb = CB;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
env = ENV;
|
2007-10-21 19:45:13 +03:00
|
|
|
human=false;
|
2023-08-30 21:07:02 +02:00
|
|
|
playerID = *cb->getPlayerID();
|
2007-10-21 19:45:13 +03:00
|
|
|
}
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
|
2023-08-28 02:42:05 +02:00
|
|
|
void CEmptyAI::yourTurn(QueryID queryID)
|
2007-10-17 01:41:45 +03:00
|
|
|
{
|
2023-08-28 02:42:05 +02:00
|
|
|
cb->selectionMade(0, queryID);
|
2008-07-27 20:07:37 +03:00
|
|
|
cb->endTurn();
|
2007-10-17 01:41:45 +03:00
|
|
|
}
|
2012-07-15 18:34:00 +03:00
|
|
|
|
2023-08-28 17:59:12 +02:00
|
|
|
void CEmptyAI::activeStack(const BattleID & battleID, const CStack * stack)
|
2023-07-18 20:43:53 +02:00
|
|
|
{
|
2023-08-28 17:59:12 +02:00
|
|
|
cb->battleMakeUnitAction(battleID, BattleAction::makeDefend(stack));
|
2023-07-18 20:43:53 +02:00
|
|
|
}
|
|
|
|
|
2023-08-28 17:59:12 +02:00
|
|
|
void CEmptyAI::yourTacticPhase(const BattleID & battleID, int distance)
|
2023-07-18 20:43:53 +02:00
|
|
|
{
|
2023-08-28 17:59:12 +02:00
|
|
|
cb->battleMakeTacticAction(battleID, BattleAction::makeEndOFTacticPhase(cb->getBattle(battleID)->battleGetTacticsSide()));
|
2023-07-18 20:43:53 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 20:43:50 +02:00
|
|
|
void CEmptyAI::heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID)
|
2007-10-17 01:41:45 +03:00
|
|
|
{
|
2020-10-01 10:38:06 +02:00
|
|
|
cb->selectionMade(CRandomGenerator::getDefault().nextInt((int)skills.size() - 1), queryID);
|
2007-10-17 01:41:45 +03:00
|
|
|
}
|
2012-06-01 18:59:26 +03:00
|
|
|
|
2013-05-27 17:20:46 +03:00
|
|
|
void CEmptyAI::commanderGotLevel(const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID)
|
2007-10-17 01:41:45 +03:00
|
|
|
{
|
2020-10-01 10:38:06 +02:00
|
|
|
cb->selectionMade(CRandomGenerator::getDefault().nextInt((int)skills.size() - 1), queryID);
|
2007-10-17 01:41:45 +03:00
|
|
|
}
|
2012-06-01 18:59:26 +03:00
|
|
|
|
2013-05-27 17:20:46 +03:00
|
|
|
void CEmptyAI::showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel)
|
2007-10-17 01:41:45 +03:00
|
|
|
{
|
2012-06-01 18:59:26 +03:00
|
|
|
cb->selectionMade(0, askID);
|
2008-08-13 03:44:31 +03:00
|
|
|
}
|
2012-06-01 18:59:26 +03:00
|
|
|
|
2023-09-15 21:18:36 +02:00
|
|
|
void CEmptyAI::showTeleportDialog(const CGHeroInstance * hero, TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID)
|
2015-03-08 15:52:50 +02:00
|
|
|
{
|
|
|
|
cb->selectionMade(0, askID);
|
|
|
|
}
|
|
|
|
|
2013-05-27 17:20:46 +03:00
|
|
|
void CEmptyAI::showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID)
|
2008-08-13 03:44:31 +03:00
|
|
|
{
|
2012-07-15 18:34:00 +03:00
|
|
|
cb->selectionMade(0, queryID);
|
2013-04-11 18:58:01 +03:00
|
|
|
}
|
2017-06-06 06:53:51 +02:00
|
|
|
|
|
|
|
void CEmptyAI::showMapObjectSelectDialog(QueryID askID, const Component & icon, const MetaString & title, const MetaString & description, const std::vector<ObjectInstanceID> & objects)
|
|
|
|
{
|
|
|
|
cb->selectionMade(0, askID);
|
|
|
|
}
|
2023-08-17 18:18:14 +02:00
|
|
|
|
2023-08-28 17:59:12 +02:00
|
|
|
std::optional<BattleAction> CEmptyAI::makeSurrenderRetreatDecision(const BattleID & battleID, const BattleStateInfoForRetreat & battleState)
|
2023-08-17 18:18:14 +02:00
|
|
|
{
|
|
|
|
return std::nullopt;
|
|
|
|
}
|