Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import ImageDraw
- from PIL import Image
- from PIL import ImageFont
- import os
- #Script by Gau Cho
- #Information credits: https://www.youtube.com/watch?v=LG5hy9bfb_g
- GetSpawn=(3, 5, 2, 1, 5, 3, 4, 1, 2, 3, 5, 4, 1, 2, 4)
- basemap=Image.open('map.png')
- font=ImageFont.truetype("calibri.ttf",22)
- MapX=249
- MapY=265
- Location2Coordinates=[(100,11),
- (35,40),
- (108,113),
- (180,140),
- (130,177),
- (30,187)] #Wave,NW,C,SE,S,SW
- Location2Cardinal=[None,"NW","C","SE","S","SW"]
- def PrintSpawn(wave):
- if(wave>=31): return [360,wave-31]
- if(wave>=15): return [180,wave-15]
- if(wave>=7): return [90,wave-7]
- if(wave>=3): return [45,wave-3]
- return [22,wave-1]
- def GenerateImage(drawlist):
- map=basemap.copy()
- mapd=ImageDraw.Draw(map)
- for item in drawlist:
- mapd.text(item[0],str(item[1]),font=font,fill=(255,255,255,255))
- del mapd
- return map
- def ProcessWave(wave,i):
- MonsterCount=[0,0,0,0,0,0]
- drawlist=[(Location2Coordinates[0],wave)]
- if(wave==63):
- spawnloc=GetSpawn[i%15]
- coord=Location2Coordinates[spawnloc]
- MonsterCount[spawnloc]+=1
- drawlist.append((coord,702))
- for j in range(4):
- i+=1
- spawnloc=GetSpawn[i%15]
- coord=Location2Coordinates[spawnloc]
- coord=(coord[0],coord[1]+MonsterCount[spawnloc]*25)
- MonsterCount[spawnloc]+=1
- drawlist.append((coord,108))
- else:
- while(wave>0):
- mob,wave=PrintSpawn(wave)
- spawnloc=GetSpawn[i%15]
- coord=Location2Coordinates[spawnloc]
- coord=(coord[0],coord[1]+MonsterCount[spawnloc]*25)
- MonsterCount[spawnloc]+=1
- drawlist.append((coord,mob))
- i+=1
- return drawlist
- def MapAllWaves(i):
- maplist=[None]*64
- wave=1
- while(wave<64):
- maplist[wave]=GenerateImage(ProcessWave(wave,i))
- i+=1
- wave+=1
- return maplist
- def GetRotation(i):
- spawnloc=[]
- for j in range(5):
- spawnloc.append(GetSpawn[(i+j)%15])
- if(spawnloc[0]==4 and spawnloc[1]==1):
- return "S/NW C/C/%s %s"%(Location2Cardinal[spawnloc[3]],Location2Cardinal[spawnloc[4]])
- else:
- return "%s/%s %s"%(Location2Cardinal[spawnloc[0]],Location2Cardinal[spawnloc[1]],Location2Cardinal[spawnloc[2]])
- def ProcessAllWaves(i):
- maplist=MapAllWaves(i)
- rotation=GetRotation(i)
- MakeSingleMaps(maplist,rotation)
- MakeVertMaps(maplist,rotation)
- def MakeSingleMaps(maplist,rotation):
- if not(os.path.exists("Single/%s"%(rotation))): os.makedirs("Single/%s"%(rotation))
- for j in range(3,64):
- maplist[j].save("Single/%s/%s.png"%(rotation,str(j)))
- def MakeVertMaps(maplist,rotation):
- if not(os.path.exists("Vert/%s"%(rotation))): os.makedirs("Vert/%s"%(rotation))
- for j in range(3,60,2):
- img=Image.new("RGBA",(MapX,MapY*4),(0,0,0,255)) #Make an empty image file of width 1 and height 4
- img.paste(maplist[j],(0,0)) #Paste map image of wave j
- img.paste(maplist[j+1],(0,MapY)) #Paste map image of wave j+1
- img.paste(maplist[j+2],(0,MapY*2)) #Paste map image of wave j+2
- img.paste(maplist[j+3],(0,MapY*3)) #Paste map image of wave j+3
- img.save("Vert/%s/%s.png"%(rotation,str(j))) #Save file under name j.png
- img=Image.new("RGBA",(MapX,MapY*4),(0,0,0,255))
- img.paste(maplist[61],(0,0))
- img.paste(maplist[62],(0,MapY))
- img.paste(maplist[63],(0,MapY*2))
- img.save("Vert/%s/61.png"%(rotation))
- def ProcessAllRotations():
- for i in range(15):
- print(i)
- ProcessAllWaves(i)
- def SampleMap():
- GenerateImage([(Location2Coordinates[0],"Wave"),(Location2Coordinates[1],"NW"),(Location2Coordinates[2],"C"),(Location2Coordinates[3],"SE"),(Location2Coordinates[4],"S"),(Location2Coordinates[5],"SW")]).save("Sample.png")
- return
- SampleMap()
- ProcessAllRotations()
Advertisement
Add Comment
Please, Sign In to add comment