summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2017-11-18 20:05:20 +0100
committerGitHub <noreply@github.com>2017-11-18 20:05:20 +0100
commit7b2f685d9fa8a2998b424c003d7a1386f76d45db (patch)
treea5f118370396e8168c5aa84b4fb105951157d35c
parenta63c82c8bd29fd829a5d8cfba7d02d11cf4634c5 (diff)
parent42248822bf5348c7cbf33efbdf12873bea11ff38 (diff)
downloadhercules-7b2f685d9fa8a2998b424c003d7a1386f76d45db.tar.gz
hercules-7b2f685d9fa8a2998b424c003d7a1386f76d45db.tar.bz2
hercules-7b2f685d9fa8a2998b424c003d7a1386f76d45db.tar.xz
hercules-7b2f685d9fa8a2998b424c003d7a1386f76d45db.zip
Merge pull request #1902 from MishimaHaruna/getiteminfo-fix
getiteminfo() / setiteminfo() fixes
-rw-r--r--doc/sample/getiteminfo.txt21
-rw-r--r--doc/sample/npc_test_setitemx.txt11
-rw-r--r--doc/script_commands.txt52
-rw-r--r--npc/custom/item_signer.txt2
-rw-r--r--npc/custom/itembind.txt12
-rw-r--r--npc/custom/quests/quest_shop.txt8
-rw-r--r--npc/merchants/socket_enchant.txt9
-rw-r--r--npc/merchants/socket_enchant2.txt4
-rw-r--r--npc/other/Global_Functions.txt171
-rw-r--r--npc/other/monster_race.txt2
-rw-r--r--npc/quests/cooking_quest.txt4
-rw-r--r--npc/re/merchants/coin_exchange.txt2
-rw-r--r--npc/re/merchants/enchan_mal.txt42
-rw-r--r--npc/re/quests/eden/eden_tutorial.txt6
-rw-r--r--npc/re/quests/quests_dewata.txt2
-rw-r--r--src/map/script.c96
-rw-r--r--src/map/script.h25
17 files changed, 308 insertions, 161 deletions
diff --git a/doc/sample/getiteminfo.txt b/doc/sample/getiteminfo.txt
index 89f9a66b5..57407c072 100644
--- a/doc/sample/getiteminfo.txt
+++ b/doc/sample/getiteminfo.txt
@@ -16,8 +16,23 @@ prontera,156,179,6 script test_getiteminfo 4_F_KAFRA1,{
// ^nItemID^XXXX -> Item Name
mes "Item ID: "+.@value+" ^nItemID^"+.@value;
- mes "Current item info:";
- for (.@id = 0; .@id < 14; ++.@id)
- mes " getiteminfo("+.@value+","+.@id+") = "+getiteminfo(.@value,.@id);
+ mes("Current item info:");
+ mesf("Buy Price: %d", getiteminfo(.@value, ITEMINFO_BUYPRICE));
+ mesf("Sell Price: %d", getiteminfo(.@value, ITEMINFO_SELLPRICE));
+ mesf("Type: %d", getiteminfo(.@value, ITEMINFO_TYPE));
+ mesf("Max drop chance: %d.%02d", getiteminfo(.@value, ITEMINFO_MAXCHANCE) / 100, getiteminfo(.@value, ITEMINFO_MAXCHANCE) % 100);
+ mesf("Sex: %d", getiteminfo(.@value, ITEMINFO_SEX));
+ mesf("Equip location: %d", getiteminfo(.@value, ITEMINFO_LOC));
+ mesf("Weight: %d.%d", getiteminfo(.@value, ITEMINFO_WEIGHT) / 10, getiteminfo(.@value, ITEMINFO_WEIGHT) % 10);
+ mesf("Attack: %d", getiteminfo(.@value, ITEMINFO_ATK));
+ mesf("Defense: %d", getiteminfo(.@value, ITEMINFO_DEF));
+ mesf("Range: %d", getiteminfo(.@value, ITEMINFO_RANGE));
+ mesf("Slots: %d", getiteminfo(.@value, ITEMINFO_SLOTS));
+ mesf("Subtype: %d", getiteminfo(.@value, ITEMINFO_SUBTYPE));
+ mesf("Equip Level: %d", getiteminfo(.@value, ITEMINFO_ELV));
+ mesf("Weapon Level: %d", getiteminfo(.@value, ITEMINFO_WLV));
+ mesf("View ID: %d", getiteminfo(.@value, ITEMINFO_VIEWID));
+ mesf("MATK: %d", getiteminfo(.@value, ITEMINFO_MATK));
+ mesf("View Sprite: %d", getiteminfo(.@value, ITEMINFO_VIEWSPRITE));
close;
}
diff --git a/doc/sample/npc_test_setitemx.txt b/doc/sample/npc_test_setitemx.txt
index a06f0dc9f..519cfa363 100644
--- a/doc/sample/npc_test_setitemx.txt
+++ b/doc/sample/npc_test_setitemx.txt
@@ -14,15 +14,14 @@ prontera,164,161,5 script Lupus WOLF,{
switch (select("Make Knife[3] Edible", "Make Apple Equippable", "Edible Knife = Full SP", "Knife = Weapon + 3 Notes")) {
case 1:
mes "Ok. We made Knife[3] edible.";
- setiteminfo(Knife, 2, IT_HEALING); //type = 0 : potion
+ setiteminfo(Knife, ITEIMINFO_TYPE, IT_HEALING);
setitemscript(Knife, "{dispbottom \"* You used Knife[3]\";}");
break;
case 2:
mes "Ok. We made Apple equippable.";
- setiteminfo(Apple, 2, IT_ARMOR); //item type -> headgear (type = 5 -> IT_ARMOR)
- setiteminfo(Apple, 5, 512); //where to equip to (equip = 512)
- setiteminfo(Apple, 11, 256); //set as headgear location (loc = 256)
- setiteminfo(Apple, 14, 85); //set Headgear Sprite ID (view id = 85)
+ setiteminfo(Apple, ITEMINFO_TYPE, IT_ARMOR);
+ setiteminfo(Apple, ITEMINFO_LOC, EQP_HEAD_MID); //where to equip to (equip = 512)
+ setiteminfo(Apple, ITEMINFO_VIEWID, 85); //set Headgear Sprite ID (view id = 85)
setitemscript(Apple, "{dispbottom \"* Other item's changed\";}", 0);
setitemscript(Apple, "{dispbottom \"* Equipped\";}", 1);
setitemscript(Apple, "{dispbottom \"* Unequipped\";}", 2);
@@ -34,7 +33,7 @@ prontera,164,161,5 script Lupus WOLF,{
break;
case 4:
mes "Ok. We made Knife a weapon, but added 3 notes.";
- setiteminfo(Knife, 2, IT_WEAPON); //type = 4 -> IT_WEAPON
+ setiteminfo(Knife, ITEIMINFO_TYPE, IT_WEAPON);
setitemscript(Knife, "{dispbottom \"* 1 Used\";}", 0);
setitemscript(Knife, "{dispbottom \"* 2 Equipped\";}", 1);
setitemscript(Knife, "{dispbottom \"* 3 Unequipped\";}", 2);
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 940302982..465804061 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -3176,23 +3176,43 @@ Example:
---------------------------------------
*getiteminfo(<item ID>, <type>)
+*setiteminfo(<item ID>, <type>, <value>)
This function will look up the item with the specified ID number in the
database and return the info set by TYPE argument.
It will return -1 if there is no such item.
Valid types are:
- 0 - Buy Price; 1 - Sell Price; 2 - Item Type;
- 3 - maxchance (Max drop chance of this item e.g. 1 = 0.01% , etc..
+
+ ITEMINFO_BUYPRICE - Buy Price
+ ITEMINFO_SELLPRICE - Sell Price
+ ITEMINFO_TYPE - Item Type
+ ITEMINFO_MAXCHANCE - Max drop chance of this item e.g. 1 = 0.01% , etc..
if = 0, then monsters don't drop it at all (rare or a quest item)
if = 10000, then this item is sold in NPC shops only
- 4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range;
- 10 - slot; 11 - subtype; 12 - elv; 13 - wlv; 14 - view id
-
- If RENEWAL is defined, 15 - matk
+ ITEMINFO_SEX - Sex
+ ITEMINFO_LOC - Equip location
+ ITEMINFO_WEIGHT - Weight (note: 1/10 of unit)
+ ITEMINFO_ATK - Attack
+ ITEMINFO_DEF - Defense
+ ITEMINFO_RANGE - Range
+ ITEMINFO_SLOTS - Slots
+ ITEMINFO_SUBTYPE - Item subtype
+ ITEMINFO_ELV - Equip min. level
+ ITEMINFO_WLV - Weapon level
+ ITEMINFO_VIEWID - View ID ("Sprite" field in the Item DB)
+ ITEMINFO_MATK - MATK (only relevant if RENEWAL is set)
+ ITEMINFO_VIEWSPRITE - View Sprite ("ViewSprite" field in the Item DB)
Check sample in doc/sample/getiteminfo.txt
+The setiteminfo function will, instead, set the item's parameters. It returns
+the new value on success, or -1 on failure (item_id not found).
+
+Example:
+
+ setiteminfo(Stone, ITEMINFO_WEIGHT, 9990); // Stone now weighs 999.0
+
---------------------------------------
*getequipisenableopt(<equipment slot>)
@@ -8296,26 +8316,6 @@ Example:
---------------------------------------
-*setiteminfo(<item id>, <type>, <value>)
-
-This function will set some value of an item.
-Returns the new value on success, or -1 on fail (item_id not found or
-invalid type).
-
-Valid types are:
- 0 - Buy Price; 1 - Sell Price; 2 - Item Type;
- 3 - maxchance (Max drop chance of this item e.g. 1 = 0.01% , etc..
- if = 0, then monsters don't drop it at all (rare or a quest item)
- if = 10000, then this item is sold in NPC shops only
- 4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range;
- 10 - slot; 11 - subtype; 12 - elv; 13 - wlv; 14 - view id
-
-Example:
-
-setiteminfo Stone, 6, 9990; // Stone now weighs 999.0
-
----------------------------------------
-
*setitemscript(<item id>, <"{ new item script }">{, <type>})
Set a new script bonus to the Item. Very useful for game events.
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<getarraysize(.@q); set .@i,.@i+2)
mes " > "+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..9882e9d71 100644
--- a/npc/other/Global_Functions.txt
+++ b/npc/other/Global_Functions.txt
@@ -235,66 +235,137 @@ 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;
+ 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;
+ 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;
+ 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 {
- 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;
- 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 =====================================
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,<cost multiplier>,<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.";
diff --git a/src/map/script.c b/src/map/script.c
index 4dcfa5687..7f7aba183 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -14081,53 +14081,61 @@ BUILDIN(getiteminfo)
}
switch (n) {
- case 0:
+ case ITEMINFO_BUYPRICE:
script_pushint(st, it->value_buy);
break;
- case 1:
+ case ITEMINFO_SELLPRICE:
script_pushint(st, it->value_sell);
break;
- case 2:
+ case ITEMINFO_TYPE:
script_pushint(st, it->type);
break;
- case 3:
+ case ITEMINFO_MAXCHANCE:
script_pushint(st, it->maxchance);
break;
- case 4:
+ case ITEMINFO_SEX:
script_pushint(st, it->sex);
break;
- case 5:
+ case ITEMINFO_LOC:
script_pushint(st, it->equip);
break;
- case 6:
+ case ITEMINFO_WEIGHT:
script_pushint(st, it->weight);
break;
- case 7:
+ case ITEMINFO_ATK:
script_pushint(st, it->atk);
break;
- case 8:
+ case ITEMINFO_DEF:
script_pushint(st, it->def);
break;
- case 9:
+ case ITEMINFO_RANGE:
script_pushint(st, it->range);
break;
- case 10:
+ case ITEMINFO_SLOTS:
script_pushint(st, it->slot);
break;
- case 11:
+ case ITEMINFO_SUBTYPE:
script_pushint(st, it->subtype);
break;
- case 12:
+ case ITEMINFO_ELV:
script_pushint(st, it->elv);
break;
- case 13:
+ case ITEMINFO_WLV:
script_pushint(st, it->wlv);
break;
- case 14:
+ case ITEMINFO_VIEWID:
script_pushint(st, it->view_id);
break;
+ case ITEMINFO_MATK:
+ script_pushint(st, it->matk);
+ break;
+ case ITEMINFO_VIEWSPRITE:
+ script_pushint(st, it->view_sprite);
+ break;
default:
+ ShowError("buildin_getiteminfo: Invalid item type %d.\n", n);
script_pushint(st,-1);
+ return false;
}
return true;
}
@@ -14339,54 +14347,61 @@ BUILDIN(setiteminfo)
}
switch (n) {
- case 0:
+ case ITEMINFO_BUYPRICE:
it->value_buy = value;
break;
- case 1:
+ case ITEMINFO_SELLPRICE:
it->value_sell = value;
break;
- case 2:
+ case ITEMINFO_TYPE:
it->type = value;
break;
- case 3:
+ case ITEMINFO_MAXCHANCE:
it->maxchance = value;
break;
- case 4:
+ case ITEMINFO_SEX:
it->sex = value;
break;
- case 5:
+ case ITEMINFO_LOC:
it->equip = value;
break;
- case 6:
+ case ITEMINFO_WEIGHT:
it->weight = value;
break;
- case 7:
+ case ITEMINFO_ATK:
it->atk = value;
break;
- case 8:
+ case ITEMINFO_DEF:
it->def = value;
break;
- case 9:
+ case ITEMINFO_RANGE:
it->range = value;
break;
- case 10:
+ case ITEMINFO_SLOTS:
it->slot = value;
break;
- case 11:
+ case ITEMINFO_SUBTYPE:
it->subtype = value;
break;
- case 12:
+ case ITEMINFO_ELV:
it->elv = value;
break;
- case 13:
+ case ITEMINFO_WLV:
it->wlv = value;
break;
- case 14:
+ case ITEMINFO_VIEWID:
it->view_id = value;
break;
+ case ITEMINFO_MATK:
+ it->matk = value;
+ break;
+ case ITEMINFO_VIEWSPRITE:
+ it->view_sprite = value;
+ break;
default:
+ ShowError("buildin_setiteminfo: invalid type %d.\n", n);
script_pushint(st,-1);
- return true;
+ return false;
}
script_pushint(st,value);
return true;
@@ -24829,6 +24844,25 @@ void script_hardcoded_constants(void)
script->set_constant("MAPINFO_SIZE_Y", MAPINFO_SIZE_Y, false, false);
script->set_constant("MAPINFO_ZONE", MAPINFO_ZONE, false, false);
+ script->constdb_comment("set/getiteminfo options");
+ script->set_constant("ITEMINFO_BUYPRICE", ITEMINFO_BUYPRICE, false, false);
+ script->set_constant("ITEMINFO_SELLPRICE", ITEMINFO_SELLPRICE, false, false);
+ script->set_constant("ITEMINFO_TYPE", ITEMINFO_TYPE, false, false);
+ script->set_constant("ITEMINFO_MAXCHANCE", ITEMINFO_MAXCHANCE, false, false);
+ script->set_constant("ITEMINFO_SEX", ITEMINFO_SEX, false, false);
+ script->set_constant("ITEMINFO_LOC", ITEMINFO_LOC, false, false);
+ script->set_constant("ITEMINFO_WEIGHT", ITEMINFO_WEIGHT, false, false);
+ script->set_constant("ITEMINFO_ATK", ITEMINFO_ATK, false, false);
+ script->set_constant("ITEMINFO_DEF", ITEMINFO_DEF, false, false);
+ script->set_constant("ITEMINFO_RANGE", ITEMINFO_RANGE, false, false);
+ script->set_constant("ITEMINFO_SLOTS", ITEMINFO_SLOTS, false, false);
+ script->set_constant("ITEMINFO_SUBTYPE", ITEMINFO_SUBTYPE, false, false);
+ script->set_constant("ITEMINFO_ELV", ITEMINFO_ELV, false, false);
+ script->set_constant("ITEMINFO_WLV", ITEMINFO_WLV, false, false);
+ script->set_constant("ITEMINFO_VIEWID", ITEMINFO_VIEWID, false, false);
+ script->set_constant("ITEMINFO_MATK", ITEMINFO_MATK, false, false);
+ script->set_constant("ITEMINFO_VIEWSPRITE", ITEMINFO_VIEWSPRITE, false, false);
+
script->constdb_comment("Renewal");
#ifdef RENEWAL
script->set_constant("RENEWAL", 1, false, false);
diff --git a/src/map/script.h b/src/map/script.h
index b2ab7510c..14d20838d 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -429,6 +429,31 @@ enum script_unit_data_types {
};
/**
+ * Item Info types.
+ */
+enum script_iteminfo_types {
+ ITEMINFO_BUYPRICE = 0,
+ ITEMINFO_SELLPRICE,
+ ITEMINFO_TYPE,
+ ITEMINFO_MAXCHANCE,
+ ITEMINFO_SEX,
+ ITEMINFO_LOC,
+ ITEMINFO_WEIGHT,
+ ITEMINFO_ATK,
+ ITEMINFO_DEF,
+ ITEMINFO_RANGE,
+ ITEMINFO_SLOTS,
+ ITEMINFO_SUBTYPE,
+ ITEMINFO_ELV,
+ ITEMINFO_WLV,
+ ITEMINFO_VIEWID,
+ ITEMINFO_MATK,
+ ITEMINFO_VIEWSPRITE,
+
+ ITEMINFO_MAX
+};
+
+/**
* Structures
**/