src/Weapon.cc
author Tero Marttila <terom@fixme.fi>
Tue, 27 Jan 2009 00:25:58 +0200
changeset 439 9823e6cd1086
parent 338 fe2b3c6fff54
permissions -rw-r--r--
some README text
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     1
#include "Weapon.hh"
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
     2
305
56799ec8d7be Weapon damage and some other stuff
ekku
parents: 282
diff changeset
     3
Weapon::Weapon(WeaponID id, TickCount expire, float velocity, float recoil, int damage, float explosionRadius, float radius,
338
fe2b3c6fff54 new DigDig weapon with massive radius
terom
parents: 305
diff changeset
     4
        TimeMS reloadTime, std::string name, float bounce, float mass) : 
282
e0e4dfc3e528 compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents: 279
diff changeset
     5
    id(id), 
e0e4dfc3e528 compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents: 279
diff changeset
     6
    name(name), 
e0e4dfc3e528 compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents: 279
diff changeset
     7
    velocity(velocity), 
305
56799ec8d7be Weapon damage and some other stuff
ekku
parents: 282
diff changeset
     8
    damage(damage),
282
e0e4dfc3e528 compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents: 279
diff changeset
     9
    explosionRadius(explosionRadius), 
e0e4dfc3e528 compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents: 279
diff changeset
    10
    radius(radius),
e0e4dfc3e528 compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents: 279
diff changeset
    11
    reloadTime(reloadTime), 
e0e4dfc3e528 compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents: 279
diff changeset
    12
    recoil(recoil), 
e0e4dfc3e528 compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents: 279
diff changeset
    13
    expire(expire), 
e0e4dfc3e528 compiles cleanly with -Wall -Wextra -Wconversion, not tested, but that shouldn't break anything :)
terom
parents: 279
diff changeset
    14
    reloadTimer(0), 
338
fe2b3c6fff54 new DigDig weapon with massive radius
terom
parents: 305
diff changeset
    15
    bounce(bounce),
fe2b3c6fff54 new DigDig weapon with massive radius
terom
parents: 305
diff changeset
    16
    mass(mass)
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    17
{
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    18
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    19
}
4389c1e6b9b8 Weapon.cc&hh
nireco
parents:
diff changeset
    20
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    21
void Weapon::tickReload (TimeMS dt) {
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    22
    reloadTimer -= dt;
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    23
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    24
    if (reloadTimer < 0)
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    25
        reloadTimer = 0;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    26
}
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    27
271
bf6784a95b08 touch up weapon/projectile with comments and slight tweaking
terom
parents: 263
diff changeset
    28
bool Weapon::canShoot() const {
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    29
    return (reloadTimer == 0);
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    30
}
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    31
223
2fcaf54ed37b basic network-projectiles
terom
parents: 221
diff changeset
    32
void Weapon::reload (void) {
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    33
    // set the reload timer
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    34
    reloadTimer = reloadTime;
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    35
}
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 212
diff changeset
    36