Planeshift
psattack.h
Go to the documentation of this file.
1 /*
2  * psattack.cpp author: hartra344 [at] gmail [dot] com
3  *
4  * Copyright (C) 2001-2011 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 #ifndef psAttack_HEADER
20 #define psAttack_HEADER
21 //====================================================================================
22 // Crystal Space Includes
23 //====================================================================================
24 #include <csutil/csstring.h>
25 #include <csutil/weakreferenced.h>
26 //====================================================================================
27 // Project Includes
28 //====================================================================================
29 #include <idal.h>
30 #include "util/scriptvar.h"
31 #include "util/gameevent.h"
32 
33 
34 //=============================================================================
35 // Local Includes
36 //=============================================================================
37 #include "psskills.h"
38 #include "psitemstats.h"
39 #include "psitem.h"
40 #include "deleteobjcallback.h"
41 #include "combatmanager.h"
42 
43 using namespace CS;
44 
45 class psQuestPrereqOp;
46 class psCharacter;
47 class psAttack;
48 class Client;
49 class gemActor;
50 class ProgressionScript;
51 class MathExpression;
52 class CombatManager;
53 struct Stance;
55 
61 {
62  unsigned int id;
63  csString name;
64  unsigned int weaponID;
65  csArray<psWeaponType*> weaponTypes;
66  bool OneHand;
68 
69 };
70 
71 struct psAttackCost// may be expanded later if more balance is needed
72 {
73  float physStamina;
74 };
75 
82 class psAttack : public csRefCount
83 {
84 public:
85  psAttack();
86  ~psAttack();
87 
91  bool Load(iResultRow& row);
92 
96  bool CanAttack(Client* client);
97 
101  bool Attack(gemActor* attacker, gemActor* target, INVENTORY_SLOT_NUMBER slot);
102 
107  virtual void Affect(psCombatAttackGameEvent* event);
108 
112  int GetID() const
113  {
114  return id;
115  }
116 
120  const csString &GetName() const
121  {
122  return name;
123  }
124 
128  const csString &GetImage() const
129  {
130  return image;
131  }
132 
136  const csString &GetDescription() const
137  {
138  return description;
139  }
140 
142  {
143  return type;
144  }
145 
146 protected:
147  int CalculateAttack(psCombatAttackGameEvent* event, psItem* subWeapon = NULL);
148  void AffectTarget(gemActor* target, psCombatAttackGameEvent* event, int attack_result);
149 
150  int id;
151  csString name;
152  csString image;
153  csString animation;
154  csString description;
156  csRef<psQuestPrereqOp> requirements;
157  csRef<psQuestPrereqOp> TypeRequirements;
158 
171 };
172 
173 //-----------------------------------------------------------------------------
174 
179 {
180 public:
181  psCombatAttackGameEvent(csTicks delayticks,
182  psAttack* attack,
183  gemActor* attacker,
184  gemActor* target,
185  INVENTORY_SLOT_NUMBER weaponslot,
186  psItem* weapon);
187 
188  virtual ~psCombatAttackGameEvent();
189 
190  virtual void Trigger(); // Abstract event processing function
191 
193  {
194  return attack;
195  }
196 
198  {
199  return attacker;
200  }
201 
203  {
204  return target;
205  }
206 
208  {
209  return weaponSlot;
210  }
211 
213  {
214  return weapon;
215  }
216 
217  uint32_t GetTargetID()
218  {
219  return TargetCID;
220  }
221 
222  uint32_t GetAttackerID()
223  {
224  return AttackerCID;
225  }
226 
227  // These are just here to make it easy to pass data from Affect().
230  float FinalDamage;
231 
232 protected:
234  csWeakRef<gemActor> attacker;
235  csWeakRef<gemActor> target;
236  uint32_t AttackerCID;
237  uint32_t TargetCID;
238 
240  // XXX There is some risk this pointer could point to trash
241  // if the item is deleted/stored.
243 };
244 
245 #endif
MathScript * damage_script
Chance of Success.
Definition: psattack.h:168
Pure virtual base quest prerequisite operator class.
float physStamina
Definition: psattack.h:73
ProgressionScript is the imperative script container.
Definition: scripting.h:78
This struct holds data for generic attack types This could be for example an assassin attack which wo...
Definition: psattack.h:60
A specific MathEnvironment to be used in a MathScript.
Definition: mathscript.h:188
MathExpression * aoeRadius
AOE Radius: (Power, WaySkill, RelatedStat) -> Meters.
Definition: psattack.h:164
csString name
The stored name of the attack.
Definition: psattack.h:151
A MathScript is a mini-program to run.
Definition: mathscript.h:442
psAttackType * GetType() const
Definition: psattack.h:141
uint32_t GetTargetID()
Definition: psattack.h:217
csRef< psQuestPrereqOp > TypeRequirements
all Attack Type based requirements(not handled as a script)
Definition: psattack.h:157
MathExpression * attackDelay
Delay in milliseconds before attack "hits" or has an effect.
Definition: psattack.h:160
INVENTORY_SLOT_NUMBER
Holds a list of the possible socket identifiers that items can be attached to.
Definition: slots.h:32
int id
The stored ID of the attack.
Definition: psattack.h:150
uint32_t AttackerCID
ClientID of attacker.
Definition: psattack.h:236
gemActor * GetTarget()
Definition: psattack.h:202
float FinalDamage
Final damage applied to target.
Definition: psattack.h:230
gemActor * GetAttacker()
Definition: psattack.h:197
csRef< psQuestPrereqOp > requirements
all non weapon based attack requirements.
Definition: psattack.h:156
csString animation
possible attack animation
Definition: psattack.h:153
const csString & GetDescription() const
Gets the attack description.
Definition: psattack.h:136
psItem * GetWeapon()
Definition: psattack.h:212
The base expression class.
Definition: mathscript.h:330
Represents an Attack.
Definition: psattack.h:82
csArray< psWeaponType * > weaponTypes
non-zero if it requires 1 specific weapon.
Definition: psattack.h:65
MathExpression * aoeAngle
AOE Angle: (Power, WaySkill, RelatedStat) -> Degrees.
Definition: psattack.h:166
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
This class handles all calculations around combat, using statistics and information from the pspcchar...
Definition: combatmanager.h:55
PSSKILL related_stat
if it is a dual weilding based attack it willb e flagged here, that means it requires 2 weapons and e...
Definition: psattack.h:67
psAttackType * type
the attack type
Definition: psattack.h:155
ProgressionScript * outcome
The progression script: (Power, Caster, Target) -> (side effects)
Definition: psattack.h:170
PSSKILL
Definition: psskills.h:44
psItem * weapon
the attacking weapon
Definition: psattack.h:242
unsigned int weaponID
the name of the attack type
Definition: psattack.h:64
bool OneHand
if list is not empty, weapon must be one of the types in the list.
Definition: psattack.h:66
const csString & GetName() const
Gets the Name.
Definition: psattack.h:120
INVENTORY_SLOT_NUMBER GetWeaponSlot()
Definition: psattack.h:207
csWeakRef< gemActor > target
Entity who is target of this attack.
Definition: psattack.h:235
This class collects data of a netclient.
Definition: client.h:95
unsigned int id
Definition: psattack.h:62
This event actually triggers an attack.
Definition: psattack.h:178
uint32_t TargetCID
ClientID of target.
Definition: psattack.h:237
psAttack * GetAttack()
Definition: psattack.h:192
csWeakRef< gemActor > attacker
Entity who instigated this attack.
Definition: psattack.h:234
csString image
the address/id of the icon for the attack
Definition: psattack.h:152
int GetID() const
gets the id
Definition: psattack.h:112
const csString & GetImage() const
Gets the attack icon string.
Definition: psattack.h:128
psAttack * attack
The attack.
Definition: psattack.h:233
INVENTORY_SLOT_NUMBER AttackLocation
Which slot should we check the armor of?
Definition: psattack.h:229
csString name
the id number, corresponding to its id in the database
Definition: psattack.h:63
MathEnvironment env
Definition: psattack.h:228
All scheduled events must inherit from this class.
Definition: gameevent.h:36
uint32_t GetAttackerID()
Definition: psattack.h:222
csString description
the attack description
Definition: psattack.h:154
MathExpression * attackRange
The Max Range of the attack (Meters)
Definition: psattack.h:162
INVENTORY_SLOT_NUMBER weaponSlot
Identifier of the slot for which this attack event should process.
Definition: psattack.h:239
This class embodies item instances in the game.
Definition: psitem.h:238