Changeset 2493
- Timestamp:
- Dec 17, 2008, 2:10:11 AM (16 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 108 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
- Property svn:mergeinfo changed
/code/branches/weapon2 (added) merged: 2108,2145,2186,2203,2232,2272-2273,2288,2308,2319,2327,2331,2337,2347,2354,2366-2368,2379,2391,2393,2398,2410
- Property svn:mergeinfo changed
-
code/branches/presentation/bin/def_keybindings.ini
r2485 r2493 247 247 MouseLeft="fire" 248 248 MouseMiddle= 249 MouseRight= 249 MouseRight="altfire" 250 250 MouseWheel1Down= 251 251 MouseWheel1Up= -
code/branches/presentation/src/core/Template.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/core/Template.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/core/XMLFile.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/core/XMLIncludes.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/CameraManager.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/CameraManager.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/OrxonoxPrereqs.h
r2492 r2493 72 72 }; 73 73 } 74 75 //put here all existing munitionTypes 76 namespace MunitionType 77 { 78 79 80 81 enum Enum 82 { laserGunMunition }; 83 } 84 85 //put here all weapon fire modes. 86 //they have to be added to Pawn and HumanController, too. 87 namespace WeaponMode 88 { 89 enum Enum 90 { 91 fire = 0x1, 92 altFire = 0x2, 93 altFire2 = 0x4 94 }; 95 } 96 74 97 75 98 class GraphicsEngine; … … 146 169 class WeaponSet; 147 170 class WeaponSlot; 171 class WeaponPack; 148 172 class Weapon; 149 173 class Munition; 174 class LaserGun; 175 class LaserGunMunition; 150 176 151 177 class EventListener; -
code/branches/presentation/src/orxonox/objects/controllers/AIController.cc
r2485 r2493 57 57 float random; 58 58 float maxrand = 100.0f / ACTION_INTERVAL; 59 /* 59 60 60 // search enemy 61 61 random = rnd(maxrand); … … 72 72 if (random < 10 && (this->target_)) 73 73 this->searchNewTarget(); 74 */ 74 75 75 // fly somewhere 76 76 random = rnd(maxrand); … … 87 87 if (random < 30 && (this->bHasTargetPosition_ && !this->target_)) 88 88 this->searchRandomTargetPosition(); 89 /* 89 90 90 // shoot 91 91 random = rnd(maxrand); … … 97 97 if (random < 25 && (this->bShooting_)) 98 98 this->bShooting_ = false; 99 */100 99 } 101 100 … … 112 111 113 112 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(500) && this->isLookingAtTarget(Ogre::Math::PI / 20.0)) 114 this->getControllableEntity()->fire( );113 this->getControllableEntity()->fire(WeaponMode::fire); 115 114 116 115 SUPER(AIController, tick, dt); -
code/branches/presentation/src/orxonox/objects/controllers/ArtificialController.cc
r2485 r2493 56 56 57 57 Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_); 58 float distance = (this->targetPosition_ - this->getControllableEntity()->getPosition()).length(); 58 59 59 float distance = (this->targetPosition_ - this->getControllableEntity()->getPosition()).length(); 60 if (this->target_ || distance > 50) 60 if (this->target_ || distance > 10) 61 61 { 62 62 // Multiply with 0.8 to make them a bit slower 63 this->getControllableEntity()->rotateYaw( 0.8 * sgn(coord.x) * coord.x*coord.x);63 this->getControllableEntity()->rotateYaw(-0.8 * sgn(coord.x) * coord.x*coord.x); 64 64 this->getControllableEntity()->rotatePitch(0.8 * sgn(coord.y) * coord.y*coord.y); 65 65 } 66 66 67 if (this->target_ && distance < 1000 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())67 if (this->target_ && distance < 200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength()) 68 68 this->getControllableEntity()->moveFrontBack(-0.5); // They don't brake with full power to give the player a chance 69 69 else … … 73 73 void ArtificialController::searchRandomTargetPosition() 74 74 { 75 this->targetPosition_ = Vector3(rnd(- 5000,5000), rnd(-5000,5000), rnd(-5000,5000));75 this->targetPosition_ = Vector3(rnd(-2000,2000), rnd(-2000,2000), rnd(-2000,2000)); 76 76 this->bHasTargetPosition_ = true; 77 77 } … … 88 88 { 89 89 // if (it->getTeamNr() != this->getTeamNr()) 90 if ((ControllableEntity*)(*it) != this->getControllableEntity()) 90 91 { 91 92 float speed = this->getControllableEntity()->getVelocity().length(); … … 113 114 return; 114 115 115 static const float hardcoded_projectile_speed = 500;116 static const float hardcoded_projectile_speed = 1250; 116 117 117 this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(), hardcoded_projectile_speed, this->target_->getPosition(), this->target_->get Orientation() * this->target_->getVelocity());118 this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(), hardcoded_projectile_speed, this->target_->getPosition(), this->target_->getVelocity()); 118 119 this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO); 119 120 } … … 138 139 } 139 140 140 void ArtificialController:: shipDied(Pawn* ship)141 void ArtificialController::destroyedPawn(Pawn* ship) 141 142 { 142 143 if (ship == this->target_) -
code/branches/presentation/src/orxonox/objects/controllers/ArtificialController.h
r2485 r2493 33 33 34 34 #include "Controller.h" 35 #include "objects/worldentities/pawns/Pawn.h" 35 36 #include "util/Math.h" 36 37 37 38 namespace orxonox 38 39 { 39 class _OrxonoxExport ArtificialController : public Controller 40 class _OrxonoxExport ArtificialController : public Controller, public PawnListener 40 41 { 41 42 public: … … 43 44 virtual ~ArtificialController(); 44 45 45 v oid shipDied(Pawn* ship);46 virtual void destroyedPawn(Pawn* pawn); 46 47 47 48 protected: -
code/branches/presentation/src/orxonox/objects/controllers/HumanController.cc
r2485 r2493 110 110 { 111 111 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 112 HumanController::localController_s->controllableEntity_->fire( );112 HumanController::localController_s->controllableEntity_->fire(WeaponMode::fire); 113 113 } 114 114 … … 116 116 { 117 117 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 118 HumanController::localController_s->controllableEntity_-> altFire();118 HumanController::localController_s->controllableEntity_->fire(WeaponMode::altFire); 119 119 } 120 120 -
code/branches/presentation/src/orxonox/objects/pickup/Usable.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddQuestHint.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddQuestHint.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddReward.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddReward.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/ChangeQuestStatus.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/ChangeQuestStatus.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/CompleteQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/CompleteQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/FailQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/FailQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/GlobalQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/GlobalQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/LocalQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/LocalQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/Quest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/Quest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestDescription.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestDescription.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestEffect.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestEffect.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestHint.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestHint.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestItem.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestItem.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestManager.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestManager.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/Rewardable.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/Rewardable.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/weaponSystem/CMakeLists.txt
r2131 r2493 2 2 Munition.cc 3 3 Weapon.cc 4 WeaponPack.cc 4 5 WeaponSet.cc 5 6 WeaponSlot.cc … … 7 8 ) 8 9 9 #ADD_SOURCE_DIRECTORY(SRC_FILES munitions)10 #ADD_SOURCE_DIRECTORY(SRC_FILES projectiles)11 #ADD_SOURCE_DIRECTORY(SRC_FILES weapons)10 ADD_SOURCE_DIRECTORY(SRC_FILES munitions) 11 ADD_SOURCE_DIRECTORY(SRC_FILES projectiles) 12 ADD_SOURCE_DIRECTORY(SRC_FILES weapons) 12 13 13 14 ADD_SOURCE_FILES(SRC_FILES) -
code/branches/presentation/src/orxonox/objects/weaponSystem/Munition.cc
r2097 r2493 37 37 namespace orxonox 38 38 { 39 CreateFactory(Munition); 40 39 41 Munition::Munition(BaseObject* creator) : BaseObject(creator) 40 42 { … … 46 48 } 47 49 50 unsigned int Munition::bullets() 51 { 52 if (this->bullets_ > 0) 53 return bullets_; 54 else 55 return 0; 56 } 57 58 unsigned int Munition::magazines() 59 { 60 if (this->magazines_ > 0) 61 return magazines_; 62 else 63 return 0; 64 } 65 66 void Munition::setMaxBullets(unsigned int amount) 67 { this->maxBullets_ = amount; } 68 69 void Munition::setMaxMagazines(unsigned int amount) 70 { this->maxMagazines_ = amount; } 71 72 void Munition::removeBullets(unsigned int amount) 73 { 74 if ( this->bullets_ != 0 ) 75 this->bullets_ = this->bullets_ - amount; 76 } 77 78 void Munition::removeMagazines(unsigned int amount) 79 { 80 if ( this->magazines_ != 0 ) 81 this->magazines_ = this->magazines_ - amount; 82 } 83 84 void Munition::addBullets(unsigned int amount) 85 { 86 if ( this->bullets_ == this->maxBullets_ ) 87 { 88 //cannot add bullets to actual magazine 89 } 90 else 91 this->bullets_ = this->bullets_ + amount; 92 } 93 94 void Munition::addMagazines(unsigned int amount) 95 { 96 if ( this->magazines_ == this->maxMagazines_ ) 97 { 98 //no more capacity for another magazine 99 } 100 else 101 this->magazines_ = this->magazines_ + amount; 102 } 103 104 105 void Munition::fillBullets() 106 { 107 //COUT(0) << "Munition::fillBullets maxBullets_=" << this->maxBullets_ << std::endl; 108 this->bullets_ = this->maxBullets_; 109 } 110 111 void Munition::fillMagazines() 112 { 113 this->magazines_ = this->maxMagazines_; 114 } 115 48 116 void Munition::XMLPort(Element& xmlelement, XMLPort::Mode mode) 49 117 { 50 118 SUPER(Munition, XMLPort, xmlelement, mode); 51 119 } 52 120 -
code/branches/presentation/src/orxonox/objects/weaponSystem/Munition.h
r2106 r2493 34 34 #include "core/BaseObject.h" 35 35 36 #include "Weapon.h" 37 36 38 37 39 namespace orxonox … … 45 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 48 49 void setMaxBullets(unsigned int amount); 50 void setMaxMagazines(unsigned int amount); 51 52 void fillBullets(); 53 void fillMagazines(); 54 55 unsigned int bullets(); 56 unsigned int magazines(); 57 58 void removeBullets(unsigned int k); 59 void removeMagazines(unsigned int k); 60 void addBullets(unsigned int k); 61 void addMagazines(unsigned int k); 47 62 48 63 private: 49 64 50 65 protected: 66 unsigned int bullets_; 67 unsigned int magazines_; 68 unsigned int maxBullets_; 69 unsigned int maxMagazines_; 51 70 }; 52 71 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/Weapon.cc
r2098 r2493 37 37 namespace orxonox 38 38 { 39 Weapon::Weapon(BaseObject* creator) : BaseObject(creator) 39 CreateFactory(Weapon); 40 41 Weapon::Weapon(BaseObject* creator) : StaticEntity(creator) 40 42 { 41 43 RegisterObject(Weapon); 42 43 this->loadingTime_ = 0; 44 this->bulletReadyToShoot_ = true; 45 this->magazineReadyToShoot_ = true; 46 this->parentWeaponSystem_ = 0; 47 this->attachedToWeaponSlot_ = 0; 44 48 this->munition_ = 0; 45 49 this->bulletLoadingTime_ = 0; 50 this->magazineLoadingTime_ = 0; 51 this->bReloading_ = false; 46 52 } 47 53 … … 50 56 } 51 57 52 void Weapon::addMunition() 58 59 void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode) 53 60 { 61 SUPER(Weapon, XMLPort, xmlelement, mode); 62 XMLPortParam(Weapon, "munitionType", setMunitionType, getMunitionType, xmlelement, mode); 63 XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode); 64 XMLPortParam(Weapon, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode); 65 } 66 67 void Weapon::setWeapon() 68 { 69 this->munition_->fillBullets(); 70 this->munition_->fillMagazines(); 71 } 72 73 74 void Weapon::fire() 75 { 76 //COUT(0) << "LaserGun::fire, this=" << this << std::endl; 77 if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_) 78 { 79 //COUT(0) << "LaserGun::fire - ready to shoot" << std::endl; 80 //COUT(0) << "LaserGun::fire - bullets" << this->munition_->bullets() << std::endl; 81 this->bulletReadyToShoot_ = false; 82 if ( this->munition_->bullets() > 0) 83 { 84 //shoot 85 this->takeBullets(); 86 this->createProjectile(); 87 } 88 //if there are no bullets, but magazines 89 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 ) 90 { 91 //COUT(0) << "LaserGun::fire - no bullets" << std::endl; 92 this->takeMagazines(); 93 } 94 else 95 { 96 //COUT(0) << "LaserGun::fire - no magazines" << std::endl; 97 //actions 98 } 99 } 100 else 101 { 102 //COUT(0) << "LaserGun::fire - weapon not reloaded - bullets remaining:" << this->munition_->bullets() << std::endl; 103 //actions 104 } 54 105 55 106 } 56 107 57 void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode) 108 109 void Weapon::bulletTimer(float bulletLoadingTime) 58 110 { 59 111 //COUT(0) << "Weapon::bulletTimer started" << std::endl; 112 this->bReloading_ = true; 113 this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded))); 114 } 115 void Weapon::magazineTimer(float magazineLoadingTime) 116 { 117 //COUT(0) << "Weapon::magazineTimer started" << std::endl; 118 this->bReloading_ = true; 119 this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded))); 60 120 } 61 121 62 void Weapon:: fire()122 void Weapon::bulletReloaded() 63 123 { 124 this->bReloading_ = false; 125 this->bulletReadyToShoot_ = true; 126 } 64 127 128 void Weapon::magazineReloaded() 129 { 130 this->bReloading_ = false; 131 this->munition_->fillBullets(); 132 this->magazineReadyToShoot_ = true; 133 this->bulletReadyToShoot_ = true; 65 134 } 135 136 137 void Weapon::attachNeededMunition(std::string munitionName) 138 { 139 //COUT(0) << "Weapon::attachNeededMunition, parentWeaponSystem=" << this->parentWeaponSystem_ << std::endl; 140 //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 141 if (this->parentWeaponSystem_) 142 { 143 //COUT(0) << "Weapon::attachNeededMunition " << munitionName << std::endl; 144 Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName); 145 if ( munition ) 146 this->munition_ = munition; 147 else 148 { 149 //create new munition with identifier 150 //COUT(0) << "Weapon::attachNeededMunition, create new Munition of Type " << munitionName << std::endl; 151 this->munitionIdentifier_ = ClassByString(munitionName); 152 this->munition_ = this->munitionIdentifier_.fabricate(this); 153 this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_); 154 } 155 } 156 } 157 158 159 /*get and set functions 160 * 161 */ 162 163 void Weapon::setMunitionType(std::string munitionType) 164 { this->munitionType_ = munitionType; } 165 166 const std::string Weapon::getMunitionType() 167 { return this->munitionType_; } 168 169 void Weapon::setBulletLoadingTime(float loadingTime) 170 { this->bulletLoadingTime_ = loadingTime; } 171 172 const float Weapon::getBulletLoadingTime() 173 { return this->bulletLoadingTime_; } 174 175 void Weapon::setMagazineLoadingTime(float loadingTime) 176 { this->magazineLoadingTime_ = loadingTime; } 177 178 const float Weapon::getMagazineLoadingTime() 179 { return this->magazineLoadingTime_; } 180 181 182 Munition * Weapon::getAttachedMunition(std::string munitionType) 183 { 184 //COUT(0) << "Weapon::getAttachedMunition, parentWeaponSystem_="<< this->parentWeaponSystem_ << std::endl; 185 this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType); 186 //COUT(0) << "Weapon::getAttachedMunition, munition_="<< this->munition_ << std::endl; 187 return this->munition_; 188 } 189 190 void Weapon::takeBullets() { }; 191 void Weapon::createProjectile() { }; 192 void Weapon::takeMagazines() { }; 193 66 194 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/Weapon.h
r2106 r2493 33 33 34 34 #include "core/BaseObject.h" 35 #include "tools/BillboardSet.h" 36 #include "tools/Timer.h" 37 #include "core/Identifier.h" 35 38 39 #include "WeaponSystem.h" 40 #include "Munition.h" 41 42 #include "objects/worldentities/StaticEntity.h" 36 43 37 44 namespace orxonox 38 45 { 39 class _OrxonoxExport Weapon : public BaseObject46 class _OrxonoxExport Weapon : public StaticEntity 40 47 { 41 48 public: … … 45 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 53 47 void addMunition();48 54 virtual void fire(); 55 void attachNeededMunition(std::string munitionType); 56 Munition * getAttachedMunition(std::string munitiontype); 57 58 //reloading 59 void bulletTimer(float bulletLoadingTime); 60 void magazineTimer(float magazineLoadingTime); 61 void bulletReloaded(); 62 void magazineReloaded(); 63 64 virtual void setMunitionType(std::string munitionType); 65 virtual const std::string getMunitionType(); 66 virtual void setBulletLoadingTime(float loadingTime); 67 virtual const float getBulletLoadingTime(); 68 virtual void setMagazineLoadingTime(float loadingTime); 69 virtual const float getMagazineLoadingTime(); 70 71 virtual void takeBullets(); 72 virtual void takeMagazines(); 73 virtual void createProjectile(); 74 75 inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem) 76 { this->parentWeaponSystem_=parentWeaponSystem; }; 77 inline WeaponSystem * getParentWeaponSystem() 78 { return this->parentWeaponSystem_; }; 79 80 inline void setAttachedToWeaponSlot(WeaponSlot * wSlot) 81 { this->attachedToWeaponSlot_ = wSlot; } 82 inline WeaponSlot * getAttachedToWeaponSlot() 83 { return this->attachedToWeaponSlot_; } 84 85 virtual void setWeapon(); 49 86 50 87 private: 51 int loadingTime_;52 Munition *munition_;53 88 89 protected: 90 bool bReloading_; 91 bool bulletReadyToShoot_; 92 bool magazineReadyToShoot_; 93 float bulletLoadingTime_; 94 float magazineLoadingTime_; 95 std::string munitionType_; 54 96 97 WeaponSlot * attachedToWeaponSlot_; 98 Munition * munition_; 99 WeaponSystem * parentWeaponSystem_; 55 100 101 SubclassIdentifier<Munition> munitionIdentifier_; 102 103 Timer<Weapon> bulletReloadTimer_; 104 Timer<Weapon> magazineReloadTimer_; 56 105 }; 57 106 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponPack.cc
r2489 r2493 63 63 for (int i=0; i < (int) this->weapons_.size(); i++) 64 64 { 65 COUT(0) << "WeaponPack::fire (attached from WeaponSet) from Weapon: "<< i << std::endl;65 //COUT(0) << "WeaponPack::fire (attached from WeaponSet) from Weapon: "<< i << std::endl; 66 66 this->weapons_[i]->getAttachedToWeaponSlot()->fire(); 67 67 } … … 83 83 void WeaponPack::setFireMode(unsigned int firemode) 84 84 { 85 COUT(0) << "WeaponPack::setFireMode " << std::endl;85 //COUT(0) << "WeaponPack::setFireMode " << std::endl; 86 86 this->firemode_ = firemode; 87 87 } … … 94 94 void WeaponPack::addWeapon(Weapon * weapon) 95 95 { 96 COUT(0) << "WeaponPack::addWeapon:" << weapon << " munition " << weapon->getMunitionType() << std::endl;96 //COUT(0) << "WeaponPack::addWeapon:" << weapon << " munition " << weapon->getMunitionType() << std::endl; 97 97 this->weapons_.push_back(weapon); 98 98 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSet.cc
r2098 r2493 33 33 #include "core/XMLPort.h" 34 34 #include "util/Debug.h" 35 #include "objects/worldentities/pawns/Pawn.h" 35 36 36 37 #include "WeaponSet.h" 38 #include "WeaponPack.h" 37 39 38 40 namespace orxonox 39 41 { 42 CreateFactory(WeaponSet); 43 40 44 WeaponSet::WeaponSet(BaseObject* creator, int k) : BaseObject(creator) 41 45 { … … 43 47 44 48 this->parentWeaponSystem_ = 0; 45 46 for (int i=0;i<k;i++) 47 { 48 attachWeaponSlot(new WeaponSlot(this)); 49 } 49 this->attachedWeaponPack_ = 0; 50 50 } 51 51 … … 54 54 } 55 55 56 //Vorwärtsdeklaration 57 WeaponSystem * parentWeaponSystem_; 56 void WeaponSet::attachWeaponPack(WeaponPack *wPack) 57 { 58 //COUT(0) << "WeaponSet::attachWeaponPack" << std::endl; 59 //COUT(0) << "........ parentWeaponSystem_=" << this->parentWeaponSystem_ << std::endl; 60 //COUT(0) << "........ this->parentWeaponSystem_->getWeaponSlotSize()" << this->parentWeaponSystem_->getWeaponSlotSize() << std::endl; 61 //COUT(0) << "........ wPack->getSize()" << wPack->getSize() << std::endl; 62 if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) ) 63 { 64 //COUT(0) << "WeaponSet::attachWeaponPack after if" << std::endl; 65 this->attachedWeaponPack_ = wPack; 66 int wPackWeapon = 0; //WeaponCounter for Attaching 67 //should be possible to choose which slot to use 68 for ( int i=0; i < wPack->getSize() ; i++ ) 69 { 70 //at the moment this function only works for one weaponPack in the entire WeaponSystem... 71 if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() == 0 && this->parentWeaponSystem_->getWeaponSlotPointer(i) != 0) //if slot not full 72 { 73 //COUT(0) << "WeaponSet::attachWeaponPack attaching Weapon" << std::endl; 74 this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(i) ); 75 this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) ); 76 this->parentWeaponSystem_->getParentPawn()->attach( wPack->getWeaponPointer(wPackWeapon) ); 77 wPackWeapon++; 78 } 79 else 80 { 81 for (int k=0; k < this->parentWeaponSystem_->getWeaponSlotSize(); k++) 82 { 83 if ( this->parentWeaponSystem_->getWeaponSlotPointer(k)->getAttachedWeapon() == 0 ) 84 { 85 //COUT(0) << "WeaponSet::attachWeaponPack mode 2 k="<< k << std::endl; 86 this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(k) ); 87 this->parentWeaponSystem_->getWeaponSlotPointer(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) ); 88 this->parentWeaponSystem_->getParentPawn()->attach( wPack->getWeaponPointer(wPackWeapon) ); 89 wPackWeapon++; 90 } 91 } 92 } 93 } 94 } 95 } 58 96 59 void WeaponSet::attachWeaponSlot(WeaponSlot *wSlot)60 {61 this->weaponSlots_.push_back(wSlot);62 }63 97 64 98 void WeaponSet::fire() 65 99 { 66 for (int i=0; i < (int) this->weaponSlots_.size(); i++)67 { 68 this->weaponSlots_[i]->fire();69 }100 //fires all WeaponSlots available for this weaponSet attached from the WeaponPack 101 //COUT(0) << "WeaponSet::fire from Pack: " << this->attachedWeaponPack_ << std::endl; 102 if (this->attachedWeaponPack_) 103 this->attachedWeaponPack_->fire(); 70 104 } 71 105 72 WeaponSlot * WeaponSet::getWeaponSlotPointer(unsigned int n) 73 { 74 if (n < this->weaponSlots_.size()) 75 return this->weaponSlots_[n]; 76 else 77 return 0; 78 } 106 void WeaponSet::setFireMode(const unsigned int firemode) 107 { this->firemode_ = firemode; } 79 108 109 const unsigned int WeaponSet::getFireMode() const 110 { return this->firemode_; } 80 111 81 112 void WeaponSet::XMLPort(Element& xmlelement, XMLPort::Mode mode) 82 113 { 83 114 SUPER(WeaponSet, XMLPort, xmlelement, mode); 115 XMLPortParam(WeaponSet, "firemode", setFireMode, getFireMode, xmlelement, mode); 84 116 } 85 117 -
code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSet.h
r2106 r2493 48 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 49 50 void attachWeapon Slot(WeaponSlot *wSlot);50 void attachWeaponPack(WeaponPack *wPack); 51 51 void fire(); 52 WeaponSlot * getWeaponSlotPointer(unsigned int n); 52 53 void setFireMode(const unsigned int firemode); 54 const unsigned int getFireMode() const; 53 55 54 56 inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem) … … 58 60 59 61 private: 60 std::vector<WeaponSlot *> weaponSlots_;61 62 WeaponSystem *parentWeaponSystem_; 63 std::vector<WeaponSlot *> setWeaponSlots_; 64 unsigned int firemode_; 65 WeaponPack * attachedWeaponPack_; 62 66 }; 63 67 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSlot.cc
r2098 r2493 36 36 37 37 38 39 38 namespace orxonox 40 39 { 41 WeaponSlot::WeaponSlot(BaseObject* creator) : BaseObject(creator) 40 CreateFactory(WeaponSlot); 41 42 WeaponSlot::WeaponSlot(BaseObject* creator) : StaticEntity(creator) 42 43 { 43 44 RegisterObject(WeaponSlot); 44 45 45 46 this->unlimitedAmmo_ = false; 46 47 47 this->attachedWeapon_ = 0; 48 this-> parentWeaponSet_ = 0;48 this->setObjectMode(0x0); 49 49 } 50 50 … … 53 53 } 54 54 55 void WeaponSlot::attachWeapon(Weapon *weaponName)56 {57 58 }59 55 60 56 /*sets the munition type … … 67 63 } 68 64 65 69 66 void WeaponSlot::fire() 70 67 { 68 if ( this->attachedWeapon_ ) 69 //COUT(0) << "WeaponSlot::fire" << std::endl; 70 this->attachedWeapon_->fire(); 71 } 71 72 72 }73 73 74 74 void WeaponSlot::XMLPort(Element& xmlelement, XMLPort::Mode mode) 75 75 { 76 SUPER(WeaponSlot, XMLPort, xmlelement, mode); 77 } 76 78 79 void WeaponSlot::attachWeapon(Weapon *weapon) 80 { 81 this->attachedWeapon_ = weapon; 82 weapon->setAttachedToWeaponSlot(this); 83 //COUT(0) << "WeaponSlot::attachWeapon position=" << this->getWorldPosition() << std::endl; 84 weapon->setPosition(this->getPosition()); 85 } 86 87 Weapon * WeaponSlot::getAttachedWeapon() const 88 { 89 return this->attachedWeapon_; 77 90 } 78 91 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSlot.h
r2106 r2493 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "core/BaseObject.h"35 36 37 34 #include "Weapon.h" 38 35 #include "objects/worldentities/StaticEntity.h" 39 36 40 37 namespace orxonox 41 38 { 42 class _OrxonoxExport WeaponSlot : public BaseObject39 class _OrxonoxExport WeaponSlot : public StaticEntity 43 40 { 44 41 public: … … 48 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 46 50 void attachWeapon(Weapon *weaponName); 47 void attachWeapon(Weapon *weapon); 48 Weapon * getAttachedWeapon() const; 51 49 void setAmmoType(bool isUnlimited); 52 50 void fire(); 53 51 54 inline void setParentWeaponSet(WeaponSet *parentWeaponSet) 55 { parentWeaponSet_=parentWeaponSet; } 56 inline WeaponSet * getParentWeaponSet() 57 { return parentWeaponSet_; } 58 52 inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem) 53 { parentWeaponSystem_=parentWeaponSystem; } 54 inline WeaponSystem * getParentWeaponSystem() 55 { return parentWeaponSystem_; } 59 56 60 57 … … 63 60 bool unlimitedAmmo_; 64 61 65 WeaponS et *parentWeaponSet_;62 WeaponSystem *parentWeaponSystem_; 66 63 }; 67 64 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSystem.cc
- Property svn:mergeinfo changed
/code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc (added) merged: 2145,2186,2203,2272,2288,2308,2319,2327,2331,2337,2366,2391
r2492 r2493 37 37 #include "WeaponSystem.h" 38 38 39 39 40 /* WEAPONSYSTEM 40 41 * creates the WeaponSystem and the ability to use weapons and munition … … 45 46 namespace orxonox 46 47 { 48 CreateFactory(WeaponSystem); 49 47 50 WeaponSystem::WeaponSystem(BaseObject* creator) : BaseObject(creator) 48 51 { … … 50 53 51 54 this->activeWeaponSet_ = 0; 52 this->parent SpaceShip_ = 0;55 this->parentPawn_ = 0; 53 56 } 54 57 … … 57 60 } 58 61 59 //creates empty weaponSet 62 void WeaponSystem::attachWeaponPack(WeaponPack *wPack, unsigned int firemode) 63 { 64 if (firemode < this->weaponSets_.size()) 65 this->weaponSets_[firemode]->attachWeaponPack(wPack); 66 this->weaponPacks_.push_back(wPack); 67 } 68 69 void WeaponSystem::attachWeaponSlot(WeaponSlot *wSlot) 70 { 71 wSlot->setParentWeaponSystem(this); 72 this->weaponSlots_.push_back(wSlot); 73 } 74 60 75 void WeaponSystem::attachWeaponSet(WeaponSet *wSet) 61 76 { 77 wSet->setParentWeaponSystem(this); 62 78 this->weaponSets_.push_back(wSet); 63 wSet->setParentWeaponSystem(this);64 79 } 65 80 81 void WeaponSystem::setNewMunition(std::string munitionType, Munition * munitionToAdd) 82 { 83 this->munitionSet_[munitionType] = munitionToAdd; 84 } 85 86 //returns the Pointer to the munitionType 87 Munition * WeaponSystem::getMunitionType(std::string munitionType) 88 { 89 //COUT(0) << "WeaponSystem::getMunitionType " << munitionType << std::endl; 90 std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType); 91 if (it != this->munitionSet_.end()) 92 return it->second; 93 else 94 return 0; 95 } 96 97 98 /* 66 99 //the first weaponSet is at n=0 67 100 void WeaponSystem::setActiveWeaponSet(unsigned int n) … … 69 102 if (n < this->weaponSets_.size()) 70 103 this->activeWeaponSet_ = this->weaponSets_[n]; 104 else 105 this->activeWeaponSet_ = this->weaponSets_[0]; 106 } 107 */ 108 109 110 //n is the n'th weaponSet, starting with zero 111 //SpaceShip.cc only needs to have the keybinding to a specific Set-number n 112 void WeaponSystem::fire(WeaponMode::Enum n) 113 { 114 int set = 0; 115 switch (n) 116 { 117 case WeaponMode::fire: 118 set = 0; 119 break; 120 case WeaponMode::altFire: 121 set = 1; 122 break; 123 case WeaponMode::altFire2: 124 set = 2; 125 break; 126 } 127 //COUT(0) << "WeaponSystem::fire" << std::endl; 128 if (set < (int)this->weaponSets_.size()) 129 //COUT(0) << "WeaponSystem::fire - after if" << std::endl; 130 this->weaponSets_[set]->fire(); 71 131 } 72 132 73 //n is the n'th weaponSet, starting with zero74 //Spaceship.cc only needs to have the keybinding to a specific Set-number n75 void WeaponSystem::fire(unsigned int n)76 {77 if (n < this->weaponSets_.size())78 this->weaponSets_[n]->fire();79 }80 81 void WeaponSystem::fire()82 {83 if (this->activeWeaponSet_)84 this->activeWeaponSet_->fire();85 }86 133 87 134 WeaponSet * WeaponSystem::getWeaponSetPointer(unsigned int n) … … 93 140 } 94 141 142 WeaponSlot * WeaponSystem::getWeaponSlotPointer(unsigned int n) 143 { 144 if (n < this->weaponSlots_.size()) 145 return this->weaponSlots_[n]; 146 else 147 return 0; 148 } 149 150 WeaponPack * WeaponSystem::getWeaponPackPointer(unsigned int n) 151 { 152 if (n < this->weaponPacks_.size()) 153 return this->weaponPacks_[n]; 154 else 155 return 0; 156 } 157 95 158 void WeaponSystem::XMLPort(Element& xmlelement, XMLPort::Mode mode) 96 159 { 97 160 SUPER(WeaponSystem, XMLPort, xmlelement, mode); 98 161 } 99 162 - Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSystem.h
- Property svn:mergeinfo changed
/code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.h (added) merged: 2145,2186,2203,2288,2319
r2492 r2493 36 36 37 37 #include "WeaponSet.h" 38 #include "WeaponPack.h" 38 39 39 40 namespace orxonox 40 41 { 42 41 43 class _OrxonoxExport WeaponSystem : public BaseObject 42 44 { … … 47 49 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 48 50 51 void attachWeaponSlot(WeaponSlot *wSlot); 49 52 void attachWeaponSet(WeaponSet *wSet); 50 void fire(); 51 void fire(unsigned int n); 52 void setActiveWeaponSet(unsigned int n); 53 //void fire(); 54 void fire(WeaponMode::Enum fireMode); 55 //void setActiveWeaponSet(unsigned int n); 56 void attachWeaponPack(WeaponPack * wPack, unsigned int firemode); 53 57 WeaponSet * getWeaponSetPointer(unsigned int n); 58 WeaponSlot * getWeaponSlotPointer(unsigned int n); 59 WeaponPack * getWeaponPackPointer(unsigned int n); 60 void setNewMunition(std::string munitionType, Munition * munitionToAdd); 61 Munition * getMunitionType(std::string munitionType); 54 62 55 inline void setParent SpaceShip(SpaceShip *parentSpaceShip)56 { parent SpaceShip_=parentSpaceShip; }57 inline SpaceShip * getParentSpaceShip()58 { return parent SpaceShip_; }63 inline void setParentPawn(Pawn *parentPawn) 64 { parentPawn_=parentPawn; } 65 inline Pawn * getParentPawn() 66 { return parentPawn_; } 59 67 68 inline int getWeaponSlotSize() 69 { return this->weaponSlots_.size(); } 60 70 61 71 private: 62 72 std::vector<WeaponSet *> weaponSets_; 73 std::vector<WeaponSlot *> weaponSlots_; 74 std::vector<WeaponPack *> weaponPacks_; 75 std::map<std::string, Munition *> munitionSet_; 63 76 WeaponSet *activeWeaponSet_; 64 65 SpaceShip *parentSpaceShip_; 77 Pawn *parentPawn_; 66 78 }; 67 79 } - Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
r2097 r2493 37 37 namespace orxonox 38 38 { 39 LaserGunMunition::LaserGunMunition(BaseObject* creator) : BaseObject(creator) 39 CreateFactory(LaserGunMunition); 40 41 LaserGunMunition::LaserGunMunition(BaseObject* creator) : Munition(creator) 40 42 { 41 43 RegisterObject(LaserGunMunition); 44 45 this->maxBullets_ = 40; 46 this->maxMagazines_ = 100; 42 47 } 43 48 -
code/branches/presentation/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h
r2106 r2493 33 33 34 34 #include "core/BaseObject.h" 35 35 #include "../Munition.h" 36 36 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport LaserGunMunition : public BaseObject39 class _OrxonoxExport LaserGunMunition : public Munition 40 40 { 41 41 public: … … 47 47 48 48 private: 49 int bullets_;50 int magazines_;51 int maxBullets_;52 int maxMagazines_;53 49 54 50 -
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc
r2099 r2493 30 30 #include "BillboardProjectile.h" 31 31 32 #include <OgreBillboard .h>32 #include <OgreBillboardSet.h> 33 33 34 34 #include "core/CoreIncludes.h" 35 #include "objects/Scene.h" 35 36 36 37 namespace orxonox … … 38 39 CreateFactory(BillboardProjectile); 39 40 40 BillboardProjectile::BillboardProjectile(BaseObject* creator , Weapon* owner) : Projectile(creator, owner)41 BillboardProjectile::BillboardProjectile(BaseObject* creator) : Projectile(creator) 41 42 { 42 43 RegisterObject(BillboardProjectile); 43 44 44 this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1); 45 this->attachObject(this->billboard_.getBillboardSet()); 46 this->scale(0.5); 45 assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity 46 47 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(0.5, 0.5, 0.7, 0.8), 1); 48 this->attachOgreObject(this->billboard_.getBillboardSet()); 49 this->scale(0.2); 47 50 } 48 51 49 52 BillboardProjectile::~BillboardProjectile() 50 53 { 51 if (this->isInitialized() && this->owner_)52 this->detachObject(this->billboard_.getBillboardSet());54 //if (this->isInitialized() && this->owner_) 55 //this->detachObject(this->billboard_.getBillboardSet()); 53 56 } 54 57 55 58 void BillboardProjectile::setColour(const ColourValue& colour) 56 59 { 57 this->billboard_. getBillboardSet()->getBillboard(0)->setColour(colour);60 this->billboard_.setColour(colour); 58 61 } 59 62 -
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.h
r2099 r2493 41 41 { 42 42 public: 43 BillboardProjectile(BaseObject* creator , Weapon* owner = 0);43 BillboardProjectile(BaseObject* creator); 44 44 virtual ~BillboardProjectile(); 45 45 -
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc
r2099 r2493 30 30 #include "ParticleProjectile.h" 31 31 32 #include "SpaceShip.h" 32 #include <OgreParticleSystem.h> 33 #include <OgreParticleEmitter.h> 34 35 #include "../../worldentities/pawns/SpaceShip.h" 33 36 #include "core/CoreIncludes.h" 34 37 #include "core/ConfigValueIncludes.h" 38 #include "objects/Scene.h" 35 39 36 40 namespace orxonox … … 38 42 CreateFactory(ParticleProjectile); 39 43 40 ParticleProjectile::ParticleProjectile(BaseObject* creator , Weapon* owner) : BillboardProjectile(creator, owner)44 ParticleProjectile::ParticleProjectile(BaseObject* creator) : BillboardProjectile(creator) 41 45 { 42 46 RegisterObject(ParticleProjectile); 43 47 44 this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal); 45 this->particles_->addToSceneNode(this->getNode()); 46 this->particles_->setKeepParticlesInLocalSpace(true); 48 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal); 49 this->attachOgreObject(this->particles_->getParticleSystem()); 50 this->particles_->setKeepParticlesInLocalSpace(0); 51 52 this->particles_->getAllEmitters()->setDirection(-WorldEntity::FRONT); 53 /* 47 54 if (this->owner_) 48 55 { … … 52 59 // this->particles_ = 0; 53 60 // } 61 */ 54 62 55 63 this->setConfigValues(); … … 59 67 { 60 68 if (this->isInitialized() && this->particles_) 69 { 70 this->detachOgreObject(this->particles_->getParticleSystem()); 61 71 delete this->particles_; 72 } 62 73 } 63 74 64 75 void ParticleProjectile::setConfigValues() 65 76 { 66 SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback((Projectile*)this, &ParticleProjectile::speedChanged);77 //SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback((Projectile*)this, &ParticleProjectile::speedChanged); 67 78 } 68 79 … … 72 83 this->particles_->setEnabled(this->isVisible()); 73 84 } 74 75 bool ParticleProjectile::create(){76 if(!Projectile::create())77 return false;78 this->particles_->getAllEmitters()->setDirection(-this->getOrientation()*Vector3(1,0,0));79 return true;80 }81 85 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.h
r2099 r2493 41 41 { 42 42 public: 43 ParticleProjectile(BaseObject* creator , Weapon* owner = 0);43 ParticleProjectile(BaseObject* creator); 44 44 virtual ~ParticleProjectile(); 45 45 virtual void changedVisibility(); 46 46 void setConfigValues(); 47 48 virtual bool create();49 47 50 48 private: -
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
r2466 r2493 40 40 #include "objects/worldentities/Model.h" 41 41 #include "objects/worldentities/ParticleSpawner.h" 42 #include " Settings.h"42 #include "core/Core.h" 43 43 44 44 namespace orxonox 45 45 { 46 float Projectile::speed_s = 5000; 47 48 Projectile::Projectile(BaseObject* creator, Weapon* owner) : MovableEntity(creator), owner_(owner) 46 Projectile::Projectile(BaseObject* creator) : MovableEntity(creator) 49 47 { 50 48 RegisterObject(Projectile); … … 54 52 this->smokeTemplateName_ = "Orxonox/smoke4"; 55 53 56 this->setStatic(false);57 this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL);54 //this->setStatic(false); 55 // this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL); 58 56 59 57 // Get notification about collisions 60 58 this->enableCollisionCallback(); 61 59 60 /* 62 61 if (this->owner_) 63 62 { … … 66 65 this->setVelocity(this->owner_->getInitialDir() * this->speed_); 67 66 } 67 */ 68 68 69 if(! orxonox::Settings::isClient()) //only if not on client69 if(!Core::isClient()) //only if not on client 70 70 this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject))); 71 71 } … … 79 79 SetConfigValue(damage_, 15.0).description("The damage caused by the projectile"); 80 80 SetConfigValue(lifetime_, 4.0).description("The time in seconds a projectile stays alive"); 81 SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback(this, &Projectile::speedChanged);82 81 } 83 82 84 void Projectile::speedChanged()85 {86 Projectile::speed_s = this->speed_;87 if (this->owner_)88 this->setVelocity(this->owner_->getInitialDir() * this->speed_);89 }90 83 91 84 void Projectile::tick(float dt) … … 95 88 if (!this->isActive()) 96 89 return; 97 90 /* 98 91 float radius; 99 92 for (ObjectList<Model>::iterator it = ObjectList<Model>::begin(); it; ++it) … … 106 99 { 107 100 // hit 108 ParticleSpawner* explosion = new ParticleSpawner(this->explosionTemplateName_, LODParticle::low, 2.0); 101 ParticleSpawner* explosion = new ParticleSpawner(this); 102 explosion->setSource(this->explosionTemplateName_); 103 explosion->setLOD(LODParticle::low); 104 explosion->configure(2.0); 109 105 explosion->setPosition(this->getPosition()); 110 106 explosion->create(); 111 ParticleSpawner* smoke = new ParticleSpawner(this->smokeTemplateName_, LODParticle::normal, 2.0, 0.0); 107 ParticleSpawner* smoke = new ParticleSpawner(this); 108 smoke->setSource(this->smokeTemplateName_); 109 smoke->setLOD(LODParticle::normal); 110 smoke->configure(2.0, 0.0); 112 111 smoke->setPosition(this->getPosition()); 113 112 // smoke->getParticleInterface()->setSpeedFactor(3.0); … … 118 117 } 119 118 } 119 */ 120 120 } 121 121 … … 124 124 delete this; 125 125 } 126 127 bool Projectile::create(){128 return WorldEntity::create();129 }130 126 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/Projectile.h
r2099 r2493 42 42 virtual ~Projectile(); 43 43 void setConfigValues(); 44 void speedChanged();45 44 void destroyObject(); 46 45 virtual void tick(float dt); 47 46 48 virtual bool create();49 50 static float getSpeed()51 { return Projectile::speed_s; }52 53 47 protected: 54 Projectile(BaseObject* creator, Weapon* owner = 0); 55 SpaceShip* owner_; 48 Projectile(BaseObject* creator); 56 49 57 50 private: … … 59 52 std::string smokeTemplateName_; 60 53 protected: 61 static float speed_s;62 54 float speed_; 63 55 private: -
code/branches/presentation/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt
r2131 r2493 1 1 SET( SRC_FILES 2 Fusion.cc 2 3 LaserGun.cc 3 Missile.cc4 # Missile.cc 4 5 ) 5 6 -
code/branches/presentation/src/orxonox/objects/weaponSystem/weapons/Fusion.cc
r2489 r2493 44 44 { 45 45 RegisterObject(Fusion); 46 46 47 47 this->speed_ = 1250; 48 48 … … 55 55 void Fusion::takeBullets() 56 56 { 57 COUT(0) << "Fusion::takeBullets" << std::endl;57 //COUT(0) << "Fusion::takeBullets" << std::endl; 58 58 this->munition_->removeBullets(1); 59 59 this->bulletTimer(this->bulletLoadingTime_); … … 68 68 void Fusion::createProjectile() 69 69 { 70 COUT(0) << "Fusion::createProjectile" << std::endl;70 //COUT(0) << "Fusion::createProjectile" << std::endl; 71 71 BillboardProjectile* projectile = new ParticleProjectile(this); 72 72 projectile->setOrientation(this->getWorldOrientation()); 73 73 projectile->setPosition(this->getWorldPosition()); 74 projectile->setVelocity( WorldEntity::FRONT * this->speed_);74 projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_); 75 75 } 76 76 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
r2097 r2493 34 34 #include "util/Debug.h" 35 35 36 #include "LaserGun.h" 37 36 38 37 39 namespace orxonox 38 40 { 41 CreateFactory(LaserGun); 42 39 43 LaserGun::LaserGun(BaseObject* creator) : Weapon(creator) 40 44 { 41 45 RegisterObject(LaserGun); 42 46 43 projectileColor_ = ColourValue(1.0, 1.0, 0.5) 47 this->speed_ = 1250; 48 44 49 } 45 50 … … 48 53 } 49 54 50 LaserGun::fire()55 void LaserGun::takeBullets() 51 56 { 52 BillboardProjectile* projectile = new ParticleProjectile(this); 53 projectile->setColour(this->projectileColor_); 54 projectile->create(); 55 if (projectile->getClassID() == 0) 56 { 57 COUT(3) << "generated projectile with classid 0" << std::endl; // TODO: remove this output 58 } 59 60 projectile->setObjectMode(0x3); 57 //COUT(0) << "LaserGun::takeBullets" << std::endl; 58 this->munition_->removeBullets(1); 59 this->bulletTimer(this->bulletLoadingTime_); 61 60 } 62 61 63 LaserGun::addMunition()62 void LaserGun::takeMagazines() 64 63 { 65 //this->munition_ = ; 64 this->munition_->removeMagazines(1); 65 this->magazineTimer(this->magazineLoadingTime_); 66 66 } 67 67 68 void LaserGun:: XMLPort(Element& xmlelement, XMLPort::Mode mode)68 void LaserGun::createProjectile() 69 69 { 70 71 } 72 73 ColorValue LaserGun::getProjectileColor() 74 { 75 return projectileColor_; 70 //COUT(0) << "LaserGun::createProjectile" << std::endl; 71 BillboardProjectile* projectile = new ParticleProjectile(this); 72 projectile->setOrientation(this->getWorldOrientation()); 73 projectile->setPosition(this->getWorldPosition()); 74 projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_); 76 75 } 77 76 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
r2106 r2493 34 34 #include "core/BaseObject.h" 35 35 36 #include "LaserGunMunition.h" 37 #include "tools/BillboardSet.h" 36 #include "../munitions/LaserGunMunition.h" 38 37 #include "util/Math.h" 38 #include "../Weapon.h" 39 #include "../projectiles/BillboardProjectile.h" 40 #include "../projectiles/ParticleProjectile.h" 39 41 40 42 namespace orxonox … … 46 48 virtual ~LaserGun(); 47 49 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);49 50 ColourValue LaserGun::getProjectileColour();50 virtual void takeBullets(); 51 virtual void takeMagazines(); 52 virtual void createProjectile(); 51 53 52 54 private: 53 ColorValue projectileColor_; 54 55 55 float speed_; 56 56 57 57 }; -
code/branches/presentation/src/orxonox/objects/worldentities/Backlight.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/worldentities/Backlight.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/worldentities/Camera.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/worldentities/Camera.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/worldentities/ControllableEntity.h
r2485 r2493 33 33 34 34 #include "MobileEntity.h" 35 #include "objects/weaponSystem/WeaponSystem.h" 35 36 36 37 namespace orxonox … … 81 82 { this->rotateRoll(Vector2(value, 0)); } 82 83 83 virtual void fire( ) {}84 virtual void altFire( ) {}84 virtual void fire(WeaponMode::Enum fireMode) {} 85 virtual void altFire(WeaponMode::Enum fireMode) {} 85 86 86 87 virtual void boost() {} -
code/branches/presentation/src/orxonox/objects/worldentities/ParticleSpawner.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/worldentities/ParticleSpawner.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2485 r2493 37 37 #include "objects/infos/PlayerInfo.h" 38 38 #include "objects/gametypes/Gametype.h" 39 #include "objects/weaponSystem/WeaponSystem.h"40 39 #include "objects/worldentities/ParticleSpawner.h" 41 40 #include "objects/worldentities/ExplosionChunk.h" … … 52 51 53 52 this->bAlive_ = true; 53 this->fire_ = 0x0; 54 54 55 55 this->health_ = 0; … … 58 58 59 59 this->lastHitOriginator_ = 0; 60 this->weaponSystem_ = 0;61 60 62 61 this->spawnparticleduration_ = 3.0f; 63 62 64 /*65 //WeaponSystem66 weaponSystem_ = new WeaponSystem();67 WeaponSet * weaponSet1 = new WeaponSet(1);68 this->weaponSystem_->attachWeaponSet(weaponSet1);69 this->weaponSystem_->getWeaponSetPointer(0)->getWeaponSlotPointer(0)->setAmmoType(true);70 */63 if (Core::isMaster()) 64 { 65 this->weaponSystem_ = new WeaponSystem(this); 66 this->weaponSystem_->setParentPawn(this); 67 } 68 else 69 this->weaponSystem_ = 0; 71 70 72 71 this->setRadarObjectColour(ColourValue::Red); … … 82 81 for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it) 83 82 it->destroyedPawn(this); 83 84 if (this->weaponSystem_) 85 delete this->weaponSystem_; 84 86 } 85 87 } … … 95 97 XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f); 96 98 XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7); 99 100 XMLPortObject(Pawn, WeaponSlot, "weaponslots", setWeaponSlot, getWeaponSlot, xmlelement, mode); 101 XMLPortObject(Pawn, WeaponSet, "weaponsets", setWeaponSet, getWeaponSet, xmlelement, mode); 102 XMLPortObject(Pawn, WeaponPack, "weapons", setWeaponPack, getWeaponPack, xmlelement, mode); 97 103 } 98 104 … … 102 108 registerVariable(this->health_, variableDirection::toclient); 103 109 registerVariable(this->initialHealth_, variableDirection::toclient); 110 registerVariable(this->fire_, variableDirection::toclient); 104 111 } 105 112 … … 107 114 { 108 115 SUPER(Pawn, tick, dt); 116 117 if (this->weaponSystem_) 118 { 119 if (this->fire_ & WeaponMode::fire) 120 this->weaponSystem_->fire(WeaponMode::fire); 121 if (this->fire_ & WeaponMode::altFire) 122 this->weaponSystem_->fire(WeaponMode::altFire); 123 if (this->fire_ & WeaponMode::altFire2) 124 this->weaponSystem_->fire(WeaponMode::altFire2); 125 } 126 this->fire_ = 0x0; 109 127 110 128 if (this->health_ <= 0) … … 205 223 } 206 224 207 void Pawn::fire() 208 { 209 if (this->weaponSystem_) 210 this->weaponSystem_->fire(); 225 void Pawn::fire(WeaponMode::Enum fireMode) 226 { 227 this->fire_ |= fireMode; 211 228 } 212 229 … … 217 234 this->spawneffect(); 218 235 } 236 237 void Pawn::setWeaponSlot(WeaponSlot * wSlot) 238 { 239 this->attach(wSlot); 240 if (this->weaponSystem_) 241 this->weaponSystem_->attachWeaponSlot(wSlot); 242 } 243 244 WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const 245 { 246 if (this->weaponSystem_) 247 return this->weaponSystem_->getWeaponSlotPointer(index); 248 else 249 return 0; 250 } 251 252 void Pawn::setWeaponPack(WeaponPack * wPack) 253 { 254 if (this->weaponSystem_) 255 { 256 wPack->setParentWeaponSystem(this->weaponSystem_); 257 wPack->setParentWeaponSystemToAllWeapons(this->weaponSystem_); 258 this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() ); 259 wPack->attachNeededMunitionToAllWeapons(); 260 } 261 } 262 263 WeaponPack * Pawn::getWeaponPack(unsigned int firemode) const 264 { 265 if (this->weaponSystem_) 266 return this->weaponSystem_->getWeaponPackPointer(firemode); 267 else 268 return 0; 269 } 270 271 void Pawn::setWeaponSet(WeaponSet * wSet) 272 { 273 if (this->weaponSystem_) 274 this->weaponSystem_->attachWeaponSet(wSet); 275 } 276 277 WeaponSet * Pawn::getWeaponSet(unsigned int index) const 278 { 279 if (this->weaponSystem_) 280 return this->weaponSystem_->getWeaponSetPointer(index); 281 else 282 return 0; 283 } 284 219 285 220 286 /////////////////// -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Pawn.h
r2485 r2493 34 34 #include "objects/worldentities/ControllableEntity.h" 35 35 #include "objects/RadarViewable.h" 36 #include "objects/weaponSystem/WeaponSystem.h" 36 37 37 38 namespace orxonox … … 75 76 virtual void kill(); 76 77 77 virtual void fire( );78 virtual void fire(WeaponMode::Enum fireMode); 78 79 79 80 virtual void postSpawn(); 81 82 void setWeaponSlot(WeaponSlot * wSlot); 83 WeaponSlot * getWeaponSlot(unsigned int index) const; 84 void setWeaponPack(WeaponPack * wPack); 85 WeaponPack * getWeaponPack(unsigned int firemode) const; 86 void setWeaponSet(WeaponSet * wSet); 87 WeaponSet * getWeaponSet(unsigned int index) const; 80 88 81 89 inline const WorldEntity* getWorldEntity() const … … 111 119 112 120 WeaponSystem* weaponSystem_; 121 unsigned int fire_; 113 122 114 123 std::string spawnparticlesource_; … … 117 126 }; 118 127 119 class _OrxonoxExport PawnListener : public OrxonoxClass128 class _OrxonoxExport PawnListener : virtual public OrxonoxClass 120 129 { 121 130 friend class Pawn; -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2485 r2493 196 196 } 197 197 198 void Spectator::fire( )198 void Spectator::fire(WeaponMode::Enum fireMode) 199 199 { 200 200 if (this->getPlayer()) -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Spectator.h
r2485 r2493 57 57 virtual void rotateRoll(const Vector2& value); 58 58 59 virtual void fire( );59 virtual void fire(WeaponMode::Enum fireMode); 60 60 virtual void greet(); 61 61 -
code/branches/presentation/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/worldentities/triggers/Trigger.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/worldentities/triggers/Trigger.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/tools/BillboardSet.h
r2459 r2493 52 52 inline Ogre::BillboardSet* getBillboardSet() 53 53 { return this->billboardSet_; } 54 inline Ogre::SceneManager* getSceneManager() 55 { return this->scenemanager_; } 54 56 55 57 const std::string& getName() const; -
code/branches/presentation/src/tolua/tolua-5.1.pkg
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/util
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/util/Exception.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/util/Exception.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/util/SignalHandler.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/util/SignalHandler.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/audio.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/base.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/ceguilua.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/core.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/cpptcl.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/debug.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/directories.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/lua.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/network.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/orxonox.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/orxonox_vc8.sln
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/release.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/tinyxml.vcproj
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/tinyxml.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/tolua.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/toluagen.vcproj
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/toluagen.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/toluagen_orxonox.vcproj
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/toluagen_orxonox.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/util.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset
for help on using the changeset viewer.