Quantcast

Jump to content

» «
Photo

Object Rotation Velocity

13 replies to this topic
12jango
  • 12jango

    "This is not revenge! This is entertainment!"

  • Members
  • Joined: 08 Mar 2008

#1

Posted 07 April 2014 - 01:47 PM Edited by 12jango, 08 April 2014 - 02:03 PM.

{$CLEO .cs}




thread 'sweat'




:LOAD
wait 0
Model.Load(615)
Model.Load(#NULL)
if and
    Model.Available(615)
    Model.Available(#NULL)
jf @LOAD




:TRI
wait 0
if and  
    Player.Defined($PLAYER_CHAR)
    0AB0:  key_pressed 49
jf @TRI
04C4: store_coords_to 11@ 12@ 13@ from_actor $PLAYER_ACTOR with_offset 0.0 3.0 5.0 
04C4: store_coords_to 14@ 15@ 16@ from_actor $PLAYER_ACTOR with_offset 13.0 3.0 5.0 
0@ = Object.Create(615, 11@, 12@, 13@)
20@ = Object.Create(615, 14@, 15@, 16@)




:TO
wait 0
Object.Angle(0@) = 0.0 
Object.Angle(20@) = 0.0 
if and  
    Player.Defined($PLAYER_CHAR)
    0AB0:  key_pressed 50
jf @TO




:wAN
wait 0
0400: store_coords_to 1@ 2@ 3@ from_object 0@ with_offset 0.0 0.0 0.0 
// Movement velocity
27@ = 0.02
33@ = 77.0
// Get the in-between vector
0063: 4@ -= 1@
0063: 5@ -= 2@
0063: 6@ -= 3@
// Calculate vector length
050A: 28@ = distance_between_XYZ 0.0 0.0 0.0 and_XYZ 4@ 5@ 6@
// Get the unit vector
0073: 4@ /= 28@
0073: 5@ /= 28@
0073: 6@ /= 28@
// Multiply the vector by velocity
006B: 4@ *= 27@
006B: 5@ *= 27@
006B: 6@ *= 27@
// Calculate the angle between the 2 points
05A1: set_object 0@ rotation_velocity_about_an_axis 4@ 5@ 6@ through_center_of_body




05A6: get_object 0@ rotation_velocity_about_an_axis_X 4@ axis_Y 5@ axis_Z 6@ through_center_of_body 
0453: set_object 20@ XY_rotation 4@ 5@ angle 6@ 
jump @WAN

Just a simple script; press 1 to spawn two trees in front of you then press 2 to rotate one tree.

It supposed to rotate both tree, but it's only one tree rotating (object 0@), I tried to rotate the other tree (object 20@) by using opcode 05A6 first then use 0453 to rotate it but didn't work!  :rol:

So, what does opcode 05A6 use for? I thought it would get an object rotation so you can use it to set another object's rotation to be same as the one you get?  :/  


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci Racing
  • Joined: 19 Aug 2006
  • Unknown

#2

Posted 07 April 2014 - 02:16 PM Edited by Wesser, 07 April 2014 - 02:22 PM.

You wrote $20@. SB oddly accepts this big syntactical incongruity and treats it as a local variable with a hexadecimal identifier (32@).

12jango
  • 12jango

    "This is not revenge! This is entertainment!"

  • Members
  • Joined: 08 Mar 2008

#3

Posted 08 April 2014 - 02:07 PM

I'm sorry I made mistakes when typing the script especially the $20@ I meant it 20@. :blush:

This time is the correct one. If you have time, please try it out to see what this script do.

The tree on your right is the object 20@ that won't rotating. :turn:


12jango
  • 12jango

    "This is not revenge! This is entertainment!"

  • Members
  • Joined: 08 Mar 2008

#4

Posted 12 April 2014 - 05:36 AM Edited by 12jango, 12 April 2014 - 05:44 AM.

Is there any way to use 05A6:?


Seemann
  • Seemann

    Ruhe

  • Members
  • Joined: 03 Sep 2004
  • Russia
  • Best Tool 2013 "Sanny Builder"

#5

Posted 12 April 2014 - 08:45 AM

You wrote $20@. SB oddly accepts this big syntactical incongruity and treats it as a local variable with a hexadecimal identifier (32@).

huh, funny :p should I fix that or leave it alone as a one yet feature?


Silent
  • Silent

    Moderating Cookie Monster

  • Feroci Racing
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#6

Posted 12 April 2014 - 09:50 AM

huh, funny :p should I fix that or leave it alone as a one yet feature?


Maybe tweak it so it's less ambiguous and allow hex for globals too?

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci Racing
  • Joined: 19 Aug 2006
  • Unknown

#7

Posted 12 April 2014 - 10:00 AM

It is not bad at all. I would suggest to clear the ambiguity with a percent sign (%).

fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • None

#8

Posted 12 April 2014 - 12:14 PM Edited by fastman92, 12 April 2014 - 12:14 PM.

What about
$0x20 - global variable with ID 32
0x20@ - local variable with ID 32

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci Racing
  • Joined: 19 Aug 2006
  • Unknown

#9

Posted 12 April 2014 - 01:01 PM Edited by Wesser, 12 April 2014 - 01:16 PM.

It will be still ambiguous as x and X are valid characters for defining custom globals names. Adding a special character right after the dollar sign ($) or before the local ID will easily advert SB to treat everything following (till another distinguishing token) as a hexadecimal number.

fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • None

#10

Posted 12 April 2014 - 02:19 PM

Ok, true.

Seemann
  • Seemann

    Ruhe

  • Members
  • Joined: 03 Sep 2004
  • Russia
  • Best Tool 2013 "Sanny Builder"

#11

Posted 13 April 2014 - 02:28 PM

GTA scripts have too much data types characters already, so I would not add a one yet as the proposed percent sign.

 

The common convention for the variables naming is that the names must not begin with a digit. So $0x10 is not a valid name.

In fact SB threats it as a hexadimal value and compiles $0x10 as $16. Similarly, 0x10@ will be compiled as 16@. It means that the fastman's way is already implemented.

 

$20@ definitely should be reported as an error by the compiler (and it looks so, two data types characters in one token are used).


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci Racing
  • Joined: 19 Aug 2006
  • Unknown

#12

Posted 13 April 2014 - 04:05 PM

Yes, my bad, SB behaves like most compilers do indeed. Didn't know about the way of representing variables indices in hexadecimal. I totally agree with you then.

12jango
  • 12jango

    "This is not revenge! This is entertainment!"

  • Members
  • Joined: 08 Mar 2008

#13

Posted 18 April 2014 - 09:33 AM Edited by 12jango, 18 April 2014 - 09:33 AM.

So you're saying 05A6: isn't working at all?


12jango
  • 12jango

    "This is not revenge! This is entertainment!"

  • Members
  • Joined: 08 Mar 2008

#14

Posted 11 May 2014 - 02:14 AM

Anyone?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users