Jump to content
  • 0

Unitwalk - destination out of sight


Aleos

Question


  • Group:  Development Manager
  • Topic Count:  56
  • Topics Per Day:  0.01
  • Content Count:  732
  • Reputation:   525
  • Joined:  12/13/11
  • Last Seen:  

What I'm trying to do is get a group of monsters to walk in a straight line. There are no obstacles in the way (walls, water, models, etc). The issue I'm having is that the distance is out of sight from the start point. I'm currently using the monster controller script command (mobspawn) which is in a for loop and spawns 20 monsters. Inside the for loop the monsters are given the directive to walk to a way point (Which later lead to other way points which vary in 10-12 cells apart). I have these NPC which are my way points:

testmap,50,74,1	script	#MobStart	-1,1,1,{
end;

OnTouchNPC: // Walk to next location.
unitwalk getunitid(0),50,62;
end;
}

testmap,50,62,1	script	#MobQuarterWay	-1,5,5,{
end;

OnTouchNPC: // Walk to next location.
unitwalk getunitid(0),50,49;
end;
}

testmap,50,49,1	script	#MobHalfWay	-1,5,5,{
end;

OnTouchNPC: // Walk to next location.
unitwalk getunitid(0),50,37;
end;
}

testmap,50,37,1	script	#Mob3QuarterWay	-1,5,5,{
end;

OnTouchNPC: // Walk to next location.
unitwalk getunitid(0),50,23;
end;
}

getunitid(0) is just a script command I made which returns the game ID of the monster that is attached to the script (it triggered the OnTouchNPC label). So this works part of the time. The start off is fine, the monsters walk to the first way point. Once the monsters touch the first way point they seem to get confused and walk around for a bit and then figure out they are supposed to walk to the next way point (At this point my map server is spitting out the unitwalktimer mismatch errors). The monsters eventually reach the end of the line but I want the monsters to walk at a steady pace from the start (no wandering around). Would the walking around issue be part of the randomwalk that monsters are given? I guess I can play around with removing the randomwalk from the spawned monsters and see how that goes.

If anyone has any input I would appreciate it!

Edited by Aleos
Link to comment
Share on other sites

14 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

http://rathena.org/board/topic/73366-walking-monster/#entry151732

btw ... I'm also writing a dota script ... LOL !!

wanna join together ? xD

oh and no paid service ...

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Development Manager
  • Topic Count:  56
  • Topics Per Day:  0.01
  • Content Count:  732
  • Reputation:   525
  • Joined:  12/13/11
  • Last Seen:  

Hm, I saw that topic but the issue is that the first monster has to reach the end of the line before the next one spawns and I don't want it to function like that.

Ha, to tell you the truth I've never played DotA. :P

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

nope, that script should be able to spawn monsters as many as possible as long as someone clicking on it

btw, can you share out your mob controller patch ?

I'm busying supporting more script related topics, not enough time to do source modifications =/

Link to comment
Share on other sites


  • Group:  Development Manager
  • Topic Count:  56
  • Topics Per Day:  0.01
  • Content Count:  732
  • Reputation:   525
  • Joined:  12/13/11
  • Last Seen:  

Interesting, thanks for the info. Let me try it out. I wasn't sure if a for loop would produce the same results.

And what part of the monster controller patch do you need? I really didn't modify anything important except adding the getunitid script command.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

eA had a very useful mob controller system but is now outdated... I was wondering if somebody could update this patch so that it can work with rAthena?

http://www.eathena.ws/board/index.php?showtopic=194375

want to say the exact same thing like he did :P

our current SVN has already gone over 17000, but that one is only 14xxx

are you using eathena .. ? or rathena ?

if using eathena, perhaps it might be still compatible with your server

but if using rathena, somebody here needs to update it to make it compatible with latest rathena revision

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Development Manager
  • Topic Count:  56
  • Topics Per Day:  0.01
  • Content Count:  732
  • Reputation:   525
  • Joined:  12/13/11
  • Last Seen:  

The SVN I use is 3CeAM based but has many features of rA that I merged myself. I went ahead and created a patch for the latest checkout of rA: mob_controller_rA_17035.patch

The only changes I made were giving the mobspawn() script command support for NPC events and spawning in instances.

Also, I tried your suggestion in the other topic and it didn't work the entire time. Sometimes the monsters would run through while other times the monster would go along and then stop.

MobCreator:
   for (set .c,0; .c < 'wave_amount; set .c,.c + 1) {
       if ('wave_stop)
           end;
       sleep 300;
       set .gid,mobspawn(getmonsterinfo(.mobid['wave],0),.mobid['wave],"1@def01",50,74,instance_npcname("#Spawn Controller", instance_id())+"::OnWaveMobDead");
       setmobdata .gid,8,100;    // Set movement speed equal to all.
       setmobdata .gid,9,1;    // Set mob mode to just MD_CANMOVE.
       setmobdata .gid,26,0;    // Remove random walk.
       unitwalk .gid,50,62;
       sleep distance(50,74,50,62) * 100;
       unitwalk .gid,50,49;
       sleep distance(50,62,50,49) * 100;
       unitwalk .gid,50,37;
       sleep distance(50,49,50,37) * 100;
       unitwalk .gid,50,23;
       sleep distance(50,37,50,23) * 100;
   }
   return;

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  754
  • Reputation:   186
  • Joined:  05/22/12
  • Last Seen:  

You can put up invisible npcs, and utilize the OnTouch event to continue walking(like way points). :P

edit: oh crap, this was the idea in the first post. sorry i read it back wards :/

edit2:

try to put unitstop <gid>; before every unitwalk. This way, it deletes the walktimer from within the source, thus, wouldn't throw errors anymore.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

the problem here is

setmobdata .gid,26,0;

this one doesn't work

because the patch is bug

I've tried your patch

and these are the error that I got

1>...\src\map\mob.c(3640): warning C4133: 'function' : incompatible types - from 'DBMap **' to 'linkdb_node **'
1>...\src\map\mob.c(3642): warning C4133: 'function' : incompatible types - from 'DBMap **' to 'linkdb_node **'
1>...\src\map\mob.c(3643): warning C4133: 'function' : incompatible types - from 'DBMap **' to 'linkdb_node **'
1>...\src\map\mob.c(3645): warning C4133: 'function' : incompatible types - from 'DBMap **' to 'linkdb_node **'
1>...\src\map\script.c(15198): error C2198: 'mob_once_spawn' : too few arguments for call

I also tried to create my own

mob_controller_17097.patch

also doesn't work

I only fixed the mob_once_spawn from *mob_spawn command

that linkdb_replace in mob_script_callback function, I dunno how to fix it

http://www.eathena.ws/board/index.php?s=&showtopic=274110&view=findpost&p=1503992

must at least try to get the patch working and get that script working fine

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  52
  • Reputation:   6
  • Joined:  01/06/12
  • Last Seen:  

The SVN I use is 3CeAM based but has many features of rA that I merged myself. I went ahead and created a patch for the latest checkout of rA: mob_controller_rA_17035.patch

The only changes I made were giving the mobspawn() script command support for NPC events and spawning in instances.

Also, I tried your suggestion in the other topic and it didn't work the entire time. Sometimes the monsters would run through while other times the monster would go along and then stop.

MobCreator:
for (set .c,0; .c < 'wave_amount; set .c,.c + 1) {
	if ('wave_stop)
		end;
	sleep 300;
	set .gid,mobspawn(getmonsterinfo(.mobid['wave],0),.mobid['wave],"1@def01",50,74,instance_npcname("#Spawn Controller", instance_id())+"::OnWaveMobDead");
	setmobdata .gid,8,100;	// Set movement speed equal to all.
	setmobdata .gid,9,1;	// Set mob mode to just MD_CANMOVE.
	setmobdata .gid,26,0;	// Remove random walk.
	unitwalk .gid,50,62;
	sleep distance(50,74,50,62) * 100;
	unitwalk .gid,50,49;
	sleep distance(50,62,50,49) * 100;
	unitwalk .gid,50,37;
	sleep distance(50,49,50,37) * 100;
	unitwalk .gid,50,23;
	sleep distance(50,37,50,23) * 100;
}
return;

Regarding this script, couldn't you have just changed the mob mode to make it unable to move before sleeping? If that doesn't do the trick, then maybe there's something wrong with how unitwalk interacts with mobs?

This might sound silly, but there's always the ridiculous route of making unwalkable cells surrounding the monster, or creating a status that freezes them after a duration or that triggers after walking so many tiles (actually, that'd be pretty cool for other purposes).

Does anyone know where the limitation on only being able to walk within a certain range comes from? I'd think monsters would have full map sight range...

@Annie: What's line 3640-3645?

Edited by Variant
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

couldn't you have just changed the mob mode to make it unable to move
if the mob mode has unset MD_CANMOVE, it can't even move

prontera,156,178,5    script    kdjhfksdjfs    100,{
   getmapxy .@map$, .@x, .@y, 0;
   .@id = bg_monster( 0, .@map$, .@x, .@y, "--ja--", 1002, "" ); // poring can walk
   unitwalk .@id, .@x + 5, .@y;
   .@id = bg_monster( 0, .@map$, .@x, .@y, "--ja--", 1288, "" ); // emperium can't walk
   unitwalk .@id, .@x + 5, .@y;
   end;
}


there's always the ridiculous route of making unwalkable cells surrounding the monster, or creating a status that freezes them after a duration or that triggers after walking so many tiles (actually, that'd be pretty cool for other purposes).
that defeat the purpose of mob controller system

currently I want to write a DOTA battleground script,

I have to use this mob controller system to simulate attack-move feature like real-time-strategy games

Does anyone know where the limitation on only being able to walk within a certain range comes from? I'd think monsters would have full map sight range...
// Mobs and Pets view-range adjustment (range2 column in the mob_db) (Note 2)

view_range_rate: 100

// Visible area size (how many squares away from a player can they see)

area_size: 14

whichever smaller one take place

even if you set it to 255, with area_size 14, it still only chase you within 14 cells

wiki is wrong


@Annie: What's line 3640-3645?

this code were working before mob controller took out, in 13020, but doesn't work in rathena

+int mob_script_callback(struct mob_data *md, struct block_list *target, short action_type)
+{
+    // DEBUG: Uncomment these if errors occur. ---
+    // nullpo_retr(md, 0);
+    // nullpo_retr(md->nd, 0);
+    // -------------------------------------------
+    if ( md->callback_flag & action_type ){
+        int regkey = add_str(".ai_action");
+        linkdb_replace(&md->nd->u.scr.script->script_vars,(void *)regkey, (void *)(int)action_type);
+        if(target){
+            linkdb_replace(&md->nd->u.scr.script->script_vars,(void *)(regkey+(1<<24)), (void *)(int)target->type);
+            linkdb_replace(&md->nd->u.scr.script->script_vars,(void *)(regkey+(2<<24)), (void *)target->id);
+        }
+        linkdb_replace(&md->nd->u.scr.script->script_vars,(void *)(regkey+(3<<24)), (void *)md->bl.id);
+        run_script(md->nd->u.scr.script, 0, 0, md->nd->bl.id);
+        return 1;
+    }
+    return 0;
+}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  52
  • Reputation:   6
  • Joined:  01/06/12
  • Last Seen:  

Oh, well the warning is (presumably) because:

struct script_code {
int script_size;
unsigned char* script_buf;
struct linkdb_node* script_vars;
};

was changed to

struct script_code {
int script_size;
unsigned char* script_buf;
struct DBMap* script_vars;
};

A change made in r15997 by Epoque to "make use of the DBMap* structure for storing variables (for Ind <3)" (see here). So my thoughts are that simply switching out linkdb functions with idb functions should (hopefully) solve your warnings, and change the diff to support the current revision. Unfortunately I don't have too much time to look into and test it myself, but I don't think I'm missing anything.

Also, the area_size isn't capped to 14 is it?

Edited by Variant
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

wow !

you pointed me in right direction !

gives you 1 rep

mob_controller_17100.patch

and this script is now working fine in latest rathena SVN

-	script	poring_race	-1,{
if ( .ai_action[AI_ACTION_TYPE] == AI_ACTION_TYPE_WALKACK ) {
	getmobdata .ai_action[AI_ACTION_SRC], .@data;
	unitwalk .ai_action[AI_ACTION_SRC], .@data[6] -1, .@data[7];
}
else if ( .ai_action[AI_ACTION_TYPE] == AI_ACTION_TYPE_DEAD ) {
	if ( .ai_action[AI_ACTION_TAR_TYPE] == AI_ACTION_TAR_TYPE_PC )
		.@name$ = rid2name(.ai_action[AI_ACTION_TAR]);
	else if ( .ai_action[AI_ACTION_TAR_TYPE] ) {
		getmobdata .ai_action[AI_ACTION_TAR], .@slave;
		if ( .@slave[4] < 100000000 )
			.@name$ = rid2name(.@slave[4]);
	}
	if ( getstrlen( .@name$ ) )
		mapannounce "guild_vs2", .@name$ + " stop killing already", 0;
	.@id = getd( ".id"+ .ai_action[AI_ACTION_SRC] );
	callsub L_spawn, .@id;
	setd ".id"+ .@id, 0;
}
end;
OnInit:
for ( .@i = 1; .@i <= 6; .@i++ )
	callsub L_spawn, .@i;
end;
L_spawn:
.gid[ getarg(0) ] = mobspawn( getarg(0) +"", 1002, "guild_vs2", 62, 56 - getarg(0) *2 );
setd ".id"+ .gid[ getarg(0) ], getarg(0);
mobattach .gid[ getarg(0) ], strnpcinfo(0);
setmobdata .gid[ getarg(0) ], 25, AI_ACTION_TYPE_DEAD | AI_ACTION_TYPE_WALKACK;
setmobdata .gid[ getarg(0) ], 26, 1;
unitwalk .gid[ getarg(0) ], 61,  56 - getarg(0) *2;
return;
}
guild_vs2	mapflag	nomobloot

Edited by AnnieRuru
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  52
  • Reputation:   6
  • Joined:  01/06/12
  • Last Seen:  

I'm glad I was able to help.

But I still think it's weird that monsters can't see past 14 tiles. According to the source, the max value should effectively be INT_MAX, so I don't see why increasing that past 14 shouldn't work (looking up battle_config.area_size in the source, and AREA_SIZE the macro doesn't seem to come up with any particular limitations). Does anyone know why that doesn't work?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  1
  • Reputation:   0
  • Joined:  06/27/12
  • Last Seen:  

I want to make a verification if the monster arrive the area that i want to send it to another, but i dont know how get the x and y of it, I guess the getmapxy for monster objects still dont work :/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...