script
prontera,150,150,0 script Cleaner 1002,15,15,{
end;
OnTouchNPC:
.@gid = monsterattached();
getmapxy .@map$, .@x, .@y, 3;
// move to 1 cell near the mob / min distance between npc-mob
if ( .@x > .x0 )
.@dx = -1;
else if ( .@x < .x0 )
.@dx = 1;
if ( .@y > .y0 )
.@dy = -1;
else if ( .@y < .y0 )
.@dy = 1;
.@x_tmp = .@x + .@dx;
.@y_tmp = .@y + .@dy;
if ( !checkcell(.@map$,.@x_tmp,.@y_tmp,cell_chkpass) ) {
for ( .@dx = -1; .@dx < 2 && .@break == 0; .@dx++ )
for ( .@dy = -1; .@dy < 2; .@dy++ ) {
if ( .@dx == 0 && .@dy == 0 ) continue;
.@x_tmp = .@x + .@dx;
.@y_tmp = .@y + .@dy;
if ( checkcell(.@map$,.@x_tmp,.@y_tmp,cell_chkpass) ) {
.@break = 1;
break;
}
}
}
if ( .@x_tmp != .@x && .@y_tmp != .@y )
movenpc strnpcinfo(3), .@x_tmp, .@y_tmp;
specialeffectmob 10;
unitkill .@gid;
end;
OnInit:
getmapxy .@map$, .x0, .y0, 1;
// .@npc_name$ = strnpcinfo(3);
npcspeed 50;
freeloop 1;
while( true ) {
sleep 10000;
do {
.@x = .x0 + rand(-10,10);
.@y = .y0 + rand(-10,10);
} while( !checkcell(.@map$,.@x,.@y,cell_chkpass) );
.x0 = .@x;
.y0 = .@y;
npcwalkto .x0, .y0;
// movenpc .@npc_name$, .x0, .y0;
}
}
src
src/custom/script.inc | 19 +++++++++++++++++++
src/custom/script_def.inc | 3 +++
src/map/script.c | 8 ++++++++
3 files changed, 30 insertions(+)
diff --git a/src/custom/script.inc b/src/custom/script.inc
index 1e01c88..c8e825c 100644
--- a/src/custom/script.inc
+++ b/src/custom/script.inc
@@ -17,3 +17,22 @@
// script_pushint(st,1);
// return 0;
//}
+
+BUILDIN_FUNC(monsterattached)
+{
+ struct block_list *bl = map_id2bl(st->rid);
+ if(st->rid == 0 || bl == NULL || bl->type != BL_MOB)
+ script_pushint(st,0);
+ else
+ script_pushint(st,st->rid);
+ return SCRIPT_CMD_SUCCESS;
+}
+
+BUILDIN_FUNC(specialeffectmob)
+{
+ int type = script_getnum(st,2);
+ struct block_list *bl=map_id2bl(st->rid);
+ if(bl != NULL && bl->type == BL_MOB)
+ clif_specialeffect(bl, type, AREA);
+ return SCRIPT_CMD_SUCCESS;
+}
\ No newline at end of file
diff --git a/src/custom/script_def.inc b/src/custom/script_def.inc
index 3319eea..5a75166 100644
--- a/src/custom/script_def.inc
+++ b/src/custom/script_def.inc
@@ -9,3 +9,6 @@
**/
//BUILDIN_DEF(example,""),
+
+BUILDIN_DEF(monsterattached,""),
+BUILDIN_DEF(specialeffectmob,"i"),
\ No newline at end of file
diff --git a/src/map/script.c b/src/map/script.c
index b6be34d..29d0634 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -13986,6 +13986,14 @@ int recovery_sub(struct map_session_data* sd, int revive)
bl = &sd->pd->bl;
break;
case 3: //Get Mob Position
+ if( script_hasdata(st,6) ) {
+ struct script_data *data = script_getdata(st,6);
+ get_val(st, data);
+ if( !data_isstring(data) )
+ bl = map_id2bl(script_getnum(st, 6));
+ }
+ else if( st->rid && map_id2bl(st->rid) != NULL )
+ bl = map_id2bl(st->rid);
break; //Not supported?
case 4: //Get Homun Position
if(script_hasdata(st,6))
I didn't thought about friendly mob