Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

player cannot shoot throu walls
per default worldentities cannot be killed
weapon correct again

File size: 4.2 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->setAbsDir( this->getAbsDir() * Quaternion( -PI/2, Vector(1, 0, 0) ) );
84  this->loadModel("models/guns/fps_sniper_rifle.obj", 1.5);
85  this->material = new Material();
86  this->material->setIllum(3);
87  this->material->setAmbient(1.0, 1.0, 1.0);
88  this->material->setDiffuseMap("textures/fps_sniper_rifle.jpg");
89
90  this->setStateDuration(WS_SHOOTING, .1);
91  this->setStateDuration(WS_RELOADING, .1);
92  this->setStateDuration(WS_ACTIVATING, .4);
93  this->setStateDuration(WS_DEACTIVATING, .4);
94
95  this->setEnergyMax(100000);
96  this->increaseEnergy(100000);
97  //this->minCharge = 2;
98
99  //this->setActionSound(WA_SHOOT, "sounds/laser.wav");
100  //this->setActionSound(WA_ACTIVATE, "sounds/voices/lasers.wav");
101
102
103  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
104  //this->setProjectileTypeC("Laser");
105  //this->prepareProjectiles(20);
106  this->toList( list );
107  this->weapon = new BspWeapon( this->getOMListNumber() );
108  this->weapon->setAlwaysHits( true );
109  this->weapon->setDamage( 35 );
110  this->weapon->setParent( this );
111  this->weapon->toList( list );
112   
113  this->bFire = false;
114}
115
116
117void FPSSniperRifle::loadParams(const TiXmlElement* root)
118{
119  Weapon::loadParams(root);
120
121}
122
123
124/**
125 *  this activates the weapon
126
127   This is needed, since there can be more than one weapon on a ship. the
128   activation can be connected with an animation. for example the weapon is
129   been armed out.
130*/
131void FPSSniperRifle::activate()
132{
133}
134
135
136/**
137 *  this deactivates the weapon
138
139   This is needed, since there can be more than one weapon on a ship. the
140   activation can be connected with an animation. for example the weapon is
141   been armed out.
142*/
143void FPSSniperRifle::deactivate()
144{
145}
146
147
148/**
149 *  fires the weapon
150
151   this is called from the player.cc, when fire-button is been pushed
152   @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
153*/
154void FPSSniperRifle::fire()
155{
156  PRINTF(0)("sniper fire\n");
157  this->bFire = true;
158}
159
160
161
162
163/**
164 *  this will draw the weapon
165 */
166void FPSSniperRifle::draw () const
167{
168  /* draw gun body */
169  glMatrixMode(GL_MODELVIEW);
170  glPushMatrix();
171
172  Vector pos = this->getAbsCoor() + this->getAbsDir().apply( Vector( 1, 0, 0 ) );
173  glTranslatef (pos.x,
174                pos.y,
175                pos.z);
176
177  Vector tmpRot = this->getAbsDir().getSpacialAxis();
178  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
179
180  if( this->leftRight == W_RIGHT)
181    glScalef(1.0, 1.0, -1.0);
182
183  this->material->select();
184  this->getModel()->draw();
185  //static_cast<StaticModel*>(this->getModel())->draw();
186
187  glPopMatrix();
188}
189
190void FPSSniperRifle::tick( float dt )
191{
192  Weapon::tick( dt );
193  this->weapon->fire( bFire );
194 
195  if ( bFire ){
196      PRINTF(0)("REAL FIRE\n");
197  }
198  bFire = false;
199}
200
201
202
Note: See TracBrowser for help on using the repository browser.