Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/playable.cc

    r7347 r7350  
    1616
    1717#include "playable.h"
    18 
    19 #include "weapons/weapon_manager.h"
    2018#include "event_handler.h"
     19
    2120#include "player.h"
    2221#include "state.h"
     
    2524#include "util/loading/load_param.h"
    2625
    27 #include "world_entities/projectiles/projectile.h"
    28 
    2926#include "power_ups/weapon_power_up.h"
    3027#include "power_ups/param_power_up.h"
     
    3835
    3936#include "effects/explosion.h"
     37
     38#include "shell_command.h"
     39SHELL_COMMAND(orxoWeapon, Playable, addSomeWeapons_CHEAT);
    4040
    4141
     
    122122 * @param slotID the slotID to add the Weapon to.
    123123 */
    124 void Playable::addWeapon(Weapon* weapon, int configID, int slotID)
    125 {
    126   this->weaponMan.addWeapon(weapon, configID, slotID);
    127 
    128   this->weaponConfigChanged();
     124bool Playable::addWeapon(Weapon* weapon, int configID, int slotID)
     125{
     126  if(this->weaponMan.addWeapon(weapon, configID, slotID))
     127  {
     128    this->weaponConfigChanged();
     129    return true;
     130  }
     131  else
     132  {
     133    if (weapon != NULL)
     134      PRINTF(2)("Unable to add Weapon (%s::%s) to %s::%s\n",
     135             weapon->getClassName(), weapon->getName(), this->getClassName(), this->getName());
     136    else
     137      PRINTF(2)("No weapon defined\n");
     138    return false;
     139
     140  }
    129141}
    130142
     
    170182}
    171183
     184/**
     185 * @brief a Cheat that gives us some Weapons
     186 */
     187void Playable::addSomeWeapons_CHEAT()
     188{
     189  PRINTF(2)("ADDING WEAPONS - you cheater\n");
     190  this->addWeapon(Weapon::createWeapon(CL_HYPERBLASTER));
     191  this->addWeapon(Weapon::createWeapon(CL_TURRET));
     192  this->addWeapon(Weapon::createWeapon(CL_AIMING_TURRET));
     193  this->addWeapon(Weapon::createWeapon(CL_CANNON));
     194  this->addWeapon(Weapon::createWeapon(CL_TARGETING_TURRET));
     195  PRINTF(2)("ADDING WEAPONS FINISHED\n");
     196}
    172197
    173198/**
  • trunk/src/world_entities/playable.h

    r7347 r7350  
    4343  // Weapon and Pickups
    4444  virtual bool pickup(PowerUp* powerUp);
    45   void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
     45  bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
    4646  void removeWeapon(Weapon* weapon);
    4747  void nextWeaponConfig();
     
    4949  inline WeaponManager& getWeaponManager() { return this->weaponMan; };
    5050  void weaponConfigChanged();
     51  void addSomeWeapons_CHEAT();
    5152
    5253
  • 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.