GetArmorType

From ZDoom Wiki
Jump to: navigation, search

int GetArmorType (string armortype, int playernum)

Returns true if the player's armor type matches the first parameter.

Parameters

  • armortype: The class name of an armor type. This must be either “None”, the name of a BasicArmorPickup or that of a BasicArmorBonus.
  • playernum: Player number. This information can be obtained through PlayerNumber.

This function targets only players. It concerns only BasicArmor and therefore does not cover HexenArmor.

Return value

The return value is the number of armor points if the player wears the designated armor, 0 otherwise.

Examples

This script constantly informs the first player which kind of Doom armor he is wearing.

str armor_types[5] = {
  "None",
  "ArmorBonus",
  "GreenArmor",
  "BlueArmor",
  "BlueArmorForMegasphere",
};

str armor_messages[6] = {
  "You are unarmored.",
  "You are unarmored, but have found armor bonuses.",
  "You are wearing security armor.",
  "You are wearing combat armor.",
  "You have a megasphere.",
  "What the hell are you wearing?"
};

function void PrintArmorType (void)
{
  bool found_armor = FALSE;

  for (i=0; i<5; i++)
  {
    if (GetArmorType(armor_types[i], PlayerNumber()))
    {
      found_armor = TRUE;
      break;
    }
  }

  if (found_armor)
  {
    HUDMessage(s:armor_messages[i]; HUDMSG_PLAIN, 1, CR_RED, 0.1, 0.9, 1.0);
  }
  else
  {
    HUDMessage(s:armor_messages[5]; HUDMSG_PLAIN, 1, CR_RED, 0.1, 0.9, 1.0);
  }
}

script 1 ENTER
{
  while (TRUE)
  {
    PrintArmorType();
    delay(35);
  }
}
Personal tools
Namespaces
Variants
Actions
Navigation
ACS
DECORATE
ZDoom mods
Toolbox