Dr. Robotnik's Simpler AnimaL

[Open Assets] Dr. Robotnik's Simpler AnimaL v1.0.1

What permissions do you give others to modify and/or maintain your submission?
Modify: YES - Maintain: YES - I give permission for my entire submission to be modified by others or used in their own work. I give permission for my entire submission to be maintained by others as well.
Dr. Robotnik's Simpler AnimaL (simpler animation Lua, "Simpler AnimaL" hereafter) is the hit sequel to the animation mod for the kart racing mod for the Sonic the Hedgehog mod of DOOM, designed for the hit sequel to the kart racing mod for the Sonic the Hedgehog mod of DOOM.

Simpler AnimaL is a reusable script made to give everybody easy but powerful control over how characters animate. Use the convenient setup function to initiate a character while declaring custom Sprite2s, then return a Sprite2 name and a list of frames for custom looping logic. It even does hitstun pauses for you!

As part of this release, a Junio Sonic port (using the fantastic spritework by @MotorRoach and co.) is available as a demo character.



Using Simpler AnimaL
Drop the script into your pk3. In a second script (make sure it's lower in your list so that it loads second), use SIMPLER_ANIMAL_SETUP to setup your character name and custom Sprite2s.

Due to Lua limitations, all characters will use their STIN animation on the character select screen. There's nothing I can do about this. Keep this in mind in case you want to use "STIN" as some special character select animation.

Hooking Simpler AnimaL
Every tick, all functions that exist as children of the global variable SIMPLER_ANIMAL_HOOKS will be run. If every Hook returns nil, then Ring Racers's default animation behaviors will occur. However, if you return a correctly-formatted set of arguments, characters using Simpler AnimaL will select that as their next animation Sequence. The format for return values is as follows:
  1. sprite2: A string corresponding to a four-character sprite2 name.
  2. expected_start: A number/frame value corresponding to the first frame of the new animation.
  3. expected_loop: A number/frame value corresponding to the desired loop point to return to when the animation is finished.
  4. expected_end: A number/frame value corresponding to when the animation should return to the loop point. If expected_start is greater than expected_end, the animation will play in reverse.
To provide an example of this:
Hook that makes Junio Sonic do various extra animations:
function SIMPLER_ANIMAL_HOOKS.junio_sonic_hook(mobj)
  if helpers.getSkin(mobj) == "juniosonic"
    local player = helpers.getPlayer(mobj)
 
    for i = 0,108 do
      S_StopSoundByID(mobj, sfx_krta00 + i) -- Stop engine sounds.
    end
 
    if mobj.sprite2 == SPR2_GOAL then return
    elseif (mobj.sprite2 == SPR2_SPIN or mobj.sprite2 == SPR2_DEAD) then return
    elseif player.spindash then return "SPDA", A, A, C -- Spindash, start at A, loop back to A after C.
    elseif player.rideroid then return "RIDE", A, A, A
    elseif player.pullup then return "RIDE", A, A, A
    elseif player.dlzrocket then return "DASH", A, A, B
    elseif player.whip then
      helpers.SquaredSlow(mobj, -1) -- Slow this animation according to player speed.
      return "ROLL", A, A, D
    elseif player.respawn.timer or helpers.isTricking(mobj) or player.fastfall then
      helpers.SquaredSlow(mobj, -1)
      return "ROLL", A, A, D
    elseif helpers.isAirborne(mobj)
      helpers.SquaredSlow(mobj, -1)
      if abs(mobj.momz) <= FRACUNIT then return "ROLL", A, A, D -- Roll to transition between air states, it's cute.
      elseif helpers.isAscending(mobj) then return "SPNG", A, A, A
      else return "FALL", A, A, B end
    elseif mobj.sprite2 == SPR2_SLWN
      if helpers.isMovingForward(mobj) then
        helpers.SquaredSlow(mobj, -1)
        return "SLWN", A, A, H
      else -- Moving sideways/backwards.
        if (player.cmd.buttons & BT_ACCELERATE) and abs(player.speed) > FRACUNIT
          helpers.SquaredSlow(mobj, -1)
          return "EDGE", A, A, B
        else
          helpers.SquaredSlow(mobj, 1)
          return "SLWN", H, H, A
        end
      end
    elseif mobj.sprite2 == SPR2_DRLN or mobj.sprite2 == SPR2_DRRN -- Slowable drift.
      helpers.SquaredSlow(mobj, -1)
      return "DRLN", A, A, C
    elseif player.laps == 0 and mobj.state == S_KART_STILL
      helpers.SquaredSlow(mobj, -1)
      return "WAIT", A, A, B
    end
  end
end

Starting from the highest priority animation and moving down...
  • Immediately end processing if the object is not Junio Sonic, or if using certain animations.
  • Stop engine sounds and continue processing.
  • Use a custom Spindash animation.
  • Use a custom riding animation for certain course gimmicks. (As of DRRR v2.3, one of these values is not exposed to Lua.)
  • Use a custom insta-whip animation. (As of DRRR v2.3, this value is not exposed to Lua.)
  • Use a custom animation for riding a lightsnake, tricking, or fastfalling.
  • Use a custom animation if the object is airborne depending on their vertical speed, slow it down depending on their horizontal speed.
  • If using a Slow animation, slow down the frame timing depending on horizontal speed.
  • If moving sideways/backwards while accelerating, do a custom animation. If not accelerating, do the normal animation but backwards.
  • If drifting, slow down the frame timing depending on horizontal speed.
  • If standing still in Position or on Lap 0, do a waiting animation.
Requests and Feedback
Requests to add features for a specific mod will generally be rejected, as the use of the default animation handler means that I don't have to handle the weird edge cases anymore.
If you want to make it easy for Simpler AnimaL editors to trigger animations under specific circumstances, a good way to do this is to document variables that character creators can check in order to activate their animations.

Global Variables
SIMPLER_ANIMAL_VERSION: An integer corresponding to Simpler AnimaL's version number.
SIMPLER_ANIMAL_SETUP: A function that sets up a character for Simpler AnimaL and freeslots sprite2s.
SIMPLER_ANIMAL_THINKER: The function used to assign a sprite2 and looping rules to a Simpler AnimaL.
SIMPLER_ANIMAL_DEFINITIONS: A table containing every Simpler AnimaL character name.
  • SIMPLER_ANIMAL_DEFINITIONS["sonic"]: Sonic's Simpler AnimaL definition. This counts as true when Sonic has been set up for Simpler AnimaL.
SIMPLER_ANIMAL_HELPERS: A table containing every Simpler AnimaL helper function.
SIMPLER_ANIMAL_HOOKS: A table containing every Simpler AnimaL hook.

Mobj/Player Properties
mobj.Simpler_AnimaL: A table containing information about the mobj's animation status.
  • mobj.Simpler_AnimaL.timer: A timer relative to the current animation's length.
  • mobj.Simpler_AnimaL.total_timer: A timer that increments forever and resets to 0 on animation change.
  • mobj.Simpler_AnimaL.last_hook: A key corresponding to the hook that decided your last animation. "simpler_animal_hitstun_interrupt" and "simpler_animal_death_interrupt" exist as default values.
  • mobj.Simpler_AnimaL.last_sequence: A string corresponding to the last sprite2 used.
  • mobj.Simpler_AnimaL.last_frame: A number corresponding to the last frame used.
Author
Togen
Downloads
561
Views
2,731
First release
Last update
Rating
5.00 star(s) 1 ratings

More resources from Togen

Share this resource

Latest updates

  1. Going Local

    Fixed several instances of implicit global variables (which don't work in this game). Oops.
Back
Top