diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-08-23 20:27:24 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-08-23 20:27:24 +0000 |
commit | 807bbb2d5494b1a9c65fc7a6fac2fd68079349cf (patch) | |
tree | e8d54638d45010e4d32d8eff67fa25da29234716 | |
parent | c01124eb980d501e27298584d8e7067108e4eac3 (diff) | |
download | hercules-807bbb2d5494b1a9c65fc7a6fac2fd68079349cf.tar.gz hercules-807bbb2d5494b1a9c65fc7a6fac2fd68079349cf.tar.bz2 hercules-807bbb2d5494b1a9c65fc7a6fac2fd68079349cf.tar.xz hercules-807bbb2d5494b1a9c65fc7a6fac2fd68079349cf.zip |
- Cleaned up getmapxy script function, also added support for type 4 so that it returns a player's homunculus position if such exists.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8459 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | Changelog-Trunk.txt | 2 | ||||
-rw-r--r-- | src/map/script.c | 203 |
2 files changed, 96 insertions, 109 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 667876d20..4120508df 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/08/23
+ * Cleaned up getmapxy script function, also added support for type 4 so
+ that it returns a player's homunculus position if such exists. [Skotlex]
* SC_ARMOR_ELEMENT looks like gone away from status_change_start since ... rev 6791.
Try to reimplement it. [Toms]
* Fixed HVAN_EXPLOSION [Skotlex]
diff --git a/src/map/script.c b/src/map/script.c index 40cf9e31a..dcb641cb3 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -10470,6 +10470,7 @@ int buildin_getsavepoint(struct script_state *st) * 1 - NPC coord * 2 - Pet coord * 3 - Mob coord (not released) + * 4 - Homun coord * CharName$ - Name object. If miss or "this" the current object * * Return: @@ -10478,9 +10479,8 @@ int buildin_getsavepoint(struct script_state *st) *------------------------------------------ */ int buildin_getmapxy(struct script_state *st){ + struct block_list *bl = NULL; struct map_session_data *sd=NULL; - struct npc_data *nd; - struct pet_data *pd; int num; char *name; @@ -10490,126 +10490,111 @@ int buildin_getmapxy(struct script_state *st){ char mapname[MAP_NAME_LENGTH+1]; memset(mapname, 0, sizeof(mapname)); - if( st->stack->stack_data[st->start+2].type!=C_NAME ){ - ShowWarning("script: buildin_getmapxy: not mapname variable\n"); - push_val(st->stack,C_INT,-1); - return 0; - } - if( st->stack->stack_data[st->start+3].type!=C_NAME ){ - ShowWarning("script: buildin_getmapxy: not mapx variable\n"); - push_val(st->stack,C_INT,-1); - return 0; - } - if( st->stack->stack_data[st->start+4].type!=C_NAME ){ - ShowWarning("script: buildin_getmapxy: not mapy variable\n"); - push_val(st->stack,C_INT,-1); - return 0; - } + if( st->stack->stack_data[st->start+2].type!=C_NAME ){ + ShowWarning("script: buildin_getmapxy: not mapname variable\n"); + push_val(st->stack,C_INT,-1); + return 1; + } + if( st->stack->stack_data[st->start+3].type!=C_NAME ){ + ShowWarning("script: buildin_getmapxy: not mapx variable\n"); + push_val(st->stack,C_INT,-1); + return 1; + } + if( st->stack->stack_data[st->start+4].type!=C_NAME ){ + ShowWarning("script: buildin_getmapxy: not mapy variable\n"); + push_val(st->stack,C_INT,-1); + return 1; + } -//??????????? >>> Possible needly check function parameters on C_STR,C_INT,C_INT <<< ???????????// + //??????????? >>> Possible needly check function parameters on C_STR,C_INT,C_INT <<< ???????????// type=conv_num(st,& (st->stack->stack_data[st->start+5])); - switch (type){ - case 0: //Get Character Position - if( st->end>st->start+6 ) - sd=map_nick2sd(conv_str(st,& (st->stack->stack_data[st->start+6]))); - else - sd=script_rid2sd(st); - - if ( sd==NULL ) { //wrong char name or char offline - push_val(st->stack,C_INT,-1); - return 0; - } - - - x=sd->bl.x; - y=sd->bl.y; - memcpy(mapname,mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH); - break; - case 1: //Get NPC Position - if( st->end > st->start+6 ) - nd=npc_name2id(conv_str(st,& (st->stack->stack_data[st->start+6]))); - else - nd=(struct npc_data *)map_id2bl(st->oid); - - if ( nd==NULL ) { //wrong npc name or char offline - push_val(st->stack,C_INT,-1); - return 0; - } - - x=nd->bl.x; - y=nd->bl.y; - memcpy(mapname, map[nd->bl.m].name, MAP_NAME_LENGTH); - break; - case 2: //Get Pet Position - if( st->end>st->start+6 ) - sd=map_nick2sd(conv_str(st,& (st->stack->stack_data[st->start+6]))); - else - sd=script_rid2sd(st); - - if ( sd==NULL ) { //wrong char name or char offline - push_val(st->stack,C_INT,-1); - return 0; - } - - pd=sd->pd; - - if(pd==NULL){ //pet data not found - push_val(st->stack,C_INT,-1); - return 0; - } - x=pd->bl.x; - y=pd->bl.y; - memcpy(mapname, map[pd->bl.m].name, MAP_NAME_LENGTH); - break; - - case 3: //Get Mob Position - push_val(st->stack,C_INT,-1); - return 0; - default: //Wrong type parameter - push_val(st->stack,C_INT,-1); - return 0; - } + switch (type){ + case 0: //Get Character Position + if( st->end>st->start+6 ) + sd=map_nick2sd(conv_str(st,& (st->stack->stack_data[st->start+6]))); + else + sd=script_rid2sd(st); - //Set MapName$ - num=st->stack->stack_data[st->start+2].u.num; - name=(char *)(str_buf+str_data[num&0x00ffffff].str); - prefix=*name; + if (sd) + bl = &sd->bl; + break; + case 1: //Get NPC Position + if( st->end > st->start+6 ) + { + struct npc_data *nd; + nd=npc_name2id(conv_str(st,& (st->stack->stack_data[st->start+6]))); + if (nd) + bl = &nd->bl; + } else //In case the origin is not an npc? + bl=map_id2bl(st->oid); + break; + case 2: //Get Pet Position + if(st->end>st->start+6) + sd=map_nick2sd(conv_str(st,& (st->stack->stack_data[st->start+6]))); + else + sd=script_rid2sd(st); - if(not_server_variable(prefix)) - sd=script_rid2sd(st); - else - sd=NULL; + if (sd && sd->pd) + bl = &sd->pd->bl; + break; + case 3: //Get Mob Position + break; //Not supported? + case 4: //Get Homun Position + if(st->end>st->start+6) + sd=map_nick2sd(conv_str(st,& (st->stack->stack_data[st->start+6]))); + else + sd=script_rid2sd(st); - set_reg(st,sd,num,name,(void*)mapname,st->stack->stack_data[st->start+2].ref); + if (sd && sd->hd) + bl = &sd->hd->bl; + break; + } + if (!bl) { //No object found. + push_val(st->stack,C_INT,-1); + return 0; + } - //Set MapX - num=st->stack->stack_data[st->start+3].u.num; - name=(char *)(str_buf+str_data[num&0x00ffffff].str); - prefix=*name; + x= bl->x; + y= bl->y; + memcpy(mapname, map[bl->m].name, MAP_NAME_LENGTH); + + //Set MapName$ + num=st->stack->stack_data[st->start+2].u.num; + name=(char *)(str_buf+str_data[num&0x00ffffff].str); + prefix=*name; - if(not_server_variable(prefix)) - sd=script_rid2sd(st); - else - sd=NULL; - set_reg(st,sd,num,name,(void*)x,st->stack->stack_data[st->start+3].ref); + if(not_server_variable(prefix)) + sd=script_rid2sd(st); + else + sd=NULL; + set_reg(st,sd,num,name,(void*)mapname,st->stack->stack_data[st->start+2].ref); + //Set MapX + num=st->stack->stack_data[st->start+3].u.num; + name=(char *)(str_buf+str_data[num&0x00ffffff].str); + prefix=*name; - //Set MapY - num=st->stack->stack_data[st->start+4].u.num; - name=(char *)(str_buf+str_data[num&0x00ffffff].str); - prefix=*name; + if(not_server_variable(prefix)) + sd=script_rid2sd(st); + else + sd=NULL; + set_reg(st,sd,num,name,(void*)x,st->stack->stack_data[st->start+3].ref); - if(not_server_variable(prefix)) - sd=script_rid2sd(st); - else - sd=NULL; + //Set MapY + num=st->stack->stack_data[st->start+4].u.num; + name=(char *)(str_buf+str_data[num&0x00ffffff].str); + prefix=*name; - set_reg(st,sd,num,name,(void*)y,st->stack->stack_data[st->start+4].ref); + if(not_server_variable(prefix)) + sd=script_rid2sd(st); + else + sd=NULL; + set_reg(st,sd,num,name,(void*)y,st->stack->stack_data[st->start+4].ref); - //Return Success value - push_val(st->stack,C_INT,0); - return 0; + //Return Success value + push_val(st->stack,C_INT,0); + return 0; } /*========================================== |