CheckArmorType: Difference between revisions

From ZDoom Wiki
Jump to navigation Jump to search
Content deleted Content added
Formatting
 
Line 2: Line 2:
__NOTOC__
__NOTOC__


'''{{class|Actor}}'''
bool '''CheckArmorType'''(name ''Type''[, int ''amount''])

{{c|bool '''CheckArmorType'''(name ''Type'', int ''amount'' }}={{c| 1)}}


== Usage ==
== Usage ==
Line 8: Line 10:


=== Parameters ===
=== Parameters ===
*{{c|Name '''Type'''}}
*''Type'' - The name of the armor class to check for.
:The name of the armor class to check for.
*''amount'' - Default is 1. The minimum amount of armor needed.
*{{c|int '''amount'''}}
:Default is 1. The minimum amount of armor needed.


=== Return value ===
=== Return value ===
Line 17: Line 21:
{{noexamples}}
{{noexamples}}


== Internal Code ==
== [[ZScript]] definition ==
{{ZScriptDefinitionNote|actors/checks.zs#L111}}
bool CheckArmorType(name Type, int amount = 1)
<syntaxhighlight lang="csharp">
{
bool CheckArmorType(name Type, int amount = 1)
let myarmor = BasicArmor(FindInventory("BasicArmor"));
{
return myarmor != null && myarmor.ArmorType == type && myarmor.Amount >= amount;
let myarmor = BasicArmor(FindInventory("BasicArmor"));
}
return myarmor != null && myarmor.ArmorType == type && myarmor.Amount >= amount;
}</syntaxhighlight>


[[Category:ZScript]]
[[Category:ZScript]]

Latest revision as of 18:13, 8 April 2024

Note: This feature is for ZScript only.


Actor

bool CheckArmorType(name Type, int amount = 1)

Usage

Checks to see if the Actor has a certain amount of the provided armor type.

Parameters

  • Name Type
The name of the armor class to check for.
  • int amount
Default is 1. The minimum amount of armor needed.

Return value

Returns true if the Actor has the correct armor type with at least the amount provided.

Examples

Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.


ZScript definition

Note: The ZScript definition below is for reference and may be different in the current version of UZDoom. The most up-to-date version of this code can be found on UZDoom GitHub.
bool CheckArmorType(name Type, int amount = 1)
{
    let myarmor = BasicArmor(FindInventory("BasicArmor"));
    return myarmor != null && myarmor.ArmorType == type && myarmor.Amount >= amount;
}