1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Nullkiller: add engine and activate it for blue AI only. Engine does nothing

This commit is contained in:
Andrii Danylchenko 2021-05-15 19:23:05 +03:00 committed by Andrii Danylchenko
parent a88181acd7
commit 9c85e26d3c
7 changed files with 59 additions and 7 deletions

View File

View File

@ -0,0 +1,13 @@
#pragma once
#include "../VCAI.h"
class Behavior
{
};
class CaptureObjectBehavior : public Behavior
{
};

View File

@ -52,6 +52,8 @@ set(VCAI_SRCS
Goals/GetArtOfType.cpp
Goals/FindObj.cpp
Goals/CompleteQuest.cpp
Engine/Nullkiller.cpp
Behaviors/Behavior.cpp
main.cpp
VCAI.cpp
)
@ -107,6 +109,8 @@ set(VCAI_HEADERS
Goals/FindObj.h
Goals/CompleteQuest.h
Goals/Goals.h
Engine/Nullkiller.h
Behaviors/Behavior.h
VCAI.h
)

View File

@ -0,0 +1,8 @@
#include "StdInc.h"
#include "Nullkiller.h"
#include "../VCAI.h"
void Nullkiller::makeTurn()
{
}

View File

@ -0,0 +1,7 @@
#pragma once
class Nullkiller
{
public:
void makeTurn();
};

View File

@ -26,6 +26,7 @@
#include "../../lib/serializer/BinaryDeserializer.h"
#include "AIhelper.h"
#include "Engine/Nullkiller.h"
extern FuzzyHelper * fh;
@ -595,6 +596,11 @@ void VCAI::init(std::shared_ptr<CCallback> CB)
if(!fh)
fh = new FuzzyHelper();
if(playerID.getStr(false) == "blue")
{
nullkiller.reset(new Nullkiller());
}
retrieveVisitableObjs();
}
@ -791,17 +797,29 @@ void VCAI::makeTurn()
markHeroAbleToExplore(primaryHero());
visitedHeroes.clear();
if(cb->getDate(Date::DAY) == 1)
{
retrieveVisitableObjs();
}
try
{
//it looks messy here, but it's better to have armed heroes before attempting realizing goals
for (const CGTownInstance * t : cb->getTownsInfo())
moveCreaturesToHero(t);
if(nullkiller)
{
nullkiller->makeTurn();
}
else
{
//it looks messy here, but it's better to have armed heroes before attempting realizing goals
for(const CGTownInstance * t : cb->getTownsInfo())
moveCreaturesToHero(t);
mainLoop();
mainLoop();
/*Below function is also responsible for hero movement via internal wander function. By design it is separate logic for heroes that have nothing to do.
Heroes that were not picked by striveToGoal(sptr(Goals::Win())); recently (so they do not have new goals and cannot continue/reevaluate previously locked goals) will do logic in wander().*/
performTypicalActions();
/*Below function is also responsible for hero movement via internal wander function. By design it is separate logic for heroes that have nothing to do.
Heroes that were not picked by striveToGoal(sptr(Goals::Win())); recently (so they do not have new goals and cannot continue/reevaluate previously locked goals) will do logic in wander().*/
performTypicalActions();
}
//for debug purpose
for (auto h : cb->getHeroesInfo())

View File

@ -29,6 +29,7 @@
struct QuestInfo;
class AIhelper;
class Nullkiller;
class AIStatus
{
@ -115,6 +116,7 @@ public:
ObjectInstanceID selectedObject;
AIhelper * ah;
std::unique_ptr<Nullkiller> nullkiller;
VCAI();
virtual ~VCAI();