WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
Item.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef WORLDSIM_ITEM_HPP
3 #define WORLDSIM_ITEM_HPP
4 
5 /* Item.cpp
6  #include"Item.hpp"
7 
8  An item is an object which can be picked up and manipulated. Items are reliant on
9  actors (Creatures/Characters) to be moved or used.
10 
11  Items cannot interfere with movement or line of sight.
12 
13  In the future stacking should be implemented for identical objects.
14 
15  Only items can be stored in an inventory.
16 
17  Item interaction is currently handled using double dispatch. It's possible to override this by using getName() as
18  a typeID.
19 
20 
21  I think in order to handle static resource requirements and dynamic stats, we need an ItemFactory class.
22 
23 */
24 
25 #include <Container/Table/TableInterface.hpp>
26 
27 #include "Item_Information.cpp"
28 
29 class Ammo
30 {
31  public:
32 
33  std::string name;
35 
36 };
37 
38 #include "LocalTile.hpp"
39 //#include "Character.hpp"
40 
41 class Character;
42 class Recipe;
43 
44 class Creature;
45 //class Creature_Deer;
46 
47 #include "Stockpile.hpp"
48 
49 #include "Item_Attributes.hpp"
50 
51 class Item: public WorldObject, public TableInterface, public Craftable /* HasStockpileRequirement */
52 {
53  public:
54 
55  //int x, y;
56  short int count; /* How many of this object there is (for example ammo) */
57 
58  ItemType type; /* The type of item. */
59 
61 
62  std::unordered_map<ItemAction, char> mAction; // list of actions this item can be used for
63 
64 
65  //unsigned char farmingValue; /* How well this works as a farming implement. 0 = not possible */
66  //unsigned char miningValue; /* How well this works as a mining implement. 0 = not possible */
67 
68  short int meleeDamage; /* Base damage if you hit someone with this. 0 = not possible. */
69  short int throwDamage; /* Base damage if you throw this at someone. 0 = not possible */
70 
71  short int reach;
72 
73  /* Ammunition might as well be hardcoded since there won't be too many different types. */
75 
76 
77  Character* owner; /* Set to 0 if nobody owns it */
78  //Character* creator; /* Character who created this item */
79 
80 
81  // CONSUMABLE PROPERTIES
82  int consumeTime; /* How long it takes to eat this. 0 = no time cost. -1 = you can't consume it. */
83  int hungerRestore; /* -1 = you can't eat it. 0 = you can eat it but get no hunger restored */
84 
86 
87  // INTERACTION PROPERTIES (currently Item specialisation isn't implemented,
88  // so Items can only interact with WorldObject).
89 
90 
91 
92  //Implementing full global coordinates to make life easier for now.
93  // This datatype should be able to hold coordinates for any reasonably-sized world.
94  //long unsigned int fullX, fullY;
95 
96 
97  /* TEMPORARY WORKAROUND TO ALLOW CHARACTERS TO MOVE ACROSS MAPS.
98  CURRENTLY ONLY USED FOR CHARACTERS
99  In future World_Local should distinguish between actors and objects */
100  //int worldX, worldY;
101 
102  //bool stackable; /* True if multiple objects of this class can be merged together into a single stack, sharing their data. */
103 
104  //double weight; /* in grams */
105  //double bulk; /* In cm^3 , and adjusted higher for cumbersome items.*/
106 
107  /* True if line of sight cannot pass this object.
108  Might be expanded in future. For example maybe a
109  crate will block view of people who are sneaking. */
110  //bool blocksView;
111 
112  /* True if characters and creatures cannot walk into this tile. */
113  //bool blocksMovement;
114 
115  Item();
116  virtual ~Item();
117 
118 
119  virtual std::string getName();
120  virtual std::string getExtendedInfo();
121 
122  virtual std::string getQuality();
123 
124 
125  /* ITEM INTERACTIONS
126  List of stuff the item can do.
127  */
128 
129  // ATTACK
130  // Anything is a weapon if you're desperate enough.
131  int slashDamage; /* Causes direct damage. */
132  int bluntDamage; /* Bypasses armour values and causes limb damage. */
133  int pierceDamage; /* Increases critical chance (piercing vital organs), but limited by armour. */
134  float throwMultiplier; /* How well this weapon can be thrown. Most weapons are less effective when thrown. */
135 
136  // Fishing
137  // ChopTree
138 
139  //Cost is base action points required. -1 means the action is not possible. 0 means no cost.
142 
143  // Used so Player can easily see what recipes an object is used for.
144  virtual bool canUseInRecipe(Recipe* _recipe)
145  {
146  std::cout<<"1\n";
147  return false;
148  }
149 
150  //int distanceTo(WorldObject*); /* Chebyshev (this one is distances where diagonal movement is allowed.) */
151  // int distanceFrom(WorldObject*); /* Alias. */
152 
153  //int distanceTo(int /* _x */, int /* _y */); /* Same, using raw coordinates */
154 
155 
156  // OBJECT INTERACTION
157  // In future these functions might need to be expanded to return multiple possibilities, for example
158  // "Stab target" and "Slash target". Or "Chop down door" and "Pry open door".
159  // The good thing about this approach is that it can list out all possible interactions between objects,
160  // which I think is better than making the player guess what everything does.
161  // There are different types of objects, such as Items, WorldObjects and LocalTiles.
162  virtual void interact (WorldObject* obj, int interactionType=0)
163  { std::cout<<"The "<<getName()<<" interacts with the "<<obj->getName()<<".\n"; }
164  virtual void interact (LocalTile* obj, int interactionType=0)
165  { std::cout<<"The "<<getName()<<" interacts with the "<<obj->getName()<<".\n"; }
166  virtual void interact (Item* obj, int interactionType=0)
167  { std::cout<<"The "<<getName()<<" interacts with the "<<obj->getName()<<".\n"; }
168  virtual void interact (Character* obj, int interactionType=0)
169  {
170  std::cout<<"Char interact\n";
171  //std::cout<<"The "<<getName()<<" interacts with the "<<obj->getName()<<".\n";
172  }
173  virtual void interact (Creature* obj, int interactionType=0)
174  {
175  std::cout<<"Creature interact\n";
176  //std::cout<<"The "<<getName()<<" interacts with the "<<obj->getName()<<".\n";
177  }
178  //virtual void interact (Creature_Deer*, int interactionType=0) {}
179 
180  // HOW LONG THIS TASK WILL TAKE. -1 MEANS YOU CAN'T DO IT. 0 MEANS NO TIME COST.
181  virtual int interactTime(WorldObject* _w)
182  { return 0; }
183  // Same but for LocalTile object. Used for interaction with terrain.
184  virtual int interactTime(LocalTile* _w)
185  { return 0; }
186 
187  // Describe the interaction. For example: "Chop down tree.
188  // Note, this should be updated to be a vector, because an object can in some cases do multiple things to an object
189  virtual Vector <std::string>* getInteractNames(WorldObject* _w)
190  { return 0; }
191  virtual Vector <std::string>* getInteractNames(Item* _w)
192  { return 0; }
193  virtual Vector <std::string>* getInteractNames(Character* _w)
194  { return 0; }
195  virtual Vector <std::string>* getInteractNames(Creature* _w)
196  { return 0; }
197  virtual Vector <std::string>* getInteractNames(LocalTile* _w)
198  { return 0; }
199  virtual Vector <std::string>* getInteractNames(Static* _w)
200  { return 0; }
201 
202  // Resources needed to build this item
203  // /* virtual */ static ResourceRequirement getResourceRequirement()
204  // { return ResourceRequirement( /* NONE */ ); }
205 
207  { return StockpileRequirement( /* NONE */ ); }
208 
209 
210  // Useful for checking recipe requirements.
211  bool sameType (WorldObject _obj)
212  { return false; }
213  bool sameType (Item* _item)
214  { return true; }
215 
216 
217  virtual std::string getInteractName(WorldObject* _w)
218  { return "Interact with "+_w->getName(); }
219  virtual std::string getInteractName(LocalTile* _w)
220  { return "Interact with "+_w->getName(); }
221 
222 
223  virtual void addToRecipeManager();
224 
225  virtual void attachInformation(Item_Information* _information)
226  {
227  information = _information;
228  }
229 
230 
231  virtual Texture* currentTexture();
232 
233  /* TABLE INTERFACE */
234  std::string getColumn(std::string _column);
235  std::string getColumnType(std::string _column);
236 
237  std::string getSaveData();
238  void loadData(std::string);
239 };
240 
241 // So it has come to this
242 // Obviously you can't call a function for a null pointer, however hand is the default (null) action
243 // therefore an object must be created to deal with these interactions.
244 // An alternative is to simply have Character handle this. However I like this approach because it keeps
245 // Interactions together.
246 class Item_Hand: public Item
247 {
248  public:
249 
251  { }
252  std::string getName() override { return "Hand"; }
253 
254  virtual Vector <std::string>* getInteractNames(WorldObject*) override;
255  virtual Vector <std::string>* getInteractNames(Static*) override;
256  // virtual Vector <std::string>* getInteractNames(Item* _w) override;
257  // virtual Vector <std::string>* getInteractNames(Character* _w) override;
258  // virtual Vector <std::string>* getInteractNames(Creature* _w) override;
259  // virtual Vector <std::string>* getInteractNames(LocalTile* _w) override;
260 
261  virtual void interact(WorldObject*, int interactType=0) override;
262 
263  // Dummy function
264  Texture* currentTexture() override
265  { return &TEX_PORTRAIT_SNEK; }
266 
268  { return StockpileRequirement( /* NONE */ ); }
269 
270 };
272 
273 class Recipe_HuntingBow: public Item
274 {
275  public:
277  {
278  requiresLocation=false;
279  //mIntermediate[INTERMEDIATE_GUT] = 1;
280  //mResource[RESOURCE_WOOD] = 2;
281 
282  mAction[ITEM_ACTION_HUNTING_RANGED]=1;
283  }
284 };
285 
286 // Used for farming. Can also be improvised weapon.
287 class Item_Hoe: public Item
288 {
289  public:
290 
292  {
293  attributes.farmingValue=1;
294  reach=1;
295  type=ITEM_HOE;
296 
297  mAction[ITEM_ACTION_FARMING]=1;
298  }
299  std::string getName() override { return "Hoe"; }
300 
301  // virtual Vector <std::string>* getInteractNames(WorldObject* _w);
302  // virtual Vector <std::string>* getInteractNames(Item* _w);
303  // virtual Vector <std::string>* getInteractNames(Character* _w);
304  // virtual Vector <std::string>* getInteractNames(Creature* _w);
305  // virtual Vector <std::string>* getInteractNames(LocalTile* _w);
306 
307  // virtual void interact (Creature* obj, int interactionType=0);
308  // virtual void interact (Character* obj, int interactionType=0);
309 
310  Texture* currentTexture() override
311  { return &TEX_ITEM_SWORD; }
312 
314  {
315  StockpileRequirement stockpileRequirement;
316  stockpileRequirement.add(RESOURCE_IRON,1);
317 
318  return stockpileRequirement;
319  }
320 
321  /* TABLE INTERFACE */
322  std::string getColumn(std::string _column) override
323  {
324  if ( _column=="name" )
325  {
326  return "hoe";
327  }
328  else if ( _column=="type" )
329  {
330  return "hoe";
331  }
332  else if ( _column=="quality" )
333  {
334  return DataTools::toString(getQuality());
335  }
336  return "<?>";
337  }
338  std::string getColumnType(std::string _column) override
339  {
340  if ( _column == "quality" )
341  {
342  return "string"; // return "number"
343  }
344  return "string";
345  }
346 };
347 
348 class Item_Sword: public Item
349 {
350  public:
351 
353  {
354  reach=1;
355  type = ITEM_SWORD;
356  }
357  std::string getName() override { return "Sword"; }
358 
359  virtual Vector <std::string>* getInteractNames(WorldObject* _w) override;
360  virtual Vector <std::string>* getInteractNames(Item* _w) override;
361  virtual Vector <std::string>* getInteractNames(Character* _w) override;
362  virtual Vector <std::string>* getInteractNames(Creature* _w) override;
363  virtual Vector <std::string>* getInteractNames(LocalTile* _w) override;
364 
365  virtual void interact (Creature* obj, int interactionType=0) override;
366  virtual void interact (Character* obj, int interactionType=0) override;
367 
369  {
370  StockpileRequirement stockpileRequirement;
371  stockpileRequirement.add(RESOURCE_IRON,1);
372 
373  return stockpileRequirement;
374  }
375 
376  Texture* currentTexture() override
377  { return &TEX_ITEM_SWORD; }
378 
379  /* TABLE INTERFACE */
380  std::string getColumn(std::string _column) override
381  {
382  if ( _column=="name" )
383  {
384  return "sword";
385  }
386  else if ( _column=="type" )
387  {
388  return "sword";
389  }
390  else if ( _column=="quality" )
391  {
392  return DataTools::toString(getQuality());
393  }
394  return "<?>";
395  }
396  std::string getColumnType(std::string _column) override
397  {
398  if ( _column == "quality" )
399  {
400  return "string"; // return "number"
401  }
402  return "string";
403  }
404 
405 };
406 
407 class Item_Knife: public Item
408 {
409  public:
410 
412  { }
413  std::string getName() { return "Knife"; }
414 
415  // virtual Vector <std::string>* getInteractNames(WorldObject* _w);
416  // virtual Vector <std::string>* getInteractNames(Item* _w);
417  virtual Vector <std::string>* getInteractNames(Character* _w);
418  virtual Vector <std::string>* getInteractNames(Creature* _w);
419  // virtual Vector <std::string>* getInteractNames(LocalTile* _w);
420 
421  virtual void interact (Creature* obj, int interactionType=0);
422  virtual void interact (Character* obj, int interactionType=0);
423 
425  {
426  StockpileRequirement stockpileRequirement;
427  stockpileRequirement.add(RESOURCE_IRON,1);
428 
429  return stockpileRequirement;
430  }
431 
432  Texture* currentTexture()
433  { return &TEX_ITEM_KNIFE; }
434 
435 };
436 
437 class Item_Longbow: public Item
438 {
439  public:
441  {
442  attributes.huntingValue=2;
443  type = ITEM_LONGBOW;
444  }
445  std::string getName() override { return "Longbow"; }
446 
448  {
449  StockpileRequirement stockpileRequirement;
450  stockpileRequirement.add(RESOURCE_WOOD,2);
451  stockpileRequirement.add(INTERMEDIATE_GUT,1);
452 
453  return stockpileRequirement;
454  }
455 
456  Texture* currentTexture() override
457  { return &TEX_ITEM_LONGBOW; }
458 
459  virtual Vector <std::string>* getInteractNames(Creature* _target) override;
460 
461  virtual void interact(Creature* _target, int interactType=0) override;
462 
463 };
464 
465 class Item_Spear: public Item
466 {
467  public:
469  {
470  attributes.huntingValue=1;
471  type = ITEM_SPEAR;
472  }
473  std::string getName() override { return "Spear"; }
474 
476  {
477  StockpileRequirement stockpileRequirement;
478  stockpileRequirement.add(RESOURCE_WOOD,1);
479 
480  return stockpileRequirement;
481  }
482 
483  Texture* currentTexture() override
484  { return &TEX_ITEM_LONGBOW; }
485 
486  //virtual Vector <std::string>* getInteractNames(Creature* _target) override;
487 
488  //virtual void interact(Creature* _target, int interactType=0) override;
489 
490 };
491 
492 class Item_Pickaxe: public Item
493 {
494  public:
495 
497  {
498  attributes.miningValue=1;
499  type = ITEM_PICKAXE;
500  }
501  std::string getName() override { return "Pickaxe"; }
502 
503 
504  Texture* currentTexture() override
505  { return &TEX_ITEM_PICKAXE; }
506 
507  virtual Vector <std::string>* getInteractNames(LocalTile* _target) override;
508 
509  virtual void interact(LocalTile* _target, int interactType=0) override;
510 
512  {
513  StockpileRequirement stockpileRequirement;
514  stockpileRequirement.add(RESOURCE_IRON,1);
515 
516  return stockpileRequirement;
517  }
518 
519  /* TABLE INTERFACE */
520  std::string getColumn(std::string _column) override
521  {
522  if ( _column=="name" )
523  {
524  return "pickaxe";
525  }
526  else if ( _column=="type" )
527  {
528  return "pickaxe";
529  }
530  else if ( _column=="quality" )
531  {
532  return DataTools::toString(getQuality());
533  }
534  return "<?>";
535  }
536  std::string getColumnType(std::string _column) override
537  {
538  if ( _column == "quality" )
539  {
540  return "string"; // return "number"
541  }
542  return "string";
543  }
544 
545 };
546 
547 class Item_Fishrod: public Item
548 {
549  public:
550 
552  {
553  reach=1;
554  }
555  std::string getName() { return "Fishing rod"; }
556 
557  virtual void interact (LocalTile* _tile, int interactionType = 0);
558 
559 
560  void interact(WorldObject* _w, int interactType=0)
561  {
562  std::cout<<"You hook the "+_w->getName();
563  }
564 
565  std::string getInteractName(WorldObject* _w)
566  {
567  return "Fish in "+_w->getName();
568  }
569  std::string getInteractName(LocalTile* _w)
570  {
571  return "Cast fishing rod: "+_w->getName();
572  }
573 
574  virtual int interactTime(WorldObject* _w)
575  {
576  return -1;
577  }
578  virtual int interactTime(LocalTile* _w)
579  {
580  if ( _w->getName() == "Ocean")
581  {
582  return 30;
583  }
584  return -1;
585  }
586 
588  {
589  StockpileRequirement stockpileRequirement;
590  stockpileRequirement.add(RESOURCE_WOOD,1);
591  stockpileRequirement.add(INTERMEDIATE_GUT,2);
592 
593  return stockpileRequirement;
594  }
595 
596  virtual Vector <std::string>* getInteractNames(LocalTile* _w);
597 
598  Texture* currentTexture()
599  {
600  return &TEX_ITEM_FISHROD;
601  }
602 
603 };
604 
605 class Item_Shovel: public Item
606 {
607  public:
608 
610  {
611 
612  }
613  std::string getName() { return "Shovel"; }
614 
615 
616  Texture* currentTexture()
617  { return &TEX_ITEM_SHOVEL; }
618 
619 };
620 
621 class Item_Axe: public Item
622 {
623  public:
624 
626  {
627  attributes.woodcuttingValue=1;
628  type=ITEM_AXE;
629  }
630  std::string getName() { return "Axe"; }
631 
633  {
634  StockpileRequirement stockpileRequirement;
635  stockpileRequirement.add(RESOURCE_IRON,1);
636 
637  return stockpileRequirement;
638  }
639 
640 
641  void interact(WorldObject* w, int interactType=0);
642 
643 
644  virtual Vector <std::string>* getInteractNames(WorldObject* _w);
645  virtual Vector <std::string>* getInteractNames(Item* _w);
646  virtual Vector <std::string>* getInteractNames(Character* _w);
647  virtual Vector <std::string>* getInteractNames(Creature* _w);
648  virtual Vector <std::string>* getInteractNames(LocalTile* _w);
649 
650  virtual void interact (LocalTile* obj, int interactionType = 0)
651  {
652  std::cout<<"You chop the TILE "<<obj->getName()<<".\n";
653  }
654  virtual void interact (Item* obj, int)
655  {
656  std::cout<<"You chop the ITM "<<obj->getName()<<".\n";
657  }
658  virtual void interact (Character* obj, int interactionType=0)
659  {
660  //std::cout<<"You chop the CHARACTER "<<obj->getName()<<".\n";
661  }
662 
663  std::string getInteractName(WorldObject* _w)
664  {
665  return "Chop "+_w->getName();
666  }
667  std::string getInteractName(LocalTile* _w)
668  {
669  return "Chop the "+_w->getName();
670  }
671 
672  virtual int interactTime(WorldObject* _w)
673  {
674  if (_w->chopAmount > -1 )
675  {
676  return 5;
677  }
678  return -1;
679  }
680 
681  Texture* currentTexture()
682  { return &TEX_ITEM_AXE; }
683 
684 };
685 
686 
687 class Item_Log: public Item
688 {
689  public:
690 
692  {
693 
694  }
695  virtual ~Item_Log() {}
696 
697  virtual void interact (LocalTile* obj, int interactionType = 0) override;
698 
699  virtual Vector <std::string>* getInteractNames(WorldObject* _w) override;
700  virtual Vector <std::string>* getInteractNames(Item* _w) override;
701  virtual Vector <std::string>* getInteractNames(Character* _w) override;
702  virtual Vector <std::string>* getInteractNames(Creature* _w) override;
703  virtual Vector <std::string>* getInteractNames(LocalTile* _w) override;
704 
705 
706 
707  // We need to have 2 interactions:
708  // Light a fire
709  // Build a wall
710  std::string getInteractName(LocalTile* _w) override
711  {
712  return "Light a fire on the "+_w->getName();
713  }
714 
715  virtual int interactTime(WorldObject* _w) override
716  {
717  return -1;
718  }
719 
720  virtual int interactTime(LocalTile* _w) override
721  {
722  return 30;
723  }
724 
725  virtual std::string getName() override
726  {
727  return "Log";
728  }
729 
730  virtual void addToRecipeManager() override;
731 
732  Texture* currentTexture() override
733  { return &TEX_OBJECT_LOG; }
734 
735 };
736 
737 class Item_Fish: public Item
738 {
739  private:
740  bool isCooked;
741 
742  public:
743 
745  {
746  consumeTime = 5;
747  hungerRestore = 200;
748  isCooked = false;
749  }
750  virtual ~Item_Fish() {}
751 
752 
753  virtual std::string getName() override
754  {
755  if (isCooked)
756  {
757  return "Cooked fish";
758  }
759  return "Fish";
760  }
761 
762  virtual void interact (Item*, int interactType=0) override; /* cook */
763  virtual void interact (Character*, int interactType=0) override; /* eat */
764  virtual void interact (WorldObject*, int interactType=0) override; /* eat */
765 
766  Texture* currentTexture() override
767  {
768  if (isCooked)
769  {
771  }
772  return &TEX_OBJECT_FISH;
773  }
774 
775  virtual Vector <std::string>* getInteractNames(Item* _w) override;
776  virtual Vector <std::string>* getInteractNames(Character* _w) override;
777 
778  virtual void addToRecipeManager() override;
779 };
780 
781 class Item_Campfire: public Item
782 {
783  public:
785  {
786  canCook=true;
787  }
788  virtual ~Item_Campfire() {}
789 
790 
791  virtual std::string getName()
792  { return "Campfire"; }
793 
794  Texture* currentTexture()
795  {
797  { return &TEX_OBJECT_CAMPFIRE[0]; }
799  }
800 
801 };
802 
803 #include "Recipe.hpp"
804 
805 class Item_Plank: public Item
806 {
807  public:
808 
810  { }
811  virtual ~Item_Plank()
812  { }
813 
814  // Used so Player can easily see what recipes an object is used for.
815  virtual bool canUseInRecipe(Recipe* _recipe)
816  {
817  if (_recipe==0)
818  { return false; }
819  std::cout<<"2\n";
820  if (_recipe->canUse(this) > 0 )
821  {
822  std::cout<<"Return true\n";
823  return true;
824  }
825  std::cout<<"Return false\n";
826  return false;
827  }
828  // Used so Player can easily see what recipes an object is used for.
829  virtual bool canUseInRecipe(Recipe_Wall* _recipe)
830  {
831  std::cout<<"3\n";
832  return true;
833  }
834 
835  Texture* currentTexture()
836  { return &TEX_OBJECT_PLANK; }
837 
838  std::string getName() { return "Plank"; }
839 
840  virtual void addToRecipeManager();
841 };
842 
843 class Item_Wall: public Item
844 {
845  public:
846 
848  { }
849  virtual ~Item_Wall()
850  { }
851 
852  Vector <std::string>* getInteractNames(LocalTile* _w);
853  virtual void interact (LocalTile* obj, int interactionType = 0);
854 
855  Texture* currentTexture()
856  { return &TEX_WALL_GREYBRICK_SOUTH; }
857 };
858 
859 class Item_Floor: public Item
860 {
861  public:
863  { }
864  virtual ~Item_Floor()
865  { }
866 
867  Vector <std::string>* getInteractNames(LocalTile* _w);
868  virtual void interact (LocalTile* obj, int interactionType = 0);
869 
870  Texture* currentTexture()
871  { return &TEX_FLOOR_WOOD; }
872 };
873 
874 class Item_PlantFibre: public Item
875 {
876  public:
878  { }
880  { }
881 
882  Texture* currentTexture() override
883  { return &TEX_CRAFTING_FLAX; }
884 };
885 
886 // DEER PELT
887 class Item_DeerPelt: public Item
888 {
889  public:
890 
892  { }
893  virtual ~Item_DeerPelt()
894  { }
895  std::string getName() override { return "Deer Pelt"; }
896 
897  virtual void addToRecipeManager() override;
898 
899  Texture* currentTexture() override
900  { return &TEX_CRAFTING_LEATHER; }
901 };
902 
903 // DEER MEAT
904 class Item_DeerMeat: public Item
905 {
906  public:
907  bool isCooked;
908 
910  {
911  isCooked=false;
912  consumeTime = 5;
913  hungerRestore = 250;
914  }
915  virtual ~Item_DeerMeat()
916  { }
917  std::string getName() override
918  {
919  if (isCooked)
920  {
921  return "Cooked deer meat";
922  }
923  return "Raw deer meat";
924  }
925 
926  virtual void interact (Item*, int interactType=0) override; /* cook */
927  virtual void interact (Character*, int interactType=0) override; /* eat */
928  virtual void interact (WorldObject*, int interactType=0) override; /* eat */
929 
930  virtual Vector <std::string>* getInteractNames(Item* _w) override;
931  virtual Vector <std::string>* getInteractNames(Character* _w) override;
932 
933  Texture* currentTexture() override
934  {
935  if (isCooked )
936  {
938  }
939  return &TEX_ITEM_FOOD_STEAK_RAW;
940  }
941 };
942 
943 // HUMAN SKIN
944 class Item_HumanSkin: public Item
945 {
946  public:
948  { }
949  virtual ~Item_HumanSkin()
950  { }
951  std::string getName() override { return "Human skin"; }
952 
953  //virtual void addToRecipeManager() override;
954 
955  Texture* currentTexture() override
956  { return &TEX_CRAFTING_LEATHER; }
957 
958 };
959 
960 // HUMAN MEAT
961 class Item_HumanMeat: public Item
962 {
963  public:
965  { }
966  virtual ~Item_HumanMeat()
967  { }
968  std::string getName() override { return "Human Meat"; }
969 
970  Texture* currentTexture() override
971  { return &TEX_ITEM_FOOD_STEAK_RAW; }
972 };
973 
974 
975 // LEATHER CLOTHES
977 {
978  public:
979 
981  { }
983  { }
984  std::string getName() override { return "Leather clothes"; }
985 
986  Texture* currentTexture() override
987  { return &TEX_CRAFTING_LEATHER_CLOTHES; }
988 };
989 
990 // WATERSKIN
991 class Item_Waterskin: public Item
992 {
993  public:
994 
996  { }
997  virtual ~Item_Waterskin()
998  { }
999  std::string getName() override { return "Waterskin"; }
1000 
1001  Texture* currentTexture() override
1002  { return &TEX_ITEM_WATERSKIN; }
1003 };
1004 
1005 // Shelter
1006 class Item_Shelter: public Item
1007 {
1008  public:
1009 
1011  { }
1012  virtual ~Item_Shelter()
1013  {
1014  }
1015  std::string getName() override { return "Shelter"; }
1016 
1017  Texture* currentTexture() override
1018  { return &TEX_OBJECT_TENT; }
1019 };
1020 
1021 // Marker for debugging
1022 class Item_Marker_Red: public Item
1023 {
1024  public:
1025 
1027  { }
1028  std::string getName() override { return "Debug Marker"; }
1029 
1030  // Dummy function
1031  Texture* currentTexture() override
1032  { return &TEX_MARKER_RED; }
1033 
1034 };
1035 // Marker for debugging
1037 {
1038  public:
1039 
1041  {
1042 
1043  }
1044  std::string getName() override { return "Debug Marker"; }
1045 
1046  // Dummy function
1047  Texture* currentTexture() override
1048  { return &TEX_MARKER_GREEN_SMALL; }
1049 
1050 
1051 };
1052 
1053 #endif
Item_DeerPelt()
Definition: Item.hpp:891
Texture * currentTexture()
Definition: Item.hpp:616
virtual ~Item_Shelter()
Definition: Item.hpp:1012
virtual int interactTime(LocalTile *_w)
Definition: Item.hpp:578
std::string getName() override
Definition: Item.hpp:917
std::string getName() override
Definition: Item.hpp:473
Texture * currentTexture() override
Definition: Item.hpp:1047
Definition: Item.hpp:991
Definition: Driver_Settings_Enums.hpp:248
Definition: Creature.hpp:34
Texture TEX_MARKER_RED
Definition: Driver_TextureList.hpp:310
Texture * currentTexture() override
Definition: Item.hpp:1031
Texture TEX_OBJECT_FISH
Definition: Driver_TextureList.hpp:259
Item_DeerMeat()
Definition: Item.hpp:909
virtual std::string getName() override
Definition: Item.hpp:725
static StockpileRequirement getStockpileRequirement()
Definition: Item.hpp:313
virtual ~Item_HumanMeat()
Definition: Item.hpp:966
virtual int interactTime(WorldObject *_w)
Definition: Item.hpp:574
std::string name
Definition: Item.hpp:33
Texture * currentTexture()
Definition: Item.hpp:432
Definition: WorldObject.hpp:18
Recipe_HuntingBow()
Definition: Item.hpp:276
virtual ~Item_HumanSkin()
Definition: Item.hpp:949
Definition: Item.hpp:781
Definition: Driver_Settings_Enums.hpp:272
Definition: Item.hpp:944
Item_Campfire()
Definition: Item.hpp:784
Definition: Item.hpp:1022
Texture * currentTexture() override
Definition: Item.hpp:732
float throwMultiplier
Definition: Item.hpp:134
Texture * currentTexture()
Definition: Item.hpp:598
Item_Waterskin()
Definition: Item.hpp:995
virtual Vector< std::string > * getInteractNames(Character *_w)
Definition: Item.hpp:193
Definition: Driver_Settings_Enums.hpp:277
Texture TEX_MARKER_GREEN_SMALL
Definition: Driver_TextureList.hpp:313
virtual ~Item_Waterskin()
Definition: Item.hpp:997
std::string getName() override
Definition: Item.hpp:999
int bluntDamage
Definition: Item.hpp:132
Texture * currentTexture() override
Definition: Item.hpp:899
std::string getName() override
Definition: Item.hpp:357
virtual void interact(Character *obj, int interactionType=0)
Definition: Item.hpp:168
Item_Longbow()
Definition: Item.hpp:440
virtual bool canUseInRecipe(Recipe *_recipe)
Definition: Item.hpp:144
virtual void interact(Item *obj, int interactionType=0)
Definition: Item.hpp:166
Item_Log()
Definition: Item.hpp:691
int CURRENT_ANIMATION_FRAME
Definition: Driver_Settings.cpp:230
virtual bool canUseInRecipe(Recipe *_recipe)
Definition: Item.hpp:815
Texture * currentTexture() override
Definition: Item.hpp:882
Definition: Item.hpp:961
Item_Floor()
Definition: Item.hpp:862
short int meleeDamage
Definition: Item.hpp:68
Definition: Item.hpp:407
virtual Vector< std::string > * getInteractNames(Creature *_w)
Definition: Item.hpp:195
Definition: Static.hpp:24
virtual std::string getName() override
Definition: Item.hpp:753
Definition: Item.hpp:1036
std::string getName()
Definition: Item.hpp:555
std::unordered_map< ItemAction, char > mAction
Definition: Item.hpp:62
int pierceDamage
Definition: Item.hpp:133
bool isCooked
Definition: Item.hpp:907
std::string getInteractName(LocalTile *_w)
Definition: Item.hpp:569
Definition: Item.hpp:465
static StockpileRequirement getStockpileRequirement()
Definition: Item.hpp:368
std::string getName() override
Definition: Item.hpp:299
Texture TEX_ITEM_LONGBOW
Definition: Driver_TextureList.hpp:241
void add(Resource resource)
Definition: Stockpile.cpp:314
Texture * currentTexture()
Definition: Item.hpp:835
virtual ~Item_DeerPelt()
Definition: Item.hpp:893
Item_Sword()
Definition: Item.hpp:352
virtual int interactTime(LocalTile *_w)
Definition: Item.hpp:184
static StockpileRequirement getStockpileRequirement()
Definition: Item.hpp:511
Texture * currentTexture() override
Definition: Item.hpp:310
Item_Marker_Green_Small()
Definition: Item.hpp:1040
virtual std::string getName()
Definition: Item.hpp:791
virtual void interact(LocalTile *obj, int interactionType=0)
Definition: Item.hpp:164
std::string getName() override
Definition: Item.hpp:252
virtual void interact(Character *obj, int interactionType=0)
Definition: Item.hpp:658
std::string getName() override
Definition: Item.hpp:445
Definition: Item.hpp:976
Texture * currentTexture() override
Definition: Item.hpp:483
Texture TEX_ITEM_WATERSKIN
Definition: Driver_TextureList.hpp:262
virtual ~Item_LeatherClothes()
Definition: Item.hpp:982
Definition: Item_Attributes.hpp:14
Character * owner
Definition: Item.hpp:77
virtual ~Item_Campfire()
Definition: Item.hpp:788
Texture * currentTexture() override
Definition: Item.hpp:766
int hungerRestore
Definition: Item.hpp:83
Definition: Item.hpp:51
Definition: Driver_Settings_Enums.hpp:136
Definition: Recipe.hpp:44
Definition: Item.hpp:874
std::string getName()
Definition: Item.hpp:413
Texture * currentTexture() override
Definition: Item.hpp:986
Definition: Item.hpp:887
std::string getName() override
Definition: Item.hpp:968
static StockpileRequirement getStockpileRequirement()
Definition: Item.hpp:206
virtual void attachInformation(Item_Information *_information)
Definition: Item.hpp:225
Definition: Driver_Settings_Enums.hpp:273
Definition: Item.hpp:273
Texture * currentTexture() override
Definition: Item.hpp:456
Item_Shovel()
Definition: Item.hpp:609
virtual Vector< std::string > * getInteractNames(Item *_w)
Definition: Item.hpp:191
virtual ~Item_Floor()
Definition: Item.hpp:864
Definition: Driver_Settings_Enums.hpp:247
std::string getName() override
Definition: Item.hpp:501
virtual void interact(Creature *obj, int interactionType=0)
Definition: Item.hpp:173
char ammunitionType
Definition: Item.hpp:74
virtual std::string getName()
Definition: Item.cpp:42
virtual ~Item_Wall()
Definition: Item.hpp:849
Item_PlantFibre()
Definition: Item.hpp:877
std::string getName()
Definition: Item.hpp:613
static StockpileRequirement getStockpileRequirement()
Definition: Item.hpp:267
static StockpileRequirement getStockpileRequirement()
Definition: Item.hpp:447
Texture * currentTexture() override
Definition: Item.hpp:1017
int chopAmount
Definition: WorldObject.hpp:52
void interact(WorldObject *_w, int interactType=0)
Definition: Item.hpp:560
Texture TEX_FLOOR_WOOD
Definition: Driver_TextureList.hpp:230
Definition: Item.hpp:437
std::string getName() override
Definition: Item.hpp:895
Texture TEX_PORTRAIT_SNEK
Definition: Driver_TextureList.hpp:319
int chopTreeCost
Definition: Item.hpp:140
std::string getColumnType(std::string _column) override
Definition: Item.hpp:536
Definition: Stockpile.hpp:29
Item_Wall()
Definition: Item.hpp:847
std::string getInteractName(WorldObject *_w)
Definition: Item.hpp:663
Item_Marker_Red()
Definition: Item.hpp:1026
virtual std::string getName()
Definition: WorldObject.cpp:32
virtual Vector< std::string > * getInteractNames(LocalTile *_w)
Definition: Item.hpp:197
virtual ~Item_Fish()
Definition: Item.hpp:750
Definition: Stockpile.hpp:90
Definition: Item.hpp:621
int slashDamage
Definition: Item.hpp:131
Definition: Item.hpp:904
Definition: Driver_Settings_Enums.hpp:168
std::string getColumn(std::string _column) override
Definition: Item.hpp:380
Texture TEX_ITEM_PICKAXE
Definition: Driver_TextureList.hpp:253
int fishingCost
Definition: Item.hpp:141
Texture * currentTexture() override
Definition: Item.hpp:955
Texture TEX_OBJECT_LOG
Definition: Driver_TextureList.hpp:256
std::string getColumn(std::string _column) override
Definition: Item.hpp:322
short int count
Definition: Item.hpp:56
Definition: Driver_Settings_Enums.hpp:275
Texture TEX_OBJECT_PLANK
Definition: Driver_TextureList.hpp:220
Definition: Item.hpp:492
Texture * currentTexture() override
Definition: Item.hpp:376
static StockpileRequirement getStockpileRequirement()
Definition: Item.hpp:632
bool sameType(Item *_item)
Definition: Item.hpp:213
Definition: Item.hpp:287
virtual int interactTime(WorldObject *_w) override
Definition: Item.hpp:715
virtual std::string getInteractName(LocalTile *_w)
Definition: Item.hpp:219
short int reach
Definition: Item.hpp:71
Definition: Item_Information.cpp:14
Texture * currentTexture()
Definition: Item.hpp:794
static StockpileRequirement getStockpileRequirement()
Definition: Item.hpp:475
std::string getColumn(std::string _column) override
Definition: Item.hpp:520
Texture TEX_CRAFTING_LEATHER
Definition: Driver_TextureList.hpp:295
Definition: Character.hpp:38
std::string getName()
Definition: LocalTile.cpp:147
Definition: Item.hpp:348
Definition: Driver_Settings_Enums.hpp:276
Texture TEX_ITEM_KNIFE
Definition: Driver_TextureList.hpp:238
Texture TEX_ITEM_FISHROD
Definition: Driver_TextureList.hpp:244
std::string getInteractName(WorldObject *_w)
Definition: Item.hpp:565
virtual ~Item_Plank()
Definition: Item.hpp:811
Texture TEX_OBJECT_CAMPFIRE[5]
Definition: Driver_TextureList.hpp:265
virtual void interact(Item *obj, int)
Definition: Item.hpp:654
Item_Information * information
Definition: Item.hpp:85
virtual bool canUseInRecipe(Recipe_Wall *_recipe)
Definition: Item.hpp:829
Definition: Item.hpp:547
std::string getName() override
Definition: Item.hpp:951
Item_Hand itemHand
Definition: Item.hpp:271
Item_Shelter()
Definition: Item.hpp:1010
Texture TEX_CRAFTING_LEATHER_CLOTHES
Definition: Driver_TextureList.hpp:298
Item_Spear()
Definition: Item.hpp:468
ItemType type
Definition: Item.hpp:58
std::string getColumnType(std::string _column) override
Definition: Item.hpp:396
Texture * currentTexture()
Definition: Item.hpp:870
Texture * currentTexture() override
Definition: Item.hpp:264
Definition: Driver_Settings_Enums.hpp:128
Definition: LocalTile.hpp:34
std::string getInteractName(LocalTile *_w)
Definition: Item.hpp:667
std::string getName()
Definition: Item.hpp:630
virtual int interactTime(LocalTile *_w) override
Definition: Item.hpp:720
Definition: Item.hpp:737
Texture * currentTexture()
Definition: Item.hpp:681
Texture TEX_ITEM_SHOVEL
Definition: Driver_TextureList.hpp:247
int baseDamage
Definition: Item.hpp:34
virtual ~Item_Log()
Definition: Item.hpp:695
std::string getName() override
Definition: Item.hpp:1015
std::string getName()
Definition: Item.hpp:838
virtual Vector< std::string > * getInteractNames(Static *_w)
Definition: Item.hpp:199
Item_Knife()
Definition: Item.hpp:411
bool sameType(WorldObject _obj)
Definition: Item.hpp:211
virtual Vector< std::string > * getInteractNames(WorldObject *_w)
Definition: Item.hpp:189
virtual int interactTime(WorldObject *_w)
Definition: Item.hpp:672
Texture TEX_ITEM_SWORD
Definition: Driver_TextureList.hpp:235
int consumeTime
Definition: Item.hpp:82
Texture TEX_OBJECT_TENT
Definition: Driver_TextureList.hpp:268
std::string getName() override
Definition: Item.hpp:1044
Item_Axe()
Definition: Item.hpp:625
Definition: Item.hpp:859
Texture TEX_WALL_GREYBRICK_SOUTH
Definition: Driver_TextureList.hpp:224
virtual std::string getInteractName(WorldObject *_w)
Definition: Item.hpp:217
Item_Pickaxe()
Definition: Item.hpp:496
Item_Plank()
Definition: Item.hpp:809
Definition: Item.hpp:1006
std::string getColumnType(std::string _column) override
Definition: Item.hpp:338
Texture * currentTexture() override
Definition: Item.hpp:970
Texture * currentTexture() override
Definition: Item.hpp:1001
std::string getName() override
Definition: Item.hpp:984
Texture TEX_ITEM_FOOD_STEAK_RAW
Definition: Driver_TextureList.hpp:279
virtual int canUse(WorldObject *)
Definition: Recipe.hpp:62
Definition: Recipe.hpp:95
Definition: Item.hpp:805
Item_HumanSkin()
Definition: Item.hpp:947
std::string getName() override
Definition: Item.hpp:1028
Item_LeatherClothes()
Definition: Item.hpp:980
short int throwDamage
Definition: Item.hpp:69
Item_HumanMeat()
Definition: Item.hpp:964
std::string getInteractName(LocalTile *_w) override
Definition: Item.hpp:710
Definition: Item.hpp:687
Texture * currentTexture() override
Definition: Item.hpp:504
Item_Fish()
Definition: Item.hpp:744
static StockpileRequirement getStockpileRequirement()
Definition: Item.hpp:424
virtual ~Item_DeerMeat()
Definition: Item.hpp:915
virtual int interactTime(WorldObject *_w)
Definition: Item.hpp:181
Texture * currentTexture()
Definition: Item.hpp:855
Texture TEX_ITEM_FOOD_COOKED_FISH
Definition: Driver_TextureList.hpp:273
Definition: Item.hpp:246
Texture TEX_ITEM_AXE
Definition: Driver_TextureList.hpp:250
static StockpileRequirement getStockpileRequirement()
Definition: Item.hpp:587
virtual ~Item_PlantFibre()
Definition: Item.hpp:879
Texture TEX_ITEM_FOOD_STEAK_COOKED
Definition: Driver_TextureList.hpp:276
Item_Fishrod()
Definition: Item.hpp:551
virtual void interact(LocalTile *obj, int interactionType=0)
Definition: Item.hpp:650
virtual void interact(WorldObject *obj, int interactionType=0)
Definition: Item.hpp:162
Definition: Item.hpp:843
Definition: Item.hpp:29
Item_Attributes attributes
Definition: Item.hpp:60
Definition: Driver_Settings_Enums.hpp:280
Texture TEX_CRAFTING_FLAX
Definition: Driver_TextureList.hpp:292
Item_Hand()
Definition: Item.hpp:250
Texture * currentTexture() override
Definition: Item.hpp:933
Item_Hoe()
Definition: Item.hpp:291
Definition: Item.hpp:605
ItemType
Definition: Driver_Settings_Enums.hpp:268