Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ------------------------------------------------------------------------------------------------------------
- ; CUSTOM FUNCTION: GET RANDOM GEAR
- ; ------------------------------------------------------------------------------------------------------------
- FormList Function GetRandomGear()
- ; ********************************************************************************************************
- ; GUARDS LOADING WILL CALL FUNCTION TO GET A LIST OF ITEMS RANDOMLY CHOSEN FROM PLAYER-STOCKED GEAR LOCKER
- ;
- ; Players can control the amount of randomness by stocking a variety of wearables, or just a few uniforms.
- ; ********************************************************************************************************
- Form ChosenItem
- FormList ChosenGearList
- FormList NestedList
- Int arSize = flStorageList.GetSize()
- Int i = 0
- Int RandMax
- Int RandIndex
- String WhatIsIt
- Bool bSkipSlot
- ; ********************************************************************************************************
- ; WHILE LOOP STARTS HERE! GUARDS CHOOSE ONE RANDOM ITEM TO WEAR FROM EACH OF THE 24 ARMOR SLOT LISTS
- ; ********************************************************************************************************
- While i < arSize ; Start while loop
- bSkipSlot = False
- If i == 0 ; If list is headgear
- If Utility.RandomInt(1, 100) <= gvChanceNoHeadgear.GetValue() ; and roll is <= chance none (MCM default: 40%)
- bSkipSlot = True ; skip headgear slot
- If gvDevTracking.GetValue() == 1
- Debug.Notification("DCS: Guard refused headgear.") ; notify dev tracker
- EndIf
- EndIf
- EndIf
- If i == 14 ; If list is eyewear
- If Utility.RandomInt(1, 100) <= gvChanceNoEyewear.GetValue() ; and roll is <= chance none (MCM default: 40%)
- bSkipSlot = True ; skip eyewear slot
- If gvDevTracking.GetValue() == 1
- Debug.Notification("DCS: Guard refused eyewear.") ; notify dev tracker
- EndIf
- EndIf
- EndIf
- If !bSkipSlot ; If not skipping slot
- NestedList = flStorageList.GetAt(i) as FormList ; grab list for this index
- If NestedList.GetSize() > 0 ; If list has items
- RandMax = NestedList.GetSize() - 1 ; set upper bound
- RandIndex = Utility.RandomInt(0, RandMax) ; roll random index
- ChosenItem = NestedList.GetAt(RandIndex) ; get form from rolled index
- ChosenGearList.AddForm(ChosenItem) ; add form to chosen gear list
- If gvDevTracking.GetValue() == 1
- WhatIsIt = strSortedItems[i] as String
- Debug.Notification("DCS: Guard chose " + WhatIsIt + ".") ; notify dev tracker
- EndIf
- EndIf
- EndIf
- i += 1 ; Increment by one
- EndWhile ; End while loop
- ; ********************************************************************************************************
- ; WHILE LOOP ENDS HERE!
- ; ********************************************************************************************************
- i = 0
- arSize = gvNumOtherItems.GetValue() as Int ; MCM default: 5 other items.
- ; ********************************************************************************************************
- ; WHILE LOOP STARTS HERE! GUARDS CHOOSE A NUMBER OF OTHER RANDOM ITEMS TO CARRY. (MCM DEFAULT = 5)
- ; ********************************************************************************************************
- While i < arSize ; Start while loop
- If flStorageUnknown.GetSize() > 0 ; If list has items
- RandMax = flStorageUnknown.GetSize() - 1 ; set upper bound
- RandIndex = Utility.RandomInt(0, RandMax) ; roll random index
- ChosenItem = flStorageUnknown.GetAt(RandIndex) ; get form from rolled index
- ChosenGearList.AddForm(ChosenItem) ; add form to chosen gear list
- If gvDevTracking.GetValue() == 1
- WhatIsIt = strSortedItems[i] as String
- Debug.Notification("DCS: Guard chose " + WhatIsIt + ".") ; notify dev tracker
- EndIf
- EndIf
- i += 1 ; Increment by one
- EndWhile ; End while loop
- ; ********************************************************************************************************
- ; WHILE LOOP ENDS HERE!
- ; ********************************************************************************************************
- Return ChosenGearList ; Send gear list to caller!
- EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement