Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- # [name] [weight]
- #weight 0-10. Lower is more rare.
- weapons = """
- Lanternbox 6 obj
- Spyglassbox 6 obj
- Knife_Variation1 5 wep
- Dagger_Variation1 5 wep
- BearingFlagBritish 4 wep
- CannonRamRod 4 wep
- Cutlass_1804PatternNaval 4 wep
- Carpenter_Adze 4 wep
- Axe2H_Variation1 4 wep
- Carbine_Elliot 2 wep
- Pistol_XIII 2 wep
- Musket_CharlevilleIXXII 1.5 wep
- Rifle_CharlevilleDragoonPattern_NoBayonet 1 wep
- Blunderbuss_Variation1 1 wep
- Carbine_Elliot 1 ammo
- Pistol_XIII 1 ammo
- Musket_CharlevilleIXXII 1 ammo
- Rifle_CharlevilleDragoonPattern_NoBayonet 0.5 ammo
- Blunderbuss_Variation1 0.5 ammo
- Rocket 0.5 obj
- Swivlegun_Stand 0.3 obj
- CannonFieldGun9PDRMoveable 0.1 obj"""
- lowPriorityPoints = """
- 676.50 94.85 329.18 0.00 296.07 0.00
- 638.69 97.90 334.22 0.00 281.48 0.00
- 637.25 95.31 354.12 0.00 0.09 0.00
- 652.22 90.71 392.01 0.00 25.29 0.00
- 695.25 91.00 412.86 0.00 53.89 0.00
- 715.94 98.45 410.43 0.00 129.42 0.00
- 721.09 101.05 387.26 0.00 170.75 0.00
- 756.96 95.87 398.02 0.00 74.14 0.00
- 793.55 87.28 397.01 0.00 88.54 0.00
- 822.40 81.99 414.45 0.00 50.03 0.00
- 813.60 84.54 434.38 0.00 112.06 0.00
- 779.36 95.09 452.58 0.00 290.53 0.00
- 793.74 90.19 380.74 0.00 137.74 0.00
- 790.72 89.61 343.17 0.00 209.67 0.00
- 769.22 90.96 344.24 0.00 282.11 0.00
- 761.11 96.19 341.85 0.00 261.80 0.00
- 746.23 100.04 443.29 0.00 5.19 0.00
- 760.36 95.93 480.84 0.00 27.88 0.00
- 783.44 93.54 516.95 0.00 25.05 0.00
- 754.06 101.49 531.74 0.00 299.43 0.00
- 731.83 98.69 531.55 0.00 264.27 0.00
- 701.33 95.47 532.72 0.00 274.87 0.00
- 681.86 90.16 503.32 0.00 226.28 0.00
- 653.17 90.10 497.58 0.00 258.48 0.00
- 636.20 90.03 497.42 0.00 269.99 0.00
- 610.43 90.40 503.75 0.00 314.98 0.00
- 607.13 91.98 520.78 0.00 355.61 0.00
- 621.00 91.69 535.76 0.00 57.76 0.00
- 658.82 90.10 532.30 0.00 100.44 0.00
- 661.41 94.49 568.36 0.00 351.43 0.00
- 626.07 99.72 575.36 0.00 280.20 0.00
- 628.64 103.62 592.54 0.00 27.16 0.00
- 674.67 106.18 584.09 0.00 95.30 0.00
- 746.39 100.01 414.82 0.00 24.31 0.00
- 678.15 89.77 415.13 0.00 290.71 0.00
- 658.21 89.13 447.42 0.00 325.94 0.00
- 626.00 89.17 437.30 0.00 219.68 0.00
- 591.96 89.94 422.59 0.00 239.28 0.00
- 571.81 95.07 394.62 0.00 205.22 0.00
- 560.27 101.75 359.96 0.00 201.29 0.00
- 527.15 111.59 341.84 0.00 244.88 0.00
- 512.45 112.37 318.22 0.00 210.10 0.00
- 548.71 106.88 310.35 0.00 104.62 0.00
- 515.98 105.90 370.47 0.00 316.90 0.00
- 477.94 103.72 375.05 0.00 276.15 0.00
- 435.71 104.45 391.06 0.00 289.52 0.00
- 404.51 108.14 388.21 0.00 267.28 0.00
- 384.55 115.63 382.03 0.00 261.49 0.00
- 383.46 102.93 414.11 0.00 329.88 0.00
- 361.85 102.64 421.14 0.00 282.96 0.00
- 346.56 97.75 442.40 0.00 321.14 0.00
- 356.74 97.35 461.49 0.00 25.68 0.00
- 345.25 99.25 476.81 0.00 315.61 0.00
- 344.61 95.85 498.30 0.00 341.71 0.00
- 366.43 95.15 507.93 0.00 53.06 0.00
- 381.13 95.97 519.89 0.00 44.96 0.00
- 401.23 95.32 540.65 0.00 29.01 0.00
- 428.36 93.31 516.43 0.00 128.39 0.00
- 458.40 91.89 525.64 0.00 80.05 0.00
- 489.71 94.39 544.28 0.00 31.46 0.00
- 494.72 100.85 586.75 0.00 7.03 0.00
- 510.71 107.90 597.41 0.00 53.95 0.00
- 540.70 104.50 584.65 0.00 100.11 0.00
- 576.84 105.37 578.03 0.00 96.38 0.00
- 595.24 93.65 534.69 0.00 134.69 0.00
- 590.13 90.70 502.97 0.00 188.30 0.00
- 574.59 91.02 478.01 0.00 250.26 0.00
- 544.78 90.79 469.98 0.00 244.35 0.00
- 521.21 91.34 497.42 0.00 307.98 0.00
- 486.04 91.29 506.62 0.00 275.58 0.00
- 487.29 92.96 488.18 0.00 175.56 0.00
- 509.65 91.20 470.36 0.00 125.81 0.00
- 498.17 91.10 473.12 0.00 272.11 0.00
- 487.47 91.32 459.34 0.00 170.94 0.00
- 510.15 91.45 456.89 0.00 102.80 0.00
- 518.45 92.11 441.26 0.00 133.27 0.00
- 564.96 91.31 413.87 0.00 132.37 0.00
- 657.18 91.26 415.60 0.00 154.48 0.00
- 673.38 92.83 374.61 0.00 167.21 0.00
- 684.76 94.80 323.09 0.00 167.21 0.00
- 626.50 103.63 309.29 0.00 249.40 0.00
- """
- # chance that the object spawns in. 0.4 => 40%
- lowPrioritySpawnChance = 0.9
- #additional chance that an object spawns. 0.01 => 1%
- lowPriorityLootWeight = 0.01
- #Distance loot boost. 0.01 => 1%
- distanceLootWeight = 0.01
- #weapons on racks
- weaponsOnRacks = 2
- shotsPerAmmoBox = 2
- shotsPerAmmoBoxInteration = 1
- maximumAmmoBoxInteractions = 2
- class WeaponBank():
- currentMin = 0
- def __init__(self, weaponID, weight, weightSum, weaponType):
- self.id = weaponID
- self.min = WeaponBank.currentMin
- self.max = WeaponBank.currentMin + weight / weightSum
- WeaponBank.currentMin = self.max
- self.type = weaponType
- def __str__(self):
- string = "type = "+self.id+"\n min ="+str(self.min)+"\n max = "+str(self.max)+"\n type = "+self.type
- return string
- def generateString(self,point):
- if (self.type == "obj"):
- string = "objects_override "+self.id + " " + point.toString()
- elif (self.type == "wep"):
- string = "objects_override WeaponRack " + point.toString() + " " + self.id +" " + str(weaponsOnRacks)
- elif (self.type == "ammo"):
- string = "objects_override firearmammobox " + point.toString()+ " " + self.id + " " + str(shotsPerAmmoBoxInteration) + " " + str(shotsPerAmmoBox) + " " + str(maximumAmmoBoxInteractions)
- return string
- class Point():
- def __init__(self, x , y ,z ,rx , ry , rz):
- self.x = x
- self.y = y
- self.z = z
- self.rx = rx
- self.ry = ry
- self.rz = rz
- def __str__(self):
- string = self.x + " " + self.y + " " + self.z + " " + self.rx + " " + self.ry + " " + self.rz
- return string
- def toString(self):
- string = self.x + " " + self.y + " " + self.z + " " + self.rx + " " + self.ry + " " + self.rz
- return string
- WeaponArray = []
- PointArray = []
- def generateWeapons(weapons):
- weightMax = getWeightMax(weapons)
- for line in weapons.strip("\n").split("\n"):
- lineArray = line.split(" ")
- itemId = lineArray[0]
- itemWeight = float(lineArray[1])
- itemType = lineArray[2]
- WeaponArray.append(WeaponBank(itemId , itemWeight, weightMax, itemType))
- def generatePoints(points):
- for line in points.strip("\n").split("\n"):
- lineArray = line.split(" ")
- PointArray.append(Point(lineArray[0],lineArray[1],lineArray[2],lineArray[3],lineArray[4],lineArray[5]))
- def getWeightMax(weapons):
- counter = 0
- for line in weapons.strip("\n").split("\n"):
- lineArray = line.split(" ")
- counter += float(lineArray[1])
- return counter
- #Checked
- def getObject(weight, WeaponArray):
- for obj in WeaponArray:
- if (obj.min <= weight and obj.max > weight):
- return obj
- return obj
- def main(PointArray, WeaponArray):
- string = ""
- for point in PointArray:
- #print(point)
- if (randomPointGenerate(point)):
- weaponForUse = randomWeaponGenerate(point, WeaponArray)
- #print("weapon",weaponForUse)
- objectString = weaponForUse.generateString(point)
- #print(objectString)
- string = string + objectString + "\n"
- print("Done")
- print(string)
- def randomPointGenerate(point):
- random = randint(1,99) / 100
- #print(random)
- if random <= lowPrioritySpawnChance:
- return True
- return False
- def randomWeaponGenerate(point, WeaponArray):
- random = randint(1,99) / 100
- return getObject(random , WeaponArray)
- generatePoints(lowPriorityPoints)
- generateWeapons(weapons)
- main(PointArray, WeaponArray)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement