Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/weapons/fps_sniper_rifle.cc @ 9109

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

orxonox/trunk: merged the single_player_map branche back
merged with command:
svn merge -r8896:HEAD https://svn.orxonox.net/orxonox/branches/single_player_map .
no conflicts

File size: 3.8 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
30
31#include "fast_factory.h"
32
33#include "fps_sniper_rifle.h"
34
35
36using namespace std;
37
38
39CREATE_FACTORY(FPSSniperRifle, CL_FPS_SNIPER_RIFLE);
40
41/**
42 *  standard constructor
43
44   creates a new weapon
45*/
46FPSSniperRifle::FPSSniperRifle ( int leftRight)
47  : Weapon()
48{
49  this->init();
50
51  this->leftRight = leftRight;
52}
53
54
55FPSSniperRifle::FPSSniperRifle(const TiXmlElement* root)
56{
57  this->init();
58
59  if (root != NULL)
60    this->loadParams(root);
61}
62
63/**
64 *  standard deconstructor
65*/
66FPSSniperRifle::~FPSSniperRifle ()
67{
68  // model will be deleted from WorldEntity-destructor
69  if( this->material != NULL)
70    delete this->material;
71}
72
73
74void FPSSniperRifle::init()
75{
76  this->setClassID(CL_FPS_SNIPER_RIFLE, "FPSSniperRifle");
77
78  this->loadModel("models/guns/fps_sniper_rifle.obj", 0.2);
79  this->material = new Material();
80  this->material->setIllum(3);
81  this->material->setAmbient(1.0, 1.0, 1.0);
82  this->material->setDiffuseMap("maps/rifle01tex.jpg");
83
84  this->setStateDuration(WS_SHOOTING, .1);
85  this->setStateDuration(WS_RELOADING, .1);
86  this->setStateDuration(WS_ACTIVATING, .4);
87  this->setStateDuration(WS_DEACTIVATING, .4);
88
89  this->setEnergyMax(100000);
90  this->increaseEnergy(100000);
91  //this->minCharge = 2;
92
93  this->setActionSound(WA_SHOOT, "sound/laser.wav");
94  this->setActionSound(WA_ACTIVATE, "sound/voices/lasers.wav");
95
96
97  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
98  this->setProjectileType(CL_LASER);
99  this->prepareProjectiles(20);
100
101}
102
103
104void FPSSniperRifle::loadParams(const TiXmlElement* root)
105{
106  Weapon::loadParams(root);
107
108}
109
110
111/**
112 *  this activates the weapon
113
114   This is needed, since there can be more than one weapon on a ship. the
115   activation can be connected with an animation. for example the weapon is
116   been armed out.
117*/
118void FPSSniperRifle::activate()
119{
120}
121
122
123/**
124 *  this deactivates 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::deactivate()
131{
132}
133
134
135/**
136 *  fires the weapon
137
138   this is called from the player.cc, when fire-button is been pushed
139   @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
140*/
141void FPSSniperRifle::fire()
142{
143  Projectile* pj =  this->getProjectile();
144  if (pj == NULL)
145    return;
146
147  pj->setParent(PNode::getNullParent());
148
149  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5));
150
151  pj->setAbsCoor(this->getEmissionPoint());
152  pj->setAbsDir(this->getAbsDir());
153  pj->activate();
154}
155
156
157
158
159/**
160 *  this will draw the weapon
161 */
162void FPSSniperRifle::draw () const
163{
164  /* draw gun body */
165  glMatrixMode(GL_MODELVIEW);
166  glPushMatrix();
167  glTranslatef (this->getAbsCoor ().x,
168                this->getAbsCoor ().y,
169                this->getAbsCoor ().z);
170
171  Vector tmpRot = this->getAbsDir().getSpacialAxis();
172  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
173
174  if( this->leftRight == W_RIGHT)
175    glScalef(1.0, 1.0, -1.0);
176
177  this->material->select();
178  static_cast<StaticModel*>(this->getModel())->draw();
179
180  glPopMatrix();
181
182}
183
184
185
Note: See TracBrowser for help on using the repository browser.