Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scriptname BetterLoadSwitches:BetterForwardsSwitch extends BetterLoadSwitches:LoadsSwitchCacheHandler
- Group InstanceVariables
- ObjectMod Property a0aLOADS_OMOD_Slot auto const
- Potion Property BLS_ALCH_Switch_Cycle_Forward auto const
- EndGroup
- Event OnEffectStart(actor akTarget, actor akCaster)
- akTarget.AddItem(BLS_ALCH_Switch_Cycle_Forward, 1, true)
- int isRunningUpdate = BLS_GLOB_IsRunningCacheUpdate.GetValueInt()
- if(isRunningUpdate == 1)
- Utility.wait(0.5)
- BLS_MESG_Info_Still_Loading.Show()
- debug.trace("Cache is updating.")
- return
- EndIf
- Weapon currentWeapon = akTarget.GetEquippedWeapon()
- Float nextAmmoIndex = BLS_GLOB_NextAmmoIndex.GetValue()
- debug.trace("NEXT_AMMO_INDEX_FS = " + nextAmmoIndex)
- if(!IsCacheAvailable() || HasCaliberChanged())
- UpdateCache(false)
- nextAmmoIndex = BLS_GLOB_NextAmmoIndex.GetValue()
- if(!IsCacheAvailable())
- BLS_MESG_Error_NO_AMMO_TO_EQUIP.Show()
- return
- EndIf
- EndIf
- If(CurrentIsSet() && CurrentIsOnlyAmmo())
- UpdateCache(true)
- if(!IsCacheAvailable() || CurrentIsOnlyAmmo())
- BLS_MESG_Error_NO_AMMO_TO_EQUIP.Show()
- debug.trace("No ammo to equip.")
- return
- EndIf
- nextAmmoIndex = BLS_GLOB_NextAmmoIndex.GetValue()
- EndIf
- ;Run Equip
- Ammo nextAmmoToEquip = GetAmmoByIndex(nextAmmoIndex as int)
- ObjectMod nextOmodToEquip = GetOModByIndex(nextAmmoIndex as Int)
- Debug.trace("NEXT = " + nextAmmoToEquip.GetName())
- bool bReturn = akTarget.AttachModToInventoryItem(currentWeapon, a0aLOADS_OMOD_Slot)
- Bool bReturn2 = akTarget.AttachModToInventoryItem(currentWeapon, nextOmodToEquip)
- if(!bReturn || !bReturn2)
- akTarget.UnequipItem(nextAmmoToEquip as form, false, true)
- if(akTarget.GetItemCount(currentWeapon as form) > 1)
- Utility.Wait(1)
- a0aLOADS_MESG_Error_TooManyItems.Show()
- Else
- Utility.Wait(1)
- a0aLOADS_MESG_Error_NoSlot.Show()
- EndIf
- return
- EndIf
- akTarget.EquipItem(nextAmmoToEquip as form, false, false)
- updateCurrentEqippedAmmoCaliberIndex(true)
- debug.trace("Successfully attached mod.")
- debug.trace("Silently Updating Cache.")
- UpdateCache(true)
- debug.trace("Silent Cache Update complete.")
- EndEvent
Advertisement
Add Comment
Please, Sign In to add comment