Hazuzi

LOADS Switch (Forward)

Sep 10th, 2022
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. Scriptname BetterLoadSwitches:BetterForwardsSwitch extends BetterLoadSwitches:LoadsSwitchCacheHandler
  2.  
  3. Group InstanceVariables
  4. ObjectMod Property a0aLOADS_OMOD_Slot auto const
  5. Potion Property BLS_ALCH_Switch_Cycle_Forward auto const
  6. EndGroup
  7.  
  8. Event OnEffectStart(actor akTarget, actor akCaster)
  9. akTarget.AddItem(BLS_ALCH_Switch_Cycle_Forward, 1, true)
  10. int isRunningUpdate = BLS_GLOB_IsRunningCacheUpdate.GetValueInt()
  11. if(isRunningUpdate == 1)
  12. Utility.wait(0.5)
  13. BLS_MESG_Info_Still_Loading.Show()
  14. debug.trace("Cache is updating.")
  15. return
  16. EndIf
  17. Weapon currentWeapon = akTarget.GetEquippedWeapon()
  18. Float nextAmmoIndex = BLS_GLOB_NextAmmoIndex.GetValue()
  19. debug.trace("NEXT_AMMO_INDEX_FS = " + nextAmmoIndex)
  20. if(!IsCacheAvailable() || HasCaliberChanged())
  21. UpdateCache(false)
  22. nextAmmoIndex = BLS_GLOB_NextAmmoIndex.GetValue()
  23. if(!IsCacheAvailable())
  24. BLS_MESG_Error_NO_AMMO_TO_EQUIP.Show()
  25. return
  26. EndIf
  27. EndIf
  28. If(CurrentIsSet() && CurrentIsOnlyAmmo())
  29. UpdateCache(true)
  30. if(!IsCacheAvailable() || CurrentIsOnlyAmmo())
  31. BLS_MESG_Error_NO_AMMO_TO_EQUIP.Show()
  32. debug.trace("No ammo to equip.")
  33. return
  34. EndIf
  35. nextAmmoIndex = BLS_GLOB_NextAmmoIndex.GetValue()
  36. EndIf
  37. ;Run Equip
  38. Ammo nextAmmoToEquip = GetAmmoByIndex(nextAmmoIndex as int)
  39. ObjectMod nextOmodToEquip = GetOModByIndex(nextAmmoIndex as Int)
  40. Debug.trace("NEXT = " + nextAmmoToEquip.GetName())
  41. bool bReturn = akTarget.AttachModToInventoryItem(currentWeapon, a0aLOADS_OMOD_Slot)
  42. Bool bReturn2 = akTarget.AttachModToInventoryItem(currentWeapon, nextOmodToEquip)
  43. if(!bReturn || !bReturn2)
  44. akTarget.UnequipItem(nextAmmoToEquip as form, false, true)
  45. if(akTarget.GetItemCount(currentWeapon as form) > 1)
  46. Utility.Wait(1)
  47. a0aLOADS_MESG_Error_TooManyItems.Show()
  48. Else
  49. Utility.Wait(1)
  50. a0aLOADS_MESG_Error_NoSlot.Show()
  51. EndIf
  52. return
  53. EndIf
  54. akTarget.EquipItem(nextAmmoToEquip as form, false, false)
  55. updateCurrentEqippedAmmoCaliberIndex(true)
  56. debug.trace("Successfully attached mod.")
  57. debug.trace("Silently Updating Cache.")
  58. UpdateCache(true)
  59. debug.trace("Silent Cache Update complete.")
  60. EndEvent
Advertisement
Add Comment
Please, Sign In to add comment