Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/weapons/acid_launcher.cc @ 10544

Last change on this file since 10544 was 10539, checked in by marcscha, 18 years ago

Fixes for weapon systems

File size: 4.1 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004-2006 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: Marc Schaerrer
13   co-programmer:
14*/
15//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
16
17#include "acid_launcher.h"
18
19#include "weapon_manager.h"
20#include "world_entities/projectiles/acid_splash.h"
21
22#include "model.h"
23
24#include "state.h"
25#include "animation3d.h"
26
27#include <list>
28#include <iterator>
29#include "util/state.h"
30
31#include "math/quaternion.h"
32
33#include "util/loading/factory.h"
34
35#include "elements/glgui_energywidgetvertical.h"
36
37
38
39using namespace std;
40
41ObjectListDefinition(AcidLauncher);
42CREATE_FACTORY(AcidLauncher);
43
44/**
45 *  standard constructor
46 *
47 * creates a new AcidLauncher
48 */
49AcidLauncher::AcidLauncher()
50  : Weapon()
51{
52  this->init();
53}
54
55/**
56 * creates a new AcidLauncher from a TiXmlElement
57 */
58AcidLauncher::AcidLauncher(const TiXmlElement* root)
59{
60  this->init();
61  if (root != NULL)
62    this->loadParams(root);
63}
64
65/**
66 *  standard deconstructor
67*/
68AcidLauncher::~AcidLauncher ()
69{
70  // model will be deleted from WorldEntity-destructor
71}
72
73void AcidLauncher::init()
74{
75  this->registerObject(this, AcidLauncher::_objectList);
76/*
77  Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this);
78  Animation3D* animation2 = this->getAnimation(WS_DEACTIVATING, this);
79
80  animation1->addKeyFrame(Vector(0, -.5, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
81  animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
82  animation2->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
83  animation2->addKeyFrame(Vector(0, -.5, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
84
85  animation1->setInfinity(ANIM_INF_CONSTANT);
86  animation2->setInfinity(ANIM_INF_CONSTANT);
87*/
88  this->setStateDuration(WS_SHOOTING, 1.0f);
89
90  this->setStateDuration(WS_RELOADING, 1.0f);
91  this->setStateDuration(WS_ACTIVATING, .4);
92  this->setStateDuration(WS_DEACTIVATING, .4);
93
94  this->setEnergyMax(100);
95  this->increaseEnergy(100);
96  //this->minCharge = 2;
97
98  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET | WTYPE_DIRECTIONAL | WTYPE_LIGHT);
99  this->setProjectileTypeC("AcidSplash");
100//   this->loadModel("models/guns/turret1.obj", 1.0);
101
102  this->setEmissionPoint(2.0, 0, 0);
103  this->getProjectileFactory()->prepare(10);
104
105  this->setActionSound(WA_SHOOT, "sounds/explosions/explosion_1.wav");
106  this->setActionSound(WA_ACTIVATE, "sounds/voices/rockets.wav");
107  this->setActionSound(WA_RELOAD, "sounds/voices/reload.wav");
108
109}
110
111void AcidLauncher::loadParams(const TiXmlElement* root)
112{
113  Weapon::loadParams(root);
114}
115
116void AcidLauncher::activate()
117{
118}
119
120void AcidLauncher::deactivate()
121{
122}
123
124void AcidLauncher::tick(float dt)
125{
126  if (!Weapon::tickW(dt))
127    return;
128  if (this->energyWidget != NULL && !this->isEnergyWidgetInitialized)
129  {
130    this->energyWidget->setDisplayedImage("textures/gui/gui_acid.png");
131    this->isEnergyWidgetInitialized = true;
132  }
133
134
135  /*
136  Quaternion quat;
137  Vector direction;
138  if (this->getDefaultTarget() == NULL)
139    direction = this->getAbsCoor();
140  else
141    direction = this->getDefaultTarget()->getAbsCoor() - this->getAbsCoor();
142
143  direction.normalize();
144
145  if (likely (this->getParent() != NULL))
146    quat = Quaternion(direction, this->getParent()->getAbsDir().apply(Vector(0,1,0))) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
147  else
148    quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
149
150  this->setAbsDirSoft(quat, 5);
151  */
152}
153
154void AcidLauncher::fire()
155{
156  bool fired  = false;
157
158  Projectile* pj = NULL;
159  for( int i=0; i < 1; i++)
160  {
161      pj  = this->getProjectile();
162      if (pj == NULL)
163        return;
164
165      fired = true;
166      pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*165.0 + VECTOR_RAND(10)));
167
168      pj->setParent(PNode::getNullParent());
169      pj->setAbsCoor(this->getEmissionPoint() + VECTOR_RAND(.1));
170      pj->setAbsDir(this->getAbsDir()+Quaternion(0,VECTOR_RAND(5)));
171      pj->activate();
172  }
173}
Note: See TracBrowser for help on using the repository browser.