Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-13-2004, 08:47 PM
Duwul Duwul is offline
Registered User
Join Date: Nov 2003
Posts: 105
Duwul is on a distinguished road
movement formula for 'move' command

I've recently created a NPC that follows a certain path. The NPC uses the move command to move, so the time it takes is required. However, I can't get it to maintain a constant speed. Does anyone know a formula that can help me out? All help is appreciated.
__________________
-Ajira
Liek, omigosh.
<3 DoomsDay.
Reply With Quote
  #2  
Old 06-13-2004, 09:09 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
The time should be something like (dx*dx + dy*dy)^0.5 / speed, I think.
Reply With Quote
  #3  
Old 06-13-2004, 09:15 PM
Duwul Duwul is offline
Registered User
Join Date: Nov 2003
Posts: 105
Duwul is on a distinguished road
I actually had that, except I did not divide it by the speed at the end. I'll try it. Thanks.

EDIT: Well it worked. Thanks a lot!
__________________
-Ajira
Liek, omigosh.
<3 DoomsDay.
Reply With Quote
  #4  
Old 06-14-2004, 12:23 AM
Ningnong Ningnong is offline
Registered User
Ningnong's Avatar
Join Date: Nov 2002
Location: < -- way
Posts: 262
Ningnong is on a distinguished road
I have attached a baddy script - it uses the move command. I made it initially for archaic, but it should help you.

But to the point:

NPC Code:

tx = targetx - x;
ty = targety - y;
dist = (tx*tx+ty*ty)^0.5;
nx = (tx/dist)*walkspeed;
ny = (ty/dist)*walkspeed;



Edit:

Then simply use
NPC Code:

move nx,ny,walkspeed,1+4+8;



etc.

Hope It helped
Attached Files
File Type: txt baddy.txt (3.6 KB, 244 views)
__________________
Former Global Scripting Team Member



Last edited by Ningnong; 06-14-2004 at 01:14 PM..
Reply With Quote
  #5  
Old 06-14-2004, 05:40 AM
Duwul Duwul is offline
Registered User
Join Date: Nov 2003
Posts: 105
Duwul is on a distinguished road
I guess a bit, but I'm only looking for an equation to put in 'time' of the move command, so that no matter the distance it moves, the walking speed remains the same. I am not using x+/x-/y+/y-.
__________________
-Ajira
Liek, omigosh.
<3 DoomsDay.
Reply With Quote
  #6  
Old 06-14-2004, 11:15 PM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
try multiplying the distance by .05? dono

Last edited by Python523; 06-16-2004 at 08:52 PM..
Reply With Quote
  #7  
Old 06-16-2004, 07:28 PM
Duwul Duwul is offline
Registered User
Join Date: Nov 2003
Posts: 105
Duwul is on a distinguished road
Ran into a problem. I made a npc that walks in a straight line on the along the x axis and while its moving in between the 2 points, it goes very fast. I guess the equation didn't work properly =/
Can anyone help me out with one that works?
__________________
-Ajira
Liek, omigosh.
<3 DoomsDay.
Reply With Quote
  #8  
Old 06-16-2004, 09:49 PM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
try somethin like this
NPC Code:

if (mousedown) {
dx = mousex - x;
dy = mousey - y;
dist = (dx^2+dy^2)^.5;
speed = dist * .05;
move dx,dy,speed,;
}

Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:18 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.