JNR
rpgSheet_Fighter.h
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 #ifndef M_FIGHTING_SHEET_H
30 #define M_FIGHTING_SHEET_H
31 
33 
34 
42 class rpgSheet_Fighter_Props: public rpgSheet_Acrobate_Props
43 {
44 public:
45  M_SHEET_PROPS_COPY(rpgSheet_Fighter_Props);
46 
47  // Constructor/destr
48  //
49  rpgSheet_Fighter_Props(void)
50  {
51  nHP_Max = nHP = 1;
52  nAP = 1;
53  for(unsigned i=0; i<M_ELEMENTS; i++) arDP[i] = 0.1;
54  }
55 
56  // Health Points
57  //
58  int nHP_Max; // total health points
59  int nHP; // current health points
60 
61  // Basic attack points (added to any active attack)
62  //
63  unsigned nAP;
64 
65  // Defense Points
66  //
67  // NOTE: Defense is specified as a double value in the range [0; 1],
68  // where 1 gives the best defense
69  //
70  double arDP[M_ELEMENTS];
71 
72  // Attacks
73  //
74  std::vector<rpgAttack> vAttacks;
75 
76  // This method is part of the laLoadableObj interface
77  //
78  // RPG property sheets can be loaded from the tileset (.ts) file,
79  // as part of a monster, NPC, potion or other object specification;
80  //
81  //
82  virtual void load(class laFileParser *fp);
83  //save
84 
85  // Load from TS
86  virtual void load(class laPropertyList* pElement);
87 
88 };
89 
90 // Fighter sheet
91 //
92 M_SHEET_BEGIN(rpgSheet_Fighter, rpgSheet_Acrobate);
93 
94  // Modified params
95  //
96  virtual rpgAttack modAttack( unsigned n ){
97  ASSERT( n <properties()->vAttacks.size(), "Attack %d is undefined.", n );
98 
99  rpgAttack a = properties()->vAttacks[n];
100  a.nAP += properties()->nAP;
101  a.nAP *= modifiers()->dMod_AP;
102 
103  return a;
104  }
105 
106  virtual double modDP(unsigned nElement){
107  ASSERT(nElement < M_ELEMENTS, "Defense against %d is undefined.", nElement);
108 
109  return properties()->arDP[nElement] * modifiers()->dMod_DP;
110  }
111 
112  inline M_BOOL isAlive() {
113  return properties()->nHP > 0 ? M_TRUE : M_FALSE;
114  }
115 
116  // Perform attack; returns inflicted -HP
117  virtual unsigned attack( unsigned nAttack, rpgSheet_Fighter* pTarget );
118 
119  // Suffer an attack; returns inflicted -HP
120  virtual unsigned hit( rpgAttack attack );
121 
122  // Heal; returns recovered HP
123  unsigned heal( unsigned hp_heal );
124 
125  // Other stuff
126  //
127  inline void addAttack( rpgAttack attack ){
128  properties()->vAttacks.push_back(attack);
129  }
130 
131 M_SHEET_END;
133 #endif
Acrobatics RPG Properties.
Attack RPG Properties.
Definition: rpgAttack.h:55
File Parser.
Definition: laFileParser.h:41