From ff6a7baa2a4ac1896980cadede3ed53dc091caee Mon Sep 17 00:00:00 2001 From: ultramage Date: Mon, 1 Sep 2008 08:06:46 +0000 Subject: Removed hardcoded equip position names from getequipname (bugreport:2156). Now it's the npc's responsibility to store and display the names. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13171 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 ++ doc/script_commands.txt | 19 ++++++------ npc/merchants/refine.txt | 10 ++++-- src/map/script.c | 79 ++++++++++++++++++++++++++++-------------------- 4 files changed, 67 insertions(+), 44 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 629cf617f..6c3b75456 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,9 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2008/09/01 + * Removed hardcoded equip position names from getequipname (bugreport:2156) + - now it's the npc's responsibility to store and display the names 2008/08/28 * Fixed @cash/@points not handling negative values properly (bugreport:2132) [ultramage] 2008/08/26 diff --git a/doc/script_commands.txt b/doc/script_commands.txt index f76176b52..8b860eb33 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -120,6 +120,8 @@ //= unitskilluseid, unitskillusepos, bonus/bonus2/bonus3/bonus4/bonus5 //= 3.22.20080622 //= Extended 'set' to return the variable reference. [FlavioJS] +//= 3.22.20080901 +//= Adjusted the 'getequipname' description to match src [ultramage] //========================================================= This document is a reference manual for all the scripting commands and functions @@ -2187,17 +2189,16 @@ armor, but also don't want them to equip if after the check, you would do this: *getequipname() -This function will return the name of the item equipped in the specified -equipment slot on the invoking character. Almost identical to 'getequipid', good -for an NPC to state what your are wearing, or maybe saving as a string variable. +Returns the jname of the item equipped in the specified equipment slot on the +invoking character, or an empty string if nothing is equipped in that position. +Does the same thing as getitemname(getequipid()). Useful for an NPC to state +what your are wearing, or maybe saving as a string variable. See 'getequipid' for a full list of valid equipment slots. - if (getequipname(EQI_HEAD_TOP)==0) goto L_No_HeadGear; - mes "So you are wearing a "+getequipname(EQI_HEAD_TOP)+" on your head"; - close; - L_No_HeadGear: - mes "You are not wearing any head gear"; - close; + if( getequipname(EQI_HEAD_TOP) != "" ) + mes "So you are wearing a "+getequipname(EQI_HEAD_TOP)+" on your head"; + else + mes "You are not wearing any head gear"; --------------------------------------- diff --git a/npc/merchants/refine.txt b/npc/merchants/refine.txt index 4fd5693c5..fd5bd24d6 100644 --- a/npc/merchants/refine.txt +++ b/npc/merchants/refine.txt @@ -362,9 +362,15 @@ function script refinemain { mes "I can refine all kinds of weapons, armor and equipment, so let me"; mes "know what you want me to refine."; next; + + setarray .@position$[1], "Head","Body","Left hand","Right hand","Robe","Shoes","Accessory 1","Accessory 2","Head 2","Head 3"; set .@menu$,""; - for( set .@i,1; .@i < 11; set .@i,.@i+1 ){ - set .@menu$,.@menu$+(getequipisequiped(.@i) ? getequipname(.@i) : "")+":"; + for( set .@i,1; .@i <= 10; set .@i,.@i+1 ) + { + if( getequipisequiped(.@i) ) + set .@menu$, .@menu$ + .@position$[.@i] + "-" + "[" + getequipname(.@i) + "]"; + + set .@menu$, .@menu$ + ":"; } set .@part,select(.@menu$); if(!getequipisequiped(.@part)) { diff --git a/src/map/script.c b/src/map/script.c index dd3a2cc15..8897c4082 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -5901,33 +5901,43 @@ BUILDIN_FUNC(strnpcinfo) } -unsigned int equip[10]={EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_GARMENT,EQP_SHOES,EQP_ACC_L,EQP_ACC_R,EQP_HEAD_MID,EQP_HEAD_LOW}; +// aegis->athena slot position conversion table +static unsigned int equip[] = {EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_GARMENT,EQP_SHOES,EQP_ACC_L,EQP_ACC_R,EQP_HEAD_MID,EQP_HEAD_LOW}; /*========================================== * GetEquipID(Pos); Pos: 1-10 *------------------------------------------*/ BUILDIN_FUNC(getequipid) { - int i=-1,num; - TBL_PC *sd; + int i, num; + TBL_PC* sd; struct item_data* item; - sd=script_rid2sd(st); - if(sd == NULL) + sd = script_rid2sd(st); + if( sd == NULL ) return 0; - num=script_getnum(st,2); - if (num > 0 && num <= ARRAYLENGTH(equip)) - i=pc_checkequip(sd,equip[num-1]); - if(i >= 0){ - item=sd->inventory_data[i]; - if(item) - script_pushint(st,item->nameid); - else - script_pushint(st,0); - }else{ + num = script_getnum(st,2) - 1; + if( num < 0 || num >= ARRAYLENGTH(equip) ) + { script_pushint(st,-1); + return 0; } + + // get inventory position of item + i = pc_checkequip(sd,equip[num]); + if( i < 0 ) + { + script_pushint(st,-1); + return 0; + } + + item = sd->inventory_data[i]; + if( item != 0 ) + script_pushint(st,item->nameid); + else + script_pushint(st,0); + return 0; } @@ -5936,31 +5946,34 @@ BUILDIN_FUNC(getequipid) *------------------------------------------*/ BUILDIN_FUNC(getequipname) { - int i=-1,num; - TBL_PC *sd; + int i, num; + TBL_PC* sd; struct item_data* item; - char *buf; - - static char pos[11][100] = {"Head","Body","Left hand","Right hand","Robe","Shoes","Accessory 1","Accessory 2","Head 2","Head 3","Not Equipped"}; sd = script_rid2sd(st); if( sd == NULL ) return 0; - buf=(char *)aMallocA(64*sizeof(char)); - num=script_getnum(st,2); - if (num > 0 && num <= ARRAYLENGTH(equip)) - i=pc_checkequip(sd,equip[num-1]); - if(i >= 0){ - item=sd->inventory_data[i]; - if(item) - sprintf(buf,"%s-[%s]",pos[num-1],item->jname); - else - sprintf(buf,"%s-[%s]",pos[num-1],pos[10]); - }else{ - sprintf(buf,"%s-[%s]",pos[num-1],pos[10]); + num = script_getnum(st,2) - 1; + if( num < 0 || num >= ARRAYLENGTH(equip) ) + { + script_pushconststr(st,""); + return 0; } - script_pushstr(st,buf); + + // get inventory position of item + i = pc_checkequip(sd,equip[num]); + if( i < 0 ) + { + script_pushint(st,-1); + return 0; + } + + item = sd->inventory_data[i]; + if( item != 0 ) + script_pushstrcopy(st,item->jname); + else + script_pushconststr(st,""); return 0; } -- cgit v1.2.3-70-g09d2