Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/blink/src/world_entities/weapons/acid_launcher.cc @ 10646

Last change on this file since 10646 was 10419, checked in by patrick, 18 years ago

vocals ⇒ voices

File size: 3.9 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
36
37using namespace std;
38
39ObjectListDefinition(AcidLauncher);
40CREATE_FACTORY(AcidLauncher);
41
42/**
43 *  standard constructor
44 *
45 * creates a new AcidLauncher
46 */
47AcidLauncher::AcidLauncher()
48  : Weapon()
49{
50  this->init();
51}
52
53/**
54 * creates a new AcidLauncher from a TiXmlElement
55 */
56AcidLauncher::AcidLauncher(const TiXmlElement* root)
57{
58  this->init();
59  if (root != NULL)
60    this->loadParams(root);
61}
62
63/**
64 *  standard deconstructor
65*/
66AcidLauncher::~AcidLauncher ()
67{
68  // model will be deleted from WorldEntity-destructor
69}
70
71void AcidLauncher::init()
72{
73  this->registerObject(this, AcidLauncher::_objectList);
74/*
75  Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this);
76  Animation3D* animation2 = this->getAnimation(WS_DEACTIVATING, this);
77
78  animation1->addKeyFrame(Vector(0, -.5, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
79  animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
80  animation2->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
81  animation2->addKeyFrame(Vector(0, -.5, 0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);
82
83  animation1->setInfinity(ANIM_INF_CONSTANT);
84  animation2->setInfinity(ANIM_INF_CONSTANT);
85*/
86  this->setStateDuration(WS_SHOOTING, 1.0f);
87
88  this->setStateDuration(WS_RELOADING, 1.0f);
89  this->setStateDuration(WS_ACTIVATING, .4);
90  this->setStateDuration(WS_DEACTIVATING, .4);
91
92  this->setEnergyMax(100);
93  this->increaseEnergy(100);
94  //this->minCharge = 2;
95
96  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET | WTYPE_DIRECTIONAL | WTYPE_LIGHT);
97  this->setProjectileTypeC("AcidSplash");
98//   this->loadModel("models/guns/turret1.obj", 1.0);
99
100  this->setEmissionPoint(2.0, 0, 0);
101  this->getProjectileFactory()->prepare(10);
102
103  this->setActionSound(WA_SHOOT, "sounds/explosions/explosion_1.wav");
104  this->setActionSound(WA_ACTIVATE, "sounds/voices/rockets.wav");
105  this->setActionSound(WA_RELOAD, "sounds/voices/reload.wav");
106
107}
108
109void AcidLauncher::loadParams(const TiXmlElement* root)
110{
111  Weapon::loadParams(root);
112}
113
114void AcidLauncher::activate()
115{
116}
117
118void AcidLauncher::deactivate()
119{
120}
121
122void AcidLauncher::tick(float dt)
123{
124  if (!Weapon::tickW(dt))
125    return;
126  /*
127  Quaternion quat;
128  Vector direction;
129  if (this->getDefaultTarget() == NULL)
130    direction = this->getAbsCoor();
131  else
132    direction = this->getDefaultTarget()->getAbsCoor() - this->getAbsCoor();
133
134  direction.normalize();
135
136  if (likely (this->getParent() != NULL))
137    quat = Quaternion(direction, this->getParent()->getAbsDir().apply(Vector(0,1,0))) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
138  else
139    quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
140
141  this->setAbsDirSoft(quat, 5);
142  */
143}
144
145void AcidLauncher::fire()
146{
147  bool fired  = false;
148
149  Projectile* pj = NULL;
150  for( int i=0; i < 1; i++)
151  {
152      pj  = this->getProjectile();
153      if (pj == NULL)
154        return;
155
156      fired = true;
157      pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*165.0 + VECTOR_RAND(10)));
158
159      pj->setParent(PNode::getNullParent());
160      pj->setAbsCoor(this->getEmissionPoint() + VECTOR_RAND(.1));
161      pj->setAbsDir(this->getAbsDir()+Quaternion(0,VECTOR_RAND(5)));
162      pj->activate();
163  }
164}
Note: See TracBrowser for help on using the repository browser.