Jump to content

Question

In need of help with having this script to work. I've been trying to create a template for "walking" NPCs to create more difficult quests (using sprites with walking animation, of course). The NPC exists when enabled, it just doesn't do anything.

 

 

**The default location (rwc03,49,49,4) can be changed, it's an area I use to test NPCs on, especially this one, since it walks and it's a small map.

rwc03,49,49,4    script    Shy Eclipse    ECLIPSE,{    function offset_select;    function step_rand;    OnInit:        while(1){            offset_select;            npcspeed 100;            npcwalkto .@npc_x,.@npc_y;            .@interval = rand(3,5); // randomized idle duration            sleep .@interval*1000; // 1000 millisec = 1 sec        }    function offset_select{        do{            getmapxy(.@map$,.@x,.@y,1); // gets npc's current location            step_rand;            .@npc_x = .@x+rand(-.@step_a,.@step_; // randomized offset x-coord            .@npc_y = .@y+rand(-.@step_a,.@step_; // randomized offset y-coord        }while( !checkcell(.@map$,.@npc_x,.@npc_y,cell_chkpass) ); // checks if selected coords is accessible    }    function step_rand{        .@step_a = rand(1,10); // randomized offset init range        .@step_b = rand(1,10); // randomized offset end range        do{ // addresses possible rand() range error            .@step_a = rand(1,10);            .@step_b = rand(1,10);        }while( .@step_a >= .@step_b );    }    mes "[Eclipse]";    mes "!! Squik..!";    emotion e_panic;    next;    if( select("Pet it.:Scare it away.") == 1 ){        mes "[Eclipse]";        mes "**Squik~**";        emotion e_lv;    } else {        mes "[Eclipse]";        mes "SQUIK!";        emotion e_omg;    }    close;}

 

Edited by MochiBunni

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0
guild_vs2,50,50,4	script	Shy Eclipse	4_DOG01,{	mes "[Eclipse]";	mes "!! Squik..!";	emotion e_panic;	next;	if ( select("Pet it.:Scare it away.") == 1 ){		mes "[Eclipse]";		mes "**Squik~**";		emotion e_lv;	} else {		mes "[Eclipse]";		mes "SQUIK!";		emotion e_omg;	}	close;OnInit:	npcspeed 100;	while ( true ) {		getmapxy .@map$, .@x, .@y, 1;		while ( checkcell( .@map$, .@x2 = .@x + rand(-10,10), .@y2 = .@y + rand(-10,10), cell_chknopass ) );		npcwalkto .@x2, .@y2;		sleep rand(3000,5000);	}}
Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

then you have to set waypoint

https://rathena.org/board/topic/73366-walking-monster/?p=151732

 

 

EDIT:

cannot trust rathena forum up time, so re-post here

the script should looks something like this

turbo_n_1,337,275,5	script	team 1	100,{	getmapxy .@map$, .@x, .@y, 0;	setd ".@mob"+ .@i++, monster( .@map$, .@x, .@y, "--ja--", PORING, 1, "" );//	setmobdata getd(".@mob"+ .@i), 26, 0; // prevent random walk	unitwalk getd(".@mob"+ .@i), 343,275; // guide them to 1st waypoint	sleep distance( .@x, .@y, 343,275 ) * 400; // let it walk to 1st waypoint	unitwalk getd(".@mob"+ .@i), 342,258; // guide them to 2nd waypoint	sleep distance( 343,275, 342,285 ) * 400; // let it walk to 2nd waypoint	// .... repeat until the last waypoint	end;}
1st guide them to the 1st waypoint that is within line of sight,

defaulted to 14 under "area_size" inside confbattle, means don't let it walk the distance over 14 cells

after that put sleep to let them walk slowly to their destination

the time to calculate is determine from the Speed field from mob_db table

for poring, it is set to 400

means, it takes 400 mili-seconds to walk 1 cell

scorpion is 200, means 200 mili-seconds to walk 1 cell

in other words, poring in 2 seconds can walk 5 cells, and scorpion can walk 10 cells in 2 seconds

hence the script looks like that

 

repeat the process guide the poring from waypoint to waypoint until reach the final destination,

and you can use unitkill getd(".@mob"+ .@i); after it reach final destination

 

 

http://upaste.me/1e4c21973722e0564

I just found out using *distance script command is not the correct way to calculate this

because it can only return the max distance of x2-x1 or y2-y1 coordinate

it can only calculate correct value if it is in perfect horizontal or vertical, but not diagonal

 

so I think ... has to stick back to radius_distance

again credit to keyworld

Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

Quick question: is this script compatible with Hercules only?

Should be compatible with any emulator

Share this post


Link to post
Share on other sites
  • 0
guild_vs2,50,50,4	script	Shy Eclipse	4_DOG01,{	addtimer 1, strnpcinfo(0)+"::OnEndTalk";	.talking++;	mes "[Eclipse]";	mes "!! Squik..!";	emotion e_panic;	next;	if ( select("Pet it.:Scare it away.") == 1 ){		mes "[Eclipse]";		mes "**Squik~**";		emotion e_lv;	} else {		mes "[Eclipse]";		mes "SQUIK!";		emotion e_omg;	}	close;OnEndTalk:OnPCLogoutEvent:	.talking--;//	announce .talking +"", 0;	end;OnInit:	npcspeed 100;	while ( true ) {		if ( !.talking ) {			getmapxy .@map$, .@x, .@y, 1;			while ( checkcell( .@map$, .@x2 = .@x + rand(-10,10), .@y2 = .@y + rand(-10,10), cell_chknopass ) );			npcwalkto .@x2, .@y2;		}		sleep rand(1000,3000);	}}
Edited by AnnieRuru

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.