From b87eb96ad9adfa8fc569841df5aa3fd35e8e1405 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 12 Nov 2017 02:03:23 +0100 Subject: Add F_GetAmmoType global function, counterpart to F_GetWeaponType for ammunitions Both functions have now been updated to only check the subtype if the item type is correct (IT_AMMO for F_GetAmmoType, IT_WEAPON for F_GetWeaponType) Signed-off-by: Haru --- npc/other/Global_Functions.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'npc/other') diff --git a/npc/other/Global_Functions.txt b/npc/other/Global_Functions.txt index cb41abcd7..360fb9e2e 100644 --- a/npc/other/Global_Functions.txt +++ b/npc/other/Global_Functions.txt @@ -237,6 +237,9 @@ function script F_Load2Skills { //== Function F_GetWeaponType ============================== // Determines weapon type by subtype function script F_GetWeaponType { + if (getiteminfo(getarg(0), ITEMINFO_TYPE) != IT_WEAPON) + return "Not a weapon"; + switch (getiteminfo(getarg(0), ITEMINFO_SUBTYPE)) { case W_DAGGER: return "Dagger"; break; case W_1HSWORD: return "One-handed Sword"; break; @@ -260,11 +263,33 @@ function script F_GetWeaponType { case W_SHOTGUN: return "Shotgun"; break; case W_GRENADE: return "Grenade Launcher"; break; case W_HUUMA: return "Shuriken"; break; + case W_2HSTAFF: return "Two-handed Staff"; break; default: return "Unable to Determine Equip Type"; break; } end; } +//== Function F_GetAmmoType ================================ +// Determines ammunition type by subtype +function script F_GetAmmoType { + if (getiteminfo(getarg(0), ITEMINFO_TYPE) != IT_AMMO) + return "Not an ammunition"; + + switch (getiteminfo(getarg(0), ITEMINFO_SUBTYPE)) { + case A_ARROW: return "Arrow"; break; + case A_DAGGER: return "Throwing Dagger"; break; + case A_BULLET: return "Bullet"; break; + case A_SHELL: return "Shell"; break; + case A_GRENADE: return "Grenade"; break; + case A_SHURIKEN: return "Huuma Shuriken"; break; + case A_KUNAI: return "Kunai"; break; + case A_CANNONBALL: return "Cannon Ball"; break; + case A_THROWWEAPON: return "Throwing Weapon"; break; + default: return "Unable to Determine Ammunition Type"; break; + } + end; +} + //== Function F_GetArmorType =============================== // Determines equipment type by equip location function script F_GetArmorType { -- cgit v1.2.3-60-g2f50