示例#1
0
static void ST_updateWidgets()
{
   // update ready weapon ammo
   auto weapon   = plyr->readyweapon;
   auto ammoType = weapon->ammo;

   w_ready.num = ammoType ? E_GetItemOwnedAmount(plyr, ammoType) : 1994;
   w_ready.max = E_GetMaxAmountForArtifact(plyr, ammoType);

   // update armor
   w_armor.n.num = plyr->armorpoints;

   // update health
   w_health.n.num = plyr->health;

   // update ammo widgets
   for(int i = 0; i < NUMAMMO; i++)
   {
      ammoType = E_ItemEffectForName(st_AmmoForNum[i]);
      
      w_ammo[i].num    = E_GetItemOwnedAmount(plyr, ammoType);
      w_maxammo[i].num = E_GetMaxAmountForArtifact(plyr, ammoType);      
   }

   // update keycard multiple widgets
   for(int i = 0; i < 3; i++)
   {
      int amount  = E_GetItemOwnedAmountName(plyr, GameModeInfo->cardNames[i]);
      keyboxes[i] = (amount > 0 ? i : -1);
      
      //jff 2/24/98 select double key
      //killough 2/28/98: preserve traditional keys by config option
      
      amount = E_GetItemOwnedAmountName(plyr, GameModeInfo->cardNames[i + 3]);
      if(amount > 0)
         keyboxes[i] = ((keyboxes[i] == -1 || sts_traditional_keys) ? i + 3 : i + 6);
   }

   // used by the w_armsbg widget
   st_notdeathmatch = (GameType != gt_dm);

   // used by w_arms[] widgets
   st_armson = st_statusbaron && GameType != gt_dm;

   // used by w_frags widget
   st_fragson = st_statusbaron && GameType == gt_dm;

   st_fragscount = plyr->totalfrags;     // sf 15/10/99 use totalfrags
   w_frags.num   = st_fragscount;

   // used by w_invbarbg widget
   st_invbar = plyr->invbarstate.inventory;
}
示例#2
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");
      }
   }
}