From ab1c84c8586b18ebb194d2f67120df7307399712 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 12 Nov 2017 01:46:40 +0100 Subject: Add type constants for the getiteminfo()/setiteminfo() buildins Replacements are as follows: 0 => ITEMINFO_BUYPRICE 1 => ITEMINFO_SELLPRICE 2 => ITEMINFO_TYPE 3 => ITEMINFO_MAXCHANCE 4 => ITEMINFO_SEX 5 => ITEMINFO_LOC 6 => ITEMINFO_WEIGHT 7 => ITEMINFO_ATK 8 => ITEMINFO_DEF 9 => ITEMINFO_RANGE 10 => ITEMINFO_SLOTS 11 (Subtype, for weapons and ammunitions) => ITEMINFO_SUBTYPE 11 (ViewSprite, for other item types) => ITEMINFO_VIEWSPRITE (NOT AVAILABLE YET) 12 => ITEMINFO_ELV 13 => ITEMINFO_WLV 14 => ITEMINFO_VIEWID 15 => ITEMINFO_MATK (NOT AVAILABLE YET - this was documented but never implemented) Calls to getiteminfo() and setiteminfo() have been replaced with the newly introduced constants. Other constants (such as W_ weapon subtypes) in related code have been replaced as well, to improve code readability. This fixes an issue in the Eden Tutorial script "Tutorial Goal", where ITEMINFO_ATK was accidentally used instead of ITEMINFO_WEIGHT. Note: calls to getiteminfo or setiteminfo with numeric type arguments in third party scripts must be replaced with the respective constants. The use of numeric literals is no longer recommended, and those values may change in the future without notice. See the getiteminfo documentation for details. Signed-off-by: Haru --- npc/custom/item_signer.txt | 2 +- npc/custom/itembind.txt | 12 ++--- npc/custom/quests/quest_shop.txt | 8 +-- npc/merchants/socket_enchant.txt | 9 ++-- npc/merchants/socket_enchant2.txt | 4 +- npc/other/Global_Functions.txt | 97 ++++++++++++++++++------------------ npc/other/monster_race.txt | 2 +- npc/quests/cooking_quest.txt | 4 +- npc/re/merchants/coin_exchange.txt | 2 +- npc/re/merchants/enchan_mal.txt | 42 +++++++++------- npc/re/quests/eden/eden_tutorial.txt | 6 +-- npc/re/quests/quests_dewata.txt | 2 +- 12 files changed, 97 insertions(+), 93 deletions(-) (limited to 'npc') diff --git a/npc/custom/item_signer.txt b/npc/custom/item_signer.txt index a0097bb55..6c12926e5 100644 --- a/npc/custom/item_signer.txt +++ b/npc/custom/item_signer.txt @@ -78,7 +78,7 @@ prt_in,24,61,7 script Perchik 1_M_01,{ emotion e_hmm; close; } - if (getiteminfo(.@id,10)) { + if (getiteminfo(.@id, ITEMINFO_SLOTS) > 0) { mes "Sorry, I don't sign slotted items."; emotion e_sry; close; diff --git a/npc/custom/itembind.txt b/npc/custom/itembind.txt index 8c51ad24d..7d95afdfc 100644 --- a/npc/custom/itembind.txt +++ b/npc/custom/itembind.txt @@ -35,14 +35,10 @@ prontera,144,174,4 script Bound Items 4_M_JP_MID,{ //Allows equipment (default) or non-rental item if (@inventorylist_bound[.@i] || @inventorylist_expire[.@i]) continue; - if (((.allowbind & 1) && (getiteminfo(@inventorylist_id[.@i], 2) == IT_WEAPON || getiteminfo(@inventorylist_id[.@i], 2) == IT_ARMOR)) || - ((.allowbind & 2) && - (getiteminfo(@inventorylist_id[.@i], 2) == IT_HEALING || getiteminfo(@inventorylist_id[.@i], 2) == IT_USABLE || - getiteminfo(@inventorylist_id[.@i], 2) == IT_DELAYCONSUME || getiteminfo(@inventorylist_id[.@i], 2) == IT_CASH)) || - ((.allowbind & 4) && - (getiteminfo(@inventorylist_id[.@i], 2) == IT_ETC || getiteminfo(@inventorylist_id[.@i], 2) == IT_CARD || - getiteminfo(@inventorylist_id[.@i], 2) == IT_PETEGG || getiteminfo(@inventorylist_id[.@i], 2) == IT_PETARMOR || - getiteminfo(@inventorylist_id[.@i], 2) == IT_AMMO)) + .@itemtype = getiteminfo(@inventorylist_id[.@i], ITEMINFO_TYPE); + if (((.allowbind & 1) != 0 && (.@itemtype == IT_WEAPON || .@itemtype == IT_ARMOR)) + || ((.allowbind & 2) != 0 && (.@itemtype == IT_HEALING || .@itemtype == IT_USABLE || .@itemtype == IT_DELAYCONSUME || .@itemtype == IT_CASH)) + || ((.allowbind & 4) != 0 && (.@itemtype == IT_ETC || .@itemtype == IT_CARD || .@itemtype == IT_PETEGG || .@itemtype == IT_PETARMOR || .@itemtype == IT_AMMO)) ) { set .@bindlist$, .@bindlist$ + ":" + getitemname(@inventorylist_id[.@i]) + " - " + @inventorylist_id[.@i]; set .@bindlist[.@j],.@i; diff --git a/npc/custom/quests/quest_shop.txt b/npc/custom/quests/quest_shop.txt index 6805220f7..739b53c02 100644 --- a/npc/custom/quests/quest_shop.txt +++ b/npc/custom/quests/quest_shop.txt @@ -121,8 +121,8 @@ OnBuyItem: if (.@q[6]) for(set .@i,6; .@i "+Chk(countitem(.@q[.@i]),.@q[.@i+1]*.@q[1])+((.ShowID)?"{"+.@q[.@i]+"} ":"")+Slot(.@q[.@i])+" ("+countitem(.@q[.@i])+"/"+(.@q[.@i+1]*.@q[1])+")^000000"; next; - setarray @qe[1], getiteminfo(.@q[0],5), getiteminfo(.@q[0],11); - if (@qe[2] > 0 && ((@qe[1] & 1) || (@qe[1] & 256) || (@qe[1] & 512) || (@qe[1] & 1024) || (@qe[1] & 2048) || (@qe[1] & 4096) || (@qe[1] & 4) || (@qe[1] & 8192))) + setarray @qe[1], getiteminfo(.@q[0], ITEMINFO_LOC), getiteminfo(.@q[0], ITEMINFO_VIEWSPRITE); + if (@qe[2] > 0 && ((@qe[1] & EQP_HEAD_LOW) || (@qe[1] & EQP_HEAD_TOP) || (@qe[1] & EQP_HEAD_MID) || (@qe[1] & EQP_COSTUME_HEAD_TOP) || (@qe[1] & EQP_COSTUME_HEAD_MID) || (@qe[1] & EQP_COSTUME_HEAD_LOW) || (@qe[1] & EQP_GARMENT) || (@qe[1] & EQP_COSTUME_GARMENT))) set .@preview,1; addtimer 1000, strnpcinfo(NPC_NAME)+"::OnEnd"; while(1) { @@ -135,7 +135,7 @@ OnBuyItem: } if (!checkweight(.@q[0],.@q[2])) { mes "[Quest Shop]"; - mes "^FF0000You need "+(((.@q[2]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000"; + mes "^FF0000You need "+(((.@q[2] * getiteminfo(.@q[0], ITEMINFO_WEIGHT)) + Weight - MaxWeight) / 10)+" additional weight capacity to complete this trade.^000000"; close; } if (.@q[4]) Zeny -= (.@q[4]*.@q[1]); @@ -198,7 +198,7 @@ function Slot { set .@s$,getitemname(getarg(0)); switch(.ShowSlot) { case 1: if (!getitemslots(getarg(0))) return .@s$; - case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return .@s$+" ["+getitemslots(getarg(0))+"]"; + case 2: if (getiteminfo(getarg(0), ITEMINFO_TYPE) == IT_WEAPON || getiteminfo(getarg(0), ITEMINFO_TYPE) == IT_ARMOR) return .@s$+" ["+getitemslots(getarg(0))+"]"; default: return .@s$; } } diff --git a/npc/merchants/socket_enchant.txt b/npc/merchants/socket_enchant.txt index 279aaf0ba..599d41564 100644 --- a/npc/merchants/socket_enchant.txt +++ b/npc/merchants/socket_enchant.txt @@ -268,17 +268,16 @@ function script Func_Socket { mes "Ah, and don't forget to bring that " + getitemname(getarg(0)) + "!"; next; mes "[Seiyablem]"; - if (getiteminfo(getarg(0),5)&2) // EQP_HAND_R = 2, it's a weapon - { + if (getiteminfo(getarg(0), ITEMINFO_LOC) & EQP_HAND_R) { + // EQP_HAND_R = 2, it's a weapon mes "I can try to add a slot now if you have the required items and zeny."; mes "However, you should know that there's a chance that I might fail."; mes "Therefore, I need to give you a fair warning..."; next; mes "[Seiyablem]"; mes "If this attempt to add a Slot to your Weapon fails, then the ^FF0000Weapon^000000, ^FF0000and any Cards compounded to it will be destroyed^000000."; - } - else // armor - { + } else { + // armor mes "If you have all the required materials, my zeny service fee and the Armor, then we can go ahead with the Slot Addition attempt."; mes "But before that, I must warn you of the risk."; next; diff --git a/npc/merchants/socket_enchant2.txt b/npc/merchants/socket_enchant2.txt index 98d33b01c..29573970d 100644 --- a/npc/merchants/socket_enchant2.txt +++ b/npc/merchants/socket_enchant2.txt @@ -425,8 +425,8 @@ function script Func_Socket2 { mes "[Leablem]"; mes "Did you already bring all of them?"; mes "For your information, if you fail to create a slot,"; - mes "you will lose all the item requirement as well as the target " + (getiteminfo(getarg(0),5)&2 ? "weapon" : "armor") + "."; // EQP_HAND_R = 2, it's a weapon, otherwise armor - mes "Also remember, if the " + (getiteminfo(getarg(0),5)&2 ? "weapon" : "armor") + " has been upgraded, and has been inserted with a card,"; + mes "you will lose all the item requirement as well as the target " + ((getiteminfo(getarg(0), ITEMINFO_LOC) & EQP_HAND_R) ? "weapon" : "armor") + "."; // EQP_HAND_R = 2, it's a weapon, otherwise armor + mes "Also remember, if the " + ((getiteminfo(getarg(0), ITEMINFO_LOC) & EQP_HAND_R) ? "weapon" : "armor") + " has been upgraded, and has been inserted with a card,"; mes "you will lose them even if you succeed in creating a slot."; next; switch(select("Ask for slot creation.", "Try next time.")) diff --git a/npc/other/Global_Functions.txt b/npc/other/Global_Functions.txt index 5a15ff1d2..cb41abcd7 100644 --- a/npc/other/Global_Functions.txt +++ b/npc/other/Global_Functions.txt @@ -235,31 +235,31 @@ function script F_Load2Skills { } //== Function F_GetWeaponType ============================== -// Determines weapon type by view +// Determines weapon type by subtype function script F_GetWeaponType { - switch(getiteminfo(getarg(0),11)) { - case 1: return "Dagger"; break; - case 2: return "One-handed Sword"; break; - case 3: return "Two-handed Sword"; break; - case 4: return "One-handed Spear"; break; - case 5: return "Two-handed Spear"; break; - case 6: return "One-handed Axe"; break; - case 7: return "Two-handed Axe"; break; - case 8: return "Mace"; break; - //case 9: return "Unused"; break; - case 10: return "Staff"; break; - case 11: return "Bow"; break; - case 12: return "Knuckle"; break; - case 13: return "Instrument"; break; - case 14: return "Whip"; break; - case 15: return "Book"; break; - case 16: return "Katar"; break; - case 17: return "Revolver"; break; - case 18: return "Rifle"; break; - case 19: return "Gatling gun"; break; - case 20: return "Shotgun"; break; - case 21: return "Grenade Launcher"; break; - case 22: return "Shuriken"; break; + switch (getiteminfo(getarg(0), ITEMINFO_SUBTYPE)) { + case W_DAGGER: return "Dagger"; break; + case W_1HSWORD: return "One-handed Sword"; break; + case W_2HSWORD: return "Two-handed Sword"; break; + case W_1HSPEAR: return "One-handed Spear"; break; + case W_2HSPEAR: return "Two-handed Spear"; break; + case W_1HAXE: return "One-handed Axe"; break; + case W_2HAXE: return "Two-handed Axe"; break; + case W_MACE: return "Mace"; break; + //case W_2HMACE: return "Two-handed Mace"; break; // Unused + case W_STAFF: return "Staff"; break; + case W_BOW: return "Bow"; break; + case W_KNUCKLE: return "Knuckle"; break; + case W_MUSICAL: return "Instrument"; break; + case W_WHIP: return "Whip"; break; + case W_BOOK: return "Book"; break; + case W_KATAR: return "Katar"; break; + case W_REVOLVER: return "Revolver"; break; + case W_RIFLE: return "Rifle"; break; + case W_GATLING: return "Gatling gun"; break; + case W_SHOTGUN: return "Shotgun"; break; + case W_GRENADE: return "Grenade Launcher"; break; + case W_HUUMA: return "Shuriken"; break; default: return "Unable to Determine Equip Type"; break; } end; @@ -268,30 +268,31 @@ function script F_GetWeaponType { //== Function F_GetArmorType =============================== // Determines equipment type by equip location function script F_GetArmorType { - switch(getiteminfo(getarg(0),5)) { - case 1: return "Lower Headgear"; break; - case 2: return callfunc("F_GetWeaponType", getarg(0)); break; - case 4: return "Garment"; break; - case 8: return "Accessory"; break; - case 16: return "Armor"; break; - case 32: return "Shield"; break; - case 64: return "Shoes"; break; - case 128: return "Accessory"; break; - case 136: return "Accessory"; break; - case 256: return "Upper Headgear"; break; - case 512: return "Middle Headgear"; break; - case 1024: return "Costume Upper Headgear"; break; - case 2048: return "Costume Midle Headgear"; break; - case 4096: return "Costume Lower Headgear"; break; - case 8192: return "Costume Garment"; break; - case 32768: return "Ammo"; break; - case 65536: return "Shadow Armor"; break; - case 131072: return "Shadow Weapon"; break; - case 262144: return "Shadow Shield"; break; - case 524288: return "Shadow Shoes"; break; - case 1048576: return "Shadow Accessory"; break; - case 2097152: return "Shadow Accessory"; break; - case 3145728: return "Shadow Accessory"; break; + switch (getiteminfo(getarg(0), ITEMINFO_LOC)) { + // FIXME + case EQP_HEAD_LOW: return "Lower Headgear"; break; + case EQP_HAND_R: return callfunc("F_GetWeaponType", getarg(0)); break; + case EQP_GARMENT: return "Garment"; break; + case EQP_ACC_L: return "Accessory"; break; + case EQP_ARMOR: return "Armor"; break; + case EQP_HAND_L: return "Shield"; break; + case EQP_SHOES: return "Shoes"; break; + case EQP_ACC_R: return "Accessory"; break; + case EQP_ACC: return "Accessory"; break; + case EQP_HEAD_TOP: return "Upper Headgear"; break; + case EQP_HEAD_MID: return "Middle Headgear"; break; + case EQP_COSTUME_HEAD_TOP: return "Costume Upper Headgear"; break; + case EQP_COSTUME_HEAD_MID: return "Costume Middle Headgear"; break; + case EQP_COSTUME_HEAD_LOW: return "Costume Lower Headgear"; break; + case EQP_COSTUME_GARMENT: return "Costume Garment"; break; + case EQP_AMMO: return "Ammo"; break; + case EQP_SHADOW_ARMOR: return "Shadow Armor"; break; + case EQP_SHADOW_WEAPON: return "Shadow Weapon"; break; + case EQP_SHADOW_SHIELD: return "Shadow Shield"; break; + case EQP_SHADOW_SHOES: return "Shadow Shoes"; break; + case EQP_SHADOW_ACC_R: return "Shadow Accessory"; break; + case EQP_SHADOW_ACC_L: return "Shadow Accessory"; break; + case EQP_SHADOW_ACC: return "Shadow Accessory"; break; default: return "Unknown Equip Type"; break; } end; diff --git a/npc/other/monster_race.txt b/npc/other/monster_race.txt index 9ddafeef5..9e938c663 100644 --- a/npc/other/monster_race.txt +++ b/npc/other/monster_race.txt @@ -2635,7 +2635,7 @@ S_BonusReward: mes "me a reward later?"; next; mes "[Ei'felle]"; - if (!getiteminfo(.@arg1,13)) { //use item level to determine if the item is armor (no weapon level) + if (!getiteminfo(.@arg1, ITEMINFO_WLV)) { // use item level to determine if the item is armor (no weapon level) mes "Of course, of course."; mes "Remember, if you donate"; mes "more medals to me, then"; diff --git a/npc/quests/cooking_quest.txt b/npc/quests/cooking_quest.txt index ad0306b2c..505561f52 100644 --- a/npc/quests/cooking_quest.txt +++ b/npc/quests/cooking_quest.txt @@ -2069,8 +2069,8 @@ prt_castle,45,35,5 script Madeleine Chu#cook 4_COOK,{ close; S_SellSets: - .@item_cost = getiteminfo(getarg(0),0); - .@item_weight = getiteminfo(getarg(0),6); + .@item_cost = getiteminfo(getarg(0), ITEMINFO_BUYPRICE); + .@item_weight = getiteminfo(getarg(0), ITEMINFO_WEIGHT); mes "[Madeleine Chu]"; mes "How many " + (getarg(0)==12125 ? "Outdoor":"Indoor"); mes "Cooking Kits would"; diff --git a/npc/re/merchants/coin_exchange.txt b/npc/re/merchants/coin_exchange.txt index be9f1dbee..f35c722f7 100644 --- a/npc/re/merchants/coin_exchange.txt +++ b/npc/re/merchants/coin_exchange.txt @@ -569,7 +569,7 @@ function script F_mal_coin { mes "I'm sorry, you need more "+.@str$+"."; close; } - if (MaxWeight - Weight < getiteminfo(getarg(3),6)) { + if (MaxWeight - Weight < getiteminfo(getarg(3), ITEMINFO_WEIGHT)) { mes getarg(1); mes "Sorry, you've purchased too many."; mes "You need to make more space in your inventory. Please come back later."; diff --git a/npc/re/merchants/enchan_mal.txt b/npc/re/merchants/enchan_mal.txt index bea4c6e03..e921a7336 100644 --- a/npc/re/merchants/enchan_mal.txt +++ b/npc/re/merchants/enchan_mal.txt @@ -84,11 +84,11 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ close; } @mal_equip_id = getequipid(EQI_HAND_R); - .@equip_type = getiteminfo(@mal_equip_id,11); + .@equip_type = getiteminfo(@mal_equip_id, ITEMINFO_SUBTYPE); //callsub L_Socket,,<4-x enchants possible>; switch(.@equip_type) { // Check weapon type first to speed up the checks. - case 1: // Daggers + case W_DAGGER: // Daggers switch(@mal_equip_id) { case 1224: callsub L_Socket,1,2; //Sword_Breaker case 1225: callsub L_Socket,1,2; //Mail_Breaker @@ -114,7 +114,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 13062: callsub L_Socket,4,2; //Ancient_Dagger } break; - case 16: // Katars + case W_KATAR: // Katars switch(@mal_equip_id) { case 1271: callsub L_Socket,1,2; //Blood_Tears case 1263: callsub L_Socket,1,2; //Unholy_Touch @@ -128,13 +128,13 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1266: callsub L_Socket,4,2; //Infiltrator_ } break; - case 6: // 1-H Axes + case W_1HAXE: // 1-H Axes switch(@mal_equip_id) { case 1305: callsub L_Socket,1,2; //Cleaver case 1311: callsub L_Socket,1,2; //Vecer_Axe } break; - case 7: // 2-H Axes + case W_2HAXE: // 2-H Axes switch(@mal_equip_id) { case 1364: callsub L_Socket,1,2; //Great_Axe case 1365: callsub L_Socket,1,2; //Sabbath @@ -151,7 +151,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1371: callsub L_Socket,4,2; //Doom_Slayer_ } break; - case 2: // 1-H Swords + case W_1HSWORD: // 1-H Swords switch(@mal_equip_id) { case 1131: callsub L_Socket,1,2; //Ice_Falchon case 1133: callsub L_Socket,1,2; //Fire_Brand @@ -170,7 +170,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1132: callsub L_Socket,4,2; //Edge } break; - case 3: // 2-H Swords + case W_2HSWORD: // 2-H Swords switch(@mal_equip_id) { case 1164: callsub L_Socket,1,2; //Muramasa case 1166: callsub L_Socket,1,2; //Dragon_Slayer @@ -194,7 +194,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1186: callsub L_Socket,4,2; //Death_Guidance } break; - case 4: // 1-H Spears + case W_1HSPEAR: // 1-H Spears switch(@mal_equip_id) { case 1420: callsub L_Socket,1,2; //Long_Horn case 1413: callsub L_Socket,1,2; //Gungnir @@ -207,7 +207,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1422: callsub L_Socket,4,2; //Hunting_Spear } break; - case 5: // 2-H Spears + case W_2HSPEAR: // 2-H Spears switch(@mal_equip_id) { case 1466: callsub L_Socket,1,2; //Crescent_Scythe case 1467: callsub L_Socket,1,2; //Bill_Guisarme @@ -224,7 +224,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1484: callsub L_Socket,2,2; //Cardo } break; - case 10: // Staves + case W_STAFF: // Staves switch(@mal_equip_id) { case 1616: callsub L_Socket,1,2; //Staff_Of_Wing case 1629: callsub L_Socket,1,2; //Walking_Stick @@ -236,7 +236,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1473: callsub L_Socket,1,2; //Wizardy_Staff } break; - case 23: // New 2-H Staves + case W_2HSTAFF: // New 2-H Staves switch(@mal_equip_id) { case 2004: callsub L_Socket,1,2; //Kronos case 2005: callsub L_Socket,1,2; //Dea_Staff @@ -244,7 +244,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 2000: callsub L_Socket,4,2; //Destruction_Rod } break; - case 8: // Maces + case W_MACE: // Maces switch(@mal_equip_id) { case 1524: callsub L_Socket,1,2; //Golden_Mace case 1525: callsub L_Socket,1,2; //Long_Mace @@ -261,7 +261,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1540: callsub L_Socket,4,2; //Grand_Cross_ } break; - case 15: // Books + case W_BOOK: // Books switch(@mal_equip_id) { case 1557: callsub L_Socket,1,2; //Book_Of_The_Apocalypse case 1558: callsub L_Socket,1,2; //Girls_Diary @@ -271,7 +271,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1565: callsub L_Socket,4,2; //Death_Note } break; - case 12: // Knuckles + case W_KNUCKLE: // Knuckles switch(@mal_equip_id) { case 1813: callsub L_Socket,1,2; //Kaiser_Knuckle case 1814: callsub L_Socket,1,2; //Berserk @@ -280,7 +280,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1830: callsub L_Socket,2,2; //Sura_Rampage } break; - case 11: // Bows + case W_BOW: // Bows switch(@mal_equip_id) { case 1719: callsub L_Socket,1,2; //Bow_Of_Roguemaster case 1722: callsub L_Socket,1,2; //Balistar @@ -295,7 +295,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1720: callsub L_Socket,2,2; //Bow_Of_Rudra } break; - case 13: // Musical Instruments + case W_MUSICAL: // Musical Instruments switch(@mal_equip_id) { case 1913: callsub L_Socket,1,2; //Electronic_Guitar case 1918: callsub L_Socket,1,2; //Oriental_Lute @@ -305,7 +305,7 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1930: callsub L_Socket,2,2; //Green_Whistle } break; - case 14: // Whips + case W_WHIP: // Whips switch(@mal_equip_id) { case 1962: callsub L_Socket,1,2; //Lariat case 1963: callsub L_Socket,1,2; //Rapture_Rose @@ -321,6 +321,14 @@ malangdo,213,167,4 script Mayomayo#mal 4_CAT_3COLOR,{ case 1985: callsub L_Socket,4,2; //Rosebine } break; + case W_2HMACE: + case W_REVOLVER: + case W_RIFLE: + case W_GATLING: + case W_SHOTGUN: + case W_GRENADE: + case W_HUUMA: + break; } mes "[Mayomayo]"; if (@mal_enchant_select == 1) diff --git a/npc/re/quests/eden/eden_tutorial.txt b/npc/re/quests/eden/eden_tutorial.txt index 45d7c6f1e..902db7945 100644 --- a/npc/re/quests/eden/eden_tutorial.txt +++ b/npc/re/quests/eden/eden_tutorial.txt @@ -290,7 +290,7 @@ moc_para01,34,178,3 script Tutorial Instructor 4_M_KHMAN,{ close; } else if (questprogress(9168) == 1) { if (checkweight(Yggdrasilberry,1) == 0) { - if (MaxWeight - Weight < getiteminfo(607,6)) { + if (MaxWeight - Weight < getiteminfo(Yggdrasilberry, ITEMINFO_WEIGHT)) { mes "[Tutorial Instructor]"; mes "You seemed to be sluggish with a lot of items"; mes "in your inventory making you heavy..."; @@ -492,7 +492,7 @@ moc_para01,34,178,3 script Tutorial Instructor 4_M_KHMAN,{ } } if (checkweight(Yggdrasilberry,6) == 0) { - if (MaxWeight - Weight < getiteminfo(607,6)) { + if (MaxWeight - Weight < getiteminfo(Yggdrasilberry, ITEMINFO_WEIGHT)) { mes "[Tutorial Instructor]"; mes "Your inventory seems to be really full"; mes "with various stuff... Do you think"; @@ -591,7 +591,7 @@ moc_para01,34,178,3 script Tutorial Instructor 4_M_KHMAN,{ moc_para01,32,179,4 script Tutorial Goal 4_F_KHELLY,{ if (checkweight(Seed_Of_Yggdrasil,7) == 0) { - if (MaxWeight - Weight < getiteminfo(608,7)) { + if (MaxWeight - Weight < getiteminfo(Seed_Of_Yggdrasil, ITEMINFO_WEIGHT)) { mes "[Tutorial Goal]"; mes "You seem to be overweight with items. Go put some stuff away then come back."; close; diff --git a/npc/re/quests/quests_dewata.txt b/npc/re/quests/quests_dewata.txt index ef1352e1e..1b57e4397 100644 --- a/npc/re/quests/quests_dewata.txt +++ b/npc/re/quests/quests_dewata.txt @@ -191,7 +191,7 @@ dew_in01,22,48,3 script Sage Kasyapa#dew 4_M_DEWZATIMAN,{ mes "Please, it would honor us if you would take it."; next; if (checkweight(Cendrawasih_SF,1) == 0) { - if (Weight + getiteminfo(6406,6) > MaxWeight) { + if (Weight + getiteminfo(Cendrawasih_SF, ITEMINFO_WEIGHT) > MaxWeight) { mes "[Sage Kasyapa]"; mes "You are carrying too much weight over the limit."; mes "I cannot get you your reward unless you reduce the amount of weighty items you are carrying."; -- cgit v1.2.3-60-g2f50 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') 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 From 42248822bf5348c7cbf33efbdf12873bea11ff38 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 12 Nov 2017 02:26:24 +0100 Subject: Rewrite F_GetArmorType to reflect the fact that ITEMINFO_LOC returns a bitmask The function now handles multi-slot headgears and other uncommon cases better. Signed-off-by: Haru --- npc/other/Global_Functions.txt | 99 ++++++++++++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 27 deletions(-) (limited to 'npc') diff --git a/npc/other/Global_Functions.txt b/npc/other/Global_Functions.txt index 360fb9e2e..9882e9d71 100644 --- a/npc/other/Global_Functions.txt +++ b/npc/other/Global_Functions.txt @@ -293,34 +293,79 @@ function script F_GetAmmoType { //== Function F_GetArmorType =============================== // Determines equipment type by equip location function script F_GetArmorType { - switch (getiteminfo(getarg(0), ITEMINFO_LOC)) { - // FIXME - case EQP_HEAD_LOW: return "Lower Headgear"; break; - case EQP_HAND_R: return callfunc("F_GetWeaponType", getarg(0)); break; - case EQP_GARMENT: return "Garment"; break; - case EQP_ACC_L: return "Accessory"; break; - case EQP_ARMOR: return "Armor"; break; - case EQP_HAND_L: return "Shield"; break; - case EQP_SHOES: return "Shoes"; break; - case EQP_ACC_R: return "Accessory"; break; - case EQP_ACC: return "Accessory"; break; - case EQP_HEAD_TOP: return "Upper Headgear"; break; - case EQP_HEAD_MID: return "Middle Headgear"; break; - case EQP_COSTUME_HEAD_TOP: return "Costume Upper Headgear"; break; - case EQP_COSTUME_HEAD_MID: return "Costume Middle Headgear"; break; - case EQP_COSTUME_HEAD_LOW: return "Costume Lower Headgear"; break; - case EQP_COSTUME_GARMENT: return "Costume Garment"; break; - case EQP_AMMO: return "Ammo"; break; - case EQP_SHADOW_ARMOR: return "Shadow Armor"; break; - case EQP_SHADOW_WEAPON: return "Shadow Weapon"; break; - case EQP_SHADOW_SHIELD: return "Shadow Shield"; break; - case EQP_SHADOW_SHOES: return "Shadow Shoes"; break; - case EQP_SHADOW_ACC_R: return "Shadow Accessory"; break; - case EQP_SHADOW_ACC_L: return "Shadow Accessory"; break; - case EQP_SHADOW_ACC: return "Shadow Accessory"; break; - default: return "Unknown Equip Type"; break; + switch (getiteminfo(getarg(0), ITEMINFO_TYPE)) { + case IT_WEAPON: + return callfunc("F_GetWeaponType", getarg(0)); + case IT_AMMO: + return callfunc("F_GetAmmoType", getarg(0)); + case IT_ARMOR: + break; + default: + return "Unknown Equip Type"; } - end; + + .@loc = getiteminfo(getarg(0), ITEMINFO_LOC); + + if ((.@loc & EQP_HELM) != 0) { + .@name$ = ""; + if ((.@loc & EQP_HEAD_TOP) != 0) { + .@name$ += "Top"; + } + if ((.@loc & EQP_HEAD_MID) != 0) { + if ((.@loc & EQP_HEAD_TOP) != 0) + .@name$ += " + "; + .@name$ += "Middle"; + } + if ((.@loc & EQP_HEAD_LOW) != 0) { + if ((.@loc & (EQP_HEAD_TOP | EQP_HEAD_MID)) != 0) + .@name$ += " + "; + .@name$ += "Lower"; + } + .@name$ += " Headgear"; + return .@name$; + } + if ((.@loc & EQP_GARMENT) != 0) + return "Garment"; + if ((.@loc & EQP_ACC) != 0) + return "Accessory"; + if ((.@loc & EQP_ARMOR) != 0) + return "Armor"; + if ((.@loc & EQP_SHIELD) != 0) + return "Shield"; + if ((.@loc & EQP_SHOES) != 0) + return "Shoes"; + if ((.@loc & EQP_COSTUE_GARMENT) != 0) + return "Costume Garment"; + if ((.@loc & EQP_COSTUME) != 0) { + .@name = "Costume "; + if ((.@loc & EQP_COSTUME_HEAD_TOP) != 0) { + .@name$ += "Top"; + } + if ((.@loc & EQP_COSTUME_HEAD_MID) != 0) { + if ((.@loc & EQP_COSTUME_HEAD_TOP) != 0) + .@name$ += " + "; + .@name$ += "Middle"; + } + if ((.@loc & EQP_COSTUME_HEAD_LOW) != 0) { + if ((.@loc & (EQP_COSTUME_HEAD_TOP | EQP_COSTUME_HEAD_MID)) != 0) + .@name$ += " + "; + .@name$ += "Lower"; + } + .@name$ += " Headgear"; + return .@name$; + } + if ((.@loc & EQP_SHADOW_ARMOR) != 0) + return "Shadow Armor"; + if ((.@loc & EQP_SHADOW_WEAPON) != 0) + return "Shadow Weapon"; + if ((.@loc & EQP_SHADOW_SHIELD) != 0) + return "Shadow Shield"; + if ((.@loc & EQP_SHADOW_SHOES) != 0) + return "Shadow Shoes"; + if ((.@loc & EQP_SHADOW_ACC) != 0) + return "Shadow Accessory"; + + return "Unknown Equip Type"; } //== Function Time2Str ===================================== -- cgit v1.2.3-60-g2f50