Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Vehicle script (https://forums.graalonline.com/forums/showthread.php?t=68193)

excaliber7388 08-18-2006 07:57 PM

Vehicle script
 
currently working on a vehicle script that will be able to move in any direction, using cosine and sine.
I have a little something made up, but it turns strange.
I'm not sure how to change this, or what I'm doing wrong. I've never played with cos and sin x_x
PHP Code:

//#CLIENTSIDE
function onKeypressed()
{
  if(
params[1]=="D")
  {
    if(
this.inuse==0)
    {
      
this.speed=0;
      
this.angle=0;
      
this.friction=0;
      
this.inuse=1;
      
onTimeout();
    }
    else
    {
      
this.inuse=0;
      
setani("idle",NULL);
      
freezeplayer(0);
      
settimer(0);
    }
  }
}
function 
onTimeout()
{
  if(
this.speed>0)
  {
    
player.x+=this.speed*cos(this.angle);
    
player.y+=-this.speed*sin(this.angle);
  }
  if(
this.friction==3)
  {
    if(
this.speed>0)
    {
      
this.speed-=.05;
    }
    
this.friction=0;
  }
  
this.friction++;
  
player.chat="Your: Speed: " this.speed " Angle: " this.angle " X: " abs(cos(this.angle)) @ " Y: " abs(sin(this.angle));
  
freezeplayer(.05);
  if(
keydown(0))
  {
    if(
this.speed<0)
    {
      
this.speed=0;
    }
    if(
this.speed<3)
    {
      
this.speed+=.25;
    }
  }
  if(
keydown(1))
  {
    
this.angle-=.05;
  }
  if(
keydown(2))
  {
    
this.speed--;
    
this.speed=int(this.speed);
  }
  if(
keydown(3))
  {
    
this.angle+=.05;
  }
  
degtorad(this.angle);
  
settimer(.05);



ForgottenLegacy 08-18-2006 09:45 PM

You have your degtorad() in the wrong place. It returns a number, and you aren't putting that number anywhere. You need to make degtorad() actually change this.angle, without just reading it.

excaliber7388 08-18-2006 10:50 PM

oh so this.angle=degtorad(this.angle) would work? I'll try that


All times are GMT +2. The time now is 02:08 PM.

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