[Orxonox-commit 2447] r7154 - in code/branches/presentation3/src: modules/weapons/projectiles modules/weapons/weaponmodes orxonox/infos

scheusso at orxonox.net scheusso at orxonox.net
Mon Jul 12 14:06:16 CEST 2010


Author: scheusso
Date: 2010-07-12 14:06:15 +0200 (Mon, 12 Jul 2010)
New Revision: 7154

Modified:
   code/branches/presentation3/src/modules/weapons/projectiles/Rocket.cc
   code/branches/presentation3/src/modules/weapons/projectiles/Rocket.h
   code/branches/presentation3/src/modules/weapons/weaponmodes/RocketFire.cc
   code/branches/presentation3/src/orxonox/infos/PlayerInfo.cc
Log:
some rocket related fixes


Modified: code/branches/presentation3/src/modules/weapons/projectiles/Rocket.cc
===================================================================
--- code/branches/presentation3/src/modules/weapons/projectiles/Rocket.cc	2010-07-12 11:08:58 UTC (rev 7153)
+++ code/branches/presentation3/src/modules/weapons/projectiles/Rocket.cc	2010-07-12 12:06:15 UTC (rev 7154)
@@ -40,6 +40,7 @@
 #include "infos/PlayerInfo.h"
 #include "controllers/Controller.h"
 #include "sound/WorldSound.h"
+#include "Scene.h"
 
 namespace orxonox
 {
@@ -115,9 +116,14 @@
     {
         if(this->isInitialized())
         {
-            if (GameMode::isMaster() && this->player_)
-                this->player_->stopTemporaryControl();
+            if (GameMode::isMaster())
+            {
+                this->destructionEffect();
 
+                if (this->getPlayer() && this->getController())
+                    this->player_->stopTemporaryControl();
+            }
+
             if ( this->defSndWpnEngine_ )
                 this->defSndWpnEngine_->destroy();
 
@@ -139,7 +145,6 @@
     void Rocket::setOwner(Pawn* owner)
     {
         this->owner_ = owner;
-        this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity();
         this->player_ = this->owner_->getPlayer();
         this->owner_->getPlayer()->startTemporaryControl(this);
 
@@ -227,27 +232,37 @@
 
     void Rocket::fired(unsigned int firemode)
     {
-        if (this->owner_)
+//         if (this->owner_)
+//         {
+            this->destroy();
+//         }
+    }
+    
+    void Rocket::destructionEffect()
+    {
+        ParticleSpawner *effect1, *effect2;
+        if( this->owner_ )
         {
-            {
-                ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
-                effect->setPosition(this->getPosition());
-                effect->setOrientation(this->getOrientation());
-                effect->setDestroyAfterLife(true);
-                effect->setSource("Orxonox/explosion4");
-                effect->setLifetime(2.0f);
-            }
-
-            {
-                ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
-                effect->setPosition(this->getPosition());
-                effect->setOrientation(this->getOrientation());
-                effect->setDestroyAfterLife(true);
-                effect->setSource("Orxonox/smoke4");
-                effect->setLifetime(3.0f);
-            }
-            this->destroy();
+            effect1 = new ParticleSpawner(this->owner_->getCreator());
+            effect2 = new ParticleSpawner(this->owner_->getCreator());
         }
+        else
+        {
+            effect1 = new ParticleSpawner(static_cast<BaseObject*>(this->getScene().get()));
+            effect2 = new ParticleSpawner(static_cast<BaseObject*>(this->getScene().get()));
+        }
+        
+        effect1->setPosition(this->getPosition());
+        effect1->setOrientation(this->getOrientation());
+        effect1->setDestroyAfterLife(true);
+        effect1->setSource("Orxonox/explosion4");
+        effect1->setLifetime(2.0f);
+        
+        effect2->setPosition(this->getPosition());
+        effect2->setOrientation(this->getOrientation());
+        effect2->setDestroyAfterLife(true);
+        effect2->setSource("Orxonox/smoke4");
+        effect2->setLifetime(3.0f);
     }
 
     /**

Modified: code/branches/presentation3/src/modules/weapons/projectiles/Rocket.h
===================================================================
--- code/branches/presentation3/src/modules/weapons/projectiles/Rocket.h	2010-07-12 11:08:58 UTC (rev 7153)
+++ code/branches/presentation3/src/modules/weapons/projectiles/Rocket.h	2010-07-12 12:06:15 UTC (rev 7154)
@@ -56,6 +56,7 @@
 
             virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
             void destroyObject();
+            void destructionEffect();
 
             virtual void moveFrontBack(const Vector2& value){}
             virtual void moveRightLeft(const Vector2& value){}
@@ -118,7 +119,6 @@
             Vector3 localAngularVelocity_;
             float damage_;
             bool bDestroy_;
-            ControllableEntity* originalControllableEntity_;
 
             WeakPtr<PlayerInfo> player_;
             Timer destroyTimer_;

Modified: code/branches/presentation3/src/modules/weapons/weaponmodes/RocketFire.cc
===================================================================
--- code/branches/presentation3/src/modules/weapons/weaponmodes/RocketFire.cc	2010-07-12 11:08:58 UTC (rev 7153)
+++ code/branches/presentation3/src/modules/weapons/weaponmodes/RocketFire.cc	2010-07-12 12:06:15 UTC (rev 7154)
@@ -65,8 +65,7 @@
         this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
         rocket->setOrientation(this->getMuzzleOrientation());
         rocket->setPosition(this->getMuzzlePosition());
-//         rocket->setVelocity(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity() + this->getMuzzleDirection() * this->speed_);
-        rocket->setVelocity(Vector3(1,0,0));
+        rocket->setVelocity(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity() + this->getMuzzleDirection() * this->speed_);
         rocket->scale(2);
 
         rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());

Modified: code/branches/presentation3/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/branches/presentation3/src/orxonox/infos/PlayerInfo.cc	2010-07-12 11:08:58 UTC (rev 7153)
+++ code/branches/presentation3/src/orxonox/infos/PlayerInfo.cc	2010-07-12 12:06:15 UTC (rev 7154)
@@ -176,13 +176,14 @@
         if (!entity)
             return;
 
-//         assert( this->temporaryControllableEntity_==0 );
+        assert( this->oldControllableEntity_==0 );
 
         this->oldControllableEntity_ = this->controllableEntity_;
         this->controllableEntity_ = entity;
         this->controllableEntityID_ = entity->getObjectID();
 
         entity->setPlayer(this);
+        entity->setController(this->controller_);
 
         if (this->controller_)
             this->controller_->setControllableEntity(entity);
@@ -221,6 +222,8 @@
         if( !entity || !this->oldControllableEntity_ )
             return;
 
+        this->controllableEntity_->setController(0);
+        
         this->controllableEntity_ = this->oldControllableEntity_;
         this->controllableEntityID_ = this->controllableEntity_->getObjectID();
         this->oldControllableEntity_ = 0;




More information about the Orxonox-commit mailing list