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 | 35467de0fb6dc06a402315ea478495d74080e3c5 (patch) | |
tree | 79659d470525996eb45773c0d196df440b35330e | |
parent | 89974727211311dc13f3c823ab6f565f8942455b (diff) | |
download | hercules-35467de0fb6dc06a402315ea478495d74080e3c5.tar.gz hercules-35467de0fb6dc06a402315ea478495d74080e3c5.tar.bz2 hercules-35467de0fb6dc06a402315ea478495d74080e3c5.tar.xz hercules-35467de0fb6dc06a402315ea478495d74080e3c5.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/trunk@14492 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | Changelog-Trunk.txt | 3 | ||||
-rw-r--r-- | db/const.txt | 9 | ||||
-rw-r--r-- | doc/script_commands.txt | 18 | ||||
-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 |
7 files changed, 120 insertions, 39 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index e7361b53c..84fd9c869 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,8 @@ Date Added +2010/11/23 + * Added script command pushpc, which is required by newer scripts. [Ai4rei] + - Moved knockback-part of skill_blown into unit_blown, to allow unconditional knockback required by pushpc without copy-pasting code. 2010/11/22 * mail_deliveryfail no longer attempts to log (since r12910) and give items (since r11855), when there is no item attached to the mail (bugreport:3239). [Ai4rei] * Fixed a crash when shutting down char-server (TXT only), after it failed to load storage save data (since r1275). [Ai4rei] diff --git a/db/const.txt b/db/const.txt index 3fbec41fb..8bf52248a 100644 --- a/db/const.txt +++ b/db/const.txt @@ -1842,3 +1842,12 @@ VAR_HEADPALETTE 6 VAR_BODYPALETTE 7 VAR_SHIELD 8 VAR_SHOES 9 + +DIR_NORTH 0 +DIR_NORTHWEST 1 +DIR_WEST 2 +DIR_SOUTHWEST 3 +DIR_SOUTH 4 +DIR_SOUTHEAST 5 +DIR_EAST 6 +DIR_NORTHEAST 7 diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 1c75bb062..29e9edee4 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -135,6 +135,8 @@ //= 3.28.20091119 //= Added showevent and searchitem commands [Skotlex] //= Added info on strcharinfo(3) [Skotlex] +//= 3.29.20101123 +//= Added 'pushpc' command. [Ai4rei] //========================================================= This document is a reference manual for all the scripting commands and functions @@ -3870,6 +3872,22 @@ you can look at, this may help you create a Stylist of your own: 'custom\dye.txt' --------------------------------------- + +*pushpc <direction>,<cells>; + +This command will push the currently attached player to given direction by given +amount of square cells. Direction is the same as used when declaring npcs, and +can be specified by using one of the DIR_* constants (db/const.txt). + +The knock-back is not restricted by items or map flags, only obstacles are taken +into account. If there is not enough space to perform the push (e.g. due to a +wall), the character is pushed only up to the obstacle. + + // pushes the character 5 cells in 3 o'clock direction from it's + // current position. + pushpc DIR_EAST, 5; + +--------------------------------------- \\ 4,1.- Item-related commands \\ 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); |