PDA

View Full Version : Some functions


Chandler
05-06-2007, 09:38 AM
Here are quite alot of functions that I use


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


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


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.


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.


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

-- Serverside part

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, 01:34 PM
Nifty :)

Looks nice :D