Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function updateAmmoList(int ammoQ, bool isBolt)
- ;weaponType - 0 = Bow, 1 = Crossbow - Determined by what type of ranged weapon you are about to equip
- ;First check if anything needs to be removed
- int count = jArray.count(ammoQ)
- int initialCount = count
- int i = 0
- while i < count && count > 0
- if PlayerRef.GetItemCount(jMap.getForm(jArray.getObj(ammoQ, i), "Form")) < 1
- jArray.eraseIndex(ammoQ, i)
- count -= 1
- i -= 1
- endIf
- i += 1
- endWhile
- int NumRemoved = initialCount - count ;Remove once tested
- ;Scan player inventory for all ammo and add it if not already found in the queue
- bool needsSorting = false
- count = GetNumItemsOfType(PlayerRef, 42)
- i = 0
- Form FoundAmmo
- String AmmoName
- while i < count && count > 0
- FoundAmmo = GetNthFormOfType(PlayerRef, 42, i)
- AmmoName = FoundAmmo.GetName()
- ;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
- if !isBolt && (contains(AmmoName, "Arrow") || contains(AmmoName, "arrow")) || isBolt && (contains(AmmoName, "Bolt") || contains(AmmoName, "bolt")) || ((contains(AmmoName, "Javelin" && AmmoName != "Javelin")))
- ;Make sure we're only adding arrows to the arrow queue or bolts to the bolt queue
- if (!isBolt && !(FoundAmmo as Ammo).isBolt()) || (isBolt && (FoundAmmo as Ammo).isBolt())
- if !isAlreadyInAmmoQueue(ammoQ, FoundAmmo)
- AddToAmmoQueue(ammoQ, isBolt, FoundAmmo, AmmoName)
- needsSorting = true
- endIf
- endIf
- endIf
- i += 1
- endWhile
- if needsSorting && !(MCM.AmmoListSorting == 0) ;MCM.AmmoListSorting == 0 is Unsorted
- sortAmmoList(ammoQ)
- endIf
- endFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement