def get_actions(filename): # get entity actions from wmb file
actions = []
f = open(filename, "rb")
f.seek(4+8+8+8+8+8+8+8+8+8+8+8+8+8+8+8)
offset, length = struct.unpack("ll", f.read(8))
f.seek(offset) # jump to object list
object_offsets = []
for i in range(struct.unpack("l", f.read(4))[0]):
object_offsets.append(struct.unpack("l", f.read(4))[0])
for o in object_offsets:
f.seek(offset + o)
type = struct.unpack("l", f.read(4))[0]
if type == 7 or type == 3: # entity
f.seek(offset + o + 4 + 4*3*3)
# strings don't always seem to start at the same position!? -> regular expression necessary
n = re.split("\x00+", struct.unpack("86s", f.read(86))[0])
if n[2]: # action exists
actions.append((n[0], n[2])) # entity name, action name
f.close()
return actions