diff options
author | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-11-23 09:26:00 +0000 |
---|---|---|
committer | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-11-23 09:26:00 +0000 |
commit | 7d7f935061145b4f387ce904ec3d1c44612341bb (patch) | |
tree | 81961130b37c75bd7915bc46247fea87c3709f40 /src | |
parent | 012a470926be6d0d0f51f877c6ba1ffd3422ea3a (diff) | |
download | hercules-7d7f935061145b4f387ce904ec3d1c44612341bb.tar.gz hercules-7d7f935061145b4f387ce904ec3d1c44612341bb.tar.bz2 hercules-7d7f935061145b4f387ce904ec3d1c44612341bb.tar.xz hercules-7d7f935061145b4f387ce904ec3d1c44612341bb.zip |
* Added script command pushpc, which is required by newer scripts.
- Moved knockback-part of skill_blown into unit_blown, to allow unconditional knockback required by pushpc without copy-pasting code.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/renewal@14492 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r-- | src/map/script.c | 39 | ||||
-rw-r--r-- | src/map/skill.c | 41 | ||||
-rw-r--r-- | src/map/unit.c | 48 | ||||
-rw-r--r-- | src/map/unit.h | 1 |
4 files changed, 90 insertions, 39 deletions
diff --git a/src/map/script.c b/src/map/script.c index d823ae597..906dce510 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -14380,6 +14380,44 @@ BUILDIN_FUNC(progressbar) return 0; } +BUILDIN_FUNC(pushpc) +{ + int direction, cells, dx, dy; + struct map_session_data* sd; + + if((sd = script_rid2sd(st))==NULL) + { + return 0; + } + + direction = script_getnum(st,2); + cells = script_getnum(st,3); + + if(direction<0 || direction>7) + { + ShowWarning("buildin_pushpc: Invalid direction %d specified.\n", direction); + script_reportsrc(st); + + direction%= 8; // trim spin-over + } + + if(!cells) + {// zero distance + return 0; + } + else if(cells<0) + {// pushing backwards + direction = (direction+4)%8; // turn around + cells = -cells; + } + + dx = dirx[direction]; + dy = diry[direction]; + + unit_blown(&sd->bl, dx, dy, cells, 0); + return 0; +} + // declarations that were supposed to be exported from npc_chat.c #ifdef PCRE_SUPPORT BUILDIN_FUNC(defpattern); @@ -14739,6 +14777,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(setfont,"i"), BUILDIN_DEF(areamobuseskill,"siiiiviiiii"), BUILDIN_DEF(progressbar, "si"), + BUILDIN_DEF(pushpc,"ii"), // WoE SE BUILDIN_DEF(agitstart2,""), BUILDIN_DEF(agitend2,""), diff --git a/src/map/skill.c b/src/map/skill.c index a54bedc20..ccc3d96f9 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1467,8 +1467,7 @@ int skill_strip_equip(struct block_list *bl, unsigned short where, int rate, int -------------------------------------------------------------------------*/ int skill_blown(struct block_list* src, struct block_list* target, int count, int direction, int flag) { - int dx = 0, dy = 0, nx, ny; - int ret; + int dx = 0, dy = 0; struct skill_unit* su = NULL; nullpo_ret(src); @@ -1514,43 +1513,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in dy = -diry[direction]; } - ret=path_blownpos(target->m,target->x,target->y,dx,dy,count); - nx = ret>>16; - ny = ret&0xffff; - - if (!su) - unit_stop_walking(target,0); - - dx = nx - target->x; - dy = ny - target->y; - - if (!dx && !dy) //Could not knockback. - return 0; - - map_foreachinmovearea(clif_outsight, target, AREA_SIZE, dx, dy, target->type == BL_PC ? BL_ALL : BL_PC, target); - - if(su) - skill_unit_move_unit_group(su->group,target->m,dx,dy); - else - map_moveblock(target, nx, ny, gettick()); - - map_foreachinmovearea(clif_insight, target, AREA_SIZE, -dx, -dy, target->type == BL_PC ? BL_ALL : BL_PC, target); - - if(!(flag&0x1)) - clif_blown(target); - - if( target->type == BL_PC ) - { - TBL_PC *sd = (TBL_PC*)target; - if( sd->touching_id ) - npc_touchnext_areanpc(sd,false); - if( map_getcell(target->m,target->x,target->y,CELL_CHKNPC) ) - npc_touch_areanpc(sd,target->m,target->x,target->y); - else - sd->areanpc_id=0; - } - - return count; //Return amount of knocked back cells. + return unit_blown(target, dx, dy, count, flag&0x1); } diff --git a/src/map/unit.c b/src/map/unit.c index 0c16977c1..f2dcdc921 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -566,6 +566,54 @@ uint8 unit_getdir(struct block_list *bl) return ud->dir; } +// Pushes a unit by given amount of cells into given direction. Only +// map cell restrictions are respected. +// flag: +// &1 Do not send position update packets. +int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag) +{ + int nx, ny, ret; + struct skill_unit* su = BL_CAST(BL_SKILL, bl); + + ret=path_blownpos(bl->m,bl->x,bl->y,dx,dy,count); + nx = ret>>16; + ny = ret&0xffff; + + if (!su) + unit_stop_walking(bl,0); + + dx = nx - bl->x; + dy = ny - bl->y; + + if (!dx && !dy) //Could not knockback. + return 0; + + map_foreachinmovearea(clif_outsight, bl, AREA_SIZE, dx, dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl); + + if(su) + skill_unit_move_unit_group(su->group,bl->m,dx,dy); + else + map_moveblock(bl, nx, ny, gettick()); + + map_foreachinmovearea(clif_insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl); + + if(!(flag&0x1)) + clif_blown(bl); + + if( bl->type == BL_PC ) + { + TBL_PC *sd = (TBL_PC*)bl; + if( sd->touching_id ) + npc_touchnext_areanpc(sd,false); + if( map_getcell(bl->m,bl->x,bl->y,CELL_CHKNPC) ) + npc_touch_areanpc(sd,bl->m,bl->x,bl->y); + else + sd->areanpc_id=0; + } + + return count; //Return amount of knocked back cells. +} + //Warps a unit/ud to a given map/position. //In the case of players, pc_setpos is used. //it respects the no warp flags, so it is safe to call this without doing nowarpto/nowarp checks. diff --git a/src/map/unit.h b/src/map/unit.h index 0d8e4535e..3b82dce56 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -84,6 +84,7 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool int unit_warp(struct block_list *bl, short map, short x, short y, int type); int unit_setdir(struct block_list *bl,unsigned char dir); uint8 unit_getdir(struct block_list *bl); +int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag); // そこまで歩行でたどり着けるかの判定 bool unit_can_reach_pos(struct block_list *bl,int x,int y,int easy); |