OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
fightalgo.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
5#include <zenkit/addon/daedalus.hh>
6
7class Npc;
8class GameScript;
9class Serialize;
10
11class FightAlgo final {
12 public:
13 FightAlgo();
14
15 void load(Serialize& fin);
16 void save(Serialize& fout);
17
38
39 Action nextFromQueue(Npc &npc, Npc &tg, GameScript& owner);
40 void consumeAction();
41 void onClearTarget();
42 void onTakeHit();
43
44 bool hasInstructions() const;
45 bool fetchInstructions(Npc &npc, Npc &tg, GameScript& owner);
46
47 float baseDistance (const Npc &npc, const Npc &tg, GameScript &owner) const;
48 float prefferedAttackDistance(const Npc &npc, const Npc &tg, GameScript &owner) const;
49 float prefferedGDistance (const Npc &npc, const Npc &tg, GameScript &owner) const;
50 float attackFinishDistance (GameScript &owner) const;
51
52 bool isInAttackRange (const Npc &npc, const Npc &tg, GameScript &owner) const;
53 bool isInFinishRange (const Npc &npc, const Npc &tg, GameScript &owner) const;
54 bool isInWRange (const Npc &npc, const Npc &tg, GameScript &owner) const;
55 bool isInGRange (const Npc &npc, const Npc &tg, GameScript &owner) const;
56 bool isInFocusAngle (const Npc &npc, const Npc &tg) const;
57
58 private:
59 void fillQueue(Npc &npc, Npc &tg, GameScript& owner);
60 bool fillQueue(GameScript& owner, const zenkit::IFightAi& src);
61
62 static float weaponRange(GameScript &owner,const Npc &npc);
63
64 zenkit::FightAiMove queueId = zenkit::FightAiMove::NOP;
65 Action tr [MV_MAX]={};
66 bool hitFlg=false;
67 };
void load(Serialize &fin)
Definition fightalgo.cpp:19
Action nextFromQueue(Npc &npc, Npc &tg, GameScript &owner)
bool isInWRange(const Npc &npc, const Npc &tg, GameScript &owner) const
float prefferedGDistance(const Npc &npc, const Npc &tg, GameScript &owner) const
float prefferedAttackDistance(const Npc &npc, const Npc &tg, GameScript &owner) const
bool hasInstructions() const
float baseDistance(const Npc &npc, const Npc &tg, GameScript &owner) const
void save(Serialize &fout)
Definition fightalgo.cpp:26
@ MV_WAITLONG
Definition fightalgo.h:30
@ MV_JUMPBACK
Definition fightalgo.h:22
@ MV_TURN2HIT
Definition fightalgo.h:31
@ MV_STRAFE_E
Definition fightalgo.h:34
bool fetchInstructions(Npc &npc, Npc &tg, GameScript &owner)
float attackFinishDistance(GameScript &owner) const
void onClearTarget()
bool isInAttackRange(const Npc &npc, const Npc &tg, GameScript &owner) const
void onTakeHit()
bool isInFinishRange(const Npc &npc, const Npc &tg, GameScript &owner) const
bool isInGRange(const Npc &npc, const Npc &tg, GameScript &owner) const
void consumeAction()
bool isInFocusAngle(const Npc &npc, const Npc &tg) const
Definition npc.h:25
Action
Definition constants.h:341