gauchoob

Fight Cave Spawn Prediction Image Generator

Jul 16th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.19 KB | None | 0 0
  1. from PIL import ImageDraw
  2. from PIL import Image
  3. from PIL import ImageFont
  4. import os
  5.  
  6. #Script by Gau Cho
  7. #Information credits: https://www.youtube.com/watch?v=LG5hy9bfb_g
  8.  
  9. GetSpawn=(3, 5, 2, 1, 5, 3, 4, 1, 2, 3, 5, 4, 1, 2, 4)
  10. basemap=Image.open('map.png')
  11. font=ImageFont.truetype("calibri.ttf",22)
  12.  
  13. MapX=249
  14. MapY=265
  15.  
  16. Location2Coordinates=[(100,11),
  17.                     (35,40),
  18.                     (108,113),
  19.                     (180,140),
  20.                     (130,177),
  21.                     (30,187)]           #Wave,NW,C,SE,S,SW
  22. Location2Cardinal=[None,"NW","C","SE","S","SW"]
  23.                    
  24. def PrintSpawn(wave):
  25.     if(wave>=31): return [360,wave-31]
  26.     if(wave>=15): return [180,wave-15]
  27.     if(wave>=7): return [90,wave-7]
  28.     if(wave>=3): return [45,wave-3]
  29.     return [22,wave-1]
  30.  
  31. def GenerateImage(drawlist):
  32.     map=basemap.copy()
  33.     mapd=ImageDraw.Draw(map)
  34.     for item in drawlist:
  35.         mapd.text(item[0],str(item[1]),font=font,fill=(255,255,255,255))
  36.     del mapd
  37.     return map
  38.    
  39. def ProcessWave(wave,i):
  40.     MonsterCount=[0,0,0,0,0,0]
  41.     drawlist=[(Location2Coordinates[0],wave)]
  42.     if(wave==63):
  43.         spawnloc=GetSpawn[i%15]
  44.         coord=Location2Coordinates[spawnloc]
  45.         MonsterCount[spawnloc]+=1
  46.         drawlist.append((coord,702))
  47.         for j in range(4):
  48.             i+=1
  49.             spawnloc=GetSpawn[i%15]
  50.             coord=Location2Coordinates[spawnloc]
  51.             coord=(coord[0],coord[1]+MonsterCount[spawnloc]*25)
  52.             MonsterCount[spawnloc]+=1
  53.            
  54.             drawlist.append((coord,108))
  55.     else:
  56.         while(wave>0):
  57.             mob,wave=PrintSpawn(wave)
  58.            
  59.             spawnloc=GetSpawn[i%15]
  60.             coord=Location2Coordinates[spawnloc]
  61.             coord=(coord[0],coord[1]+MonsterCount[spawnloc]*25)
  62.             MonsterCount[spawnloc]+=1
  63.            
  64.             drawlist.append((coord,mob))
  65.             i+=1
  66.     return drawlist
  67.    
  68. def MapAllWaves(i):
  69.     maplist=[None]*64
  70.     wave=1
  71.     while(wave<64):
  72.         maplist[wave]=GenerateImage(ProcessWave(wave,i))
  73.         i+=1
  74.         wave+=1
  75.     return maplist
  76.  
  77. def GetRotation(i):
  78.     spawnloc=[]
  79.     for j in range(5):
  80.         spawnloc.append(GetSpawn[(i+j)%15])
  81.     if(spawnloc[0]==4 and spawnloc[1]==1):
  82.         return "S/NW C/C/%s %s"%(Location2Cardinal[spawnloc[3]],Location2Cardinal[spawnloc[4]])
  83.     else:
  84.         return "%s/%s %s"%(Location2Cardinal[spawnloc[0]],Location2Cardinal[spawnloc[1]],Location2Cardinal[spawnloc[2]])
  85.    
  86.    
  87.    
  88.    
  89.    
  90.    
  91. def ProcessAllWaves(i):
  92.     maplist=MapAllWaves(i)
  93.     rotation=GetRotation(i)
  94.     MakeSingleMaps(maplist,rotation)
  95.     MakeVertMaps(maplist,rotation)
  96.  
  97. def MakeSingleMaps(maplist,rotation):
  98.     if not(os.path.exists("Single/%s"%(rotation))): os.makedirs("Single/%s"%(rotation))
  99.     for j in range(3,64):
  100.         maplist[j].save("Single/%s/%s.png"%(rotation,str(j)))
  101.  
  102. def MakeVertMaps(maplist,rotation):
  103.     if not(os.path.exists("Vert/%s"%(rotation))): os.makedirs("Vert/%s"%(rotation))
  104.     for j in range(3,60,2):
  105.         img=Image.new("RGBA",(MapX,MapY*4),(0,0,0,255))     #Make an empty image file of width 1 and height 4
  106.         img.paste(maplist[j],(0,0))                         #Paste map image of wave j
  107.         img.paste(maplist[j+1],(0,MapY))                    #Paste map image of wave j+1
  108.         img.paste(maplist[j+2],(0,MapY*2))                  #Paste map image of wave j+2
  109.         img.paste(maplist[j+3],(0,MapY*3))                  #Paste map image of wave j+3
  110.         img.save("Vert/%s/%s.png"%(rotation,str(j)))        #Save file under name j.png
  111.     img=Image.new("RGBA",(MapX,MapY*4),(0,0,0,255))
  112.     img.paste(maplist[61],(0,0))
  113.     img.paste(maplist[62],(0,MapY))
  114.     img.paste(maplist[63],(0,MapY*2))
  115.     img.save("Vert/%s/61.png"%(rotation))
  116.  
  117. def ProcessAllRotations():
  118.     for i in range(15):
  119.         print(i)
  120.         ProcessAllWaves(i)
  121.  
  122. def SampleMap():
  123.     GenerateImage([(Location2Coordinates[0],"Wave"),(Location2Coordinates[1],"NW"),(Location2Coordinates[2],"C"),(Location2Coordinates[3],"SE"),(Location2Coordinates[4],"S"),(Location2Coordinates[5],"SW")]).save("Sample.png")
  124.     return
  125.    
  126. SampleMap()
  127. ProcessAllRotations()
Advertisement
Add Comment
Please, Sign In to add comment