Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-29-2012, 11:23 PM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
Quote:
Originally Posted by ffcmike View Post
Do you realise you have 2 conditions which are exactly the same?
If you were to remove the first line of player.account in this.tempStaff, it would still work.
Yes, I did that so if the first part didn't check, it wouldn't have to do the for loop, I assumed it would speed up what ever else it is doing if the first part was not correct.

The second part is only to add +1 to whatever the i is for the level, which I believe I could do with .index() but don't know how...


Quote:
Originally Posted by ffcmike View Post
player.level is an object rather than a string, the correct value to check is 'player.level.name'.
I have been told this many times, and I still don't quite understand it since the results are always the same. :[

Quote:
Originally Posted by ffcmike View Post
It's a bad practise to loop through non-changing arrays and use .size(); for every cycle, as the function will occur every time rather than once, this can generate a lot of overhead with very large arrays. The array size can be defined as a temporary variable beforehand, which can then be used in the loop condition.
for instance temp.num = something.size(); and stick that in the loop?
I shall do that!

Quote:
Originally Posted by ffcmike View Post
onTimeout(); occuring within function onTimeout(){} without any specification for it would run infinitely until cancelled by the engine/NPC-Server.
I'll ask you later, he says it does not work but I don't know what he had done. All I know is he had many loops inside of his and said it kept maxing out or something...

He is not on for me to ask. :[

-Correction-
He gave it to me to see, but I don't know if I have the right to expose it. :X
So I must ask.
__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz



Reply With Quote
  #2  
Old 03-30-2012, 01:16 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 Devil_Lord2 View Post
I have been told this many times, and I still don't quite understand it since the results are always the same. :[
I feel like I've explained this before to you. Objects are typically coerced into strings (using their name property) when you abuse them like strings. It's better to compare the strings yourself for clarity.
__________________
Reply With Quote
  #3  
Old 03-31-2012, 05:38 PM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
Quote:
Originally Posted by cbk1994 View Post
I feel like I've explained this before to you. Objects are typically coerced into strings (using their name property) when you abuse them like strings. It's better to compare the strings yourself for clarity.
You probably have and I still don't get it..
They just equal the same things in testing, unless I see an error of some kind giving physical evidence why it shouldn't be used I'll probably never fully understand. D:



ZeroG's algorithm I'll explain but won't show. It checks every tile within 32x32 of a level spreading out from the NPC. It finds the nearest path to the player, and comes back to it self in the check. After that it moves once...

This process repeats over and over and over until it moves towards the player.

It uses MANY for loops in the timeout, however, at the end it seems to NOT work if you do not have a sleep(.05); and having that makes it seriously slow...

Yet this algorythm works fine on another game that he is making in Simple. He doesn't want me to post it because he doesn't believe anyone else has tried it, nor does he believe anyone can fix it.

Is Graal not fast enough to do these type of things?

He uses V5 and it slowly comes to him, I use V6 and it seems to do the loop about 3 times before stopping.. if it finds me and I'm close to it then it will move to me once or twice... if I'm about 6 tiles away the finding part of the gets to me and stops... if I'm farther it stops in the same spot too..

If this cannot be helped without images or code than it is fine.
__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz



Reply With Quote
  #4  
Old 03-31-2012, 05:57 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Devil_Lord2 View Post
You probably have and I still don't get it..
They just equal the same things in testing, unless I see an error of some kind giving physical evidence why it shouldn't be used I'll probably never fully understand. D:
PHP Code:
function onCreated()
{
  
temp.obj = new TStaticVar("SomeObject");
  
  
temp.one = new SomeObject();
  
temp.two = new SomeObject();
  
  
temp.one.asdf "hi";
  
temp.two.asdf "foo";
  
  echo(
format("Object one is '%s'"temp.one));
  echo(
format("Object two is '%s'"temp.two));
  echo(
format("Object keys: '%s', '%s'"temp.one.asdftemp.two.asdf));
  
  
// Compare the objects as objects
  
if (temp.one == temp.two)
    echo(
"Objects are the same");
  else
    echo(
"Objects are different");
  
  
// Compare the objects after being coerced to strings
  
if (@temp.one == @temp.two)
    echo(
"Object names are equal");
  else
    echo(
"Object names are different");  

Output:
NPC Code:
Object one is 'SomeObject'
Object two is 'SomeObject'
Object keys: 'hi', 'foo'
Objects are different
Object names are equal


When the objects are coerced into strings, you get the object names only typically. In this example, it results in two objects appearing to be the same (because their object names are the same) even though we have just proven them to be different.

This is something you MUST be aware of when coercing objects into strings in GScript. It doesn't always work how you expect.
__________________
Skyld
Reply With Quote
  #5  
Old 03-31-2012, 06:47 PM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
Quote:
Originally Posted by Skyld View Post
PHP Code:
function onCreated()
{
  
temp.obj = new TStaticVar("SomeObject");
  
  
temp.one = new SomeObject();
  
temp.two = new SomeObject();
  
  
temp.one.asdf "hi";
  
temp.two.asdf "foo";
  
  echo(
format("Object one is '%s'"temp.one));
  echo(
format("Object two is '%s'"temp.two));
  echo(
format("Object keys: '%s', '%s'"temp.one.asdftemp.two.asdf));
  
  
// Compare the objects as objects
  
if (temp.one == temp.two)
    echo(
"Objects are the same");
  else
    echo(
"Objects are different");
  
  
// Compare the objects after being coerced to strings
  
if (@temp.one == @temp.two)
    echo(
"Object names are equal");
  else
    echo(
"Object names are different");  

Output:
NPC Code:
Object one is 'SomeObject'
Object two is 'SomeObject'
Object keys: 'hi', 'foo'
Objects are different
Object names are equal


When the objects are coerced into strings, you get the object names only typically. In this example, it results in two objects appearing to be the same (because their object names are the same) even though we have just proven them to be different.

This is something you MUST be aware of when coercing objects into strings in GScript. It doesn't always work how you expect.
Sorry, I know you are trying to help, but I'm confused as to what any of that means..

Can you do it in layman's terms and possibly actually use levels?
Also, why are levels objects and not only strings?
I thought levels were only names of a textfiles converted to .nw..
__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz



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 04:51 PM.


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