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 --- doc/sample/getiteminfo.txt | 19 +++++++++++++--- doc/sample/npc_test_setitemx.txt | 11 +++++---- doc/script_commands.txt | 48 ++++++++++++++++++++-------------------- 3 files changed, 45 insertions(+), 33 deletions(-) (limited to 'doc') diff --git a/doc/sample/getiteminfo.txt b/doc/sample/getiteminfo.txt index 89f9a66b5..35dd9e27c 100644 --- a/doc/sample/getiteminfo.txt +++ b/doc/sample/getiteminfo.txt @@ -16,8 +16,21 @@ 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)); close; } diff --git a/doc/sample/npc_test_setitemx.txt b/doc/sample/npc_test_setitemx.txt index a06f0dc9f..990c09bae 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, 14, 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..c8496d227 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3176,23 +3176,43 @@ Example: --------------------------------------- *getiteminfo(, ) +*setiteminfo(, , ) 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 + 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) If RENEWAL is defined, 15 - matk 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() @@ -8296,26 +8316,6 @@ Example: --------------------------------------- -*setiteminfo(, , ) - -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(, <"{ new item script }">{, }) Set a new script bonus to the Item. Very useful for game events. -- cgit v1.2.3-70-g09d2 From dfcb1ff37ad077249c0050bb1bab8994225191e1 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 12 Nov 2017 01:56:57 +0100 Subject: Add ITEMINFO_MATK support to getiteminfo() / setiteminfo(). This item info type was documented in commit 315d632e69c60d2996872c9330164133101befdf, but never implemented. Signed-off-by: Haru --- doc/sample/getiteminfo.txt | 1 + doc/script_commands.txt | 3 +-- src/map/script.c | 7 +++++++ src/map/script.h | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/sample/getiteminfo.txt b/doc/sample/getiteminfo.txt index 35dd9e27c..63a6e7928 100644 --- a/doc/sample/getiteminfo.txt +++ b/doc/sample/getiteminfo.txt @@ -32,5 +32,6 @@ prontera,156,179,6 script test_getiteminfo 4_F_KAFRA1,{ 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)); close; } diff --git a/doc/script_commands.txt b/doc/script_commands.txt index c8496d227..746eaea2b 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3201,8 +3201,7 @@ Valid types are: ITEMINFO_ELV - Equip min. level ITEMINFO_WLV - Weapon level ITEMINFO_VIEWID - View ID ("Sprite" field in the Item DB) - - If RENEWAL is defined, 15 - matk + ITEMINFO_MATK - MATK (only relevant if RENEWAL is set) Check sample in doc/sample/getiteminfo.txt diff --git a/src/map/script.c b/src/map/script.c index 72c33dc5d..133142625 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -14126,6 +14126,9 @@ BUILDIN(getiteminfo) case ITEMINFO_VIEWID: script_pushint(st, it->view_id); break; + case ITEMINFO_MATK: + script_pushint(st, it->matk); + break; default: ShowError("buildin_getiteminfo: Invalid item type %d.\n", n); script_pushint(st,-1); @@ -14386,6 +14389,9 @@ BUILDIN(setiteminfo) case ITEMINFO_VIEWID: it->view_id = value; break; + case ITEMINFO_MATK: + it->matk = value; + break; default: ShowError("buildin_setiteminfo: invalid type %d.\n", n); script_pushint(st,-1); @@ -24830,6 +24836,7 @@ void script_hardcoded_constants(void) 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->constdb_comment("Renewal"); #ifdef RENEWAL diff --git a/src/map/script.h b/src/map/script.h index 3fd62a3f8..f9d86007b 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -447,6 +447,7 @@ enum script_iteminfo_types { ITEMINFO_ELV, ITEMINFO_WLV, ITEMINFO_VIEWID, + ITEMINFO_MATK, ITEMINFO_MAX }; -- cgit v1.2.3-70-g09d2 From e52cb33ab5f9900e9c10818a19b49c80c2196f76 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 12 Nov 2017 02:01:05 +0100 Subject: Add ITEMINFO_VIEWSPRITE support to getiteminfo() / setiteminfo(). Adds the ability to query an item's view sprite, lost with #1828 Fixes #1895 Signed-off-by: Haru --- doc/sample/getiteminfo.txt | 1 + doc/sample/npc_test_setitemx.txt | 2 +- doc/script_commands.txt | 1 + src/map/script.c | 7 +++++++ src/map/script.h | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/sample/getiteminfo.txt b/doc/sample/getiteminfo.txt index 63a6e7928..57407c072 100644 --- a/doc/sample/getiteminfo.txt +++ b/doc/sample/getiteminfo.txt @@ -33,5 +33,6 @@ prontera,156,179,6 script test_getiteminfo 4_F_KAFRA1,{ 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 990c09bae..519cfa363 100644 --- a/doc/sample/npc_test_setitemx.txt +++ b/doc/sample/npc_test_setitemx.txt @@ -21,7 +21,7 @@ prontera,164,161,5 script Lupus WOLF,{ mes "Ok. We made Apple equippable."; setiteminfo(Apple, ITEMINFO_TYPE, IT_ARMOR); setiteminfo(Apple, ITEMINFO_LOC, EQP_HEAD_MID); //where to equip to (equip = 512) - //setiteminfo(Apple, 14, 85); //set Headgear Sprite ID (view id = 85) + 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); diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 746eaea2b..465804061 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3202,6 +3202,7 @@ Valid types are: 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 diff --git a/src/map/script.c b/src/map/script.c index 133142625..68c4c7468 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -14129,6 +14129,9 @@ BUILDIN(getiteminfo) 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); @@ -14392,6 +14395,9 @@ BUILDIN(setiteminfo) 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); @@ -24837,6 +24843,7 @@ void script_hardcoded_constants(void) 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 diff --git a/src/map/script.h b/src/map/script.h index f9d86007b..14d20838d 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -448,6 +448,7 @@ enum script_iteminfo_types { ITEMINFO_WLV, ITEMINFO_VIEWID, ITEMINFO_MATK, + ITEMINFO_VIEWSPRITE, ITEMINFO_MAX }; -- cgit v1.2.3-70-g09d2