Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7350 in orxonox.OLD for trunk/src/world_entities/weapons


Ignore:
Timestamp:
Apr 19, 2006, 3:42:23 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: our first cheat :)

Location:
trunk/src/world_entities/weapons
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/weapons/aiming_turret.cc

    r7221 r7350  
    4848{
    4949  this->init();
    50   this->loadParams(root);
     50  if (root != NULL)
     51    this->loadParams(root);
    5152}
    5253
  • trunk/src/world_entities/weapons/weapon.cc

    r7221 r7350  
    2626#include "util/loading/resource_manager.h"
    2727#include "class_list.h"
     28#include "util/loading/factory.h"
    2829#include "util/loading/load_param.h"
    2930#include "state.h"
     
    3435
    3536#include "glgui_bar.h"
     37
     38using namespace std;
    3639
    3740////////////////////
     
    6669
    6770/**
     71 * @brief creates a new Weapon of type weaponID and returns it.
     72 * @param weaponID the WeaponID type to create.
     73 * @returns the newly created Weapon.
     74 */
     75Weapon* Weapon::createWeapon(ClassID weaponID)
     76{
     77  BaseObject* createdObject = Factory::fabricate(weaponID);
     78  if (createdObject != NULL)
     79  {
     80    if (createdObject->isA(CL_WEAPON))
     81      return dynamic_cast<Weapon*>(createdObject);
     82    else
     83    {
     84      delete createdObject;
     85      return NULL;
     86    }
     87  }
     88}
     89
     90/**
    6891 * initializes the Weapon with ALL default values
    6992 *
     
    7295void Weapon::init()
    7396{
     97  this->setClassID(CL_WEAPON, "Weapon");
    7498  this->currentState     = WS_INACTIVE;            //< Normaly the Weapon is Inactive
    7599  this->requestedAction  = WA_NONE;                //< No action is requested by default
     
    382406  switch (action)
    383407  {
    384   case WA_SHOOT:
    385     return this->fireW();
    386     break;
    387   case WA_CHARGE:
    388     return this->chargeW();
    389     break;
    390   case WA_RELOAD:
    391     return this->reloadW();
    392     break;
    393   case WA_DEACTIVATE:
    394     return this->deactivateW();
    395     break;
    396   case WA_ACTIVATE:
    397     return this->activateW();
    398     break;
     408    case WA_SHOOT:
     409      return this->fireW();
     410      break;
     411    case WA_CHARGE:
     412      return this->chargeW();
     413      break;
     414    case WA_RELOAD:
     415      return this->reloadW();
     416      break;
     417    case WA_DEACTIVATE:
     418      return this->deactivateW();
     419      break;
     420    case WA_ACTIVATE:
     421      return this->activateW();
     422      break;
    399423  }
    400424}
     
    495519  PRINTF(4)("Reloading Weapon %s\n", this->getName());
    496520  if (this->ammoContainer.get() != NULL &&
    497         unlikely(this->energy + this->ammoContainer->getStoredEnergy() < this->minCharge))
     521      unlikely(this->energy + this->ammoContainer->getStoredEnergy() < this->minCharge))
    498522  {
    499523    this->requestAction(WA_DEACTIVATE);
     
    643667  switch (action)
    644668  {
    645   case WA_SHOOT:
    646     return "shoot";
    647     break;
    648   case WA_CHARGE:
    649     return "charge";
    650     break;
    651   case WA_RELOAD:
    652     return "reload";
    653     break;
    654   case WA_ACTIVATE:
    655     return "activate";
    656     break;
    657   case WA_DEACTIVATE:
    658     return "deactivate";
    659     break;
    660   case WA_SPECIAL1:
    661     return "special1";
    662     break;
    663   default:
    664     return "none";
    665     break;
     669    case WA_SHOOT:
     670      return "shoot";
     671      break;
     672    case WA_CHARGE:
     673      return "charge";
     674      break;
     675    case WA_RELOAD:
     676      return "reload";
     677      break;
     678    case WA_ACTIVATE:
     679      return "activate";
     680      break;
     681    case WA_DEACTIVATE:
     682      return "deactivate";
     683      break;
     684    case WA_SPECIAL1:
     685      return "special1";
     686      break;
     687    default:
     688      return "none";
     689      break;
    666690  }
    667691}
     
    706730  switch (state)
    707731  {
    708   case WS_SHOOTING:
    709     return "shooting";
    710     break;
    711   case WS_CHARGING:
    712     return "charging";
    713     break;
    714   case WS_RELOADING:
    715     return "reloading";
    716     break;
    717   case WS_ACTIVATING:
    718     return "activating";
    719     break;
    720   case WS_DEACTIVATING:
    721     return "deactivating";
    722     break;
    723   case WS_IDLE:
    724     return "idle";
    725     break;
    726   case WS_INACTIVE:
    727     return "inactive";
    728     break;
    729   default:
    730     return "none";
    731     break;
    732   }
    733 }
     732    case WS_SHOOTING:
     733      return "shooting";
     734      break;
     735    case WS_CHARGING:
     736      return "charging";
     737      break;
     738    case WS_RELOADING:
     739      return "reloading";
     740      break;
     741    case WS_ACTIVATING:
     742      return "activating";
     743      break;
     744    case WS_DEACTIVATING:
     745      return "deactivating";
     746      break;
     747    case WS_IDLE:
     748      return "idle";
     749      break;
     750    case WS_INACTIVE:
     751      return "inactive";
     752      break;
     753    default:
     754      return "none";
     755      break;
     756  }
     757}
  • trunk/src/world_entities/weapons/weapon.h

    r7221 r7350  
    8888    Weapon ();
    8989    virtual ~Weapon ();
     90    static Weapon* createWeapon(ClassID weaponID);
    9091
    9192    void init();
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r7193 r7350  
    1717*/
    1818
    19 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
     19#define DEBUG_SPECIAL_MODULE 4 //DEBUG_MODULE_WEAPON
    2020
    2121#include "weapon_manager.h"
     
    113113
    114114/**
    115  * loads the settings of the WeaponManager
     115 * @brief loads the settings of the WeaponManager
    116116 * @param root the XML-element to load from
    117117 */
     
    133133
    134134/**
    135  * loads a Weapon onto the WeaponManager
     135 * @brief loads a Weapon onto the WeaponManager
    136136 * @param root the XML-element to load the Weapons from
    137137 */
     
    148148
    149149/**
    150  * sets the Parent of the WeaponManager.
     150 * @brief sets the Parent of the WeaponManager.
    151151 * @param parent the parent of the WeaponManager
    152152 *
     
    168168
    169169/**
    170  * sets the number of Slots the WeaponManager has
     170 * @brief sets the number of Slots the WeaponManager has
    171171 * @param slotCount the number of slots
    172172 */
     
    181181
    182182/**
    183  * sets the position of the Slot relative to the parent
     183 * @brief sets the position of the Slot relative to the parent
    184184 * @param slot the slot to set-up
    185185 * @param position the position of the given slot
     
    198198
    199199/**
    200  * sets the relative rotation of the slot to its parent
     200 * @brief sets the relative rotation of the slot to its parent
    201201 * @param slot the slot to set-up
    202202 * @param rotation the relative rotation of the given slot
     
    210210
    211211/**
    212  * adds a weapon to the selected weaponconfiguration into the selected slot
     212 * @brief adds a weapon to the selected weaponconfiguration into the selected slot
    213213 * @param weapon the weapon to add
    214214 * @param configID an identifier for the slot: number between 0..7 if not specified: slotID=next free slot
Note: See TracChangeset for help on using the changeset viewer.