Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/presentation/src/world_entities/weapons/fps_sniper_rifle.cc @ 10704

Last change on this file since 10704 was 10704, checked in by rennerc, 17 years ago

FPSSniperRifle uses BspWeapon now

File size: 4.1 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: Patrick Boenzli
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 "world_entities/projectiles/projectile.h"
24
25#include "world_entity.h"
26#include "static_model.h"
27#include "weapon_manager.h"
28#include "util/loading/factory.h"
29#include "debug.h"
30
31
32#include "loading/fast_factory.h"
33
34#include "fps_sniper_rifle.h"
35
36
37#include "effects/explosion.h"
38
39
40
41
42
43ObjectListDefinition(FPSSniperRifle);
44CREATE_FACTORY(FPSSniperRifle);
45
46/**
47 *  standard constructor
48
49   creates a new weapon
50*/
51FPSSniperRifle::FPSSniperRifle ( int leftRight, OM_LIST list)
52  : Weapon()
53{
54  this->init(list);
55
56  this->leftRight = leftRight;
57}
58
59
60FPSSniperRifle::FPSSniperRifle(const TiXmlElement* root)
61{
62  this->init( OM_GROUP_01 );
63
64  if (root != NULL)
65    this->loadParams(root);
66}
67
68/**
69 *  standard deconstructor
70*/
71FPSSniperRifle::~FPSSniperRifle ()
72{
73  // model will be deleted from WorldEntity-destructor
74  if( this->material != NULL)
75    delete this->material;
76}
77
78
79void FPSSniperRifle::init(OM_LIST list)
80{
81  this->registerObject(this, FPSSniperRifle::_objectList);
82
83  this->loadModel("models/guns/fps_sniper_rifle.obj", 0.2);
84  this->material = new Material();
85  this->material->setIllum(3);
86  this->material->setAmbient(1.0, 1.0, 1.0);
87  this->material->setDiffuseMap("textures/rifle01tex.jpg");
88
89  this->setStateDuration(WS_SHOOTING, .1);
90  this->setStateDuration(WS_RELOADING, .1);
91  this->setStateDuration(WS_ACTIVATING, .4);
92  this->setStateDuration(WS_DEACTIVATING, .4);
93
94  this->setEnergyMax(100000);
95  this->increaseEnergy(100000);
96  //this->minCharge = 2;
97
98  //this->setActionSound(WA_SHOOT, "sounds/laser.wav");
99  //this->setActionSound(WA_ACTIVATE, "sounds/voices/lasers.wav");
100
101
102  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
103  //this->setProjectileTypeC("Laser");
104  //this->prepareProjectiles(20);
105  this->toList( list );
106  this->weapon = new BspWeapon( this->getOMListNumber() );
107  this->weapon->setAlwaysHits( true );
108  this->weapon->setDamage( 35 );
109  this->weapon->setParent( this );
110  this->weapon->toList( list );
111   
112  this->bFire = false;
113}
114
115
116void FPSSniperRifle::loadParams(const TiXmlElement* root)
117{
118  Weapon::loadParams(root);
119
120}
121
122
123/**
124 *  this activates the weapon
125
126   This is needed, since there can be more than one weapon on a ship. the
127   activation can be connected with an animation. for example the weapon is
128   been armed out.
129*/
130void FPSSniperRifle::activate()
131{
132}
133
134
135/**
136 *  this deactivates the weapon
137
138   This is needed, since there can be more than one weapon on a ship. the
139   activation can be connected with an animation. for example the weapon is
140   been armed out.
141*/
142void FPSSniperRifle::deactivate()
143{
144}
145
146
147/**
148 *  fires the weapon
149
150   this is called from the player.cc, when fire-button is been pushed
151   @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
152*/
153void FPSSniperRifle::fire()
154{
155  PRINTF(0)("sniper fire\n");
156  this->bFire = true;
157}
158
159
160
161
162/**
163 *  this will draw the weapon
164 */
165void FPSSniperRifle::draw () const
166{
167  /* draw gun body */
168  glMatrixMode(GL_MODELVIEW);
169  glPushMatrix();
170  glTranslatef (this->getAbsCoor ().x,
171                this->getAbsCoor ().y,
172                this->getAbsCoor ().z);
173
174  Vector tmpRot = this->getAbsDir().getSpacialAxis();
175  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
176
177  if( this->leftRight == W_RIGHT)
178    glScalef(1.0, 1.0, -1.0);
179
180  this->material->select();
181  this->getModel()->draw();
182  //static_cast<StaticModel*>(this->getModel())->draw();
183
184  glPopMatrix();
185
186}
187
188void FPSSniperRifle::tick( float dt )
189{
190  Weapon::tick( dt );
191  this->weapon->fire( bFire );
192 
193  if ( bFire ){
194      PRINTF(0)("REAL FIRE\n");
195  }
196  bFire = false;
197}
198
199
200
Note: See TracBrowser for help on using the repository browser.