Beispiel #1
0
//
// EV_canUnlockGenDoor()
//
// Passed a generalized locked door linedef and a player, returns whether
// the player has the keys necessary to unlock that door.
//
// Note: The linedef passed MUST be a generalized locked door type
//       or results are undefined.
//
// jff 02/05/98 routine added to test for unlockability of
//  generalized locked doors
//
// killough 11/98: reformatted
//
// haleyjd 08/22/00: fixed bug found by fraggle
//
static bool EV_canUnlockGenDoor(line_t *line, player_t *player)
{
   int lockdefID = EV_lockdefIDForGenSpec(line->special);

   itemeffect_t *yskull = E_ItemEffectForName(ARTI_YELLOWSKULL);
   bool hasYellowSkull  = (E_GetItemOwnedAmount(player, yskull) > 0);

   // MBF compatibility hack - if lockdef ID is ALL3 and the player has the 
   // YellowSkull, we have to take it away; if he doesn't have it, we have to 
   // give it.
   if(demo_version == 203 && lockdefID == EV_LOCKDEF_ALL3)
   {
      if(hasYellowSkull)
         E_RemoveInventoryItem(player, yskull, -1);
      else
         E_GiveInventoryItem(player, yskull);
   }

   bool result = E_PlayerCanUnlock(player, lockdefID, false);

   // restore inventory state if lockdef was ALL3 and playing back an MBF demo
   if(demo_version == 203 && lockdefID == EV_LOCKDEF_ALL3)
   {
      if(hasYellowSkull)
         E_GiveInventoryItem(player, yskull);
      else
         E_RemoveInventoryItem(player, yskull, -1);
   }

   return result;
}
Beispiel #2
0
static void cheat_keyxx(const void *arg)
{
   int key = *(const int *)arg;
   const char *msg = NULL;

   if(key >= GameModeInfo->numHUDKeys)
      return;

   itemeffect_t *fx;
   if(!(fx = E_ItemEffectForName(GameModeInfo->cardNames[key])))
      return;

   if(!E_GetItemOwnedAmount(plyr, fx))
   {
      E_GiveInventoryItem(plyr, fx);
      msg = "Key Added"; // Ty 03/27/98 - *not* externalized
   }
   else
   {
      E_RemoveInventoryItem(plyr, fx, -1);
      msg = "Key Removed";
   }

   doom_printf("%s", msg);
}
Beispiel #3
0
static void cheat_ammox(const void *arg)
{
   const char *buf = (const char *)arg;
   int a = *buf - '1';

   if(*buf == 'b')
   {
      if(!E_PlayerHasBackpack(plyr))
      {
         doom_printf("Backpack Added");
         E_GiveBackpack(plyr);
      }
      else
      {
         doom_printf("Backpack Removed");
         E_RemoveBackpack(plyr);
      }
   }
   else if(a >= 0 && a < NUMAMMO)
   { 
      // haleyjd 10/24/09: altered behavior:
      // * Add ammo if ammo is not at maxammo.
      // * Remove ammo otherwise.
      auto item = E_ItemEffectForName(cheat_AmmoForNum[a]);
      if(!item)
         return;

      int amount    = E_GetItemOwnedAmount(plyr, item);
      int maxamount = E_GetMaxAmountForArtifact(plyr, item);

      if(amount != maxamount)
      {
         E_GiveInventoryItem(plyr, item, maxamount);
         doom_printf("Ammo Added");
      }
      else
      {
         E_RemoveInventoryItem(plyr, item, -1);
         doom_printf("Ammo Removed");
      }
   }
}
Beispiel #4
0
//
// Give a player a weapon if they don't own it
//
void E_GiveWeapon(player_t *player, const weaponinfo_t *weapon)
{
   if(!E_PlayerOwnsWeapon(player, weapon))
      E_GiveInventoryItem(player, weapon->tracker);
}