Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   function... (https://forums.graalonline.com/forums/showthread.php?t=74064)

theHAWKER 05-19-2007 04:25 PM

function...
 
is there a function like "function onPlayerMoves()" or something that would update the npc every time the player moves??

Chompy 05-19-2007 04:26 PM

use a loop to check the players x and y movement :)

Gambet 05-19-2007 04:32 PM

You could set two constant clientside variables that monitor the player's LAST x and y coordinates in a system NPC and then do something like:

PHP Code:

//#CLIENTSIDE
function onKeyPressed()
{
 for (
dir 0dir 4dir++)
  {
   if (
keydown(dir))
    {
     if (
player.!= client.lastplayer_x || player.!= client.lastplayer_y)
      {
       
//The player has moved!
      
}
    }
  }



theHAWKER 05-19-2007 04:33 PM

so are you saying that there isn't?

Gambet 05-19-2007 04:34 PM

Quote:

Originally Posted by theHAWKER (Post 1309495)
so are you saying that there isn't?


No, make your own system for it.

theHAWKER 05-19-2007 04:55 PM

Quote:

Originally Posted by Gambet (Post 1309496)
No, make your own system for it.

umkay, but there should be a built in function for that :(

Twinny 05-19-2007 05:14 PM

Quote:

Originally Posted by theHAWKER (Post 1309505)
umkay, but there should be a built in function for that :(

onPlayermoves() wouldn't be a function: it would be an event. Also, there is no inherit action for moving. Some playerworlds don't use the default movement system for starters.

In short: I doubt there will ever be a onPlayermoves() event since it would be too limited. A keydown loop check can work for whenever the player walks or a timeout check if there are other methods of moving.

Deadly_Killer 05-19-2007 05:55 PM

PHP Code:

// Custom Events System

//#CLIENTSIDE
// Set Default Flags
function onCreated()
{
  
this.pxy = {player.xplayer.y};
  
this.screen = {screenwidthscreenheight};
  
  
this.onTimeout();
}

function 
onTimeout()
{
  
// function onPlayerMoved(newx, newy) { }
  
if (player.!= this.pxy[0] || player.!= this.pxy[1])
  {
    
this.pxy = {player.xplayer.y};
    
    for (
temp.var : weaponstemp.var.trigger("PlayerMoved"player.xplayer.y);
  }

  
// function onScreenResize(newwidth, newheight) { }
  
if (screenwidth != this.screen[0] || screenheight != this.screen[1])
  {
    
this.screen = {screenwidthscreenheight};
    
    for (
temp.var : weaponstemp.var.trigger("ScreenResize"screenwidthscreenheight); // function onPlayerMoved(newx, newy) { }
  
}
  
  
setTimer(0.05);


Add it to every player. I could only think of two new events, but if others can think of more, you can easily add them.

Enjoy ;)

P.S. Events only work in weapons.

Novo 05-19-2007 06:40 PM

Quote:

Originally Posted by Deadly_Killer (Post 1309535)
stuff

For ScreenResize, I just do
PHP Code:

function GraalControl.onResize()
{
  
// stuff



Deadly_Killer 05-19-2007 07:10 PM

Quote:

Originally Posted by Novo (Post 1309552)
For ScreenResize, I just do
PHP Code:

function GraalControl.onResize()
{
  
// stuff



:o?

Skyld 05-19-2007 07:13 PM

Quote:

Originally Posted by Deadly_Killer (Post 1309561)
:o?

GraalControl is the control that contains pretty much the Graal interface. When the window is resized, GraalControl is resized also to match, and GraalControl.onResize() is called.

Deadly_Killer 05-19-2007 07:18 PM

Quote:

Originally Posted by Skyld (Post 1309563)
GraalControl is the control that contains pretty much the Graal interface. When the window is resized, GraalControl is resized also to match, and GraalControl.onResize() is called.

Sounds cool, I guess.

xXziroXx 05-19-2007 10:23 PM

PHP Code:

//#CLIENTSIDE
function onCreated() GraalControl.width GraalControl.height 50

<3

DustyPorViva 05-20-2007 12:28 AM

Is it a read only thing?

Rapidwolve 05-20-2007 12:47 AM

Quote:

Originally Posted by DustyPorViva (Post 1309663)
Is it a read only thing?

I was about to ask the same exact thing before you posted :\ :P

Gambet 05-20-2007 01:11 AM

Quote:

Originally Posted by DustyPorViva (Post 1309663)
Is it a read only thing?


If you're talking about the GraalControl object, then if you look at Ziro's post, you'll see that he altered the height/width, so I wouldn't think so.


Though, I've never used the GraalControl object except for checking whether or not it's the firstresponder.

Novo 05-20-2007 01:18 AM

I do believe it is read/write... The problem is that the content not covered by GraalControl is in YOUR duty to generate content... That is... You're responsible for the blank-spots. With that insight, it's best not to play with it unless you're doing something quite... Custom.

DustyPorViva 05-20-2007 01:37 AM

Well he may have posted the script, doesn't mean he used it, which is really why I asked. Not a big deal anyways.

Deadly_Killer 05-20-2007 03:12 AM

Yeah.. it totally messes your screen up =(

xXziroXx 05-20-2007 03:54 PM

Quote:

Originally Posted by DustyPorViva (Post 1309716)
Well he may have posted the script, doesn't mean he used it, which is really why I asked. Not a big deal anyways.

If you logon Mythic, you'll see that I've shrunken the height of it and added a hotkey bar there (which can best be seen when you press F8).

xAndrewx 05-22-2007 10:13 PM

Quote:

Originally Posted by Deadly_Killer (Post 1309535)
PHP Code:

//#CLIENTSIDE
function onCreated()

  
this.onTimeout();
}

function 
onTimeout()
{
  
// function onPlayerMoved(newx, newy) { }
  
if (player.!= this.pxy[0] || player.!= this.pxy[1])
  {
    
this.pxy = {player.xplayer.y};
    
    for (
temp.var : weaponstemp.var.trigger("PlayerMoved"player.xplayer.y);
  }
  
setTimer(0.05);



Very poor... make it set a player flag to say that the player is moving, don't send every weapon that the player has an event saying that the player has moved. Why would you even need that?

Deadly_Killer 05-22-2007 10:22 PM

Quote:

Originally Posted by xAndrewx (Post 1310773)
Very poor... make it set a player flag to say that the player is moving, don't send every weapon that the player has an event saying that the player has moved. Why would you even need that?

Explain why you would waste a timeout on the clientside for 0.05 for something like this.

This is the best solution without creating wasteful timeouts for events. Besides the current events do the same thing too.

xAndrewx 05-22-2007 10:28 PM

Quote:

Originally Posted by Deadly_Killer (Post 1310776)
Explain why you would waste a timeout on the clientside for 0.05 for something like this.

This is the best solution without creating wasteful timeouts for events. Besides the current events do the same thing too.

Still, you've just ignored my question! Why are you checking if a player has moved?
If anything, send it to the selected weapon. You could even make it a flag.

HTML Code:

//#CLIENTSIDE
function onCreated()
{
  setTimer(0.05);
}
function onTimeout()
{
  if (player.currentPosition[0] != player.x || temp.currentPosition[1] != player.y)
  {
    player.currentPosition.clear();
    player.currentPosition.addArray(0, {player.x, player.y});
    player.isMoving = true;
  }
    else
  {
    player.isMoving = false;
  }
}

Although, a built in event would be better!

Deadly_Killer 05-22-2007 10:34 PM

What if someone needed the event for 10 weapons. Are you going to make 10 timeouts to check for the new flag.

xAndrewx 05-22-2007 10:37 PM

I'd call you retarded for having 10 different weapons to check if a person has moved.

Deadly_Killer 05-22-2007 10:37 PM

Quote:

Originally Posted by xAndrewx (Post 1310790)
I'd call you retarded for having 10 different weapons to check if a person has moved.

Hypothetical situation.

xAndrewx 05-22-2007 10:44 PM

Still, I'd call you retarded! However, since you insist!
I'd be an innovator and create my own movement system, which wouldn't involve ten different weapons having the same check, I'd also create a flag which would only check if the player has moved, that is if the flag exists of cause! I'd also gloat in your face, show how it's done and also post it on video jug [I also insist that you use google for your research!] to show how optimization works!

JkWhoSaysNi 05-22-2007 10:48 PM

Quote:

Originally Posted by xXziroXx (Post 1309892)
If you logon Mythic, you'll see that I've shrunken the height of it and added a hotkey bar there (which can best be seen when you press F8).

How did you do that?

I want to do that, but I can't create GUI controls outside the GraalControl.

Deadly_Killer 05-22-2007 10:54 PM

Quote:

Originally Posted by xAndrewx (Post 1310798)
Still, I'd call you retarded! However, since you insist!
I'd be an innovator and create my own movement system, which wouldn't involve ten different weapons having the same check, I'd also create a flag which would only check if the player has moved, that is if the flag exists of cause! I'd also gloat in your face, show how it's done and also post it on video jug [I also insist that you use google for your research!] to show how optimization works!

I think you're totally off the subject now.

xXziroXx 05-22-2007 11:20 PM

Quote:

Originally Posted by JkWhoSaysNi (Post 1310802)
How did you do that?

I want to do that, but I can't create GUI controls outside the GraalControl.

I will be delighted to show you how it works!

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
GraalControl.height GUIContainer.height 56;

  new 
GuiControl("Hotbar_Main") {
    
width screenwidthheight 57;
    
0GUIContainer.height height;
      
    
GUIContainer.addControl(this);  // Note this line in particularly
  
}



zokemon 05-23-2007 02:10 AM

I love how little people know about GUIs :)
(ie GraalControl)

Inverness 05-23-2007 02:40 AM

Quote:

Originally Posted by zokemon (Post 1310887)
I love how little people know about GUIs :)
(ie GraalControl)

Then you're a bad scripter. Good scripters try to help the community.

zokemon 05-23-2007 03:01 AM

Quote:

Originally Posted by xXziroXx (Post 1310813)
I will be delighted to show you how it works!

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
GraalControl.height GUIContainer.height 56;

  new 
GuiControl("Hotbar_Main") {
    
width screenwidthheight 57;
    
0GUIContainer.height height;
      
    
GUIContainer.addControl(this);  // Note this line in particularly
  
}




I showed you how it works <3

Quote:

Originally Posted by Inverness (Post 1310908)
Then you're a bad scripter. Good scripters try to help the community.

This thread already seems answered enough... I help with scripting errors plenty, there is nothing for me to say otherwise here.

xXziroXx 05-23-2007 03:10 AM

Quote:

Originally Posted by zokemon (Post 1310916)
I showed you how it works <3

And so the Apprentice has became the Master.

Kristi 05-23-2007 05:38 AM

Can you guys not have a discussion without pride issues and attacking each other?

killerogue 05-23-2007 06:44 AM

Quote:

Originally Posted by Kristi (Post 1310974)
Can you guys not have a discussion with pride issues and attacking each other?

Fixed. :cool:

And well pride issues are gunna happen hell raven. It's what happen when every scripts a different way and think they're rather damn good at it.

xAndrewx 05-23-2007 07:36 AM

We're man.

Twinny 05-23-2007 10:53 AM

Quote:

Originally Posted by xAndrewx (Post 1310986)
We're man.

You mean 'men'? :D

Inverness 05-24-2007 02:59 AM

I do consider myself the most organized in scripting and other things, on Graal at least. :D
Quote:

Originally Posted by Kristi
Can you guys not have a discussion without pride issues and attacking each other?

If you're referring to me then you missed the joke. I shall now direct you to my title.

zokemon 05-24-2007 03:05 AM

Quote:

Originally Posted by Inverness (Post 1311236)
I do consider myself the most organized in scripting and other things, on Graal at least. :D
If you're referring to me then you missed the joke. I shall now direct you to my title.

I think he was refering to my comment pointing out people's lack of knowledge with GUIs.


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

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