Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NOTE: i'm not responsible for any emotional or psychological
- #damage that might be caused by the code structure below. you have been warned.
- #update 1.0.1 - fixed jacket and biker being their cars and vice versa
- vehicleIDs = [236, #ObjFansVan editor ID is 1582
- 764, #objCopCar
- 1049, #objTaxi
- 1341, #objMilitaryJeepUSA
- 1366, #objSonCar
- 2040, #objRatBusStop
- 870, #objCobraCar
- 2349, #objPigCart
- 1147, #objHenchmanCar
- 2394, #objHammerCar
- 2345, #objJacketCar
- 2347] #objBikerBike
- playerCharacterIDs = [185, #ObjPlayerZebra editor ID is 1583
- 169, #ObjPlayerTiger
- 859, #ObjPlayerBear
- 1051, #objPlayerSwanChainsaw
- 763, #ObjCop
- 1048, #objWriter
- 324, #objNicke
- 1347, #objSon
- 1225, #objRat
- 866, #objPlayerCobra
- 35, #objPigButcher
- 1067, #objPlayerHenchman
- 2387, #objTheHammer
- 2335, #objJacket
- 2334] #objBiker
- enemyIDs = [1064, #objDogPatrol editor ID is 10
- 170, #objEGangMeleeRandom
- 183, #objEGangRandom
- 184, #objEGangPatrol
- 186, #objEGangStatic
- 229, #objEGangIdlePipe
- 230, #objEGangIdleKnife
- 231, #objEGangIdleSmoke
- 941, #objEGangMeleePatrol
- 1144, #objEGangIdleMoney
- 1289, #objEGangFat
- 2286, #objGangDodger
- 875, #objEMafiaMeleeRandom
- 876, #objEMafiaRandom
- 877, #objEMafiaStatic
- 878, #objEMafiaPatrol
- 916, #objEMafiaIdlePhoneSilencer
- 938, #objEMafiaMeleePatrol
- 1464, #objEMafiaFat
- 2407, #objEMafiaIdleSmoke
- 2408, #objEMafiaIdlePipe
- 1354, #objColombianMeleeRandom
- 1355, #objColombianMeleePatrol
- 1356, #objColombianRandom
- 1357, #objColombianStatic
- 1358, #objColombianPatrol
- 1359, #objColombianIdlePipe
- 1737, #objColombianHiding
- 1886, #objColombianDodger
- 931, #objEPoliceMeleeRandom
- 932, #objEPoliceRandom
- 933, #objEPolicePatrol
- 934, #objEPoliceStatic
- 937, #objFatPolice
- 939, #objEPoliceMeleePatrol
- 2409, #objPoliceIdleTalk
- 1530, #objGuardMeleeRandom
- 1531, #objGuardMeleePatrol
- 1532, #objGuardRandom
- 1533, #objGuardStatic
- 1534, #objGuardPatrol
- 2168, #objGuardIdleStick
- 672, #objSoldierMeleeRandom
- 674, #objSoldierRandom
- 696, #objSoldierPatrol
- 697, #objSoldierStatic
- 698, #objSoldierFatKnife
- 704, #objSoldierFatGun
- 706, #objSoldierIdlePonchoSmoke
- 707, #objPoncho
- 708, #objSoldierIdleRain
- 1460, #objSoldierHiding
- 2396, #objSoldierMeleePatrol
- 2109, #objPrisonerMeleeRandom
- 2110, #objPrisonerMeleePatrol
- 2111, #objPrisonerRandom
- 2112, #objPrisonerStatic
- 2113, #objPrisonerPatrol
- 2145, #objPrisonerPsycho
- 2146, #objPrisonerMeleeStatic
- 2148, #objPrisonerFat
- 2167] #objPrisonerIdleGuns
- weaponIDs = [179, #obj9mm
- 880, #objSilencer
- 1352, #objMagnum
- 178, #objUzi
- 2343, #objSilencedUzi
- 1348, #objFamae
- 1349, #objMendoza
- 724, #objM16
- 723, #objKalashnikov
- 177, #objShotgun
- 150, #objDoubleBarrel
- 180, #objNailGun
- 910, #objBottle
- 2261, #objAcid
- 940, #objTaser
- 173, #objKnife
- 175, #objButterfly
- 936, #objStick
- 2337, #objDrill
- 83, #objBat
- 176, #objPipe
- 881, #objClub
- 1368, #objSword
- 741, #objMachete
- 1818, #objAxe
- 1351, #objSkateboard
- 174, #objChain
- 2338, #objPotFull
- 2339, #objPotEmpty
- 144, #objHammer
- 100, #objShotgunWall
- 720, #objHeavy
- 721, #objFlameThrower
- 722, #objSniperRifle
- 882, #objMP5
- 1055, #objChainsaw
- 1227, #objDiscardedGun
- 1228, #objGunClip
- 1350, #objShardBlade
- 2105, #objPipeBig
- 2106, #objBrush
- 2292, #objNickeKnife
- 2293, #objBottleBroken
- 2346] #objCleaver
- doorIDs = [25, #objEditorDoorV
- 26, #objEditorDoorH
- 2254, #objEditorDoorH2
- 2255] #objEditorDoorV2
- wallIDs = [7, #objEditorWallH #white walls
- 8, #objEditorWallV
- 31, #objEditorBrickWallV #red walls
- 32, #objEditorBrickWallH
- 33, #objEditorSoftWallV #soft walls
- 34, #objEditorSoftWallH
- 1271, #objSewerWallV #sewer green walls
- 1272, #objSewerWallH
- 101, #objEditorPorchWallV #sickly green walls
- 102, #objEditorPorchWallH
- 675, #objWoodWallV #brown wood walls
- 677, #objWoodWallH
- 682, #objWoodWindowV #normal windows, idk why wood in name
- 683, #objWoodWindowH
- 2413, #objEditorRailsLeft #brown wooden rails
- 56, #objEditorRailsUp
- 55, #objEditorRailsDown
- 54, #objEditorRailsRight
- 53, #sprEditorRailsLeft #actually unused in the editor? look at 1st rails
- 1511, #objRenovationWallH #shoot through "walls"
- 1512, #objRenovationWallV
- 1724, #objSubwayWallV #yellow black "danger" walls
- 986, #objSubwayWallH
- 1725, #objBoatRailingH #dead ahead
- 1726, #objBoatRailingV
- 1259, #objBalconyRailsH #idk, used in the henchman bar map
- 1260, #objBalconyRailsV
- 676, #objWoodWallInteriorV #wooden walls but sickly yellow
- 678, #objWoodWallInteriorH
- 987, #objSubwayWindowH #no V version
- 950, #objBarsH #prison bars
- 951] #objBarsV
- screenTransitionID = 124 #editor ID is 2297
- elevatorID = 810 #editor ID is 2410
- barrierID = 2411 #same in editor
- entryIDs = [302,303] #editor ID is 2412
- darknessID = 1417 #same in editor
- rainID = 663 #same in editor
- lightOverlayID = 1770 #same in editor
- weaponID = 2401
- def generic_object_conversion(lines):
- global lc
- lc+=6 #a generic object in .play is 6 lines, so move 6 lines ahead in the read
- objID = int(lines[0][:-1]) #grab 1st line (objectID) for finding editorID (:-1 for removing the \n)
- reorder = [1,2,3,4,0,5] #order of reorder
- lines = [lines[i] for i in reorder] #reordering
- lines.insert(0,"dummy") #adding the editorID
- #print("written "+str(lines)) #debug
- return(lines)
- def wall_conversion(lines): #these "change only 1 line" functions aren't really necessary tbh and only make a mess, but too late lol i already made em
- global lc
- lc+=6 #a wall in .play is 6 lines, so move 6 lines ahead in the read
- lines = lines[:-1] #removing the last (random number) line
- return lines
- def screen_transition_conversion(lines):
- global lc
- lc+=10 #a screen transition in .play is 10 lines, so move 10 lines ahead in the read
- lines[0] = "2297\n" #changing the objectID to editorID
- return lines
- def elevator_conversion(lines):
- global lc
- lc+=7 #an elevator in .play is 7 lines, so move 7 lines ahead in the read
- lines[0] = "2410\n" #changing the objectID to editorID
- return lines
- def entry_conversion(lines): #THIS IS A MESS
- global lc
- lc+=6 #an entry in .play is 6 lines, so move 6 lines ahead in the read
- lines.append("0\n")
- if lines[0] == "302\n": #... it means it's vertical
- if debugFlag: print("inserting vertical 2nd editor id")
- lines.insert(-2, "4356\n")
- if lines[-2] == "-1\n": #... it means it's left
- lines[-2] = "-1\n"
- else: #... it means it's right
- lines[-2] = "1\n"
- lines[-1] = "0\n" #neutralizing horizontal direction line
- else: #... it means it's horizontal
- if debugFlag: print("inserting horizontal 2nd editor id")
- lines.insert(-2, "4355\n")
- if lines[-2] == "-1\n": #... it means it's up
- lines[-1] = "-1\n"
- else: #... it means it's horizontal
- lines[-1] = "1\n"
- lines[-2] = "0\n" #neutralizing vertical direction line
- lines[0] = "2412\n" #finally editing the objectID to editorID
- return lines
- magicNumber = input("gimme - ")
- if ("d") in magicNumber:
- debugFlag = 1
- magicNumber = magicNumber.replace("d","")
- else:
- debugFlag = 0
- if ("e") in magicNumber:
- enemyFlag = 1
- magicNumber = magicNumber.replace("e","")
- else: enemyFlag = 0
- if debugFlag: print("debug flag on, printing debug info")
- readPlay = open("level"+magicNumber+".play","r")
- inputData = readPlay.readlines()
- readPlay.close()
- inputData = inputData[2:] #getting rid of the 0 and -1
- inputData.append("EoF") #end of file marker, hey it works alright?
- output = []
- playerCharactersOutput = []
- vehiclesOutput = []
- enemiesOutput = []
- screenTransitionsOutput = []
- elevatorsOutput = []
- barriersOutput = []
- entriesOutput = []
- doorsOutput = []
- rainOutput = []
- darknessOutput = []
- lightOverlayOutput = []
- weaponsOutput = []
- trueGenericObjectsOutput = []
- wallsOutput = []
- #print(inputData)
- lc = 0 #linecounter
- while inputData[lc] != "EoF":
- if debugFlag: print("current line "+str(int(inputData[lc])))
- if int(inputData[lc]) in playerCharacterIDs: #a player character is a generic object
- package = inputData[lc:lc+6] #a generic object is 6 lines
- if debugFlag: print("initial player character data "+str(package))
- converted = generic_object_conversion(package)
- converted[0] = "1582\n" #player character editor ID
- if debugFlag: print("converted player character data "+str(converted))
- playerCharactersOutput.append(converted)
- elif int(inputData[lc]) in vehicleIDs: #a vehicle is a generic object
- package = inputData[lc:lc+6] #a generic object is 6 lines
- if debugFlag: print("initial vehicle data "+str(package))
- converted = generic_object_conversion(package)
- converted[0] = "1583\n" #vehicle editor ID
- if debugFlag: print("converted vehicle data "+str(converted))
- vehiclesOutput.append(converted)
- elif int(inputData[lc]) in enemyIDs: #an enemy is a generic object
- package = inputData[lc:lc+6] #a generic object is 6 lines
- if debugFlag: print("initial enemy data "+str(package))
- converted = generic_object_conversion(package)
- converted[0] = "10\n" #enemy editor ID
- if enemyFlag:
- converted[0] = "11\n"
- if debugFlag: print("enemy flag on, changing id from 10 to 11")
- if debugFlag: print("converted enemy data "+str(converted))
- enemiesOutput.append(converted)
- elif int(inputData[lc]) == screenTransitionID: #a screen transition is a unique object
- package = inputData[lc:lc+10] #a screen transition is 10 lines
- if debugFlag: print("initial screen transition data "+str(package))
- converted = screen_transition_conversion(package)
- if debugFlag: print("converted screen transition data "+str(converted))
- screenTransitionsOutput.append(converted)
- elif int(inputData[lc]) == elevatorID: #an elevator is a unique object
- package = inputData[lc:lc+7] #an elevator is 7 lines
- if debugFlag: print("initial elevator data "+str(package))
- converted = elevator_conversion(package)
- if debugFlag: print("converted elevator data "+str(converted))
- elevatorsOutput.append(converted)
- elif int(inputData[lc]) == barrierID: #a barrier is a unique object
- package = inputData[lc:lc+5] #a barrier is 5 lines
- lc+=5
- if debugFlag: print("general barrier data "+str(package)) #barrier structure doesn't change from play to obj
- barriersOutput.append(package)
- elif int(inputData[lc]) in entryIDs: #an entry is a unique object
- package = inputData[lc:lc+6] #an entry is 6 lines
- if debugFlag: print("initial entry data "+str(package))
- converted = entry_conversion(package)
- if debugFlag: print("converted entry data "+str(converted))
- entriesOutput.append(converted)
- elif int(inputData[lc]) in doorIDs: #a door is a unique object
- package = inputData[lc:lc+7] #a door is 7 lines
- lc+=7
- if debugFlag: print("general door data "+str(package)) #door structure doesn't change from play to obj
- doorsOutput.append(package)
- elif int(inputData[lc]) == darknessID: #a darkness is a unique object
- package = inputData[lc:lc+5] #a darkness is 5 lines
- lc+=5
- if debugFlag: print("general darkness data "+str(package)) #darkness structure doesn't change from play to obj
- darknessOutput.append(package)
- elif int(inputData[lc]) == rainID: #a rain is a unique object
- rainAmount = int(inputData[lc+1]) #its length depends on its 2nd line
- rainLength = 2 + (4 * rainAmount) #objectID and amount of rain objects + amount*4(4 lines per object)
- package = inputData[lc:lc+rainLength]
- if debugFlag: print("general rain data "+str(package)) #rain structure doesn't change from play to obj
- lc+=rainLength #variable length, look at rainLength
- rainOutput.append(package)
- elif int(inputData[lc]) == lightOverlayID: #a light overlay is a unique object
- package = inputData[lc:lc+2] #a light overlay is 2 lines long
- lc+=2
- if debugFlag: print("general light overlay data "+str(package)) #light overlay structure doesn't change from play to obj
- lightOverlayOutput.append(package)
- elif int(inputData[lc]) in wallIDs: #a wall is a unique object, AND it's stored in .wll, AND Trans Rights btw
- package = inputData[lc:lc+6] #a wall is 6 lines long
- if debugFlag: print("initial wall data "+str(package))
- lc+=6
- package=package[:-1] #cutting off the weird random(?) number
- if debugFlag: print("converted wall data "+str(package)) #except the last line, wall structure doesn't change from play to obj
- wallsOutput.append(package)
- elif int(inputData[lc]) in weaponIDs: #a weapon is a generic object
- package = inputData[lc:lc+6] #a generic object is 6 lines
- if debugFlag: print("initial weapon data "+str(package))
- converted = generic_object_conversion(package)
- converted[0] = "2401\n" #editor weapon ID
- if debugFlag: print("converted weapon data "+str(converted))
- weaponsOutput.append(converted)
- else: #it PROBABLY AND I HOPE TO GOD it means it's a true generic object
- package = inputData[lc:lc+6] #a generic object is 6 lines
- if debugFlag: print("initial true generic object data "+str(package))
- converted = generic_object_conversion(package)
- converted[0] = "11\n" #true generic object ID
- if debugFlag: print("converted true generic object data "+str(converted))
- trueGenericObjectsOutput.append(converted)
- if debugFlag: print("finished making output groups")
- orderedOutputs = [playerCharactersOutput,
- vehiclesOutput,
- enemiesOutput,
- trueGenericObjectsOutput,
- weaponsOutput,
- screenTransitionsOutput,
- elevatorsOutput,
- barriersOutput,
- entriesOutput,
- doorsOutput,
- rainOutput,
- darknessOutput,
- lightOverlayOutput]
- writeObj = open("level"+magicNumber+".obj","w")
- for outputGroup in orderedOutputs:
- for object in outputGroup:
- for line in object:
- writeObj.writelines(line)
- if debugFlag: print("finished writing to .obj")
- writeObj.close()
- writeWll = open("level"+magicNumber+".wll","w")
- for wall in wallsOutput:
- for line in wall:
- writeWll.writelines(line)
- if debugFlag: print("finished writing to .wll")
- writeWll.close()
- print("done")
- input("enter to close program")
- #made by Kataiser17, aka actually Gofer#5776 on Discord
- #it may be a mess but it's mine and it works darnit
- #you're free to edit and share this script in any way you want, just don't take all the credit for it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement