Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-22-2009, 05:38 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
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?
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #2  
Old 12-22-2009, 05:39 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Switch View Post
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().
__________________
Reply With Quote
  #3  
Old 12-22-2009, 05:41 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by cbk1994 View Post
Sure. move() doesn't freeze the thread like sleep() or waitfor().
Updated post, realized that question wasn't going to get the answer intended.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #4  
Old 12-22-2009, 05:48 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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)
__________________
Reply With Quote
  #5  
Old 12-22-2009, 05:56 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by cbk1994 View Post
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.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #6  
Old 12-22-2009, 05:59 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Switch View Post
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.
__________________
Reply With Quote
  #7  
Old 12-22-2009, 06:31 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by cbk1994 View Post
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

__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.

Last edited by Switch; 12-22-2009 at 10:01 PM.. Reason: better way to do it :P
Reply With Quote
  #8  
Old 12-23-2009, 08:20 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #9  
Old 12-23-2009, 09:56 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
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.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #10  
Old 12-23-2009, 10:01 PM
Immolate Immolate is offline
Indigo
Join Date: Dec 2009
Posts: 322
Immolate is on a distinguished road
Quote:
Originally Posted by Switch View Post
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?
Reply With Quote
  #11  
Old 12-23-2009, 11:16 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Immolate View Post
Could you show us your implementation?
I actually got it to work pretty well now Never mind I guess. Would still be neat.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 01:10 AM.


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