author | terom |
Tue, 09 Dec 2008 04:23:57 +0000 | |
changeset 362 | 6c7b4deefdfb |
parent 338 | fe2b3c6fff54 |
child 423 | 947ab54de4b7 |
permissions | -rw-r--r-- |
212 | 1 |
#ifndef WEAPON_HH |
2 |
#define WEAPON_HH |
|
3 |
||
221 | 4 |
// forward-declare |
5 |
class Weapon; |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
6 |
typedef unsigned int WeaponID; |
221 | 7 |
|
8 |
#include "GameState.hh" |
|
222
293ddf4c067d
reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents:
221
diff
changeset
|
9 |
#include "Projectile.hh" |
212 | 10 |
#include "Timer.hh" |
11 |
#include <string> |
|
12 |
||
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
279
diff
changeset
|
13 |
/** |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
279
diff
changeset
|
14 |
* A Weapon is something that a Player has in their list of weapons. It has a name, some parameters related to the |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
279
diff
changeset
|
15 |
* weapon itself (name, reload time), and some parameters related to the projectiles that it creates (velocity, |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
279
diff
changeset
|
16 |
* radius, etc). |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
279
diff
changeset
|
17 |
*/ |
212 | 18 |
class Weapon { |
221 | 19 |
protected: |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
20 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
21 |
* weapon's index in player's weapons list |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
22 |
*/ |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
23 |
WeaponID id; |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
24 |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
25 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
26 |
* weapon name |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
27 |
*/ |
221 | 28 |
std::string name; |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
29 |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
30 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
31 |
* projectile velocity |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
32 |
*/ |
212 | 33 |
float velocity; |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
34 |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
35 |
/** |
305 | 36 |
* Damage it does to player's health. |
37 |
*/ |
|
38 |
int damage; |
|
39 |
||
40 |
/** |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
41 |
* radius of damage done on impact |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
42 |
*/ |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
43 |
float explosionRadius; |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
44 |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
45 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
46 |
* radius of projectile itself |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
47 |
*/ |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
48 |
float radius; |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
49 |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
50 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
51 |
* how long it takes to reload |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
52 |
*/ |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
53 |
TimeMS reloadTime; |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
54 |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
55 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
56 |
* recoil force, backwards |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
57 |
*/ |
251
6a6208e5c7a1
Added recoil parameter for weapons, but it is not used yet.
saiam
parents:
236
diff
changeset
|
58 |
float recoil; |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
59 |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
60 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
61 |
* XXX: unused |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
62 |
*/ |
212 | 63 |
int clipSize; |
64 |
||
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
65 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
66 |
* How many ticks projectiles last |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
67 |
*/ |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
68 |
TickCount expire; |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
69 |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
70 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
71 |
* current reload state |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
72 |
*/ |
221 | 73 |
int reloadTimer; |
212 | 74 |
|
279
e36f5e1a1c8d
let projectiles bounce, the new BounceBounce weapon puts the Physics engine into an infinite loop
terom
parents:
276
diff
changeset
|
75 |
/** |
e36f5e1a1c8d
let projectiles bounce, the new BounceBounce weapon puts the Physics engine into an infinite loop
terom
parents:
276
diff
changeset
|
76 |
* If nonzero, projectiles bounce off walls (it's the elasticity factor), else they explode on contact |
e36f5e1a1c8d
let projectiles bounce, the new BounceBounce weapon puts the Physics engine into an infinite loop
terom
parents:
276
diff
changeset
|
77 |
*/ |
e36f5e1a1c8d
let projectiles bounce, the new BounceBounce weapon puts the Physics engine into an infinite loop
terom
parents:
276
diff
changeset
|
78 |
float bounce; |
e36f5e1a1c8d
let projectiles bounce, the new BounceBounce weapon puts the Physics engine into an infinite loop
terom
parents:
276
diff
changeset
|
79 |
|
338 | 80 |
/** |
81 |
* Projectile mass |
|
82 |
*/ |
|
83 |
float mass; |
|
84 |
||
221 | 85 |
public: |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
86 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
87 |
* Create a weapon with the given parameters |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
88 |
*/ |
338 | 89 |
Weapon (WeaponID id, TickCount expire, float velocity, float recoil, int damage, float explosionRadius, float radius, TimeMS reloadTime, std::string name, float bounce, float mass); |
221 | 90 |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
91 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
92 |
* Decrement the reload timer, if it's still going |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
93 |
*/ |
221 | 94 |
void tickReload (TimeMS dt); |
95 |
||
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
96 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
97 |
* Can the weapon be fired (not reloading, have a clip, etc) |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
98 |
*/ |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
99 |
bool canShoot (void) const; |
221 | 100 |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
101 |
/* |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
102 |
* Get weapon parameters |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
103 |
*/ |
276
87434abc1ba1
ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents:
271
diff
changeset
|
104 |
WeaponID getID (void) const { return id; } |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
105 |
std::string getName (void) const { return name; } |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
106 |
float getSpeed (void) const { return velocity; } |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
107 |
float getRecoil (void) const { return recoil; } |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
108 |
float getExplosionRadius (void) const { return explosionRadius; } |
305 | 109 |
int getDamage (void) const { return damage; } |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
110 |
float getRadius (void) const { return radius; } |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
111 |
TickCount getExpire (void) const { return expire; } |
279
e36f5e1a1c8d
let projectiles bounce, the new BounceBounce weapon puts the Physics engine into an infinite loop
terom
parents:
276
diff
changeset
|
112 |
float getBounce (void) const { return bounce; } |
338 | 113 |
float getMass (void) const { return mass; } |
318 | 114 |
|
115 |
int getReloadTimer(void) const { return reloadTimer; } |
|
116 |
int getReloadTime(void) const { return reloadTime; } |
|
223 | 117 |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
118 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
119 |
* Start reloading |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
120 |
*/ |
223 | 121 |
void reload (void); |
212 | 122 |
}; |
123 |
||
124 |
#endif |