summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorSkotlex <Skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-08-10 15:52:59 +0000
committerSkotlex <Skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-08-10 15:52:59 +0000
commit09b2f259b86749e57b1179d795f19f495c5defab (patch)
treeb15138123690db0e7722e6a6141e825e1c8060ae /src/map/script.c
parentc5fa6396f9cbb8e5e6e4deb0bb1cbf926d21c6e1 (diff)
downloadhercules-09b2f259b86749e57b1179d795f19f495c5defab.tar.gz
hercules-09b2f259b86749e57b1179d795f19f495c5defab.tar.bz2
hercules-09b2f259b86749e57b1179d795f19f495c5defab.tar.xz
hercules-09b2f259b86749e57b1179d795f19f495c5defab.zip
- Commiting a bunch of cleanups piled up from the past few weeks/months/years.
- Updated unitwarp so that an id of "0" causes the script's rid to be warped. - Updated the Brasilis ontouchNPC warp command to use unitwarp instead. - Signum Crucis's duration is now specified in the skill_cast_db file - Updated @warp/@jump commands so that when an invalid tile is specified, a nearby cell is chosen (rather than using a map-wide random value) - The if(req.weapon) code was broken, since req.weapon is never "0" for a skill. Updated the code so that the requirement of '99' (any weapon) is stored as 0, in order to make the checks effective. - Cleaned up the code for script command warpparty - Fixed the define itemdb_canrefine() - Cleaned up some the status_damage() function - Fixed map_random_dir(), which at times would pick cells that didn't preserve the required distance. - Some aesthetic code cleanups. - Fixed some possible crashes for skills where the code assumes the caster is a player. - Fixed a bunch of idiotic code-snippets that should have embarrassed whoever was responsible for them. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14929 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 632dc0e14..c61b6d184 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -4559,7 +4559,7 @@ BUILDIN_FUNC(warpparty)
struct party_data* p;
int type;
int mapindex;
- int i, j;
+ int i;
const char* str = script_getstr(st,2);
int x = script_getnum(st,3);
@@ -4579,9 +4579,27 @@ BUILDIN_FUNC(warpparty)
: ( strcmp(str,"Leader")==0 ) ? 3
: 4;
- if( type == 2 && ( sd = script_rid2sd(st) ) == NULL )
- {// "SavePoint" uses save point of the currently attached player
- return 0;
+ switch (type)
+ {
+ case 3:
+ for(i = 0; i < MAX_PARTY && !p->party.member[i].leader; i++);
+ if (i == MAX_PARTY || !p->data[i].sd) //Leader not found / not online
+ return 0;
+ pl_sd = p->data[i].sd;
+ mapindex = pl_sd->mapindex;
+ x = pl_sd->bl.x;
+ y = pl_sd->bl.y;
+ break;
+ case 4:
+ mapindex = mapindex_name2id(str);
+ break;
+ case 2:
+ //"SavePoint" uses save point of the currently attached player
+ if (( sd = script_rid2sd(st) ) == NULL )
+ return 0;
+ default:
+ mapindex = 0;
+ break;
}
for (i = 0; i < MAX_PARTY; i++)
@@ -4610,25 +4628,9 @@ BUILDIN_FUNC(warpparty)
pc_setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
break;
case 3: // Leader
- for(j = 0; j < MAX_PARTY && !p->party.member[j].leader; j++);
- if (j == MAX_PARTY || !p->data[j].sd) //Leader not found / not online
- return 0;
- mapindex = p->data[j].sd->mapindex;
- x = p->data[j].sd->bl.x;
- y = p->data[j].sd->bl.y;
- for (j = 0; j < MAX_PARTY; j++)
- {
- pl_sd = p->data[j].sd;
- if (!pl_sd)
- continue;
- if(map[pl_sd->bl.m].flag.noreturn || map[pl_sd->bl.m].flag.nowarp)
- continue;
- pc_setpos(pl_sd,mapindex,x,y,CLR_TELEPORT);
- }
- break;
case 4: // m,x,y
if(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp)
- pc_setpos(pl_sd,mapindex_name2id(str),x,y,CLR_TELEPORT);
+ pc_setpos(pl_sd,mapindex,x,y,CLR_TELEPORT);
break;
}
}
@@ -6574,6 +6576,9 @@ BUILDIN_FUNC(strnpcinfo)
case 3: // unique name
name = aStrdup(nd->exname);
break;
+ case 4: // map name
+ name = aStrdup(map[nd->bl.m].name);
+ break;
}
if(name)
@@ -13452,8 +13457,11 @@ BUILDIN_FUNC(unitwarp)
map = map_mapname2mapid(script_getstr(st, 3));
x = (short)script_getnum(st,4);
y = (short)script_getnum(st,5);
-
- bl = map_id2bl(unit_id);
+
+ if (!unit_id) //Warp the script's runner
+ bl = map_id2bl(st->rid);
+ else
+ bl = map_id2bl(unit_id);
if( map >= 0 && bl != NULL )
script_pushint(st, unit_warp(bl,map,x,y,CLR_OUTSIGHT));
else