Advertisement
Guest User

Untitled

a guest
Oct 11th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This Highlander hook will get called when any unit's weapon gets initialized, e.g. usually right after the weapon gets equipped or the unit is spawned.
  2. static function WeaponInitialized(XGWeapon WeaponArchetype, XComWeapon Weapon, optional XComGameState_Item ItemState=none)
  3. {
  4.     Local XComGameState_Item    InternalWeaponState;
  5.     local XComGameStateHistory  History;
  6.     local XComGameState_Unit    UnitState;
  7.     local X2WeaponTemplate      WeaponTemplate;
  8.    
  9.     History = `XCOMHISTORY;
  10.    
  11.     //  Acquire Item State if it was not passed on to us.
  12.     if (ItemState == none)
  13.     {
  14.         InternalWeaponState = XComGameState_Item(History.GetGameStateForObjectID(WeaponArchetype.ObjectID));
  15.     }
  16.     else
  17.     {
  18.         InternalWeaponState = ItemState;
  19.     }
  20.    
  21.     if (InternalWeaponState != none)
  22.     {
  23.         // Acquire the Weapon Template for the Weapon that is being Initialized.
  24.         WeaponTemplate = X2WeaponTemplate(InternalWeaponState.GetMyTemplate());
  25.        
  26.         // If the Initialized weapon is a pistol or an autopistol
  27.         if (WeaponTemplate.WeaponCat == 'pistol' || WeaponTemplate.WeaponCat == 'sidearm')
  28.         {
  29.             //  Acquire the Unit State of the unit that holds the weapon that is being initialized.
  30.             UnitState = XComGameState_Unit(History.GetGameStateForObjectID(InternalWeaponState.OwnerStateObject.ObjectID));
  31.            
  32.             //  Acquire the Item State of the weapon in the unit's Secondary Slot.
  33.             InternalWeaponState = UnitState.GetItemInSlot(eInvSlot_SecondaryWeapon);
  34.            
  35.             //  Acquire its template.
  36.             WeaponTemplate = X2WeaponTemplate(InternalWeaponState.GetMyTemplate());
  37.            
  38.             //  If the weapon in the secondary slot is a Ballistic Shield
  39.             if (WeaponTemplate.WeaponCat == 'shield')
  40.             {
  41.                 // Then change the Default Socket of the initialized weapon to the one on soldier's back.
  42.                 // (This socket is added by LW2 Secondary Weapons mod)
  43.                 Weapon.DefaultSocket = 'LowerBackHolster';
  44.                
  45.                 //  Add an Anim Set for pulling out and putting the pistol to that socket.
  46.                 Weapon.CustomUnitPawnAnimsets.AddItem(AnimSet(`CONTENT.RequestGameArchetype("PistolOnBack.AS_Pistol")));
  47.                
  48.                 //No special AnimSet for Females.
  49.                 //Weapon.CustomUnitPawnAnimsetsFemale.AddItem(AnimSet(`CONTENT.RequestGameArchetype("PistolOnBack.FemaleAnimSet")));
  50.             }
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement