WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
Creature.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef WORLDSIM_CREATURE_HPP
3 #define WORLDSIM_CREATURE_HPP
4 
5 /* WorldSim: Creature
6  #include "Creature.hpp"
7 
8  Creatures are non-civilised actors. They are no members of Tribes or Civilisations, and don't have a race.
9  For now they are randomly spawned in. In the future I'd like them to have realistic behaviour,
10  for example travelling in groups and looking for food.
11 
12  Creatures may be herbivores or carnivores. Each creature type may have its own AI package.
13 
14  Creatures are usually simulated using the abstract data layer.
15 
16  Creature should refer to the base type. Creature_Implementation should refer to infividual Creature instances.
17  This also provides the opportunity to later divide Creature instances into Creature_Abstract and fully detailed
18  instances.
19 
20 */
21 
22 #include <Game/Calendar/Calendar.hpp>
23 #include <Container/Table/TableInterface.hpp>
24 
25 #include "WorldObject.hpp"
26 #include "Creature_Knowledge.hpp"
27 
28 class World_Local;
29 
30 #include "Creature_Attack.hpp"
31 
32 #include "Creature_Species.hpp"
33 
34 class Creature: public WorldObject, public TableInterface
35 {
36  public:
37 
38  bool isMale;
39  int age; /* In ticks */
40  int daysCounter; /* 0-360 */
41  int secondsCounter; /* 0 - 86,400 */
42 
43  bool isCarnivore; /* Creature can eat other animals. Otherwise the creature is a herbivore */
44  /* Herbivores are reliant on the grass and plants on their map */
45  // Home biome - Biome the creature is evolved for.
46 
47 
48  int actionPoints; /* Base: 100. Points are deducted for each action. */
49 
50  bool isAlive;
51 
52  int health;
53 
54  // Creatures also need to eat and drink.
55  // However herbivores can eat grass.
56  int hunger;
57  int thirst;
58 
59  short int fleeCounter; /* How many more turns the Creature should flee for. */
60 
61  // All loaded creatures can get a link to their world.
63 
64  //Creature's knowledge of the world (optional).
66 
68 
69  // INTERACTION
70  int nPelt; /* How many pelts you can harvest from the creature. */
71  int nMeat; /* How many meats you can harvest from the creature. */
72 
73  // ATTACK
74  // Creatures might get a choice of attacks kinda like Pokemon.
75  // For example an elephant might gore you with its tusks, or stomp on you.
76  // A dragon might slash you with its claws or breathe fire.
77  // Creatures may pick these attacks randomly or intelligently, depending on the creature.
78  Vector <Creature_Attack*> vAttack;
79 
80  Texture * baseTexture;
81 
82  // short int baseAtkSlash;
83  // short int baseAtkStab;
84  // short int baseAtkBlunt;
85 
86 
87  // INITIALIZATION
88  Creature();
89  // Initialise, including roll for stats. 0 - Roll gender. 1 - Male. 2 - Female.
90  void init( int _sex = 0);
91 
92  /* AI FUNCTIONS
93 
94  */
95  virtual void incrementTicks(int = 1);
96 
97  virtual void wander() override;
98 
99  Texture* currentTexture () override;
100 
101  void die();
102 
103  // KNOWLEDGE
104 
105  //returns true if the Creature has seen this tile.
106  bool hasSeen( World_Local* /* _map */, int /* _x */, int /* _y */ );
107 
108 
109  /* TABLE INTERFACE */
110  std::string getColumn(std::string _column) override;
111  std::string getColumnType(std::string _column) override;
112 
113 
114  /* COMBAT FUNCTIONS */
115 
116  //Attack a Creature once.
117  virtual void attack (Creature*, Creature_Attack*) {}
118  virtual void attack (Character*, Creature_Attack*) {}
119 
120  //Update knowledge with current instance.
121  void updateKnowledge();
122  // Extra processing available
123  void updateKnowledgeIdle();
124 
125  virtual std::string getName() override;
126 
127 
128 };
129 
130 // Footprints indicate the type of creature that walked here, the direction they were walking, and a rough
131 // estimate of how long ago they were here. Footprints disappear over time. Footprints will generally last
132 // a few hours.
133 // Footprints probably won't stack, it is assumed one set of footprints will make the others illegible.
134 // Todo: This could be updated to provide more than just footprints. For example droppings or blood.
135 // Class could be renamed as Evidence.
136 
138 {
139  public:
140 
143  int age;
144 
145  Texture* currentTexture () override;
146 };
147 
148 #include "Creature_Generator.hpp"
149 #include "Creature_Manager.cpp"
150 
151 #endif
bool isMale
Definition: Creature.hpp:38
Definition: Creature.hpp:34
short int fleeCounter
Definition: Creature.hpp:59
Definition: WorldObject.hpp:18
virtual void wander() override
Definition: Creature.cpp:91
Creature_Species * species
Definition: Creature.hpp:67
virtual void attack(Creature *, Creature_Attack *)
Definition: Creature.hpp:117
Texture * baseTexture
Definition: Creature.hpp:80
std::string getColumn(std::string _column) override
Definition: Creature.cpp:370
virtual std::string getName() override
Definition: Creature.cpp:358
bool isAlive
Definition: Creature.hpp:50
Creature()
Definition: Creature.cpp:18
int age
Definition: Creature.hpp:39
void updateKnowledgeIdle()
Definition: Creature.cpp:269
Creature * owner
Definition: Creature.hpp:141
Vector< Creature_Attack * > vAttack
Definition: Creature.hpp:78
bool hasSeen(World_Local *, int, int)
Definition: Creature.cpp:338
int nPelt
Definition: Creature.hpp:70
void updateKnowledge()
Definition: Creature.cpp:246
Definition: Creature.hpp:137
int direction
Definition: Creature.hpp:142
Definition: World_Local.hpp:58
std::string getColumnType(std::string _column) override
Definition: Creature.cpp:374
Texture * currentTexture() override
Definition: Creature.cpp:346
virtual void attack(Character *, Creature_Attack *)
Definition: Creature.hpp:118
bool isCarnivore
Definition: Creature.hpp:43
Definition: Creature_Attack.hpp:16
int secondsCounter
Definition: Creature.hpp:41
Definition: Character.hpp:38
int nMeat
Definition: Creature.hpp:71
int thirst
Definition: Creature.hpp:57
int hunger
Definition: Creature.hpp:56
virtual void incrementTicks(int=1)
Definition: Creature.cpp:61
int actionPoints
Definition: Creature.hpp:48
Definition: Creature_Species.hpp:23
World_Local * map
Definition: Creature.hpp:62
int age
Definition: Creature.hpp:143
int health
Definition: Creature.hpp:52
void die()
Definition: Creature.cpp:86
void init(int _sex=0)
Definition: Creature.cpp:47
int daysCounter
Definition: Creature.hpp:40
Definition: Creature_Knowledge.hpp:16
Creature_Knowledge * knowledge
Definition: Creature.hpp:65