2021-05-15 21:04:26 +02:00
|
|
|
/*
|
|
|
|
* DangerHitMapAnalyzer.h, 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
|
|
|
|
*
|
|
|
|
*/
|
2021-05-15 20:57:36 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../VCAI.h"
|
|
|
|
|
|
|
|
struct HitMapInfo
|
|
|
|
{
|
|
|
|
uint64_t danger;
|
|
|
|
uint8_t turn;
|
2021-05-16 12:53:32 +02:00
|
|
|
const CGHeroInstance * hero;
|
2021-05-15 20:57:36 +02:00
|
|
|
|
|
|
|
void reset()
|
|
|
|
{
|
|
|
|
danger = 0;
|
|
|
|
turn = 255;
|
2021-05-16 12:53:32 +02:00
|
|
|
hero = nullptr;
|
2021-05-15 20:57:36 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HitMapNode
|
|
|
|
{
|
|
|
|
HitMapInfo maximumDanger;
|
|
|
|
HitMapInfo fastestDanger;
|
|
|
|
|
|
|
|
void reset()
|
|
|
|
{
|
|
|
|
maximumDanger.reset();
|
|
|
|
fastestDanger.reset();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class DangerHitMapAnalyzer
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
boost::multi_array<HitMapNode, 3> hitMap;
|
2021-05-16 13:13:35 +02:00
|
|
|
std::map<const CGHeroInstance *, std::set<const CGObjectInstance *>> enemyHeroAccessibleObjects;
|
|
|
|
bool upToDate;
|
2020-05-04 17:58:43 +02:00
|
|
|
const Nullkiller * ai;
|
2021-05-15 20:57:36 +02:00
|
|
|
|
|
|
|
public:
|
2020-05-04 17:58:43 +02:00
|
|
|
DangerHitMapAnalyzer(const Nullkiller * ai) :ai(ai) {}
|
|
|
|
|
2021-05-15 20:57:36 +02:00
|
|
|
void updateHitMap();
|
|
|
|
uint64_t enemyCanKillOurHeroesAlongThePath(const AIPath & path) const;
|
2021-05-16 13:13:35 +02:00
|
|
|
const HitMapNode & getObjectTreat(const CGObjectInstance * obj) const;
|
|
|
|
const std::set<const CGObjectInstance *> & getOneTurnAccessibleObjects(const CGHeroInstance * enemy) const;
|
|
|
|
void reset();
|
2021-05-15 21:04:26 +02:00
|
|
|
};
|