Jump to content
  • 0

Calculating the sleep timer for npcwalkto with npcspeed and distance


Sehrentos

Question


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   22
  • Joined:  10/24/14
  • Last Seen:  

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
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   22
  • Joined:  10/24/14
  • Last Seen:  

Thanks for the tip!

 

Tested it out. Works perfectly thank you.

 

/no1

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...