Advertisement
dunc001

Untitled

Aug 28th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. function updateAmmoList(int ammoQ, bool isBolt)
  2. ;weaponType - 0 = Bow, 1 = Crossbow - Determined by what type of ranged weapon you are about to equip
  3. ;First check if anything needs to be removed
  4. int count = jArray.count(ammoQ)
  5. int initialCount = count
  6. int i = 0
  7. while i < count && count > 0
  8. if PlayerRef.GetItemCount(jMap.getForm(jArray.getObj(ammoQ, i), "Form")) < 1
  9. jArray.eraseIndex(ammoQ, i)
  10. count -= 1
  11. i -= 1
  12. endIf
  13. i += 1
  14. endWhile
  15. int NumRemoved = initialCount - count ;Remove once tested
  16. ;Scan player inventory for all ammo and add it if not already found in the queue
  17. bool needsSorting = false
  18. count = GetNumItemsOfType(PlayerRef, 42)
  19. i = 0
  20. Form FoundAmmo
  21. String AmmoName
  22. while i < count && count > 0
  23. FoundAmmo = GetNthFormOfType(PlayerRef, 42, i)
  24. AmmoName = FoundAmmo.GetName()
  25. ;stringUtil.Find() is case sensitive, the Javelin check is to get the Spears by Soolie javelins which are classed as arrows/bolts and all of which have more descriptive names than simply Javelin, which is from Throwing Weapons and is an equippable throwing weapon
  26. if !isBolt && (contains(AmmoName, "Arrow") || contains(AmmoName, "arrow")) || isBolt && (contains(AmmoName, "Bolt") || contains(AmmoName, "bolt")) || ((contains(AmmoName, "Javelin" && AmmoName != "Javelin")))
  27. ;Make sure we're only adding arrows to the arrow queue or bolts to the bolt queue
  28. if (!isBolt && !(FoundAmmo as Ammo).isBolt()) || (isBolt && (FoundAmmo as Ammo).isBolt())
  29. if !isAlreadyInAmmoQueue(ammoQ, FoundAmmo)
  30. AddToAmmoQueue(ammoQ, isBolt, FoundAmmo, AmmoName)
  31. needsSorting = true
  32. endIf
  33. endIf
  34. endIf
  35. i += 1
  36. endWhile
  37. if needsSorting && !(MCM.AmmoListSorting == 0) ;MCM.AmmoListSorting == 0 is Unsorted
  38. sortAmmoList(ammoQ)
  39. endIf
  40. endFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement