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://svn.code.sf.net/p/rathena/svn/trunk@13171 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
ultramage 2008-09-01 08:06:46 +00:00
parent bba8e623b7
commit cf57c2fc20
4 changed files with 67 additions and 44 deletions

View File

@ -3,6 +3,9 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. 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. 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 2008/08/28
* Fixed @cash/@points not handling negative values properly (bugreport:2132) [ultramage] * Fixed @cash/@points not handling negative values properly (bugreport:2132) [ultramage]
2008/08/26 2008/08/26

View File

@ -120,6 +120,8 @@
//= unitskilluseid, unitskillusepos, bonus/bonus2/bonus3/bonus4/bonus5 //= unitskilluseid, unitskillusepos, bonus/bonus2/bonus3/bonus4/bonus5
//= 3.22.20080622 //= 3.22.20080622
//= Extended 'set' to return the variable reference. [FlavioJS] //= 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 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(<equpment slot>) *getequipname(<equpment slot>)
This function will return the name of the item equipped in the specified Returns the jname of the item equipped in the specified equipment slot on the
equipment slot on the invoking character. Almost identical to 'getequipid', good invoking character, or an empty string if nothing is equipped in that position.
for an NPC to state what your are wearing, or maybe saving as a string variable. 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. See 'getequipid' for a full list of valid equipment slots.
if (getequipname(EQI_HEAD_TOP)==0) goto L_No_HeadGear; if( getequipname(EQI_HEAD_TOP) != "" )
mes "So you are wearing a "+getequipname(EQI_HEAD_TOP)+" on your head"; mes "So you are wearing a "+getequipname(EQI_HEAD_TOP)+" on your head";
close; else
L_No_HeadGear:
mes "You are not wearing any head gear"; mes "You are not wearing any head gear";
close;
--------------------------------------- ---------------------------------------

View File

@ -362,9 +362,15 @@ function script refinemain {
mes "I can refine all kinds of weapons, armor and equipment, so let me"; mes "I can refine all kinds of weapons, armor and equipment, so let me";
mes "know what you want me to refine."; mes "know what you want me to refine.";
next; next;
setarray .@position$[1], "Head","Body","Left hand","Right hand","Robe","Shoes","Accessory 1","Accessory 2","Head 2","Head 3";
set .@menu$,""; set .@menu$,"";
for( set .@i,1; .@i < 11; set .@i,.@i+1 ){ for( set .@i,1; .@i <= 10; set .@i,.@i+1 )
set .@menu$,.@menu$+(getequipisequiped(.@i) ? getequipname(.@i) : "")+":"; {
if( getequipisequiped(.@i) )
set .@menu$, .@menu$ + .@position$[.@i] + "-" + "[" + getequipname(.@i) + "]";
set .@menu$, .@menu$ + ":";
} }
set .@part,select(.@menu$); set .@part,select(.@menu$);
if(!getequipisequiped(.@part)) { if(!getequipisequiped(.@part)) {

View File

@ -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 * GetEquipID(Pos); Pos: 1-10
*------------------------------------------*/ *------------------------------------------*/
BUILDIN_FUNC(getequipid) BUILDIN_FUNC(getequipid)
{ {
int i=-1,num; int i, num;
TBL_PC *sd; TBL_PC* sd;
struct item_data* item; struct item_data* item;
sd=script_rid2sd(st); sd = script_rid2sd(st);
if(sd == NULL) if( sd == NULL )
return 0; return 0;
num=script_getnum(st,2); num = script_getnum(st,2) - 1;
if (num > 0 && num <= ARRAYLENGTH(equip)) if( num < 0 || num >= ARRAYLENGTH(equip) )
i=pc_checkequip(sd,equip[num-1]); {
if(i >= 0){ script_pushint(st,-1);
item=sd->inventory_data[i]; return 0;
if(item) }
// 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); script_pushint(st,item->nameid);
else else
script_pushint(st,0); script_pushint(st,0);
}else{
script_pushint(st,-1);
}
return 0; return 0;
} }
@ -5936,31 +5946,34 @@ BUILDIN_FUNC(getequipid)
*------------------------------------------*/ *------------------------------------------*/
BUILDIN_FUNC(getequipname) BUILDIN_FUNC(getequipname)
{ {
int i=-1,num; int i, num;
TBL_PC *sd; TBL_PC* sd;
struct item_data* item; 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); sd = script_rid2sd(st);
if( sd == NULL ) if( sd == NULL )
return 0; return 0;
buf=(char *)aMallocA(64*sizeof(char)); num = script_getnum(st,2) - 1;
num=script_getnum(st,2); if( num < 0 || num >= ARRAYLENGTH(equip) )
if (num > 0 && num <= ARRAYLENGTH(equip)) {
i=pc_checkequip(sd,equip[num-1]); script_pushconststr(st,"");
if(i >= 0){ return 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]);
} }
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; return 0;
} }