#include <weapon.h>
Inherited by equipWeapon, wp_1000V, wp_boomerang, wp_chut, wp_gren, wp_gun, wp_hook, wp_invis, wp_magnet, wp_mine, wp_net, wp_puck, wp_warp, and wp_weasel.
Inheritance diagram for Weapon:
Public Member Functions | |
Weapon (Player *p) | |
Create a Weapon and assign it to the Player who has it in their inventory. | |
virtual | ~Weapon () |
virtual bool | fire () |
Called by a Player to try and fire this Weapon. | |
virtual void | stopFiring () |
Called by a Player to stop this Weapon from firing, usually to stop a held-fire Weapon's weaponFireAction(). | |
virtual void | weaponTick () |
Executed every frame to fire the Weapon if it is a held-fire Weapon and firing. | |
bool | isFiring () |
check if the Weapon is currently firing | |
bool | wasFiring () |
check if the Weapon was firing in the previous tick (useful for animation notifications etc) | |
bool | midairWeapon () |
check if the Weapon can be fired whilst the player is in the air | |
s8 | getAmmo () |
find out how much ammo this Weapon has left | |
Pickup::pickupType | getType () |
Determine the type of Pickup that this Weapon corresponds to. | |
Protected Member Functions | |
virtual void | weaponFireAction ()=0 |
Actions to perform when the Weapon is fired. | |
void | handleMovementAndAmmo () |
Handle the low-level effects of firing a Weapon, such as halting Player movement when required, playing fire animations and decrementing Weapon::ammo. | |
Protected Attributes | |
Player * | pawn |
the Player who owns this Weapon and is currently holding it | |
Pickup::pickupType | myType |
the type of Pickup that this Weapon corresponds to | |
bool | canFireStanding |
specifies whether or not this Weapon can be fired while the player is standing upright | |
bool | canFireInAir |
specifies whether or not this Weapon can be fired while the player is in midair | |
bool | canFireCrouching |
specifies whether or not this Weapon can be fired while the player is crouching | |
bool | canMoveWhileFiring |
specifies whether or not the Player can move whilst firing this Weapon | |
s8 | ammo |
the amount of shots remaining in this Weapon. When ammo is depleted, the Weapon is deleted. | |
bool | bHeldFire |
specifies if this Weapon operates in 'held-fire' mode or 'single-fire' mode | |
vector< u8 > | firingAnim |
the animation to play once for single-fire Weapons when fired | |
u8 | fireAnimSpeed |
the speed to play Weapon::firingAnim at | |
bool | bFiring |
true while the Weapon is firing | |
bool | bWasFiring |
true if the Weapon was firing in the previous tick |
Weapons are not sprite-driven and have no visual display. They perform high-level game logic and respond to a variety of events from the player carrying them.
A Weapon operates either in single-fire or held-fire mode. Single-fire mode refers to one 'shot' per keypress, whilst held-fire refers to a constant effect while the fire button is held down.
For single-fire Weapons, weaponFireAction() is executed when the fire button is pressed. For held-fire weapons, weaponFireAction() is executed every frame until the button is released. In both cases, stopFiring() is called to stop the weapon from firing. weaponFireAction() automaticlly decrements ammo and handles object destruction when it runs out. An ammo of -1 means infinite ammo.
Definition at line 52 of file weapon.h.
Weapon::Weapon | ( | Player * | p | ) |
Weapon::~Weapon | ( | ) | [virtual] |
Definition at line 39 of file weapon.cpp.
References pawn, stopFiring(), and Player::weaponDestroyed().
Here is the call graph for this function:
bool Weapon::fire | ( | ) | [virtual] |
Called by a Player to try and fire this Weapon.
The Weapon checks if it can fire before performing any actions.
Definition at line 54 of file weapon.cpp.
References bFiring, bHeldFire, canFireCrouching, canFireInAir, canFireStanding, handleMovementAndAmmo(), Player::isCrouched(), massObject::isOnGround(), Player::isOnRope(), pawn, and weaponFireAction().
Referenced by Player::basicInput().
Here is the call graph for this function:
void Weapon::stopFiring | ( | ) | [virtual] |
Called by a Player to stop this Weapon from firing, usually to stop a held-fire Weapon's weaponFireAction().
Reimplemented in wp_chut, wp_hook, and wp_magnet.
Definition at line 79 of file weapon.cpp.
References bFiring.
Referenced by Player::basicInput(), Player::bounce(), Player::collidingWith(), wp_magnet::stopFiring(), wp_hook::stopFiring(), wp_chut::stopFiring(), and ~Weapon().
void Weapon::weaponTick | ( | ) | [virtual] |
Executed every frame to fire the Weapon if it is a held-fire Weapon and firing.
Reimplemented in wp_1000V, wp_chut, wp_hook, wp_invis, wp_magnet, and wp_shield.
Definition at line 90 of file weapon.cpp.
References bFiring, bHeldFire, bWasFiring, handleMovementAndAmmo(), and weaponFireAction().
Referenced by Player::updateSprite(), wp_shield::weaponTick(), wp_magnet::weaponTick(), wp_invis::weaponTick(), wp_hook::weaponTick(), and wp_chut::weaponTick().
Here is the call graph for this function:
bool Weapon::isFiring | ( | ) | [inline] |
check if the Weapon is currently firing
Definition at line 66 of file weapon.h.
References bFiring.
Referenced by Player::basicInput(), Player::bounce(), Player::collidingWith(), Player::usingChut(), Player::usingMagnet(), wp_magnet::weaponTick(), wp_hook::weaponTick(), wp_chut::weaponTick(), wp_chut::~wp_chut(), wp_hook::~wp_hook(), wp_magnet::~wp_magnet(), wp_mine::~wp_mine(), and wp_weasel::~wp_weasel().
bool Weapon::wasFiring | ( | ) | [inline] |
check if the Weapon was firing in the previous tick (useful for animation notifications etc)
Definition at line 71 of file weapon.h.
References bWasFiring.
Referenced by wp_magnet::weaponFireAction(), wp_magnet::weaponTick(), wp_hook::weaponTick(), wp_chut::weaponTick(), wp_chut::~wp_chut(), wp_hook::~wp_hook(), wp_magnet::~wp_magnet(), wp_mine::~wp_mine(), and wp_weasel::~wp_weasel().
bool Weapon::midairWeapon | ( | ) | [inline] |
check if the Weapon can be fired whilst the player is in the air
Definition at line 77 of file weapon.h.
References canFireInAir.
s8 Weapon::getAmmo | ( | ) | [inline] |
Pickup::pickupType Weapon::getType | ( | ) | [inline] |
Determine the type of Pickup that this Weapon corresponds to.
Definition at line 89 of file weapon.h.
References myType.
Referenced by wp_magnet::popOutPawnWeapon(), and Player::weaponChange().
virtual void Weapon::weaponFireAction | ( | ) | [protected, pure virtual] |
Actions to perform when the Weapon is fired.
This may be only executed once for single-fire Weapons or every frame for held-fire Weapons.
Implemented in wp_1000V, wp_boomerang, wp_boot, wp_chut, wp_dunce, wp_gren, wp_gun, wp_hook, wp_invis, wp_magnet, wp_mine, wp_net, wp_puck, wp_shield, wp_warp, and wp_weasel.
Referenced by fire(), and weaponTick().
void Weapon::handleMovementAndAmmo | ( | ) | [protected] |
Handle the low-level effects of firing a Weapon, such as halting Player movement when required, playing fire animations and decrementing Weapon::ammo.
Definition at line 104 of file weapon.cpp.
References ammo, bHeldFire, canMoveWhileFiring, fireAnimSpeed, firingAnim, pawn, spriteObject::setArbitraryAnim(), Player::setInputInterrupt(), and spriteObject::setvx().
Referenced by fire(), and weaponTick().
Here is the call graph for this function:
Player* Weapon::pawn [protected] |
the Player who owns this Weapon and is currently holding it
Definition at line 101 of file weapon.h.
Referenced by wp_shield::equipAction(), wp_dunce::equipAction(), wp_boot::equipAction(), fire(), handleMovementAndAmmo(), wp_magnet::popOutPawnWeapon(), wp_magnet::stopFiring(), wp_chut::stopFiring(), wp_shield::unEquipAction(), wp_dunce::unEquipAction(), wp_boot::unEquipAction(), wp_weasel::weaponFireAction(), wp_warp::weaponFireAction(), wp_puck::weaponFireAction(), wp_net::weaponFireAction(), wp_mine::weaponFireAction(), wp_magnet::weaponFireAction(), wp_invis::weaponFireAction(), wp_hook::weaponFireAction(), wp_gun::weaponFireAction(), wp_gren::weaponFireAction(), wp_chut::weaponFireAction(), wp_boot::weaponFireAction(), wp_boomerang::weaponFireAction(), wp_shield::weaponTick(), wp_magnet::weaponTick(), wp_invis::weaponTick(), wp_hook::weaponTick(), wp_chut::weaponTick(), wp_1000V::weaponTick(), wp_1000V::wp_1000V(), ~Weapon(), wp_1000V::~wp_1000V(), wp_chut::~wp_chut(), wp_hook::~wp_hook(), wp_invis::~wp_invis(), wp_magnet::~wp_magnet(), wp_mine::~wp_mine(), and wp_weasel::~wp_weasel().
Pickup::pickupType Weapon::myType [protected] |
the type of Pickup that this Weapon corresponds to
Definition at line 104 of file weapon.h.
Referenced by getType(), wp_1000V::wp_1000V(), wp_boomerang::wp_boomerang(), wp_boot::wp_boot(), wp_chut::wp_chut(), wp_dunce::wp_dunce(), wp_gren::wp_gren(), wp_gun::wp_gun(), wp_hook::wp_hook(), wp_invis::wp_invis(), wp_magnet::wp_magnet(), wp_mine::wp_mine(), wp_net::wp_net(), wp_puck::wp_puck(), wp_shield::wp_shield(), wp_warp::wp_warp(), and wp_weasel::wp_weasel().
bool Weapon::canFireStanding [protected] |
specifies whether or not this Weapon can be fired while the player is standing upright
Definition at line 107 of file weapon.h.
Referenced by fire(), wp_1000V::wp_1000V(), wp_boomerang::wp_boomerang(), wp_boot::wp_boot(), wp_chut::wp_chut(), wp_dunce::wp_dunce(), wp_gren::wp_gren(), wp_gun::wp_gun(), wp_hook::wp_hook(), wp_invis::wp_invis(), wp_magnet::wp_magnet(), wp_mine::wp_mine(), wp_net::wp_net(), wp_puck::wp_puck(), wp_shield::wp_shield(), wp_warp::wp_warp(), and wp_weasel::wp_weasel().
bool Weapon::canFireInAir [protected] |
specifies whether or not this Weapon can be fired while the player is in midair
Definition at line 109 of file weapon.h.
Referenced by fire(), midairWeapon(), wp_1000V::wp_1000V(), wp_boomerang::wp_boomerang(), wp_boot::wp_boot(), wp_chut::wp_chut(), wp_dunce::wp_dunce(), wp_gren::wp_gren(), wp_gun::wp_gun(), wp_hook::wp_hook(), wp_invis::wp_invis(), wp_magnet::wp_magnet(), wp_mine::wp_mine(), wp_net::wp_net(), wp_puck::wp_puck(), wp_shield::wp_shield(), wp_warp::wp_warp(), and wp_weasel::wp_weasel().
bool Weapon::canFireCrouching [protected] |
specifies whether or not this Weapon can be fired while the player is crouching
Definition at line 111 of file weapon.h.
Referenced by fire(), wp_1000V::wp_1000V(), wp_boomerang::wp_boomerang(), wp_boot::wp_boot(), wp_chut::wp_chut(), wp_dunce::wp_dunce(), wp_gren::wp_gren(), wp_gun::wp_gun(), wp_hook::wp_hook(), wp_invis::wp_invis(), wp_magnet::wp_magnet(), wp_mine::wp_mine(), wp_net::wp_net(), wp_puck::wp_puck(), wp_shield::wp_shield(), wp_warp::wp_warp(), and wp_weasel::wp_weasel().
bool Weapon::canMoveWhileFiring [protected] |
specifies whether or not the Player can move whilst firing this Weapon
Definition at line 113 of file weapon.h.
Referenced by handleMovementAndAmmo(), wp_gun::weaponFireAction(), wp_boomerang::wp_boomerang(), wp_boot::wp_boot(), wp_chut::wp_chut(), wp_gren::wp_gren(), wp_gun::wp_gun(), wp_hook::wp_hook(), wp_invis::wp_invis(), wp_magnet::wp_magnet(), wp_mine::wp_mine(), wp_net::wp_net(), wp_puck::wp_puck(), wp_warp::wp_warp(), and wp_weasel::wp_weasel().
s8 Weapon::ammo [protected] |
the amount of shots remaining in this Weapon. When ammo is depleted, the Weapon is deleted.
Definition at line 115 of file weapon.h.
Referenced by getAmmo(), handleMovementAndAmmo(), wp_1000V::wp_1000V(), wp_boomerang::wp_boomerang(), wp_boot::wp_boot(), wp_chut::wp_chut(), wp_dunce::wp_dunce(), wp_gren::wp_gren(), wp_gun::wp_gun(), wp_hook::wp_hook(), wp_invis::wp_invis(), wp_magnet::wp_magnet(), wp_mine::wp_mine(), wp_net::wp_net(), wp_puck::wp_puck(), wp_shield::wp_shield(), wp_warp::wp_warp(), and wp_weasel::wp_weasel().
bool Weapon::bHeldFire [protected] |
specifies if this Weapon operates in 'held-fire' mode or 'single-fire' mode
Definition at line 118 of file weapon.h.
Referenced by fire(), handleMovementAndAmmo(), wp_gun::weaponFireAction(), weaponTick(), wp_1000V::wp_1000V(), wp_boomerang::wp_boomerang(), wp_boot::wp_boot(), wp_chut::wp_chut(), wp_dunce::wp_dunce(), wp_gren::wp_gren(), wp_gun::wp_gun(), wp_hook::wp_hook(), wp_invis::wp_invis(), wp_magnet::wp_magnet(), wp_mine::wp_mine(), wp_net::wp_net(), wp_puck::wp_puck(), wp_shield::wp_shield(), wp_warp::wp_warp(), and wp_weasel::wp_weasel().
vector<u8> Weapon::firingAnim [protected] |
the animation to play once for single-fire Weapons when fired
Definition at line 120 of file weapon.h.
Referenced by handleMovementAndAmmo(), wp_gun::weaponFireAction(), wp_boomerang::wp_boomerang(), wp_gren::wp_gren(), wp_gun::wp_gun(), wp_mine::wp_mine(), wp_net::wp_net(), wp_puck::wp_puck(), and wp_weasel::wp_weasel().
u8 Weapon::fireAnimSpeed [protected] |
the speed to play Weapon::firingAnim at
Definition at line 122 of file weapon.h.
Referenced by handleMovementAndAmmo(), and wp_gun::weaponFireAction().
bool Weapon::bFiring [protected] |
true while the Weapon is firing
Definition at line 125 of file weapon.h.
Referenced by fire(), isFiring(), stopFiring(), wp_mine::weaponFireAction(), wp_boomerang::weaponFireAction(), wp_hook::weaponTick(), and weaponTick().
bool Weapon::bWasFiring [protected] |
true if the Weapon was firing in the previous tick
Definition at line 127 of file weapon.h.
Referenced by wasFiring(), wp_hook::weaponTick(), and weaponTick().