Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Point n click movement system (https://forums.graalonline.com/forums/showthread.php?t=72985)

DrakilorP2P 03-22-2007 01:40 AM

Point n click movement system
 
This script implements a Diablo 2 style movement system. You click on a location and the player will attempt to move there. Included is acceleration and friction, which are configurable from onCreated().
This script used to have stamina and walking/running, but I removed it since most people would probably want to implement their own such system anyway (And to avoid bloating the script with features no one will use which only make it harder to read.).

Here's some documentation to help you expand it if necessary.

onCreated():
  • Variable initialisation.
onTimeout():
  • Acceleration, friction and movement.
SetTarget(x, y):
  • Properly sets this.target.[x/y] which is where the player will accelerate towards.
Accelerate(xspeed, yspeed, maxspeed):
  • Properly increases this.speed.[x/y] to avoid accelerating further than maxspeed.
Move(x, y):
  • Moves the player with block detection.
Distance(x, y):
  • Helper function; returns distance between (0, 0) and (x, y).

Installation: Used as a weapon.
PHP Code:

//#CLIENTSIDE

//**************************************************
function onCreated()
{
  
this.baseSpeed 8;
  
this.acceleration 4;
  
this.baseFriction 0.5;
  
  
this.target.player.1.5;
  
this.target.player.2;
  
  
onTimeout();
}


//**************************************************
function onTimeout()
{
  
// *****Set target position so we know where to move
  
if (leftmousebutton) {
    
SetTarget(mousexmousey);
  }
  
  
// *****Friction (We aren't walking on ice)
  
this.speed.*= this.baseFriction;
  
this.speed.*= this.baseFriction;
  
  
// *****Accelerate so we'll eventually reach that target position.
  
if (Distance(this.target.player.1.5this.target.player.2) > && !this.stopped) {
    
temp.angle getangle(this.target.player.1.5this.target.player.2);
    
temp.speed.cos(temp.angle) * this.acceleration;
    
temp.speed.= -sin(temp.angle) * this.acceleration;
    
    
Accelerate(temp.speed.xtemp.speed.ythis.baseSpeed);
    
    
setani("walk""");
  }
  else
  {
    if (
this.speed.0.5 && this.speed.> -0.5this.speed.0;
    if (
this.speed.0.5 && this.speed.> -0.5this.speed.0;
    
this.stopped true;
    
setani("idle""");
  }
  
  
// *****Actually move the player according to current speed.
  
Move(this.speed.xthis.speed.y);
  if (
this.speed.!= && this.speed.!= 0player.dir getdir(this.speed.xthis.speed.y);

  
setTimer(0.05);
}


//**************************************************
function onMouseDown(button)
{
  
// Set target position so we know where to move.
  
if (button == "left") {
    
SetTarget(mousexmousey);
  }
}


//**************************************************
// Set the position the system will try to reach.
function SetTarget(targetxtargety)
{
    if (
Distance(targetx player.1.5targety player.2) > 1) {
      
this.target.targetx;
      
this.target.targety;
      
this.stopped false;
    }
}


//**************************************************
// Increase the speed in pixels per frame.
function Accelerate(xSpeedySpeedmaxSpeed)
{
  if (
Distance(this.speed.xthis.speed.y) < maxSpeed || (Distance(this.speed.xSpeedthis.speed.ySpeed) - Distance(this.speed.xthis.speed.y)) <= 0) {
    
this.speed.+= xSpeed;
    
this.speed.+= ySpeed;
    
    if (
Distance(this.speed.xthis.speed.y) > maxSpeed) {
      
temp.angle getangle(this.speed.xthis.speed.y);
      
this.speed.cos(temp.angle) * maxSpeed;
      
this.speed.= -sin(temp.angle) * maxSpeed;
    }
  }
}


//**************************************************
// Move the player by specified amount of pixels.
function Move(xSpeedySpeed)
{
  if (!
isapplicationactive) return;
  
  
xSpeed xSpeed<0?int(xSpeed)+1:int(xSpeed);
  
ySpeed ySpeed<0?int(ySpeed)+1:int(ySpeed);
  
  
// --- 'x' movement of the player --- \\
  
if (xSpeed != 0) {
    
temp.int(player.16);
    
temp.xDir = (abs(xSpeed) / xSpeed);
    for (
i=0i<abs(xSpeed); i++) {
      if (!
onwall2(temp.16 temp.xDir * (1/16), player.211)) temp.+= temp.xDir;
      else break;
    }
    
player.temp.16;
  }
  
  
// --- 'y' movement of the player --- \\
  
if (ySpeed != 0) {
    
temp.int(player.16);
    
temp.yDir = (abs(ySpeed) / ySpeed);
    for (
i=0i<abs(ySpeed); i++) {
      if (!
onwall2(player.1temp.16 temp.yDir * (1/16), 11)) temp.+= temp.yDir;
      else break;
    }
    
player.temp.16;
  }
  
  
//Hack
  
if (tiletype(player.1.5player.2) == 3) {
    
setani("sit""");
  }
}


//**************************************************
//Calculate the distance between (0, 0) and (dx, dy).
function Distance(dxdy)
{
  return ((
dx)^+ (dy)^2)^0.5



Angel_Light 03-22-2007 02:35 AM

awesome ^_^

Rapidwolve 03-22-2007 02:48 AM

Nice

theHAWKER 03-22-2007 03:15 AM

where do u put this script? in weapons?

Switch 03-22-2007 03:49 AM

It looks good. Doesn't work on servers O.o

killerogue 03-22-2007 04:12 AM

Quote:

Originally Posted by theHAWKER (Post 1291559)
where do u put this script? in weapons?

Damn, GS1 using....UIGGGHGHGSDNGSK

Quote:

Originally Posted by Switch (Post 1291572)
It looks good. Doesn't work on servers O.o

It works on Mythic so YOU must've ****ed it up.

Twinny 03-22-2007 04:37 AM

Quote:

Originally Posted by DrakilorP2P (Post 1291531)
You click on a location and the player will attempt to move there.

Haha one part of my master plan has been taken >_<. I wanted to make a point and click styled system like Monkey Island.

DrakilorP2P 03-22-2007 09:47 AM

More precise installation instructions:
1. Get access to a server using GS2.
2. Insert the script as a "weapon". For example: System/Movement.
3. Add the weapon to your account, or add a script that automatically adds it when a player connect.

Quote:

Originally Posted by Twinny (Post 1291591)
Haha one part of my master plan has been taken >_<. I wanted to make a point and click styled system like Monkey Island.

You can view it in two ways:
1. Part of your master plan was taken.
or 2. Someone wrote the script for you.

xXziroXx 03-22-2007 11:01 AM

Thats right folks! Now YOUR server can have a small part of Mythic on them!

Twinny 03-22-2007 03:13 PM

Quote:

Originally Posted by DrakilorP2P (Post 1291637)
You can view it in two ways:
1. Part of your master plan was taken.
or 2. Someone wrote the script for you.

I'd have to write a pretty damn good pathfinding system for mine...or get some unlucky LAT to map out possible paths in each level ^^. I suppose you could write a spider to scan all possible paths then save them to a database...hmm...

Angel_Light 03-22-2007 10:20 PM

Links don't work with this, nor does onPlayerTouchsMe() :| Gotta make some checks and so forth, works well on a gmap =D

Crow 03-22-2007 10:37 PM

Quote:

Originally Posted by Switch (Post 1291572)
It looks good. Doesn't work on servers O.o

Pretty nice script! I checked it, looks pretty cool. I got no server to test it atm though :/

Edit: Correction: I actually got one, but my RC seems to be totally ****ed up.

Switch 03-22-2007 11:19 PM

Quote:

Originally Posted by Crow (Post 1291858)
Pretty nice script! I checked it, looks pretty cool. I got no server to test it atm though :/

Edit: Correction: I actually got one, but my RC seems to be totally ****ed up.

I happen to OWN a server and I put it on to test it and it DIDN'T work. AND I had one of my GATs test it RIGHT now. It ALSO didn't work.

Twinny 03-22-2007 11:41 PM

Did you add the weapon to yourselves? :rolleyes:

Angel_Light 03-23-2007 12:48 AM

Quote:

Originally Posted by Switch (Post 1291874)
I had one of my GATs test it RIGHT now. It ALSO didn't work.

GAT != NAT

lol

EDIT: How would I reset setTarget()? I've tried a few different method but the player spazzes out or just head north east. :/ Also I tried to make it so the players normal movement isnt afftected by this aswell and failed... any pointers to get me started?

DrakilorP2P 03-23-2007 01:04 PM

Quote:

Originally Posted by Angel_Light (Post 1291917)
EDIT: How would I reset setTarget()? I've tried a few different method but the player spazzes out or just head north east. :/ Also I tried to make it so the players normal movement isnt afftected by this aswell and failed... any pointers to get me started?

disabledefmovement();

this.stopped = true; or setTarget(player.x+1.5, player.y+.2).
The latter may or may not work, but it looks neater.

Angel_Light 03-24-2007 12:22 AM

Quote:

Originally Posted by DrakilorP2P (Post 1292121)
disabledefmovement();

this.stopped = true; or setTarget(player.x+1.5, player.y+.2).
The latter may or may not work, but it looks neater.

tried player goes to north west

middo 04-10-2007 11:54 AM

I did a little modification so that it works with arrow keys :D

There was also a bug in the condition before your getdir(speed.x,speed.y)
You had &&'d it, and so it wouldn't update the direction if you were only moving one way. Just replace && with || like I did here.

EDIT: I changed a lot of the code. There were a lot of problems, I tested it with a friend and when we collided, we were stuck on each other! Now you can get out of walls and not fly through them if moving fast (only does the save check if you are stuck in a wall, otherwise you can still have a high speed set and the raytrace won't skip the wall)

LAST EDIT:
I fixed my own bugs and made it work almost perfectly! A saveCheck is set and overrides the speeds to try and get you out of the wall. Works perfectly for me :D
If you want to use it for mouse still, just uncomment the mouse lines I took out.

PHP Code:

//#CLIENTSIDE

//**************************************************
function onCreated()
{
  
this.baseSpeed 8;
  
this.acceleration 4.5;
  
this.baseFriction .5;
  
  
this.target.player.1.5;
  
this.target.player.2;
  
  
onTimeout();
  
  
disabledefmovement();
}

function 
onPlayerEnters()
{
  
disabledefmovement();
  
this.target.player.1.5;
  
this.target.player.2;  
}


//**************************************************
function onTimeout()
{
  
modY=0;
  
modX=0;
  if (
keydown(0))    modY=-1.2;
  if (
keydown(1))    modX=-1.2;
  if (
keydown(2))    modY=1.2;
  if (
keydown(3))    modX=1.2;

  if (
modY != || modX != 0SetTarget(player.x+1.5+modX,player.y+2+modY);  
  
  
// *****Set target position so we know where to move
  //if (leftmousebutton) {
  //  SetTarget(mousex, mousey);
  //}
  
  // *****Friction (We aren't walking on ice)
  
this.speed.*= this.baseFriction;
  
this.speed.*= this.baseFriction;
  
  
// *****Accelerate so we'll eventually reach that target position.
  
if (Distance(this.target.player.1.5this.target.player.2) > && !this.stopped) {
    
temp.angle getangle(this.target.player.1.5this.target.player.2);
    
temp.speed.cos(temp.angle) * this.acceleration;
    
temp.speed.= -sin(temp.angle) * this.acceleration;
    
    
Accelerate(temp.speed.xtemp.speed.ythis.baseSpeed);
    
setani("walk""");
  }
  else
  {
    if (
this.speed.0.1 && this.speed.> -0.1this.speed.0;
    if (
this.speed.0.1 && this.speed.> -0.1this.speed.0;
    
this.stopped true;
  }
  
  
// *****Actually move the player according to current speed.
  
Move(this.speed.xthis.speed.y);
  if (
this.speed.!= || this.speed.!= 0player.dir getdir(this.speed.xthis.speed.y);
  if ((
modX == && modY == 0) && (this.speed.!=|| this.speed.!=0)) 
  {
  
this.stopped == true;
  
SetTarget(player.x+1.5,player.y+2);
    
//Hack
  
if (tiletype(player.1.5player.2) == 3) {
    
setani("sit""");
  } else {
      
setani("idle""");
    }
  }
  
  
setTimer(0.05);
}


//**************************************************
/*function onMouseDown(button)
{
  // Set target position so we know where to move.
  if (button == "left") {
    SetTarget(mousex, mousey);
  }
}*/


//**************************************************
// Set the position the system will try to reach.
function SetTarget(targetxtargety)
{
    if (
Distance(targetx player.1.5targety player.2) > 1) {
      
this.target.targetx;
      
this.target.targety;
      
this.stopped false;
    }
}


//**************************************************
// Increase the speed in pixels per frame.
function Accelerate(xSpeedySpeedmaxSpeed)
{
  
  if (
Distance(this.speed.xthis.speed.y) < maxSpeed || (Distance(this.speed.xSpeedthis.speed.ySpeed) - Distance(this.speed.xthis.speed.y)) <= 0) {
//    if (modX != 0 || modY != 0) {
    
this.speed.+= xSpeed;
    
this.speed.+= ySpeed;
//    }
    
if (Distance(this.speed.xthis.speed.y) > maxSpeed) {
      
temp.angle getangle(this.speed.xthis.speed.y);
      
this.speed.cos(temp.angle) * maxSpeed;
      
this.speed.= -sin(temp.angle) * maxSpeed;
    }
  }
}

//**************************************************
// Move the player by specified amount of pixels.
function Move(xSpeedySpeed)
{
  
//if (!isapplicationactive) return;
  
  
xSpeed xSpeed<0?int(xSpeed)+1:int(xSpeed);
  
ySpeed ySpeed<0?int(ySpeed)+1:int(ySpeed);
  
  
temp.saveCheck onwall2(player.x+1,player.y+2,1,1); // modify our detection to get unstuck if we are
  
  // --- 'x' movement of the player --- \\
  
if (xSpeed != 0) {
    
temp.xDir = (abs(xSpeed) / xSpeed);
    
temp.int(player.16);
    
temp.scanx 0;
    for (
i=0< (temp.saveCheck .45 abs(xSpeed)); ++ ) {
      if (!
onwall2((temp.x+(i*temp.xDir)) / 16 + (temp.xDir*(temp.saveCheck 24 8)) * (1/16), player.211)) temp.scanx++;
      else if (
temp.saveCheck) continue; else break;
    }
    
temp.x+=(temp.scanx*temp.xDir);
    
player.temp.16;
  }
  
  
// --- 'y' movement of the player --- \\
  
if (ySpeed != 0) {
    
temp.int(player.16);
    
temp.yDir = (abs(ySpeed) / ySpeed);
    
temp.scany 0;    
    for (
i=0i<(temp.saveCheck .45 abs(ySpeed)); i++) {
      if (!
onwall2(player.1, (temp.y+(temp.scany*temp.yDir)) / 16 + (temp.saveCheck 1.5 2) + (temp.yDir*(temp.saveCheck 24 1)) * (1/16), 11)) temp.scany++;
      else if (
temp.saveCheck) continue; else break;
    }
    
temp.y+=(temp.scany*temp.yDir);
    
temp.varia=onwall2(player.x+1,player.y+2,1,1);
    
player.temp.16;
  }
  if (
tiletype(player.1.5player.2) == 3) {
    
setani("sit""");
  }  

}


//**************************************************
//Calculate the distance between (0, 0) and (dx, dy).
function Distance(dxdy)
{
  return ((
dx)^+ (dy)^2)^0.5


I'll be using this I think.
Thanks <3

Angel_Light 06-07-2008 05:56 AM

sorry to bring up an old thread but I have a question, in middo's form of this script, near the bottom of the script what is the point of

PHP Code:

temp.varia=onwall2(player.x+1,player.y+2,1,1); 


Crow 06-07-2008 11:50 AM

Quote:

Originally Posted by Angel_Light (Post 1395168)
sorry to bring up an old thread but I have a question, in middo's form of this script, near the bottom of the script what is the point of

PHP Code:

temp.varia=onwall2(player.x+1,player.y+2,1,1); 


Most likely an unused leftover variable.

cbk1994 06-07-2008 06:05 PM

Quote:

Originally Posted by Angel_Light (Post 1395168)
sorry to bring up an old thread but I have a question, in middo's form of this script, near the bottom of the script what is the point of

PHP Code:

temp.varia=onwall2(player.x+1,player.y+2,1,1); 


Without reading the script, it would seem that he is using it for some kind of wall detection, no?

Crow 06-07-2008 06:16 PM

Quote:

Originally Posted by cbk1994 (Post 1395233)
Without reading the script, it would seem that he is using it for some kind of wall detection, no?

Well, it isn't used anywhere else. Maybe he wanted to do that first, but I guess he didn't like that idea later ;P

cbk1994 06-07-2008 06:24 PM

Quote:

Originally Posted by Crow (Post 1395240)
Well, it isn't used anywhere else. Maybe he wanted to do that first, but I guess he didn't like that idea later ;P

I bet it's just there to piss people off.

Angel_Light 06-07-2008 06:44 PM

haha, I was did a search last night for all posts that have my server name in it and this came up, it puzzled me. XD

Deas_Voice 06-07-2008 10:05 PM

Quote:

Originally Posted by Angel_Light (Post 1395248)
haha, I was did a search last night for all posts that have my server name in it and this came up, it puzzled me. XD

how meny posts was it? xD

cbk1994 06-07-2008 11:13 PM

1 Attachment(s)
Quote:

Originally Posted by Deas_Voice (Post 1395278)
how meny posts was it? xD

Attachment 44841

Crow 06-07-2008 11:26 PM

1 Attachment(s)
We are doomed.

Attachment 44843

xXziroXx 06-08-2008 12:27 AM

Quote:

Originally Posted by Crow (Post 1395303)
We are doomed.

Attachment 44843

I don't get it.

cbk1994 06-08-2008 01:37 AM

Quote:

Originally Posted by xXziroXx (Post 1395318)
I don't get it.

Neither does a quick Google search ...

DustyPorViva 06-08-2008 02:28 AM

I'm assuming the movie 23. I haven't seen it, but I think it's like the evil 42.

Angel_Light 06-08-2008 06:45 AM

hey! 42 is the answer to life, the universe, and everything!

cbk1994 06-08-2008 06:58 AM

1 Attachment(s)
Quote:

Originally Posted by Angel_Light (Post 1395401)
hey! 42 is the answer to life, the universe, and everything!

Google agrees.

Attachment 44844

Crow 06-08-2008 10:39 AM

Quote:

Originally Posted by DustyPorViva (Post 1395347)
I'm assuming the movie 23. I haven't seen it, but I think it's like the evil 42.

Ding ding ding. 23 and its cross sum 5, Illuminati.

DrakilorP2P 06-25-2008 02:59 AM

Since this thread is already kind of bumped:

PHP Code:

function onActionServerSide()
{
  switch (
params[0]) {    
    case 
"freezeplayer":
      
clientr.frozen true;
    break;
    
    case 
"unfreezeplayer":
      
clientr.frozen false;
    break;
  }
}

//#CLIENTSIDE

//**************************************************
function onCreated()
{
  
this.baseSpeed 12;
  
this.acceleration 2;
  
this.friction.plain 0.75// <- Ordinary, which means 'normal ground'.
  
this.friction.water 0.5;
  
this.friction.chair 0.5;
  
this.friction.air 0.95;
  
this.gravity 2;
  
  
this.baseJumpPower.xy 25;
  
this.baseJumpPower.7;
  
this.doublePressDelay 0.25;
  
  
this.gani.idle "idle";
  
this.gani.walk "walk";
  
this.gani.slowWalk "slowwalk";
  
this.gani.swim "swim";
  
this.gani.sit "sit";
  
  
disabledefmovement();
  
  
onTimeout();
}


//**************************************************
function onKeyPressed(keycodekeynamescancode)
{
  switch (
keyname) {
    case 
"n":
      
this.noclip = !this.noclip;
      
player.chat "Noclip: " SPC this.noclip;
    break;
  }
}


//**************************************************
function onTimeout()
{
  
temp.dirArr = {falsefalsefalsefalse};
  if (
this.freezetime <= 0)
  {
    if (
keydown(0)) temp.dirArr[0] = true;
    if (
keydown(1)) temp.dirArr[1] = true;
    if (
keydown(2)) temp.dirArr[2] = true;
    if (
keydown(3)) temp.dirArr[3] = true;
  }
  
  
// *****Loop throught the keys (temp.dirArr).
  
for (i=0i<4i++) {
    
temp.dir i;
    if (
temp.dirArr[i] == true) {
      if (
this.("keyMode" temp.dir) == 0) {
        
this.("lastKeyPress" temp.dir) = timevar2;
        
this.("keyMode" temp.dir) = 1;
      }
      elseif (
this.("keyMode" temp.dir) == 2) {
        
Jump(temp.dir);
        
this.("keyMode" temp.dir) = 0;
      }
    }
    else {
      if (
this.("keyMode" temp.dir) == 1) {
          
this.("keyMode" temp.dir) = 2;
      }
      if (
timevar2 this.("lastKeyPress" temp.dir) > this.doublePressDelay) {
        
this.("keyMode" temp.dir) = 0;
      }
    }
  }
  
  
// *****Get current friction
  
if (player.== 0) {
    
temp.curtiletype tiletype(player.1.5player.2);
    if (
temp.curtiletype == 11temp.friction this.friction.water;
    elseif (
temp.curtiletype == 3temp.friction this.friction.chair;
    else 
temp.friction this.friction.plain;
  }
  else 
temp.friction this.friction.air;
  
  
// *****Apply friction
  
this.speed.*= temp.friction;
  
this.speed.*= temp.friction;
  if (
this.speed.0.25 && this.speed.> -0.25this.speed.0;
  if (
this.speed.0.25 && this.speed.> -0.25this.speed.0;
  
  
// *****Accelerate so we'll eventually reach that target position.
  
if (player.== && this.freezetime <= 0) {
    if (
keydown(0)) Accelerate(0, -this.accelerationthis.baseSpeed);
    if (
keydown(1)) Accelerate(-this.acceleration0this.baseSpeed);
    if (
keydown(2)) Accelerate(0this.accelerationthis.baseSpeed);
    if (
keydown(3)) Accelerate(this.acceleration0this.baseSpeed);
  }
  
  
// *****Actually move the player according to current speed.
  
Move(this.speed.xthis.speed.y);
  if (!
clientr.frozen && (this.speed.!= || this.speed.!= 0)) player.dir getdir(this.speed.xthis.speed.y);
  
  
// *****Gravity
  
if (player.0this.speed.-= this.gravity;
  elseif (
this.speed.0this.speed.0;
  
player.+= this.speed.16;
  
  
// *****Freeze
  
if (this.freezetime 0this.freezetime -= 0.05;
  
  
// *****Set animation.
  
if (Distance(this.speed.xthis.speed.y) > 0.1) {
    
temp.groundtype GetGroundType();
    if (
temp.groundtype == "water"setani(this.gani.swim"");
    elseif (
temp.groundtype == "chair"setani(this.gani.sit"");
    elseif (!
clientr.frozen && Distance(this.speed.xthis.speed.y) > 0.5) {
      if (
Distance(this.speed.xthis.speed.y) < 7.5setani(this.gani.slowWalk"");
      else 
setani(this.gani.walk"");
    }
    else 
setani(this.gani.idle"");
  }
  
  
setTimer(0.05);
}


//**************************************************
// Increase the speed in pixels per frame.
function Accelerate(xSpeedySpeedmaxSpeed)
{
  if (
Distance(this.speed.xthis.speed.y) < maxSpeed || (Distance(this.speed.xSpeedthis.speed.ySpeed) - Distance(this.speed.xthis.speed.y)) <= 0) {
    
this.speed.+= xSpeed;
    
this.speed.+= ySpeed;
    
    if (
Distance(this.speed.xthis.speed.y) > maxSpeed) {
      
temp.angle getangle(this.speed.xthis.speed.y);
      
this.speed.cos(temp.angle) * maxSpeed;
      
this.speed.= -sin(temp.angle) * maxSpeed;
    }
  }
}


//**************************************************
// Move the player by specified amount of pixels.
function Move(xSpeedySpeed)
{
  if (!
isapplicationactive || clientr.frozen) return;
  
  
xSpeed xSpeed<0?int(xSpeed)+1:int(xSpeed);
  
ySpeed ySpeed<0?int(ySpeed)+1:int(ySpeed);
  
  
// --- 'x' movement of the player --- \\
  
if (xSpeed != 0) {
    
temp.int(player.16);
    
temp.xDir = (abs(xSpeed) / xSpeed);
    for (
i=0i<abs(xSpeed); i++) {
      if (!
onwall2(temp.16 0.75 temp.xDir * (1/16), player.1.751.51.25) || this.nocliptemp.+= temp.xDir;
      else break;
    }
    
player.temp.16;
  }
  
  
// --- 'y' movement of the player --- \\
  
if (ySpeed != 0) {
    
temp.int(player.16);
    
temp.yDir = (abs(ySpeed) / ySpeed);
    for (
i=0i<abs(ySpeed); i++) {
      if (!
onwall2(player.0.75temp.16 1.75 temp.yDir * (1/16), 1.51.25) || this.nocliptemp.+= temp.yDir;
      else break;
    }
    
player.temp.16;
  }
}


//**************************************************
// Jump in the specified direction.
function Jump(direction)
{
  if (
player.== 0) {
    if (
this.speed.== NULLthis.speed.+= this.baseJumpPower.z;
    if (
direction == 0this.speed.-= this.baseJumpPower.xy;
    elseif (
direction == 1this.speed.-= this.baseJumpPower.xy;
    elseif (
direction == 2this.speed.+= this.baseJumpPower.xy;
    elseif (
direction == 3this.speed.+= this.baseJumpPower.xy;
  }
}


//**************************************************
// Prevent the player form accelerating or jumping via keydown() for the specified amount of time.
public function freeze(time) {
  if (
time != NULLthis.freezetime time;
  else return 
this.freezetime;
}


//**************************************************
// Replace ganis to be displayed when walking etc. Read onCreated() for list of variables.
public function replaceGani(typegani)
{
  
makevar("this.gani." type) = gani;
  
player.chat makevar("this.gani." type);
}


//**************************************************
// Returns a string representing the ground type the player is standing on. We need this in order to figure out what gani to use.
function GetGroundType()
{
  
temp.tiletype tiletype(player.1.5player.2);
  if (
temp.tiletype == 11) return "water";
  elseif (
temp.tiletype == 3) return "chair";
  else return 
"ground";
}


//**************************************************
//Calculate the distance between (0, 0) and (dx, dy).
function Distance(dxdy)
{
  return ((
dx)^+ (dy)^2)^0.5;


It's a later revision of the original code that I completely forgot about and found again only recently.
Note: the animations might not work properly since I didn't bother with extensive debugging after modifying it slightly for Code Gallery use.

Like the previous modification posted, this one lets you use the keyboard to move around. Unlike the previous, it uses Accelerate() instead of SetTarget() (*gasp*).
In addition, as a result of the great mind leakage of 1978*, it implements a UT style jump/dodge function which is activated when you tap a direction button twice. It will usually keep you entertained for about sixty seconds.

It's been fooled around with by at least two other coders but I'm unable to deduce who did what exactly.

[Footnote*]
This disastrous event, which killed many, was a result of Xzirox running into the Barsebäck reactor to save a baby from radiation poisoning. The baby had already been burnt to a crisp by the intense heat of course, so he was faced with nought but carbon fumes. The combination of fumes, radiation and a conveniently occurring discharge of electricity momentarily mutated Xzirox into a Mindflayer with great telepathic abilities who lost control of it's telepathic wave transmitters, resulting in all of his most terrible ideas being leaked into a nearby town. I was observing a pane of lead at the time which blocked most of the waves, so I was fortunately only struck with a somewhat innocent idea. However, even this limited exposure caused me to lose a whole night of sleep by forcing me to compulsively finish the feature before finally allowing me to sleep. The Swedish government agreed to pay for the medical bills for the humanification if Xzirox would promise never to attempt to save a baby again. Nowadays the survivors of that terrible accident annually pay respects to the less lucky ones who had their heads explode.

Admins 06-30-2008 02:52 PM

Funny story :D
Will eventually use the scripts for a future project :)

xXziroXx 06-30-2008 11:45 PM

Quote:

Originally Posted by Stefan (Post 1400198)
Funny store :D

Yeah go ahead, laugh at my expense all you want. !pissed!

cbk1994 07-01-2008 01:19 AM

Lol Awesome Story

Samposse 11-28-2009 04:29 PM

Think how to PK whoud be like ^^ *Old Warcraft style xD


All times are GMT +2. The time now is 01:09 AM.

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