Jump to content
  • 0

Calculating the sleep timer for npcwalkto with npcspeed and distance


Question

Posted (edited)

Hey,

 

I'm not quite sure if this is the correct way to calculate the sleep time for the npc to move to another location.

 

Lets think it will move straight line with no blocks in its way to keep it simple.

 

Explained:

NPC will remove waiting room, do a map announce and starts to walk to another location. After it's finished walking it will disappear leaving the room for players.

 

Any suggestions or corrections?

OnStart:
	.@speed = 100;
	.@distance = distance(150,150,153,127);
	.@sleep = (.@distance * (.@speed * 10));
	kickwaitingroomall instance_npcname(strnpcinfo(0));
	delwaitingroom instance_npcname(strnpcinfo(0));
	mapannounce instance_mapname("prt_are01"),"Event will start. Get ready!",bc_map,"0x7799ff";
	npcspeed .@speed;
	npcwalkto 153,127;
	sleep .@sleep; 
	donpcevent instance_npcname("TestTimer#1_1")+"::OnEnable";
	donpcevent instance_npcname(strnpcinfo(0))+"::OnDisable";
	end;

Here is the full test script (if you need to take a closer look):

https://www.dropbox.com/s/lacve3srhsf53qh/instance-test.txt?dl=0

 

 

Thanks  /pat

Edited by Sehrentos

2 answers to this question

Recommended Posts

Posted

Why not just time how long it takes for the npc to travel one square... (.@distance * .@time_per_square_in_miliseconds);

 

Well if the movement speed is like iRO it's 0.15s per-square at the normal walk speed.

.@sleep = (.@distance * 150);
  • Upvote 1

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...