[3573] | 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 | |
---|
| 19 | #include "weapon.h" |
---|
| 20 | #include "stdincl.h" |
---|
| 21 | #include "world_entity.h" |
---|
| 22 | #include "vector.h" |
---|
| 23 | #include "objModel.h" |
---|
[3575] | 24 | #include "projectile.h" |
---|
[3573] | 25 | |
---|
| 26 | using namespace std; |
---|
| 27 | |
---|
| 28 | |
---|
[3575] | 29 | /** |
---|
| 30 | \brief standard constructor |
---|
[3573] | 31 | |
---|
[3575] | 32 | creates a new weapon |
---|
| 33 | */ |
---|
[3573] | 34 | Weapon::Weapon () : WorldEntity() |
---|
| 35 | { |
---|
[3575] | 36 | this->model = new OBJModel(""); |
---|
[3573] | 37 | } |
---|
| 38 | |
---|
| 39 | |
---|
[3575] | 40 | /** |
---|
| 41 | \brief standard deconstructor |
---|
| 42 | */ |
---|
[3573] | 43 | Weapon::~Weapon () |
---|
| 44 | { |
---|
[3579] | 45 | // model will be deleted from WorldEntity-destructor |
---|
[3573] | 46 | } |
---|
| 47 | |
---|
| 48 | |
---|
[3577] | 49 | /** |
---|
| 50 | \brief enables the weapon |
---|
| 51 | |
---|
| 52 | a weapon can be enabled/disabled because of various reasons. if a weapon is |
---|
| 53 | been enabled, it can interact in a world. elswhere it wont react to any |
---|
| 54 | action. |
---|
| 55 | */ |
---|
| 56 | void Weapon::enable() |
---|
| 57 | {} |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | /** |
---|
| 61 | \brief disables the weapon |
---|
| 62 | |
---|
| 63 | a weapon can be enabled/disabled because of various reasons. if a weapon is |
---|
| 64 | been enabled, it can interact in a world. elswhere it wont react to any |
---|
| 65 | action. |
---|
| 66 | */ |
---|
| 67 | void Weapon::disable() |
---|
| 68 | {} |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | /** |
---|
| 72 | \brief checks if the weapon is enabled |
---|
| 73 | \returns true if enabled |
---|
| 74 | |
---|
| 75 | a weapon can be ebabled/disabled because of various reasons. if a weapon is |
---|
| 76 | been enabled, it can interact in a world. elswhere it wont react to any |
---|
| 77 | action. |
---|
| 78 | */ |
---|
| 79 | bool Weapon::isEnabled() |
---|
| 80 | {} |
---|
| 81 | |
---|
| 82 | |
---|
[3575] | 83 | /** |
---|
| 84 | \brief sets a new projectile to the weapon |
---|
| 85 | \param new projectile for this weapon |
---|
[3573] | 86 | |
---|
[3575] | 87 | weapon an projectile are independent, so you can combine them as you want |
---|
| 88 | */ |
---|
| 89 | void Weapon::setProjectile(Projectile* projectile) |
---|
| 90 | { |
---|
| 91 | this->projectile = projectile; |
---|
| 92 | } |
---|
[3573] | 93 | |
---|
| 94 | |
---|
[3575] | 95 | /** |
---|
| 96 | \brief sets a new projectile to the weapon |
---|
| 97 | \returns the current projectile of this weapon |
---|
| 98 | |
---|
| 99 | weapon an projectile are independent, so you can combine them as you want |
---|
| 100 | */ |
---|
| 101 | Projectile* Weapon::getProjectile() |
---|
| 102 | { |
---|
| 103 | return this->projectile; |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | /** |
---|
| 108 | \brief this activates the weapon |
---|
| 109 | |
---|
| 110 | This is needed, since there can be more than one weapon on a ship. the |
---|
| 111 | activation can be connected with an animation. for example the weapon is |
---|
| 112 | been armed out. |
---|
| 113 | */ |
---|
| 114 | void Weapon::activate() |
---|
| 115 | {} |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | /** |
---|
| 119 | \brief this deactivates the weapon |
---|
| 120 | |
---|
| 121 | This is needed, since there can be more than one weapon on a ship. the |
---|
| 122 | activation can be connected with an animation. for example the weapon is |
---|
| 123 | been armed out. |
---|
| 124 | */ |
---|
| 125 | void Weapon::deactivate() |
---|
| 126 | {} |
---|
| 127 | |
---|
| 128 | /** |
---|
| 129 | \brief asks if the current weapon is active |
---|
| 130 | \returns true if it the weapon is active |
---|
| 131 | */ |
---|
| 132 | bool Weapon::isActive() |
---|
| 133 | {} |
---|
| 134 | |
---|
| 135 | |
---|
[3576] | 136 | /** |
---|
| 137 | \brief this sets the energy of a weapon |
---|
| 138 | \param amount of energy |
---|
[3575] | 139 | |
---|
[3576] | 140 | a weapon has a limited amount of energy, this means a limited amount of shoots |
---|
| 141 | */ |
---|
| 142 | void Weapon::setWeaponEnergy(int energy) |
---|
| 143 | {} |
---|
[3575] | 144 | |
---|
[3576] | 145 | /** |
---|
| 146 | \brief adds weapon energy |
---|
| 147 | \param amount of energy |
---|
| 148 | \returns amount of energy, that is over the energy limit |
---|
[3575] | 149 | |
---|
[3576] | 150 | this can be used for energy-power up for example. There is a limited amount of energy |
---|
| 151 | a weapon can have. so if you want to add more, than it supports, the rest will |
---|
| 152 | be returned from this weapon. |
---|
| 153 | */ |
---|
| 154 | int Weapon::addWeaponEnergy(int addEnergy) |
---|
| 155 | {} |
---|
| 156 | |
---|
[3575] | 157 | /** |
---|
[3576] | 158 | \brief removes weapon energy |
---|
| 159 | \param amount of enery |
---|
| 160 | |
---|
| 161 | this is the case, when ther should be some sort of energy loss in the weapon |
---|
| 162 | system. propably wont be the case but usefull to have |
---|
| 163 | */ |
---|
| 164 | void Weapon::substractWeaponEnergy(int subEnergy) |
---|
| 165 | {} |
---|
| 166 | |
---|
| 167 | /** |
---|
| 168 | \brief gets the amount of energy of a weapon (= ammo) |
---|
| 169 | */ |
---|
| 170 | int Weapon::getWeaponEnergy() |
---|
| 171 | {} |
---|
| 172 | |
---|
| 173 | |
---|
| 174 | /** |
---|
[3577] | 175 | \brief fires the weapon |
---|
| 176 | |
---|
| 177 | this is called from the player.cc, when fire-button is been pushed |
---|
[3575] | 178 | */ |
---|
[3577] | 179 | void Weapon::fire() |
---|
[3575] | 180 | {} |
---|
| 181 | |
---|
[3577] | 182 | |
---|
[3575] | 183 | /** |
---|
| 184 | \brief is called, when the weapon gets hit (=collide with something) |
---|
| 185 | \param from which entity it is been hit |
---|
| 186 | \param where it is been hit |
---|
| 187 | |
---|
| 188 | this may not be used, since it would make the game relay complicated when one |
---|
| 189 | can destroy the weapons of enemies or vice versa. |
---|
| 190 | */ |
---|
[3578] | 191 | void Weapon::hit (WorldEntity* entity, Vector* position) |
---|
[3575] | 192 | {} |
---|
| 193 | |
---|
[3577] | 194 | |
---|
[3575] | 195 | /** |
---|
| 196 | \brief is called, when the weapon is destroyed |
---|
| 197 | |
---|
| 198 | this is in conjunction with the hit function, so when a weapon is able to get |
---|
| 199 | hit, it can also be destoryed. |
---|
| 200 | */ |
---|
| 201 | void Weapon::destroy () |
---|
| 202 | {} |
---|
| 203 | |
---|
| 204 | |
---|
| 205 | /** |
---|
[3577] | 206 | \brief tick signal for time dependent/driven stuff |
---|
| 207 | */ |
---|
| 208 | void Weapon::tick (float time) |
---|
| 209 | {} |
---|
| 210 | |
---|
| 211 | |
---|
| 212 | /** |
---|
[3575] | 213 | \brief this will draw the weapon |
---|
| 214 | */ |
---|
[3573] | 215 | void Weapon::draw () |
---|
| 216 | { |
---|
| 217 | glMatrixMode(GL_MODELVIEW); |
---|
| 218 | glPushMatrix(); |
---|
[3575] | 219 | |
---|
[3573] | 220 | float matrix[4][4]; |
---|
| 221 | glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); |
---|
| 222 | this->getAbsDir().matrix (matrix); |
---|
| 223 | glMultMatrixf((float*)matrix); |
---|
| 224 | this->model->draw(); |
---|
| 225 | |
---|
| 226 | glPopMatrix(); |
---|
| 227 | } |
---|
| 228 | |
---|