Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # python blahhhhhhThings.py myHouse.wad
- import sys
- import numpy as np
- def nullPad(string,length=8):
- return string+chr(0)*(length-len(string))
- M_NAMES = [nullPad('MAP'+'0'*(n<10)+str(n)) for n in xrange(100)]
- def readThingsLumps(inWad):
- f = open(inWad,'rb')
- [pwad,nLmp,dirP] = np.fromfile(f,'<i4',3)
- f.seek(dirP)
- lmpDir = []
- allData = []
- for n in range(nLmp):
- [lmpP,lmpS] = np.fromfile(f,'<i4',2)
- name = f.read(8)
- lmpDir.append([name,lmpP,lmpS])
- outDict = {}
- for n in lmpDir:
- if n[0] in M_NAMES:
- currentMap = n[0][:5]
- if n[0] == nullPad('THINGS'):
- f.seek(n[1])
- outDict[currentMap] = f.read(n[2])
- f.close()
- return outDict
- ARTIFACTS = {2023: 'Berserk', 2026: 'Computer Map', 2014: 'Health Bonus',
- 2024: 'Invisibility', 2022: 'Invulnerability', 2045: 'Light Visor',
- 83: 'Megasphere', 2013: 'Soul Sphere', 2015: 'Armor Bonus'}
- POWERUPS = {8: 'Backpack', 2019: 'Blue Armor', 2018: 'Green Armor',
- 2012: 'Medikit', 2025: 'Rad Suit', 2011: 'Stimpack'}
- WEAPONS = {2006: 'BFG 9000', 2002: 'Chaingun', 2005: 'Chainsaw',
- 2004: 'Plasma Gun', 2003: 'Rocket Launcher', 2001: 'Shotgun',
- 82: 'Super Shotgun'}
- AMMUNITION = {2007: 'Ammo Clip', 2048: 'Box of Ammo', 2046: 'Box of Rockets',
- 2049: 'Box of Shells', 2047: 'Cell Charge', 17: 'Cell Charge Pack',
- 2010: 'Rocket', 2008: 'Shotgun Shells'}
- MONSTERS = {68: 'Arachnotron', 64: 'Arch-Vile', 3003: 'Baron of Hell',
- 3005: 'Cacodemon', 65: 'Chaingunner', 72: 'Commander Keen',
- 16: 'Cyberdemon', 3002: 'Demon', 3004: 'Zombieman',
- 9: 'Sergeant', 69: 'Hell Knight', 3001: 'Imp',
- 3006: 'Lost Soul', 67: 'Mancubus', 71: 'Pain Elemental',
- 66: 'Revenant', 58: 'Spectre', 7: 'Spiderdemon',
- 84: 'Wolfenstein SS'}
- def main():
- things = readThingsLumps(sys.argv[1])
- for k in sorted(things.keys()):
- print '\n'+'*'*19+'\n'+'***** '+k+' *****\n'+'*'*19+'\n'
- countDict = {'Skill 1&2': {}, 'Skill 3':{}, 'Skill 4&5':{}}
- for i in xrange(0,len(things[k]),10):
- tid = np.fromstring(things[k][i+6:i+8],'<i2')[0]
- dif = np.fromstring(things[k][i+8:i+10],'<i2')[0]
- skillList = ('Skill 1&2'*bool(dif&1)+'/Skill 3'*bool(dif&2)+'/Skill 4&5'*bool(dif&4)).split('/')
- if len(skillList) and not dif&16:
- for skl in [s for s in skillList if len(s)]:
- if tid not in countDict[skl]: countDict[skl][tid] = 0
- countDict[skl][tid] += 1
- for k1 in sorted(countDict.keys()):
- print k1+':'
- print '\tArtifacts:'
- for k2 in ARTIFACTS.keys():
- if k2 in countDict[k1]:
- print '\t\t'+str(countDict[k1][k2])+'\t'+ARTIFACTS[k2]
- print '\tPowerups:'
- for k2 in POWERUPS.keys():
- if k2 in countDict[k1]:
- print '\t\t'+str(countDict[k1][k2])+'\t'+POWERUPS[k2]
- print '\tWeapons:'
- for k2 in WEAPONS.keys():
- if k2 in countDict[k1]:
- print '\t\t'+str(countDict[k1][k2])+'\t'+WEAPONS[k2]
- print '\tAmmunition:'
- for k2 in AMMUNITION.keys():
- if k2 in countDict[k1]:
- print '\t\t'+str(countDict[k1][k2])+'\t'+AMMUNITION[k2]
- print '\tMonsters:'
- for k2 in MONSTERS.keys():
- if k2 in countDict[k1]:
- print '\t\t'+str(countDict[k1][k2])+'\t'+MONSTERS[k2]
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement