Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/weapons/hyperblaster.cc @ 8097

Last change on this file since 8097 was 7193, checked in by bensch, 19 years ago

orxonox/trunk: new style for resources (prework/movement)

File size: 4.4 KB
RevLine 
[3618]1
2
[4592]3/*
[3618]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
[6810]14   main-programmer: Benjamin Grauer
[4592]15   co-programmer:
[3631]16
17
[4836]18   @todo: direction in which the projectile flights
19   @todo: a target to set/hit
[3618]20*/
[5357]21#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
[3618]22
[6810]23#include "hyperblaster.h"
[3618]24
25#include "world_entity.h"
[3677]26#include "model.h"
[6434]27#include "world_entities/projectiles/projectile.h"
[4955]28#include "weapon_manager.h"
[7193]29#include "util/loading/factory.h"
[3618]30
[3851]31#include "animation3d.h"
[3618]32
[4940]33#include "fast_factory.h"
[4287]34
[4931]35
[3618]36using namespace std;
37
[6810]38CREATE_FACTORY(Hyperblaster, CL_HYPERBLASTER);
[3618]39
[6810]40Hyperblaster::Hyperblaster(const TiXmlElement* root)
[3683]41{
[4974]42  this->init();
[6517]43  if (root != NULL)
44    this->loadParams(root);
[4972]45}
46
47/**
48 *  standard deconstructor
49*/
[6810]50Hyperblaster::~Hyperblaster ()
[4972]51{
52  // model will be deleted from WorldEntity-destructor
53}
54
55
[6810]56void Hyperblaster::init()
[4972]57{
[6810]58  this->setClassID(CL_HYPERBLASTER, "Hyperblaster");
[4972]59
[5053]60//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN);
[4972]61
[6803]62  this->loadModel("models/guns/plasmadriver_#.obj", 2.0);
[5053]63
[5744]64  this->setStateDuration(WS_SHOOTING, 2.0);
[6810]65  this->setStateDuration(WS_RELOADING, 5.0);
[6811]66  this->setStateDuration(WS_ACTIVATING, .8);
67  this->setStateDuration(WS_DEACTIVATING, .8);
[4885]68
[7076]69  this->setEnergyMax(5000);
70  this->increaseEnergy(5000);
[4927]71  //this->minCharge = 2;
[4885]72
[7045]73  this->setActionSound(WA_SHOOT, "sound/explosions/explosion_4.wav");
74  this->setActionSound(WA_ACTIVATE, "sound/powerups/whats this2.wav");
75  this->setActionSound(WA_RELOAD, "sound/spawn/alien_generator.wav");
[4934]76
[6803]77  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_HEAVY);
[6810]78  this->setProjectileType(CL_HYPERBLAST);
79  this->prepareProjectiles(2);
[5457]80
[5623]81//  this->objectComponent1 = new PNode();
82//  Animation3D* animation1 = this->getAnimation(WS_SHOOTING, this->objectComponent1);
83  Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this);
84  Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this);
85  //parent->addChild(this->objectComponent1, PNODE_ALL);
86//  this->addChild(this->objectComponent1);
87
88//  animation1->setInfinity(ANIM_INF_CONSTANT);
89  animation2->setInfinity(ANIM_INF_CONSTANT);
90  animation3->setInfinity(ANIM_INF_CONSTANT);
91
92  this->setEmissionPoint(3.8, 1.2, 0);
93
94//     animation1->addKeyFrame(Vector(0, -1.5, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
95//     animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
96//     animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL);
97
[6811]98  animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
99  animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL);
[5623]100
[6811]101  animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL);
102  animation3->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
[3683]103}
[3618]104
105
[6810]106void Hyperblaster::loadParams(const TiXmlElement* root)
[3618]107{
[6512]108  Weapon::loadParams(root);
[3618]109}
110
111
112/**
[4836]113 *  this activates the weapon
[3618]114
[4592]115   This is needed, since there can be more than one weapon on a ship. the
116   activation can be connected with an animation. for example the weapon is
117   been armed out.
[3618]118*/
[6810]119void Hyperblaster::activate()
[3980]120{
121}
[3618]122
123
124/**
[4836]125 *  this deactivates the weapon
[3618]126
[4592]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
[3618]129   been armed out.
130*/
[6810]131void Hyperblaster::deactivate()
[3980]132{
133}
[3618]134
135
136/**
[4836]137 *  fires the weapon
[4592]138
[3618]139   this is called from the player.cc, when fire-button is been pushed
[4836]140   @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
[3618]141*/
[6810]142void Hyperblaster::fire()
[3620]143{
[5356]144  Projectile* pj =  this->getProjectile();
145  if (pj == NULL)
146    return;
[3888]147
[6074]148  pj->setParent(PNode::getNullParent());
[5000]149
[5744]150  pj->setVelocity(this->getVelocity() + this->getAbsDir().apply(Vector(1,0,0))*15+VECTOR_RAND(5));
[4955]151
[4927]152  pj->setAbsCoor(this->getEmissionPoint());
[3708]153  pj->setAbsDir(this->getAbsDir());
[5443]154  pj->activate();
[3620]155}
[3618]156
157/**
[4836]158 *  is called, when the weapon is destroyed
[5498]159 *
160 * this is in conjunction with the hit function, so when a weapon is able to get
161 * hit, it can also be destoryed.
[3618]162*/
[6810]163void Hyperblaster::destroy ()
[3618]164{}
Note: See TracBrowser for help on using the repository browser.