Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/weapons/hyperblaster.cc @ 6810

Last change on this file since 6810 was 6810, checked in by bensch, 18 years ago

trunk: added hyperblaster

File size: 4.5 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific
14   main-programmer: Benjamin Grauer
15   co-programmer:
16
17
18   @todo: direction in which the projectile flights
19   @todo: a target to set/hit
20*/
21#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
22
23#include "hyperblaster.h"
24
25#include "world_entity.h"
26#include "model.h"
27#include "world_entities/projectiles/projectile.h"
28#include "weapon_manager.h"
29#include "factory.h"
30
31#include "vector.h"
32#include "list.h"
33#include "animation3d.h"
34
35#include "fast_factory.h"
36
37
38using namespace std;
39
40CREATE_FACTORY(Hyperblaster, CL_HYPERBLASTER);
41
42Hyperblaster::Hyperblaster(const TiXmlElement* root)
43{
44  this->init();
45  if (root != NULL)
46    this->loadParams(root);
47}
48
49/**
50 *  standard deconstructor
51*/
52Hyperblaster::~Hyperblaster ()
53{
54  // model will be deleted from WorldEntity-destructor
55}
56
57
58void Hyperblaster::init()
59{
60  this->setClassID(CL_HYPERBLASTER, "Hyperblaster");
61
62//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN);
63
64  this->loadModel("models/guns/plasmadriver_#.obj", 2.0);
65
66  this->setStateDuration(WS_SHOOTING, 2.0);
67  this->setStateDuration(WS_RELOADING, 5.0);
68  this->setStateDuration(WS_ACTIVATING, .1);
69  this->setStateDuration(WS_DEACTIVATING, .4);
70
71  this->setEnergyMax(10);
72  this->increaseEnergy(10);
73  //this->minCharge = 2;
74
75  this->setActionSound(WA_SHOOT, "sound/explo.wav");
76  this->setActionSound(WA_ACTIVATE, "sound/voices/hyperblaster.wav");
77
78  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_HEAVY);
79  this->setProjectileType(CL_HYPERBLAST);
80  this->prepareProjectiles(2);
81
82//  this->objectComponent1 = new PNode();
83//  Animation3D* animation1 = this->getAnimation(WS_SHOOTING, this->objectComponent1);
84  Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this);
85  Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this);
86  //parent->addChild(this->objectComponent1, PNODE_ALL);
87//  this->addChild(this->objectComponent1);
88
89//  animation1->setInfinity(ANIM_INF_CONSTANT);
90  animation2->setInfinity(ANIM_INF_CONSTANT);
91  animation3->setInfinity(ANIM_INF_CONSTANT);
92
93  this->setEmissionPoint(3.8, 1.2, 0);
94
95//     animation1->addKeyFrame(Vector(0, -1.5, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
96//     animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
97//     animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL);
98
99  animation2->addKeyFrame(Vector(1.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
100  animation2->addKeyFrame(Vector(1.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
101  animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
102
103  animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
104  animation3->addKeyFrame(Vector(1.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
105  animation2->addKeyFrame(Vector(1.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
106}
107
108
109void Hyperblaster::loadParams(const TiXmlElement* root)
110{
111  Weapon::loadParams(root);
112}
113
114
115/**
116 *  this activates the weapon
117
118   This is needed, since there can be more than one weapon on a ship. the
119   activation can be connected with an animation. for example the weapon is
120   been armed out.
121*/
122void Hyperblaster::activate()
123{
124}
125
126
127/**
128 *  this deactivates the weapon
129
130   This is needed, since there can be more than one weapon on a ship. the
131   activation can be connected with an animation. for example the weapon is
132   been armed out.
133*/
134void Hyperblaster::deactivate()
135{
136}
137
138
139/**
140 *  fires the weapon
141
142   this is called from the player.cc, when fire-button is been pushed
143   @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
144*/
145void Hyperblaster::fire()
146{
147  Projectile* pj =  this->getProjectile();
148  if (pj == NULL)
149    return;
150
151  pj->setParent(PNode::getNullParent());
152
153  pj->setVelocity(this->getVelocity() + this->getAbsDir().apply(Vector(1,0,0))*15+VECTOR_RAND(5));
154
155  pj->setAbsCoor(this->getEmissionPoint());
156  pj->setAbsDir(this->getAbsDir());
157  pj->activate();
158}
159
160/**
161 *  is called, when the weapon is destroyed
162 *
163 * this is in conjunction with the hit function, so when a weapon is able to get
164 * hit, it can also be destoryed.
165*/
166void Hyperblaster::destroy ()
167{}
Note: See TracBrowser for help on using the repository browser.