Graal Forums

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

Rapidwolve 01-29-2007 12:56 AM

Math Help
 
I am finishing up an inventory script, but I need help for one part which is dropping an item. I want to make it so when the mousescreenx and mousescreeny variable is near the player another function begins. I'm not sure but I remember on an old script with it having something to do with %4 or something im not sure.

Help is appreciated, Thanks.

JkWhoSaysNi 01-29-2007 01:06 AM

Why not use mousex and mousey instead of mousescreenx?

Then you can compare mousex to player.x directly.

Rapidwolve 01-29-2007 01:11 AM

Because it is an inventory z.z. The items are not on the gmap they are on the screen

Tolnaftate2004 01-29-2007 01:16 AM

Quote:

Originally Posted by Rapidwolve (Post 1270763)
Because it is an inventory z.z. The items are not on the gmap they are on the screen

But if your mouse is dragging it, the mouse has a position on the screen AND on the board.

Rapidwolve 01-29-2007 01:18 AM

The mouse is just making a duplicate image on the screen. It's still using the mousescreenx/y var. Also I need to make it so if the mouse is in front of the player the player.dir changes to down, or if its right, the player.dir changes to right. I think thats where I got the %4 from

Tolnaftate2004 01-29-2007 01:26 AM

Quote:

Originally Posted by Rapidwolve (Post 1270765)
Also I need to make it so if the mouse is in front of the player the player.dir changes to down, or if its right, the player.dir changes to right. I think thats where I got the %4 from

PHP Code:

player.dir getdir(mousex-player.x,mousey-player.y); 

Oh no, mousex variable! Unthinkable.

Rapidwolve 01-29-2007 01:27 AM

I forgot that function existed, lol thanks. Now that thats done I realized another problem z.z.

Well im using a custom ItemLib with item IDs. {1-10 for currency, 200's guns, etc..}

PHP Code:

for (this.igetstringkeys("clientr.item_")){ 

Is what I am using, the problem is that. The script puts the item by the id number. For example I have "Dollar" as item_1. The script puts that in the first slot, I have no item_2 but I have item_3 as "Cent", so the script skips the next slot and puts it in the third one. I cant even see my gun which has an id of 240. Is it the way I'm using for();?

Tolnaftate2004 01-29-2007 01:37 AM

Quote:

Originally Posted by Rapidwolve (Post 1270768)
Is it the way I'm using for();?

Perhaps, I'm pretty sure the token before ":" is made to be a local variable, so I don't know what naming it this.- would do.

Rapidwolve 01-29-2007 01:39 AM

Even without the this.- its the same problem.

Chompy 01-29-2007 03:56 PM

PHP Code:

for( temp.igetstringkeys"clientr.item_"))
  echo( 
makevar"clientr.item_" temp.i)); 

do this output anything?

Chandler 01-29-2007 09:03 PM

HTML Code:

//#CLIENTSIDE
function onCreated()
{
  this.onTimeout();
}
function onTimeout()
{
  if (mousex in |player.x - 5, player.x + 5| && mousey in |player.y - 5, player.y + 5|)
  {
    //Do Direction...and drop effect
  }
  showimg(200, this.curImage, mousescreenx, mousescreeny);
  changeimgvis(200, 3);
}


Tolnaftate2004 01-29-2007 10:08 PM

Quote:

Originally Posted by Chandler (Post 1270996)
HTML Code:

  if (mousescreenx in |player.x - 5, player.x + 5| && mousescreeny in |player.y - 5, player.y + 5|)
  {
    //Do Direction...and drop effect
  }


mousescreen- and player.- position are using a different kind of coordinates.

It should be mousex-player.x in |-5,5| blah blah blah

Even better is
PHP Code:

if (((mousex-player.x)^2+(mousey-player.y)^2)^.5 5) {
  
// do stuffs



Chandler 01-29-2007 10:13 PM

Quote:

Originally Posted by Tolnaftate2004 (Post 1271025)
mousescreen- and player.- position are using a different kind of coordinates.

It should be mousex-player.x in |-5,5| blah blah blah

Or
HTML Code:

mousex in |player.x - 5, player.x + 5|
I should edit my post for mousex, not mousescreenx.

Tolnaftate2004 01-29-2007 10:16 PM

Quote:

Originally Posted by Chandler (Post 1271029)
Or
HTML Code:

mousex in |player.x - 5, player.x + 5|
I should edit my post for mousex, not mousescreenx.

Yeah, I didn't mean it needed to be exactly as I wrote it. That's merely my preference.

Chandler 01-29-2007 10:18 PM

Quote:

Originally Posted by Tolnaftate2004 (Post 1271032)
Yeah, I didn't mean it needed to be exactly as I wrote it. That's merely my preference.

Yeah, I prefer your way personally, as it looks more structured. :)


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

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