Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 05-06-2007, 12:34 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Nifty

Looks nice
__________________
Reply With Quote
Reply


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 05:10 AM.


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