/* $Id: bonushomingvirus.hpp,v 1.6 2005/10/05 14:46:44 chfreund Exp $ */ #ifndef _BONUSHOMINGVIRUS_HPP_ #define _BONUSHOMINGVIRUS_HPP_ /**********************************************************/ #include "avatar.hpp" #include "bonus.hpp" #include "homingmissile.hpp" /**********************************************************/ #define HOMING_VIRUS_INFECTION_RADIUS 150 /**********************************************************/ //! bonus, that carries a program virus for homing missiles class BonusHomingVirus : public Bonus { public: BonusHomingVirus( World* wp ); ~BonusHomingVirus(); //! reimplemented from base class Object inline Sint32 getID() const { return BONUS_HOMING_VIRUS; } //! reimplemented from base class Bonus inline bool isWeapon() const { return false; } //! returns the number of left applications inline Sint32 getNumDefenses() const { return m_numDefenses; } //! sets the number of left applications inline void setNumDefenses( Sint32 nDef ) { m_numDefenses = nDef; } //! \name functions for the interaction with avatars //@{ //! shield boni can always be picked up inline bool canBePickedUpByAvatar( const Avatar* const avatar ) { return true; } //! adds two shield boni void add( const Bonus *const bonus ); //! update for the shield bonus in the avtar's bonus pack bool updateInBonusPack( Avatar *const avatar ) { return m_numDefenses > 0; } //! shield boni must be put into the bonus pack of the avatar inline bool mustBePutIntoPack() const { return true; } //! applies the virus once to the passe missile inline void applyVirus( HomingMissile *const missile, const Avatar *const newOwner ) { missile->setOwner( newOwner->getPlayer()->getPlayerID() ); m_numDefenses--; } //@} //! returns the square of the detection radius static real getInfectionRadius() { return HOMING_VIRUS_INFECTION_RADIUS; } //! returns the square of the detection radius static real getInfectionRadiusSquare() { return HOMING_VIRUS_INFECTION_RADIUS * HOMING_VIRUS_INFECTION_RADIUS; } //! \name (de)serialization //@{ virtual Uint32 getSerializeBufferSize() const; virtual void serialize( Uint8*& bufferPointer ) const; virtual void deserialize( Uint8*& bufferPointer ); //@} protected: //! number of possible Sint32 m_numDefenses; }; /**********************************************************/ #endif // _BONUSHOMINGVIRUS_HPP_