Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Functions during move() (https://forums.graalonline.com/forums/showthread.php?t=134257401)

Switch 12-22-2009 05:38 AM

Functions during move()
 
Is there any way to do some functions while an NPC is going through a move(), synchronized with every time it moves it's x and y?

cbk1994 12-22-2009 05:39 AM

Quote:

Originally Posted by Switch (Post 1546206)
Is there any way to do some functions while an NPC is going through a move() ?

Sure. move() doesn't freeze the thread like sleep() or waitfor().

Switch 12-22-2009 05:41 AM

Quote:

Originally Posted by cbk1994 (Post 1546207)
Sure. move() doesn't freeze the thread like sleep() or waitfor().

Updated post, realized that question wasn't going to get the answer intended.

cbk1994 12-22-2009 05:48 AM

I'm not sure if move() updated the x and y continually or only when it reaches the end, but you could do like:

PHP Code:

function whatever() {
  
this.move(52100); // delta x, delta y, time, options


If you wanted to call a function when it reached an x of 7, you would just schedule the event for when the x would be 7

Set it up like an equation

PHP Code:

+ (5/10)(t)

+ (5/10)(t)

= (5/10)(t)



then in your function

PHP Code:

function whatever() {
  
this.move(52100); // delta x, delta y, time, options
  
this.scheduleEvent(4"onMyFunction");


(not trying to sound condescending, sorry if it comes off that way)

Switch 12-22-2009 05:56 AM

Quote:

Originally Posted by cbk1994 (Post 1546209)
I'm not sure if move() updated the x and y continually or only when it reaches the end,

I'm trying to get the function to run continually as the npc actually moves, so that won't really help, especially since it's moving every .1 second and it takes the server .1 second to actually call a .05 second event, at least that's what I'm seeing in my test.

cbk1994 12-22-2009 05:59 AM

Quote:

Originally Posted by Switch (Post 1546210)
I'm trying to get the function to run continually as the npc actually moves, so that won't really help, especially since it's moving every .1 second and it takes the server .1 second to actually call a .05 second event, at least that's what I'm seeing in my test.

It's only updating every tenth of a second on serverside anyway, it just appears smooth on clientside because of some special scripting to make it move at 20 steps per second on clientside. The only thing you can really do is have a .1 second timeout on serverside.

Switch 12-22-2009 06:31 AM

Quote:

Originally Posted by cbk1994 (Post 1546212)
It's only updating every tenth of a second on serverside anyway, it just appears smooth on clientside because of some special scripting to make it move at 20 steps per second on clientside. The only thing you can really do is have a .1 second timeout on serverside.

I guess that could work. Would be much easier to have something like:
PHP Code:

with (npc.move(0.600.10)) {
  
//functions



fowlplay4 12-23-2009 08:20 AM

What are you doing that needs what you're looking for?

I know with Boats on Zodiac I just move in smaller intervals, and check for control input before it's next move.

Switch 12-23-2009 09:56 PM

Walls, players, water, etc.
I asked Chompy if he knew a way, and he did say to try simulating the movement and doing the checks in that, but it doesn't seem to work exactly like how I want it.

Immolate 12-23-2009 10:01 PM

Quote:

Originally Posted by Switch (Post 1546613)
Walls, players, water, etc.
I asked Chompy if he knew a way, and he did say to try simulating the movement and doing the checks in that, but it doesn't seem to work exactly like how I want it.

Could you show us your implementation?

Switch 12-23-2009 11:16 PM

Quote:

Originally Posted by Immolate (Post 1546616)
Could you show us your implementation?

I actually got it to work pretty well now :) Never mind I guess. Would still be neat.


All times are GMT +2. The time now is 10:54 AM.

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