Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged the branche single_player_map with the trunk

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