Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 28, 2006, 11:29:03 AM (18 years ago)
Author:
bensch
Message:

trunk: remastered Playables a bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/creatures/md2_creature.cc

    r6561 r6804  
    3939
    4040CREATE_FACTORY(MD2Creature, CL_MD2_CREATURE);
    41 
    42 /**
    43  *  creates the controlable MD2Creature
    44  */
    45 MD2Creature::MD2Creature()
    46 {
    47   this->init();
    48 }
    4941
    5042/**
     
    231223void MD2Creature::collidesWith(WorldEntity* entity, const Vector& location)
    232224{
    233   if (entity->isA(CL_TURRET_POWER_UP) )
    234   {
    235     this->ADDWEAPON();
    236     }
    237 //  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
     225
    238226}
    239227
     
    254242void MD2Creature::tick (float time)
    255243{
     244  Playable::tick(time);
    256245  if( likely(this->getModel(0) != NULL))
    257246    ((MD2Model*)this->getModel(0))->tick(time);
     
    284273  this->setAbsDir(mouseDirX);
    285274  this->cameraConnNode.setRelDir(mouseDirY);
    286 
    287   this->getWeaponManager()->tick(time);
    288   // weapon system manipulation
    289   this->weaponAction();
    290275}
    291276
     
    348333
    349334
    350 /**
    351  * weapon manipulation by the player
    352 */
    353 void MD2Creature::weaponAction()
    354 {
    355   if( this->bFire)
    356     {
    357       this->getWeaponManager()->fire();
    358     }
    359 }
    360335
    361336/**
     
    364339void MD2Creature::process(const Event &event)
    365340{
     341  Playable::process(event);
    366342  if( event.type == SDLK_a)
    367343      this->bStrafeL = event.bPressed;
    368344  else if( event.type == SDLK_d)
    369345      this->bStrafeR = event.bPressed;
    370   else if( event.type == KeyMapper::PEV_FIRE1)
    371       this->bFire = event.bPressed;
    372   else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)
    373     this->getWeaponManager()->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;
    374   else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)
    375     this->getWeaponManager()->previousWeaponConfig();
    376346  else if( event.type == SDLK_w)
    377347    this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
     
    390360  }
    391361}
    392 
    393 #include "weapons/aiming_turret.h"
    394 // FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG
    395 void MD2Creature::ADDWEAPON()
    396 {
    397   Weapon* turret = NULL;
    398 
    399   if ((float)rand()/RAND_MAX < .1)
    400   {
    401     //if (this->getWeaponManager()->hasFreeSlot(2, WTYPE_TURRET))
    402     {
    403       turret = new Turret();
    404       this->getWeaponManager()->addWeapon(turret, 2);
    405       this->getWeaponManager()->changeWeaponConfig(2);
    406     }
    407   }
    408   else
    409   {
    410     //if (this->getWeaponManager()->hasFreeSlot(3))
    411     {
    412       turret = new AimingTurret();
    413       this->getWeaponManager()->addWeapon(turret, 3);
    414 
    415       this->getWeaponManager()->changeWeaponConfig(3);
    416     }
    417   }
    418 
    419   if(turret != NULL)
    420   {
    421     turret->setName("Turret");
    422     turret->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);
    423   }
    424 }
Note: See TracChangeset for help on using the changeset viewer.