Changeset 10669 in orxonox.OLD for branches/vs-enhencements/src/world_entities/space_ships/space_ship.cc
- Timestamp:
- Jun 3, 2007, 10:17:15 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/vs-enhencements/src/world_entities/space_ships/space_ship.cc
r10667 r10669 158 158 this->secWeaponMan.setParentEntity( this); 159 159 160 this-> setWMSlotCount(1,8);161 this->se tWMSlotCount(2,6);162 163 this-> createWeaponSlot(1, 0, Vector(3.006, 1.028, .155), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);164 this-> createWeaponSlot(1, 1, Vector(3.006, 1.028, -.155), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);165 this-> createWeaponSlot(1, 2, Vector(4.03, .063, .876), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);166 this-> createWeaponSlot(1, 3, Vector(4.03, -.063, -.876), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);167 this-> createWeaponSlot(1, 4, Vector(1.431, -.612, 2.691), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);168 this-> createWeaponSlot(1, 5, Vector(1.431, -.612, -2.691), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);169 this-> createWeaponSlot(1, 6, Vector(1.431, -.612, 3.254), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);170 this-> createWeaponSlot(1, 7, Vector(1.431, -.612, -3.254), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);171 172 173 this-> addWeaponToSlot(1,0, 0, "RFCannon");174 this-> addWeaponToSlot(1,0, 1, "RFCannon");175 this-> addWeaponToSlot(1,0, 2, "RFCannon");176 this-> addWeaponToSlot(1,0, 3, "RFCannon");177 this-> addWeaponToSlot(1,1, 0, "RFCannon");178 this-> addWeaponToSlot(1,1, 1, "RFCannon");179 this-> addWeaponToSlot(1,1, 2, "RFCannon");180 this-> addWeaponToSlot(1,1, 3, "RFCannon");181 182 this-> addWeaponToSlot(1,0, 4, "NadionLaser");183 this-> addWeaponToSlot(1,0, 5, "NadionLaser");184 this-> addWeaponToSlot(1,2, 4, "NadionLaser");185 this-> addWeaponToSlot(1,2, 5, "NadionLaser");186 187 this-> addWeaponToSlot(1,0, 6, "Disruptor");188 this-> addWeaponToSlot(1,0, 7, "Disruptor");189 this-> addWeaponToSlot(1,3, 6, "Disruptor");190 this-> addWeaponToSlot(1,3, 7, "Disruptor");191 192 193 this-> createWeaponSlot(2, 0, Vector(1.5, 3, 0), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);194 this-> createWeaponSlot(2, 1, Vector(2.6, 0, 3.0), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);195 this-> createWeaponSlot(2, 2, Vector(1.5, 0, -.5), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);196 this-> createWeaponSlot(2, 3, Vector(1.5, 0, .5), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);197 this-> createWeaponSlot(2, 4, Vector(1.5, 0, .5), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);198 this-> createWeaponSlot(2, 5, Vector(1.5, 0, -.5), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);199 200 this-> addWeaponToSlot(2,0, 2, "SwarmLauncher");160 this->weaponMan.setSlotCount(8); 161 this->secWeaponMan.setSlotCount(6); 162 163 this->weaponMan.createWeaponSlot(0, 3.006, 1.028, .155, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 164 this->weaponMan.createWeaponSlot(1, 3.006, 1.028, -.155, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 165 this->weaponMan.createWeaponSlot(2, 4.03, .063, .876, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 166 this->weaponMan.createWeaponSlot(3, 4.03, -.063, -.876, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 167 this->weaponMan.createWeaponSlot(4, 1.431, -.612, 2.691, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 168 this->weaponMan.createWeaponSlot(5, 1.431, -.612, -2.691, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 169 this->weaponMan.createWeaponSlot(6, 1.431, -.612, 3.254, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 170 this->weaponMan.createWeaponSlot(7, 1.431, -.612, -3.254, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 171 172 173 this->weaponMan.addWeaponToSlot(0, 0, "RFCannon"); 174 this->weaponMan.addWeaponToSlot(0, 1, "RFCannon"); 175 this->weaponMan.addWeaponToSlot(0, 2, "RFCannon"); 176 this->weaponMan.addWeaponToSlot(0, 3, "RFCannon"); 177 this->weaponMan.addWeaponToSlot(1, 0, "RFCannon"); 178 this->weaponMan.addWeaponToSlot(1, 1, "RFCannon"); 179 this->weaponMan.addWeaponToSlot(1, 2, "RFCannon"); 180 this->weaponMan.addWeaponToSlot(1, 3, "RFCannon"); 181 182 this->weaponMan.addWeaponToSlot(0, 4, "NadionLaser"); 183 this->weaponMan.addWeaponToSlot(0, 5, "NadionLaser"); 184 this->weaponMan.addWeaponToSlot(2, 4, "NadionLaser"); 185 this->weaponMan.addWeaponToSlot(2, 5, "NadionLaser"); 186 187 this->weaponMan.addWeaponToSlot(0, 6, "Disruptor"); 188 this->weaponMan.addWeaponToSlot(0, 7, "Disruptor"); 189 this->weaponMan.addWeaponToSlot(3, 6, "Disruptor"); 190 this->weaponMan.addWeaponToSlot(3, 7, "Disruptor"); 191 192 193 this->secWeaponMan.createWeaponSlot(0, 1.5, 3, 0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 194 this->secWeaponMan.createWeaponSlot(1, 2.6, 0, 3.0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 195 this->secWeaponMan.createWeaponSlot(2, 1.5, 0, -.5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 196 this->secWeaponMan.createWeaponSlot(3, 1.5, 0, .5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 197 this->secWeaponMan.createWeaponSlot(4, 1.5, 0, .5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 198 this->secWeaponMan.createWeaponSlot(5, 1.5, 0, -.5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 199 200 this->secWeaponMan.addWeaponToSlot(0, 2, "SwarmLauncher"); 201 201 202 202 … … 231 231 this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); 232 232 233 // widget handling 234 /* 235 this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 236 this->electronicWidget->setDisplayedName(std::string(this->getClassName()) + " Electronics:"); 237 this->electronicWidget->setSize2D(30,400); 238 this->electronicWidget->setAbsCoor2D(150,200); 239 this->electronicWidget->shiftDir2D(270); 240 this->updateElectronicWidget(); 241 this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 242 this->shieldWidget->setDisplayedName(std::string(this->getClassName()) + " Shield:"); 243 this->shieldWidget->setSize2D(30,400); 244 this->shieldWidget->setAbsCoor2D(200,200); 245 this->shieldWidget->shiftDir2D(270); 246 this->updateShieldWidget(); 247 if (this->hasPlayer()) 248 { 249 State::getPlayer()->hud().setShiledWidget(this->shieldWidget); 250 State::getPlayer()->hud().setEnergyWidget(this->electronicWidget); 251 } 252 */ 233 253 234 this->electronicWidget = NULL; 254 235 this->shieldWidget = NULL; … … 308 289 this->setSupportedPlaymodes(Playable::Horizontal | Playable::Vertical); 309 290 310 /// FIXME311 // this->trail = new Trail( 5, 10, .2, this);312 // this->trail->setTexture( "textures/engine.png");313 //314 // this->trailL = new Trail( 5, 10, .2, this);315 // this->trailL->setTexture( "textures/engine.png");316 //317 // this->trailR = new ( 5, 10, .2, this);318 // this->trailR->setTexture( "textures/engine.png");319 320 291 321 292 this->toList(OM_GROUP_00); 322 323 //FIXME Just testaddition to show the wobblegrid324 /*325 this->test = new Wobblegrid(5);326 test->setTexture("textures/blub.png");327 328 test->setAbsCoor( this->getAbsCoor() + Vector(0, 2, 0));329 test->setParent( this);330 */331 332 293 } 333 294 … … 350 311 State::getCamera()->setParent(this); 351 312 352 LoadParam(root, "reactor", this, SpaceShip, setReactor); 353 LoadParam(root, "shield", this, SpaceShip, setShield); 354 LoadParam(root, "armor", this, SpaceShip, setArmor); 355 LoadParam(root, "electronic", this, SpaceShip, setElectronic); 356 LoadParam(root, "engine", this, SpaceShip, setEngine); 357 LoadParam(root, "energyshare", this, SpaceShip, setEnergyShare); 358 LoadParam(root, "weapon", this, SpaceShip, setWeapon); 359 313 LoadParam(root, "setReactor", this, SpaceShip, setReactor) 314 .describe("set reactor output"); 315 LoadParam(root, "setShield", this, SpaceShip, setShield) 316 .describe("set shield parameters: current strenght , max strenght, threshhold value (0..1), regeneration rate"); 317 LoadParam(root, "setArmor", this, SpaceShip, setArmor) 318 .describe("set armor/health parameters: current strenght , max strenght"); 319 LoadParam(root, "setElectronic", this, SpaceShip, setElectronic) 320 .describe("set electronics parameters: current strenght , max strenght, threshhold value (0..1), regeneration rate"); 321 LoadParam(root, "setEngine", this, SpaceShip, setEngine) 322 .describe("set base speed"); 323 LoadParam(root, "setEnergyShare", this, SpaceShip, setEnergyShare) 324 .describe("set energy partitioning: shield, weapons, engine (sum should be 1)"); 325 LoadParam(root, "setWeapon", this, SpaceShip, setWeapon) 326 .describe("set weapon regeneration"); 327 328 /* 329 LOAD_PARAM_START_CYCLE(root, element); 330 { 331 LoadParamXML_CYCLE(element, "weaponMan", this->weaponMan, WeaponManager, loadWeapons) 332 .describe("loads Weapons"); 333 } 334 LOAD_PARAM_END_CYCLE(element); 335 336 LOAD_PARAM_START_CYCLE(root, element); 337 { 338 LoadParamXML_CYCLE(element, "secWeaponMan", this->secWeaponMan, WeaponManager, loadWeapons) 339 .describe("loads Weapons"); 340 } 341 LOAD_PARAM_END_CYCLE(element);*/ 360 342 } 361 343 … … 370 352 bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false; 371 353 372 //xMouse = yMouse = 0; 373 374 this->setHealth(80); 354 355 // this->armorCur = this->armorMax; 356 this->setHealth(this->getHealthMax()); 357 this->shieldCur = this->shieldMax; 358 this->shieldActive = true; 359 this->electronicCur = this->electronicMax; 360 // this->updateHealth(); 375 361 this->velocity = Vector(0.0, 0.0, 0.0); 376 362 } … … 383 369 State::getPlayer()->hud().setRadarCenterNode(this->travelNode); 384 370 State::getPlayer()->hud().setOverlayActive(true); 385 //dynamic_cast <OrxGui::GLGuiEnergyWidgetVertical*> (State::getPlayer()->hud().getArmorWidget())->setDisplayedName("Armor");386 //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);387 //this->attachCamera();388 // this->setPlaymode(Playable::Horizontal);389 371 } 390 372 … … 396 378 State::getCamera()->setEventHandling(true); 397 379 State::getPlayer()->hud().setRadarCenterNode(NULL); 398 //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);399 //this->detachCamera();400 380 } 401 381 … … 408 388 if(this->hasPlayer()) 409 389 Playable::postSpawn(); 410 411 //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));412 390 } 413 391 … … 695 673 pDamage += this->shieldCur; 696 674 if( !this->shieldActive) { 697 this-> armorCur -= pDamage / 2; // remaining damages hits armor at half rate675 this->decreaseHealth( pDamage / 2); // remaining damages hits armor at half rate 698 676 this->electronicCur -= eDamage; 699 677 } … … 701 679 } 702 680 else { 703 this-> armorCur = this->armorCur - pDamage;681 this->decreaseHealth(pDamage); 704 682 this->electronicCur = this->electronicCur - eDamage; 705 683 } 706 if( this-> armorCur<= 0) { /* FIXME implement shipcrash*/ }684 if( this->getHealth() <= 0) { /* FIXME implement shipcrash*/ } 707 685 this->destroy(this); 708 686 … … 710 688 updateShieldWidget(); 711 689 712 this->setHealth( this->armorCur);690 // this->setHealth( this->armorCur); 713 691 } 714 692 715 693 716 694 void SpaceShip::regen(float time){ 717 float tmp;718 if ( this->armorCur != this->armorMax || this->armorRegen != 0){719 tmp = this->armorCur + this->armorRegen * time;720 if ( tmp > electronicMax)721 this->armorCur = this->armorMax;695 static float tmp, armorCur, armorMax; 696 if (armorCur != armorMax || this->armorRegen != 0){ 697 tmp = armorCur + armorRegen * time; 698 if ( tmp > armorMax) 699 armorCur = armorMax; 722 700 else 723 this->armorCur = tmp;701 armorCur = tmp; 724 702 } 725 703 if (this->shieldCur != this->shieldMax || this->shieldRegen != 0){ … … 1205 1183 }; 1206 1184 1207 void SpaceShip::addWeaponToSlot(int wm, int config, int slot, const std::string& weaponName){1208 if (wm == 1) { this->weaponMan.addWeapon( Weapon::createWeapon( weaponName ), config, slot); }1209 if (wm == 1) { this->weaponMan.addWeapon( Weapon::createWeapon( weaponName ), config, slot); }1210 else return;1211 }1212 1185 // void SpaceShip::addWeaponToSlot(int wm, int config, int slot, const std::string& weaponName){ 1186 // if (wm == 1) { this->weaponMan.addWeapon( Weapon::createWeapon( weaponName ), config, slot); } 1187 // if (wm == 1) { this->weaponMan.addWeapon( Weapon::createWeapon( weaponName ), config, slot); } 1188 // else return; 1189 // } 1190
Note: See TracChangeset
for help on using the changeset viewer.