Extra fields in module_animations.py OR: how to do a Super Mario 64 Long Jump

Users who are viewing this thread

dstemmer

Knight at Arms
Hello,

I just wanted to start a discussion about the 3 "extra" fields in animation sequences of module_animations.py that are not listed in the docstring at the top. If you notice there are 3 fields that are sometimes but not always present.

The first of the 3 "extra" fields is either 0 or defined by a function, "pack2f". Because "pack2f" always occurs with the arf_make_custom_sound or arf_make_walk_sound sequence flags, it seems to be related to sound. The pack2f function, as defined in header_animations.py, pack2f(a, b) just takes a and b, which are both decimal numbers between 0.0 and 1.0, multiplies each by 255 to get a byte value, and generates a number that is 2 bytes long with 'b' as the first half and 'a' as the second.

For example, in the "fall_right_front" animation there is "pack2f(0.47, 0.82)".

a = 119 = binary 01110111 = int(0.47 * 255)
b = 209 = binary 11010001 = int(0.82 * 255)

pack2f = (b << 8 | a) = 53623 = binary 11010001 01110111

Any ideas on how to interpret this?

The second of the 3 "extra" fields is a 3-int tuple. I believe these numbers to be related to the acf_displace_position animation flag - specifically I think it might refer to x, y and z distances to be displaced.

EDIT
: Success! Change the "jump" animation in to this for a Super Mario 64-style long jump:
Code:
["jump", acf_enforce_lowerbody|acf_displace_position,
  [1.09, "jump", 22, 48, arf_blend_in_1, 0, (0, 10, 0), 0],
],
I trust all of you will find much more creative ways to abuse this :wink:

The third of the three "extra" fields is somewhat of a mystery to me. It seems to have to do with cyclic animations. Any info would be appreciated.
 
The pack2f is just a quantization and a pack of two float values.  I originally thought that one was probably volume and the other attenuation but I've since changed my mind.  You'll see pack2f only on walk cycles as you point out (at least, I haven't found any instances that aren't walk cycles).  It's probably an offset in percentage of when to play the sound during that anim loop.  If you look at pack4f, it shows up only on horse walk anims.

You've probably got the right idea on the extra 3-tuple. 

I'm also stumped on the last value.  It shows up for acyclic anims as welll (e.x., all the death animations like "fall_face_hold").  It's probably not a blend value (already got flags for that) and doesn't seem to be associated with sounds.  It's also probably not a speed slider either because we've already got that in frame count and animation duration.  I thought it might be a hint to the ragdoll/IK solver because it seems to be on every single death anim but then I found it on stand_ anims.  Dunno.
 
I had to look up quantization.  :grin: From Wikipedia:

Quantization is the procedure of constraining something from a continuous set of values (such as the real numbers) to a discrete set (such as the integers).

So takes two arbitrary floats from 0.0 to 1.0 and maps it to a number from 0-255 (floats higher than 1.0 map to 255), then packages them together, rightmost members of the tuple first. Same for pack4f except with 4 floats. Right. kt0's description was much more concise.  :smile:

I would really like it if that third value had something to do with ragdolls. If it gave a way to force a ragdoll on any custom animation, that would open up a lot of possibilities. But I just can't tell from the context.
 
I tried your super-jump this morning and this is very cool.  Your info about the 2nd field and how it relates to the acf_displace_position flag is very neat!  I could definitely see some uses for this, since we could now bind some hot keys to super jump, maybe a side-step, roll, jump backwards, etc.....  Very interesting!
 
I like this too, perfect for my moon mod, though i still have 2 problems. Jumping while mounted is completely ok, but jumping on foot, makes only the camera jump, while the character falls under the map, and then instantly teleports to where the camera fell.
And is there any way to make jumping and falling slower?
 
I exploited this to the max and made vehicles fly! It's a little buggy, as you must keep pressing the jump key from time to time to avoid falling, and you need to spam the direction keys to keep moving, cause i didn't try making it loop yet. I'll make that tomorrow.
 
hmm, interesting, can you explain this more and what happens with the camera during this?  I added a 'force jump' in my mod, but the camera just warps to the spot after the animation is over...  maybe we need to have is have a toggle, so you press F to enable flying, and then when flying is on and you press the W, A, S, or D keys it calls anim_fly_forward, anim_fly_left, etc....  so we'd have different animations for each direction or something?
 
Well, how do i code this toggle thing, i still need to work on it a little, you move like a helicopter and you can't turn. And it only worked well when i replaced the horse move animations,  but now that i use unused ones, it makes the player act as a horse which looks really weird. How do i assign a variable to the player's horse?

Edit: Nevermind that, i figured it out, it's still buggy as hell, but if you want to try it here's the codes.

module_animations.py
Code:
["fly_forward", acf_enforce_lowerbody|acf_displace_position,
   [0.1, "anim_horse", 205, 222,  arf_blend_in_4, 0, (0, 4, 2), 0], #|arf_end_pos_0_25],
 ],
 ["fly_left", acf_enforce_lowerbody|acf_displace_position,
   [0.1, "anim_horse", 205, 222,  arf_blend_in_4, 0, (-4, 0, 2), 0], #|arf_end_pos_0_25],
 ],
 ["fly_right", acf_enforce_lowerbody|acf_displace_position,
   [0.1, "anim_horse", 205, 222,  arf_blend_in_4, 0, (4, 0, 2), 0], #|arf_end_pos_0_25],
 ],
 ["fly_up", acf_enforce_lowerbody|acf_displace_position,
   [0.1, "anim_horse", 205, 222,  arf_blend_in_4, 0, (0, 0, 4), 0], #|arf_end_pos_0_25],
 ],
 ["fly_down", acf_enforce_lowerbody|acf_displace_position,
   [0.1, "anim_horse", 205, 222,  arf_blend_in_4, 0, (0, 0, -4), 0], #|arf_end_pos_0_25],
 ],
 ["fly_backward", acf_enforce_lowerbody|acf_displace_position,
   [0.1, "anim_horse", 205, 222,  arf_blend_in_4, 0, (0, -4, 2), 0], #|arf_end_pos_0_25],
 ],

module_mission_templates.py
Code:
#TLW - Flymode Start#################
common_fly_forward = (
  0, 0, 0, [(key_clicked, key_numpad_8),],
 [
  (get_player_agent_no,":player_agent"),
  (try_for_agents, ":cur_agent"),
            (agent_is_alive, ":cur_agent"),   
            (neg|agent_is_human,":cur_agent"),   
            (agent_get_rider,":cur_rider", ":cur_agent"),
            (eq, ":cur_rider", ":player_agent"),  
            (agent_set_animation, ":cur_agent", "anim_fly_forward"),   
         (try_end),
  ])

common_fly_backward = (
  0, 0, 0, [(key_clicked, key_numpad_5),],
 [
  (get_player_agent_no,":player_agent"),
  (try_for_agents, ":cur_agent"),
            (agent_is_alive, ":cur_agent"),  
            (neg|agent_is_human,":cur_agent"),  
            (agent_get_rider,":cur_rider", ":cur_agent"),
            (eq, ":cur_rider", ":player_agent"),   
            (agent_set_animation, ":cur_agent", "anim_fly_backward"),  
         (try_end),
  ])

common_fly_left = (
  0, 0, 0, [(key_clicked, key_numpad_4),],
 [
  (get_player_agent_no,":player_agent"),
  (try_for_agents, ":cur_agent"),
            (agent_is_alive, ":cur_agent"),  
            (neg|agent_is_human,":cur_agent"), 
            (agent_get_rider,":cur_rider", ":cur_agent"),
            (eq, ":cur_rider", ":player_agent"),  
            (agent_set_animation, ":cur_agent", "anim_fly_left"),  
         (try_end),
  ])

common_fly_right = (
  0, 0, 0, [(key_clicked, key_numpad_6),],
 [
  (get_player_agent_no,":player_agent"),
  (try_for_agents, ":cur_agent"),
            (agent_is_alive, ":cur_agent"),   
            (neg|agent_is_human,":cur_agent"), 
            (agent_get_rider,":cur_rider", ":cur_agent"),
            (eq, ":cur_rider", ":player_agent"),   
            (agent_set_animation, ":cur_agent", "anim_fly_right"),   
         (try_end),
  ])

common_fly_up = (
  0, 0, 0, [(key_clicked, key_numpad_7),],
 [
  (get_player_agent_no,":player_agent"),
  (try_for_agents, ":cur_agent"),
            (agent_is_alive, ":cur_agent"),  
            (neg|agent_is_human,":cur_agent"),
            (agent_get_rider,":cur_rider", ":cur_agent"),
            (eq, ":cur_rider", ":player_agent"), 
            (agent_set_animation, ":cur_agent", "anim_fly_up"),  
         (try_end),
  ])

common_fly_down = (
  0, 0, 0, [(key_clicked, key_numpad_9),],
 [
  (get_player_agent_no,":player_agent"),
  (try_for_agents, ":cur_agent"),
            (agent_is_alive, ":cur_agent"),   
            (neg|agent_is_human,":cur_agent"), 
            (agent_get_rider,":cur_rider", ":cur_agent"),
            (eq, ":cur_rider", ":player_agent"),  
            (agent_set_animation, ":cur_agent", "anim_fly_down"),   
         (try_end),
  ])

#TLW - Flymode End#########################
 
Back
Top Bottom