mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Moved CGCreature to a new file
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CArmedInstance.h"
|
||||
#include "../ResourceSet.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
@@ -40,80 +39,6 @@ public:
|
||||
static constexpr int OBJPROP_VISITED = 10;
|
||||
};
|
||||
|
||||
class DLL_LINKAGE CGCreature : public CArmedInstance //creatures on map
|
||||
{
|
||||
public:
|
||||
enum Action {
|
||||
FIGHT = -2, FLEE = -1, JOIN_FOR_FREE = 0 //values > 0 mean gold price
|
||||
};
|
||||
|
||||
enum Character {
|
||||
COMPLIANT = 0, FRIENDLY = 1, AGRESSIVE = 2, HOSTILE = 3, SAVAGE = 4
|
||||
};
|
||||
|
||||
ui32 identifier; //unique code for this monster (used in missions)
|
||||
si8 character; //character of this set of creatures (0 - the most friendly, 4 - the most hostile) => on init changed to -4 (compliant) ... 10 value (savage)
|
||||
std::string message; //message printed for attacking hero
|
||||
TResources resources; // resources given to hero that has won with monsters
|
||||
ArtifactID gainedArtifact; //ID of artifact gained to hero, -1 if none
|
||||
bool neverFlees; //if true, the troops will never flee
|
||||
bool notGrowingTeam; //if true, number of units won't grow
|
||||
ui64 temppower; //used to handle fractional stack growth for tiny stacks
|
||||
|
||||
bool refusedJoining;
|
||||
|
||||
void onHeroVisit(const CGHeroInstance * h) const override;
|
||||
std::string getHoverText(PlayerColor player) const override;
|
||||
std::string getHoverText(const CGHeroInstance * hero) const override;
|
||||
void initObj(CRandomGenerator & rand) override;
|
||||
void newTurn(CRandomGenerator & rand) const override;
|
||||
void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
|
||||
void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
|
||||
|
||||
//stack formation depends on position,
|
||||
bool containsUpgradedStack() const;
|
||||
int getNumberOfStacks(const CGHeroInstance *hero) const;
|
||||
|
||||
struct DLL_LINKAGE formationInfo // info about merging stacks after battle back into one
|
||||
{
|
||||
si32 basicType;
|
||||
ui8 upgrade; //random seed used to determine number of stacks and is there's upgraded stack
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & basicType;
|
||||
h & upgrade;
|
||||
}
|
||||
} formation;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<CArmedInstance&>(*this);
|
||||
h & identifier;
|
||||
h & character;
|
||||
h & message;
|
||||
h & resources;
|
||||
h & gainedArtifact;
|
||||
h & neverFlees;
|
||||
h & notGrowingTeam;
|
||||
h & temppower;
|
||||
h & refusedJoining;
|
||||
h & formation;
|
||||
}
|
||||
protected:
|
||||
void setPropertyDer(ui8 what, ui32 val) override;
|
||||
void serializeJsonOptions(JsonSerializeFormat & handler) override;
|
||||
|
||||
private:
|
||||
void fight(const CGHeroInstance *h) const;
|
||||
void flee( const CGHeroInstance * h ) const;
|
||||
void fleeDecision(const CGHeroInstance *h, ui32 pursue) const;
|
||||
void joinDecision(const CGHeroInstance *h, int cost, ui32 accept) const;
|
||||
|
||||
int takenAction(const CGHeroInstance *h, bool allowJoin=true) const; //action on confrontation: -2 - fight, -1 - flee, >=0 - will join for given value of gold (may be 0)
|
||||
void giveReward(const CGHeroInstance * h) const;
|
||||
|
||||
};
|
||||
|
||||
class DLL_LINKAGE CGSignBottle : public CGObjectInstance //signs and ocean bottles
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user