Jump to content

How to manage Skip Tokens with UE Explorer


Amineri

Recommended Posts

For me, managing large boolean constructions has always been something I've avoided. Managing the relative jump offsets of the required skip tokens has always been a major hassle.

 

Recently I was forced to construct a truly horrendous-looking boolean construction :

if(((((!m_kUnit.IsInCover() && m_kUnit.CanUseCover()) || m_kUnit.m_arrFlankingUnits.Length > 0) && m_kUnit.IsBeingSuppressed() || m_iOverwatchDangerZone > 0) && m_kUnit.m_arrVisibleFriends.Length == 0) && !m_kAbilityDM.m_bHasStrongAttack)

Yes, it's ugly and yes I had to put it in a single boolean as there is a following else statement.

 

Recently I discovered a trick to more easily set the skip token offset using the token view in UE Explorer. I'm currently using 1.2.3 beta -- I think similar functionality was in the 1.2.2.1 version, but formatted slightly differently.

 

Here is the breakdown of the hex that creates the above monstrosity :

 

 

07 C3 01 
82 
	82 
		82 
			84 
				82 
					81 
						19 01 B8 8A 00 00 0A 00 A4 31 00 00 00 1C A5 31 00 00 16 
					16 
					18 21 00 
					19 01 B8 8A 00 00 0B 00 CC 33 00 00 00 1B A3 0F 00 00 00 00 00 00 4A 16 
				16 
				18 23 00 
				97 36 19 01 B8 8A 00 00 09 00 91 30 00 00 00 01 91 30 00 00 25 16 
			16 
			18 31 00 
			84 
				19 01 B8 8A 00 00 0A 00 3E 31 00 00 00 1B F0 3C 00 00 00 00 00 00 16 
				18 0D 00 
				97 01 8C 8A 00 00 25 16 
			16 
		16 
		18 23 00 
		9A 36 19 01 B8 8A 00 00 09 00 9B 30 00 00 00 01 9B 30 00 00 25 16 
	16 
	18 21 00 
	81 
		19 01 B3 8A 00 00 09 00 A7 88 00 00 00 01 A7 88 00 00 
	16 
16  

 

 

 

I've indented to show the nesting. The 18 XX XX lines are the skip tokens -- there are six of them so that's six relative offsets to update.

 

In the token view of UE Explorer, this line has the following breakdown :

JIN(241/173) -> NF(238/170) -> NF(201/145) -> NF(162/118) -> NF(109/77) -> NF(70/50) -> NF(33/21) -> C(31/19) -> IV(9/5) -> FF(10/6) -> EFP(1/1) -> EFP(1/1) -> S(35/27) -> C(32/24) -> IV(9/5) -> VF(11/11) -> NP(1/1) -> EFP(1/1) -> EFP(1/1) -> S(37/25) -> NF(34/22) -> DAL(31/19) -> C(30/18) -> IV(9/5) -> IV(9/5) -> IZ(1/1) -> EFP(1/1) -> EFP(1/1) -> S(51/39) -> NF(48/36) -> C(31/23) -> IV(9/5) -> VF(10/10) -> EFP(1/1) -> S(15/11) -> NF(12/8) -> IV(9/5) -> IZ(1/1) -> EFP(1/1) -> EFP(1/1) -> EFP(1/1) -> S(37/25) -> NF(34/22) -> DAL(31/19) -> C(30/18) -> IV(9/5) -> IV(9/5) -> IZ(1/1) -> EFP(1/1) -> EFP(1/1) -> S(35/23) -> NF(32/20) -> C(30/18) -> IV(9/5) -> IV(9/5) -> EFP(1/1) -> EFP(1/1)

Of particular note are the six skip tokens, represented using 'S' , shown here in order:

  • S(35/27)
  • S(37/25)
  • S(51/39)
  • S(15/11)
  • S(37/25)
  • S(35/23)

The first value represents the memory size of the skip token statement (always 3 bytes) + the immediately following statement. This number is in decimal, not hex. Since the proper offset for a skip token does not include the length of the skip token, but always includes the 0x16 token terminating the AND/OR statement following the statement after the skip, this means that the correct memory size is the VALUE - 2

 

So, the first skip shows 35, so the memory offset is 35 - 2 = 33 = 0x21. This means updating the skip to 18 21 00.

 

 

Link to comment
Share on other sites

This looks like something to go along with Zybertryx's tutorial on re-factoring code, even though I suspect he is not going to be addressing the subject directly. Unless you can think of somewhere more appropriate to place it?

 

-Dubious-

Link to comment
Share on other sites

I think Zybertryx's tutorial will be the first step for people trying to learn how to make hex changes more significant than single-value changes. Within that category I'd say that being able to manage skip tokens to build more complex boolean constructions is an 'intermediate' level skill.

 

I major part of the reason I asked Zybertryx to write the tutorial (instead of writing it myself) is that I'd have a harder time sorting out the minimal things to put into such a "beginner" tutorial -- hence I begged someone just getting started with coding to write it. I think that adding too many different things to it will make it harder for people rather than easier.

 

So, for the "learning to write hex" section, I'd imagine something like :

 

1) Beginning tutorial (Zybertryx's in-progress)

2) Intermediate level topics

Managing Skip tokens

Construction Ternary operators

3) Advanced level topics

Changing default values

Building new class/struct constructions

Building calls to previously uncalled functions/variables

Link to comment
Share on other sites

"I think Zybertryx's tutorial will be the first step for people trying to learn how to make hex changes more significant than single-value changes. Within that category I'd say that being able to manage skip tokens to build more complex boolean constructions is an 'intermediate' level skill."

 

I agree with this, it's the precise intention.

 

This skip stuff is beyond me currently and I failed my first boolean attempt; I'm still working with simple if statements and relatively tidy nests (and that's great, I've done some cool and unique things already).

 

I'm hoping that my tutorial acts as a foot-in-the-door for those who are filled with desire but frustrated with the seeming unassailable learning curve concerning the even decompiled code, let alone the hex. Also, as I said when I first got into this scene, the wiki I'm sure is great for the technically savvy, but for a lot of 'mere' gamers it seems an unfriendly bludgeon.

 

I'm trying to add as much "101" type stuff as I can when it comes up during the exercise, and I think, as has been my experience, that the more basics I click to, the more accessible (and relevant) the information on the wiki becomes. So, rather than dumbing down the wiki, I'm trying to skill up some noobs (myself included) and maybe entertain some bored pros with my quips. :wink:

 

This is cool stuff though, great to see Amineri offering new modder-side enhancements and insights (like this and the renaming of functions recently).

Edited by Zybertryx
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...