[Orxonox-commit 269] r2918 - in branches/weapons/src/orxonox: . objects/controllers objects/weaponSystem objects/weaponSystem/munitions objects/weaponSystem/projectiles objects/weaponSystem/weapons objects/worldentities objects/worldentities/pawns
landauf at orxonox.net
landauf at orxonox.net
Sat Apr 18 18:14:52 CEST 2009
Author: landauf
Date: 2009-04-18 18:14:52 +0200 (Sat, 18 Apr 2009)
New Revision: 2918
Added:
branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.cc
branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.h
branches/weapons/src/orxonox/objects/weaponSystem/munitions/ReplenishingMunition.cc
branches/weapons/src/orxonox/objects/weaponSystem/munitions/ReplenishingMunition.h
branches/weapons/src/orxonox/objects/weaponSystem/weapons/FusionFire.cc
branches/weapons/src/orxonox/objects/weaponSystem/weapons/FusionFire.h
branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserFire.cc
branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserFire.h
Removed:
branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.cc
branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.h
branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.cc
branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.h
Modified:
branches/weapons/src/orxonox/OrxonoxPrereqs.h
branches/weapons/src/orxonox/objects/controllers/HumanController.cc
branches/weapons/src/orxonox/objects/controllers/HumanController.h
branches/weapons/src/orxonox/objects/weaponSystem/CMakeLists.txt
branches/weapons/src/orxonox/objects/weaponSystem/Munition.cc
branches/weapons/src/orxonox/objects/weaponSystem/Munition.h
branches/weapons/src/orxonox/objects/weaponSystem/Weapon.cc
branches/weapons/src/orxonox/objects/weaponSystem/Weapon.h
branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.cc
branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.h
branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.cc
branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.h
branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.cc
branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc
branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.h
branches/weapons/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt
branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.cc
branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.h
branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h
branches/weapons/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
branches/weapons/src/orxonox/objects/weaponSystem/projectiles/Projectile.h
branches/weapons/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt
branches/weapons/src/orxonox/objects/worldentities/ControllableEntity.h
branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.cc
branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.h
Log:
Added many new features in the Munition class:
- there are now 3 modes:
a) every weapon has it's own magazine
b) all weapons use the same magazin
c) no magazines, just a big munition pool
- the Munition class handles the reloading of the magazine
Split the Weapon class into Weapon and WeaponMode. WeaponMode creates the fire of the Weapon. A weapon can own several WeaponModes (for example primary and secondary fire). But it's also possible to have a weapon with several muzzles which all fire at the same time (there's a WeaponMode for each muzzle).
Renamed LaserGun to LaserFire and Fusion to FusionFire. They inherit now from WeaponMode.
Changed the code in the Weapon class to use the new Munition functionality.
Added ReplenishingMunition, a subclass of Munition that replenishes itself (used for LaserGunMunition).
Added a reload command to reload magazines.
Modified: branches/weapons/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- branches/weapons/src/orxonox/OrxonoxPrereqs.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/OrxonoxPrereqs.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -156,9 +156,14 @@
class WeaponSlot;
class WeaponPack;
class Weapon;
+ class WeaponMode;
class DefaultWeaponmodeLink;
+
+ class LaserFire;
+ class FusionFire;
+
+ class ReplenishingMunition;
class Munition;
- class LaserGun;
class LaserGunMunition;
class FusionMunition;
Modified: branches/weapons/src/orxonox/objects/controllers/HumanController.cc
===================================================================
--- branches/weapons/src/orxonox/objects/controllers/HumanController.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/controllers/HumanController.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -45,6 +45,7 @@
SetConsoleCommand(HumanController, rotatePitch, true).setAsInputCommand();
SetConsoleCommand(HumanController, rotateRoll, true).setAsInputCommand();
SetConsoleCommand(HumanController, fire, true).keybindMode(KeybindMode::OnHold);
+ SetConsoleCommand(HumanController, reload, true);
SetConsoleCommand(HumanController, boost, true).keybindMode(KeybindMode::OnHold);
SetConsoleCommand(HumanController, greet, true);
SetConsoleCommand(HumanController, use, true);
@@ -113,6 +114,12 @@
HumanController::localController_s->controllableEntity_->fire(firemode);
}
+ void HumanController::reload()
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->reload();
+ }
+
void HumanController::boost()
{
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
Modified: branches/weapons/src/orxonox/objects/controllers/HumanController.h
===================================================================
--- branches/weapons/src/orxonox/objects/controllers/HumanController.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/controllers/HumanController.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -51,6 +51,7 @@
static void rotateRoll(const Vector2& value);
static void fire(unsigned int firemode);
+ static void reload();
static void boost();
static void greet();
Modified: branches/weapons/src/orxonox/objects/weaponSystem/CMakeLists.txt
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/CMakeLists.txt 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/CMakeLists.txt 2009-04-18 16:14:52 UTC (rev 2918)
@@ -1,6 +1,7 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
Munition.cc
Weapon.cc
+ WeaponMode.cc
WeaponPack.cc
WeaponSet.cc
WeaponSlot.cc
Modified: branches/weapons/src/orxonox/objects/weaponSystem/Munition.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/Munition.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/Munition.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -19,8 +19,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Author:
+ * Authors:
* Martin Polak
+ * Fabian 'x3n' Landau
* Co-authors:
* ...
*
@@ -39,76 +40,442 @@
{
RegisterObject(Munition);
+ this->maxMunitionPerMagazine_ = 10;
+ this->maxMagazines_ = 10;
+ this->magazines_ = 10;
+
+ this->bUseSeparateMagazines_ = false;
+ this->bStackMunition_ = true;
+ this->bAllowMunitionRefilling_ = true;
+ this->bAllowMultiMunitionRemovementUnderflow_ = true;
+
+ this->reloadTime_ = 0;
+
COUT(0) << "+Munition" << std::endl;
}
Munition::~Munition()
{
+ for (std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
+ delete it->second;
+
COUT(0) << "~Munition" << std::endl;
}
- unsigned int Munition::bullets()
+ Munition::Magazine* Munition::getMagazine(WeaponMode* user) const
{
- if (this->bullets_ > 0)
- return bullets_;
+ if (this->bUseSeparateMagazines_)
+ {
+ // For separated magazines we definitively need a given user
+ if (!user)
+ return 0;
+
+ // Use the map to get the magazine assigned to the given user
+ std::map<WeaponMode*, Magazine*>::const_iterator it = this->currentMagazines_.find(user);
+ if (it != this->currentMagazines_.end())
+ return it->second;
+ }
else
- return 0;
+ {
+ // We don't use separate magazines for each user, so just take the first magazine
+ if (this->currentMagazines_.size() > 0)
+ return this->currentMagazines_.begin()->second;
+ }
+
+ return 0;
}
- unsigned int Munition::magazines()
+ unsigned int Munition::getNumMunition(WeaponMode* user) const
{
- if (this->magazines_ > 0)
- return magazines_;
+ Magazine* magazine = this->getMagazine(user);
+ if (magazine)
+ {
+ if (this->bStackMunition_)
+ // With stacked munition every magazine contributes to the total amount
+ return this->maxMunitionPerMagazine_ * this->magazines_ + magazine->munition_;
+ else
+ // Wihtout stacked munition we just consider the current magazine
+ return magazine->munition_;
+ }
+ return 0;
+ }
+
+ unsigned int Munition::getNumMunitionInCurrentMagazine(WeaponMode* user) const
+ {
+ // In contrast to getNumMunition() we really just consider the current magazine, even if we're stacking munition
+ Magazine* magazine = this->getMagazine(user);
+ if (magazine)
+ return magazine->munition_;
else
return 0;
}
- void Munition::setMaxBullets(unsigned int amount)
- { this->maxBullets_ = amount; }
+ unsigned int Munition::getNumMagazines() const
+ {
+ if (this->bStackMunition_)
+ {
+ // If we stack munition and the current magazine is still full, it counts too
+ Magazine* magazine = this->getMagazine(0);
+ if (magazine && magazine->munition_ == this->maxMunitionPerMagazine_)
+ return this->magazines_ + 1;
+ }
- void Munition::setMaxMagazines(unsigned int amount)
- { this->maxMagazines_ = amount; }
+ return this->magazines_;
+ }
- void Munition::removeBullets(unsigned int amount)
+ unsigned int Munition::getMaxMunition() const
{
- if ( this->bullets_ != 0 )
- this->bullets_ = this->bullets_ - amount;
+ if (this->bStackMunition_)
+ return this->maxMunitionPerMagazine_ * this->maxMagazines_;
+ else
+ return this->maxMunitionPerMagazine_;
}
- void Munition::removeMagazines(unsigned int amount)
+ bool Munition::canTakeMunition(unsigned int amount, WeaponMode* user) const
{
- if ( this->magazines_ != 0 )
- this->magazines_ = this->magazines_ - amount;
+ Magazine* magazine = this->getMagazine(user);
+ if (magazine && magazine->bLoaded_)
+ {
+ unsigned int munition = magazine->munition_;
+
+ // If we stack munition, we con't care about the current magazine - we just need enough munition in total
+ if (this->bStackMunition_)
+ munition += this->maxMunitionPerMagazine_ * this->magazines_;
+
+ if (munition == 0)
+ // Absolutely no munition - no chance to take munition
+ return false;
+ else if (this->bAllowMultiMunitionRemovementUnderflow_)
+ // We're not empty AND we allow underflow, so this will always work
+ return true;
+ else
+ // We don't allow underflow, so we have to check the amount
+ return (munition >= amount);
+ }
+ return false;
}
- void Munition::addBullets(unsigned int amount)
+ bool Munition::takeMunition(unsigned int amount, WeaponMode* user)
{
- if ( this->bullets_ == this->maxBullets_ )
+ if (!this->canTakeMunition(amount, user))
+ return false;
+
+ Magazine* magazine = this->getMagazine(user);
+ if (magazine && magazine->bLoaded_)
{
- //cannot add bullets to actual magazine
+ if (magazine->munition_ >= amount)
+ {
+ // Enough munition
+ magazine->munition_ -= amount;
+ return true;
+ }
+ else
+ {
+ // Not enough munition
+ if (this->bStackMunition_)
+ {
+ // We stack munition, so just take what we can and then load the next magazine
+ amount -= magazine->munition_;
+ magazine->munition_ = 0;
+
+ if (this->reload(0))
+ // Successfully reloaded, continue recursively
+ return this->takeMunition(amount, 0);
+ else
+ // We don't have more magazines, so let's just hope we allow underflow
+ return this->bAllowMultiMunitionRemovementUnderflow_;
+ }
+ else
+ {
+ // We don't stack, so we can only take munition if this is allowed
+ if (magazine->munition_ > 0 && this->bAllowMultiMunitionRemovementUnderflow_)
+ {
+ magazine->munition_ -= 0;
+ return true;
+ }
+ }
+ }
}
+ return false;
+ }
+
+ bool Munition::canReload() const
+ {
+ // As long as we have enough magazines (and don't stack munition) we can reload
+ return (this->magazines_ > 0 && !this->bStackMunition_);
+ }
+
+ bool Munition::needReload(WeaponMode* user) const
+ {
+ Magazine* magazine = this->getMagazine(user);
+ if (magazine)
+ {
+ if (this->bStackMunition_)
+ // With stacked munition, we never have to reload
+ return false;
+ else
+ // We need to reload if an already loaded magazine is empty
+ return (magazine->bLoaded_ && magazine->munition_ == 0);
+ }
else
- this->bullets_ = this->bullets_ + amount;
+ // No magazine - we definitively need to reload
+ return true;
}
- void Munition::addMagazines(unsigned int amount)
+ bool Munition::reload(WeaponMode* user, bool bUseReloadTime)
{
- if ( this->magazines_ == this->maxMagazines_ )
+ // Don't reload if we're already reloading
+ Magazine* magazine = this->getMagazine(user);
+ if (magazine && !magazine->bLoaded_)
+ return false;
+
+ // Check if we actually can reload
+ if (this->magazines_ == 0)
+ return false;
+
+ // If we use separate magazines for each user, we definitively need a user given
+ if (this->bUseSeparateMagazines_ && !user)
+ return false;
+
+ // If we don't use separate magazines, set user to 0
+ if (!this->bUseSeparateMagazines_)
+ user = 0;
+
+ // Remove the current magazine for the given user
+ std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.find(user);
+ if (it != this->currentMagazines_.end())
{
- //no more capacity for another magazine
+ delete it->second;
+ this->currentMagazines_.erase(it);
}
+
+ // Load a new magazine
+ this->currentMagazines_[user] = new Magazine(this, bUseReloadTime);
+ this->magazines_--;
+
+ return true;
+ }
+
+ bool Munition::canAddMunition(unsigned int amount) const
+ {
+ if (!this->bAllowMunitionRefilling_)
+ return false;
+
+ if (this->bStackMunition_)
+ {
+ // If we stack munition, we can always add munition until we reach the limit
+ return (this->getNumMunition(0) < this->getMaxMunition());
+ }
else
- this->magazines_ = this->magazines_ + amount;
+ {
+ // Return true if any of the current magazines is not full (loading counts as full although it returns 0 munition)
+ for (std::map<WeaponMode*, Magazine*>::const_iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
+ if (it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)
+ return true;
+ }
+
+ return false;
}
+ bool Munition::addMunition(unsigned int amount)
+ {
+ if (!this->canAddMunition(amount))
+ return false;
- void Munition::fillBullets()
+ if (this->bStackMunition_)
+ {
+ // Stacking munition means, if a magazine gets full, the munition adds to a new magazine
+ Magazine* magazine = this->getMagazine(0);
+ if (magazine)
+ {
+ // Add the whole amount
+ magazine->munition_ += amount;
+
+ // Add new magazines if the current magazine is overfull
+ while (magazine->munition_ > this->maxMunitionPerMagazine_)
+ {
+ magazine->munition_ -= this->maxMunitionPerMagazine_;
+ this->magazines_++;
+ }
+
+ // If we reached the limit, reduze both magazines and munition to the maximum
+ if (this->magazines_ >= this->maxMagazines_)
+ {
+ this->magazines_ = this->maxMagazines_ - 1;
+ magazine->munition_ = this->maxMunitionPerMagazine_;
+ }
+
+ return true;
+ }
+
+ // Something went wrong
+ return false;
+ }
+ else
+ {
+ // Share the munition equally to the current magazines
+ while (amount > 0)
+ {
+ bool change = false;
+ for (std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
+ {
+ // Add munition if the magazine isn't full (but only to loaded magazines)
+ if (amount > 0 && it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)
+ {
+ it->second->munition_++;
+ amount--;
+ change = true;
+ }
+ }
+
+ // If there was no change in a loop, all magazines are full (or locked due to loading)
+ if (!change)
+ break;
+ }
+
+ return true;
+ }
+ }
+
+ bool Munition::canAddMagazines(unsigned int amount) const
{
- this->bullets_ = this->maxBullets_;
+ if (this->bStackMunition_)
+ // If we stack munition, we can always add new magazines because they contribute directly to the munition
+ return (this->getNumMunition(0) < this->getMaxMunition());
+ else
+ // If we don't stack munition, we're more limited
+ return ((this->currentMagazines_.size() + this->magazines_) < this->maxMagazines_);
}
- void Munition::fillMagazines()
+ bool Munition::addMagazines(unsigned int amount)
{
- this->magazines_ = this->maxMagazines_;
+ if (!this->canAddMagazines(amount))
+ return false;
+
+ // Calculate how many magazines are needed
+ int needed_magazines = this->maxMagazines_ - this->magazines_ - this->currentMagazines_.size();
+
+ // If zero or less magazines are needed, we definitively don't need more magazines (unless we stack munition - then a magazine contributes directly to the munition)
+ if (needed_magazines <= 0 && !this->bStackMunition_)
+ return false;
+
+ if (amount <= needed_magazines)
+ {
+ // We need more magazines than we get, so just add them
+ this->magazines_ += amount;
+ }
+ else
+ {
+ // We get more magazines than we need, so just add the needed amount
+ this->magazines_ += needed_magazines;
+ if (this->bStackMunition_)
+ {
+ // We stack munition, so the additional amount contributes directly to the munition of the current magazine
+ Magazine* magazine = this->getMagazine(0);
+ if (magazine)
+ magazine->munition_ = this->maxMunitionPerMagazine_;
+ }
+ }
+
+ return true;
}
+
+ bool Munition::canRemoveMagazines(unsigned int amount) const
+ {
+ if (this->bStackMunition_)
+ {
+ if (this->magazines_ >= amount)
+ {
+ // We have enough magazines
+ return true;
+ }
+ else if (this->magazines_ == amount - 1)
+ {
+ // We lack one magazine, check if the current magazine is still full, if yes we're fine
+ Magazine* magazine = this->getMagazine(0);
+ if (magazine && magazine->munition_ == this->maxMunitionPerMagazine_)
+ return true;
+ }
+ else
+ {
+ // We don't have enough magazines
+ return false;
+ }
+ }
+ else
+ {
+ // In case we're not stacking munition, just check the number of magazines
+ return (this->magazines_ >= amount);
+ }
+ }
+
+ bool Munition::removeMagazines(unsigned int amount)
+ {
+ if (!this->canRemoveMagazines(amount))
+ return false;
+
+ if (this->magazines_ >= amount)
+ {
+ // We have enough magazines, just remove the amount
+ this->magazines_ -= amount;
+ }
+ else if (this->bStackMunition_)
+ {
+ // We don't have enough magazines, but we're stacking munition, so additionally remove the bullets from the current magazine
+ this->magazines_ = 0;
+ Magazine* magazine = this->getMagazine(0);
+ if (magazine)
+ magazine->munition_ = 0;
+ }
+
+ return true;
+ }
+
+ bool Munition::dropMagazine(WeaponMode* user)
+ {
+ // If we use separate magazines, we need a user
+ if (this->bUseSeparateMagazines_ && !user)
+ return false;
+
+ // If we don't use separate magazines, set user to 0
+ if (!this->bUseSeparateMagazines_)
+ user = 0;
+
+ // Remove the current magazine for the given user
+ std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.find(user);
+ if (it != this->currentMagazines_.end())
+ {
+ delete it->second;
+ this->currentMagazines_.erase(it);
+ return true;
+ }
+
+ return false;
+ }
+
+
+ /////////////////////
+ // Magazine struct //
+ /////////////////////
+ Munition::Magazine::Magazine(Munition* munition, bool bUseReloadTime)
+ {
+ this->munition_ = 0;
+ this->bLoaded_ = false;
+
+ if (bUseReloadTime && (munition->reloadTime_ > 0 || munition->bStackMunition_))
+ {
+ ExecutorMember<Magazine>* executor = createExecutor(createFunctor(&Magazine::loaded));
+ executor->setDefaultValues(munition);
+
+ this->loadTimer_.setTimer(munition->reloadTime_, false, this, executor);
+ }
+ else
+ this->loaded(munition);
+ }
+
+ void Munition::Magazine::loaded(Munition* munition)
+ {
+ this->bLoaded_ = true;
+ this->munition_ = munition->maxMunitionPerMagazine_;
+ }
}
Modified: branches/weapons/src/orxonox/objects/weaponSystem/Munition.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/Munition.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/Munition.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -19,8 +19,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Author:
+ * Authors:
* Martin Polak
+ * Fabian 'x3n' Landau
* Co-authors:
* ...
*
@@ -30,37 +31,78 @@
#define _Munition_H__
#include "OrxonoxPrereqs.h"
+
+#include <map>
+
#include "core/BaseObject.h"
+#include "tools/Timer.h"
namespace orxonox
{
class _OrxonoxExport Munition : public BaseObject
{
+ struct Magazine
+ {
+ public:
+ Magazine(Munition* munition, bool bUseReloadTime = true);
+
+ unsigned int munition_;
+ Timer<Magazine> loadTimer_;
+ bool bLoaded_;
+
+ private:
+ void loaded(Munition* munition);
+ };
+
public:
Munition(BaseObject* creator);
virtual ~Munition();
- void setMaxBullets(unsigned int amount);
- void setMaxMagazines(unsigned int amount);
+ unsigned int getNumMunition(WeaponMode* user) const;
+ unsigned int getNumMunitionInCurrentMagazine(WeaponMode* user) const;
+ unsigned int getNumMagazines() const;
- void fillBullets();
- void fillMagazines();
+ unsigned int getMaxMunition() const;
+ inline unsigned int getMaxMagazines() const
+ { return this->maxMagazines_; }
+ inline unsigned int getMaxMunitionPerMagazine() const
+ { return this->maxMunitionPerMagazine_; }
- unsigned int bullets();
- unsigned int magazines();
+ bool canTakeMunition(unsigned int amount, WeaponMode* user) const;
+ bool takeMunition(unsigned int amount, WeaponMode* user);
- void removeBullets(unsigned int k);
- void removeMagazines(unsigned int k);
- void addBullets(unsigned int k);
- void addMagazines(unsigned int k);
+ bool canReload() const;
+ bool needReload(WeaponMode* user) const;
+ bool reload(WeaponMode* user, bool bUseReloadTime = true);
+ inline float getReloadTime() const
+ { return this->reloadTime_; }
- private:
+ bool canAddMunition(unsigned int amount) const;
+ bool addMunition(unsigned int amount);
+ bool canAddMagazines(unsigned int amount) const;
+ bool addMagazines(unsigned int amount);
+
+ bool canRemoveMagazines(unsigned int amount) const;
+ bool removeMagazines(unsigned int amount);
+
+ bool dropMagazine(WeaponMode* user);
+
protected:
- unsigned int bullets_;
+ unsigned int maxMunitionPerMagazine_;
+ unsigned int maxMagazines_;
unsigned int magazines_;
- unsigned int maxBullets_;
- unsigned int maxMagazines_;
+ std::map<WeaponMode*, Magazine*> currentMagazines_;
+
+ bool bUseSeparateMagazines_;
+ bool bStackMunition_;
+ bool bAllowMunitionRefilling_;
+ bool bAllowMultiMunitionRemovementUnderflow_;
+
+ float reloadTime_;
+
+ private:
+ Magazine* getMagazine(WeaponMode* user) const;
};
}
Modified: branches/weapons/src/orxonox/objects/weaponSystem/Weapon.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/Weapon.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/Weapon.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -21,6 +21,7 @@
*
* Author:
* Martin Polak
+ * Fabian 'x3n' Landau
* Co-authors:
* ...
*
@@ -32,7 +33,7 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
-#include "Munition.h"
+#include "WeaponMode.h"
#include "WeaponPack.h"
#include "WeaponSystem.h"
@@ -44,196 +45,110 @@
{
RegisterObject(Weapon);
- this->bulletReadyToShoot_ = true;
- this->magazineReadyToShoot_ = true;
- this->weaponSystem_ = 0;
this->weaponPack_ = 0;
this->weaponSlot_ = 0;
- this->bulletLoadingTime_ = 0;
- this->magazineLoadingTime_ = 0;
this->bReloading_ = false;
- this->bulletAmount_= 0;
- this->magazineAmount_ = 0;
- this->munition_ = 0;
- this->unlimitedMunition_ = false;
- this->setObjectMode(0x0);
+ this->reloadingWeaponmode_ = WeaponSystem::WEAPON_MODE_UNASSIGNED;
+ this->reloadTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&Weapon::reloaded)));
+ this->reloadTimer_.stopTimer();
+
COUT(0) << "+Weapon" << std::endl;
}
Weapon::~Weapon()
{
COUT(0) << "~Weapon" << std::endl;
- if (this->isInitialized() && this->weaponPack_)
- this->weaponPack_->removeWeapon(this);
+
+ if (this->isInitialized())
+ {
+ if (this->weaponPack_)
+ this->weaponPack_->removeWeapon(this);
+
+ for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
+ delete it->second;
+ }
}
void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(Weapon, XMLPort, xmlelement, mode);
- XMLPortParam(Weapon, "munitionType", setMunitionType, getMunitionType, xmlelement, mode);
- XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode);
- XMLPortParam(Weapon, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode);
- XMLPortParam(Weapon, "bullets", setBulletAmount, getBulletAmount, xmlelement, mode);
- XMLPortParam(Weapon, "magazines", setMagazineAmount, getMagazineAmount, xmlelement, mode);
- XMLPortParam(Weapon, "unlimitedMunition", setUnlimitedMunition, getUnlimitedMunition, xmlelement, mode);
+ XMLPortObject(Weapon, WeaponMode, "", addWeaponmode, getWeaponmode, xmlelement, mode);
}
- void Weapon::setWeapon()
+ void Weapon::addWeaponmode(WeaponMode* weaponmode)
{
- this->munition_->fillBullets();
- this->munition_->fillMagazines();
- }
+ if (!weaponmode)
+ return;
- void Weapon::setMunition()
- {
- this->munition_->setMaxBullets(this->bulletAmount_);
- this->munition_->setMaxMagazines(this->magazineAmount_);
+ this->weaponmodes_.insert(std::pair<unsigned int, WeaponMode*>(weaponmode->getMode(), weaponmode));
+ weaponmode->setWeapon(this);
}
- void Weapon::fire()
+ WeaponMode* Weapon::getWeaponmode(unsigned int index) const
{
- if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_)
+ unsigned int i = 0;
+ for (std::multimap<unsigned int, WeaponMode*>::const_iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
{
- this->bulletReadyToShoot_ = false;
- if ( this->unlimitedMunition_== true )
- {
- //shoot
- this->reloadBullet();
- this->createProjectile();
- }
- else
- {
- if ( this->munition_->bullets() > 0)
- {
- //shoot and reload
- this->takeBullets();
- this->reloadBullet();
- this->createProjectile();
- }
- //if there are no bullets, but magazines
- else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )
- {
- //reload magazine
- this->takeMagazines();
- this->reloadMagazine();
- }
- else
- {
- //no magazines
- }
- }
- }
- else
- {
- //weapon not reloaded
- }
+ if (i == index)
+ return it->second;
+ ++i;
+ }
+ return 0;
}
-
- //weapon reloading
- void Weapon::bulletTimer(float bulletLoadingTime)
+ void Weapon::fire(unsigned int mode)
{
- this->bReloading_ = true;
- this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded)));
- }
- void Weapon::magazineTimer(float magazineLoadingTime)
- {
- this->bReloading_ = true;
- this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded)));
- }
+ // To avoid firing with more than one mode at the same time, we lock the weapon (reloading) for
+ // all modes except the one which is currently reloading.
+ //
+ // Example:
+ // WeaponMode A -> mode 0
+ // WeaponMode B -> mode 0
+ // WeaponMode C -> mode 1
+ //
+ // -> A and B can fire at the same time, but C has to wait until both (A and B) have reloaded
+ // -> If C fires, A and B have to wait until C has reloaded
+ //
+ // Note: The reloading of each WeaponMode is internally handled by each A, B and C.
+ // The reloading of the weapon is only performed to avoid firing with different modes at the same time.
+ if (this->bReloading_ && this->reloadingWeaponmode_ != mode)
+ return;
- void Weapon::bulletReloaded()
- {
- this->bReloading_ = false;
- this->bulletReadyToShoot_ = true;
- }
+ std::multimap<unsigned int, WeaponMode*>::iterator start = this->weaponmodes_.lower_bound(mode);
+ std::multimap<unsigned int, WeaponMode*>::iterator end = this->weaponmodes_.upper_bound(mode);
- void Weapon::magazineReloaded()
- {
- this->bReloading_ = false;
- this->munition_->fillBullets();
- }
-
-
-
- void Weapon::attachNeededMunition(const std::string& munitionName)
- {
- /* if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
- */
- if (this->weaponSystem_)
+ for (std::multimap<unsigned int, WeaponMode*>::iterator it = start; it != end; ++it)
{
- //getMunitionType returns 0 if there is no such munitionType
- Munition* munition = this->weaponSystem_->getMunitionType(munitionName);
- if ( munition )
+ float reloading_time = 0;
+ if (it->second->fire(&reloading_time))
{
- this->munition_ = munition;
- this->setMunition();
+ this->bReloading_ = true;
+ this->reloadingWeaponmode_ = mode;
+
+ this->reloadTimer_.setInterval(reloading_time);
+ this->reloadTimer_.startTimer();
}
- else
- {
- //create new munition with identifier because there is no such munitionType
- this->munitionIdentifier_ = ClassByString(munitionName);
- this->munition_ = this->munitionIdentifier_.fabricate(this);
- this->weaponSystem_->setNewMunition(munitionName, this->munition_);
- this->setMunition();
- }
}
}
+ void Weapon::reload()
+ {
+ for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
+ it->second->reload();
+ }
- Munition * Weapon::getAttachedMunition(const std::string& munitionType)
+ void Weapon::reloaded()
{
- this->munition_ = this->weaponSystem_->getMunitionType(munitionType);
- return this->munition_;
+ this->bReloading_ = false;
+ this->reloadingWeaponmode_ = WeaponSystem::WEAPON_MODE_UNASSIGNED;
}
-
- //these function are defined in the weapon classes
- void Weapon::takeBullets() { };
- void Weapon::createProjectile() { };
- void Weapon::takeMagazines() { };
- void Weapon::reloadBullet() { };
- void Weapon::reloadMagazine() { };
-
-
- //get and set functions for XMLPort
- void Weapon::setMunitionType(const std::string& munitionType)
- { this->munitionType_ = munitionType; }
-
- const std::string& Weapon::getMunitionType() const
- { return this->munitionType_; }
-
- void Weapon::setBulletLoadingTime(float loadingTime)
- { this->bulletLoadingTime_ = loadingTime; }
-
- const float Weapon::getBulletLoadingTime() const
- { return this->bulletLoadingTime_; }
-
- void Weapon::setMagazineLoadingTime(float loadingTime)
- { this->magazineLoadingTime_ = loadingTime; }
-
- const float Weapon::getMagazineLoadingTime() const
- { return this->magazineLoadingTime_; }
-
- void Weapon::setBulletAmount(unsigned int amount)
- { this->bulletAmount_ = amount; }
-
- const unsigned int Weapon::getBulletAmount() const
- { return this->bulletAmount_; }
-
- void Weapon::setMagazineAmount(unsigned int amount)
- { this->magazineAmount_ = amount; }
-
- const unsigned int Weapon::getMagazineAmount() const
- { return this->magazineAmount_; }
-
- void Weapon::setUnlimitedMunition(bool unlimitedMunition)
- { this->unlimitedMunition_ = unlimitedMunition; }
-
- const bool Weapon::getUnlimitedMunition() const
- { return this->unlimitedMunition_; }
-
+ void Weapon::notifyWeaponModes()
+ {
+ for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
+ it->second->setWeapon(this);
+ }
}
Modified: branches/weapons/src/orxonox/objects/weaponSystem/Weapon.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/Weapon.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/Weapon.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -21,6 +21,7 @@
*
* Author:
* Martin Polak
+ * Fabian 'x3n' Landau
* Co-authors:
* ...
*
@@ -33,7 +34,6 @@
#include "objects/worldentities/StaticEntity.h"
#include "tools/Timer.h"
-#include "core/Identifier.h"
namespace orxonox
{
@@ -45,76 +45,33 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- virtual void fire();
- void attachNeededMunition(const std::string& munitionType);
- Munition * getAttachedMunition(const std::string& munitiontype);
+ void fire(unsigned int mode);
+ void reload();
- //reloading
- void bulletTimer(float bulletLoadingTime);
- void magazineTimer(float magazineLoadingTime);
- void bulletReloaded();
- void magazineReloaded();
+ void addWeaponmode(WeaponMode* weaponmode);
+ WeaponMode* getWeaponmode(unsigned int index) const;
- //XMLPort functions
- virtual void setMunitionType(const std::string& munitionType);
- virtual const std::string& getMunitionType() const;
- virtual void setBulletLoadingTime(float loadingTime);
- virtual const float getBulletLoadingTime() const;
- virtual void setMagazineLoadingTime(float loadingTime);
- virtual const float getMagazineLoadingTime() const;
- virtual void setBulletAmount(unsigned int amount);
- virtual const unsigned int getBulletAmount() const;
- virtual void setMagazineAmount(unsigned int amount);
- virtual const unsigned int getMagazineAmount() const;
- virtual void setUnlimitedMunition(bool unlimitedMunition);
- virtual const bool getUnlimitedMunition() const;
-
- //weapon actions
- virtual void takeBullets();
- virtual void takeMagazines();
- virtual void createProjectile();
- virtual void reloadBullet();
- virtual void reloadMagazine();
-
- //manually set or reset
- virtual void setWeapon();
- virtual void setMunition();
-
- inline void setWeaponSystem(WeaponSystem *weaponSystem)
- { this->weaponSystem_ = weaponSystem; };
- inline WeaponSystem * getWeaponSystem() const
- { return this->weaponSystem_; };
-
- inline void setWeaponPack(WeaponPack *weaponPack)
- { this->weaponPack_ = weaponPack; };
+ inline void setWeaponPack(WeaponPack * weaponPack)
+ { this->weaponPack_ = weaponPack; this->notifyWeaponModes(); }
inline WeaponPack * getWeaponPack() const
- { return this->weaponPack_; };
+ { return this->weaponPack_; }
inline void setWeaponSlot(WeaponSlot * wSlot)
{ this->weaponSlot_ = wSlot; }
inline WeaponSlot * getWeaponSlot() const
{ return this->weaponSlot_; }
- protected:
- bool bReloading_;
- bool bulletReadyToShoot_;
- bool magazineReadyToShoot_;
- bool unlimitedMunition_;
- float bulletLoadingTime_;
- float magazineLoadingTime_;
- unsigned int bulletAmount_;
- unsigned int magazineAmount_;
- std::string munitionType_;
+ private:
+ void reloaded();
+ void notifyWeaponModes();
- WeaponSlot * weaponSlot_;
- Munition * munition_;
- WeaponSystem * weaponSystem_;
WeaponPack* weaponPack_;
+ WeaponSlot* weaponSlot_;
+ std::multimap<unsigned int, WeaponMode*> weaponmodes_;
- SubclassIdentifier<Munition> munitionIdentifier_;
-
- Timer<Weapon> bulletReloadTimer_;
- Timer<Weapon> magazineReloadTimer_;
+ Timer<Weapon> reloadTimer_;
+ bool bReloading_;
+ unsigned int reloadingWeaponmode_;
};
}
Added: branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.cc (rev 0)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -0,0 +1,372 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Martin Polak
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "WeaponMode.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "Munition.h"
+#include "Weapon.h"
+#include "WeaponPack.h"
+#include "WeaponSystem.h"
+
+namespace orxonox
+{
+ WeaponMode::WeaponMode(BaseObject* creator) : BaseObject(creator)
+ {
+ RegisterObject(WeaponMode);
+
+ this->weapon_ = 0;
+ this->mode_ = WeaponSystem::WEAPON_MODE_UNASSIGNED;
+
+ this->munition_ = 0;
+ this->initialMunition_ = 0;
+ this->initialMagazines_ = 0;
+ this->munitionPerShot_ = 1;
+
+ this->reloadTime_ = 0.25;
+ this->bReloading_ = false;
+ this->bAutoReload_ = true;
+ this->bParallelReload_ = true;
+
+ this->reloadTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&WeaponMode::reloaded)));
+ this->reloadTimer_.stopTimer();
+
+ this->damage_ = 0;
+ this->muzzleOffset_ = Vector3::ZERO;
+
+COUT(0) << "+WeaponMode" << std::endl;
+ }
+
+ WeaponMode::~WeaponMode()
+ {
+COUT(0) << "~WeaponMode" << std::endl;
+ }
+
+ void WeaponMode::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(WeaponMode, XMLPort, xmlelement, mode);
+
+ XMLPortParam(WeaponMode, "mode", setMode, getMode, xmlelement, mode);
+
+ XMLPortParam(WeaponMode, "munitiontype", setMunitionName, getMunitionName, xmlelement, mode);
+ XMLPortParam(WeaponMode, "initialmunition", setInitialMunition, getInitialMunition, xmlelement, mode);
+ XMLPortParam(WeaponMode, "initialmagazines", setInitialMagazines, getInitialMagazines, xmlelement, mode);
+ XMLPortParam(WeaponMode, "munitionpershot", setMunitionPerShot, getMunitionPerShot, xmlelement, mode);
+
+ XMLPortParam(WeaponMode, "reloadtime", setReloadTime, getReloadTime, xmlelement, mode);
+ XMLPortParam(WeaponMode, "autoreload", setAutoReload, getAutoReload, xmlelement, mode).description("If true, the weapon reloads the magazine automatically");
+ XMLPortParam(WeaponMode, "parallelreload", setParallelReload, getParallelReload, xmlelement, mode).description("If true, the weapon reloads in parallel to the magazine reloading");
+
+ XMLPortParam(WeaponMode, "damage", setDamage, getDamage, xmlelement, mode);
+ XMLPortParam(WeaponMode, "muzzleoffset", setMuzzleOffset, getMuzzleOffset, xmlelement, mode);
+ }
+
+ bool WeaponMode::fire(float* reloadTime)
+ {
+ (*reloadTime) = this->reloadTime_;
+
+ if (!this->bReloading_ && this->munition_ && this->munition_->takeMunition(this->munitionPerShot_, this))
+ {
+ float reloadtime = this->reloadTime_;
+
+ if (this->bAutoReload_ && this->munition_->needReload(this))
+ {
+ if (this->munition_->reload(this))
+ {
+ if (!this->bParallelReload_)
+ reloadtime += this->munition_->getReloadTime();
+ }
+ }
+
+ this->bReloading_ = true;
+ this->reloadTimer_.setInterval(reloadtime);
+ this->reloadTimer_.startTimer();
+
+ this->fire();
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ bool WeaponMode::reload()
+ {
+ if (this->munition_ && this->munition_->reload(this))
+ {
+ if (!this->bParallelReload_)
+ {
+ this->bReloading_ = true;
+ this->reloadTimer_.setInterval(this->reloadTime_ + this->munition_->getReloadTime());
+ this->reloadTimer_.startTimer();
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ void WeaponMode::setMunitionType(Identifier* identifier)
+ {
+ this->munitionname_ = identifier->getName();
+ this->munitiontype_ = identifier;
+ this->updateMunition();
+ }
+
+ void WeaponMode::setMunitionName(const std::string& munitionname)
+ {
+ this->munitionname_ = munitionname;
+ this->munitiontype_ = ClassByString(this->munitionname_);
+ this->updateMunition();
+ }
+
+ void WeaponMode::updateMunition()
+ {
+ if (this->munitiontype_ && this->weapon_ && this->weapon_->getWeaponPack() && this->weapon_->getWeaponPack()->getWeaponSystem())
+ {
+ this->munition_ = this->weapon_->getWeaponPack()->getWeaponSystem()->getMunition(&this->munitiontype_);
+
+ if (this->munition_)
+ {
+ // Add the initial magazines
+ this->munition_->addMagazines(this->initialMagazines_);
+
+ // Maybe we have to reload (if this munition is used the first time or if there weren't any magazines available before)
+ if (this->munition_->needReload(this))
+ this->munition_->reload(this, false);
+
+ // Add the initial munition
+ if (this->initialMunition_ > 0 && this->munition_->getNumMunitionInCurrentMagazine(this) == this->munition_->getMaxMunitionPerMagazine())
+ {
+ // The current magazine is still full, so let's just add another magazine to
+ // the stack and reduce the current magazine to the given amount of munition
+
+ unsigned int initialmunition = this->initialMunition_;
+ if (initialmunition > this->munition_->getMaxMunitionPerMagazine())
+ initialmunition = this->munition_->getMaxMunitionPerMagazine();
+
+ this->munition_->takeMunition(this->munition_->getMaxMunitionPerMagazine() - initialmunition, this);
+ this->munition_->addMagazines(1);
+ }
+ else
+ {
+ // The current magazine isn't full, add the munition directly
+
+ this->munition_->addMunition(this->initialMunition_);
+ }
+ }
+ }
+ else
+ this->munition_ = 0;
+ }
+
+ void WeaponMode::reloaded()
+ {
+ this->bReloading_ = false;
+ }
+
+ Vector3 WeaponMode::getMuzzlePosition() const
+ {
+ if (this->weapon_)
+ return (this->weapon_->getWorldPosition() + this->muzzleOffset_);
+ else
+ return this->muzzleOffset_;
+ }
+
+ const Quaternion& WeaponMode::getMuzzleOrientation() const
+ {
+ if (this->weapon_)
+ return this->weapon_->getWorldOrientation();
+ else
+ return Quaternion::IDENTITY;
+ }
+
+ Vector3 WeaponMode::getMuzzleDirection() const
+ {
+ if (this->weapon_)
+ return (this->weapon_->getWorldOrientation() * WorldEntity::FRONT);
+ else
+ return WorldEntity::FRONT;
+ }
+
+/*
+ WeaponMode::WeaponMode(BaseObject* creator) : StaticEntity(creator)
+ {
+ RegisterObject(WeaponMode);
+
+ this->bulletReadyToShoot_ = true;
+ this->magazineReadyToShoot_ = true;
+ this->weaponSystem_ = 0;
+ this->weaponPack_ = 0;
+ this->weaponSlot_ = 0;
+ this->bulletLoadingTime_ = 0;
+ this->magazineLoadingTime_ = 0;
+ this->bReloading_ = false;
+ this->bulletAmount_= 0;
+ this->magazineAmount_ = 0;
+ this->munition_ = 0;
+ this->unlimitedMunition_ = false;
+ this->setObjectMode(0x0);
+COUT(0) << "+WeaponMode" << std::endl;
+ }
+
+ WeaponMode::~WeaponMode()
+ {
+COUT(0) << "~WeaponMode" << std::endl;
+ if (this->isInitialized() && this->weaponPack_)
+ this->weaponPack_->removeWeapon(this);
+ }
+
+ void WeaponMode::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(WeaponMode, XMLPort, xmlelement, mode);
+
+ XMLPortParam(WeaponMode, "munitionType", setMunitionType, getMunitionType, xmlelement, mode);
+ XMLPortParam(WeaponMode, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode);
+ XMLPortParam(WeaponMode, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode);
+ XMLPortParam(WeaponMode, "bullets", setBulletAmount, getBulletAmount, xmlelement, mode);
+ XMLPortParam(WeaponMode, "magazines", setMagazineAmount, getMagazineAmount, xmlelement, mode);
+ XMLPortParam(WeaponMode, "unlimitedMunition", setUnlimitedMunition, getUnlimitedMunition, xmlelement, mode);
+ }
+
+ void WeaponMode::setWeapon()
+ {
+ this->munition_->fillBullets();
+ this->munition_->fillMagazines();
+ }
+
+ void WeaponMode::setMunition()
+ {
+ this->munition_->setMaxBullets(this->bulletAmount_);
+ this->munition_->setMaxMagazines(this->magazineAmount_);
+ }
+
+ void WeaponMode::fire()
+ {
+ if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_)
+ {
+ this->bulletReadyToShoot_ = false;
+ if ( this->unlimitedMunition_== true )
+ {
+ //shoot
+ this->reloadBullet();
+ this->createProjectile();
+ }
+ else
+ {
+ if ( this->munition_->bullets() > 0)
+ {
+ //shoot and reload
+ this->takeBullets();
+ this->reloadBullet();
+ this->createProjectile();
+ }
+ //if there are no bullets, but magazines
+ else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )
+ {
+ //reload magazine
+ this->takeMagazines();
+ this->reloadMagazine();
+ }
+ else
+ {
+ //no magazines
+ }
+ }
+ }
+ else
+ {
+ //weapon not reloaded
+ }
+ }
+
+
+ //weapon reloading
+ void WeaponMode::bulletTimer(float bulletLoadingTime)
+ {
+ this->bReloading_ = true;
+ this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&WeaponMode::bulletReloaded)));
+ }
+ void WeaponMode::magazineTimer(float magazineLoadingTime)
+ {
+ this->bReloading_ = true;
+ this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&WeaponMode::magazineReloaded)));
+ }
+
+ void WeaponMode::bulletReloaded()
+ {
+ this->bReloading_ = false;
+ this->bulletReadyToShoot_ = true;
+ }
+
+ void WeaponMode::magazineReloaded()
+ {
+ this->bReloading_ = false;
+ this->munition_->fillBullets();
+ }
+
+
+
+ void WeaponMode::attachNeededMunition(const std::string& munitionName)
+ {
+ // if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
+ if (this->weaponSystem_)
+ {
+ //getMunitionType returns 0 if there is no such munitionType
+ Munition* munition = this->weaponSystem_->getMunitionType(munitionName);
+ if ( munition )
+ {
+ this->munition_ = munition;
+ this->setMunition();
+ }
+ else
+ {
+ //create new munition with identifier because there is no such munitionType
+ this->munitionIdentifier_ = ClassByString(munitionName);
+ this->munition_ = this->munitionIdentifier_.fabricate(this);
+ this->weaponSystem_->setNewMunition(munitionName, this->munition_);
+ this->setMunition();
+ }
+ }
+ }
+
+
+ Munition * WeaponMode::getAttachedMunition(const std::string& munitionType)
+ {
+ this->munition_ = this->weaponSystem_->getMunitionType(munitionType);
+ return this->munition_;
+ }
+*/
+}
Property changes on: branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Added: branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.h (rev 0)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -0,0 +1,246 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Martin Polak
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _WeaponMode_H__
+#define _WeaponMode_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/BaseObject.h"
+
+#include "tools/Timer.h"
+#include "core/Identifier.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport WeaponMode : public BaseObject
+ {
+ public:
+ WeaponMode(BaseObject* creator);
+ virtual ~WeaponMode();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ bool fire(float* reloadTime);
+ bool reload();
+
+
+ // Munition
+ inline Munition* getMunition() const
+ { return this->munition_; }
+
+ void setMunitionType(Identifier* identifier);
+ inline Identifier* getMunitionType() const
+ { return this->munitiontype_; }
+
+ void setMunitionName(const std::string& munitionname);
+ inline const std::string& getMunitionName() const
+ { return this->munitionname_; }
+
+ inline void setInitialMunition(unsigned int amount)
+ { this->initialMunition_ = amount; }
+ inline unsigned int getInitialMunition() const
+ { return this->initialMunition_; }
+
+ inline void setInitialMagazines(unsigned int amount)
+ { this->initialMagazines_ = amount; }
+ inline unsigned int getInitialMagazines() const
+ { return this->initialMagazines_; }
+
+ inline void setMunitionPerShot(unsigned int amount)
+ { this->munitionPerShot_ = amount; }
+ inline unsigned int getMunitionPerShot() const
+ { return this->munitionPerShot_; }
+
+
+ // Reloading
+ inline void setReloadTime(float time)
+ { this->reloadTime_ = time; }
+ inline float getReloadTime() const
+ { return this->reloadTime_; }
+
+ inline void setAutoReload(bool autoreload)
+ { this->bAutoReload_ = autoreload; }
+ inline bool getAutoReload() const
+ { return this->bAutoReload_; }
+
+ inline void setParallelReload(bool parallelreload)
+ { this->bParallelReload_ = parallelreload; }
+ inline bool getParallelReload() const
+ { return this->bParallelReload_; }
+
+
+ // Fire
+ inline void setDamage(float damage)
+ { this->damage_ = damage; }
+ inline float getDamage() const
+ { return this->damage_; }
+
+ inline void setMuzzleOffset(const Vector3& offset)
+ { this->muzzleOffset_ = offset; }
+ inline const Vector3& getMuzzleOffset() const
+ { return this->muzzleOffset_; }
+
+ Vector3 getMuzzlePosition() const;
+ const Quaternion& getMuzzleOrientation() const;
+ Vector3 getMuzzleDirection() const;
+
+
+ // Weapon
+ inline void setWeapon(Weapon* weapon)
+ { this->weapon_ = weapon; this->updateMunition(); }
+ inline Weapon* getWeapon() const
+ { return this->weapon_; }
+
+ inline void setMode(unsigned int mode)
+ { this->mode_ = mode; }
+ inline unsigned int getMode() const
+ { return this->mode_; }
+
+ protected:
+ virtual void fire() = 0;
+
+ unsigned int initialMunition_;
+ unsigned int initialMagazines_;
+ unsigned int munitionPerShot_;
+
+ float reloadTime_;
+ bool bAutoReload_;
+ bool bParallelReload_;
+
+ float damage_;
+ Vector3 muzzleOffset_;
+
+ private:
+ void updateMunition();
+ void reloaded();
+
+ Weapon* weapon_;
+ unsigned int mode_;
+
+ Munition* munition_;
+ SubclassIdentifier<Munition> munitiontype_;
+ std::string munitionname_;
+
+ Timer<WeaponMode> reloadTimer_;
+ bool bReloading_;
+/*
+ virtual void fire();
+ void attachNeededMunition(const std::string& munitionType);
+ Munition * getAttachedMunition(const std::string& munitiontype);
+
+ //reloading
+ void bulletTimer(float bulletLoadingTime);
+ void magazineTimer(float magazineLoadingTime);
+ void bulletReloaded();
+ void magazineReloaded();
+
+ //get and set functions for XMLPort
+ void setMunitionType(const std::string& munitionType)
+ { this->munitionType_ = munitionType; }
+ std::string& getMunitionType() const
+ { return this->munitionType_; }
+
+ void setBulletLoadingTime(float loadingTime)
+ { this->bulletLoadingTime_ = loadingTime; }
+ float getBulletLoadingTime() const
+ { return this->bulletLoadingTime_; }
+
+ void setMagazineLoadingTime(float loadingTime)
+ { this->magazineLoadingTime_ = loadingTime; }
+ float getMagazineLoadingTime() const
+ { return this->magazineLoadingTime_; }
+
+ void setBulletAmount(unsigned int amount)
+ { this->bulletAmount_ = amount; }
+ unsigned int getBulletAmount() const
+ { return this->bulletAmount_; }
+
+ void setMagazineAmount(unsigned int amount)
+ { this->magazineAmount_ = amount; }
+ unsigned int getMagazineAmount() const
+ { return this->magazineAmount_; }
+
+ void setUnlimitedMunition(bool unlimitedMunition)
+ { this->unlimitedMunition_ = unlimitedMunition; }
+ bool getUnlimitedMunition() const
+ { return this->unlimitedMunition_; }
+
+ //weapon actions
+ //these function are defined in the weapon classes
+ virtual void takeBullets() {}
+ virtual void takeMagazines() {}
+ virtual void createProjectile() {}
+ virtual void reloadBullet() {}
+ virtual void reloadMagazine() {}
+
+ //manually set or reset
+ virtual void setWeapon();
+ virtual void setMunition();
+
+ inline void setWeaponSystem(WeaponSystem *weaponSystem)
+ { this->weaponSystem_ = weaponSystem; };
+ inline WeaponSystem * getWeaponSystem() const
+ { return this->weaponSystem_; };
+
+ inline void setWeaponPack(WeaponPack *weaponPack)
+ { this->weaponPack_ = weaponPack; };
+ inline WeaponPack * getWeaponPack() const
+ { return this->weaponPack_; };
+
+ inline void setWeaponSlot(WeaponSlot * wSlot)
+ { this->weaponSlot_ = wSlot; }
+ inline WeaponSlot * getWeaponSlot() const
+ { return this->weaponSlot_; }
+
+ protected:
+ bool bReloading_;
+ bool bulletReadyToShoot_;
+ bool magazineReadyToShoot_;
+ bool unlimitedMunition_;
+ float bulletLoadingTime_;
+ float magazineLoadingTime_;
+ unsigned int bulletAmount_;
+ unsigned int magazineAmount_;
+ std::string munitionType_;
+
+ WeaponSlot * weaponSlot_;
+ Munition * munition_;
+ WeaponSystem * weaponSystem_;
+ WeaponPack* weaponPack_;
+
+ SubclassIdentifier<Munition> munitionIdentifier_;
+
+ Timer<WeaponMode> bulletReloadTimer_;
+ Timer<WeaponMode> magazineReloadTimer_;
+*/
+ };
+}
+
+#endif /* _WeaponMode_H__ */
Property changes on: branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -71,16 +71,22 @@
{
SUPER(WeaponPack, XMLPort, xmlelement, mode);
- XMLPortObject(WeaponPack, Weapon, "", addWeapon, getWeapon, xmlelement, mode);
+ XMLPortObjectExtended(WeaponPack, Weapon, "", addWeapon, getWeapon, xmlelement, mode, false, false);
XMLPortObject(WeaponPack, DefaultWeaponmodeLink, "links", addDefaultWeaponmodeLink, getDefaultWeaponmodeLink, xmlelement, mode);
}
void WeaponPack::fire(unsigned int weaponmode)
{
for (std::set<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
- (*it)->fire();
+ (*it)->fire(weaponmode);
}
+ void WeaponPack::reload()
+ {
+ for (std::set<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
+ (*it)->reload();
+ }
+
void WeaponPack::addWeapon(Weapon * weapon)
{
if (!weapon)
@@ -113,21 +119,6 @@
return 0;
}
- void WeaponPack::setWeaponSystemToAllWeapons()
- {
- for (std::set<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
- (*it)->setWeaponSystem(this->weaponSystem_);
- }
-
- void WeaponPack::attachNeededMunitionToAllWeapons()
- {
- for (std::set<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
- {
- (*it)->attachNeededMunition((*it)->getMunitionType());
- (*it)->setWeapon();
- }
- }
-
void WeaponPack::addDefaultWeaponmodeLink(DefaultWeaponmodeLink* link)
{
this->links_.insert(link);
@@ -154,4 +145,10 @@
return WeaponSystem::WEAPON_MODE_UNASSIGNED;
}
+
+ void WeaponPack::notifyWeapons()
+ {
+ for (std::set<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
+ (*it)->setWeaponPack(this);
+ }
}
Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -47,6 +47,7 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
void fire(unsigned int weaponmode);
+ void reload();
void addWeapon(Weapon * weapon);
void removeWeapon(Weapon * weapon);
@@ -60,18 +61,13 @@
unsigned int getDesiredWeaponmode(unsigned int firemode) const;
- inline void setWeaponSystem(WeaponSystem *weaponSystem)
- {
- this->weaponSystem_ = weaponSystem;
- this->setWeaponSystemToAllWeapons();
- this->attachNeededMunitionToAllWeapons();
- }
+ inline void setWeaponSystem(WeaponSystem * weaponSystem)
+ { this->weaponSystem_ = weaponSystem; this->notifyWeapons(); }
inline WeaponSystem * getWeaponSystem() const
{ return this->weaponSystem_; }
private:
- void setWeaponSystemToAllWeapons();
- void attachNeededMunitionToAllWeapons();
+ void notifyWeapons();
std::set<Weapon *> weapons_;
std::set<DefaultWeaponmodeLink *> links_;
Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -63,45 +63,7 @@
XMLPortParam(WeaponSet, "firemode", setDesiredFiremode, getDesiredFiremode, xmlelement, mode);
}
-/*
- void WeaponSet::attachWeaponPack(WeaponPack *wPack)
- {
- if ( this->weaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->weaponSystem_->getWeaponSlotSize() ) )
- {
- this->attachedWeaponPack_ = wPack;
- int wPackWeapon = 0; //WeaponCounter for Attaching
- //should be possible to choose which slot to use
- //attach every weapon of the weaponPack to a weaponSlot
- for ( int i=0; i < wPack->getSize() ; i++ )
- {
- //at the moment this function only works for one weaponPack in the entire WeaponSystem...
- //it also takes the first free weaponSlot...
- if ( this->weaponSystem_->getWeaponSlot(i)->getAttachedWeapon() == 0 && this->weaponSystem_->getWeaponSlot(i) != 0) //if slot not full
- {
- this->setWeaponSlots_.push_back( this->weaponSystem_->getWeaponSlot(i) );
- this->weaponSystem_->getWeaponSlot(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
- this->weaponSystem_->getPawn()->attach( wPack->getWeaponPointer(wPackWeapon) );
- wPackWeapon++;
- }
- else
- {
- for (int k=0; k < this->weaponSystem_->getWeaponSlotSize(); k++)
- {
- if ( this->weaponSystem_->getWeaponSlot(k)->getAttachedWeapon() == 0 )
- {
- this->setWeaponSlots_.push_back( this->weaponSystem_->getWeaponSlot(k) );
- this->weaponSystem_->getWeaponSlot(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
- this->weaponSystem_->getPawn()->attach( wPack->getWeaponPointer(wPackWeapon) );
- wPackWeapon++;
- }
- }
- }
- }
- }
- }
-*/
-
void WeaponSet::fire()
{
// fire all WeaponPacks with their defined weaponmode
@@ -110,6 +72,13 @@
it->first->fire(it->second);
}
+ void WeaponSet::reload()
+ {
+ // fire all WeaponPacks with their defined weaponmode
+ for (std::map<WeaponPack*, unsigned int>::iterator it = this->weaponpacks_.begin(); it != this->weaponpacks_.end(); ++it)
+ it->first->reload();
+ }
+
void WeaponSet::setWeaponmodeLink(WeaponPack* weaponpack, unsigned int weaponmode)
{
this->weaponpacks_[weaponpack] = weaponmode;
Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -46,9 +46,8 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-// void attachWeaponPack(WeaponPack *wPack);
-
void fire();
+ void reload();
void setWeaponmodeLink(WeaponPack* weaponpack, unsigned int weaponmode);
void removeWeaponmodeLink(WeaponPack* weaponpack);
@@ -65,7 +64,7 @@
{ return this->weaponSystem_; }
private:
- WeaponSystem *weaponSystem_;
+ WeaponSystem * weaponSystem_;
unsigned int desiredFiremode_;
std::map<WeaponPack*, unsigned int> weaponpacks_;
};
Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -63,7 +63,7 @@
{
SUPER(WeaponSlot, XMLPort, xmlelement, mode);
- // ...
+ // In the future, there might be parameters like allowed weapon types or max size of the weapon
}
void WeaponSlot::attachWeapon(Weapon *weapon)
Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -36,6 +36,7 @@
#include "WeaponPack.h"
#include "WeaponSet.h"
#include "Weapon.h"
+#include "Munition.h"
/* WeaponSystem
*
@@ -62,20 +63,17 @@
if (this->pawn_)
this->pawn_->setWeaponSystem(0);
-// for (std::map<unsigned int, WeaponSet*>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); )
-// delete (it++)->second;
while (!this->weaponSets_.empty())
delete (this->weaponSets_.begin()->second);
-// for (std::set<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); )
-// delete (*(it++));
while (!this->weaponPacks_.empty())
delete (*this->weaponPacks_.begin());
-// for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); )
-// delete (*(it++));
while (!this->weaponSlots_.empty())
delete (*this->weaponSlots_.begin());
+
+ while (!this->munitions_.empty())
+ { delete (this->munitions_.begin()->second); this->munitions_.erase(this->munitions_.begin()); }
}
}
@@ -283,26 +281,38 @@
wSet->setWeaponmodeLink(wPack, weaponmode);
}
- void WeaponSystem::setNewMunition(const std::string& munitionType, Munition * munitionToAdd)
+ void WeaponSystem::fire(unsigned int firemode)
{
- this->munitionSet_[munitionType] = munitionToAdd;
+ std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.find(firemode);
+ if (it != this->weaponSets_.end() && it->second)
+ it->second->fire();
}
+ void WeaponSystem::reload()
+ {
+ for (std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)
+ it->second->reload();
+ }
- //returns the Pointer to the munitionType, if this munitionType doesn't exist returns 0, see Weapon::attachNeededMunition
- Munition * WeaponSystem::getMunitionType(const std::string& munitionType) const
+ Munition * WeaponSystem::getMunition(SubclassIdentifier<Munition> * identifier)
{
- std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType);
- if (it != this->munitionSet_.end())
+ if (!identifier || !identifier->getIdentifier())
+ return 0;
+
+ std::map<Identifier *, Munition *>::iterator it = this->munitions_.find(identifier->getIdentifier());
+ if (it != this->munitions_.end())
+ {
return it->second;
+ }
+ else if (identifier->getIdentifier()->isA(Class(Munition)))
+ {
+ Munition* munition = identifier->fabricate(this);
+ this->munitions_[identifier->getIdentifier()] = munition;
+ return munition;
+ }
else
+ {
return 0;
+ }
}
-
- void WeaponSystem::fire(unsigned int firemode)
- {
- std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.find(firemode);
- if (it != this->weaponSets_.end() && it->second)
- it->second->fire();
- }
}
Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -68,12 +68,10 @@
void changeWeaponmode(WeaponPack * wPack, WeaponSet * wSet, unsigned int weaponmode);
void fire(unsigned int firemode);
+ void reload();
+ Munition * getMunition(SubclassIdentifier<Munition> * identifier);
- void setNewMunition(const std::string& munitionType, Munition * munitionToAdd);
- void setNewSharedMunition(const std::string& munitionType, Munition * munitionToAdd);
- Munition * getMunitionType(const std::string& munitionType) const;
-
inline void setPawn(Pawn * pawn)
{ this->pawn_ = pawn; }
inline Pawn * getPawn() const
@@ -95,7 +93,7 @@
std::map<unsigned int, WeaponSet *> weaponSets_;
std::vector<WeaponSlot *> weaponSlots_;
std::set<WeaponPack *> weaponPacks_;
- std::map<std::string, Munition *> munitionSet_;
+ std::map<Identifier *, Munition *> munitions_;
Pawn * pawn_;
};
}
Modified: branches/weapons/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt 2009-04-18 16:14:52 UTC (rev 2918)
@@ -1,4 +1,5 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ ReplenishingMunition.cc
LaserGunMunition.cc
FusionMunition.cc
)
Modified: branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -39,18 +39,15 @@
{
RegisterObject(FusionMunition);
- //default if not defined in XML
- this->maxBullets_ = 10;
- this->maxMagazines_ = 100;
- }
+ this->maxMunitionPerMagazine_ = 10;
+ this->maxMagazines_ = 10;
+ this->magazines_ = 10;
- FusionMunition::~FusionMunition()
- {
- }
+ this->bUseSeparateMagazines_ = true;
+ this->bStackMunition_ = false;
+ this->reloadTime_ = 1.0f;
- void FusionMunition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
-
+ this->bAllowMunitionRefilling_ = true;
+ this->bAllowMultiMunitionRemovementUnderflow_ = true;
}
-
}
Modified: branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -38,14 +38,7 @@
{
public:
FusionMunition(BaseObject* creator);
- virtual ~FusionMunition();
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
-
- private:
-
-
+ virtual ~FusionMunition() {}
};
}
Modified: branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -35,22 +35,21 @@
{
CreateFactory(LaserGunMunition);
- LaserGunMunition::LaserGunMunition(BaseObject* creator) : Munition(creator)
+ LaserGunMunition::LaserGunMunition(BaseObject* creator) : ReplenishingMunition(creator)
{
RegisterObject(LaserGunMunition);
- //default if not defined in XML
- this->maxBullets_ = 40;
- this->maxMagazines_ = 100;
- }
+ this->maxMunitionPerMagazine_ = 20;
+ this->maxMagazines_ = 1;
+ this->magazines_ = 1;
- LaserGunMunition::~LaserGunMunition()
- {
- }
+ this->bUseSeparateMagazines_ = false;
+ this->bStackMunition_ = true;
- void LaserGunMunition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
+ this->bAllowMunitionRefilling_ = true;
+ this->bAllowMultiMunitionRemovementUnderflow_ = true;
+ this->replenishIntervall_ = 0.5f;
+ this->replenishMunitionAmount_ = 1;
}
-
}
Modified: branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -30,22 +30,15 @@
#define _LaserGunMunition_H__
#include "OrxonoxPrereqs.h"
-#include "objects/weaponSystem/Munition.h"
+#include "ReplenishingMunition.h"
namespace orxonox
{
- class _OrxonoxExport LaserGunMunition : public Munition
+ class _OrxonoxExport LaserGunMunition : public ReplenishingMunition
{
public:
LaserGunMunition(BaseObject* creator);
- virtual ~LaserGunMunition();
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
-
- private:
-
-
+ virtual ~LaserGunMunition() {}
};
}
Added: branches/weapons/src/orxonox/objects/weaponSystem/munitions/ReplenishingMunition.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/munitions/ReplenishingMunition.cc (rev 0)
+++ branches/weapons/src/orxonox/objects/weaponSystem/munitions/ReplenishingMunition.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -0,0 +1,70 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "ReplenishingMunition.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ CreateFactory(ReplenishingMunition);
+
+ ReplenishingMunition::ReplenishingMunition(BaseObject* creator) : Munition(creator)
+ {
+ RegisterObject(ReplenishingMunition);
+
+ this->replenishIntervall_ = 1.0f;
+ this->replenishMunitionAmount_ = 1;
+
+ // Use the timer to initialize itself after the first tick (because the real values for
+ // replenishIntervall_ and replenishMunitionAmount_ will be set in the constructor of the
+ // inheriting class, which comes after this constructor)
+ this->replenishingTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&ReplenishingMunition::initializeTimer)));
+ }
+
+ void ReplenishingMunition::initializeTimer()
+ {
+ // Initialize the timer
+ this->replenishingTimer_.setTimer(this->replenishIntervall_, true, this, createExecutor(createFunctor(&ReplenishingMunition::replenish)));
+ }
+
+ void ReplenishingMunition::replenish()
+ {
+ // Make a temporary copy of bAllowMunitionRefilling_, because this might be disallowed in every
+ // case except the internal munition replenishing
+ bool temp = this->bAllowMunitionRefilling_;
+ this->bAllowMunitionRefilling_ = true;
+
+ // Replenish munition
+ this->addMunition(this->replenishMunitionAmount_);
+
+ // Write back the temporary value
+ this->bAllowMunitionRefilling_ = temp;
+ }
+}
Property changes on: branches/weapons/src/orxonox/objects/weaponSystem/munitions/ReplenishingMunition.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Added: branches/weapons/src/orxonox/objects/weaponSystem/munitions/ReplenishingMunition.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/munitions/ReplenishingMunition.h (rev 0)
+++ branches/weapons/src/orxonox/objects/weaponSystem/munitions/ReplenishingMunition.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -0,0 +1,56 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _ReplenishingMunition_H__
+#define _ReplenishingMunition_H__
+
+#include "OrxonoxPrereqs.h"
+#include "objects/weaponSystem/Munition.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport ReplenishingMunition : public Munition
+ {
+ public:
+ ReplenishingMunition(BaseObject* creator);
+ virtual ~ReplenishingMunition() {}
+
+ protected:
+ float replenishIntervall_;
+ unsigned int replenishMunitionAmount_;
+
+ private:
+ void replenish();
+ void initializeTimer();
+
+ Timer<ReplenishingMunition> replenishingTimer_;
+ };
+}
+
+#endif /* _ReplenishingMunition_H__ */
Property changes on: branches/weapons/src/orxonox/objects/weaponSystem/munitions/ReplenishingMunition.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: branches/weapons/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -100,6 +100,9 @@
{
if (!this->bDestroy_ && GameMode::isMaster())
{
+ if (otherObject == this->owner_)
+ return true;
+
this->bDestroy_ = true;
if (this->owner_)
Modified: branches/weapons/src/orxonox/objects/weaponSystem/projectiles/Projectile.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/projectiles/Projectile.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/projectiles/Projectile.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -50,6 +50,11 @@
virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
virtual void destroyedPawn(Pawn* pawn);
+ inline void setDamage(float damage)
+ { this->damage_ = damage; }
+ inline float getDamage() const
+ { return this->damage_; }
+
inline void setOwner(Pawn* owner)
{ this->owner_ = owner; }
inline Pawn* getOwner() const
Modified: branches/weapons/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt 2009-04-18 16:14:52 UTC (rev 2918)
@@ -1,5 +1,4 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
- Fusion.cc
- LaserGun.cc
-# Missile.cc
+ FusionFire.cc
+ LaserFire.cc
)
Deleted: branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -1,76 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Martin Polak
- * Co-authors:
- * ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "Fusion.h"
-
-#include "core/CoreIncludes.h"
-
-#include "objects/weaponSystem/Munition.h"
-#include "objects/weaponSystem/projectiles/ParticleProjectile.h"
-#include "objects/weaponSystem/WeaponSystem.h"
-
-namespace orxonox
-{
- CreateFactory(Fusion);
-
- Fusion::Fusion(BaseObject* creator) : Weapon(creator)
- {
- RegisterObject(Fusion);
-
- this->speed_ = 1250;
-
- }
-
- Fusion::~Fusion()
- {
- }
-
- void Fusion::takeBullets()
- {
-//COUT(0) << "Fusion::takeBullets" << std::endl;
- this->munition_->removeBullets(1);
- this->bulletTimer(this->bulletLoadingTime_);
- }
-
- void Fusion::takeMagazines()
- {
- this->munition_->removeMagazines(1);
- this->magazineTimer(this->magazineLoadingTime_);
- }
-
- void Fusion::createProjectile()
- {
-//COUT(0) << "Fusion::createProjectile" << std::endl;
- BillboardProjectile* projectile = new ParticleProjectile(this);
- projectile->setOrientation(this->getWorldOrientation());
- projectile->setPosition(this->getWorldPosition());
- projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_);
- projectile->setOwner(this->getWeaponSystem()->getPawn());
- }
-}
Deleted: branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -1,53 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Martin Polak
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _Fusion_H__
-#define _Fusion_H__
-
-#include "OrxonoxPrereqs.h"
-#include "objects/weaponSystem/Weapon.h"
-
-namespace orxonox
-{
- class _OrxonoxExport Fusion : public Weapon
- {
- public:
- Fusion(BaseObject* creator);
- virtual ~Fusion();
-
- virtual void takeBullets();
- virtual void takeMagazines();
- virtual void createProjectile();
-
- private:
- float speed_;
-
- };
-}
-
-#endif /* _Fusion_H__ */
Copied: branches/weapons/src/orxonox/objects/weaponSystem/weapons/FusionFire.cc (from rev 2914, branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.cc)
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/FusionFire.cc (rev 0)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/FusionFire.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -0,0 +1,67 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Martin Polak
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "FusionFire.h"
+
+#include "core/CoreIncludes.h"
+#include "objects/weaponSystem/projectiles/BillboardProjectile.h"
+
+#include "objects/weaponSystem/Weapon.h"
+#include "objects/weaponSystem/WeaponPack.h"
+#include "objects/weaponSystem/WeaponSystem.h"
+
+namespace orxonox
+{
+ CreateFactory(FusionFire);
+
+ FusionFire::FusionFire(BaseObject* creator) : WeaponMode(creator)
+ {
+ RegisterObject(FusionFire);
+
+ this->reloadTime_ = 1.0;
+ this->bParallelReload_ = false;
+ this->damage_ = 40;
+ this->speed_ = 1250;
+
+ this->setMunitionName("FusionMunition");
+ }
+
+ void FusionFire::fire()
+ {
+ BillboardProjectile* projectile = new BillboardProjectile(this);
+
+ projectile->setOrientation(this->getMuzzleOrientation());
+ projectile->setPosition(this->getMuzzlePosition());
+ projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
+
+ projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ projectile->setColour(ColourValue(1.0f, 0.7f, 0.3f, 1.0f));
+ }
+}
Property changes on: branches/weapons/src/orxonox/objects/weaponSystem/weapons/FusionFire.cc
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/buildsystem/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:1875-2277,2279-2401
/branches/buildsystem2/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2507-2659
/branches/buildsystem3/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2663-2709
/branches/ceguilua/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:1803-1809
/branches/core3/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:1573-1740
/branches/gcc43/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:1581
/branches/gui/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:1636-1724,2796-2895
/branches/input/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:1630-1637
/branches/lodfinal/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2373-2412
/branches/miniprojects/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2755-2825
/branches/network/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2357
/branches/network64/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2211-2356
/branches/objecthierarchy/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:1912-2086,2101,2111-2170
/branches/objecthierarchy2/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2172-2480
/branches/overlay/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2118-2386
/branches/physics/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:1913-2056,2108-2440
/branches/physics_merge/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2437-2458
/branches/pickups/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:1927-2087,2128
/branches/pickups2/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2108-2498
/branches/presentation/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2370-2653,2655-2661
/branches/questsystem/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:1895-2089
/branches/questsystem2/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2108-2260
/branches/script_trigger/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:1296-1954,1956
/branches/weapon/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:1926-2095
/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2108-2489
/branches/weaponsystem/src/orxonox/objects/weaponSystem/weapons/Fusion.cc:2743-2891
Added: svn:eol-style
+ native
Copied: branches/weapons/src/orxonox/objects/weaponSystem/weapons/FusionFire.h (from rev 2914, branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.h)
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/FusionFire.h (rev 0)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/FusionFire.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -0,0 +1,50 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Martin Polak
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _FusionFire_H__
+#define _FusionFire_H__
+
+#include "OrxonoxPrereqs.h"
+#include "objects/weaponSystem/WeaponMode.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport FusionFire : public WeaponMode
+ {
+ public:
+ FusionFire(BaseObject* creator);
+ virtual ~FusionFire() {}
+
+ virtual void fire();
+
+ private:
+ float speed_;
+ };
+}
+
+#endif /* _FusionFire_H__ */
Property changes on: branches/weapons/src/orxonox/objects/weaponSystem/weapons/FusionFire.h
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/buildsystem/src/orxonox/objects/weaponSystem/weapons/Fusion.h:1875-2277,2279-2401
/branches/buildsystem2/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2507-2659
/branches/buildsystem3/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2663-2709
/branches/ceguilua/src/orxonox/objects/weaponSystem/weapons/Fusion.h:1803-1809
/branches/core3/src/orxonox/objects/weaponSystem/weapons/Fusion.h:1573-1740
/branches/gcc43/src/orxonox/objects/weaponSystem/weapons/Fusion.h:1581
/branches/gui/src/orxonox/objects/weaponSystem/weapons/Fusion.h:1636-1724,2796-2895
/branches/input/src/orxonox/objects/weaponSystem/weapons/Fusion.h:1630-1637
/branches/lodfinal/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2373-2412
/branches/miniprojects/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2755-2825
/branches/network/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2357
/branches/network64/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2211-2356
/branches/objecthierarchy/src/orxonox/objects/weaponSystem/weapons/Fusion.h:1912-2086,2101,2111-2170
/branches/objecthierarchy2/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2172-2480
/branches/overlay/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2118-2386
/branches/physics/src/orxonox/objects/weaponSystem/weapons/Fusion.h:1913-2056,2108-2440
/branches/physics_merge/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2437-2458
/branches/pickups/src/orxonox/objects/weaponSystem/weapons/Fusion.h:1927-2087,2128
/branches/pickups2/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2108-2498
/branches/presentation/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2370-2653,2655-2661
/branches/questsystem/src/orxonox/objects/weaponSystem/weapons/Fusion.h:1895-2089
/branches/questsystem2/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2108-2260
/branches/script_trigger/src/orxonox/objects/weaponSystem/weapons/Fusion.h:1296-1954,1956
/branches/weapon/src/orxonox/objects/weaponSystem/weapons/Fusion.h:1926-2095
/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2108-2489
/branches/weaponsystem/src/orxonox/objects/weaponSystem/weapons/Fusion.h:2743-2891
Added: svn:eol-style
+ native
Copied: branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserFire.cc (from rev 2914, branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc)
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserFire.cc (rev 0)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserFire.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -0,0 +1,65 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Martin Polak
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "LaserFire.h"
+
+#include "core/CoreIncludes.h"
+#include "objects/weaponSystem/projectiles/ParticleProjectile.h"
+
+#include "objects/weaponSystem/Weapon.h"
+#include "objects/weaponSystem/WeaponPack.h"
+#include "objects/weaponSystem/WeaponSystem.h"
+
+namespace orxonox
+{
+ CreateFactory(LaserFire);
+
+ LaserFire::LaserFire(BaseObject* creator) : WeaponMode(creator)
+ {
+ RegisterObject(LaserFire);
+
+ this->reloadTime_ = 0.25;
+ this->damage_ = 15;
+ this->speed_ = 1250;
+
+ this->setMunitionName("LaserGunMunition");
+ }
+
+ void LaserFire::fire()
+ {
+ ParticleProjectile* projectile = new ParticleProjectile(this);
+
+ projectile->setOrientation(this->getMuzzleOrientation());
+ projectile->setPosition(this->getMuzzlePosition());
+ projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
+
+ projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ }
+}
Property changes on: branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserFire.cc
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/buildsystem/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:1875-2277,2279-2401
/branches/buildsystem2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2507-2659
/branches/buildsystem3/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2663-2709
/branches/ceguilua/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:1803-1809
/branches/core3/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:1573-1740
/branches/gcc43/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:1581
/branches/gui/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:1636-1724,2796-2895
/branches/input/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:1630-1637
/branches/lodfinal/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2373-2412
/branches/miniprojects/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2755-2825
/branches/network/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2357
/branches/network64/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2211-2356
/branches/objecthierarchy/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:1912-2086,2101,2111-2170
/branches/objecthierarchy2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2172-2480
/branches/overlay/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2118-2386
/branches/physics/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:1913-2056,2108-2440
/branches/physics_merge/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2437-2458
/branches/pickups/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:1927-2087,2128
/branches/pickups2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2108-2498
/branches/presentation/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2370-2653,2655-2661
/branches/questsystem/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:1895-2089
/branches/questsystem2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2108-2260
/branches/script_trigger/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:1296-1954,1956
/branches/weapon/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:1926-2095
/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2108-2489
/branches/weaponsystem/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc:2743-2891
Added: svn:eol-style
+ native
Copied: branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserFire.h (from rev 2914, branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.h)
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserFire.h (rev 0)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserFire.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -0,0 +1,50 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Martin Polak
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _LaserFire_H__
+#define _LaserFire_H__
+
+#include "OrxonoxPrereqs.h"
+#include "objects/weaponSystem/WeaponMode.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport LaserFire : public WeaponMode
+ {
+ public:
+ LaserFire(BaseObject* creator);
+ virtual ~LaserFire() {}
+
+ virtual void fire();
+
+ private:
+ float speed_;
+ };
+}
+
+#endif /* _LaserFire_H__ */
Property changes on: branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserFire.h
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/buildsystem/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:1875-2277,2279-2401
/branches/buildsystem2/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2507-2659
/branches/buildsystem3/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2663-2709
/branches/ceguilua/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:1803-1809
/branches/core3/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:1573-1740
/branches/gcc43/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:1581
/branches/gui/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:1636-1724,2796-2895
/branches/input/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:1630-1637
/branches/lodfinal/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2373-2412
/branches/miniprojects/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2755-2825
/branches/network/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2357
/branches/network64/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2211-2356
/branches/objecthierarchy/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:1912-2086,2101,2111-2170
/branches/objecthierarchy2/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2172-2480
/branches/overlay/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2118-2386
/branches/physics/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:1913-2056,2108-2440
/branches/physics_merge/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2437-2458
/branches/pickups/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:1927-2087,2128
/branches/pickups2/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2108-2498
/branches/presentation/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2370-2653,2655-2661
/branches/questsystem/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:1895-2089
/branches/questsystem2/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2108-2260
/branches/script_trigger/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:1296-1954,1956
/branches/weapon/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:1926-2095
/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2108-2489
/branches/weaponsystem/src/orxonox/objects/weaponSystem/weapons/LaserGun.h:2743-2891
Added: svn:eol-style
+ native
Deleted: branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -1,82 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Martin Polak
- * Co-authors:
- * ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "LaserGun.h"
-
-#include "core/CoreIncludes.h"
-
-#include "objects/weaponSystem/Munition.h"
-#include "objects/weaponSystem/projectiles/ParticleProjectile.h"
-#include "objects/weaponSystem/WeaponSystem.h"
-
-namespace orxonox
-{
- CreateFactory(LaserGun);
-
- LaserGun::LaserGun(BaseObject* creator) : Weapon(creator)
- {
- RegisterObject(LaserGun);
-
- this->speed_ = 1250;
-
- }
-
- LaserGun::~LaserGun()
- {
- }
-
- void LaserGun::reloadBullet()
- {
- this->bulletTimer(this->bulletLoadingTime_);
- }
-
- void LaserGun::reloadMagazine()
- {
- this->magazineTimer(this->magazineLoadingTime_);
- }
-
- void LaserGun::takeBullets()
- {
- this->munition_->removeBullets(1);
- }
-
- void LaserGun::takeMagazines()
- {
- this->munition_->removeMagazines(1);
- }
-
- void LaserGun::createProjectile()
- {
- BillboardProjectile* projectile = new ParticleProjectile(this);
- projectile->setOrientation(this->getWorldOrientation());
- projectile->setPosition(this->getWorldPosition());
- projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_);
- projectile->setOwner(this->getWeaponSystem()->getPawn());
- }
-}
Deleted: branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -1,55 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Martin Polak
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _LaserGun_H__
-#define _LaserGun_H__
-
-#include "OrxonoxPrereqs.h"
-#include "objects/weaponSystem/Weapon.h"
-
-namespace orxonox
-{
- class _OrxonoxExport LaserGun : public Weapon
- {
- public:
- LaserGun(BaseObject* creator);
- virtual ~LaserGun();
-
- virtual void takeBullets();
- virtual void takeMagazines();
- virtual void createProjectile();
- virtual void reloadBullet();
- virtual void reloadMagazine();
-
- private:
- float speed_;
-
- };
-}
-
-#endif /* _LaserGun_H__ */
Deleted: branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -1,51 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Martin Polak
- * Co-authors:
- * ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "Missile.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox
-{
- Missile::Missile(BaseObject* creator) : Weapon(creator)
- {
- RegisterObject(Missile);
- }
-
- Missile::~Missile()
- {
- }
-
- void Missile::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
-
- }
-
-}
Deleted: branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -1,52 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Martin Polak
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _Missile_H__
-#define _Missile_H__
-
-#include "OrxonoxPrereqs.h"
-#include "objects/weaponSystem/Weapon.h"
-
-namespace orxonox
-{
- class _OrxonoxExport Missile : public Weapon
- {
- public:
- Missile(BaseObject* creator);
- virtual ~Missile();
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
-
- private:
-
-
- };
-}
-
-#endif /* _Missile_H__ */
Modified: branches/weapons/src/orxonox/objects/worldentities/ControllableEntity.h
===================================================================
--- branches/weapons/src/orxonox/objects/worldentities/ControllableEntity.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/worldentities/ControllableEntity.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -81,6 +81,7 @@
{ this->rotateRoll(Vector2(value, 0)); }
virtual void fire(unsigned int firemode) {}
+ virtual void reload() {}
virtual void boost() {}
virtual void greet() {}
Modified: branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.cc 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.cc 2009-04-18 16:14:52 UTC (rev 2918)
@@ -55,6 +55,7 @@
this->bAlive_ = true;
this->fire_ = 0x0;
this->firehack_ = 0x0;
+ this->bReload_ = false;
this->health_ = 0;
this->maxHealth_ = 0;
@@ -114,20 +115,26 @@
registerVariable(this->health_, variableDirection::toclient);
registerVariable(this->initialHealth_, variableDirection::toclient);
registerVariable(this->fire_, variableDirection::toserver);
+ registerVariable(this->bReload_, variableDirection::toserver);
}
void Pawn::tick(float dt)
{
SUPER(Pawn, tick, dt);
- if (this->weaponSystem_)
+ if (this->weaponSystem_ && GameMode::isMaster())
{
for (unsigned int firemode = 0; firemode < WeaponSystem::MAX_FIRE_MODES; firemode++)
if (this->fire_ & WeaponSystem::getFiremodeMask(firemode))
this->weaponSystem_->fire(firemode);
+
+ if (this->bReload_)
+ this->weaponSystem_->reload();
}
+
this->fire_ = this->firehack_;
this->firehack_ = 0x0;
+ this->bReload_ = false;
if (this->health_ <= 0)
this->death();
@@ -257,6 +264,11 @@
this->firehack_ |= WeaponSystem::getFiremodeMask(firemode);
}
+ void Pawn::reload()
+ {
+ this->bReload_ = true;
+ }
+
void Pawn::postSpawn()
{
this->setHealth(this->initialHealth_);
Modified: branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.h 2009-04-15 15:03:58 UTC (rev 2917)
+++ branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.h 2009-04-18 16:14:52 UTC (rev 2918)
@@ -80,6 +80,7 @@
virtual void kill();
virtual void fire(unsigned int firemode);
+ virtual void reload();
virtual void postSpawn();
void addWeaponSlot(WeaponSlot * wSlot);
@@ -130,6 +131,7 @@
WeaponSystem* weaponSystem_;
unsigned int fire_;
unsigned int firehack_;
+ bool bReload_;
std::string spawnparticlesource_;
float spawnparticleduration_;
More information about the Orxonox-commit
mailing list