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
  #16  
Old 12-13-2012, 09:19 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 Stowen View Post
So that would include determining players direction, correct? I tried the calculating distance, but I cant really figure out an efficient formula without figuring the players direction. Could somebody help me on a formula?
Quote:
Originally Posted by cbk1994 View Post
Use the distance formula:



Therefore, to get distance

PHP Code:
function dist(x1y1x2y2) {
  return (((
x1 x2) ^ 2) + ((y1 y2) ^ 2)) ^ 0.5;

..
__________________
Reply With Quote
  #17  
Old 12-13-2012, 02:23 PM
Stowen Stowen is offline
Graalian since '01
Join Date: Sep 2005
Location: Massachusets, USA
Posts: 156
Stowen will become famous soon enough
Send a message via AIM to Stowen Send a message via MSN to Stowen
Quote:
Originally Posted by cbk1994 View Post
..
Thanks, Chris, this actually helped me out a lot. I was just struggling, and came on to see if there were anymore replies.
Reply With Quote
  #18  
Old 12-13-2012, 02:31 PM
Stowen Stowen is offline
Graalian since '01
Join Date: Sep 2005
Location: Massachusets, USA
Posts: 156
Stowen will become famous soon enough
Send a message via AIM to Stowen Send a message via MSN to Stowen
Alright guys, so I used the formula for distance that Chris has supplied me with and it works great. I get a constant moving speed of 10. Not sure what the measurement for speed on Graal would be LOL but I got 10. That's enough for me to do my work. Anyways, here's the script if anybody wishes to use it themselves.

PHP Code:
//#CLIENTSIDE

function onCreated() {
onTimeOut();
}

function 
onTimeOut() {
this.x1 player.x;
this.y1 player.y;
sleep(1);
this.x2 player.x;
this.y2 player.y;
dist(this.x1this.y1this.x2this.y2);
}

function 
dist(x1y1x2y2) { 
  
this.dist = (((x1 x2) ^ 2) + ((y1 y2) ^ 2)) ^ 0.5;
  
player.chat this.dist;
  
setTimer(0.05);

Reply With Quote
  #19  
Old 12-13-2012, 02:43 PM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by cbk1994 View Post
..
I was trying to not confuse him since he's new to scripting. But that works better then what I suggested.

Quote:
Originally Posted by Stowen View Post
Alright guys, so I used the formula for distance that Chris has supplied me with and it works great. I get a constant moving speed of 10. Not sure what the measurement for speed on Graal would be LOL but I got 10. That's enough for me to do my work. Anyways, here's the script if anybody wishes to use it themselves.

PHP Code:
//#CLIENTSIDE

function onCreated() {
onTimeOut();
}

function 
onTimeOut() {
this.x1 player.x;
this.y1 player.y;
sleep(1);
this.x2 player.x;
this.y2 player.y;
dist(this.x1this.y1this.x2this.y2);
}

function 
dist(x1y1x2y2) { 
  
this.dist = (((x1 x2) ^ 2) + ((y1 y2) ^ 2)) ^ 0.5;
  
player.chat this.dist;
  
setTimer(0.05);

Normally you set the timer at the end of the timeout function itself..

and sleep(1).. isn't needed.. let me adjust it a little.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.x1 player.x;
  
this.y1 player.y;
  
setTimer(1);
}

function 
onTimeOut() {
  
dist(this.x1this.y1player.xplayer.y);
  
// set the values to current position
  
this.x1 player.x;
  
this.y1 player.y;
  
setTimer(1);
}

function 
dist(x1y1x2y2) { 
  
this.dist = (((x1 x2) ^ 2) + ((y1 y2) ^ 2)) ^ 0.5;
  
player.chat this.dist;

The reason I changed it like this is becasue if you set the variables after you check the distance.. the next time the script runs the dist() function it will be using the old values.. then updating them after the comparison. also sleep causes script problems.. you can just set the timer to 1 second intervals and not need sleep() or waitfor()
Reply With Quote
  #20  
Old 12-13-2012, 04:10 PM
Stowen Stowen is offline
Graalian since '01
Join Date: Sep 2005
Location: Massachusets, USA
Posts: 156
Stowen will become famous soon enough
Send a message via AIM to Stowen Send a message via MSN to Stowen
Ah thank you, and I'm not really new to scripting. I used to be very fluent in GS1 I just have some troubles with GS2, and I havent really done major scripting in a while, so I'm kinda rusty. Thanks for the tips, though, much appreciated. My big issue is complexity. I turn the simplest scripts into complex nightmares xD


*EDIT: Somebody has brought to my attention, and I can't believe I overlooked it myself. Warping from levels triggers it as speed hacking. How would I go about fixing that? I tried to do a level check, but it only sets the original variable on created, so that was pointless and rendered it useless. Any ideas?

Last edited by Stowen; 12-13-2012 at 06:31 PM..
Reply With Quote
  #21  
Old 12-13-2012, 10:22 PM
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 Stowen View Post
*EDIT: Somebody has brought to my attention, and I can't believe I overlooked it myself. Warping from levels triggers it as speed hacking. How would I go about fixing that? I tried to do a level check, but it only sets the original variable on created, so that was pointless and rendered it useless. Any ideas?
In my experience you have to be very careful with these kinds of detection systems, they get a lot of false positives. When the player enters a new level, just reset the timer (wait, say, a second before you start keeping track of their speed).
__________________
Reply With Quote
  #22  
Old 12-13-2012, 10:59 PM
Stowen Stowen is offline
Graalian since '01
Join Date: Sep 2005
Location: Massachusets, USA
Posts: 156
Stowen will become famous soon enough
Send a message via AIM to Stowen Send a message via MSN to Stowen
Yeah, I can imagine there to be alot of false positives. Without the level checks, I get one everytime somebody goes from one level to another. So just add an onPlayerEnters() command with the original x/y ?

Like this? :

PHP Code:
function onPlayerEnters() {
   
this.x1 player.x;
   
this.y1 player.y;
   
setTimer(1);

Reply With Quote
  #23  
Old 12-14-2012, 01:19 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 Stowen View Post
Yeah, I can imagine there to be alot of false positives. Without the level checks, I get one everytime somebody goes from one level to another. So just add an onPlayerEnters() command with the original x/y ?

Like this? :

PHP Code:
function onPlayerEnters() {
   
this.x1 player.x;
   
this.y1 player.y;
   
setTimer(1);

That is one way to do it, but ultimately your system needs to be more robust because you will have false positives in all kinds of cases. For starters, it shouldn't trigger an alarm until it's fairly certain a person is speed-hacking (sustained periods of time of increased speed).
__________________
Reply With Quote
  #24  
Old 12-14-2012, 01:50 AM
Stowen Stowen is offline
Graalian since '01
Join Date: Sep 2005
Location: Massachusets, USA
Posts: 156
Stowen will become famous soon enough
Send a message via AIM to Stowen Send a message via MSN to Stowen
Quote:
Originally Posted by cbk1994 View Post
For starters, it shouldn't trigger an alarm until it's fairly certain a person is speed-hacking (sustained periods of time of increased speed).
Yeah I was actually thinking about doing that. Right now I have a flag that staff have, and I'm using that to determine whether or not to monitor them. That's so it doesn't set off false positives for using boots. I'm going to attempt to script what you just suggested.
Reply With Quote
  #25  
Old 12-14-2012, 04:01 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by Stowen View Post
Yeah I was actually thinking about doing that. Right now I have a flag that staff have, and I'm using that to determine whether or not to monitor them. That's so it doesn't set off false positives for using boots. I'm going to attempt to script what you just suggested.
You don't need a flag. Last I checked it was possible to check the staff= list in the server options.

And I would suggest playing with the script doing countless test's until you have it perfected how you want.

Also not much changed form GS1 to GS2.. with the exception that GS2 is now more object oriented and you use ( and ).. ex : player.chat instead of setplayerprop #c... and settimer() instead of timeout =...

you could add backup checks.. and do like this.lastlevel = ... to store current level and have the alarm part of it not go off if the level is now different. it would help ensure that onPlayerEnters() is setting the new variables before it does it's next check cycle.

Does anyone know if there is a onPlayerLeaves() command? I have never looked it up to see.
Reply With Quote
  #26  
Old 12-14-2012, 08:53 PM
Stowen Stowen is offline
Graalian since '01
Join Date: Sep 2005
Location: Massachusets, USA
Posts: 156
Stowen will become famous soon enough
Send a message via AIM to Stowen Send a message via MSN to Stowen
Quote:
Originally Posted by scriptless View Post
Does anyone know if there is a onPlayerLeaves() command? I have never looked it up to see.
No I don't believe there is, but there is a onPlayerLogOut(). I've been working on it, and I found using onPlayerEnters() and setting the x/y again has fixed the level warping issue, so there arent anymore false positives from that. Now I'm working on recording how long they are moving at abnormal speeds, so lag doesn't set off more false positives. Thanks for all the help guys!
Reply With Quote
  #27  
Old 12-14-2012, 09:38 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
onPlayerLeaves() exists. Serverside event, and I believe the first parameter is the object of the player who left.
__________________
Reply With Quote
  #28  
Old 12-14-2012, 09:45 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Crow View Post
onPlayerLeaves() exists. Serverside event, and I believe the first parameter is the object of the player who left.
onPlayerLeaves() uses the 'player' scope.
onPlayerLogout() has the player object as a parameter.
Reply With Quote
  #29  
Old 12-14-2012, 10:06 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by ffcmike View Post
onPlayerLeaves() uses the 'player' scope.
onPlayerLogout() has the player object as a parameter.
Good to know.
__________________
Reply With Quote
  #30  
Old 12-14-2012, 10:48 PM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by ffcmike View Post
onPlayerLeaves() uses the 'player' scope.
onPlayerLogout() has the player object as a parameter.
Thanks, I thought there was both.. i remember gk getting the trade tables fixed because of player logout.. xD

would rep u but i give u to much rep as it is and it wont let me lol
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 06:18 PM.


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