Changeset 12281 for code/branches/OrxoBlox_FS19/src/modules
- Timestamp:
- Apr 4, 2019, 4:37:19 PM (6 years ago)
- Location:
- code/branches/OrxoBlox_FS19/src/modules
- Files:
-
- 6 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.cc
r12254 r12281 21 21 * 22 22 * Author: 23 * Fabien Vultier23 * Hagen Seifert 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ 28 28 29 29 /** 30 @file IceGun.cc31 @brief Implementation of the IceGunclass.30 @file HsW01.h 31 @brief Implementation of the HsW01 class. 32 32 */ 33 33 … … 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "core/XMLPort.h" 37 #include "core/XMLPort.h" 38 #include "core/command/Executor.h" 39 40 #include "graphics/Model.h" 38 41 #include "weaponsystem/Weapon.h" 39 42 #include "weaponsystem/WeaponPack.h" 40 43 #include "weaponsystem/WeaponSystem.h" 44 #include "worldentities/WorldEntity.h" 41 45 #include "worldentities/pawns/Pawn.h" 42 46 43 #include "BallProjectile.h" 47 #include "weapons/projectiles/Projectile.h" 48 #include "weapons/MuzzleFlash.h" 44 49 45 50 namespace orxonox … … 51 56 RegisterObject(BallGun); 52 57 53 // Default values 54 this->reloadTime_ = 1.0f; 55 this->damage_ = 0.0f; 56 this->speed_ = 1200.0f; 58 this->reloadTime_ = 0.25f; 59 this->damage_ = 0.0f; //default 15 60 this->speed_ = 750.0f; 61 this->delay_ = 0.0f; 62 this->setMunitionName("BallMunition"); 63 this->mesh_ = "laserbeam.mesh"; 57 64 58 65 59 this->setMunitionName("BallMunition"); 60 this->setFireSound("sounds/Weapon_LightningGun.ogg"); 61 this->setReloadSound("sounds/Reload_IceGun.ogg", 0.4); 66 this->delayTimer_.setTimer(this->delay_, false, createExecutor(createFunctor(&BallGun::shot, this))); 67 this->delayTimer_.stopTimer(); 62 68 63 hudImageString_ = "Orxonox/WSHUD_WM_IceGun"; 69 this->setFireSound("sounds/Weapon_HsW01.ogg"); 70 this->setReloadSound("sounds/Reload_HsW01.ogg", 0.5); 71 72 hudImageString_ = "Orxonox/WSHUD_WM_HsW01"; 64 73 } 65 74 … … 68 77 } 69 78 79 void BallGun::XMLPort(Element& xmlelement, XMLPort::Mode mode) 80 { 81 SUPER(BallGun, XMLPort, xmlelement, mode); 82 83 XMLPortParam(BallGun, "delay", setDelay, getDelay, xmlelement, mode); 84 XMLPortParam(BallGun, "material", setMaterial, getMaterial, xmlelement, mode); 85 XMLPortParam(BallGun, "projectileMesh", setMesh, getMesh, xmlelement, mode); 86 XMLPortParam(BallGun, "sound", setSound, getSound, xmlelement, mode); 87 } 88 89 /** 90 @brief 91 Set the firing delay. 92 @param delay 93 The firing delay in seconds. 94 */ 95 void BallGun::setDelay(float delay) 96 { 97 orxout() << "delay" << endl; 98 this->delay_ = delay; 99 this->delayTimer_.setInterval(this->delay_); 100 } 101 102 void BallGun::fire() 103 { 104 orxout() << "fire" << endl; 105 this->delayTimer_.startTimer(); 106 } 107 70 108 /** 71 109 @brief 72 110 Fires the weapon. Creates a projectile and fires it. 73 111 */ 74 void BallGun:: fire()112 void BallGun::shot() 75 113 { 76 BallProjectile* projectile = new BallProjectile(this->getContext()); 114 assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() ); 115 orxout() << "sajkfg" << endl; 116 // Create the projectile. 117 Projectile* projectile = new Projectile(this->getContext()); 118 Model* model = new Model(projectile->getContext()); 119 model->setMeshSource(mesh_); 120 model->setCastShadows(false); 121 projectile->attach(model); 122 model->setScale(5); 77 123 78 124 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); … … 85 131 projectile->setShieldDamage(this->getShieldDamage()); 86 132 projectile->setHealthDamage(this->getHealthDamage()); 133 134 // Display the muzzle flash. 135 this->BallGun::muzzleflash(); 136 } 137 138 /** 139 @brief 140 Displays the muzzle flash. 141 */ 142 void BallGun::muzzleflash() 143 { 144 MuzzleFlash *muzzleFlash = new MuzzleFlash(this->getContext()); 145 this->getWeapon()->attach(muzzleFlash); 146 muzzleFlash->setPosition(this->getMuzzleOffset()); 147 muzzleFlash->setMaterial(this->material_); 87 148 } 88 149 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.h
r12254 r12281 21 21 * 22 22 * Author: 23 * Fabien Vultier23 * Hagen Seifert 24 24 * Co-authors: 25 25 * ... … … 28 28 29 29 /** 30 @file IceGun.h31 @brief Definition of the IceGunclass.30 @file HsW01.h 31 @brief Definition of the HsW01 class. 32 32 */ 33 33 … … 36 36 37 37 #include "weapons/WeaponsPrereqs.h" 38 39 #include "tools/Timer.h" 38 40 #include "weaponsystem/WeaponMode.h" 39 41 … … 43 45 /** 44 46 @brief 45 A Gun that fires ice arrows that slow down any SpaceShip object that gets hit.47 Shoots laser beams. 46 48 @author 47 Fabien Vultier49 Hagen Seifert 48 50 @ingroup WeaponsWeaponModes 49 51 */ … … 55 57 56 58 virtual void fire() override; 57 58 private: 59 float speed_; //The speed of the fired projectile. 59 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 60 61 protected: 62 /** 63 @brief Set the mesh. 64 @param mesh The mesh name. 65 */ 66 void setMesh(const std::string& mesh) 67 { this->mesh_ = mesh; } 68 69 /** 70 @brief Get the mesh. 71 @return Returns the mesh name. 72 */ 73 const std::string& getMesh() const 74 { return this->mesh_; } 75 76 /** 77 @brief Set the sound. 78 @param sound The Sound name. 79 */ 80 void setSound(const std::string& sound) 81 { this->sound_ = sound; } 82 83 /** 84 @brief Get the sound. 85 @return Returns the sound name. 86 */ 87 const std::string& getSound() const 88 { return this->sound_; } 89 90 /** 91 @brief Set the material. 92 @param material The material name. 93 */ 94 void setMaterial(const std::string& material) 95 { this->material_ = material; } 96 /** 97 @brief Get the material. 98 @return Returns the material name. 99 */ 100 const std::string& getMaterial() const 101 { return this->material_; } 102 103 void setDelay(float delay); 104 /** 105 @brief Get the firing delay. 106 @return Returns the firing delay in seconds. 107 */ 108 float getDelay() const 109 { return this->delay_; } 110 111 virtual void shot(); 112 void muzzleflash(); 113 114 std::string material_; //!< The material. 115 std::string mesh_; //!< The mesh. 116 std::string sound_; //!< The sound. 117 118 119 120 float speed_; //!< The speed of the fired projectile. 121 float delay_; //!< The firing delay. 122 Timer delayTimer_; //!< A timer to delay the firing. 60 123 }; 61 124 } 62 125 63 #endif /* _ IceGun_H__ */126 #endif /* _HsW01_H__ */ -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallMunition.cc
r12254 r12281 39 39 RegisterClass(BallMunition); 40 40 41 BallMunition::BallMunition(Context* context) : Munition(context)41 BallMunition::BallMunition(Context* context) : ReplenishingMunition(context) 42 42 { 43 43 RegisterObject(BallMunition); 44 44 45 this->maxMunitionPerMagazine_ = 1;46 this->maxMagazines_ = 50;47 this->unassignedMagazines_ = 25;45 this->maxMunitionPerMagazine_ = 20; 46 this->maxMagazines_ = 10; 47 this->unassignedMagazines_ = 10; 48 48 49 this->deployment_ = MunitionDeployment::S tack;49 this->deployment_ = MunitionDeployment::Separate; 50 50 51 51 this->bAllowMunitionRefilling_ = true; 52 this->bAllowMultiMunitionRemovementUnderflow_ = false;52 this->bAllowMultiMunitionRemovementUnderflow_ = true; 53 53 54 this->reloadTime_ = 0.5f; 54 this->replenishInterval_ = 7.0f; 55 this->replenishAmount_ = 1; 56 57 this->reloadTime_ = 0.6f; 55 58 } 56 59 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallMunition.h
r12254 r12281 36 36 37 37 #include "weapons/WeaponsPrereqs.h" 38 #include "weaponsystem/ Munition.h"38 #include "weaponsystem/ReplenishingMunition.h" 39 39 40 40 namespace orxonox … … 48 48 @ingroup WeaponsMunitions 49 49 */ 50 class _WeaponsExport BallMunition : public Munition50 class _WeaponsExport BallMunition : public ReplenishingMunition 51 51 { 52 52 public: -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallProjectile.cc
r12254 r12281 38 38 #include "tools/ParticleInterface.h" 39 39 #include "Scene.h" 40 #include "core/command/Executor.h" 41 #include "util/Convert.h" 40 42 41 43 namespace orxonox … … 43 45 RegisterClass(BallProjectile); 44 46 45 BallProjectile::BallProjectile(Context* context) : Projectile(context)47 BallProjectile::BallProjectile(Context* context) : BillboardProjectile(context) 46 48 { 47 49 RegisterObject(BallProjectile); 48 49 this->particles_ = nullptr; 50 orxout() << "It's a bird, it's a plane' it's a BallParticle..." << endl; 51 this->textureIndex_ = 1; 52 this->setMass(0.1f); 53 this->maxTextureIndex_ = 8; 50 54 this->setDestroyAfterCollision(false); //I want the ball to bounce, not to be destroyed 51 55 … … 53 57 } 54 58 55 BallProjectile::~BallProjectile()59 void BallProjectile::registerVariables() 56 60 { 57 if (this->isInitialized() && this->particles_) 58 { 59 this->detachOgreObject(this->particles_->getParticleSystem()); 60 delete this->particles_; 61 } 61 registerVariable(this->materialBase_); 62 } 63 64 /** 65 @brief 66 Set the material. 67 @param material 68 The name of the material. Material names with 1 to 8 appended must exist. 69 */ 70 void BallProjectile::setMaterial(const std::string& material) 71 { 72 this->materialBase_ = material; 73 74 BillboardProjectile::setMaterial(material + multi_cast<std::string>(this->textureIndex_)); 75 } 76 77 /** 78 @brief 79 Change the texture. 80 */ 81 void BallProjectile::changeTexture() 82 { 83 this->textureIndex_++; 84 if (this->textureIndex_ > this->maxTextureIndex_) 85 this->textureIndex_ = 1; 86 87 this->setMaterial(this->materialBase_); 62 88 } 63 89 … … 68 94 Vector3 contactPosition = this->getPosition(); 69 95 70 if (positionOtherObject.y < 0) { 71 this->destroy(); 72 } 73 else { 96 //if (positionOtherObject.y < 0) { 97 //this.destroy() 98 //} 99 //else { 100 74 101 int distance_X = positionOtherObject.x - contactPosition.x; 102 int distance_Y = positionOtherObject.y - contactPosition.y; 75 103 76 104 if (distance_X < 0) 77 distance_X = -distance_X; 78 79 int distance_Y = positionOtherObject.y - contactPosition.y; 105 distance_Y = -distance_Y; 106 80 107 81 108 if (distance_Y < 0) 82 distance_ Y = -distance_Y;109 distance_X = -distance_X; 83 110 84 111 if (distance_X < distance_Y) … … 90 117 velocity.y = -velocity.y; 91 118 } 92 }119 //} 93 120 } 94 95 121 96 122 /** … … 110 136 */ 111 137 138 /* 139 bool BallProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 140 { 141 orxout() << "I collided against something" << endl; 142 return this->processCollision(otherObject, contactPoint, cs); 143 } 144 */ 145 146 bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape*) 147 { 112 148 113 bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)114 {115 if (GameMode::isMaster())116 {149 orxout() << "wanna bounce..." << endl; 150 bool result = BasicProjectile::processCollision(otherObject, contactPoint, cs); 151 Bounce(otherObject, contactPoint, cs); 152 orxout() << "BOUNCED!" << endl; 117 153 118 Pawn* victim = orxonox_cast<Pawn*>(otherObject); // If otherObject isn't a Pawn, then victim is nullptr 119 120 WorldEntity* entity = orxonox_cast<WorldEntity*>(this); 121 assert(entity); // The projectile must not be a WorldEntity. 122 123 // If visual effects after destruction cause problems, put this block below the effects code block 124 if (victim) 125 { 126 victim->hit(this->getShooter(), contactPoint, cs, this->getDamage(), this->getHealthDamage(), this->getShieldDamage()); 127 victim->startShieldRechargeCountdown(); 128 } 129 130 // Visual effects for being hit, depending on whether the shield is hit or not 131 if (this->getShooter()) // If the owner does not exist (anymore?), no effects are displayed. 132 { 133 // Damping and explosion effect is only played if the victim is no Pawn (see cast above) 134 // or if the victim is a Pawn, has no shield left, is still alive and any damage goes to the health 135 if (!victim || (victim && !victim->hasShield() && victim->getHealth() > 0.0f && (this->getDamage() > 0.0f || this->getHealthDamage() > 0.0f))) 136 { 137 { 138 ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext()); 139 effect->setPosition(entity->getPosition()); 140 effect->setOrientation(entity->getOrientation()); 141 effect->setDestroyAfterLife(true); 142 effect->setSource("Orxonox/explosion3"); 143 effect->setLifetime(2.0f); 144 } 145 // Second effect with same condition 146 { 147 ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext()); 148 effect->setPosition(entity->getPosition()); 149 effect->setOrientation(entity->getOrientation()); 150 effect->setDestroyAfterLife(true); 151 effect->setSource("Orxonox/smoke4"); 152 effect->setLifetime(3.0f); 153 } 154 } 155 156 // victim->isAlive() is not false until the next tick, so getHealth() > 0 is used instead 157 if (victim && victim->hasShield() && (this->getDamage() > 0.0f || this->getShieldDamage() > 0.0f) && victim->getHealth() > 0.0f) 158 { 159 ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext()); 160 effect->setDestroyAfterLife(true); 161 effect->setSource("Orxonox/Shield"); 162 effect->setLifetime(0.5f); 163 victim->attach(effect); 164 } 165 } 166 167 Bounce(otherObject, contactPoint, cs); 168 169 return true; 170 } 171 return false; 154 return result; 172 155 } 173 156 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallProjectile.h
r12254 r12281 48 48 @ingroup WeaponsProjectiles 49 49 */ 50 class _WeaponsExport BallProjectile : public Projectile50 class _WeaponsExport BallProjectile : public BillboardProjectile 51 51 { 52 52 public: 53 53 BallProjectile(Context* context); 54 virtual ~BallProjectile(); 55 virtual void Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs); 56 virtual bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs); 54 void Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs); 55 //bool BallProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 56 bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape*); 57 virtual void setMaterial(const std::string& material) override; 58 57 59 private: 58 ParticleInterface* particles_; //!< The particles. 60 61 void registerVariables(); 62 void changeTexture(); 63 64 unsigned int textureIndex_; //!< The current index of the texture. (i.e. the index of the currently displayed texture) 65 unsigned int maxTextureIndex_; //!< The maximal index. 66 std::string materialBase_; //!< The base name of the material. 59 67 }; 60 68 } -
code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/CMakeLists.txt
r11108 r12281 9 9 SplitMunition.cc 10 10 MineMunition.cc 11 BallMunition.cc 11 12 ) -
code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BasicProjectile.h
r11108 r12281 117 117 118 118 protected: 119 bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);119 virtual bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs); 120 120 void destroyCheck(void); 121 121 inline void setDestroyAfterCollision(bool destroyAfterCollision) -
code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/CMakeLists.txt
r12191 r12281 15 15 MineProjectile.cc 16 16 WagnisProjectile.cc 17 BallProjectile.cc 17 18 ) -
code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/CMakeLists.txt
r12191 r12281 14 14 MineGun.cc 15 15 WagnisGun.cc 16 BallGun.cc 16 17 )
Note: See TracChangeset
for help on using the changeset viewer.