Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/vs-enhencements/src/world_entities/space_ships/space_ship.cc @ 10660

Last change on this file since 10660 was 10660, checked in by nicolasc, 17 years ago

night bunp

File size: 37.5 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Benjamin Knecht
13   co-programmer: Silvan Nellen
14
15*/
16
17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
18
19#include "executor/executor.h"
20#include "space_ship.h"
21
22#include "util/loading/resource_manager.h"
23
24#include "weapons/test_gun.h"
25#include "weapons/light_blaster.h"
26#include "weapons/medium_blaster.h"
27#include "weapons/heavy_blaster.h"
28#include "weapons/rf_cannon.h"
29#include "weapons/nadion_laser.h"
30#include "weapons/disruptor.h"
31#include "weapons/swarm_launcher.h"
32#include "weapons/spike_thrower.h"
33#include "weapons/acid_launcher.h"
34#include "weapons/boomerang_gun.h"
35#include "weapons/turret.h"
36#include "weapons/cannon.h"
37
38#include "elements/glgui_energywidgetvertical.h"
39#include "glgui_bar.h"
40
41#include "particles/dot_emitter.h"
42#include "particles/emitter_node.h"
43#include "particles/sprite_particles.h"
44#include "effects/trail.h"
45
46#include "effects/wobblegrid.h"
47
48#include "util/loading/factory.h"
49#include "key_mapper.h"
50
51#include "network_game_manager.h"
52#include "shared_network_data.h"
53
54#include "items/power_ups/weapon_power_up.h"
55#include "items/power_ups/param_power_up.h"
56
57#include "graphics_engine.h"
58
59#include "plane.h"
60
61#include "state.h"
62#include "player.h"
63#include "tools/camera.h"
64#include "tools/cameraman.h"
65
66
67#include "util/loading/load_param.h"
68#include "time.h"
69
70#include "track/track.h"
71
72
73// #include "lib/gui/gl_gui/glgui_bar.h"
74// #include "lib/gui/gl_gui/glgui_pushbutton.h"
75
76
77
78ObjectListDefinition(SpaceShip);
79CREATE_FACTORY(SpaceShip);
80
81#include "script_class.h"
82CREATE_SCRIPTABLE_CLASS(SpaceShip,
83                        addMethod("hasPlayer", Executor0ret<Playable, lua_State*,bool>(&Playable::hasPlayer))
84                        ->addMethod("fire", Executor1<Playable, lua_State*, bool>(&Playable::fire))
85                        ->addMethod("loadModel", Executor2<WorldEntity, lua_State*,const std::string& ,float>(&WorldEntity::loadModel2))
86                        ->addMethod("setName", Executor1<BaseObject, lua_State*,const std::string&>(&BaseObject::setName))
87                        ->addMethod("hide", Executor0<WorldEntity, lua_State*>(&WorldEntity::hide))
88                        ->addMethod("unhide", Executor0<WorldEntity, lua_State*>(&WorldEntity::unhide))
89                        //Coordinates
90                        ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor))
91                        ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX))
92                        ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
93                        ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
94                        //->addMethod("setCameraSpeed", Executor1<SpaceShip, lua_State*, float>(&SpaceShip::setCameraSpeed))
95                        ->addMethod("pause", Executor1<WorldEntity, lua_State*, bool>(&WorldEntity::pauseTrack))
96                        ->addMethod("setCameraDist", Executor1<SpaceShip, lua_State*, float>(&SpaceShip::setCameraDistance))
97                       );
98
99/**
100 *  destructs the spaceship, deletes alocated memory
101 */
102SpaceShip::~SpaceShip ()
103{
104  this->setPlayer(NULL);
105}
106
107/**
108 * loads a Spaceships information from a specified file.
109 * @param fileName the name of the File to load the spaceship from (absolute path)
110 */
111SpaceShip::SpaceShip(const std::string& fileName)
112    : secWeaponMan(this) //,
113    //supportedPlaymodes(Playable::Vertical) ,
114    //playmode(Playable::Vertical)
115{
116  this->init();
117  TiXmlDocument doc(fileName);
118
119  if(!doc.LoadFile())
120  {
121    PRINTF(2)("Loading file %s failed for spaceship.\n", fileName.c_str());
122    return;
123  }
124
125  this->loadParams(doc.RootElement());
126}
127
128/**
129 *  creates a new Spaceship from Xml Data
130 * @param root the xml element containing spaceship data
131
132   @todo add more parameters to load
133*/
134SpaceShip::SpaceShip(const TiXmlElement* root)
135    : secWeaponMan(this) //,
136    //supportedPlaymodes(Playable::Vertical) ,
137    //playmode(Playable::Vertical)
138{
139  this->init();
140  //this->setParentMode(PNODE_REPARENT_DELETE_CHILDREN);
141  if (root != NULL)
142    this->loadParams(root);
143
144}
145
146
147/**
148 * initializes a Spaceship
149 */
150void SpaceShip::init()
151{
152
153  srand(time(0));   //initialize Random Nomber Generator
154
155  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
156  this->registerObject(this, SpaceShip::_objectList);
157  PRINTF(4)("SPACESHIP INIT\n");
158  this->weaponMan.setParentEntity( this);
159  //weapons:
160
161  Weapon* wpRight0 = new RFCannon ();
162  wpRight0->setName( "RFCannon");
163  Weapon* wpLeft0 = new RFCannon ();
164  wpLeft0->setName( "RFCannon");
165
166  Weapon* wpRight1 = new RFCannon ();
167  wpRight1->setName( "RFCannon");
168  Weapon* wpLeft1 = new RFCannon ();
169  wpLeft1->setName( "RFCannon");
170/*
171  Weapon* wpRight2 = new MediumBlaster ();
172  wpRight2->setName( "MediumBlaster");
173  Weapon* wpLeft2 = new MediumBlaster ();
174  wpLeft2->setName( "MediumBlaster");*/
175
176  Weapon* wpRight2 = new NadionLaser ();
177  wpRight2->setName( "NadionLaser");
178  Weapon* wpLeft2 = new NadionLaser ();
179  wpLeft2->setName( "NadionLaser");
180/*
181  Weapon* wpRight3 = new HeavyBlaster (1);
182  wpRight3->setName( "HeavyBlaster");
183  Weapon* wpLeft3 = new HeavyBlaster (0);
184  wpLeft3->setName( "HeavyBlaster");*/
185
186  Weapon* wpRight3 = new Disruptor ();
187  wpRight3->setName( "Disruptor");
188  Weapon* wpLeft3 = new Disruptor ();
189  wpLeft3->setName( "Disruptor");
190
191/*
192  Weapon* wpRight3 = Weapon::createWeapon( "Disruptor" );
193  wpRight3->setName( "Disruptor");
194  Weapon* wpLeft3 = Weapon::createWeapon( "Disruptor" );
195  wpLeft3->setName( "Disruptor");*/
196
197  Weapon* cannon = new SwarmLauncher();
198  cannon->setName( "SwarmLauncher");
199
200
201  this->weaponMan.addWeapon( wpLeft0, 0, 0);
202  this->weaponMan.addWeapon( wpRight0, 0, 1);
203
204  this->weaponMan.addWeapon( wpLeft1, 0, 2);
205  this->weaponMan.addWeapon( wpRight1, 0, 3);
206
207  this->weaponMan.addWeapon( wpLeft2, 1, 4);
208  this->weaponMan.addWeapon( wpRight2, 1, 5);
209
210  this->weaponMan.addWeapon( wpLeft3, 2, 6);
211  this->weaponMan.addWeapon( wpRight3, 2, 7);
212
213  this->weaponMan.addWeapon( wpLeft0, 3, 0);
214  this->weaponMan.addWeapon( wpRight0, 3, 1);
215
216  this->weaponMan.addWeapon( wpLeft1, 3, 2);
217  this->weaponMan.addWeapon( wpRight1, 3, 3);
218
219  this->weaponMan.addWeapon( wpLeft2, 3, 4);
220  this->weaponMan.addWeapon( wpRight2, 3, 5);
221
222  this->weaponMan.addWeapon( wpLeft3, 3, 6);
223  this->weaponMan.addWeapon( wpRight3, 3, 7);
224
225
226  this->secWeaponMan.addWeapon( cannon, 0, 2);
227
228  this->weaponMan.changeWeaponConfig(3);
229  this->secWeaponMan.changeWeaponConfig(0);
230
231
232  Playable::weaponConfigChanged();
233
234//   reactorOutput     = 10;
235  setReactor(10);
236//   weaponEnergyRegen = 10;       // 10 einheiten pro Sekunde
237  setWeapon(10);
238//   engineSpeedBase   = 15;
239  setEngine(15);
240//   shieldRegen       = 2;
241/*
242  shieldEnergyShare = 0.3;
243  weaponEnergyShare = 0.3;
244  engineEnergyShare = 0.4;*/
245  setEnergyShare(.3,.3,.4);
246/*
247  shieldCur         = 100;
248  shieldMax         = 100;
249  shieldTH          = .2 * shieldMax;   // shield power must be 20% before shield kicks in again*/
250  setShield(100, 100, .2, 2);
251/*
252  this->setHealth( 100);
253  this->setHealthMax( 100);*/
254  setArmor(100, 100);
255/*
256  electronicCur = 50;
257  electronicMax = 50;
258  electronicRegen   = 3;
259  electronicTH      = .7 * electronicMax; // 30% of eDamage can be handled by the ship*/
260  setElectronic(50, 50, .7, 3.0);
261
262//   this->loadModel("models/spaceships/fighter_redesign9.obj");
263  //this->setVisibiliy(false);
264
265  bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false;
266
267//   this->setHealthMax(shieldMax);
268//   this->setHealth(shieldCur);
269
270  this->travelNode = new PNode();
271
272  // camera - issue
273  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
274  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
275
276  // widget handling
277  /*
278  this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
279  this->electronicWidget->setDisplayedName(std::string(this->getClassName()) + " Electronics:");
280  this->electronicWidget->setSize2D(30,400);
281  this->electronicWidget->setAbsCoor2D(150,200);
282  this->electronicWidget->shiftDir2D(270);
283  this->updateElectronicWidget();
284  this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
285  this->shieldWidget->setDisplayedName(std::string(this->getClassName()) + " Shield:");
286  this->shieldWidget->setSize2D(30,400);
287  this->shieldWidget->setAbsCoor2D(200,200);
288  this->shieldWidget->shiftDir2D(270);
289  this->updateShieldWidget();
290  if (this->hasPlayer())
291  {
292    State::getPlayer()->hud().setShiledWidget(this->shieldWidget);
293    State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
294  }
295  */
296  this->electronicWidget = NULL;
297  this->shieldWidget = NULL;
298
299  //add events to the eventlist
300  registerEvent(KeyMapper::PEV_FORWARD);
301  registerEvent(KeyMapper::PEV_BACKWARD);
302  registerEvent(KeyMapper::PEV_LEFT);
303  registerEvent(KeyMapper::PEV_RIGHT);
304  //registerEvent(SDLK_q);
305  //registerEvent(SDLK_e);
306  registerEvent(KeyMapper::PEV_FIRE1);
307  registerEvent(KeyMapper::PEV_FIRE2);                  // Added for secondary weapon support
308  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
309  registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON);
310  //registerEvent(SDLK_PAGEUP);
311  //registerEvent(SDLK_PAGEDOWN);
312  registerEvent(EV_MOUSE_MOTION);
313
314  this->weaponMan.setParentEntity( this);
315  this->secWeaponMan.setParentEntity( this);
316
317  this->weaponMan.setSlotCount(8);
318/*
319  this->weaponMan.setSlotPosition(0, Vector(3.006, 1.028, .155));
320  this->weaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
321
322  this->weaponMan.setSlotPosition(1, Vector(3.006, 1.028, -.155));
323  this->weaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
324
325  this->weaponMan.setSlotPosition(2, Vector(4.03, .063, .876));
326  this->weaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
327
328  this->weaponMan.setSlotPosition(3, Vector(4.03, -.063, -.876));
329  this->weaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
330
331  this->weaponMan.setSlotPosition(4, Vector(1.431, -.612, 2.691));
332  this->weaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
333
334  this->weaponMan.setSlotPosition(5, Vector(1.431, -.612, -2.691));
335  this->weaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
336
337  this->weaponMan.setSlotPosition(6, Vector(1.431, -.612, 3.254));
338  this->weaponMan.setSlotDirection(6, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
339
340  this->weaponMan.setSlotPosition(7, Vector(1.431, -.612, -3.254));
341  this->weaponMan.setSlotDirection(7, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));*/
342
343  this->createPriWMSlot(0, Vector(3.006, 1.028, .155), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
344  this->createPriWMSlot(1, Vector(3.006, 1.028, -.155), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
345  this->createPriWMSlot(2, Vector(4.03, .063, .876), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
346  this->createPriWMSlot(3, Vector(4.03, -.063, -.876), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
347  this->createPriWMSlot(4, Vector(1.431, -.612, 2.691), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
348  this->createPriWMSlot(5, Vector(1.431, -.612, -2.691), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
349  this->createPriWMSlot(6, Vector(1.431, -.612, 3.254), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
350  this->createPriWMSlot(7, Vector(1.431, -.612, -3.254), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
351
352  this->secWeaponMan.setSlotCount(6);
353/*
354  this->secWeaponMan.setSlotPosition(0, Vector(1.5, 3, 0));
355  this->secWeaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
356
357  this->secWeaponMan.setSlotPosition(1, Vector(2.6, 0, 3.0));
358  this->secWeaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
359
360  this->secWeaponMan.setSlotPosition(2, Vector(1.5, 0, -.5));
361  this->secWeaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
362
363  this->secWeaponMan.setSlotPosition(3, Vector(1.5, 0, .5));
364  this->secWeaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
365
366  this->secWeaponMan.setSlotPosition(4, Vector(1.5, 0, .5));
367  this->secWeaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
368
369  this->secWeaponMan.setSlotPosition(5, Vector(1.5, 0, -.5));
370  this->secWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));*/
371
372  this->createSecWMSlot(0, Vector(1.5, 3, 0), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
373  this->createSecWMSlot(1, Vector(2.6, 0, 3.0), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
374  this->createSecWMSlot(2, Vector(1.5, 0, -.5), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
375  this->createSecWMSlot(3, Vector(1.5, 0, .5), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
376  this->createSecWMSlot(4, Vector(1.5, 0, .5), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
377  this->createSecWMSlot(5, Vector(1.5, 0, -.5), WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
378
379
380  this->weaponMan.getFixedTarget()->setParent(this);
381  this->weaponMan.getFixedTarget()->setRelCoor(100000,0,0);
382
383
384  this->secWeaponMan.getFixedTarget()->setParent(this);
385  this->secWeaponMan.getFixedTarget()->setRelCoor(100000,0,0);
386  this->secWeaponMan.setRotationSpeed(0);
387
388  dynamic_cast<Element2D*>(this->weaponMan.getFixedTarget())->setVisibility( false);
389
390
391  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
392  registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) );
393  registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft", PERMISSION_OWNER ) );
394  registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight", PERMISSION_OWNER ) );
395  registerVar( new SynchronizeableFloat( &cameraLook, &cameraLook, "cameraLook", PERMISSION_OWNER ) );
396  registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) );
397  registerVar( new SynchronizeableBool( &bFire, &bFire, "bSecFire", PERMISSION_OWNER));
398  registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity", PERMISSION_MASTER_SERVER ) );
399
400  //this->airFriction = 0.5f;
401  //this->travelDistancePlus = Vector2D(38.0, 43.0);
402  //this->travelDistanceMinus = Vector2D(-38.0, -43.0);
403  this->travelDistancePlus = Vector2D(50,50);
404  this->travelDistanceMinus = Vector2D(-50,-50);
405  this->isTravelDistanceInit = true;
406  this->actionWidthPercentage = 1;
407
408  this->cameraSpeed = 40;
409  this->cameraLook = 0.0f;
410  //this->airFriction = 0.0f;
411
412  srand(time(0));  //initaialize RNG
413
414  this->travelNode->debugDraw();
415
416  this->setSupportedPlaymodes(Playable::Horizontal | Playable::Vertical);
417
418  /// FIXME
419//   this->trail = new Trail( 5, 10, .2, this);
420//   this->trail->setTexture( "textures/engine.png");
421//
422//   this->trailL = new Trail( 5, 10, .2, this);
423//   this->trailL->setTexture( "textures/engine.png");
424//
425//   this->trailR = new ( 5, 10, .2, this);
426//   this->trailR->setTexture( "textures/engine.png");
427
428
429  this->toList(OM_GROUP_00);
430
431  //FIXME Just testaddition to show the wobblegrid
432/*
433  this->test  = new Wobblegrid(5);
434  test->setTexture("textures/blub.png");
435
436  test->setAbsCoor( this->getAbsCoor() + Vector(0, 2, 0));
437  test->setParent( this);
438*/
439
440}
441
442
443/**
444 * loads the Settings of a SpaceShip from an XML-element.
445 * @param root the XML-element to load the Spaceship's properties from
446 */
447void SpaceShip::loadParams(const TiXmlElement* root)
448{
449  Playable::loadParams(root);
450
451  LoadParam(root, "playmode", this, SpaceShip, setPlaymodeXML);
452  LoadParam(root, "cameraDistance", this, SpaceShip, setCameraDistance);
453  LoadParam(root, "cameraFovy", this, SpaceShip, setCameraFovy);
454  LoadParam(root, "actionWidthPercentage", this, SpaceShip, setActionWidthPercentage);
455
456  State::getCamera()->setViewMode(Camera::ViewTop);
457
458  LoadParam(root, "reactor", this, SpaceShip, setReactor);
459  LoadParam(root, "shield", this, SpaceShip, setShield);
460  LoadParam(root, "armor", this, SpaceShip, setArmor);
461  LoadParam(root, "electronic", this, SpaceShip, setElectronic);
462  LoadParam(root, "engine", this, SpaceShip, setEngine);
463  LoadParam(root, "energyshare", this, SpaceShip, setEnergyShare);
464  LoadParam(root, "weapon", this, SpaceShip, setWeapon);
465
466}
467
468
469void SpaceShip::setPlayDirection(const Quaternion& rot, float speed)
470{
471  //this->direction = Quaternion (rot.getHeading(), Vector(0,1,0));
472}
473
474void SpaceShip::reset()
475{
476  bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false;
477
478  //xMouse = yMouse = 0;
479
480  this->setHealth(80);
481  this->velocity = Vector(0.0, 0.0, 0.0);
482}
483
484
485void SpaceShip::enter()
486{
487  this->secWeaponMan.showCrosshair();
488  this->toList( OM_GROUP_01 );
489  State::getPlayer()->hud().setRadarCenterNode(this->travelNode);
490  State::getPlayer()->hud().setOverlayActive(true);
491  //dynamic_cast <OrxGui::GLGuiEnergyWidgetVertical*> (State::getPlayer()->hud().getArmorWidget())->setDisplayedName("Armor");
492  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
493  //this->attachCamera();
494 // this->setPlaymode(Playable::Horizontal);
495}
496
497void SpaceShip::leave()
498{
499  this->secWeaponMan.hideCrosshair();
500  this->toList( OM_GROUP_00);
501  State::getPlayer()->hud().setOverlayActive(false);
502  State::getCamera()->setEventHandling(true);
503  State::getPlayer()->hud().setRadarCenterNode(NULL);
504  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);
505  //this->detachCamera();
506}
507
508
509/**
510 *  effect that occurs after the SpaceShip is spawned
511*/
512void SpaceShip::postSpawn ()
513{
514  if(this->hasPlayer())
515    Playable::postSpawn();
516
517  //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
518}
519
520/**
521 *  the action occuring if the spaceship left the game
522*/
523void SpaceShip::leftWorld ()
524{
525
526}
527
528WorldEntity* ref = NULL;
529
530/**
531 *  draws the spaceship after transforming it.
532*/
533void SpaceShip::draw () const
534{
535  if( this->entityTrack != NULL && this->isDrawTrack())
536    this->entityTrack->drawGraph();
537
538  WorldEntity::draw();
539
540//   glMatrixMode(GL_MODELVIEW);
541//   glPushMatrix();
542
543//   float matrix[4][4];
544//   glTranslatef (this->getAbsCoor ().x-1, this->getAbsCoor ().y-.2, this->getAbsCoor ().z);
545//   this->getAbsDir().matrix (matrix);
546//   glMultMatrixf((float*)matrix);
547  //glScalef(2.0, 2.0, 2.0);  // no double rescale
548
549
550//   this->trail->draw();
551
552//   glTranslatef(0,0,-.5);
553//   this->trailL->draw();
554
555//   glTranslatef(0,0,1);
556//   this->trailR->draw();
557
558//   glPopMatrix();
559  //this->debug(0);
560}
561
562/**
563 *  the function called for each passing timeSnap
564 * @param time The timespan passed since last update
565*/
566void SpaceShip::tick (float time)
567{
568  // Playable::tick(time);
569
570 // this->test->tick(time);
571
572  // Own Tick Setup, as a different fire routine is used on the weapon manager
573  this->weaponMan.tick(time);
574  this->secWeaponMan.tick(time);
575
576  if( this->systemFailure() )
577    bFire = bSecFire = false;
578
579  // fire reqeust/release for primary weapons
580  if( this->bFire)
581    this->weaponMan.fire();
582  else
583    this->weaponMan.releaseFire();
584
585  // fire reqeust/release for secondary weapons
586  if( this->bSecFire)
587    this->secWeaponMan.fire();
588  else
589    this->secWeaponMan.releaseFire();
590
591  // Tracktick
592  if(this->entityTrack)
593    this->entityTrack->tick(time);
594
595
596  // Shield Regeneration and other regular calculations on the ship
597  this->regen(time);
598
599  // Weapon Regeneration and other regular calculations on the ship
600  this->weaponRegen(time);
601
602  // current engine speed output
603  this->engineSpeedCur = this->engineSpeedBase + this->reactorOutput * this->engineEnergyShare;
604
605  // calculation of maxSpeed and acceleration:
606  this->travelSpeed = this->engineSpeedCur * 5;
607  this->acceleration = this->travelSpeed * 2;
608
609  this->movement(time);
610
611   // TRYING TO FIX PNode.
612  this->cameraNode.setAbsCoorSoft(this->getAbsCoor() + Vector(0.0f, 5.0f, 0.0f), 30.0f);
613  this->cameraNode.setRelDirSoft(this->getAbsDir(), 30.0f);
614
615
616  this->velocity  = (this->getAbsCoor() - this->oldPos) / time;
617  this->oldPos    = this->getAbsCoor();
618
619//FIXME
620//   this->trail->tick(time);
621//   this->trailL->tick(time);
622//   this->trailR->tick(time);
623
624  if (!this->isTravelDistanceInit)
625  {
626    this->updateTravelDistance();
627    //this->isTravelDistanceInit = true;
628  }
629
630  //orient the spaceship in direction of the mouse
631  /*
632  rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, 0.5);//fabsf(time)*shipInertia);
633  if (this->getAbsDir().distance(rotQuat) > 0.00000000000001)
634    this->setAbsDir( rotQuat);
635  //this->setAbsDirSoft(mouseDir,5);
636  */
637  /*
638  this->shiftCoor(move);
639  */
640
641  //   PRINTF(0)("id of %s is: %i\n", this->getName(), this->getOMListNumber());
642
643}
644
645/**
646 * @todo switch statement ??
647 */
648void SpaceShip::process(const Event &event)
649{
650  //Playable::process(event);
651
652  if( event.type == KeyMapper::PEV_LEFT)
653    this->bLeft = event.bPressed;
654  else if( event.type == KeyMapper::PEV_RIGHT)
655  {
656    this->bRight = event.bPressed;
657//     printf("ShipCoors: %f , %f, %f \n", this->getAbsCoor().x, this->getAbsCoor().y, this->getAbsCoor().z);
658  }
659  else if( event.type == KeyMapper::PEV_FORWARD)
660  {
661    this->bForward = event.bPressed; //this->shiftCoor(0,.1,0);
662
663  }
664  else if( event.type == KeyMapper::PEV_BACKWARD)
665    this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0);
666  else if( event.type == KeyMapper::PEV_FIRE2)
667    this->bSecFire = event.bPressed;
668  else if( event.type == KeyMapper::PEV_FIRE1)
669    this->bFire = event.bPressed;
670  else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)
671  {
672    this->nextWeaponConfig();
673  }
674  else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)
675    this->previousWeaponConfig();
676
677  if (!(State::getCamera()->getEventHandling()))
678  {
679    if( event.type == KeyMapper::PEV_VIEW0)
680    {
681      State::getCamera()->setViewMode(Camera::ViewNormal);
682      State::getCameraTargetNode()->setParent(this);
683      State::getCamera()->setParent(this);
684    }
685    else if( event.type == KeyMapper::PEV_VIEW1)
686    {
687      State::getCamera()->setViewMode(Camera::ViewBehind);
688      State::getCameraTargetNode()->setParent(this);
689      State::getCamera()->setParent(this);
690    }
691    else if( event.type == KeyMapper::PEV_VIEW2)
692    {
693      State::getCamera()->setViewMode(Camera::ViewFront);
694      State::getCameraTargetNode()->setParent(this);
695      State::getCamera()->setParent(this);
696    }
697    else if( event.type == KeyMapper::PEV_VIEW3)
698    {
699      State::getCamera()->setViewMode(Camera::ViewLeft);
700      State::getCameraTargetNode()->setParent(this);
701      State::getCamera()->setParent(this);
702    }
703    else if( event.type == KeyMapper::PEV_VIEW4)
704    {
705      State::getCamera()->setViewMode(Camera::ViewRight);
706      State::getCameraTargetNode()->setParent(this);
707      State::getCamera()->setParent(this);
708    }
709    else if( event.type == KeyMapper::PEV_VIEW5)
710    {
711      State::getCamera()->setViewMode(Camera::ViewTop);
712      State::getCameraTargetNode()->setParent(this->travelNode);
713      State::getCamera()->setParent(this->travelNode);
714    }
715  }
716
717
718  /*
719  else if( event.type == EV_MOUSE_MOTION)
720  {
721
722    this->xMouse += event.xRel;
723    this->yMouse += event.yRel;
724  }
725  */
726}
727
728void SpaceShip::destroy( WorldEntity* killer )
729{
730  if(this->hasPlayer())
731    Playable::destroy( killer);
732
733  PRINTF(5)("spaceship destroy\n");
734
735  EmitterNode* node  = NULL;
736  DotEmitter* emitter = NULL;
737  SpriteParticles*  explosionParticles  = NULL;
738
739  explosionParticles = new SpriteParticles(200);
740  explosionParticles->setName("SpaceShipExplosionParticles");
741  explosionParticles->setLifeSpan(.2, .3);
742  explosionParticles->setRadius(0.0, 10.0);
743  explosionParticles->setRadius(.5, 6.0);
744  explosionParticles->setRadius(1.0, 3.0);
745  explosionParticles->setColor(0.0, 1,1,1,.9);
746  explosionParticles->setColor(0.1,  1,1,0,.9);
747  explosionParticles->setColor(0.5, .8,.4,0,.5);
748  explosionParticles->setColor(1.0, .2,.2,.2,.5);
749
750
751  emitter = new DotEmitter( 2000, 70, 360);
752  //emitter->setSpread( 0, M_2_PI);
753  emitter->setEmissionRate( 200.0);
754  //emitter->setEmissionVelocity( 200.0);
755  //emitter->setSystem( explosionParticles);
756  //emitter->setAbsCoor( this->getAbsCoor());
757
758  node  = new EmitterNode( .1f);
759  node->setupParticle( emitter, explosionParticles);
760  node->setAbsDir( this->getAbsDir());
761  node->setVelocity( this->getVelocity() * .9f);
762  node->setAbsCoor( this->getAbsCoor());
763  if( !node->start())
764    PRINTF(0)("Explosion node not correctly started!");
765/*
766  PNode* node          = new PNode();
767  node->setAbsCoor(this->getAbsCoor());
768  Explosion* explosion = new Explosion();
769  explosion->explode( node, Vector(5,5,5));
770*/
771/*
772  if( this->hasPlayer())
773  {
774        this->setAbsCoor(Vector(-10000,10000,10000));
775        this->hide();
776  }
777  else
778  {*/
779    this->setAbsCoor( this->getAbsCoor() + Vector(100,0,0) + Vector(1,0,0) * VECTOR_RAND(150).dot(Vector(1,0,0)));
780  //}
781
782}
783
784void SpaceShip::respawn( )
785{
786  Playable::respawn();
787}
788
789
790void SpaceShip::damage(float pDamage, float eDamage){
791  PRINTF(5)("ship hit for (%f,%f) \n",pDamage,eDamage);
792
793  if( this->shieldActive) {
794    if( this->shieldCur > pDamage) {
795      this->shieldCur = this->shieldCur - pDamage;
796    }
797    else { // shield <= pDamage
798      this->shieldCur -=pDamage;
799      this->shieldActive = false; //shield collapses
800      pDamage += this->shieldCur;
801      if( !this->shieldActive) {
802        this->armorCur -= pDamage / 2; // remaining damages hits armor at half rate
803        this->electronicCur -= eDamage;
804      }
805    }
806  }
807  else {
808    this->armorCur = this->armorCur - pDamage;
809    this->electronicCur = this->electronicCur - eDamage;
810  }
811  if( this->armorCur <= 0) { /* FIXME implement shipcrash*/ }
812    this->destroy(this);
813
814  updateElectronicWidget();
815  updateShieldWidget();
816
817  this->setHealth( this->armorCur);
818}
819
820
821void SpaceShip::regen(float time){
822  float tmp;
823  if (this->armorCur != this->armorMax || this->armorRegen != 0){
824    tmp = this->armorCur + this->armorRegen * time;
825    if ( tmp > electronicMax)
826      this->armorCur = this->armorMax;
827    else
828      this->armorCur = tmp;
829  }
830  if (this->shieldCur != this->shieldMax || this->shieldRegen != 0){
831    tmp =  this->shieldCur + (this->shieldRegen + this->reactorOutput * this->shieldEnergyShare) * time;
832    if( tmp > shieldMax)
833      this->shieldCur = this->shieldMax;
834    else
835      this->shieldCur = tmp;
836    this->shieldActive = ( this->shieldActive || this->shieldCur > shieldTH);
837
838    updateShieldWidget();
839  }
840
841  this->setHealth( this->shieldCur);      // FIXME currently just to test share system
842
843  if (this->electronicCur != this->electronicMax || this->electronicRegen != 0){
844    tmp = this->electronicCur + this->electronicRegen * time;
845    if ( tmp > electronicMax)
846      this->electronicCur = this->electronicMax;
847    else
848      this->electronicCur = tmp;
849
850    updateElectronicWidget();
851  }
852
853}
854
855
856/**
857 * Weapon regeneration
858 * does not use any reactor capacity, as it wouldn't work in a consistent way.
859 */
860void SpaceShip::weaponRegen(float time)
861{
862  float energy  = ( this->reactorOutput * this->weaponEnergyShare + this->weaponEnergyRegen) * time;
863  Weapon* weapon;
864  for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++)
865  {
866    weapon = this->weaponMan.getWeapon(i);
867    if( weapon != NULL && weapon->isActive())
868    {
869      weapon->increaseEnergy( energy);
870    }
871
872  }
873  // weaponMan.increaseAmmunition( weapon, energy);
874}
875
876
877void SpaceShip::enterPlaymode(Playable::Playmode playmode)
878{
879  switch(playmode)
880  {
881    case Playable::Full3D:
882      /*
883      if (State::getCameraNode != NULL)
884      {
885        Vector absCoor = this->getAbsCoor();
886        this->setParent(PNode::getNullParent());
887        this->setAbsCoor(absCoor);
888        State::getCameraNode()->setParentSoft(&this->cameraNode);
889        State::getCameraNode()->setRelCoorSoft(-10, 0,0);
890        State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
891        State::getCameraTargetNode()->setRelCoorSoft(100, 0,0);
892
893      }
894      */
895      //break;
896
897      break;
898    case Playable::Horizontal:
899      if (State::getCameraNode != NULL)
900      {
901        this->debugNode(1);
902        this->travelNode->debugNode(1);
903
904        this->travelNode->setAbsCoor(this->getAbsCoor());
905        this->travelNode->updateNode(0.01f);
906
907        this->isTravelDistanceInit = false;
908
909        if(this->entityTrack)
910           this->travelNode->setParent(this->entityTrack->getTrackNode());
911
912        this->setParent(this->travelNode);
913        this->setRelCoor(0,0,0);
914
915        State::getCameraNode()->setParentSoft(this->travelNode);
916        //State::getCameraNode()->setParentSoft(this);
917        //State::getCameraNode()->setRelCoorSoft(-0.01, 40, 0);
918        State::getCameraTargetNode()->setParentSoft(this->travelNode);
919        //State::getCameraTargetNode()->setParentSoft(this);
920        //State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
921        this->setCameraMode(Camera::ViewTop);
922        State::getCamera()->setEventHandling(false);
923        registerEvent(KeyMapper::PEV_VIEW0);
924        registerEvent(KeyMapper::PEV_VIEW1);
925        registerEvent(KeyMapper::PEV_VIEW2);
926        registerEvent(KeyMapper::PEV_VIEW3);
927        registerEvent(KeyMapper::PEV_VIEW4);
928        registerEvent(KeyMapper::PEV_VIEW5);
929
930        State::getCamera()->setParentMode(PNODE_ALL);
931
932        //this->updateTravelDistance();
933
934        this->debugNode(1);
935        this->travelNode->debugNode(1);
936      }
937      break;
938
939    default:
940      PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName());
941  }
942}
943
944/**
945 * @brief calculate the velocity
946 * @param time the timeslice since the last frame
947*/
948
949void SpaceShip::movement (float dt)
950{
951  //by releasing the buttons, the velocity decreases with airCoeff*Acceleration. Should be strong enough so
952  //the ship doesn't slide too much.
953  float airCoeff = 2.5;
954  float pi = 3.14;
955
956  switch(this->getPlaymode())
957  {
958    case Playable::Horizontal:
959    {
960      // these routines will change the travel movement into zero in a short amout of time, if the player
961      // doesn't press any buttons.
962      if (this->travelVelocity.x >= 0)
963      {
964        if (this->travelVelocity.x > airCoeff*this->acceleration * dt)
965          this->travelVelocity.x -= airCoeff* this->acceleration * dt;
966        else
967          this->travelVelocity.x = 0;
968      }
969      else
970      {
971        if (this->travelVelocity.x < -airCoeff*this->acceleration * dt)
972          this->travelVelocity.x += airCoeff* this->acceleration * dt;
973        else
974          this->travelVelocity.x = 0;
975      }
976      if (this->travelVelocity.z >= 0)
977      {
978        if (this->travelVelocity.z > airCoeff*this->acceleration * dt)
979          this->travelVelocity.z -= airCoeff* this->acceleration * dt;
980        else
981          this->travelVelocity.z = 0;
982      }
983      else
984      {
985        if (this->travelVelocity.z < -airCoeff*this->acceleration * dt)
986          this->travelVelocity.z += airCoeff* this->acceleration * dt;
987        else
988          this->travelVelocity.z = 0;
989      }
990
991      // this will evite, that the ship moves outside the travelDistance- borders,when the player releases all buttons
992      // and its continuing to slide a bit.
993      Vector oldCoor = this->getRelCoor();
994      if (this->getRelCoor().x > this->travelDistancePlus.x) this->setRelCoor(this->travelDistancePlus.x, oldCoor.y, oldCoor.z);
995      if (this->getRelCoor().x < this->travelDistanceMinus.x) this->setRelCoor(this->travelDistanceMinus.x, oldCoor.y, oldCoor.z);
996      if (this->getRelCoor().z > this->travelDistancePlus.y) this->setRelCoor(oldCoor.x, oldCoor.y, this->travelDistancePlus.y);
997      if (this->getRelCoor().z < this->travelDistanceMinus.y) this->setRelCoor(oldCoor.x, oldCoor.y, this->travelDistanceMinus.y);
998
999      if( this->systemFailure() )
1000        bForward = bBackward = bLeft = bRight = false;
1001
1002      if( this->bForward )
1003      {
1004        //printf("ShipCoorX: %f \n", this->getRelCoor().x);
1005        if(this->getRelCoor().x < this->travelDistancePlus.x)
1006        {
1007          if (this->travelVelocity.x < this->travelSpeed)
1008          {
1009            this->travelVelocity.x += (airCoeff + 1.0)*this->acceleration*dt;
1010          }
1011          else
1012          {
1013            this->travelVelocity.x = this->travelSpeed;
1014          }
1015        }
1016        else
1017        {
1018          this->travelVelocity.x = 0.0f;
1019        }
1020      }
1021
1022      if( this->bBackward )
1023      {
1024        if(this->getRelCoor().x > this->travelDistanceMinus.x)
1025        {
1026          if (this->travelVelocity.x > -this->travelSpeed)
1027          {
1028            this->travelVelocity.x -= (airCoeff + 1.0)*this->acceleration*dt;
1029          }
1030          else
1031          {
1032            this->travelVelocity.x = -this->travelSpeed;
1033          }
1034        }
1035        else
1036        {
1037          this->travelVelocity.x = 0.0f;
1038        }
1039      }
1040
1041      if( this->bLeft)
1042      {
1043        if(this->getRelCoor().z > this->travelDistanceMinus.y)
1044        {
1045          if (this->travelVelocity.z > -this->travelSpeed)
1046          {
1047            this->travelVelocity.z -= (airCoeff + 1.0)*this->acceleration*dt;
1048          }
1049          else
1050          {
1051            this->travelVelocity.z = -this->travelSpeed;
1052          }
1053        }
1054        else
1055        {
1056          this->travelVelocity.z = 0.0f;
1057        }
1058        this->setRelDirSoft(Quaternion(-pi/6, Vector(1,0,0)), 6);
1059      }
1060
1061      if( this->bRight)
1062      {
1063        //printf("ShipCoorZ: %f \n", this->getRelCoor().z);
1064        if(this->getRelCoor().z < this->travelDistancePlus.y)
1065        {
1066          if (this->travelVelocity.z < this->travelSpeed)
1067          {
1068            this->travelVelocity.z += (airCoeff + 1.0)*this->acceleration*dt;
1069          }
1070          else
1071          {
1072            this->travelVelocity.z = this->travelSpeed;
1073          }
1074        }
1075        else
1076        {
1077          this->travelVelocity.z = 0.0f;
1078        }
1079        this->setRelDirSoft(Quaternion(pi/6, Vector(1,0,0)), 6);
1080      }
1081      if (!this->bRight && !this->bLeft)
1082      {
1083        this->setRelDirSoft(Quaternion(0, Vector(1,0,0)), 6);
1084      }
1085
1086    //normalisation of the vectors (vector sum must be <= travelspeed)
1087    float xzNorm = sqrt(pow(this->travelVelocity.x, 2) + pow(this->travelVelocity.z, 2));
1088    if (xzNorm > this->travelSpeed)
1089    {
1090      this->travelVelocity.x = this->travelVelocity.x/xzNorm * this->travelSpeed;
1091      this->travelVelocity.z = this->travelVelocity.z/xzNorm * this->travelSpeed;
1092    }
1093
1094    //this moves camera and ship along the travel path.
1095    if(!this->entityTrack)
1096       this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));
1097
1098    break;
1099    }
1100    case Playable::Vertical:
1101      break;
1102    default:
1103      PRINTF(4)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName());
1104  }
1105   //set new coordinates calculated through key- events.
1106  this->shiftCoor (this->travelVelocity * dt);
1107}
1108
1109void SpaceShip::setPlaymodeXML(const std::string& playmode)
1110{
1111  this->setPlaymode(Playable::stringToPlaymode(playmode));
1112}
1113
1114/**
1115 * @brief jumps to the next WeaponConfiguration
1116 */
1117void SpaceShip::nextWeaponConfig()
1118{
1119  PRINTF(0)("Requested next weapon config!\n");
1120  this->weaponMan.nextWeaponConfig();
1121  Playable::weaponConfigChanged();
1122}
1123
1124/**
1125 * @brief moves to the last WeaponConfiguration
1126 */
1127void SpaceShip::previousWeaponConfig()
1128{
1129  /*
1130  this->curWeaponPrimary    = (this->curWeaponPrimary + 1) % 3;
1131  this->weaponMan.changeWeaponConfig(this->curWeaponPrimary);
1132  */
1133  this->weaponMan.previousWeaponConfig();
1134  Playable::weaponConfigChanged();
1135}
1136
1137void SpaceShip::hit( float damage, WorldEntity* killer)
1138{
1139  this->damage(killer->getDamage(),0);
1140}
1141
1142void SpaceShip::updateElectronicWidget()
1143{
1144  if (this->electronicWidget != NULL)
1145  { //if it exists already: update it
1146     this->electronicWidget->setMaximum(this->electronicMax);
1147     this->electronicWidget->setValue(this->electronicCur);
1148  }
1149  else
1150  { //create the widget
1151    this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
1152    this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
1153    //this->electronicWidget->setDisplayedName("Electronics:");
1154    //this->electronicWidget->setSize2D(100,20);
1155    //this->electronicWidget->setAbsCoor2D(150,200);
1156    this->updateElectronicWidget();
1157    if (this->hasPlayer())
1158      State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
1159  }
1160}
1161
1162void SpaceShip::updateShieldWidget()
1163{
1164  if (this->shieldWidget != NULL)
1165  {
1166    this->shieldWidget->setMaximum(this->shieldMax);
1167    this->shieldWidget->setValue(this->shieldCur);;
1168  }
1169  else
1170  {
1171    this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
1172    this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
1173    //this->shieldWidget->setDisplayedName("Shield:");
1174    //his->shieldWidget->setSize2D(100,20);
1175    //this->shieldWidget->setAbsCoor2D(200,200);
1176    this->updateShieldWidget();
1177    if (this->hasPlayer())
1178      State::getPlayer()->hud().setShiledWidget(this->shieldWidget);
1179  }
1180}
1181
1182void SpaceShip::setCameraDistance(float dist)
1183{
1184  Camera* c = State::getCamera();
1185  c->setViewTopDistance(dist);
1186
1187  if (this->hasPlayer())
1188    this->isTravelDistanceInit = false;
1189}
1190
1191void SpaceShip::setCameraFovy(float fovy)
1192{
1193
1194  Camera* c = State::getCamera();
1195  c->setViewTopFovy(fovy);
1196
1197  if (this->hasPlayer())
1198    this->isTravelDistanceInit = false;
1199}
1200
1201void SpaceShip::updateTravelDistance()
1202{
1203
1204  Camera* c = State::getCamera();
1205
1206  float x = 1.25 * this->actionWidthPercentage * fabsf(c->getAbsCoor().y) * tan(c->getFovy()*M_PI /360.0);
1207  float y = x / c->getAspectRatio() / this->actionWidthPercentage;
1208  //State::getCamera()->setAbsCoor(-5, 1000, 0);
1209
1210
1211  //State::getCamera()->getAbsCoor().print();
1212  //printf("CameraRelCoorY: %f \n", State::getCamera()->getRelCoor().y);
1213
1214  //printf("x: %f, y: %f \n", x, y);
1215  this->travelDistancePlus = Vector2D(y, x);
1216  this->travelDistanceMinus = Vector2D(-y, -x);
1217
1218  State::getPlayer()->hud().setOverlayPercentage(100-int(100*this->actionWidthPercentage));
1219//   PRINTF(0)("TravelDistance has been updated\n");
1220  this->isTravelDistanceInit = true;
1221}
1222
1223void SpaceShip::setActionWidthPercentage(int i)
1224{
1225  if (i>100) i=100;
1226  if (i<0) i=0;
1227  this->actionWidthPercentage = i/100.0;
1228
1229  if (this->hasPlayer())
1230    this->isTravelDistanceInit = false;
1231};
Note: See TracBrowser for help on using the repository browser.