Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7076 in orxonox.OLD for trunk/src/world_entities/npcs


Ignore:
Timestamp:
Feb 7, 2006, 3:46:43 PM (19 years ago)
Author:
bensch
Message:

weaponAdjustment

Location:
trunk/src/world_entities/npcs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/npcs/ground_turret.cc

    r6815 r7076  
    1818#include "world_entities/weapons/turret.h"
    1919
     20#include "state.h"
     21#include "playable.h"
     22#include "player.h"
     23
     24
    2025#include "factory.h"
    2126#include "network_game_manager.h"
     
    5863  this->left = NULL;
    5964  this->right = NULL;
     65
     66  this->setHealthMax(300);
     67  this->setHealth(300);
    6068
    6169  /*  left = new Turret();
     
    113121void GroundTurret::tick(float dt)
    114122{
     123  if(this->getHealth() > 0.0f && State::getPlayer() &&
     124     State::getPlayer()->getPlayable() &&
     125     State::getPlayer()->getPlayable()->distance(this) < 150) // HACK
     126  {
    115127  if (likely(this->left != NULL))
    116128  {
     
    123135    this->right->requestAction(WA_SHOOT);
    124136  }
    125 
     137  }
    126138}
    127139
     
    140152
    141153
    142 /**
    143  *
    144  *
    145  */
    146 void GroundTurret::collidesWith (WorldEntity* entity, const Vector& location)
    147 {
    148   if (entity->isA(CL_PROJECTILE))
    149     this->setAbsDirSoft(Quaternion(-90, Vector(0,0,1)), 90);
    150 }
    151154
    152155/**
     
    166169{
    167170
     171}
     172
     173void GroundTurret::destroy()
     174{
     175  this->setAbsDirSoft(Quaternion(-90, Vector(0,0,1)), 90);
    168176}
    169177
  • trunk/src/world_entities/npcs/ground_turret.h

    r6512 r7076  
    2525  virtual void leftWorld ();
    2626
     27  virtual void destroy();
    2728
    2829  virtual void draw() const;
    2930  virtual void tick(float time);
    30   virtual void collidesWith (WorldEntity* entity, const Vector& location);
    3131
    3232  virtual int writeBytes(const byte* data, int length, int sender);
  • trunk/src/world_entities/npcs/npc.cc

    r6341 r7076  
    4141void NPC::collidesWith(WorldEntity* entity, const Vector& location)
    4242{
    43   if (entity->isA(CL_PROJECTILE) && entity != this->collider)
     43
     44  if (entity == collider)
     45    return;
     46  collider = entity;
     47
     48  if (entity->isA(CL_PROJECTILE))
    4449  {
    45 //    PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
    46 //    this->applyForce(Vector(0,0,0)-location*1000);
    47     if ((float)rand()/RAND_MAX < .3)
     50    this->decreaseHealth(entity->getHealth() *(float)rand()/(float)RAND_MAX);
     51    // EXTREME HACK
     52    if (this->getHealth() <= 0.0f)
    4853    {
    49       WorldEntity* powerUp = new TurretPowerUp();
    50       powerUp->setAbsCoor(this->getAbsCoor());
    51 //      powerUp->toList(OM_COMMON);
     54      this->destroy();
    5255    }
    53     else if ((float)rand()/RAND_MAX < .3)
    54     {
    55       WorldEntity* powerUp = new LaserPowerUp();
    56       powerUp->setAbsCoor(this->getAbsCoor());
    57       powerUp->toList(OM_COMMON);
    58     }
    59     this->toList(OM_DEAD);
    60     this->removeNode();
     56  }
    6157
    62       this->collider = entity;
    63   }
    64   //  else if (entity->isA(CL_PLAYER))
    65   //    this->applyForce(Vector(0,0,0)-location*100);
    66   else if (entity->isA(CL_NPC))
    67   {
    68     this->setVisibiliy(false);
    69     this->toList(OM_DEAD);
    70     this->removeNode();
    71   }
     58
     59// //    PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
     60// //    this->applyForce(Vector(0,0,0)-location*1000);
     61//     if ((float)rand()/RAND_MAX < .3)
     62//     {
     63//       WorldEntity* powerUp = new TurretPowerUp();
     64//       powerUp->setAbsCoor(this->getAbsCoor());
     65// //      powerUp->toList(OM_COMMON);
     66//     }
     67//     else if ((float)rand()/RAND_MAX < .3)
     68//     {
     69//       WorldEntity* powerUp = new LaserPowerUp();
     70//       powerUp->setAbsCoor(this->getAbsCoor());
     71//       powerUp->toList(OM_COMMON);
     72//     }
     73//     this->toList(OM_DEAD);
     74//     this->removeNode();
     75//
     76//       this->collider = entity;
     77//   }
     78//   //  else if (entity->isA(CL_PLAYER))
     79//   //    this->applyForce(Vector(0,0,0)-location*100);
     80//   else if (entity->isA(CL_NPC))
     81//   {
     82//     this->setVisibiliy(false);
     83//     this->toList(OM_DEAD);
     84//     this->removeNode();
     85//   }
    7286}
Note: See TracChangeset for help on using the changeset viewer.