Advertisement
RustyDios

PsiSkill_WeaponEquip

Sep 24th, 2020 (edited)
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.33 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////
  2. //  FUNCTION TO ALLOW TRAINED SOLDIERS TO USE PSIONIC WEAPONS
  3. //  NOT RELIANT ON XCOMCLASSDATA.INI CHANGES !!
  4. //  MANY THANKS TO IRIDAR AND SOLARNOUGAT AND ROBOJUMPER
  5. //  **** NOT WORKING -- CRASHES ON (ROBOJUMPERS) SQUAD SELECT ON ANY CHANGE TO SOLDIER LINEUP ****
  6. //  **** WORKS FINE IN ARMOURY *****
  7. ////////////////////////////////////////////////////////////////////////
  8.  
  9. static function bool CanAddItemToInventory_CH_Improved( out int bCanAddItem, const EInventorySlot Slot, const X2ItemTemplate ItemTemplate, int Quantity, XComGameState_Unit UnitState, optional XComGameState CheckGameState, optional out string DisabledReason, optional XComGameState_Item ItemState)
  10. {
  11.     local name PsiAbilityName;
  12.     local array<name> PSI_IDENTIFIER_SKILLS;
  13.  
  14.     local bool OverrideNormalBehavior;
  15.     local bool DoNotOverrideNormalBehavior;
  16.  
  17.     OverrideNormalBehavior = CheckGameState != none;        //change things
  18.     DoNotOverrideNormalBehavior = CheckGameState == none;   //not change things
  19.  
  20.  
  21.     if(DisabledReason != "")
  22.     {
  23.         return DoNotOverrideNormalBehavior;
  24.     }
  25.  
  26.     //Check/confirm slot
  27.     if (Slot != eInvSlot_PrimaryWeapon)
  28.     {
  29.         return DoNotOverrideNormalBehavior;
  30.     }
  31.  
  32.     //check confirm weapons
  33.     if (ItemTemplate.DataName != 'Weapon_AshXcomPsionicReaper' || ItemTemplate.DataName != 'GatlingVorpalRifle_XC')
  34.     {
  35.         return DoNotOverrideNormalBehavior;
  36.     }
  37.  
  38.     //check/confirm class
  39.     if (   UnitState.GetSoldierClassTemplateName() == 'Templar'
  40.         || UnitState.GetSoldierClassTemplateName() == 'Stormrider'
  41.         || UnitState.GetSoldierClassTemplateName() == 'Samurai'
  42.         || UnitState.GetSoldierClassTemplateName() == 'Jedi'
  43.         || UnitState.GetSoldierClassTemplateName() == 'Akimbo'
  44.         )
  45.     {
  46.         //not a class we're interested in -- do nothing (not equip, or as per classdata.ini)
  47.         return DoNotOverrideNormalBehavior;
  48.     }
  49.  
  50.     //create the psi identifier array
  51.     PSI_IDENTIFIER_SKILLS.AddItem('PexM_TestBoost_Standard');
  52.     PSI_IDENTIFIER_SKILLS.AddItem('PexM_TestBoost_Average');
  53.     PSI_IDENTIFIER_SKILLS.AddItem('PexM_TestBoost_Gifted');
  54.     PSI_IDENTIFIER_SKILLS.AddItem('PexM_TestBoost_Genius');
  55.     PSI_IDENTIFIER_SKILLS.AddItem('PexM_TestBoost_Savant');
  56.  
  57.     //check/confirm psi training skills
  58.     foreach PSI_IDENTIFIER_SKILLS(PsiAbilityName)
  59.     {
  60.         if (UnitState.HasSoldierAbility(PsiAbilityName, true))
  61.         {
  62.             `LOG("Weapon Equip Override for soldier :: " @UnitState.GetFullName() @" :: Psi Skill Confirmed :: " @PsiAbilityName @" :: Weapon :: " @ItemTemplate.DataName,default.bEnablePexMLogging,'PsionicsExMachina');
  63.             //slot correct, class correct, weapon correct, psi ability correct -- allow equip
  64.             bCanAddItem = 1;
  65.             return OverrideNormalBehavior;
  66.         }
  67.  
  68.         //slot correct, weapon correct, psi ability not -- disable equip
  69.         DisabledReason = class'UIUtilities_Text'.static.CapsCheckForGermanScharfesS(default.m_strNeedsPsionicUnit);
  70.     }
  71.  
  72.     if (DisabledReason != "")
  73.     {
  74.         bCanAddItem = 0;
  75.         return OverrideNormalBehavior;
  76.     }
  77.  
  78.     //not an item or slot or class or ability we're interested in -- do nothing
  79.     return DoNotOverrideNormalBehavior;
  80. }
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement