Rewrote/optimized script command warpparty.

Added support for an optional extra parameter "from_mapname" to restrict effect of warpparty to only those on a specific map.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14311 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
Paradox924X 2010-05-29 07:53:42 +00:00
parent 6d3fc13aea
commit 336865596c
2 changed files with 70 additions and 84 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.
2010/05/29
* Rewrote/optimized script command warpparty. [Paradox924X]
- Added support for an optional extra parameter "from_mapname" to restrict effect of warpparty to only those on a specific map.
2010/05/28 2010/05/28
* Rev. 14310 Fixed it so you can't add opositions during woe se. [L0ne_W0lf] * Rev. 14310 Fixed it so you can't add opositions during woe se. [L0ne_W0lf]
2010/05/20 2010/05/20

View File

@ -4215,107 +4215,90 @@ BUILDIN_FUNC(warpchar)
return 0; return 0;
} }
/*========================================== /*==========================================
* Warpparty - [Fredzilla] * Warpparty - [Fredzilla] [Paradox924X]
* Syntax: warpparty "mapname",x,y,Party_ID; * Syntax: warpparty "to_mapname",x,y,Party_ID,{"from_mapname"};
* If 'from_mapname' is specified, only the party members on that map will be warped
*------------------------------------------*/ *------------------------------------------*/
BUILDIN_FUNC(warpparty) BUILDIN_FUNC(warpparty)
{ {
int x,y; TBL_PC *sd;
const char *str;
int p_id;
int i;
unsigned short mapindex;
TBL_PC *pl_sd; TBL_PC *pl_sd;
struct party_data *p=NULL; struct party_data* p;
str=script_getstr(st,2); int type;
x=script_getnum(st,3); int mapindex;
y=script_getnum(st,4); int i, j;
p_id=script_getnum(st,5);
if(p_id < 1) const char* str = script_getstr(st,2);
int x = script_getnum(st,3);
int y = script_getnum(st,4);
int p_id = script_getnum(st,5);
const char* str2 = NULL;
if ( script_hasdata(st,6) )
str2 = script_getstr(st,6);
sd=script_rid2sd(st);
if( sd == NULL )
return 0; return 0;
p = party_search(p_id); p = party_search(p_id);
if (!p) if(!p)
return 0; return 0;
if(strcmp(str,"Random")==0)
{
for (i = 0; i < MAX_PARTY; i++)
{
if ((pl_sd = p->data[i].sd))
{
if(map[pl_sd->bl.m].flag.nowarp)
continue;
pc_randomwarp(pl_sd,3);
}
}
}
else if(strcmp(str,"SavePointAll")==0)
{
for (i = 0; i < MAX_PARTY; i++)
{
if ((pl_sd = p->data[i].sd))
{
if(map[pl_sd->bl.m].flag.noreturn)
continue;
pc_setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,3);
}
}
}
else if(strcmp(str,"SavePoint")==0)
{
pl_sd=script_rid2sd(st);
if (!pl_sd) return 0;
mapindex=pl_sd->status.save_point.map; if(map[sd->bl.m].flag.noreturn || map[sd->bl.m].flag.nowarpto)
x=pl_sd->status.save_point.x; return 0;
y=pl_sd->status.save_point.y;
type = ( strcmp(str,"Random")==0 ) ? 0
for (i = 0; i < MAX_PARTY; i++) : ( strcmp(str,"SavePointAll")==0 ) ? 1
{ : ( strcmp(str,"SavePoint")==0 ) ? 2
if ((pl_sd = p->data[i].sd)) : ( strcmp(str,"Leader")==0 ) ? 3
{ : 4;
if(map[pl_sd->bl.m].flag.noreturn)
continue; for (i = 0; i < MAX_PARTY; i++)
pc_setpos(pl_sd,mapindex,x,y,3);
}
}
}
else if(strcmp(str,"Leader")==0)
{ {
for(i = 0; i < MAX_PARTY && !p->party.member[i].leader; i++); if( !(pl_sd = p->data[i].sd) || pl_sd->status.party_id != p_id )
if (i == MAX_PARTY || !p->data[i].sd) //Leader not found / not online continue;
return 0;
if(map[p->data[i].sd->bl.m].flag.nowarpto) if( str2 && strcmp(str2, map[pl_sd->bl.m].name) != 0 )
return 0; continue;
mapindex = p->data[i].sd->mapindex;
x = p->data[i].sd->bl.x; switch( type )
y = p->data[i].sd->bl.y;
for (i = 0; i < MAX_PARTY; i++)
{ {
pl_sd = p->data[i].sd; case 0: // Random
if (!pl_sd) if(!map[pl_sd->bl.m].flag.nowarp)
continue; pc_randomwarp(pl_sd,3);
if(map[pl_sd->bl.m].flag.noreturn || map[pl_sd->bl.m].flag.nowarp) break;
continue; case 1: // SavePointAll
pc_setpos(pl_sd,mapindex,x,y,3); if(!map[pl_sd->bl.m].flag.noreturn)
} pc_setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,3);
} break;
else case 2: // SavePoint
{ if(!map[pl_sd->bl.m].flag.noreturn)
mapindex = mapindex_name2id(str); pc_setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,3);
if (!mapindex) //Show source of npc error. break;
return 1; case 3: // Leader
for (i = 0; i < MAX_PARTY; i++) 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
if ((pl_sd = p->data[i].sd)) 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) if(map[pl_sd->bl.m].flag.noreturn || map[pl_sd->bl.m].flag.nowarp)
continue; continue;
pc_setpos(pl_sd,mapindex,x,y,3); pc_setpos(pl_sd,mapindex,x,y,3);
} }
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,3);
break;
} }
} }
return 0; return 0;
} }
/*========================================== /*==========================================
@ -14309,7 +14292,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(warp,"sii"), BUILDIN_DEF(warp,"sii"),
BUILDIN_DEF(areawarp,"siiiisii"), BUILDIN_DEF(areawarp,"siiiisii"),
BUILDIN_DEF(warpchar,"siii"), // [LuzZza] BUILDIN_DEF(warpchar,"siii"), // [LuzZza]
BUILDIN_DEF(warpparty,"siii"), // [Fredzilla] BUILDIN_DEF(warpparty,"siii*"), // [Fredzilla] [Paradox924X]
BUILDIN_DEF(warpguild,"siii"), // [Fredzilla] BUILDIN_DEF(warpguild,"siii"), // [Fredzilla]
BUILDIN_DEF(setlook,"ii"), BUILDIN_DEF(setlook,"ii"),
BUILDIN_DEF(changelook,"ii"), // Simulates but don't Store it BUILDIN_DEF(changelook,"ii"), // Simulates but don't Store it