Advertisement
Guest User

lasers.py

a guest
Jul 15th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.62 KB | None | 0 0
  1. import os
  2.  
  3. mapfolder = "C:\Program Files (x86)\Steam\steamapps\common\Momentum Mod\momentum\maps"
  4. mapname = input("Enter map name: ")
  5. filedir = "%s\%s.zon" % (mapfolder, mapname)
  6.  
  7. if not os.path.isfile(filedir):
  8.     print(".zon file does not exist for this map!")
  9. else:
  10.     with open(filedir) as zonefile:
  11.         for linecount, line in enumerate(zonefile):
  12.             if linecount+1 == 7:
  13.                 xpos = float(line.lstrip().lstrip('"xpos"').lstrip().rstrip('\n').strip('""'))
  14.             if linecount+1 == 8:
  15.                 ypos = float(line.lstrip().lstrip('"ypos"').lstrip().rstrip('\n').strip('""'))
  16.             if linecount+1 == 9:
  17.                 zpos = float(line.lstrip().lstrip('"zpos"').lstrip().rstrip('\n').strip('""'))
  18.             if linecount+1 == 13:
  19.                 xScaleMins = float(line.lstrip().lstrip('"xScaleMins"').lstrip().rstrip('\n').strip('""'))
  20.             if linecount+1 == 14:
  21.                 yScaleMins = float(line.lstrip().lstrip('"yScaleMins"').lstrip().rstrip('\n').strip('""'))
  22.             if linecount+1 == 15:
  23.                 zScaleMins = float(line.lstrip().lstrip('"zScaleMins"').lstrip().rstrip('\n').strip('""'))
  24.             print("%d | %s" % (linecount+1, line.rstrip('\n')))
  25. print("=====================")
  26. point_top1 = [xpos - xScaleMins - 1, ypos - yScaleMins - 1, zpos - zScaleMins - 1]          #The +/- 1 on each value is to shrink the laser box by 1 unit in each direction, to make sure the lasers are visible when touching up against a wall.
  27. point_top2 = [xpos + xScaleMins + 1, ypos - yScaleMins - 1, zpos - zScaleMins - 1]
  28. point_top3 = [xpos + xScaleMins + 1, ypos + yScaleMins + 1, zpos - zScaleMins - 1]
  29. point_top4 = [xpos - xScaleMins - 1, ypos + yScaleMins + 1, zpos - zScaleMins - 1]
  30. point_bottom1 = [xpos - xScaleMins - 1, ypos - yScaleMins - 1, zpos + zScaleMins + 1]
  31. point_bottom2 = [xpos + xScaleMins + 1, ypos - yScaleMins - 1, zpos + zScaleMins + 1]
  32. point_bottom3 = [xpos + xScaleMins + 1, ypos + yScaleMins + 1, zpos + zScaleMins + 1]
  33. point_bottom4 = [xpos - xScaleMins - 1, ypos + yScaleMins + 1, zpos + zScaleMins + 1]
  34. point_bottom1_2 = [xpos - xScaleMins - 1, ypos - yScaleMins - 1, zpos + zScaleMins + 1]
  35. point_bottom2_2 = [xpos + xScaleMins + 1, ypos - yScaleMins - 1, zpos + zScaleMins + 1]
  36. point_bottom3_2 = [xpos + xScaleMins + 1, ypos + yScaleMins + 1, zpos + zScaleMins + 1]
  37. point_bottom4_2 = [xpos - xScaleMins - 1, ypos + yScaleMins + 1, zpos + zScaleMins + 1]
  38.  
  39. configtext = """
  40. add:
  41. {
  42.    "classname" "env_laser"
  43.    "targetname" "laser_top1"
  44.    "LaserTarget" "laser_top2"
  45.    "origin" "%d %d %d"
  46.    "width" "1"
  47.    "TextureScroll" "0"
  48.    "texture" "sprites/laserbeam.vmt"
  49.    "spawnflags" "1"
  50.    "brightness" "255"
  51.    "rendercolor" "255 0 0"
  52.    "renderamt" "255"
  53.    "dissolvetype" "None"
  54.    "damage" "0"
  55.    "NoiseAmplitude" "0"
  56. }
  57. {
  58.    "classname" "env_laser"
  59.    "targetname" "laser_top2"
  60.    "LaserTarget" "laser_top3"
  61.    "origin" "%d %d %d"
  62.    "width" "1"
  63.    "TextureScroll" "0"
  64.    "texture" "sprites/laserbeam.vmt"
  65.    "spawnflags" "1"
  66.    "brightness" "255"
  67.    "rendercolor" "255 0 0"
  68.    "renderamt" "255"
  69.    "dissolvetype" "None"
  70.    "damage" "0"
  71.    "NoiseAmplitude" "0"
  72. }
  73. {
  74.    "classname" "env_laser"
  75.    "targetname" "laser_top3"
  76.    "LaserTarget" "laser_top4"
  77.    "origin" "%d %d %d"
  78.    "width" "1"
  79.    "TextureScroll" "0"
  80.    "texture" "sprites/laserbeam.vmt"
  81.    "spawnflags" "1"
  82.    "brightness" "255"
  83.    "rendercolor" "255 0 0"
  84.    "renderamt" "255"
  85.    "dissolvetype" "None"
  86.    "damage" "0"
  87.    "NoiseAmplitude" "0"
  88. }
  89. {
  90.    "classname" "env_laser"
  91.    "targetname" "laser_top4"
  92.    "LaserTarget" "laser_top1"
  93.    "origin" "%d %d %d"
  94.    "width" "1"
  95.    "TextureScroll" "0"
  96.    "texture" "sprites/laserbeam.vmt"
  97.    "spawnflags" "1"
  98.    "brightness" "255"
  99.    "rendercolor" "255 0 0"
  100.    "renderamt" "255"
  101.    "dissolvetype" "None"
  102.    "damage" "0"
  103.    "NoiseAmplitude" "0"
  104. }
  105. {
  106.    "classname" "env_laser"
  107.    "targetname" "laser_bottom1"
  108.    "LaserTarget" "laser_bottom2"
  109.    "origin" "%d %d %d"
  110.    "width" "1"
  111.    "TextureScroll" "0"
  112.    "texture" "sprites/laserbeam.vmt"
  113.    "spawnflags" "1"
  114.    "brightness" "255"
  115.    "rendercolor" "255 0 0"
  116.    "renderamt" "255"
  117.    "dissolvetype" "None"
  118.    "damage" "0"
  119.    "NoiseAmplitude" "0"
  120. }
  121. {
  122.    "classname" "env_laser"
  123.    "targetname" "laser_bottom2"
  124.    "LaserTarget" "laser_bottom3"
  125.    "origin" "%d %d %d"
  126.    "width" "1"
  127.    "TextureScroll" "0"
  128.    "texture" "sprites/laserbeam.vmt"
  129.    "spawnflags" "1"
  130.    "brightness" "255"
  131.    "rendercolor" "255 0 0"
  132.    "renderamt" "255"
  133.    "dissolvetype" "None"
  134.    "damage" "0"
  135.    "NoiseAmplitude" "0"
  136. }
  137. {
  138.    "classname" "env_laser"
  139.    "targetname" "laser_bottom3"
  140.    "LaserTarget" "laser_bottom4"
  141.    "origin" "%d %d %d"
  142.    "width" "1"
  143.    "TextureScroll" "0"
  144.    "texture" "sprites/laserbeam.vmt"
  145.    "spawnflags" "1"
  146.    "brightness" "255"
  147.    "rendercolor" "255 0 0"
  148.    "renderamt" "255"
  149.    "dissolvetype" "None"
  150.    "damage" "0"
  151.    "NoiseAmplitude" "0"
  152. }
  153. {
  154.    "classname" "env_laser"
  155.    "targetname" "laser_bottom4"
  156.    "LaserTarget" "laser_bottom1"
  157.    "origin" "%d %d %d"
  158.    "width" "1"
  159.    "TextureScroll" "0"
  160.    "texture" "sprites/laserbeam.vmt"
  161.    "spawnflags" "1"
  162.    "brightness" "255"
  163.    "rendercolor" "255 0 0"
  164.    "renderamt" "255"
  165.    "dissolvetype" "None"
  166.    "damage" "0"
  167.    "NoiseAmplitude" "0"
  168. }
  169. {
  170.    "classname" "env_laser"
  171.    "targetname" "laser_bottom1_2"
  172.    "LaserTarget" "laser_top1"
  173.    "origin" "%d %d %d"
  174.    "width" "1"
  175.    "TextureScroll" "0"
  176.    "texture" "sprites/laserbeam.vmt"
  177.    "spawnflags" "1"
  178.    "brightness" "255"
  179.    "rendercolor" "255 0 0"
  180.    "renderamt" "255"
  181.    "dissolvetype" "None"
  182.    "damage" "0"
  183.    "NoiseAmplitude" "0"
  184. }
  185. {
  186.    "classname" "env_laser"
  187.    "targetname" "laser_bottom2_2"
  188.    "LaserTarget" "laser_top2"
  189.    "origin" "%d %d %d"
  190.    "width" "1"
  191.    "TextureScroll" "0"
  192.    "texture" "sprites/laserbeam.vmt"
  193.    "spawnflags" "1"
  194.    "brightness" "255"
  195.    "rendercolor" "255 0 0"
  196.    "renderamt" "255"
  197.    "dissolvetype" "None"
  198.    "damage" "0"
  199.    "NoiseAmplitude" "0"
  200. }
  201. {
  202.    "classname" "env_laser"
  203.    "targetname" "laser_bottom3_2"
  204.    "LaserTarget" "laser_top3"
  205.    "origin" "%d %d %d"
  206.    "width" "1"
  207.    "TextureScroll" "0"
  208.    "texture" "sprites/laserbeam.vmt"
  209.    "spawnflags" "1"
  210.    "brightness" "255"
  211.    "rendercolor" "255 0 0"
  212.    "renderamt" "255"
  213.    "dissolvetype" "None"
  214.    "damage" "0"
  215.    "NoiseAmplitude" "0"
  216. }
  217. {
  218.    "classname" "env_laser"
  219.    "targetname" "laser_bottom4_2"
  220.    "LaserTarget" "laser_top4"
  221.    "origin" "%d %d %d"
  222.    "width" "1"
  223.    "TextureScroll" "0"
  224.    "texture" "sprites/laserbeam.vmt"
  225.    "spawnflags" "1"
  226.    "brightness" "255"
  227.    "rendercolor" "255 0 0"
  228.    "renderamt" "255"
  229.    "dissolvetype" "None"
  230.    "damage" "0"
  231.    "NoiseAmplitude" "0"
  232. }
  233. """ % (point_top1[0], point_top1[1], point_top1[2], point_top2[0], point_top2[1], point_top2[2], point_top3[0], point_top3[1], point_top3[2], point_top4[0], point_top4[1], point_top4[2], point_bottom1[0], point_bottom1[1], point_bottom1[2], point_bottom2[0], point_bottom2[1], point_bottom2[2], point_bottom3[0], point_bottom3[1], point_bottom3[2], point_bottom4[0], point_bottom4[1], point_bottom4[2], point_bottom1_2[0], point_bottom1_2[1], point_bottom1_2[2], point_bottom2_2[0], point_bottom2_2[1], point_bottom2_2[2], point_bottom3_2[0], point_bottom3_2[1], point_bottom3_2[2], point_bottom4_2[0], point_bottom4_2[1], point_bottom4_2[2])
  234. print(configtext)
  235.  
  236. with open("%s\%s_lasers.cfg" % (mapfolder, mapname), "w") as outputfile:
  237.     outputfile.write(configtext)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement