Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/weapons/laser_cannon.cc @ 10114

Last change on this file since 10114 was 10114, checked in by patrick, 17 years ago

merged network back to trunk

File size: 3.0 KB
RevLine 
[4592]1/*
[3618]2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific
12   main-programmer: Patrick Boenzli
[4592]13   co-programmer:
[3631]14
15
[4836]16   @todo: direction in which the projectile flights
17   @todo: a target to set/hit
[3618]18*/
[5357]19#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
[3618]20
[9131]21#include "laser_cannon.h"
[6434]22#include "world_entities/projectiles/projectile.h"
[3618]23
24#include "world_entity.h"
[6022]25#include "static_model.h"
[4955]26#include "weapon_manager.h"
[7193]27#include "util/loading/factory.h"
[3618]28
[3851]29#include "animation3d.h"
[3618]30
[9869]31#include "loading/fast_factory.h"
[4287]32
[10114]33
34ObjectListDefinition(LaserCannon);
[9869]35CREATE_FACTORY(LaserCannon);
[3618]36
[9131]37LaserCannon::LaserCannon(const TiXmlElement* root)
[4972]38{
39  this->init();
[7084]40  if (root != NULL)
41    this->loadParams(root);
[4972]42}
43
44/**
45 *  standard deconstructor
46*/
[9131]47LaserCannon::~LaserCannon ()
[4972]48{
49  // model will be deleted from WorldEntity-destructor
50}
51
52
[9131]53void LaserCannon::init()
[4972]54{
[9869]55  this->registerObject(this, LaserCannon::_objectList);
[4972]56
[9131]57//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/laser_cannon.obj", OBJ, RP_CAMPAIGN);
[4972]58
[9159]59  this->loadModel("models/guns/lasercannon.obj", 5.0f);
[5053]60
[5457]61  this->setStateDuration(WS_SHOOTING, .1);
62  this->setStateDuration(WS_RELOADING, .1);
[4910]63  this->setStateDuration(WS_ACTIVATING, .4);
64  this->setStateDuration(WS_DEACTIVATING, .4);
[4885]65
[9002]66  this->setEnergyMax(10000);
67  this->increaseEnergy(10000);
[4927]68  //this->minCharge = 2;
[4885]69
[5819]70  this->setActionSound(WA_SHOOT, "sound/laser.wav");
71  this->setActionSound(WA_ACTIVATE, "sound/voices/lasers.wav");
[4934]72
[5819]73
[5441]74  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
[9869]75  this->setProjectileTypeC("RailProjectile");
[8983]76  this->prepareProjectiles(100);
[9159]77  this->setEmissionPoint(Vector(2.8,0,0) * 5.0);
[3683]78}
[3618]79
80
[9131]81void LaserCannon::loadParams(const TiXmlElement* root)
[3618]82{
[6512]83  Weapon::loadParams(root);
[4972]84
[3618]85}
86
87
88/**
[4836]89 *  this activates the weapon
[3618]90
[4592]91   This is needed, since there can be more than one weapon on a ship. the
92   activation can be connected with an animation. for example the weapon is
93   been armed out.
[3618]94*/
[9131]95void LaserCannon::activate()
[3980]96{
97}
[3618]98
99
100/**
[4836]101 *  this deactivates the weapon
[3618]102
[4592]103   This is needed, since there can be more than one weapon on a ship. the
104   activation can be connected with an animation. for example the weapon is
[3618]105   been armed out.
106*/
[9131]107void LaserCannon::deactivate()
[3980]108{
109}
[3618]110
111
112/**
[4836]113 *  fires the weapon
[4592]114
[3618]115   this is called from the player.cc, when fire-button is been pushed
[4836]116   @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
[3618]117*/
[9131]118void LaserCannon::fire()
[3620]119{
[5356]120  Projectile* pj =  this->getProjectile();
121  if (pj == NULL)
122    return;
[3888]123
[9656]124  // make this to let the onKill(...) fuction get the stuff
125  pj->setOwner(this->getOwner());
126
[6074]127  pj->setParent(PNode::getNullParent());
[5000]128
[6162]129  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5));
[4955]130
[4927]131  pj->setAbsCoor(this->getEmissionPoint());
[3708]132  pj->setAbsDir(this->getAbsDir());
[5443]133  pj->activate();
[3620]134}
Note: See TracBrowser for help on using the repository browser.