Advertisement
Guest User

Untitled

a guest
Sep 24th, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 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)]
  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'}
  49.  
  50. def main():
  51. things = readThingsLumps(sys.argv[1])
  52. for k in sorted(things.keys()):
  53. print '\n'+'*'*19+'\n'+'***** '+k+' *****\n'+'*'*19+'\n'
  54. countDict = {'Skill 1&2': {}, 'Skill 3':{}, 'Skill 4&5':{}}
  55. for i in xrange(0,len(things[k]),10):
  56. tid = np.fromstring(things[k][i+6:i+8],'<i2')[0]
  57. dif = np.fromstring(things[k][i+8:i+10],'<i2')[0]
  58. skillList = ('Skill 1&2'*bool(dif&1)+'/Skill 3'*bool(dif&2)+'/Skill 4&5'*bool(dif&4)).split('/')
  59. if len(skillList) and not dif&16:
  60. for skl in [s for s in skillList if len(s)]:
  61. if tid not in countDict[skl]: countDict[skl][tid] = 0
  62. countDict[skl][tid] += 1
  63. for k1 in sorted(countDict.keys()):
  64. print k1+':'
  65. print '\tArtifacts:'
  66. for k2 in ARTIFACTS.keys():
  67. if k2 in countDict[k1]:
  68. print '\t\t'+str(countDict[k1][k2])+'\t'+ARTIFACTS[k2]
  69. print '\tPowerups:'
  70. for k2 in POWERUPS.keys():
  71. if k2 in countDict[k1]:
  72. print '\t\t'+str(countDict[k1][k2])+'\t'+POWERUPS[k2]
  73. print '\tWeapons:'
  74. for k2 in WEAPONS.keys():
  75. if k2 in countDict[k1]:
  76. print '\t\t'+str(countDict[k1][k2])+'\t'+WEAPONS[k2]
  77. print '\tAmmunition:'
  78. for k2 in AMMUNITION.keys():
  79. if k2 in countDict[k1]:
  80. print '\t\t'+str(countDict[k1][k2])+'\t'+AMMUNITION[k2]
  81. print '\tMonsters:'
  82. for k2 in MONSTERS.keys():
  83. if k2 in countDict[k1]:
  84. print '\t\t'+str(countDict[k1][k2])+'\t'+MONSTERS[k2]
  85.  
  86. if __name__ == '__main__':
  87. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement