Thread: Some functions
View Single Post
  #1  
Old 05-06-2007, 08:38 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
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.
Reply With Quote