Advertisement
Guest User

Untitled

a guest
Oct 26th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. # python blahhhhhhThings.py myHouse.wad
  2.  
  3. import sys
  4. import numpy as np
  5.  
  6. def nullPad(string,length=8):
  7. return string+chr(0)*(length-len(string))
  8.  
  9. M_NAMES = [nullPad('MAP'+'0'*(n<10)+str(n)) for n in xrange(100)] + [nullPad('E'+str(n)[0]+'M'+str(n)[1]) for n in xrange(11,100)]
  10.  
  11. def readThingsLumps(inWad):
  12. f = open(inWad,'rb')
  13. [pwad,nLmp,dirP] = np.fromfile(f,'<i4',3)
  14. f.seek(dirP)
  15. lmpDir = []
  16. allData = []
  17. for n in range(nLmp):
  18. [lmpP,lmpS] = np.fromfile(f,'<i4',2)
  19. name = f.read(8)
  20. lmpDir.append([name,lmpP,lmpS])
  21. outDict = {}
  22. for n in lmpDir:
  23. if n[0] in M_NAMES:
  24. currentMap = n[0][:5]
  25. if n[0] == nullPad('THINGS'):
  26. f.seek(n[1])
  27. outDict[currentMap] = f.read(n[2])
  28. f.close()
  29. return outDict
  30.  
  31. ARTIFACTS = {2023: 'Berserk', 2026: 'Computer Map', 2014: 'Health Bonus',
  32. 2024: 'Invisibility', 2022: 'Invulnerability', 2045: 'Light Visor',
  33. 83: 'Megasphere', 2013: 'Soul Sphere', 2015: 'Armor Bonus'}
  34. POWERUPS = {8: 'Backpack', 2019: 'Blue Armor', 2018: 'Green Armor',
  35. 2012: 'Medikit', 2025: 'Rad Suit', 2011: 'Stimpack'}
  36. WEAPONS = {2006: 'BFG 9000', 2002: 'Chaingun', 2005: 'Chainsaw',
  37. 2004: 'Plasma Gun', 2003: 'Rocket Launcher', 2001: 'Shotgun',
  38. 82: 'Super Shotgun'}
  39. AMMUNITION = {2007: 'Ammo Clip', 2048: 'Box of Ammo', 2046: 'Box of Rockets',
  40. 2049: 'Box of Shells', 2047: 'Cell Charge', 17: 'Cell Charge Pack',
  41. 2010: 'Rocket', 2008: 'Shotgun Shells'}
  42. MONSTERS = {68: 'Arachnotron', 64: 'Arch-Vile', 3003: 'Baron of Hell',
  43. 3005: 'Cacodemon', 65: 'Chaingunner', 72: 'Commander Keen',
  44. 16: 'Cyberdemon', 3002: 'Demon', 3004: 'Zombieman',
  45. 9: 'Sergeant', 69: 'Hell Knight', 3001: 'Imp',
  46. 3006: 'Lost Soul', 67: 'Mancubus', 71: 'Pain Elemental',
  47. 66: 'Revenant', 58: 'Spectre', 7: 'Spiderdemon',
  48. 84: 'Wolfenstein SS', 88: 'Boss Brain', 89: 'Spawn Shooter'}
  49. KEYS = {5: 'Blue Keycard', 40: 'Blue Skull Key', 13: 'Red Keycard',
  50. 38: 'Red Skull Key', 6: 'Yellow Keycard', 39: 'Yellow Skull Key'}
  51. OBSTACLES = {2035: 'Barrel'}
  52.  
  53. def main():
  54. things = readThingsLumps(sys.argv[1])
  55. for k in sorted(things.keys()):
  56. print '\n'+'*'*19+'\n'+'***** '+k+' *****\n'+'*'*19+'\n'
  57. countDict = {'Skill 1&2': {}, 'Skill 3':{}, 'Skill 4&5':{}}
  58. for i in xrange(0,len(things[k]),10):
  59. tid = np.fromstring(things[k][i+6:i+8],'<i2')[0]
  60. dif = np.fromstring(things[k][i+8:i+10],'<i2')[0]
  61. skillList = ('Skill 1&2'*bool(dif&1)+'/Skill 3'*bool(dif&2)+'/Skill 4&5'*bool(dif&4)).split('/')
  62. if len(skillList) and not dif&16:
  63. for skl in [s for s in skillList if len(s)]:
  64. if tid not in countDict[skl]: countDict[skl][tid] = 0
  65. countDict[skl][tid] += 1
  66. for k1 in sorted(countDict.keys()):
  67. print '\n'+k1+':\n'
  68. print '\tArtifacts:'
  69. for k2 in ARTIFACTS.keys():
  70. if k2 in countDict[k1]:
  71. print '\t\t'+str(countDict[k1][k2])+'\t'+ARTIFACTS[k2]
  72. print '\tPowerups:'
  73. for k2 in POWERUPS.keys():
  74. if k2 in countDict[k1]:
  75. print '\t\t'+str(countDict[k1][k2])+'\t'+POWERUPS[k2]
  76. print '\tWeapons:'
  77. for k2 in WEAPONS.keys():
  78. if k2 in countDict[k1]:
  79. print '\t\t'+str(countDict[k1][k2])+'\t'+WEAPONS[k2]
  80. print '\tAmmunition:'
  81. for k2 in AMMUNITION.keys():
  82. if k2 in countDict[k1]:
  83. print '\t\t'+str(countDict[k1][k2])+'\t'+AMMUNITION[k2]
  84. print '\tMonsters:'
  85. for k2 in MONSTERS.keys():
  86. if k2 in countDict[k1]:
  87. print '\t\t'+str(countDict[k1][k2])+'\t'+MONSTERS[k2]
  88. print '\tKeys:'
  89. for k2 in KEYS.keys():
  90. if k2 in countDict[k1]:
  91. print '\t\t'+str(countDict[k1][k2])+'\t'+KEYS[k2]
  92. print '\tObstacles:'
  93. for k2 in OBSTACLES.keys():
  94. if k2 in countDict[k1]:
  95. print '\t\t'+str(countDict[k1][k2])+'\t'+OBSTACLES[k2]
  96.  
  97. if __name__ == '__main__':
  98. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement