Changeset 10704 in orxonox.OLD for branches/presentation/src/world_entities/weapons
- Timestamp:
- Jun 15, 2007, 11:12:29 AM (17 years ago)
- Location:
- branches/presentation/src/world_entities/weapons
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/presentation/src/world_entities/weapons/bsp_weapon.cc
r10698 r10704 31 31 * Standard constructor 32 32 */ 33 BspWeapon::BspWeapon ( )34 { 35 this->init( );33 BspWeapon::BspWeapon ( OM_LIST list ) 34 { 35 this->init( list ); 36 36 } 37 37 … … 49 49 BspWeapon::BspWeapon (const TiXmlElement* root) 50 50 { 51 this->init( );51 this->init( OM_GROUP_00 ); 52 52 if (root != NULL) 53 53 { … … 94 94 void BspWeapon::tick( float dt ) 95 95 { 96 PRINTF(0)("BSPWEAPON TICK: %d %f %f\n", bFire, bRate, dt ); 96 97 if (bFire) { 97 if (bRate < 0) {98 if (bRate <= 0) { 98 99 bRate += fireRate; 100 PRINTF(0)("BSPWEAPON SHOOT\n"); 99 101 this->shoot(); 100 102 } … … 111 113 } 112 114 113 void BspWeapon::init( )114 { 115 bRate = 0 ;115 void BspWeapon::init( OM_LIST list ) 116 { 117 bRate = 0.0; 116 118 bFire = false; 117 119 range = 1000; … … 123 125 this->aimingSystem = new AimingSystem( this ); 124 126 this->aimingSystem->setParent( this ); 125 this->aimingSystem->toList( OM_GROUP_00);127 this->aimingSystem->toList(list); 126 128 127 129 } … … 157 159 158 160 bool hit = false; 161 162 PRINTF(0)("groups: %d %d %d %d\n", this->getOMListNumber(), this->aimingSystem->getOMListNumber(), OM_GROUP_01, OM_GROUP_00); 159 163 160 164 if ( target == NULL ) … … 170 174 hit = true; 171 175 printf( "HIT %s\n", target->getClassName().c_str() ); 176 target->hit( this->damage, this ); 172 177 } 173 178 else … … 178 183 } 179 184 180 if ( !hit ) 181 { 182 //Vector explosionPos = this->getAbsCoor() + this->getAbsDir().apply( Vector( 1, 0, 0 ) )*shortestDist; 183 184 //TODO create explosion at explosionPos 185 } 185 186 186 187 187 … … 196 196 (*it)->draw(); 197 197 } 198 #if 0198 #if 1 199 199 glMatrixMode(GL_MODELVIEW); 200 200 glPushMatrix(); -
branches/presentation/src/world_entities/weapons/bsp_weapon.h
r10698 r10704 51 51 ObjectListDeclaration(BspWeapon); 52 52 public: 53 BspWeapon ( );53 BspWeapon ( OM_LIST list ); 54 54 BspWeapon (const TiXmlElement* root); 55 55 virtual ~BspWeapon(); 56 56 57 void init( );57 void init( OM_LIST list ); 58 58 void loadParams(const TiXmlElement* root); 59 void fire(bool fire){ bFire = fire; }59 void fire(bool fire){ this->bFire = fire; } 60 60 virtual void tick(float dt); 61 61 virtual void draw() const; 62 62 63 63 void setAlwaysHits( bool r ){ this->alwaysHits = r; } 64 void setDamage( float d ){ this->damage = d; } 64 65 private: 65 66 … … 68 69 void setRange( float r ){ this->range = r; } 69 70 float damage; 70 void setDamage( float d ){ this->damage = d; }71 71 float fireRate; 72 72 void setFireRate( float r ){ this->fireRate = r; } 73 73 bool alwaysHits; 74 void setAlwaysHits( bool r ){ this->alwaysHits = r; }75 74 void addPoint(float x, float y, float z); 76 75 -
branches/presentation/src/world_entities/weapons/fps_sniper_rifle.cc
r10317 r10704 27 27 #include "weapon_manager.h" 28 28 #include "util/loading/factory.h" 29 #include "debug.h" 29 30 30 31 … … 48 49 creates a new weapon 49 50 */ 50 FPSSniperRifle::FPSSniperRifle ( int leftRight )51 FPSSniperRifle::FPSSniperRifle ( int leftRight, OM_LIST list) 51 52 : Weapon() 52 53 { 53 this->init( );54 this->init(list); 54 55 55 56 this->leftRight = leftRight; … … 59 60 FPSSniperRifle::FPSSniperRifle(const TiXmlElement* root) 60 61 { 61 this->init( );62 this->init( OM_GROUP_01 ); 62 63 63 64 if (root != NULL) … … 76 77 77 78 78 void FPSSniperRifle::init( )79 void FPSSniperRifle::init(OM_LIST list) 79 80 { 80 81 this->registerObject(this, FPSSniperRifle::_objectList); … … 95 96 //this->minCharge = 2; 96 97 97 this->setActionSound(WA_SHOOT, "sounds/laser.wav");98 this->setActionSound(WA_ACTIVATE, "sounds/voices/lasers.wav");98 //this->setActionSound(WA_SHOOT, "sounds/laser.wav"); 99 //this->setActionSound(WA_ACTIVATE, "sounds/voices/lasers.wav"); 99 100 100 101 101 102 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 102 this->setProjectileTypeC("Laser"); 103 this->prepareProjectiles(20); 104 103 //this->setProjectileTypeC("Laser"); 104 //this->prepareProjectiles(20); 105 this->toList( list ); 106 this->weapon = new BspWeapon( this->getOMListNumber() ); 107 this->weapon->setAlwaysHits( true ); 108 this->weapon->setDamage( 35 ); 109 this->weapon->setParent( this ); 110 this->weapon->toList( list ); 111 112 this->bFire = false; 105 113 } 106 114 … … 145 153 void FPSSniperRifle::fire() 146 154 { 147 Projectile* pj = this->getProjectile(); 148 if (pj == NULL) 149 return; 150 151 // Explosion::explode(this, Vector(0.1,0.1,0.1)); 152 153 pj->setParent(this); 154 pj->setParentMode(PNODE_ROTATE_AND_MOVE); 155 156 pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*550 + VECTOR_RAND(5) ); 157 158 pj->setAbsCoor(this->getEmissionPoint() + this->getAbsDirX() * 25.0f); 159 pj->setAbsDir(this->getAbsDir()); 160 pj->activate(); 155 PRINTF(0)("sniper fire\n"); 156 this->bFire = true; 161 157 } 162 158 … … 190 186 } 191 187 192 193 188 void FPSSniperRifle::tick( float dt ) 189 { 190 Weapon::tick( dt ); 191 this->weapon->fire( bFire ); 192 193 if ( bFire ){ 194 PRINTF(0)("REAL FIRE\n"); 195 } 196 bFire = false; 197 } 198 199 200 -
branches/presentation/src/world_entities/weapons/fps_sniper_rifle.h
r9869 r10704 25 25 26 26 #include "weapon.h" 27 #include "bsp_weapon.h" 27 28 28 29 … … 42 43 43 44 public: 44 FPSSniperRifle (int leftRight );45 FPSSniperRifle (int leftRight, OM_LIST list); 45 46 FPSSniperRifle (const TiXmlElement* root); 46 47 virtual ~FPSSniperRifle (); 47 48 48 void init( );49 void init(OM_LIST list); 49 50 virtual void loadParams(const TiXmlElement* root); 50 51 … … 55 56 56 57 virtual void draw() const; 58 virtual void tick( float dt ); 57 59 58 60 … … 61 63 int leftRight; //!< this will become an enum 62 64 Material* material; //!< material 65 66 BspWeapon* weapon; 67 bool bFire; 63 68 64 69 };
Note: See TracChangeset
for help on using the changeset viewer.