Changeset 10023 for code/branches
- Timestamp:
- Apr 9, 2014, 9:50:45 PM (11 years ago)
- Location:
- code/branches/modularships
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/modularships/data/levels/emptyLevel.oxw
r10011 r10023 98 98 </ModularSpaceShip> 99 99 100 <ModularSpaceShip position="0,-1000,-200" >100 <ModularSpaceShip position="0,-1000,-200" health="1000" maxhealth="2000" initialhealth="1000"> 101 101 <templates> 102 102 <Template link=HeavyCruiser /> -
code/branches/modularships/data/levels/templates/HeavyCruiser.oxt
r10019 r10023 11 11 explosionchunks = 6 12 12 13 health = 100 14 maxhealth = 200 15 initialhealth = 100 13 health = 1000 14 maxhealth = 2000 15 initialhealth = 1000 16 16 17 17 shieldhealth = 100 … … 51 51 52 52 <parts> 53 <ShipPart name="frontL" /> 54 <ShipPart name="frontR" /> 53 <ShipPart name="frontL" health="100" damageabsorption="0.5" /> 54 <ShipPart name="frontR" health="100" damageabsorption="0.5" /> 55 <ShipPart name="partL" health="100" damageabsorption="0.5" /> 56 <ShipPart name="partR" health="100" damageabsorption="0.5" /> 57 <ShipPart name="sidearmL" health="201" damageabsorption="0.2" /> 58 <ShipPart name="sidearmLfront" health="100" damageabsorption="0.5" /> 59 <ShipPart name="sidearmR" health="200" damageabsorption="0.2" /> 60 <ShipPart name="sidearmRfront" health="100" damageabsorption="0.5" /> 55 61 </parts> 56 62 … … 61 67 <attached> 62 68 <Model mesh="HeavyCruiser_frontL.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 69 <BlinkingBillboard position="-75,30,-416" material="Examples/Flare" colour="0.8, 0.8, 0, 0.1" amplitude=0.05 frequency=0.3 phase=240 quadratic=1 /> 70 <BlinkingBillboard position="-74,30,-402" material="Examples/Flare" colour="0.8, 0.8, 0, 0.1" amplitude=0.1 frequency=0.3 phase=120 quadratic=1 /> 71 <BlinkingBillboard position="-73,30,-388" material="Examples/Flare" colour="0.8, 0.8, 0, 0.1" amplitude=0.15 frequency=0.3 phase=0 quadratic=1 /> 63 72 </attached> 64 73 <collisionShapes> … … 71 80 <attached> 72 81 <Model mesh="HeavyCruiser_frontR.mesh" direction="-1,0,0" position="0,0,0" scale="40"/> 82 <BlinkingBillboard position="75,30,-416" material="Examples/Flare" colour="0.8, 0.8, 0, 0.1" amplitude=0.05 frequency=0.3 phase=240 quadratic=1 /> 83 <BlinkingBillboard position="74,30,-402" material="Examples/Flare" colour="0.8, 0.8, 0, 0.1" amplitude=0.1 frequency=0.3 phase=120 quadratic=1 /> 84 <BlinkingBillboard position="73,30,-388" material="Examples/Flare" colour="0.8, 0.8, 0, 0.1" amplitude=0.15 frequency=0.3 phase=0 quadratic=1 /> 73 85 </attached> 74 86 <collisionShapes> … … 176 188 </StaticEntity> 177 189 178 <!-- bay1 lights -->179 <BlinkingBillboard position="75,30,-416" material="Examples/Flare" colour="0.8, 0.8, 0, 0.1" amplitude=0.05 frequency=0.3 phase=240 quadratic=1 />180 <BlinkingBillboard position="-75,30,-416" material="Examples/Flare" colour="0.8, 0.8, 0, 0.1" amplitude=0.05 frequency=0.3 phase=240 quadratic=1 />181 <BlinkingBillboard position="74,30,-402" material="Examples/Flare" colour="0.8, 0.8, 0, 0.1" amplitude=0.1 frequency=0.3 phase=120 quadratic=1 />182 <BlinkingBillboard position="-74,30,-402" material="Examples/Flare" colour="0.8, 0.8, 0, 0.1" amplitude=0.1 frequency=0.3 phase=120 quadratic=1 />183 <BlinkingBillboard position="73,30,-388" material="Examples/Flare" colour="0.8, 0.8, 0, 0.1" amplitude=0.15 frequency=0.3 phase=0 quadratic=1 />184 <BlinkingBillboard position="-73,30,-388" material="Examples/Flare" colour="0.8, 0.8, 0, 0.1" amplitude=0.15 frequency=0.3 phase=0 quadratic=1 />185 190 <!-- front position lights --> 186 191 <BlinkingBillboard position="67,-5,-240" material="Examples/Flare" colour="0, 0.7, 0, 0.1" amplitude=0.3 frequency=0.15 phase=0 quadratic=1 /> -
code/branches/modularships/src/orxonox/OrxonoxPrereqs.h
r9348 r10023 142 142 143 143 // items 144 class ShipPart; 144 145 class Engine; 145 146 class Item; … … 189 190 class Pawn; 190 191 class SpaceShip; 192 class ModularSpaceShip; 191 193 class Spectator; 192 194 class TeamBaseMatchBase; -
code/branches/modularships/src/orxonox/items/ShipPart.cc
r10019 r10023 37 37 #include "Item.h" 38 38 #include "worldentities/pawns/Pawn.h" 39 #include "worldentities/pawns/ModularSpaceShip.h" 39 40 #include "gametypes/Gametype.h" 40 41 #include "worldentities/StaticEntity.h" … … 56 57 } 57 58 59 void ShipPart::XMLPort(Element& xmlelement, XMLPort::Mode mode) 60 { 61 SUPER(ShipPart, XMLPort, xmlelement, mode); 62 63 XMLPortParam(ShipPart, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100); 64 XMLPortParam(ShipPart, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); 65 XMLPortParam(ShipPart, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100); 66 67 XMLPortParam(ShipPart, "damageabsorption", setDamageAbsorption, getDamageAbsorption, xmlelement, mode).defaultValues(0.5); 68 69 /* 70 XMLPortParam(ShipPart, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0); 71 XMLPortParam(ShipPart, "initialshieldhealth", setInitialShieldHealth, getInitialShieldHealth, xmlelement, mode).defaultValues(0); 72 XMLPortParam(ShipPart, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100); 73 XMLPortParam(ShipPart, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0); 74 75 XMLPortParam(ShipPart, "sShipPartparticlesource", setSShipPartParticleSource, getSShipPartParticleSource, xmlelement, mode); 76 XMLPortParam(ShipPart, "sShipPartparticleduration", setSShipPartParticleDuration, getSShipPartParticleDuration, xmlelement, mode).defaultValues(3.0f); 77 XMLPortParam(ShipPart, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7); 78 79 XMLPortParam(ShipPart, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0); 80 XMLPortParam(ShipPart, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f); 81 82 XMLPortParam(ShipPart, "explosionSound", setExplosionSound, getExplosionSound, xmlelement, mode); 83 84 XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode ); 85 */ 86 } 87 88 void ShipPart::death() 89 { 90 this->parent_->removeShipPart(this); 91 } 58 92 59 93 /** … … 112 146 { 113 147 this->damageAbsorption_ = value; 148 } 149 150 void ShipPart::setParent(ModularSpaceShip* ship) 151 { 152 this->parent_ = ship; 114 153 } 115 154 … … 152 191 } 153 192 } 193 if (this->health_ < 0) 194 this->death(); 195 orxout() << "Health of ShipPart " << this->getName() << " is " << this->getHealth() << endl; 154 196 } 155 197 -
code/branches/modularships/src/orxonox/items/ShipPart.h
r10019 r10023 46 46 virtual ~ShipPart(); 47 47 48 //virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 49 50 50 virtual void handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator); 51 52 virtual void death(); 51 53 52 54 //virtual void attachTo(Pawn* newParent); … … 63 65 { return this->damageAbsorption_; } 64 66 67 void setParent(ModularSpaceShip* ship); 68 inline ModularSpaceShip* getParent() 69 { return this->parent_; } 70 65 71 virtual void setHealth(float health); 66 72 inline void addHealth(float health) … … 71 77 { return this->health_; } 72 78 79 inline void setMaxHealth(float maxhealth) 80 { this->maxHealth_ = maxhealth; this->setHealth(this->health_); } 81 inline float getMaxHealth() const 82 { return this->maxHealth_; } 83 84 inline void setInitialHealth(float initialhealth) 85 { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); } 86 inline float getInitialHealth() const 87 { return this->initialHealth_; } 88 73 89 74 90 // FIXME: (noep) Why doesn't this work? Works fine in Engine.h … … 76 92 77 93 protected: 78 Pawn* parent_;94 ModularSpaceShip* parent_; 79 95 unsigned int parentID_; // Object ID of the SpaceShip the Part is mounted on. 80 96 81 97 float damageAbsorption_; 82 98 float health_; 99 float maxHealth_; 100 float initialHealth_; 83 101 84 102 private: -
code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
r10019 r10023 88 88 if((this->partList_[j]->getName() == this->getAttachedObject(i)->getName()) && !this->partList_[j]->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)))) 89 89 { 90 // The Entity is added to the part's entityList_ 90 91 this->partList_[j]->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))); 92 // An entry in the partMap_ is created, assigning the part to the entity. 93 this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), this->partList_[j]); 91 94 orxout() << "A matching part-entity-pair with name " << this->partList_[j]->getName() << " was found!" << endl; 92 95 this->partList_[j]->printEntities(); // FIXME: (noep) remove debug … … 94 97 } 95 98 } 99 100 orxout() << "List of all assignments:" << endl; 101 for (std::map<StaticEntity*, ShipPart*>::const_iterator it = this->partMap_.begin(); it != this->partMap_.end(); ++it) 102 { 103 orxout() << "Entity: " << it->first << " Part: " << it->second << endl; 104 } 96 105 } 97 106 … … 143 152 orxout() << "UserPtr of said collisionShape: " << cs->getUserPointer() << endl; 144 153 145 // List all attached Objects 154 155 // Print all attached objects & parts 156 /* 146 157 orxout() << " " << this->getName() << " has the following Objects attached:" << endl; 147 for (int i=0; i<10; i++) 158 159 for (int i=0; i<50; i++) 148 160 { 149 161 if (this->getAttachedObject(i)==NULL) … … 157 169 { 158 170 orxout() << " " << i << ": " << this->partList_[i] << " (" << this->partList_[i]->getName() << ")" << endl; 159 } 171 }*/ 172 160 173 161 174 //int collisionShapeIndex = this->isMyCollisionShape(cs); 162 175 //orxout() << collisionShapeIndex << endl; 163 176 164 orxout() << "ShipPart of Entity " << cs->getUserPointer() << ": " << this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) << endl; 177 //orxout() << "ShipPart of Entity " << cs->getUserPointer() << ": " << this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) << endl; 178 179 orxout() << "CP_start" << endl; 165 180 166 181 if (this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) != NULL) 167 182 this->getPartOfEntity((StaticEntity*)(cs->getUserPointer()))->handleHit(damage, healthdamage, shielddamage, originator); 168 //else 169 // SpaceShip::damage(damage, healthdamage, shielddamage, originator, cs); 183 else 184 SpaceShip::damage(damage, healthdamage, shielddamage, originator, cs); 185 186 orxout() << "CP_end" << endl; 170 187 171 188 /* … … 208 225 OrxAssert(part != NULL, "The ShipPart cannot be NULL."); 209 226 this->partList_.push_back(part); 227 part->setParent(this); 210 228 //part->addToSpaceShip(this); //FIXME: (noep) add 211 229 this->updatePartAssignment(); … … 242 260 } 243 261 262 void ModularSpaceShip::removeShipPart(ShipPart* part) 263 { 264 // Remove the part from the partList_ 265 std::vector<ShipPart*>::iterator it = this->partList_.begin(); 266 for(unsigned int i = 0; i < this->partList_.size(); i++) 267 { 268 if(this->partList_[i] == part) 269 this->partList_.erase(it); 270 it++; 271 } 272 // Remove the part-entity assignment and detach the Entity of this ShipPart 273 for (std::map<StaticEntity*, ShipPart*>::iterator itt = this->partMap_.begin(); itt != this->partMap_.end(); ++itt) 274 { 275 if (itt->second == part) 276 { 277 this->detach(itt->first); 278 this->partMap_.erase(itt); 279 } 280 } 281 } 282 244 283 } -
code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h
r10019 r10023 48 48 /** 49 49 @brief 50 The ModularSpaceShip is the principal entity through which the player interacts with the game. Its main function is to fly, however many things, such as @ref orxonox::Engine Engines or @ref orxonox::Weapon Weapons, can be attached to it. 50 The SpaceShip is the principal entity through which the player interacts with the game. Its main function is to fly, however many things, such as @ref orxonox::Engine Engines or @ref orxonox::Weapon Weapons, can be attached to it. 51 The ModularSpaceShip is an extension of a @ref orxonox::SpaceShip SpaceShip, which uses @ref orxonox::ShipPart ShipParts to allow entities attached to it to be destroyed individually. 51 52 52 53 There are several parameters that define the behavior of the ModularSpaceShip> … … 56 57 - The <b>lift</b> creates a more natural flight feeling through the addition of a lift force. There are again tow parameters that can be specified. The <b>lift</b> which is the lift force that is applied. And the <b>stallSpeed</b> which is the forward speed after which no more lift is generated. 57 58 58 As mentioned @ref orxonox::Engine Engines can be mounted on the ModularSpaceShip. Here is a (primitive) example of a ModularSpaceShip defined in XML: 59 As mentioned @ref orxonox::Engine Engines can be mounted on the ModularSpaceShip. 60 In order to assign attached entities to a ShipPart, a ShipPart with the same name as the corresponding entity needs to be created in the <parts> tag. 61 Here is a (primitive) example of a ModularSpaceShip defined in XML: 59 62 @code 60 63 <ModularSpaceShip … … 77 80 angularDamping = 0.9999999 78 81 > 82 <attached> 83 <StaticEntity name="wing" . . . /> 84 <StaticEntity name="tail" . . . /> 85 </attached> 86 <parts> 87 <ShipPart name="wing" . . . /> 88 <ShipPart name="tail" . . . /> 89 </parts> 79 90 <engines> 80 91 <Engine /> … … 85 96 86 97 @author 87 Fabian 'x3n' Landau 98 Fabian 'x3n' Landau, Noe Pedrazzini 88 99 */ 89 100 class _OrxonoxExport ModularSpaceShip : public SpaceShip … … 105 116 ShipPart* getShipPart(unsigned int index); 106 117 bool hasShipPart(ShipPart* part) const; 118 void removeShipPart(ShipPart* part); 107 119 108 120 virtual void updatePartAssignment(); -
code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.cc
r10011 r10023 252 252 void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) 253 253 { 254 orxout() << "damage(): Collision detected on " << this->getName() << ", btCS*: " << cs << endl; 255 256 int collisionShapeIndex = this->isMyCollisionShape(cs); 257 orxout() << collisionShapeIndex << endl; 254 //FIXME: (noep) remove debug 255 //orxout() << "damage(): Collision detected on " << this->getName() << ", btCS*: " << cs << endl; 256 257 //int collisionShapeIndex = this->isMyCollisionShape(cs); 258 //orxout() << collisionShapeIndex << endl; 258 259 259 260 // Applies multiplier given by the DamageBoost Pickup. … … 587 588 // List all attached Objects 588 589 orxout() << " " << this->getName() << " has the following Objects attached:" << endl; 589 for (int i=0; i< 10; i++)590 for (int i=0; i<50; i++) 590 591 { 591 592 if (this->getAttachedObject(i)==NULL) -
code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.h
r10019 r10023 229 229 unsigned int numexplosionchunks_; 230 230 231 virtual int isMyCollisionShape(const btCollisionShape* cs); 231 virtual int isMyCollisionShape(const btCollisionShape* cs); // FIXME: (noep) remove debug 232 232 void printBtChildShapes(btCompoundShape* cs, int indent, int subshape); // FIXME: (noep) remove debug 233 233 void printSpaces(int num); // FIXME: (noep) remove debug
Note: See TracChangeset
for help on using the changeset viewer.