Jump to content

Help please..I lost a mod I made with an update


tsanford01

Recommended Posts

I found a very simple way to allow you to pick both abilities from the perk tree many months ago and for the life of me I can not remember where I found it(the function that is) was something simple like changing an and (&&) to an or(||) if I remember correctly. If anyone could help I would much appreciate it. Happy gaming all!

Link to comment
Share on other sites

The function that keeps you from selecting multiple perks is:

 

XGStrategySoldier.PerkLockedOut(int perk, int branch, optional bool isPsiPerk)

 

The part where it checks for whether one of the current ranks perks is already selected is:

    iOptions = 0;
    J0x66:
    // End:0x111 [Loop If]
    if(iOptions < 2)
    {
        iPerk = perkMgr().GetPerkInTree(m_kSoldier.kClass.eType, branch, iOptions, isPsiPerk);
        // End:0x103
        if(HasPerk(iPerk))
        {
            return true;
        }
        ++ iOptions;
        // [Loop Continue]
        goto J0x66;
    }

I think making this return false would allow you to select all perks in the entire tree.

Link to comment
Share on other sites

Many thanks Amineri !! That advice was spot on.. I got it going again

 

 

If anyone else is interested..

xcomstrategygame.xgstrategysoldier.perklockout(select multiple perks per rank..change last 27 to 28 I.E. true to false)

1A450000AB1F0000000000001445000000000000000000001A4500000000000021010000D72100001E010000D60000004902002815072F002D0018450000072

 

C009700194500001B051000000000000016160427065B000749009700194500001B101000000000000016160427075B009A1B10100000000000001625160427

 

0F0016450000250711019600164500002C02160F0015450000191BAE210000000000001655004FFCFFFF001BF20F0000000000003530FFFFFF7DFAFFFF00003

 

5B4F9FFFF74FAFFFF000001EC440000001945000000164500002D0018450000160703011B1B110000000000000015450000160427

Edited by tsanford01
Link to comment
Share on other sites

  • 4 months later...

Hello again guys...I am finally back went through nasty divorce, moved and a bunch of other crap but saw there is an expansion on the way. Horray! Anyways ill get right to the question.. As you can see up above i was able to get my troups to be able to choose both perks per rank for those uber tough mods..I was trying use it again and found they have changed the perklockout coding in to:

 

if((m_iEnergy & (1 << ((branch - 1) + ((isPsiPerk) ? 16 : 0)))) > 0)
{
return true;
}

 

I changed it to return false and you can in fact choose both perks however next time you open abilities it crashes the game can some one explain to me what this piece of code mean i know it is the key to what im trying.

 

Thanks and happy modding!

Link to comment
Share on other sites

Hee hee. When you say "they" in this case you mean me, as I'm the one that wrote that modded code for the Expanded Perk Tree.

 

What this code is doing is jamming two different things into the same conditional. Unfortunately I often have to put in some obtuse-and-difficult-to-understand code in order to try and squeeze the functionality into the original space. When modding hex code the file size of the function cannot be larger than the vanilla function :(

 

So... a few key points:

1) Ranks that have had perks selected are now stored as bit-flags in the m_iEnergy variable.

2) The code has to handle both regular perks and psi perks. Regular perks are stored in bits 0-15, while psi perks are stored in bits 16-31.

3) The vanilla code allowed perk selection by comparing current soldier perks to the perks available at each rank. I changed this for a couple of reasons.

 

The basic conditional is performing the operation:

if((m_iEnergy & GetBitFlag()) > 0)

The "&" operator is a bitwise-and operator. Essentially this conditional is testing whether a particular bit in the m_iEnergy variable is zero or one.

 

The second part of the conditional (which I represented above as GetBitFlag()), is:

(1 << ((branch - 1) + ((isPsiPerk) ? 16 : 0))))

This again has several parts. The '<<' operator is the 'bit-shift-left' operator. The 1 is there to put a single 1 in the most least-significant-bit. The branch is essentially the rank, except +1'ed. The next part is a ternary operator checking whether we are in the regular perk tree or the psi perk tree. If it's a psi perk then we shift left 16 additional bits.

 

So if branch is 1 (rank 0, rookie), and it's not a psi perk, then we shift-left 0 bits, resulting in just checking the 0 bit. If branch is 2 (rank 1, squaddie), and it's not a psi perk, the we shift-left 1 bit, resulting in checking the 1 bit.

 

After a perk is selected the appropriate bit is set to 1 in the m_iEnergy field for that soldier.

 

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

 

So, effectively changing the true to false disables the bit-checking routine, and allows every perk at every rank to be selected. For the Long War mod which has 3 perk choices at most ranks, all 3 perks would be selectable.

 

Hopefully this helps! (and I apologize again for the nigh-unreadable code :( )

Link to comment
Share on other sites

Lol... you are very sharp to come up with this..I could not for the life of me figure out what the m_iEnergy variable was. Also, I love your mod better than the original game IMHO keep up the great work. So long story short I cant make both perks available without the original conditional evaluation of the perk status per rank..Correct?

Edited by tsanford01
Link to comment
Share on other sites

That's correct (if I'm understanding you correctly).

 

The bit-flag setup using m_iEnergy is explicitly designed to allows exactly 1 perk choice per rank. This is what allows putting the same perk in a class's perk tree more than once. I did this because the larger perk tree was sometimes a bit short on perk choices, so this allows the "weaker" perks to be put in multiple times.

 

Originally I was also thinking that this would be necessary in order to make the smoke grenade and battlescanner equippable items work (they only work if the perk is granted, not just by equipping an item). My goal was to have both items work as both equippable items AND as perk choices. However, I was able to come up with a different way to get those working.

Link to comment
Share on other sites

  • 2 weeks later...

The mechanism that vanilla EU uses to limit soldiers to 1 perk/rank is completely different from how the Expanded Perk Tree mod limits to 1 perk/rank.

 

And neither of these systems allows for a randomized perk tree (per soldier) as is being added with Enemy Within's Training Roulette SW options, so I fully expect there to be a third system with the expansion.

 

Since the expansion is going to be out in a bit over 1.5 weeks, I'm not really working on hex code for any new mods (I'm doing some high level design stuff but that's it).

Link to comment
Share on other sites

  • Recently Browsing   0 members

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