Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5527 in orxonox.OLD for branches/world_entities


Ignore:
Timestamp:
Nov 10, 2005, 12:33:31 AM (19 years ago)
Author:
bensch
Message:

world_entities: new AimingTurret added.
This turret aims a Target that is the nearest one, and shoots in its direction

Location:
branches/world_entities/src
Files:
26 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/world_entities/src/Makefile.am

    r5463 r5527  
    6262                  world_entities/weapons/test_gun.cc \
    6363                  world_entities/weapons/turret.cc \
     64                  world_entities/weapons/aiming_turret.cc \
    6465                  world_entities/weapons/test_bullet.cc \
    6566                  world_entities/weapons/rocket.cc \
     
    9596                 world_entities/weapons/test_gun.h \
    9697                 world_entities/weapons/turret.h \
     98                 world_entities/weapons/aiming_turret.h \
    9799                 world_entities/weapons/test_bullet.h \
    98100                 world_entities/weapons/rocket.h \
  • branches/world_entities/src/Makefile.in

    r5479 r5527  
    6565        orxonox-weapon.$(OBJEXT) orxonox-projectile.$(OBJEXT) \
    6666        orxonox-test_gun.$(OBJEXT) orxonox-turret.$(OBJEXT) \
    67         orxonox-test_bullet.$(OBJEXT) orxonox-rocket.$(OBJEXT) \
    68         orxonox-laser.$(OBJEXT) orxonox-crosshair.$(OBJEXT) \
    69         orxonox-power_up.$(OBJEXT) orxonox-turret_power_up.$(OBJEXT) \
     67        orxonox-aiming_turret.$(OBJEXT) orxonox-test_bullet.$(OBJEXT) \
     68        orxonox-rocket.$(OBJEXT) orxonox-laser.$(OBJEXT) \
     69        orxonox-crosshair.$(OBJEXT) orxonox-power_up.$(OBJEXT) \
     70        orxonox-turret_power_up.$(OBJEXT) \
    7071        orxonox-laser_power_up.$(OBJEXT) orxonox-benchmark.$(OBJEXT)
    7172orxonox_OBJECTS = $(am_orxonox_OBJECTS)
     
    256257                  world_entities/weapons/test_gun.cc \
    257258                  world_entities/weapons/turret.cc \
     259                  world_entities/weapons/aiming_turret.cc \
    258260                  world_entities/weapons/test_bullet.cc \
    259261                  world_entities/weapons/rocket.cc \
     
    289291                 world_entities/weapons/test_gun.h \
    290292                 world_entities/weapons/turret.h \
     293                 world_entities/weapons/aiming_turret.h \
    291294                 world_entities/weapons/test_bullet.h \
    292295                 world_entities/weapons/rocket.h \
     
    339342          esac; \
    340343        done; \
    341         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/Makefile'; \
     344        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/Makefile'; \
    342345        cd $(top_srcdir) && \
    343           $(AUTOMAKE) --foreign  src/Makefile
     346          $(AUTOMAKE) --gnu  src/Makefile
    344347.PRECIOUS: Makefile
    345348Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
     
    392395        -rm -f *.tab.c
    393396
     397@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-aiming_turret.Po@am__quote@
    394398@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-benchmark.Po@am__quote@
    395399@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-camera.Po@am__quote@
     
    729733@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    730734@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-turret.obj `if test -f 'world_entities/weapons/turret.cc'; then $(CYGPATH_W) 'world_entities/weapons/turret.cc'; else $(CYGPATH_W) '$(srcdir)/world_entities/weapons/turret.cc'; fi`
     735
     736orxonox-aiming_turret.o: world_entities/weapons/aiming_turret.cc
     737@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-aiming_turret.o -MD -MP -MF "$(DEPDIR)/orxonox-aiming_turret.Tpo" -c -o orxonox-aiming_turret.o `test -f 'world_entities/weapons/aiming_turret.cc' || echo '$(srcdir)/'`world_entities/weapons/aiming_turret.cc; \
     738@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/orxonox-aiming_turret.Tpo" "$(DEPDIR)/orxonox-aiming_turret.Po"; else rm -f "$(DEPDIR)/orxonox-aiming_turret.Tpo"; exit 1; fi
     739@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='world_entities/weapons/aiming_turret.cc' object='orxonox-aiming_turret.o' libtool=no @AMDEPBACKSLASH@
     740@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     741@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-aiming_turret.o `test -f 'world_entities/weapons/aiming_turret.cc' || echo '$(srcdir)/'`world_entities/weapons/aiming_turret.cc
     742
     743orxonox-aiming_turret.obj: world_entities/weapons/aiming_turret.cc
     744@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-aiming_turret.obj -MD -MP -MF "$(DEPDIR)/orxonox-aiming_turret.Tpo" -c -o orxonox-aiming_turret.obj `if test -f 'world_entities/weapons/aiming_turret.cc'; then $(CYGPATH_W) 'world_entities/weapons/aiming_turret.cc'; else $(CYGPATH_W) '$(srcdir)/world_entities/weapons/aiming_turret.cc'; fi`; \
     745@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/orxonox-aiming_turret.Tpo" "$(DEPDIR)/orxonox-aiming_turret.Po"; else rm -f "$(DEPDIR)/orxonox-aiming_turret.Tpo"; exit 1; fi
     746@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='world_entities/weapons/aiming_turret.cc' object='orxonox-aiming_turret.obj' libtool=no @AMDEPBACKSLASH@
     747@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     748@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-aiming_turret.obj `if test -f 'world_entities/weapons/aiming_turret.cc'; then $(CYGPATH_W) 'world_entities/weapons/aiming_turret.cc'; else $(CYGPATH_W) '$(srcdir)/world_entities/weapons/aiming_turret.cc'; fi`
    731749
    732750orxonox-test_bullet.o: world_entities/weapons/test_bullet.cc
  • branches/world_entities/src/defs/class_id.h

    r5458 r5527  
    135135  CL_TEST_GUN                   =    0x00000230,
    136136  CL_TURRET                     =    0x00000231,
     137  CL_AIMING_TURRET              =    0x00000232,
    137138
    138139
  • branches/world_entities/src/lib/Makefile.in

    r5479 r5527  
    270270          esac; \
    271271        done; \
    272         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/Makefile'; \
     272        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/Makefile'; \
    273273        cd $(top_srcdir) && \
    274           $(AUTOMAKE) --foreign  src/lib/Makefile
     274          $(AUTOMAKE) --gnu  src/lib/Makefile
    275275.PRECIOUS: Makefile
    276276Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/collision_detection/Makefile.in

    r5479 r5527  
    220220          esac; \
    221221        done; \
    222         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/collision_detection/Makefile'; \
     222        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/collision_detection/Makefile'; \
    223223        cd $(top_srcdir) && \
    224           $(AUTOMAKE) --foreign  src/lib/collision_detection/Makefile
     224          $(AUTOMAKE) --gnu  src/lib/collision_detection/Makefile
    225225.PRECIOUS: Makefile
    226226Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/event/Makefile.in

    r5479 r5527  
    210210          esac; \
    211211        done; \
    212         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/event/Makefile'; \
     212        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/event/Makefile'; \
    213213        cd $(top_srcdir) && \
    214           $(AUTOMAKE) --foreign  src/lib/event/Makefile
     214          $(AUTOMAKE) --gnu  src/lib/event/Makefile
    215215.PRECIOUS: Makefile
    216216Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/graphics/Makefile.in

    r5479 r5527  
    227227          esac; \
    228228        done; \
    229         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/graphics/Makefile'; \
     229        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/graphics/Makefile'; \
    230230        cd $(top_srcdir) && \
    231           $(AUTOMAKE) --foreign  src/lib/graphics/Makefile
     231          $(AUTOMAKE) --gnu  src/lib/graphics/Makefile
    232232.PRECIOUS: Makefile
    233233Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/graphics/importer/Makefile.in

    r5479 r5527  
    214214          esac; \
    215215        done; \
    216         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/graphics/importer/Makefile'; \
     216        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/graphics/importer/Makefile'; \
    217217        cd $(top_srcdir) && \
    218           $(AUTOMAKE) --foreign  src/lib/graphics/importer/Makefile
     218          $(AUTOMAKE) --gnu  src/lib/graphics/importer/Makefile
    219219.PRECIOUS: Makefile
    220220Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/graphics/spatial_separation/Makefile.in

    r5479 r5527  
    204204          esac; \
    205205        done; \
    206         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/graphics/spatial_separation/Makefile'; \
     206        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/graphics/spatial_separation/Makefile'; \
    207207        cd $(top_srcdir) && \
    208           $(AUTOMAKE) --foreign  src/lib/graphics/spatial_separation/Makefile
     208          $(AUTOMAKE) --gnu  src/lib/graphics/spatial_separation/Makefile
    209209.PRECIOUS: Makefile
    210210Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/gui/Makefile.in

    r5479 r5527  
    183183          esac; \
    184184        done; \
    185         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/gui/Makefile'; \
     185        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/gui/Makefile'; \
    186186        cd $(top_srcdir) && \
    187           $(AUTOMAKE) --foreign  src/lib/gui/Makefile
     187          $(AUTOMAKE) --gnu  src/lib/gui/Makefile
    188188.PRECIOUS: Makefile
    189189Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/gui/gl_gui/Makefile.in

    r5479 r5527  
    230230          esac; \
    231231        done; \
    232         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/gui/gl_gui/Makefile'; \
     232        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/gui/gl_gui/Makefile'; \
    233233        cd $(top_srcdir) && \
    234           $(AUTOMAKE) --foreign  src/lib/gui/gl_gui/Makefile
     234          $(AUTOMAKE) --gnu  src/lib/gui/gl_gui/Makefile
    235235.PRECIOUS: Makefile
    236236Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/gui/gtk_gui/Makefile.in

    r5479 r5527  
    232232          esac; \
    233233        done; \
    234         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/gui/gtk_gui/Makefile'; \
     234        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/gui/gtk_gui/Makefile'; \
    235235        cd $(top_srcdir) && \
    236           $(AUTOMAKE) --foreign  src/lib/gui/gtk_gui/Makefile
     236          $(AUTOMAKE) --gnu  src/lib/gui/gtk_gui/Makefile
    237237.PRECIOUS: Makefile
    238238Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/particles/Makefile.in

    r5479 r5527  
    207207          esac; \
    208208        done; \
    209         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/particles/Makefile'; \
     209        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/particles/Makefile'; \
    210210        cd $(top_srcdir) && \
    211           $(AUTOMAKE) --foreign  src/lib/particles/Makefile
     211          $(AUTOMAKE) --gnu  src/lib/particles/Makefile
    212212.PRECIOUS: Makefile
    213213Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/physics/Makefile.in

    r5479 r5527  
    215215          esac; \
    216216        done; \
    217         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/physics/Makefile'; \
     217        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/physics/Makefile'; \
    218218        cd $(top_srcdir) && \
    219           $(AUTOMAKE) --foreign  src/lib/physics/Makefile
     219          $(AUTOMAKE) --gnu  src/lib/physics/Makefile
    220220.PRECIOUS: Makefile
    221221Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/shell/Makefile.in

    r5479 r5527  
    209209          esac; \
    210210        done; \
    211         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/shell/Makefile'; \
     211        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/shell/Makefile'; \
    212212        cd $(top_srcdir) && \
    213           $(AUTOMAKE) --foreign  src/lib/shell/Makefile
     213          $(AUTOMAKE) --gnu  src/lib/shell/Makefile
    214214.PRECIOUS: Makefile
    215215Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/sound/Makefile.in

    r5479 r5527  
    207207          esac; \
    208208        done; \
    209         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/sound/Makefile'; \
     209        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/sound/Makefile'; \
    210210        cd $(top_srcdir) && \
    211           $(AUTOMAKE) --foreign  src/lib/sound/Makefile
     211          $(AUTOMAKE) --gnu  src/lib/sound/Makefile
    212212.PRECIOUS: Makefile
    213213Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/lib/tinyxml/Makefile.in

    r5479 r5527  
    203203          esac; \
    204204        done; \
    205         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/tinyxml/Makefile'; \
     205        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/tinyxml/Makefile'; \
    206206        cd $(top_srcdir) && \
    207           $(AUTOMAKE) --foreign  src/lib/tinyxml/Makefile
     207          $(AUTOMAKE) --gnu  src/lib/tinyxml/Makefile
    208208.PRECIOUS: Makefile
    209209Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/subprojects/Makefile.in

    r5479 r5527  
    190190          esac; \
    191191        done; \
    192         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/subprojects/Makefile'; \
     192        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/subprojects/Makefile'; \
    193193        cd $(top_srcdir) && \
    194           $(AUTOMAKE) --foreign  src/subprojects/Makefile
     194          $(AUTOMAKE) --gnu  src/subprojects/Makefile
    195195.PRECIOUS: Makefile
    196196Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/subprojects/collision_detection/Makefile.in

    r5486 r5527  
    259259          esac; \
    260260        done; \
    261         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/subprojects/collision_detection/Makefile'; \
     261        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/subprojects/collision_detection/Makefile'; \
    262262        cd $(top_srcdir) && \
    263           $(AUTOMAKE) --foreign  src/subprojects/collision_detection/Makefile
     263          $(AUTOMAKE) --gnu  src/subprojects/collision_detection/Makefile
    264264.PRECIOUS: Makefile
    265265Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/subprojects/importer/Makefile.in

    r5485 r5527  
    231231          esac; \
    232232        done; \
    233         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/subprojects/importer/Makefile'; \
     233        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/subprojects/importer/Makefile'; \
    234234        cd $(top_srcdir) && \
    235           $(AUTOMAKE) --foreign  src/subprojects/importer/Makefile
     235          $(AUTOMAKE) --gnu  src/subprojects/importer/Makefile
    236236.PRECIOUS: Makefile
    237237Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/subprojects/particles/Makefile.in

    r5485 r5527  
    251251          esac; \
    252252        done; \
    253         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/subprojects/particles/Makefile'; \
     253        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/subprojects/particles/Makefile'; \
    254254        cd $(top_srcdir) && \
    255           $(AUTOMAKE) --foreign  src/subprojects/particles/Makefile
     255          $(AUTOMAKE) --gnu  src/subprojects/particles/Makefile
    256256.PRECIOUS: Makefile
    257257Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/subprojects/testmain/Makefile.in

    r5479 r5527  
    197197          esac; \
    198198        done; \
    199         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/subprojects/testmain/Makefile'; \
     199        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/subprojects/testmain/Makefile'; \
    200200        cd $(top_srcdir) && \
    201           $(AUTOMAKE) --foreign  src/subprojects/testmain/Makefile
     201          $(AUTOMAKE) --gnu  src/subprojects/testmain/Makefile
    202202.PRECIOUS: Makefile
    203203Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/util/Makefile.in

    r5479 r5527  
    233233          esac; \
    234234        done; \
    235         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/util/Makefile'; \
     235        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/util/Makefile'; \
    236236        cd $(top_srcdir) && \
    237           $(AUTOMAKE) --foreign  src/util/Makefile
     237          $(AUTOMAKE) --gnu  src/util/Makefile
    238238.PRECIOUS: Makefile
    239239Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • branches/world_entities/src/world_entities/player.cc

    r5500 r5527  
    337337}
    338338
     339#include "aiming_turret.h"
    339340// FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG
    340341void Player::ADDWEAPON()
    341342{
    342   Weapon* turret1 = new Turret(this->weaponMan);
     343  Weapon* turret1;
     344  if ((float)rand()/RAND_MAX < .7)
     345    turret1 = new Turret(this->weaponMan);
     346  else
     347    turret1 = new AimingTurret(this->weaponMan);
     348
    343349  turret1->setName("Turret");
    344350  turret1->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);
  • branches/world_entities/src/world_entities/weapons/aiming_turret.cc

    r5526 r5527  
    1515#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
    1616
    17 #include "turret.h"
     17#include "aiming_turret.h"
    1818
    1919#include "weapon_manager.h"
     
    3030#include "factory.h"
    3131
    32 CREATE_FACTORY(Turret);
     32CREATE_FACTORY(AimingTurret);
    3333
    3434using namespace std;
     
    4040   creates a new weapon
    4141*/
    42 Turret::Turret (WeaponManager* weaponManager)
     42AimingTurret::AimingTurret (WeaponManager* weaponManager)
    4343  : Weapon(weaponManager)
    4444{
     
    5454
    5555
    56 Turret::Turret(const TiXmlElement* root)
     56AimingTurret::AimingTurret(const TiXmlElement* root)
    5757{
    5858  this->init();
     
    6363 *  standard deconstructor
    6464*/
    65 Turret::~Turret ()
     65AimingTurret::~AimingTurret ()
    6666{
    6767  // model will be deleted from WorldEntity-destructor
    6868}
    6969
    70 void Turret::init()
     70void AimingTurret::init()
    7171{
    72   this->setClassID(CL_TURRET, "Turret");
     72  this->setClassID(CL_AIMING_TURRET, "AimingTurret");
    7373
    7474  Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this);
     
    9898  this->setEmissionPoint(1.684, 0.472, 0);
    9999  //this->getProjectileFactory()->prepare(100);
     100
     101  this->target = NULL;
    100102}
    101103
    102 void Turret::loadParams(const TiXmlElement* root)
     104void AimingTurret::loadParams(const TiXmlElement* root)
    103105{
    104106  static_cast<Weapon*>(this)->loadParams(root);
     
    106108}
    107109
    108 void Turret::activate()
     110void AimingTurret::activate()
    109111{
    110112}
    111113
    112 void Turret::deactivate()
     114void AimingTurret::deactivate()
    113115{
    114116}
    115117
    116 void Turret::tick(float dt)
     118void AimingTurret::tick(float dt)
    117119{
    118120  Quaternion quat;
    119   Vector direction = this->getWeaponManager()->getFixedTarget()->getAbsCoor() - this->getAbsCoor();
     121  if (this->target == NULL)
     122    this->target = this->getWeaponManager()->getDistanceTarget(this, 50);
     123  Vector direction = this->target->getAbsCoor() - this->getAbsCoor();
    120124
    121125  direction.normalize();
     
    126130    quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
    127131
    128   this->setAbsDirSoft(quat, 5);
     132  this->setAbsDirSoft(quat, 20);
    129133}
    130134
    131 void Turret::fire()
     135void AimingTurret::fire()
    132136{
    133137  Projectile* pj = this->getProjectile();
     
    139143  if (target != NULL)
    140144  {
    141     pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*100.0 + VECTOR_RAND(13)
     145    pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDir().apply(Vector(1,0,0))*100.0 + VECTOR_RAND(13)
    142146            /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());
    143147  }
     
    149153  pj->setAbsDir(this->getAbsDir());
    150154  pj->activate();
     155  this->target = this->getWeaponManager()->getDistanceTarget(this, 50);
    151156}
    152157
    153 void Turret::destroy ()
     158void AimingTurret::destroy ()
    154159{}
    155160
    156161/**
    157  * draws the Turret
     162 * draws the AimingTurret
    158163*/
    159 void Turret::draw () const
     164void AimingTurret::draw () const
    160165{
    161166  this->getWeaponManager()->getFixedTarget()->debugDraw(10);
  • branches/world_entities/src/world_entities/weapons/aiming_turret.h

    r5526 r5527  
    11/*!
    2  * @file turret.h
     2 * @file aiming_turret.h
    33*/
    44
    55
    6 #ifndef _TURRET_H
    7 #define _TURRET_H
     6#ifndef _AIMING_TURRET_H
     7#define _AIMING_TURRET_H
    88
    99#include "weapon.h"
    1010
    11 class Turret : public Weapon
     11class AimingTurret : public Weapon
    1212  {
    1313  public:
    14     Turret (WeaponManager* weaponManager);
    15     Turret(const TiXmlElement* root);
    16     virtual ~Turret ();
     14    AimingTurret (WeaponManager* weaponManager);
     15    AimingTurret(const TiXmlElement* root);
     16    virtual ~AimingTurret ();
    1717
    1818    void init();
     
    2929
    3030  private:
     31    PNode*          target;
    3132  };
    3233
    33 #endif /* _TURRET_H */
     34#endif /* _AIMING_TURRET_H */
  • branches/world_entities/src/world_entities/weapons/weapon_manager.cc

    r5441 r5527  
    2323#include "crosshair.h"
    2424
     25#include "class_list.h"
    2526#include "load_param.h"
    2627#include "factory.h"
    27 #include "vector.h"
    2828#include "list.h"
    2929#include "t_animation.h"
    3030#include "null_parent.h"
     31
    3132
    3233using namespace std;
     
    109110  this->crossHairSizeAnim->addKeyFrame(100, .05, ANIM_LINEAR);
    110111  this->crossHairSizeAnim->addKeyFrame(50, .01, ANIM_LINEAR);
     112
     113  this->targetIterator = NULL;
    111114}
    112115
     
    140143
    141144  Weapon* newWeapon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(element));
    142 
    143145
    144146
     
    334336    }
    335337  }
     338}
     339
     340
     341/**
     342 * Selects an Entity from the NPC-list, and returns the Target
     343 */
     344PNode* WeaponManager::getSomeTarget()
     345{
     346   if (this->targetIterator == NULL)
     347   {
     348     tList<BaseObject>* npcList = ClassList::getList(CL_NPC);
     349     if (npcList != NULL)
     350     {
     351       this->targetIterator = npcList->getIterator();
     352       this->targetIterator->firstElement();
     353     }
     354     else
     355       return NULL;
     356   }
     357
     358   PNode* retNode = dynamic_cast<PNode*>(targetIterator->nextElement());
     359   if (retNode == NULL && this->targetIterator->getList()->getSize() > 0)
     360     retNode =  dynamic_cast<PNode*>(targetIterator->firstElement());
     361
     362   return retNode;
     363}
     364
     365
     366/**
     367 * Selects an Entity from the Entity-List, that is near of the carrier PNode.
     368 * @param carrier: The PNode from which the distance should be measured
     369 * @param distance: The Maximum Distance to Return.
     370 */
     371PNode* WeaponManager::getDistanceTarget(const PNode* carrier, float distance)
     372{
     373  tList<BaseObject>* npcList = ClassList::getList(CL_NPC);
     374  if (npcList != NULL)
     375  {
     376    tIterator<BaseObject>* npcIT = npcList->getIterator();
     377    PNode* tmpNPC = dynamic_cast<PNode*>(npcIT->firstElement());
     378    while (tmpNPC != NULL)
     379    {
     380      if ((carrier->getAbsCoor() - tmpNPC->getAbsCoor()).len() < distance)
     381      {
     382        delete npcIT;
     383        return tmpNPC;
     384      }
     385      tmpNPC = dynamic_cast<PNode*>(npcIT->nextElement());
     386    }
     387    delete npcIT;
     388  }
     389  return this->getFixedTarget();
     390
    336391}
    337392
  • branches/world_entities/src/world_entities/weapons/weapon_manager.h

    r5453 r5527  
    1717// FORWARD DECLARATION
    1818template <class T> class tAnimation;
     19template <class T> class tIterator;
    1920
    2021
     
    7778
    7879    /** @returns a fixed target namely the Crosshair's 3D position */
    79     inline PNode* getFixedTarget() { return this->crosshair; };
     80    inline PNode* getFixedTarget() const { return this->crosshair; };
     81    PNode* getSomeTarget();
     82    PNode* getDistanceTarget(const PNode* carrier, float distance);
     83
    8084    void fire();
     85    //! @TODO: implement this function (maybe also in Weapon itself)
     86    void releaseFire();
    8187
    8288    void tick(float dt);
     
    102108    Crosshair*              crosshair;                                //!< an aim.
    103109    tAnimation<Crosshair>*  crossHairSizeAnim;                        //!< An animation for the crosshair (scaling)
     110
     111    tIterator<BaseObject>*  targetIterator;                           //!< An iterator for traversion lists of enemies.
    104112};
Note: See TracChangeset for help on using the changeset viewer.