Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/single_player_map/src/world_entities/weapons/fps_sniper_rifle.cc @ 8890

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

door and weapon stuff

File size: 3.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
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}
70
71
72void FPSSniperRifle::init()
73{
74  this->setClassID(CL_FPS_SNIPER_RIFLE, "FPSSniperRifle");
75
76//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN);
77
78  this->loadModel("models/guns/fps_sniper_rifle.obj");
79
80  this->setStateDuration(WS_SHOOTING, .1);
81  this->setStateDuration(WS_RELOADING, .1);
82  this->setStateDuration(WS_ACTIVATING, .4);
83  this->setStateDuration(WS_DEACTIVATING, .4);
84
85  this->setEnergyMax(100000);
86  this->increaseEnergy(100000);
87  //this->minCharge = 2;
88
89  this->setActionSound(WA_SHOOT, "sound/laser.wav");
90  this->setActionSound(WA_ACTIVATE, "sound/voices/lasers.wav");
91
92
93  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
94  this->setProjectileType(CL_LASER);
95  this->prepareProjectiles(20);
96
97}
98
99
100void FPSSniperRifle::loadParams(const TiXmlElement* root)
101{
102  Weapon::loadParams(root);
103
104}
105
106
107/**
108 *  this activates the weapon
109
110   This is needed, since there can be more than one weapon on a ship. the
111   activation can be connected with an animation. for example the weapon is
112   been armed out.
113*/
114void FPSSniperRifle::activate()
115{
116}
117
118
119/**
120 *  this deactivates the weapon
121
122   This is needed, since there can be more than one weapon on a ship. the
123   activation can be connected with an animation. for example the weapon is
124   been armed out.
125*/
126void FPSSniperRifle::deactivate()
127{
128}
129
130
131/**
132 *  fires the weapon
133
134   this is called from the player.cc, when fire-button is been pushed
135   @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
136*/
137void FPSSniperRifle::fire()
138{
139  Projectile* pj =  this->getProjectile();
140  if (pj == NULL)
141    return;
142
143  pj->setParent(PNode::getNullParent());
144
145  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5));
146
147  pj->setAbsCoor(this->getEmissionPoint());
148  pj->setAbsDir(this->getAbsDir());
149  pj->activate();
150}
151
152
Note: See TracBrowser for help on using the repository browser.