Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   [help] car script speed (https://forums.graalonline.com/forums/showthread.php?t=81539)

GULTHEX 08-28-2008 07:49 PM

[help] car script speed
 
i got this script that makes them play a car gani. but how do i make it so they go fast when they in the car??? and its a spy car it shoots bullets :)

PHP Code:

//#CLIENTSIDE
if (weaponfired) {
  
replaceani idle,dg_car;
  
replaceani walk,dg_car;
  
setani dg_car,;
  
freezeplayer .1;
  
setani dg_car,;
  
this.angle=getangle(vecx(playerdir),vecy(playerdir));
  
this.x=playerx+vecx(playerdir)*2;
  
this.y=(playery-.5)+vecy(playerdir)*2.5;
 
shoot this.x,this.y,playerz,this.angle+random(this.maxangle*5,this.maxangle),
    
1,0,dg_bullet,1;

  
triggeraction this.x,this.y,shot,;
}
if (
keypressed && strequals(#p(1),s)) {
replaceani idle,idle;
replaceani walk,walk;


and dg stands for dev gulthex

DrakilorP2P 08-28-2008 07:57 PM

Freeze the player and update their position manually.

Codein 08-28-2008 07:59 PM

Dude, please try and use GS2 :(

GULTHEX 08-28-2008 09:24 PM

how do i freeze my player and update there possition???

xXziroXx 08-28-2008 09:27 PM

.... HR? Skyld? Can I? Pleeeeeaaaaasseee?

GULTHEX 08-28-2008 09:49 PM

Quote:

Originally Posted by xXziroXx (Post 1418732)
.... HR? Skyld? Can I? Pleeeeeaaaaasseee?

!pissed!!pissed!!pissed!!pissed!!pissed!!pissed!!p issed!!pissed!!pissed!!pissed!

your just gonna tell me about graal wiki iv ben there about it none of that crap helps me so just tell me and not take me to a website

Crow 08-28-2008 09:55 PM

Quote:

Originally Posted by GULTHEX (Post 1418744)
your just gonna tell me about graal wiki iv ben there about it none of that crap helps me so just tell me and not take me to a website

If the stuff on the wiki doesn't help you, get a scripter.

GULTHEX 08-28-2008 09:56 PM

i have 1 so he is not on

abd can ya help me with the script????

DrakilorP2P 08-28-2008 10:40 PM

Quote:

Originally Posted by GULTHEX (Post 1418729)
how do i freeze my player and update there possition???

You can prevent the current player from moving using freezeplayer(t), where t is the amount of time the effect should last.

As for position, Graal uses the two-dimensional Cartesian coordinate system to describe positions as points in the Euclidean space.

The following image visualizes this in a clear manner.
http://i35.tinypic.com/59sy05.png

You can translate an object thusly:
(x, y) -> (x + dx, y + dy)

Conversely:
x' = x + dx
y' = y + dy

To rotate about the origin:
http://i38.tinypic.com/4jql9h.png

Or:
x' = x * cos(theta) - y * sin(theta)
y' = -x * sin(theta) + y * cos(theta)

GULTHEX 08-28-2008 10:44 PM

say what

DrakilorP2P 08-28-2008 10:56 PM

Quote:

Originally Posted by GULTHEX (Post 1418775)
say what

Please elaborate. I just researched and wrote a post for you, what else can I do? I'm not going to rewrite it over and over again until I accidentally get it right.

cbk1994 08-28-2008 11:18 PM

Quote:

Originally Posted by GULTHEX (Post 1418744)
!pissed!!pissed!!pissed!!pissed!!pissed!!pissed!!p issed!!pissed!!pissed!!pissed!

your just gonna tell me about graal wiki iv ben there about it none of that crap helps me so just tell me and not take me to a website

Read the guides on the Wiki. Read Twinny's guide. Find someone to help you learn to script. Look at Code Gallery posts.

Just please don't come on the forums, ask for scripts, then act like a jackass.

Switch 08-28-2008 11:22 PM

Quote:

Originally Posted by cbk1994 (Post 1418794)
Just please don't come on the forums, ask for scripts, then act like a jackass.

wurd.

And also, GS2 is like New English, it can be manipulated to do a lot of things. GS1 is like Old English, it can't really be said well off the top of your head anymore and can't be changed.

Programmer 08-29-2008 01:09 AM

Quote:

Originally Posted by GULTHEX (Post 1418775)
say what

This type of mathematics is quite difficult to understand at first, but it will get easier. For the purposes of this script, I will be using Trigonometry to get the appropriate answer.

Say we have angle a and speed s, and we wanted to get the changing X and the changing Y values for said speeds.

For these purposes, I will assign the following values to a and s.

PHP Code:

180


From this, we can work out what the changing X and changing Y are.

First off, we want to convert a into radians so that they will work with Sine and Cosine. This is done using the following formula*:

PHP Code:

pi 180 

Now that we have the radian value of the angle (now referred to as r), we can continue on.

To get a simple speed (if s was 1, for example), you would use the following formula:

PHP Code:

changeX sin(r)
changeY = -cos(r

Now, if you wanted to alter the speed to the value specified in s, simply multiply it in the formula. You end up with the following:

PHP Code:

changeX sin(r) * s
changeY 
= -cos(r) * 

From this, you will be able to get your new position using the speed specified. To do this, simply add it to your object's X and Y values, like so:

PHP Code:

+= changeX
+= changeY 

Now, you may only want your object to move in 4 ways or in 8 ways, or even up to an infinite amount of ways. If you wish to put directional restrictions on your object, do the following before converting to radians:

PHP Code:

// This is for a 4-way movement.
-= (a mod** 90)

// This is for an 8-way movement
-= (a mod** 45


Hope this was helpful :)

(NOTE: With the values specified, if you followed instructions carefully enough, you should get changeX = 0 and changeY = 5.)

* In GraalScript, this functionality is built-in. You can either use the formula or use degtorad(float) to get your answer.
** Replace this with a percent sign in GraalScript.

Quote:

Originally Posted by DrakilorP2P (Post 1418772)
Post

I think this is a little too complicated for him to understand.

cbk1994 08-29-2008 02:05 AM

Just use radians for your angle. Degrees is seldom used in programming.

PHP Code:

pi 2// 180 degree angle
// Of course, in this case, you can just use pi 

To turn 4 directions:

PHP Code:

+= pi 2

To turn 8 directions:
PHP Code:

+= pi 4


Kappa00p2p 08-29-2008 02:14 AM

Quote:

Originally Posted by Switch (Post 1418799)
GS1 is like Old English, it can't really be said well off the top of your head anymore and can't be changed.

GS1 is my favorite language ^^


All times are GMT +2. The time now is 11:28 AM.

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