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-28-2008, 07:49 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
Angry [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
Reply With Quote
  #2  
Old 08-28-2008, 07:57 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Freeze the player and update their position manually.
Reply With Quote
  #3  
Old 08-28-2008, 07:59 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Dude, please try and use GS2
Reply With Quote
  #4  
Old 08-28-2008, 09:24 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
how do i freeze my player and update there possition???
Reply With Quote
  #5  
Old 08-28-2008, 09:27 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
.... HR? Skyld? Can I? Pleeeeeaaaaasseee?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #6  
Old 08-28-2008, 09:49 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
Angry

Quote:
Originally Posted by xXziroXx View Post
.... HR? Skyld? Can I? Pleeeeeaaaaasseee?
!p issed!

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
Reply With Quote
  #7  
Old 08-28-2008, 09:55 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by GULTHEX View Post
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.
Reply With Quote
  #8  
Old 08-28-2008, 09:56 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
i have 1 so he is not on

abd can ya help me with the script????
Reply With Quote
  #9  
Old 08-28-2008, 10:40 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Quote:
Originally Posted by GULTHEX View Post
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.


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

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

To rotate about the origin:


Or:
x' = x * cos(theta) - y * sin(theta)
y' = -x * sin(theta) + y * cos(theta)
Reply With Quote
  #10  
Old 08-28-2008, 10:44 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
say what
Reply With Quote
  #11  
Old 08-28-2008, 10:56 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Quote:
Originally Posted by GULTHEX View Post
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.
Reply With Quote
  #12  
Old 08-28-2008, 11:18 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by GULTHEX View Post
!p issed!

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.
__________________
Reply With Quote
  #13  
Old 08-28-2008, 11:22 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by cbk1994 View Post
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.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #14  
Old 08-29-2008, 01:09 AM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
Quote:
Originally Posted by GULTHEX View Post
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 View Post
Post
I think this is a little too complicated for him to understand.
__________________
- Iᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ

Last edited by Programmer; 08-29-2008 at 01:25 AM.. Reason: Grammar, Ian! Grammar!
Reply With Quote
  #15  
Old 08-29-2008, 02:05 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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
__________________
Reply With Quote
  #16  
Old 08-29-2008, 02:14 AM
Kappa00p2p Kappa00p2p is offline
Registered theRapist
Kappa00p2p's Avatar
Join Date: Jul 2003
Posts: 198
Kappa00p2p is an unknown quantity at this point
Send a message via AIM to Kappa00p2p
Quote:
Originally Posted by Switch View Post
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
__________________

-Kappa
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 01:01 PM.


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