Search In
• More options...
Find results that contain...
Find results in...

# sine and cosine

## Recommended Posts

how do i calculate sine and cosine?

since i wont be learning that at school i thought i'd better ask, so ill know...

here is what i got:

`02F9: get_car [email protected] Z_angle_sine_to [email protected]: get_car [email protected] Z_angle_cosine_to [email protected] [email protected] *= -1.007D5: set_car [email protected] velocity_in_direction_XYZ [email protected] [email protected] 0.0 rotation_velocitiesXY 0.0 -1.0 unk 0.0  `

but the plane keeps spinning out of control

when i didnt use the velocity in direction it worked fine...only rotation velocity, so i guess thats not the reason

but when i added the damn velocity in direction, it got all messed up

here is what i want:

you press SHIFT+A

the plane moves left and makes one spin to the left(not Z angle spin, y angle)

so i want to know how to calculate the right XYZ velocities...

##### Share on other sites

Uhh... rotation velocity ROTATES the vehicle...

And there's no need to use sine and cosine here... You can simply get the velocity with another opcode.

And finally, you've got the sine/cosine opcodes mixed up. Download the latest sascm.ini and opcodes.txt file to fix this: http://gtag.gtagaming.com/opcode-database/

##### Share on other sites

ok

but you got my question wrong:

i DO need sine and cosine

i dont wanna just ROTATE the car

i want to move it to the left, and get velocity isnt gonna help me accomplish that...thats why i need the sine and cosine

stays the same...

Edited by yair1221

##### Share on other sites

My mistake, try again

This should be the new result (as well as the other two sin/cos opcodes switched).

`02F8: get_car [email protected] Z_angle_sine_to [email protected]: get_car [email protected] Z_angle_cosine_to [email protected]`

But I'm confused now.. if you don't actually want to use this to set velocities.. why are you trying to? No wonder the heli is spinning eratically.

##### Share on other sites

a. its a plane, not a heli

c.it still didnt change a damn thing

d.im trying to set the velocity, but not FORWARD, i want it to go left

##### Share on other sites

Plane, heli.. whatever.

It won't go left. And if you don't need to use these functions, don't use them. If you don't need to make this script, stop bothering us by asking how to make it... If you wanna learn about sine and cosine, go read a book, an online tutorial or one of the many other questions there are about this. And of course, there's always actually experimenting with it yourself!

For example, you wanna test an opcode, try creating a debug script:

`{\$CLEO}0000:while true   wait 0   if       00E1:   player 0 pressed_key 4   then       0811: [email protected] = actor \$PLAYER_ACTOR car       07DA: set_car [email protected] rotation_velocity_XYZ 0.0 0.0 90.0 through_center_of_body   endend`

##### Share on other sites

this TURNS the car left

i want it to go left, while looking forward...

##### Share on other sites

Why were you setting the rotation then? Grr...

`{\$CLEO}0000:while true   wait 0   if       0ADC:   test_cheat "A"   then       0811: [email protected] = actor \$PLAYER_ACTOR car       0174: [email protected] = car [email protected] Z_angle       000B: [email protected] += 90.0       02F6: [email protected] = sine [email protected]       02F7: [email protected] = cosine [email protected]       0013: [email protected] *= 10.0       0013: [email protected] *= 10.0       06A2: get_car [email protected] velocity_in_direction_XYZ [email protected] [email protected] [email protected]       005B: [email protected] += [email protected]       005B: [email protected] += [email protected]       07D5: set_car [email protected] velocity_in_direction_XYZ [email protected] [email protected] [email protected] rotation_velocitiesXY 0.0 0.0 unk 0.0   endend`

Tested, but I hope it somehow doesn't work and your computer explodes.

##### Share on other sites

keep dreaming dude

thanks though...

edit: doesnt work, the plane does move left/right at my will

but it also makes crazy spins in the air(i didnt use the rotation velocity)

Edited by yair1221

##### Share on other sites

Use your imagination.. you can't just throw a plane sideways and expect there to be no "air resistance".

If you tested this on a plane that didn't have it's engine on, the effect would differ.

##### Share on other sites

well...it IS just a game...right?

and besides, there must be some kind to move the plane...easily...right?

maybe if i attach it to an object, move the object, detach it, and destroy the object...should work, shouldnt it?

##### Share on other sites

Well, I understood what he wanna do already at the beginning.

You want to make your plane dodge to left / right and make it a spin to that direction, like actors do when crouching?

Hmm, should work with that one:

`03A4: name_thread 'PLANEDODGER' :PLANEDODGER_110001: wait 0 ms 00D6: if and0256:   player \$PLAYER_CHAR defined04C8:   actor \$PLAYER_ACTOR driving_flying_vehicle 84A9:   not actor \$PLAYER_ACTOR driving_heli 0AB0:   key_pressed 16 0AB0:   key_pressed 65 004D: jump_if_false @PLANEDODGER_1103C0: [email protected] = actor \$PLAYER_ACTOR car0007: [email protected] = [The velocity you want to dodge it left - I would recommend 0.20, but try it out] :PLANEDODGER_30 0001: wait 0 ms0174: [email protected] = car [email protected] Z_angle 000B: [email protected] += 90.0 02F6: [email protected] = sine [email protected] // (float)02F7: [email protected] = cosine [email protected] // (float)006B: [email protected] *= [email protected] // (float) 006B: [email protected] *= [email protected] // (float)07D5: set_car [email protected] velocity_in_direction_XYZ [email protected] [email protected] 0.0 rotation_velocitiesXY 0.0 0.0 unk 0.00007: [email protected] = [Well, I don´t know about rotation velocities... try out a low value, then increase it until it´s right for you]07DB: set_car [email protected] rotation_velocity_XYZ 0.0 [email protected] 0.0 through_center_of_mass 0002: jump @PLANEDODGER_11`

If you wanna have it also for the right-hand side, it has to be changed (Right to SHIFT+D):

`03A4: name_thread 'PLANEDODGER' :PLANEDODGER_110001: wait 0 ms 00D6: if and0256:   player \$PLAYER_CHAR defined04C8:   actor \$PLAYER_ACTOR driving_flying_vehicle 84A9:   not actor \$PLAYER_ACTOR driving_heli 0AB0:   key_pressed 16 004D: jump_if_false @PLANEDODGER_1103C0: [email protected] = actor \$PLAYER_ACTOR car0007: [email protected] = [The velocity you want to dodge it left - I would recommend 0.20, but try it out]00D6: if0AB0:   not key_pressed 65 004D: jump_if_false @PLANEDODGER_3000D6: if0AB0:   not key_pressed 68 004D: jump_if_false @PLANEDODGER_500002: jump @PLANEDODGER_11:PLANEDODGER_30 0001: wait 0 ms0007: [email protected] = 90.00007: [email protected] = [Well, I don´t know about rotation velocities... try out a low value, then increase it until it´s right for you]0002: jump @PLANEDODGER_70:PLANEDODGER_50 0001: wait 0 ms0007: [email protected] = -90.00007: [email protected] = -[Well, I don´t know about rotation velocities... try out a low value, then increase it until it´s right for you]:PLANEDODGER_70 0001: wait 0 ms0174: [email protected] = car [email protected] Z_angle 000B: [email protected] += [email protected] 02F6: [email protected] = sine [email protected] // (float)02F7: [email protected] = cosine [email protected] // (float)006B: [email protected] *= [email protected] // (float) 006B: [email protected] *= [email protected] // (float)07D5: set_car [email protected] velocity_in_direction_XYZ [email protected] [email protected] 0.0 rotation_velocitiesXY 0.0 0.0 unk 0.007DB: set_car [email protected] rotation_velocity_XYZ 0.0 [email protected] 0.0 through_center_of_mass 0002: jump @PLANEDODGER_11`

Try it out, I didn´t

##### Share on other sites

really awesome!

works, except for the rotation part

and it moves more like forward/backward than right/left

maybe i should increase the value...

##### Share on other sites

No bad day.. but yair is enough to drive anyone to screaming. I'm able to shout and express anger at someone without actually being angry.

Wie wärs mit testen, ehh?

##### Share on other sites

hey, aint my fault, i didnt even understand what you want from me the entire thread...

@Bennington: scratch the last one, the script works great now, just need to make it a little less forward, i guess ill settle at that...thanks!

##### Share on other sites

@yair1221 You sais it move more forward / backward... How do you mean that? Does it refer to the direction your pointing? Then there´s a mistake by me...

Wait a minute, I´ll try it myself.

EDIT:

Lol? What is that sh*t I scripted there

Let me change it a lil bit...

Edited by Bennington

##### Share on other sites

when i press SHIFT+A

it works great

but then i press SHIFT+D

and it goes BACKWARDS

(i used [email protected] += 270.0)

until i stop pressing, then it makes about a 270.0 degrees turn, and continues the wrong way

im beginning to think that its because i modified the hydra handling

i removed all the "stab" thingies to 0.0

but then i also added more power to the Pitch, Roll, and Yaw

maybe it will work if i install the original handling

##### Share on other sites

OMG something went totally wrong at me...

The plane even rotates when only pressing SHIFT

##### Share on other sites

lol, i dont have that problem...i didnt use YOUR script, only the part with the sine and cosine and rotations and velocities, mine isnt even CLEO

and its probably because of that:

`00D6: if and0256:   player \$PLAYER_CHAR defined04C8:   actor \$PLAYER_ACTOR driving_flying_vehicle84A9:   not actor \$PLAYER_ACTOR driving_heli0AB0:   key_pressed 16004D: jump_if_false @PLANEDODGER_11`

however, i used the first code as a base

##### Share on other sites

I solved the problem now, I changed opcode number 8AB0 with 0AB0...

##### Share on other sites

lol

but the plane still moves forward/backward

`if and0ab0: 160ab0: 65then0174: [email protected] = car [email protected] Z_angle000B: [email protected] += 270.002F6: [email protected] = sine [email protected] // (float)02F7: [email protected] = cosine [email protected] // (float)07D5: set_car [email protected] velocity_in_direction_XYZ [email protected] [email protected] 0.0 rotation_velocitiesXY 0.0 0.0 unk 0.007DB: set_car [email protected] rotation_velocity_XYZ 0.0 -0.5 0.0 through_center_of_massendif and0ab0: 160ab0: 68then0174: [email protected] = car [email protected] Z_angle000B: [email protected] += 90.002F6: [email protected] = sine [email protected] // (float)02F7: [email protected] = cosine [email protected] // (float)07D5: set_car [email protected] velocity_in_direction_XYZ [email protected] [email protected] 0.0 rotation_velocitiesXY 0.0 0.0 unk 0.007DB: set_car [email protected] rotation_velocity_XYZ 0.0 0.5 0.0 through_center_of_massend`

##### Share on other sites

`07D5: set_car [email protected] velocity_in_direction_XYZ [email protected] [email protected] 0.0 rotation_velocitiesXY 0.0 0.0 unk 0.0`

You're setting both X and Y velocities, so plane will move backward/forward & left/right.

Wow, what a polite and patient reply, I'm really calm now.

And start using damn Tabs with high-level scripts, will save much of your (our?) nerves and make script WAY more readable, rly.

##### Share on other sites

`03A4: name_thread 'PLANEDODGER' :PLANEDODGER_190001: wait 0 ms 00D6: if and0256:   player \$PLAYER_CHAR defined 04C8:   actor \$PLAYER_ACTOR driving_flying_vehicle 84A9:   not actor \$PLAYER_ACTOR driving_heli 0AB0:   key_pressed 16 004D: jump_if_false @PLANEDODGER_19 00D6: if 8AB0:   not key_pressed 65 004D: jump_if_false @PLANEDODGER_108 00D6: if 8AB0:   not key_pressed 68 004D: jump_if_false @PLANEDODGER_139 0002: jump @PLANEDODGER_19 :PLANEDODGER_1080001: wait 0 ms 0007: [email protected] = 90.0 0007: [email protected] = 100.0 0002: jump @PLANEDODGER_163 :PLANEDODGER_1390001: wait 0 ms 0007: [email protected] = 270.0 0007: [email protected] = -100.0 :PLANEDODGER_1630001: wait 0 ms 03C0: [email protected] = actor \$PLAYER_ACTOR car 0174: [email protected] = car [email protected] Z_angle 000B: [email protected] += [email protected] 02F6: [email protected] = sine [email protected] // (float) 02F7: [email protected] = cosine [email protected] // (float) 0013: [email protected] *= -0.2 // (float) 0013: [email protected] *= 0.2 // (float) 07D5: set_car [email protected] velocity_in_direction_XYZ [email protected] [email protected] 0.0 rotation_velocitiesXY 0.0 0.0 unk 0.0 07DB: set_car [email protected] rotation_velocity_XYZ 0.0 [email protected] 0.0 through_center_of_mass 0001: wait 1000 ms 0002: jump @PLANEDODGER_19 `

That´s the script now!

We had to negate [email protected], cause it moved in the opposite X direction.

Well, but it´s a damn thing with that rotation velocity [email protected] I already have increased it to 100.0, but I still can only do a half spin.

However, on this point I´ll stop, and you can go on, yair1221

##### Share on other sites
`07D5: set_car [email protected] velocity_in_direction_XYZ [email protected] [email protected] 0.0 rotation_velocitiesXY 0.0 0.0 unk 0.0`

You're setting both X and Y velocities, so plane will move backward/forward & left/right.

Wow, what a polite and patient reply, I'm really calm now.

And start using damn Tabs with high-level scripts, will save much of your (our?) nerves and make script WAY more readable, rly.

thanks dude

@Sessemi street:

what tabs?

you mean, labels?

i cant, it will make the script unreadable

im working with this structure:

:plane

wait 0

if and

0ab0: 16

0ab0: 65

then

...

end

jump @plane

there are many other functions, its the "scripted handling" thread...

##### Share on other sites

1x TAB = 3 spaces + new tabulator position! I thought you know C++??!?

`while true   wait 20   if   0256:   player \$PLAYER_CHAR defined    then       if       03EE:   player \$PLAYER_CHAR controllable        then           if           80DF:   not actor \$PLAYER_ACTOR driving            then               wait 2000               show_text_box 'YAIRSUCKS' // oh, too long entry :S               break           end       end   endend0000:0A93: end_custom_thread`

you think we press SPACE all the time???

##### Share on other sites

what on earth do YOU want?

and no, i never got to the C++

just a simple loops, variables, strings, and input/output

all within command prompt scripts...

##### Share on other sites

Dude keep cool he´s a moderator

##### Share on other sites
what on earth do YOU want?

and no, i never got to the C++

just a simple loops, variables, strings, and input/output

all within command prompt scripts...

If you worked with loops, there'd be no doubt on getting a 'oh, thanks, that makes the syntax more clear' from you

@Bennington: I'm what? Where the hell did you get that from (dev. not an offence)

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×