Jump to content

UI Mod - Bigger Perk Tree


Amineri

Recommended Posts

reading this request gave me an idea... could some perk choices determine which of the next choices will be available? kind of creating paths inside the perk tree. Just an idea, if there's 3 choices per level, picking the one in the middle (most versatile but weaker) could allow picking anyone on next level, but picking one in the sides would only allow to pick next from that same side or the one in the middle *only* for the next level choice, as a way to strengthen two defined roles among so many options... or make it only in the one level with the most powerful perks, so to get THAT perk you need to have already picked some other perk in particular.

 

expanding and combining dubious and lycaninja ideas... could units have more than 2 perk trees each? How nice would it be having one or two common perk tree to all classes, and each class having it's own perk tree as well? ... If there were a way to make that picking a perk from one tree would "cost" xp so other perks re-evaluated wether if they're still available to be selected... so for example there'd be an offensive abilities list/tree, defensive abilities, and class-related special abilities, so each level-up you pick from *one* of the trees. This would mean reworking the way perks become available and make it depends on XP instead of level, I guess.

 

Well, since Amineri said he's got tons of null bytes to fill I thought I'd toss it here... I'm not meddling with ui or perks by now

Link to comment
Share on other sites

  • Replies 193
  • Created
  • Last Reply

Top Posters In This Topic

Definitely is possible to have a "common" perk tree if you like. The easiest way would be to graft it onto the existing psi tree.

 

With this mod, the psi tree display will use the same sprite as the regular tree, so effectively there will be two trees -- each with 7 levels and up to 3 perk choices per level.

 

I'm now planning on adding code to the psi tree display that will allow for customization of the first four column choices ... which needn't be psi powers, and then leaving the bottom three column slots for the psi powers.

 

My default thought for these extra four colums are to have the stat-upgrades -- although additional perk choices are possible. My thought is that soldiers can select off of both trees. If a level unlocks a new column in both trees, then there are two choices to be made.

 

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

 

As to having MORE than 2 perk trees. *ponder*....

 

The tree sprite is really more of a template. If there were some way to cycle beween them, and the data storage were available to store multiple trees, then it would be possible to cycle between trees, calling UpdateAbilityData to refresh the ability icons, just as it does now when switching between soldiers.

 

One issue that we'll quickly run into is a lack of perks (and perk icons).

 

Thanks to bokauk's advice, I've been trying to go through the 2D images in Command1.upk, looking at the gfxSoldierPromotion section. However, its a little mystifying, as some icons that work in game aren't represented, such as "GunSlinger", while others that are represented don't work -- for example, the "ReadyForAnything" perk works fine when turned on, and there is an icon for it defined in the file, but it doesn't work. Also, the umodel app doesn't display an image for these icons (just the name appears)

 

I suspect something shady is going on.

Link to comment
Share on other sites

Just thought I'd update you on the progress I'm making with the Perk Tree Builder :smile:

 

http://i.imgur.com/2TkkkCz.jpg

 

Initially, you'll be able to use the default tree layout (1, 2, 2, 2, 2, 1, 2) and select whichever perks you want in those slots, but I've made the number of perks at each rank, customisable, so it has the potential to add extra perks to the tree in the future.

 

I'll have to get familiarising myself with SWF editing once I sort out the necessary UPK edits! :smile:

 

Link to comment
Share on other sites

That looks really, really excellent! I see you even went ahead and added in the capability of up to 4 ability icons per rank (which I didn't put into the current iteration of the sprite @_@ ).

 

I see you were also able to find the ability icons -- where are they? I tried to scan through the Command1.upk file with Gildor's umodel tool, but all of the icons in the gfxSoldierPromotion were blank.

 

Since you've found them, is there any chance that we could REPLACE icons? That would make this oh-so-much-more effective :)

 

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

 

I've figured out how to pack in up to four perk choices (for up to 11 ranks for each class) into the existing functions. It basically involves byte-packing the perk IDs into a single four byte integer, and the using bit-shifting to retrieve the correct value. Essentially it treats the four-byte integer as an array of four 1-byte values, each one of which can store a perk.

 

The code is quite cryptic-looking, but very efficiently packed. The new function would consist of an outer switch/case statement for each "branch" (this corresponds to rank). Each case has a tightly-coded shift and return statement.

 

switch(branch)

case 1:

return((669739 >> Option) & 0xFF);

case 2:

return((849749 >> Option) & 0xFF);

case 3:

return((144752 >> Option) & 0xFF);

....

The value is determined by:


//value = 65536*perk2 + 256*perk1 + perk0
//ex 65536*10 + 256*56 + 43 = 669739 = 0xA382B
The hex code for this is EXTREMELY efficient:
04 9C 2C FF 95 1D 2B 38 0A 00 00 XX XX XX XX 16 16 16 -- 18 bytes
combined with the case statement, each rank selection takes only 23 bytes of code. The entire function (including endofscript and return tokens) is only 271 bytes long, so I've had to get creative.
The initial switch(branch) is 11 bytes, plus 3 bytes for return null and endofscript, reduces the available space for case statements to 257.
11 of these 23 byte case statements take up 254 bytes -- not a lot of extra room.
-----------------------------------------------
My current plan (reason) for having 11 "ranks" is to use the extra four ranks to establish extra selections in the second tree. The psi abilities take up 3 of the 7 columns, leaving 4 to be used for other things.
By default I plan to set these up as stat increases. The player can choose at certain ranks between different stat increases. Clearly, to balance this the automatic stat increases would have to decrease (but that's already easily configurable).
----------------------------------------------
Other planned changes from the default perk tree:
1) Ranks above the soldier's current rank will simply not display, instead of showing the "?" icons.
2) Players can select a higher level perk if they skipped a lower level one (this one doesn't crop up much normally)
3) Modders will be able to enter the same perk in the tree multiple times. Each perk will only be selectable once, however. (having it in the tree twice allows for multiple chances though)

 

Link to comment
Share on other sites

The 4 perks at a single rank level was just to illustrate that it could be capable of 4 perks (5 even), it isn't hardcoded so it's quite flexible with whatever layout you decide, such as the 3x7 design you posted before :smile: . At some point I'll want delve into SWF editing and to make the Perk Tree UI customisable. From what I gather with what you've said, that won't be easy at all though, but I enjoy a technical challenge :smile:

 

The ability icons are actually dotted about in several places; there are a lot of duplicate textures. I used the ones in Startup.upk > gfxXComIcons >Texture2D because there were some that could only be found there and no duplicates of them.

 

They appear blank because they use an alpha channel which is hidden, rather than using the RGB channels. You'll need to open them up in a graphics editing program and enable the alpha channel of the tga, then re-save it.

 

As far as I'm aware, no one has been able to replace textures in the game and people have instead resorted to using TexMod to change textures. It's on my to-investigate list, as with many other things. I'm guessing it would be beyond my capabilities, but you might have more luck though :smile:

 

Your method of byte-packing is very similar to the idea I had the other day. I didn't think of the bit-wise operations (similar concept though), so I'm not sure if it'll be more compact than yours (I suspect not). Once I test it in practice, I'll have something more conclusive to report back :smile: . If I understand correctly, you're saying the bit-wise method would yield 4*11 perks? :smile:

 

I like the idea of stat increases in the Perk Tree :smile:

 

What benefit would there be for not showing the "?" icons and hiding the placeholders for higher rank perks?

 

 

Link to comment
Share on other sites

Thank you! Most of the UPK headers for the embedded SWF files reference a set of standard "SWF packages" that are included with many of the SWF files. One of those is the gfxXcomIcons, which you have now found in Startup.upk

 

((they show up as text strings just prior to the "GFX" string, like: gfxGamepadIcons.GamepadIcons.....gfxComponents.components.....gfxxcomicons.xcomicons))

 

It definitely looks like that is the "standard library" of icons. Good times!

 

And ... blerg... alpha channels... I didn't think of that ~_~

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

 

Although I represented it as byte-packing, from your tool's point of view you really just would have to set a particular byte at a particular location to the perkID. This method even has the advantage that the spacing is more regular than the nested if/else statements in the original function.

 

And yes, use the bit-shifting to retrieve the packed bytes it is possible to squeeze in 11*4 perks (with 4 bytes to spare in the function).

 

I haven't done any re-writing of that function yet -- I just sized it to know whether I should code in an extra four perk slots on the top of the "Psi Abilities". Since it can fit, I'm going to add it. Functionally all I need is that the perk-selection code returns a perk ID given a row and column (branch and option), or returns a zero if that ability icon slot is to be left empty.

 

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

 

Here is the evolution of hiding the "?" icons and hiding placeholders for higher ranks:

1) The existing psi tree uses some sort of strange offset/mutation of the normaltree, which I completely broke when I reworked the normaltree sprite

2) Rather than try and fix the psitree, I just set it to use the normaltree sprite

3) This cause the "psitree" to display all 7 columns, along with default ranks strings and default rank icons

4) I thought it would be easier to suppress the excess stuff on the normaltree than to fix the actual psitree

5) Once I had the ability to suppress columns, it was just as easy to hide the higher rank stuff as to add extra code to display it

 

I have to build one loop that fills out both the trees under the "Abilities" button and the "Psi Abilities" button. Suppressing unselectable (future) options will make it easier to change the "Psi Abilities" button into a "Stats / Psi Abilities" button.

 

Essentially, the first four entries will be stat increases (or normal perks), and the last three will be the psi abilities (if they are unlocked).

Link to comment
Share on other sites

I keep tossing ideas in, although I'm aware of the difficulty of modding such things, so just tell me when you've got enough :)

 

given that perk trees could hold 11 levels and that it's possible to hide unreached levels (or so I assume from your words)... could it be possible to create hidden, extra levels, that only some of the units could reach? I'm thinking either calculating at random the maximum level possible for each unit (from 7 to 11) when it's created, or making so once each certain XP gain above level 7, there's a small random chance to unlock another level of perks, or both combined...

 

edit: typo

Edited by anUser
Link to comment
Share on other sites

It is definitely possible to dynamically adjust which sets of icons are displayed in the abilitytree sprite.

 

Bokauk uncovered that there are two extra rank icons present in the game (Commander and FieldMarshall)

 

All of the things you suggest are certainly possible. The good news is that making any of those mods would purely be done within the upk files -- once I have the new actionscript set up.

 

Essentially you would check the rank of the soldier, and if it were greater than 6 (since it starts at 0, 6 is current max possible), you would start the column loop at a higher value than 0, thus not displaying the lower rank abilities. If you hadn't selected them then you are out of luck, as they wouldn't be displayed any longer. Alternatively, the extra ranks could be displayed under the 2nd tree, where the "Psi Abilities button" is now.

 

How you define the xp required to reach the higher ranks, and doing the extra checks to level up soldiers past 6 would be up to each modder :).

 

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

 

As to possibilities for limiting -- I'll toss one into the ring. X-COM:Apocalypse limited the number of higher ranks to be relative to the number of lower ranks that you had. But, that game also had a distinction between improving stats and reaching higher rank -- higher rank enabled the soldier to lead squads and gave the squad/etc they were leading bonuses to morale checks.

Link to comment
Share on other sites

The work is moving forward.

1) I have the new rank-tracking system in and working. (not soldier's rank, but promotion ranks)

Previously the game kept track of which rank's perks had been assigned by checking which perks had been assigned, which prevented perks from appearing more than once in the tree, or from having items temporarily grant perks while they are equipped.

The game now tracks which ranks have been promoted in the XGStrategySoldier.m_iEnergy variable-- done via using each bit as a flag. Regular ranks are bits 0-6, Psi ranks are bits 16-18. I've implemented some of the extra ability selections into bits 7-10.


2) All of the SWF code is written

SWF code will turn off all rank icons for the psi tree, display the class icon in the upper left of psi tree, and allows for completely hiding the rank brackets (for the psi tree, there are no rank icons for different psi ranks).

3) Support for branching/dynamic/random ability branching is included

The perk tree will only display the next promotion's worth of ability icons, by default. Rank icons and names will be displayed up to the soldier's current level.

By hiding future ability icons, it allows setting future icons based upon the choices that the player makes at the current rank. I haven't built any data structures to hold this (nor do I have any immediate plans to), but the mod is built for that sort of extension.

4) Support for ZERO perk choices at a level is included

If you want to get really hard-core, a rank can have NO perk choices offered. ZERO. NONE. ZILCH. The game will display no ability icons and will skip the promotion sequence in this case.

No pretty picture yet -- sorry about that! -- only three more functions to rewrite and the mod should be done (excepting the GetPerkInTree functions, which I think bokauk has been working on, so I've left alone so far).

Edited by Amineri
Link to comment
Share on other sites

I'm now at the stage of getting ToolBoks to write the bytecode for those functions.

I gave my theory a test to try and squeeze as many perks into those functions, but it was obviously no way near as efficient as the bit-wise method.

My idea was to combine the two parameters together to produce a unique value like this:

    option +=  branch ** 3;
    switch ( option ) {
        case 1:return 120;
        case 2:return 121;
        case 3:return 122;

It produces all unique values for 1-11 ranks and 1-5 perks for each rank with a maximum of 25 perks in total, which is measly in comparison to bit-wise's 4*11 :smile: . The benefit of this method though is that you can have more than 3 perks per level, but I think the bit-wise is limited to 3 (at least in the implementation Amineri posted?). I always struggle getting my head around bit-wise operations and thinking in binary!

Anyway, I think it's probably better to go with more 7 promotion ranks, rather than more than 3 perks per level, so I'm going to use bit-wise. This will also hopefully allow the Perk Tree Builder to be compatibility with the other promotion options being discussed :smile:

Edited by bokauk
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...