|
|
|
|
|
|
|
|
SGT_FW
by Aku_Aku. 05/31/26 11:05
|
|
|
|
|
XTB
by pr0logic. 05/18/26 12:27
|
|
|
1 registered members (TipmyPip),
3,688
guests, and 3
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Changing Function/Action at runtime?
[Re: DJBMASTER]
#276068
07/03/09 10:34
07/03/09 10:34
|
Joined: May 2002
Posts: 7,441
ventilator
Senior Expert
|
Senior Expert
Joined: May 2002
Posts: 7,441
|
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
and here is my level_load() function:
def level_load(filename, g):
# only keep threads where my isn't set
new = [thread for thread in threads if thread[2] is None]
del threads[:] # delete all elements but keep the original list instance
threads.extend(new)
# load level
_level_load(filename)
# start actions
if filename[-3:].lower() == "wmb":
if not os.path.exists(filename):
for path in e.pPaths: # look for file in all paths that got added with add_folder()
f = os.path.join(path, filename)
if os.path.exists(f):
filename = f
break
actions = get_actions(filename) # get entity actions from wmb file
for action in actions:
entity = ent_for_name(action[0])
entity.eflags &= ~ANIMATE
entity.emask |= DYNAMIC
e.my = entity
eval(action[1] + "()", g)
e.my = None
|
|
|
Re: Changing Function/Action at runtime?
[Re: pegamode]
#276099
07/03/09 11:52
07/03/09 11:52
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
OP
Serious User
|
OP
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
i'm not trying to read out the actions, i want to write them in. I'll try and see what i can do...
Last edited by DJBMASTER; 07/03/09 11:53.
|
|
|
Re: Changing Function/Action at runtime?
[Re: pegamode]
#276117
07/03/09 12:35
07/03/09 12:35
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
OP
Serious User
|
OP
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
Ok, i'm getting somewhere now. I've converted as much as i can to C#, and i can read the name of the entity,filename and action from the .wmb file.
I'm having a little trouble writing names back to the file though.
Last edited by DJBMASTER; 07/04/09 09:07.
|
|
|
|