Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Some functions (https://forums.graalonline.com/forums/showthread.php?t=73846)

Chandler 05-06-2007 08:38 AM

Some functions
 
Here are quite alot of functions that I use

HTML Code:

public function dropPosition()
{
  temp.playerPos = {{0.75, 1}, {0.6, 1.5}};
  temp.dropPos = {
    player.x + (player.dir in {0, 2}? temp.playerPos[0][0] : temp.playerPos[1][0]) + vecx(player.dir) * 2,
    player.y + (player.dir in {0, 2}? temp.playerPos[0][1] : temp.playerPos[1][1]) + vecy(player.dir) * 2
  };
  return temp.dropPos;
}

Drop position infront of the player

HTML Code:

public function grabPosition()
{
  temp.dropPos = {
    player.x + 1.5 + vecx(player.dir) * 1.5,
    player.y + 2 + vecy(player.dir) * 1.5
  };
  return temp.dropPos;
}

A players grab position of an object

HTML Code:

public function getDistance(newPosition)
{
  temp.allPositions = {
    (((temp.newPosition[0] - player.x) ^ 2) + ((temp.newPosition[1] - player.y) ^ 2) ^ 0.5),
    {(temp.newPosition[0] - player.x), (temp.newPosition[1] - player.y)},
    (((temp.newPosition[0] ^ 2) + (temp.newPosition[1] ^ 2)) ^ 0.5)
  };
  return temp.allPositions;

Returns three distances depending on how you want it.

HTML Code:

public function getCenter(objectWidth, objectHeight)
{
  return {((screenwidth / 2) - temp.objectWidth / 2), ((screenheight / 2) - temp.objectHeight / 2)};

Returns the center position of the graal client, being an image there.

HTML Code:

public function onRegainHealth()
{
  if (player.hearts != player.fullhearts)
  {
    triggerserver("weapon", this.name, "regainHealth");
  }
  scheduleevent(25, "RegainHealth", "");
}

-- Serverside part
HTML Code:

function onActionServerSide(currentOption)
{
  switch(temp.currentOption)
  {
    case "regainHealth":
      if ((timevar2 - clientr.lastRegain) <= 20 && clientr.lastRegain)
      {
        return false;
      }
      clientr.lastRegain = timevar2;
      //Do the health part...
    break;
  }
}

Regeneration for health, every 25 seconds.

Chompy 05-06-2007 12:34 PM

Nifty :)

Looks nice :D


All times are GMT +2. The time now is 01:13 PM.

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