Coding

 Reply to this postStart new topic

"Trick" with "if" opcodes with no apparently negative form

AlexTMjugador
post Mar 4 2013, 07:00 PM
Post #1


The New Guy!

Posts: 9
Joined: 20-December 12



Hi everyone! rolleyes.gif

I write this post to show you a quite useful "trick" with "if" opcodes which don't have a negative form in GTAG opcodes.txt, like this one:

04AD: actor $PLAYER_ACTOR in_water

You can use it in any check with no problems, but... sometimes it's more useful to have it in the negative form, so you have less labels, isn't it? For doing that, you only have to change the first 0 of the opcode to a 8, like in the example below:

84AD: actor $PLAYER_ACTOR in_water

When you try to compile it, it'll turn to:

84AD: not actor $PLAYER_ACTOR in_water

And it'll have the negative, inversed function.

I don't really know why does it happen, but it's useful and some people perhaps don't know this thumbsup.gif

This post has been edited by AlexTMjugador: Mar 4 2013, 07:02 PM
Go to the top of the page
 
+Quote Post
fastman92
post Mar 4 2013, 07:13 PM
Post #2


Trained Member

Posts: 77
Joined: 25-October 10



It's known for ages.

Command ID (whole 16 bits) is made up from two components:

command ID (lowest 15 bits)
notFlag - negation flag (highest bit)

04AD has highest bit off, while 84AD has highest bit on, that's the only difference.

This post has been edited by fastman92: Mar 4 2013, 07:13 PM
Go to the top of the page
 
+Quote Post
AlexTMjugador
post Mar 4 2013, 07:17 PM
Post #3


The New Guy!

Posts: 9
Joined: 20-December 12



QUOTE (fastman92 @ Mar 4 2013, 08:13 PM) *
It's known for ages.

Command ID (whole 16 bits) is made up from two components:

command ID (lowest 15 bits)
notFlag - negation flag (highest bit)

04AD has highest bit off, while 84AD has highest bit on, that's the only difference.


Thanks, but my intention was to help newbies who don't know that turned.gif

And can you make, by the way, semi-negative opcodes (although the won't probably work)? LOL tongue.gif

This post has been edited by AlexTMjugador: Mar 4 2013, 07:18 PM
Go to the top of the page
 
+Quote Post
Deji
post Mar 4 2013, 07:27 PM
Post #4


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



If you could divide 1 by any whole number and not get 1 or 0 in decimal, then yes, you could have a semi-negative opcode. But I challenge you to find a way to do that tongue.gif

As for the OpcodeDB thing, it is intentional to leave out the negated opcode forms for a few reasons. They dont really need to show up anywhere and they just create a longer chain of opcodes to magic key through. And as of SCR, using keywords should be the norm, which can be negated easier by preceeding the command name with "NOT". I'd highly recommend using SCR (SCM v2) for future projects in Sanny Builder, by the way.


--------------------
Go to the top of the page
 
+Quote Post
AlexTMjugador
post Mar 4 2013, 07:37 PM
Post #5


The New Guy!

Posts: 9
Joined: 20-December 12



QUOTE (Deji @ Mar 4 2013, 08:27 PM) *
If you could divide 1 by any whole number and not get 1 or 0 in decimal, then yes, you could have a semi-negative opcode. But I challenge you to find a way to do that tongue.gif

As for the OpcodeDB thing, it is intentional to leave out the negated opcode forms for a few reasons. They dont really need to show up anywhere and they just create a longer chain of opcodes to magic key through. And as of SCR, using keywords should be the norm, which can be negated easier by preceeding the command name with "NOT". I'd highly recommend using SCR (SCM v2) for future projects in Sanny Builder, by the way.


Ok, you can't do that with real numbers pinch.gif

And about the SCR, I use Sanny Builder 3, the most beginner one, and only certain opcodes can be negated, like:

not Actor.DrivingVehicleType()

So, where can I get that wonderful and full of posibilities thing called SCR? (Sorry if this means a little nooby wub.gif ).

EDIT: http://gtagmodding.com/opcode-database/generator thumbsup.gif

EDIT 2: Whoa! SCR is wonderful! It doesn't require intensive opcode search teehee.gif

This post has been edited by AlexTMjugador: Mar 4 2013, 07:43 PM
Go to the top of the page
 
+Quote Post
lennoseanx
post Jan 19 2014, 05:43 PM
Post #6


The New Guy!

Posts: 5
Joined: 17-January 14



Useful for newbies like me.


--------------------
Removed
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

5 User(s) are reading this topic (5 Guests and 0 Anonymous Users)
0 Members: