src/Weapon.hh
author terom
Sun, 07 Dec 2008 23:10:30 +0000
changeset 271 bf6784a95b08
parent 263 8c999cf4c182
child 276 87434abc1ba1
permissions -rw-r--r--
touch up weapon/projectile with comments and slight tweaking
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     1
#ifndef WEAPON_HH
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     2
#define WEAPON_HH
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     3
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     4
// forward-declare
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     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
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     7
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
     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
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    10
#include "Timer.hh"
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    11
#include <string>
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    12
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    13
class Weapon {
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    14
protected:
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    15
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    16
     *  weapon's index in player's weapons list
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    17
     */
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    18
    WeaponID id;
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    19
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 name
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    22
     */
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    23
    std::string name;
271
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
     * projectile velocity
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    27
     */
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    28
    float velocity;
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
     * radius of damage done on impact
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    32
     */
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    33
    float explosionRadius;
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
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    36
     * radius of projectile itself
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    37
     */
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    38
    float radius;
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    39
    
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    40
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    41
     * how long it takes to reload
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
    TimeMS reloadTime;
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
     * recoil force, backwards
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    47
     */
251
6a6208e5c7a1 Added recoil parameter for weapons, but it is not used yet.
saiam
parents: 236
diff changeset
    48
    float recoil;
271
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
     * XXX: unused
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    52
     */
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    53
    int clipSize;
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    54
271
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
     * How many ticks projectiles last
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    57
     */
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    58
    TickCount expire;
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
     * current reload state
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    62
     */
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    63
    int reloadTimer;
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    64
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    65
public:
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    66
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    67
     * Create a weapon with the given parameters
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    68
     */
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    69
    Weapon (WeaponID id, TickCount expire, float velocity, float recoil, float explosionRadius, float radius, TimeMS reloadTime, std::string name);
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    70
    
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    71
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    72
     * Decrement the reload timer, if it's still going
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    73
     */
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    74
    void tickReload (TimeMS dt);
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    75
    
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    76
    /**
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    77
     * 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
    78
     */
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    79
    bool canShoot (void) const;
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    80
    
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    81
    /*
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    82
     * Get weapon parameters
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    83
     */
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    84
    std::string getName (void) const { return name; }
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    85
    float getSpeed (void) const { return velocity; }
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    86
    float getRecoil (void) const { return recoil; }
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    87
    float getExplosionRadius (void) const { return explosionRadius; }
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    88
    float getRadius (void) const { return radius; }
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    89
    TickCount getExpire (void) const { return expire; }
223
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    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
     * Start reloading
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    93
     */
223
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    94
    void reload (void);
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    95
};
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    96
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    97
#endif