Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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.
- static function WeaponInitialized(XGWeapon WeaponArchetype, XComWeapon Weapon, optional XComGameState_Item ItemState=none)
- {
- Local XComGameState_Item InternalWeaponState;
- local XComGameStateHistory History;
- local XComGameState_Unit UnitState;
- local X2WeaponTemplate WeaponTemplate;
- History = `XCOMHISTORY;
- // Acquire Item State if it was not passed on to us.
- if (ItemState == none)
- {
- InternalWeaponState = XComGameState_Item(History.GetGameStateForObjectID(WeaponArchetype.ObjectID));
- }
- else
- {
- InternalWeaponState = ItemState;
- }
- if (InternalWeaponState != none)
- {
- // Acquire the Weapon Template for the Weapon that is being Initialized.
- WeaponTemplate = X2WeaponTemplate(InternalWeaponState.GetMyTemplate());
- // If the Initialized weapon is a pistol or an autopistol
- if (WeaponTemplate.WeaponCat == 'pistol' || WeaponTemplate.WeaponCat == 'sidearm')
- {
- // Acquire the Unit State of the unit that holds the weapon that is being initialized.
- UnitState = XComGameState_Unit(History.GetGameStateForObjectID(InternalWeaponState.OwnerStateObject.ObjectID));
- // Acquire the Item State of the weapon in the unit's Secondary Slot.
- InternalWeaponState = UnitState.GetItemInSlot(eInvSlot_SecondaryWeapon);
- // Acquire its template.
- WeaponTemplate = X2WeaponTemplate(InternalWeaponState.GetMyTemplate());
- // If the weapon in the secondary slot is a Ballistic Shield
- if (WeaponTemplate.WeaponCat == 'shield')
- {
- // Then change the Default Socket of the initialized weapon to the one on soldier's back.
- // (This socket is added by LW2 Secondary Weapons mod)
- Weapon.DefaultSocket = 'LowerBackHolster';
- // Add an Anim Set for pulling out and putting the pistol to that socket.
- Weapon.CustomUnitPawnAnimsets.AddItem(AnimSet(`CONTENT.RequestGameArchetype("PistolOnBack.AS_Pistol")));
- //No special AnimSet for Females.
- //Weapon.CustomUnitPawnAnimsetsFemale.AddItem(AnimSet(`CONTENT.RequestGameArchetype("PistolOnBack.FemaleAnimSet")));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement