Advertisement
logancberrypie

Untitled

Dec 26th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.37 KB | None | 0 0
  1. from random import randint
  2.  
  3.  
  4. # [name] [weight]
  5. #weight 0-10. Lower is more rare.
  6. weapons = """
  7. Lanternbox 6 obj
  8. Spyglassbox 6 obj
  9. Knife_Variation1 5 wep
  10. Dagger_Variation1 5 wep
  11. BearingFlagBritish 4 wep
  12. CannonRamRod 4 wep
  13. Cutlass_1804PatternNaval 4 wep
  14. Carpenter_Adze 4 wep
  15. Axe2H_Variation1 4 wep
  16. Carbine_Elliot 2 wep
  17. Pistol_XIII 2 wep
  18. Musket_CharlevilleIXXII 1.5 wep
  19. Rifle_CharlevilleDragoonPattern_NoBayonet 1 wep
  20. Blunderbuss_Variation1 1 wep
  21. Carbine_Elliot 1 ammo
  22. Pistol_XIII 1 ammo
  23. Musket_CharlevilleIXXII 1 ammo
  24. Rifle_CharlevilleDragoonPattern_NoBayonet 0.5 ammo
  25. Blunderbuss_Variation1 0.5 ammo
  26. Rocket 0.5 obj
  27. Swivlegun_Stand 0.3 obj
  28. CannonFieldGun9PDRMoveable 0.1 obj"""
  29.  
  30. lowPriorityPoints = """
  31. 676.50 94.85 329.18 0.00 296.07 0.00
  32. 638.69 97.90 334.22 0.00 281.48 0.00
  33. 637.25 95.31 354.12 0.00 0.09 0.00
  34. 652.22 90.71 392.01 0.00 25.29 0.00
  35. 695.25 91.00 412.86 0.00 53.89 0.00
  36. 715.94 98.45 410.43 0.00 129.42 0.00
  37. 721.09 101.05 387.26 0.00 170.75 0.00
  38. 756.96 95.87 398.02 0.00 74.14 0.00
  39. 793.55 87.28 397.01 0.00 88.54 0.00
  40. 822.40 81.99 414.45 0.00 50.03 0.00
  41. 813.60 84.54 434.38 0.00 112.06 0.00
  42. 779.36 95.09 452.58 0.00 290.53 0.00
  43. 793.74 90.19 380.74 0.00 137.74 0.00
  44. 790.72 89.61 343.17 0.00 209.67 0.00
  45. 769.22 90.96 344.24 0.00 282.11 0.00
  46. 761.11 96.19 341.85 0.00 261.80 0.00
  47. 746.23 100.04 443.29 0.00 5.19 0.00
  48. 760.36 95.93 480.84 0.00 27.88 0.00
  49. 783.44 93.54 516.95 0.00 25.05 0.00
  50. 754.06 101.49 531.74 0.00 299.43 0.00
  51. 731.83 98.69 531.55 0.00 264.27 0.00
  52. 701.33 95.47 532.72 0.00 274.87 0.00
  53. 681.86 90.16 503.32 0.00 226.28 0.00
  54. 653.17 90.10 497.58 0.00 258.48 0.00
  55. 636.20 90.03 497.42 0.00 269.99 0.00
  56. 610.43 90.40 503.75 0.00 314.98 0.00
  57. 607.13 91.98 520.78 0.00 355.61 0.00
  58. 621.00 91.69 535.76 0.00 57.76 0.00
  59. 658.82 90.10 532.30 0.00 100.44 0.00
  60. 661.41 94.49 568.36 0.00 351.43 0.00
  61. 626.07 99.72 575.36 0.00 280.20 0.00
  62. 628.64 103.62 592.54 0.00 27.16 0.00
  63. 674.67 106.18 584.09 0.00 95.30 0.00
  64. 746.39 100.01 414.82 0.00 24.31 0.00
  65. 678.15 89.77 415.13 0.00 290.71 0.00
  66. 658.21 89.13 447.42 0.00 325.94 0.00
  67. 626.00 89.17 437.30 0.00 219.68 0.00
  68. 591.96 89.94 422.59 0.00 239.28 0.00
  69. 571.81 95.07 394.62 0.00 205.22 0.00
  70. 560.27 101.75 359.96 0.00 201.29 0.00
  71. 527.15 111.59 341.84 0.00 244.88 0.00
  72. 512.45 112.37 318.22 0.00 210.10 0.00
  73. 548.71 106.88 310.35 0.00 104.62 0.00
  74. 515.98 105.90 370.47 0.00 316.90 0.00
  75. 477.94 103.72 375.05 0.00 276.15 0.00
  76. 435.71 104.45 391.06 0.00 289.52 0.00
  77. 404.51 108.14 388.21 0.00 267.28 0.00
  78. 384.55 115.63 382.03 0.00 261.49 0.00
  79. 383.46 102.93 414.11 0.00 329.88 0.00
  80. 361.85 102.64 421.14 0.00 282.96 0.00
  81. 346.56 97.75 442.40 0.00 321.14 0.00
  82. 356.74 97.35 461.49 0.00 25.68 0.00
  83. 345.25 99.25 476.81 0.00 315.61 0.00
  84. 344.61 95.85 498.30 0.00 341.71 0.00
  85. 366.43 95.15 507.93 0.00 53.06 0.00
  86. 381.13 95.97 519.89 0.00 44.96 0.00
  87. 401.23 95.32 540.65 0.00 29.01 0.00
  88. 428.36 93.31 516.43 0.00 128.39 0.00
  89. 458.40 91.89 525.64 0.00 80.05 0.00
  90. 489.71 94.39 544.28 0.00 31.46 0.00
  91. 494.72 100.85 586.75 0.00 7.03 0.00
  92. 510.71 107.90 597.41 0.00 53.95 0.00
  93. 540.70 104.50 584.65 0.00 100.11 0.00
  94. 576.84 105.37 578.03 0.00 96.38 0.00
  95. 595.24 93.65 534.69 0.00 134.69 0.00
  96. 590.13 90.70 502.97 0.00 188.30 0.00
  97. 574.59 91.02 478.01 0.00 250.26 0.00
  98. 544.78 90.79 469.98 0.00 244.35 0.00
  99. 521.21 91.34 497.42 0.00 307.98 0.00
  100. 486.04 91.29 506.62 0.00 275.58 0.00
  101. 487.29 92.96 488.18 0.00 175.56 0.00
  102. 509.65 91.20 470.36 0.00 125.81 0.00
  103. 498.17 91.10 473.12 0.00 272.11 0.00
  104. 487.47 91.32 459.34 0.00 170.94 0.00
  105. 510.15 91.45 456.89 0.00 102.80 0.00
  106. 518.45 92.11 441.26 0.00 133.27 0.00
  107. 564.96 91.31 413.87 0.00 132.37 0.00
  108. 657.18 91.26 415.60 0.00 154.48 0.00
  109. 673.38 92.83 374.61 0.00 167.21 0.00
  110. 684.76 94.80 323.09 0.00 167.21 0.00
  111. 626.50 103.63 309.29 0.00 249.40 0.00
  112. """
  113.  
  114. # chance that the object spawns in. 0.4 => 40%
  115. lowPrioritySpawnChance = 0.9
  116. #additional chance that an object spawns. 0.01 => 1%
  117. lowPriorityLootWeight = 0.01
  118. #Distance loot boost. 0.01 => 1%
  119. distanceLootWeight = 0.01
  120.  
  121. #weapons on racks
  122. weaponsOnRacks = 2
  123. shotsPerAmmoBox = 2
  124. shotsPerAmmoBoxInteration = 1
  125. maximumAmmoBoxInteractions = 2
  126.  
  127. class WeaponBank():
  128. currentMin = 0
  129. def __init__(self, weaponID, weight, weightSum, weaponType):
  130. self.id = weaponID
  131. self.min = WeaponBank.currentMin
  132. self.max = WeaponBank.currentMin + weight / weightSum
  133. WeaponBank.currentMin = self.max
  134. self.type = weaponType
  135.  
  136. def __str__(self):
  137. string = "type = "+self.id+"\n min ="+str(self.min)+"\n max = "+str(self.max)+"\n type = "+self.type
  138. return string
  139.  
  140. def generateString(self,point):
  141. if (self.type == "obj"):
  142. string = "objects_override "+self.id + " " + point.toString()
  143. elif (self.type == "wep"):
  144. string = "objects_override WeaponRack " + point.toString() + " " + self.id +" " + str(weaponsOnRacks)
  145. elif (self.type == "ammo"):
  146. string = "objects_override firearmammobox " + point.toString()+ " " + self.id + " " + str(shotsPerAmmoBoxInteration) + " " + str(shotsPerAmmoBox) + " " + str(maximumAmmoBoxInteractions)
  147. return string
  148.  
  149.  
  150. class Point():
  151. def __init__(self, x , y ,z ,rx , ry , rz):
  152. self.x = x
  153. self.y = y
  154. self.z = z
  155. self.rx = rx
  156. self.ry = ry
  157. self.rz = rz
  158.  
  159. def __str__(self):
  160. string = self.x + " " + self.y + " " + self.z + " " + self.rx + " " + self.ry + " " + self.rz
  161. return string
  162.  
  163. def toString(self):
  164. string = self.x + " " + self.y + " " + self.z + " " + self.rx + " " + self.ry + " " + self.rz
  165. return string
  166.  
  167.  
  168. WeaponArray = []
  169. PointArray = []
  170. def generateWeapons(weapons):
  171. weightMax = getWeightMax(weapons)
  172. for line in weapons.strip("\n").split("\n"):
  173. lineArray = line.split(" ")
  174. itemId = lineArray[0]
  175. itemWeight = float(lineArray[1])
  176. itemType = lineArray[2]
  177. WeaponArray.append(WeaponBank(itemId , itemWeight, weightMax, itemType))
  178.  
  179. def generatePoints(points):
  180. for line in points.strip("\n").split("\n"):
  181. lineArray = line.split(" ")
  182. PointArray.append(Point(lineArray[0],lineArray[1],lineArray[2],lineArray[3],lineArray[4],lineArray[5]))
  183.  
  184. def getWeightMax(weapons):
  185. counter = 0
  186. for line in weapons.strip("\n").split("\n"):
  187. lineArray = line.split(" ")
  188. counter += float(lineArray[1])
  189. return counter
  190.  
  191.  
  192. #Checked
  193. def getObject(weight, WeaponArray):
  194. for obj in WeaponArray:
  195. if (obj.min <= weight and obj.max > weight):
  196. return obj
  197. return obj
  198.  
  199. def main(PointArray, WeaponArray):
  200. string = ""
  201. for point in PointArray:
  202. #print(point)
  203. if (randomPointGenerate(point)):
  204. weaponForUse = randomWeaponGenerate(point, WeaponArray)
  205. #print("weapon",weaponForUse)
  206. objectString = weaponForUse.generateString(point)
  207. #print(objectString)
  208. string = string + objectString + "\n"
  209. print("Done")
  210. print(string)
  211.  
  212. def randomPointGenerate(point):
  213. random = randint(1,99) / 100
  214. #print(random)
  215. if random <= lowPrioritySpawnChance:
  216. return True
  217. return False
  218.  
  219. def randomWeaponGenerate(point, WeaponArray):
  220. random = randint(1,99) / 100
  221. return getObject(random , WeaponArray)
  222.  
  223. generatePoints(lowPriorityPoints)
  224. generateWeapons(weapons)
  225. main(PointArray, WeaponArray)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement