/*! \file weapon.h \brief a weapon that a player can use A Player has a list of weapons, that can be choosen to shoot projectiles (projectiles.{cc,h}) at ennemies. These weapons can be shooted sequentially or (if able) combined. Therefore you can choose the weapon mode = choose a weapon. A weapon is characterized by: o firing-rate: the initial firing rate of a weapon (1/s = Herz) o slowdown-factor: this is a factor d: exp(-d*x), d is element of all positive R. it determines how fast the firing-rate will slow down. if no slowdown: d=0, the bigger d is, the faster the weapon will slow down! o energy-consumption: this determines the energy that has to be used to produce this projectile = costs per projectile Furthermore there are some other attributes, that will help to represent a firing weapon in this world: o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented o shooting animation a player defines one or more weapon configurations. a player has got one to eight weapon slots: places where weapons can be attached to. a weapon configuration is a matching between weapons and slots. Since its clear how many weapons a player will have, there is no list of weapons: its hard coded and limited to 8 slots and 4 configs. More would be a waste of memory and time you need to customize and change to a weapon config... */ #ifndef _WEAPON_H #define _WEAPON_H #include "world_entity.h" #define W_MAX_SLOTS 8 #define W_MAX_CONFIGS 4 class Projectile; class Weapon; class Animation3D; typedef enum { SHOOT, EMPTY, RELOAD, SPECIAL1, SPECIAL2, SPECIAL3 } weaponSoundType; //! this is an identifier for the slot. there are up to 8 weapon slots -> this means there can't be more than 8 weapons at the same time #define W_SLOT0 0 #define W_SLOT1 1 #define W_SLOT2 2 #define W_SLOT3 3 #define W_SLOT4 4 #define W_SLOT5 5 #define W_SLOT6 6 #define W_SLOT7 7 #define W_FREE_SLOT 99 //! this is an identifier for the weapon config #define W_CONFIG0 0 #define W_CONFIG1 1 #define W_CONFIG2 2 #define W_CONFIG3 3 //! a weapon can be left or right sided #define W_LEFT 0 #define W_RIGHT 1 //! this is a weapon Configuration: it has up to 8 slots typedef struct weaponConfig { bool bUsed; //idleTime = time; } /** \brief gets the weapon idle time \returns idle time in ms a weapon idle time is the time spend after a shoot until the weapon can shoot again */ inline float getWeaponIdleTime(void) const { return this->idleTime;} /** \brief checks if the idle time is elapsed \return true if time is elapsed a weapon idle time is the time spend after a shoot until the weapon can shoot again */ inline bool hasWeaponIdleTimeElapsed(void) const { return (this->localTime>this->idleTime)?true:false; } /** \brief fires the weapon this is called from the player.cc, when fire-button is been pushed */ virtual void fire(void) = 0; virtual void hit (WorldEntity* weapon, Vector* loc); virtual void destroy(void); virtual void tick(float time); virtual void weaponIdle(void); virtual void draw(void); protected: tList* worldEntities; float localTime; //