Advertisement
ThoraldGM

Custom Function: GetRandomGear

Sep 19th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.49 KB | None | 0 0
  1.  
  2. ; ------------------------------------------------------------------------------------------------------------
  3. ; CUSTOM FUNCTION: GET RANDOM GEAR
  4. ; ------------------------------------------------------------------------------------------------------------
  5.  
  6. FormList Function GetRandomGear()
  7.  
  8. ; ********************************************************************************************************
  9. ; GUARDS LOADING WILL CALL FUNCTION TO GET A LIST OF ITEMS RANDOMLY CHOSEN FROM PLAYER-STOCKED GEAR LOCKER
  10. ;
  11. ; Players can control the amount of randomness by stocking a variety of wearables, or just a few uniforms.
  12. ; ********************************************************************************************************
  13.  
  14. Form ChosenItem
  15. FormList ChosenGearList
  16. FormList NestedList
  17.  
  18. Int arSize = flStorageList.GetSize()
  19. Int i = 0
  20. Int RandMax
  21. Int RandIndex
  22.  
  23. String WhatIsIt
  24. Bool bSkipSlot
  25.  
  26. ; ********************************************************************************************************
  27. ; WHILE LOOP STARTS HERE! GUARDS CHOOSE ONE RANDOM ITEM TO WEAR FROM EACH OF THE 24 ARMOR SLOT LISTS
  28. ; ********************************************************************************************************
  29.  
  30. While i < arSize ; Start while loop
  31. bSkipSlot = False
  32.  
  33. If i == 0 ; If list is headgear
  34. If Utility.RandomInt(1, 100) <= gvChanceNoHeadgear.GetValue() ; and roll is <= chance none (MCM default: 40%)
  35. bSkipSlot = True ; skip headgear slot
  36.  
  37. If gvDevTracking.GetValue() == 1
  38. Debug.Notification("DCS: Guard refused headgear.") ; notify dev tracker
  39. EndIf
  40. EndIf
  41. EndIf
  42.  
  43. If i == 14 ; If list is eyewear
  44. If Utility.RandomInt(1, 100) <= gvChanceNoEyewear.GetValue() ; and roll is <= chance none (MCM default: 40%)
  45. bSkipSlot = True ; skip eyewear slot
  46.  
  47. If gvDevTracking.GetValue() == 1
  48. Debug.Notification("DCS: Guard refused eyewear.") ; notify dev tracker
  49. EndIf
  50. EndIf
  51. EndIf
  52.  
  53. If !bSkipSlot ; If not skipping slot
  54. NestedList = flStorageList.GetAt(i) as FormList ; grab list for this index
  55.  
  56. If NestedList.GetSize() > 0 ; If list has items
  57. RandMax = NestedList.GetSize() - 1 ; set upper bound
  58. RandIndex = Utility.RandomInt(0, RandMax) ; roll random index
  59.  
  60. ChosenItem = NestedList.GetAt(RandIndex) ; get form from rolled index
  61. ChosenGearList.AddForm(ChosenItem) ; add form to chosen gear list
  62.  
  63. If gvDevTracking.GetValue() == 1
  64. WhatIsIt = strSortedItems[i] as String
  65. Debug.Notification("DCS: Guard chose " + WhatIsIt + ".") ; notify dev tracker
  66. EndIf
  67. EndIf
  68. EndIf
  69.  
  70. i += 1 ; Increment by one
  71.  
  72. EndWhile ; End while loop
  73.  
  74. ; ********************************************************************************************************
  75. ; WHILE LOOP ENDS HERE!
  76. ; ********************************************************************************************************
  77.  
  78. i = 0
  79. arSize = gvNumOtherItems.GetValue() as Int ; MCM default: 5 other items.
  80.  
  81. ; ********************************************************************************************************
  82. ; WHILE LOOP STARTS HERE! GUARDS CHOOSE A NUMBER OF OTHER RANDOM ITEMS TO CARRY. (MCM DEFAULT = 5)
  83. ; ********************************************************************************************************
  84.  
  85. While i < arSize ; Start while loop
  86. If flStorageUnknown.GetSize() > 0 ; If list has items
  87. RandMax = flStorageUnknown.GetSize() - 1 ; set upper bound
  88. RandIndex = Utility.RandomInt(0, RandMax) ; roll random index
  89.  
  90. ChosenItem = flStorageUnknown.GetAt(RandIndex) ; get form from rolled index
  91. ChosenGearList.AddForm(ChosenItem) ; add form to chosen gear list
  92.  
  93. If gvDevTracking.GetValue() == 1
  94. WhatIsIt = strSortedItems[i] as String
  95. Debug.Notification("DCS: Guard chose " + WhatIsIt + ".") ; notify dev tracker
  96. EndIf
  97. EndIf
  98.  
  99. i += 1 ; Increment by one
  100.  
  101. EndWhile ; End while loop
  102.  
  103. ; ********************************************************************************************************
  104. ; WHILE LOOP ENDS HERE!
  105. ; ********************************************************************************************************
  106.  
  107. Return ChosenGearList ; Send gear list to caller!
  108.  
  109. EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement