1 /* $Id: bonushomingvirus.hpp,v 1.6 2005/10/05 14:46:44 chfreund Exp $ */
2 
3 #ifndef _BONUSHOMINGVIRUS_HPP_
4 #define _BONUSHOMINGVIRUS_HPP_
5 
6 /**********************************************************/
7 
8 #include "avatar.hpp"
9 #include "bonus.hpp"
10 #include "homingmissile.hpp"
11 
12 /**********************************************************/
13 #define  HOMING_VIRUS_INFECTION_RADIUS  150
14 /**********************************************************/
15 
16 //! bonus, that carries a program virus for homing missiles
17 class BonusHomingVirus : public Bonus
18 {
19 	public:
20 
21 		BonusHomingVirus( World* wp );
22 		~BonusHomingVirus();
23 
24 		//! reimplemented from base class Object
getID() const25 		inline Sint32 getID() const { return BONUS_HOMING_VIRUS; }
26 		//! reimplemented from base class Bonus
isWeapon() const27 		inline bool isWeapon() const { return false; }
28 
29 		//! returns the number of left applications
getNumDefenses() const30 		inline Sint32 getNumDefenses() const {
31 			return m_numDefenses; }
32 		//! sets the number of left applications
setNumDefenses(Sint32 nDef)33 		inline void setNumDefenses( Sint32 nDef ) {
34 			m_numDefenses = nDef; }
35 
36 		//! \name functions for the interaction with avatars
37 		//@{
38 		//! shield boni can always be picked up
canBePickedUpByAvatar(const Avatar * const avatar)39 		inline bool canBePickedUpByAvatar( const Avatar* const avatar ) {
40 			return true; }
41 
42 		//! adds two shield boni
43 		void add( const Bonus *const bonus );
44 
45 		//! update for the shield bonus in the avtar's bonus pack
updateInBonusPack(Avatar * const avatar)46 		bool updateInBonusPack( Avatar *const avatar ) {
47 			return m_numDefenses > 0; }
48 
49 		//! shield boni must be put into the bonus pack of the avatar
mustBePutIntoPack() const50 		inline bool mustBePutIntoPack() const { return true; }
51 
52 		//! applies the virus once to the passe missile
applyVirus(HomingMissile * const missile,const Avatar * const newOwner)53 		inline void applyVirus( HomingMissile *const missile,
54 		                        const Avatar  *const newOwner ) {
55 			missile->setOwner( newOwner->getPlayer()->getPlayerID() );
56 			m_numDefenses--;
57 		}
58 		//@}
59 
60 		//! returns the square of the detection radius
getInfectionRadius()61 		static real getInfectionRadius() {
62 			return HOMING_VIRUS_INFECTION_RADIUS; }
63 
64 		//! returns the square of the detection radius
getInfectionRadiusSquare()65 		static real getInfectionRadiusSquare() {
66 			return   HOMING_VIRUS_INFECTION_RADIUS
67 			       * HOMING_VIRUS_INFECTION_RADIUS;
68 		}
69 
70 		//! \name (de)serialization
71 		//@{
72 		virtual Uint32 getSerializeBufferSize() const;
73 		virtual void serialize( Uint8*& bufferPointer ) const;
74 		virtual void deserialize( Uint8*& bufferPointer );
75 		//@}
76 
77 
78 	protected:
79 
80 		//! number of possible
81 		Sint32 m_numDefenses;
82 };
83 
84 /**********************************************************/
85 
86 #endif // _BONUSHOMINGVIRUS_HPP_
87