Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10108 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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