Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5441 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Oct 27, 2005, 11:46:46 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Weapons update, Now one can really assign SlotCapabilities and they are used and checked

Location:
trunk/src/world_entities
Files:
6 edited

Legend:

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

    r5440 r5441  
    136136
    137137  this->weaponMan->setSlotPosition(0, Vector(-2.6, .1, -3.0));
    138   this->weaponMan->setSlotCapability(0, WTYPE_ALLDIRS & WTYPE_DIRECTIONAL);
     138  this->weaponMan->setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    139139
    140140  this->weaponMan->setSlotPosition(1, Vector(-2.6, .1, 3.0));
    141   this->weaponMan->setSlotCapability(1, WTYPE_ALLDIRS & WTYPE_DIRECTIONAL);
     141  this->weaponMan->setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    142142
    143143  this->weaponMan->setSlotPosition(2, Vector(-1.5, .5, -.5));
  • trunk/src/world_entities/weapons/test_gun.cc

    r5382 r5441  
    134134  this->setActionSound(WA_SHOOT, "sound/shot1.wav");
    135135
     136  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    136137  this->setProjectileType(CL_TEST_BULLET);
    137138  this->prepareProjectiles(20);
  • trunk/src/world_entities/weapons/turret.cc

    r5440 r5441  
    9191  //this->minCharge = 2;
    9292
    93 
     93  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET);
    9494  this->setProjectileType(CL_TEST_BULLET);
    9595
  • trunk/src/world_entities/weapons/weapon.cc

    r5357 r5441  
    9494  this->energy = .0;
    9595  this->energyMax = 10.0;
     96  this->capability = WTYPE_ALL;
    9697
    9798  this->setWeaponManager(NULL);
  • trunk/src/world_entities/weapons/weapon.h

    r5356 r5441  
    106106
    107107    // FUNCTIONS TO SET THE WEAPONS PROPERTIES.
     108    /** sets the Weapons Capabilities */
     109    inline void setCapability(long capabilities) { this->capability = capabilities; };
     110    /** @returns the Capabilities of this Weapon */
     111    inline long getCapability() { return this->capability; };
    108112    void setProjectileType(ClassID projectile);
    109113    void setProjectileType(const char* projectile);
     
    185189
    186190  private:
     191    // type of Weapon
     192    long                 capability;                       //!< what capabilities the Weapon has @see W_Capability
     193
    187194    // it is all about energy
    188195    float                energy;                           //!< The energy stored in the weapons secondary buffers (reserve)
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r5440 r5441  
    229229  if (slotID == -1) // WM_FREE_SLOT
    230230  {
    231     slotID = this->getNextFreeSlot(configID);
     231    slotID = this->getNextFreeSlot(configID, weapon->getCapability());
    232232    if( slotID < 0 || slotID >= this->slotCount)
    233233    {
    234       PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
     234      PRINTF(1)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
    235235      return;
    236236    }
     237  }
     238
     239  if (!(this->currentSlotConfig[slotID].capability & weapon->getCapability() & WTYPE_ALLKINDS) &&
     240        this->currentSlotConfig[slotID].capability & weapon->getCapability() & WTYPE_ALLDIRS)
     241  {
     242    PRINTF(2)("Unable to add Weapon with wrong capatibility to Slot %d (W:%d M:%d)\n",
     243              slotID, weapon->getCapability(), this->currentSlotConfig[slotID].capability);
     244    return;
    237245  }
    238246
     
    407415  {
    408416    if( this->configs[configID][i] == NULL &&
    409         (this->currentSlotConfig[i].capability & capability == this->currentSlotConfig[i].capability))
     417        (this->currentSlotConfig[i].capability & capability & WTYPE_ALLKINDS) &&
     418        (this->currentSlotConfig[i].capability & capability & WTYPE_ALLDIRS))
    410419      return i;
    411420  }
Note: See TracChangeset for help on using the changeset viewer.