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 --- src/map/script.c | 82 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 31 deletions(-) (limited to 'src/map/script.c') diff --git a/src/map/script.c b/src/map/script.c index 5773457a7..72c33dc5d 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -14081,53 +14081,55 @@ 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; default: + ShowError("buildin_getiteminfo: Invalid item type %d.\n", n); script_pushint(st,-1); + return false; } return true; } @@ -14339,54 +14341,55 @@ 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; default: + ShowError("buildin_setiteminfo: invalid type %d.\n", n); script_pushint(st,-1); - return true; + return false; } script_pushint(st,value); return true; @@ -24811,6 +24814,23 @@ 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->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); -- cgit v1.2.3-60-g2f50 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 'src/map/script.c') 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-60-g2f50 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 'src/map/script.c') 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-60-g2f50