Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-18-2006, 07:57 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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
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);

Reply With Quote
  #2  
Old 08-18-2006, 09:45 PM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
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.
__________________
"The higher you fly, the harder it is to breathe."

[Kaidenn] Maybe I will somehow take control of Lance's body when he isn't looking, have him log onto Kingdoms, update one script, and leave.
[Kaidenn] And leave him exactly where I found him, unchanged and completely unnaware of what just took place the last two minutes.
[GrowlZ] Lance: You might want to lock your bedroom door tonight
Reply With Quote
  #3  
Old 08-18-2006, 10:50 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
oh so this.angle=degtorad(this.angle) would work? I'll try that
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 11:00 PM.


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