Jump to content

UI Mod - Bigger Perk Tree


Amineri

Recommended Posts

Actually the bit-shifting method can support four perks per integer. I just didn't post the complete code for it >.>;

 

The actual bit-shift operation remains exactly the same, except that 0-, 8-, 16- and 24-bit shifts will generate valid 1-byte values.

 

To encode it manually, the code fragment would be:

 

 

//value = 16777216*perk3 + 65536*perk2 + 256*perk1 + perk0
//ex 16777216*22 + 65536*10 + 256*56 + 43 = 369768491= 0x160A382B
Of course it's a lot clearer if I write it in hexadecimal:
//value = 0x1000000*perk3 + 0x10000*perk2 + 0x100*perk1 + perk0
/ex 0x1000000*0x16 + 0x10000*0x0A + 0x100*38 + 2B = 0x160A382B
You can see that in hexadecimal I'm just concatenating the values together.
EDIT:
Another way to see it is when you enter the hex value (using the 1D) tag, which would be:
1D 2B 38 0A 16
Entering it like this, the first byte is perk0, second byte is perk1, etc
Edited by Amineri
Link to comment
Share on other sites

  • Replies 193
  • Created
  • Last Reply

Top Posters In This Topic

Ahh, I knew I was doing something wrong trying to pack 4 8-bit numbers into a 32-bit integer! I was trying to shift 0, 8, 16 and... 32, I'm such an idiot! haha :wallbash:

 

In which case, I might be misunderstanding something else.

   switch(branch)
          case 1:
                return((669739 >> Option) & 0xFF);

This doesn't seem to return the original numbers packed in. "Option" will be 0-4, so that number should be multiplied by 8 to shift the correct number of bits.

I've had to add "Option *= 8;" before the switch statement to fix that, so this takes up a few more bytes.

 

If I misunderstand this too, please feel free to correct me :smile:

 

Thanks for the clarification. When it comes to bit-wise, you can tell I'm not a bit wise :wink:

Link to comment
Share on other sites

You've totally got it right.

I hadn't mentioned the Option *= 8 thing.

I was just messing around with that before. I had thought originally that the return statement was 1 byte longer ... so I was thinking of multiplying the Option value by 8 before calling the function.

However, with the extra bytes, it fits, so happy times.

I just made a version for my own testing for the support class, and the rest of the UI works with the new structure. The values I'm basing on are the Long War perks, so don't fret if the exact numbers don't match.

I had:
case 1 : 1D 00 2C 00 00
case 2 : 1D 0A 00 30 00
case 3 : 1D 2F 00 38 00
case 4 : 1D 08 00 5C 00
case 5 : 1D 31 00 34 00
case 6 : 1D 00 21 00 00
case 7 : 1D 36 00 37 00
case 8+: 1D 00 00 00 00


You see how I left the perk0 slot in case 1 as zero, and also perk2. This selects only the CENTER icon for display, so that the display can remain centered and pretty.
For case 2 there are values in perk0 and perk2, but perk 1 is left empty. This selects the RIGHT and LEFT icons for display (leaving the center one blank).

I've confirmed that the above values will replicate the perk tree layout of the vanilla game.

I haven't implemented anything for using branches 8 and higher yet, so I'm just leaving those zero for now.

----

P.S. My code wasn't working until I cast the 8 as a float... apparently *= only takes floats as the second operator ~_~. However, I still had 1 byte to spare in my example function.

In case you want to see my test-code, here it is:


New Hex broken down:
header
4D 66 00 00 50 55 00 00 00 00 00 00 38 66 00 00 00 00 00 00 00 00 00 00 3B 66 00 00 00 00 00 00 C5 01 00 00 A2 41 00 00 47 01 00 00 0F 01 00 00

body
Option *= float(8 );
9F 00 3A 66 00 00 38 3F 2C 08 16

switch(branch)
05 3B 66 00 00 00 00 3B 66 00 00

case 1:
0A 3C 00 2C 01

return((## ## ## ## >> Option) & 0xFF); // numbers are based on perk ID
04 9C 2C FF 95 1D 00 2C 00 00 00 3A 66 00 00 16 16

case 2:
0A 56 00 2C 02

return((## ## ## ## >> Option) & 0xFF); // numbers are based on perk ID
04 9C 2C FF 95 1D 0A 00 30 00 00 3A 66 00 00 16 16

case 3:
0A 70 00 2C 03

return((## ## ## ## >> Option) & 0xFF); // numbers are based on perk ID
04 9C 2C FF 95 1D 2F 00 38 00 00 3A 66 00 00 16 16

case 4:
0A 8A 00 2C 04

return((## ## ## ## >> Option) & 0xFF); // numbers are based on perk ID
04 9C 2C FF 95 1D 08 00 5C 00 00 3A 66 00 00 16 16

case 5:
0A A4 00 2C 05

return((## ## ## ## >> Option) & 0xFF); // numbers are based on perk ID
04 9C 2C FF 95 1D 31 00 34 00 00 3A 66 00 00 16 16

case 6:
0A BE 00 2C 06

return((## ## ## ## >> Option) & 0xFF); // numbers are based on perk ID
04 9C 2C FF 95 1D 00 21 00 00 00 3A 66 00 00 16 16

case 7:
0A D8 00 2C 07

return((## ## ## ## >> Option) & 0xFF); // numbers are based on perk ID
04 9C 2C FF 95 1D 36 00 37 00 00 3A 66 00 00 16 16

case 8:
0A F2 00 2C 08

return((## ## ## ## >> Option) & 0xFF); // numbers are based on perk ID
04 9C 2C FF 95 1D 00 00 00 00 00 3A 66 00 00 16 16

case 9:
0A 0C 01 2C 09

return((## ## ## ## >> Option) & 0xFF); // numbers are based on perk ID
04 9C 2C FF 95 1D 00 00 00 00 00 3A 66 00 00 16 16

case 10:
0A 26 01 2C 0A

return((## ## ## ## >> Option) & 0xFF); // numbers are based on perk ID
04 9C 2C FF 95 1D 00 00 00 00 00 3A 66 00 00 16 16

case 11:
0A 40 01 2C 0B

return (## ## ## ## >> Option) & 0xFF; // numbers are based on perk ID
04 9C 2C FF 95 1D 00 00 00 00 00 3A 66 00 00 16 16

default:
0A FF FF

return 0
04 25

null-ops (1 bytes)
0B

endofscript
53

 

Edited by Amineri
Link to comment
Share on other sites

Okay, all the major rewrites are done. I've seen one minor glitch, but it's pretty much working now.

 

Here is a screenshot of a rank 5 Support with a customized perk tree:

 

http://wiki.tesnexus.com/images/3/3e/Expanded_PerkUI_Screenshot.jpg

 

This screenshot is to showcase various features of the mod -- it is not intended to be representative of actual gameplay.

 

Note that both Smoke Grenade and Field Medic were offered at both Squaddie and Corporal. Selecting Smoke Grenade at Squaddie will disallow it as a choice at Corporal (and similar for Field Medic).

 

The Soldier is currently a Captain, but has not chosen the Lieutenant rank perk yet, so the Captain-level perks are not yet displayed. Also all perks below Captain are not displayed. This is to allow future mods to build randomized or branching perk trees, where later perks depend upon what was selected earlier.

 

Customization of 0, 1, 2, or 3 perks is allowed via the basic hex edit (which bokauk is working on the tool to make even easier). Selecting 0 perks at a level will result in the rank icon / label being displayed, but no perk icons. Zero'd out perks leave a blank area and are not selectable.

 

 

-------------------

Here is what the psi tree is looking like. Unfortunately I haven't rewritten the perk-retrieval function for psi perks, so the ability icons are bit off, but the rest is working as planned:

 

http://wiki.tesnexus.com/images/a/a4/Expanded_PsiPerkUI_Screenshot.jpg

 

Perk customization works basically the same as with the ability tree. Up to 3 perks can be selected per rank. Duplicate perks at different levels are allowed. Maximum psi rank is still 3 currently, although that could be adjusted with a little effort. Because psionic perks are granted in the same way as other perks, regular perks can be placed in the Psi Tree (for example "Will to Survive" could be put in)

 

Psionic rank names are editable via a hex edit -- I allocated 15 characters per psionic rank string.

 

The stat increases in the four extra slots of the psi tree aren't going to be in the first release. Going to need icons and a few other things, and I'd rather get the mod out and being used with the extra perks rather than delay it further to try and get them in.

 

I noticed one small bug that I need to still fix (when using prev/next soldier and moving from a soldier of lower rank to higher, the borders aren't made visible properly), and then I plan on posting this up to the wiki. Probably be up tomorrow ... probably.

 

This mod currently replaces about 12 kilobytes of hex code -- it's not exactly lightweight :o

Link to comment
Share on other sites

Great work as always, Amineri :smile: . I'm sure many people in the community will appreciate your efforts :smile:

ToolBoks is now writing the UPK change for the Assault class successfully. I'll finish off the functions for the other classes and do some tests.

Amineri, what layout are you going with for the Perk Tree (i.e, how many perks for each rank level)? Will the initial release be 3x7? Obviously ToolBoks won't be able to write the SWF UI changes just yet, so I'll have to setup presets (default layout and your layout design) rather than enabling full customisation for now.

Link to comment
Share on other sites

Here's an early release of the Perk Tree Builder to whet you appetite. Consider the Perks section as Beta because it's not quite finished and there might be some bugs.

 

There are no restrictions in place to prevent you from selecting too many perks; you must currently stick with default layout:

 

Rank1: 1 perk

Rank2: 2 perks

Rank3: 2 perks

Rank4: 2 perks

Rank5: 2 perks

Rank6: 1 perk

Rank7: 2 perks

 

When Amineri has finished with the UI side of things, you'll be able to change to the layout she has defined (possibly 3 perks for each rank?).

 

Please let me know of any bugs or misconfigurations of the perks, their IDs or their images etc, so that I can fix them.

 

You currently have to Apply Changes for each class one at a time, you can't applying the settings to all 4 classes in one go.

 

I've done some tests and it seems to work ok with the perks I tried out. There might be some perks that aren't available to some classes. I'm think someone has done more extensive testing on this before though and have more information on this subject :smile:

 

I've included the enemy perks/abilities in case someone makes them available in the future.

 

At the moment, it doesn't detect your current Perk Tree and it will display the default Assault Perk Tree for all classes.

 

I haven't tested it on saved games, so I'm not sure how the perks will behave.

 

Don't forget, stick to the default layout (1, 2, 2, 2, 2, 1, 2) and replace the perks, rather than adding more or removing some.

 

Make backups just in case :smile:

 

Let me know if you have any suggestions/improvements and I'm happy to hear your thoughts on it so far :smile:

 

Download it here

(It's listed in the "Optional Files" section of the download page)

 

http://i.imgur.com/KNFnppn.jpg

Link to comment
Share on other sites

This is looking really, excellent, bokauk !!

 

Unfortunately the release of the the Perk Tree enhancement is going to be a bit delayed. At some point in the last couple of weeks I introduced a bug that causes the game to crash when entering a tactical mission, and I have no idea what caused it. I'm going to be a bit trying to trace it down ...

 

The only recent changes I've made since the last time I'd tested the tactical missions were the Interceptor and Perk Tree UI changes, none of which should be affecting the tactical code, so I'm a bit stumped. I'm having to trace through step by step to see if I can isolate specifically what was causing it to crash -- if I can.

Link to comment
Share on other sites

My last two bugs are squashed!

 

They were:

1) Brackets, rank icon and rank label would not display if using Prev/Next soldier and and switching from a lower rank soldier to a higher rank soldier

 

2) If a rank had zero choosable abilities (due to all perks having been previous selected, or having zero defined available perks), the progression could get stuck. The code now auto-marks the rank as having been (perk-wise) promoted if there are no valid choices for the current rank.

 

As a side note on bug 2, the code now checks HasPerk() by checking only bit 0 of the m_kSoldier.m_kChar.aUpgrades[iPerk] array. This will return as true only if the integer in this value is ODD. The intended use is that equipping items that generate perks as a side effect will always increment or decrement the aUpgrades[] array by TWO. This will allow for selection of perks from the perk tree even if an item that ALSO grants the perk is currently equipped.

 

For example, if a soldier has a Smoke Grenade equipped, aUpgrades(ePerk_SmokeGrenade) = 2 (0b00000010). Because the 0 bit is still zero, the soldier can still select the Smoke Grenade perk from the Barracks promotion screen. After selecting the perk aUpgrades(ePerk_SmokeGrenade) = 3 (0b00000011).

 

This allows each perk to be selected only once. However, it should solidly de-conflict items and perks from one another.

 

When setting item charges in the tactical code, it will be simple to distinguish between the number of items granting a perk and whether the perk itself has been selected.

 

For example, if each equipped smoke grenade is to grant 1 charge, but ePerk_SmokeGrenade should grant 2 charges, this can be accomplished via:

 

charges = (aUpgrades[iPerk] >> 1) + (2*(aUpgrades[iPerk] & 1))

 

In general

1) aUpgrades[iPerk] & 1 will tell whether a perk has been applied (from the perk tree)

2) aUpgrades[iPerk] >> 1 will supply the number of items equipped that grant the perk

3) aUpgrades[iPerk] > 0 will indicate whether the character has the perk from any source

 

--------------------------------------------------------------------

 

All that remains is to build the new GetPerkInTree functions. The template is complete, so it shouldn't take long.

 

Does anyone have any feedback as to what the default perk selection should be with the expanded perk tree? I'd prefer to NOT have it be the default 1-2-2-2-2-1-2 perk layout, as I want someone installing the mod to quickly be able to tell that it has been installed.

 

Any thoughts on this?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...