Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7069 was 7045, checked in by bensch, 19 years ago

orxonox/trunk: some samples

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