azxeus Posted December 18, 2015 Author Share Posted December 18, 2015 (edited) okay, you were right putting the check in getperkinclasstree wasnt the best choice, but something you said gave me a great idea, m_arrRandomPerks isn't being used in non-TR games so i could use that to store the perktree, so the game knows which perks i had before i got my perk tree and which were assigned after.i've almost finished implementing this but for some reason the game crashes if i try to alter what is going into the m_arrRandomPerks and i just can't figure out why the only clue i have is this weird thing appearing in the log [0040.00] ScriptWarning: Accessed array 'XGStrategySoldier_7.m_arrRandomPerks' out of bounds (3/0) XGStrategySoldier Command1.TheWorld:PersistentLevel.XGStrategySoldier_7 Function XComStrategyGame.XGStrategySoldier:GetPerkInClassTree:00DA which is strange because i never altered how getperkinclasstree accesses m_RandomPerks apart from that it now does so in non-TR games also EDIT: no.. that's not causing the crash.. there are more of them further up. i really have no idea Edited December 18, 2015 by azxeus Link to comment Share on other sites More sharing options...
azxeus Posted December 18, 2015 Author Share Posted December 18, 2015 here's my function, it's crashing when i when i enter line 43 when i try to alter a perk in the tree that the soldier has it crashes.. it works up until the point this happenshttp://pastebin.com/LLJ1pM2K Link to comment Share on other sites More sharing options...
tracktwo Posted December 20, 2015 Share Posted December 20, 2015 ePerk is an array of perk enum values, but GetPerk() in the perk manager returns a TPerk struct. You just need to use ePerk[0] = (byte)71 if you always want to force it to be that perk. But bear in mind that you can re-roll that same perk again, and wind up with 71 in the tree more than once. You might want to actually put the check in IsRandomPerkValidToAdd(). e.g. after the check for m_arrRandomPerks.Find(Perk) != -1 {} add : if (HasPerk(Perk)) return false; Link to comment Share on other sites More sharing options...
azxeus Posted December 20, 2015 Author Share Posted December 20, 2015 (edited) yeah, (byte)71 is what i tried in the first place and that crashes the game too, i really don't know why.. since 71 is mind control and shouldnt appear in the normal perk tree i was going to remove it in getperkinclasstree but i cant get it to work at all..i already have if (HasPerk(Perk)) return false; in the israndomperkvalidtoadd as the training roulette version of this mod, was much easier than what you suggested xD Edited December 20, 2015 by azxeus Link to comment Share on other sites More sharing options...
azxeus Posted December 20, 2015 Author Share Posted December 20, 2015 OKAY NEVERMIND looks like i had 14 (LetBool) instead of 0F (Let) for my = ...NO WONDER IT WASN'T WORKING! I feel like such an idiot, i've been looking at this scratching my head trying to figure out why it was crashing for days.. sighwell the mod is finished now haha, i just replace it with 0 and it removes the perk, i'll post the link here once i have it up Link to comment Share on other sites More sharing options...
azxeus Posted December 20, 2015 Author Share Posted December 20, 2015 and here it is! http://www.nexusmods.com/xcom/mods/655/ Link to comment Share on other sites More sharing options...
tracktwo Posted December 20, 2015 Share Posted December 20, 2015 Cool, glad you got it working! Link to comment Share on other sites More sharing options...
Recommended Posts