SHARE
TWEET

generate_statics.py

rPoXoTauJIo Sep 27th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import re
  2.  
  3. INITIAL_POINT = (1576.0, 44.3, 613.0)
  4. INITIAL_ROTATION = (0.0, 0.0, 0.0)
  5.  
  6. OFFSET_Z = 40.0
  7. OFFSET_X = -40.0
  8.  
  9. TEMPLATE = """
  10. rem *** housingblock_1_groundfloor_v2 ***
  11. Object.create housingblock_1_groundfloor_v2
  12. Object.absolutePosition 0.0/0.0/0.0
  13. Object.rotation 0.0/0.0/0.0
  14. Object.layer 1
  15.  
  16. rem *** housingblock_1_midfloor_v1 ***
  17. Object.create housingblock_1_midfloor_v1
  18. Object.absolutePosition 0.0/3.5/0.0
  19. Object.rotation 0.0/0.0/0.0
  20. Object.layer 1
  21.  
  22. rem *** housingblock_1_topfloor ***
  23. Object.create housingblock_1_topfloor
  24. Object.absolutePosition 0.0/7.0/0.0
  25. Object.rotation 0.0/0.0/0.0
  26. Object.layer 1
  27. """
  28.  
  29. class BF2Object(object):
  30.     def __init__(self, name, position=(0.0, 0.0, 0.0), rotation=(0.0, 0.0, 0.0)):
  31.         self.name = name
  32.         self.position = position
  33.         self.rotation = rotation
  34.  
  35. def generate_tshape(position, rotation, num_floors):
  36.     HEIGHT_midfloor = 3.5
  37.     objects = []
  38.  
  39.     # ground floor
  40.     ground_floor = BF2Object('housingblock_1_groundfloor_v2', position, rotation)
  41.     objects.append(ground_floor)
  42.     #print('added %s at %s at floor %d' % (ground_floor.name, ground_floor.position, 0))
  43.  
  44.     # middle floors
  45.     for floor_num in range(1, num_floors):
  46.         positionY = position[1] + HEIGHT_midfloor * floor_num
  47.         position_midfloor = (position[0], positionY, position[2])
  48.         middle_floor = BF2Object('housingblock_1_midfloor_v1', position_midfloor, rotation)
  49.         objects.append(middle_floor)
  50.         #print('added %s at %s at floor %d' % (middle_floor.name, middle_floor.position, floor_num))
  51.    
  52.     # top floor
  53.     # anchor of housingblock_1_topfloor is -10.5, so its on 3rd floor height
  54.     positionY = position[1] + HEIGHT_midfloor * num_floors
  55.     position_topfloor = (position[0], positionY, position[2])
  56.     topfloor = BF2Object('housingblock_1_topfloor', position_topfloor, rotation)
  57.     objects.append(topfloor)
  58.     #print('added %s at %s at floor %d' % (topfloor.name, topfloor.position, num_floors))
  59.  
  60.     return objects
  61.  
  62. def createScript(bf2object):
  63.     createScriptString = ''
  64.     createScriptString += 'rem *** {0.name} ***\n'.format(bf2object)
  65.     createScriptString += 'Object.create {0.name}\n'.format(bf2object)
  66.     createScriptString += 'Object.absolutePosition {0.position[0]}/{0.position[1]}/{0.position[2]}\n'.format(bf2object)
  67.     createScriptString += 'Object.rotation {0.rotation[0]}/{0.rotation[1]}/{0.rotation[2]}\n'.format(bf2object)
  68.     createScriptString += 'Object.layer 1\n\n'
  69.  
  70.     return createScriptString
  71.  
  72. def main():
  73.     path_testing = 'D:\\Games\\Project Reality\\mods\\pr_repo\\levels\\test_airfield\\staticobjects_testing.con'
  74.     with open(path_testing, 'w') as staticobjects:
  75.         CITY_X = 5
  76.         CITY_Z = 10
  77.         NUM_FLOORS = 10
  78.         for i in range(0, CITY_X):
  79.             for j in range(0, CITY_Z):
  80.                 positionX = INITIAL_POINT[0] + OFFSET_X * i
  81.                 positionZ = INITIAL_POINT[2] + OFFSET_Z * j
  82.                 position = (positionX, INITIAL_POINT[1], positionZ)
  83.  
  84.                 print('generating T-shape[%d][%d] of %d floors at %s' % (i, j, NUM_FLOORS, position))
  85.                 tshape = generate_tshape(position, INITIAL_ROTATION, NUM_FLOORS)
  86.                 for bf2object in tshape:
  87.                     staticobjects.write(createScript(bf2object))
  88.  
  89.  
  90.  
  91. if __name__ == '__main__':
  92.     main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top