Replace Jazz's animations

Version:

1.0

Added on:

13 Apr 2015 22:32

Tags:

Description:
Loads a new set of animations from your custom .j2a file and replaces Jazz's animations with them. Works in either 1.23 or 1.24, and people using the opposite version of yours in an online server will still see your animations displayed correctly.
#pragma require "myCustom.j2a"

namespace RABBIT { //save some extra typing
  array<Anim> Anims = { //This should correspond exactly to the order of animations in your .j2a. I'm assuming you're using the same order that TSF does.
    AIRBOARD, AIRBOARDTURN, BUTTSTOMPLAND, CORPSE, DIE, DIVE, DIVEFIREQUIT, DIVEFIRERIGHT, DIVEUP, EARBRACHIATE, ENDOFLEVEL, FALL, FALLBUTTSTOMP, FALLLAND, FIRE, FIREUP, FIREUPQUIT, FROG, HANGFIREQUIT, HANGFIREREST, HANGFIREUP, HANGIDLE1, HANGIDLE2, HANGINGFIREQUIT, HANGINGFIRERIGHT, HELICOPTER, HELICOPTERFIREQUIT, HELICOPTERFIRERIGHT, HPOLE, HURT, IDLE1, IDLE2, IDLE3, IDLE4, IDLE5, JUMPFIREQUIT, JUMPFIRERIGHT, JUMPING1, JUMPING2, JUMPING3, LEDGEWIGGLE, LIFT, LIFTJUMP, LIFTLAND, LOOKUP, LOOPY, PUSH, QUIT, REV1, REV2, REV3, RIGHTFALL, RIGHTJUMP, ROLLING, RUN1, RUN2, RUN3, SKID1, SKID2, SKID3, SPRING, STAND, STATIONARYJUMP, STATIONARYJUMPEND, STATIONARYJUMPSTART, STONED, SWIMDOWN, SWIMRIGHT, SWIMTURN1, SWIMTURN2, SWIMUP, SWINGINGVINE, TELEPORT, TELEPORTFALL, TELEPORTFALLING, TELEPORTFALLTELEPORT, TELEPORTSTAND, VPOLE
  };
}

void onLevelLoad() {
  uint emptyCustomAnimSlot = 0;
  while (jjAnimSets[ANIM::CUSTOM[emptyCustomAnimSlot]].firstAnim != 0) //find an unused slot in ANIM::CUSTOM
    ++emptyCustomAnimSlot;
  jjANIMSET@ emptyCustomAnim = jjAnimSets[ANIM::CUSTOM[emptyCustomAnimSlot]];
  emptyCustomAnim.load(0, "myCustom.j2a"); //adjust as needed for your particular circumstances
  const uint firstCustomCharacterAnimID = emptyCustomAnim.firstAnim;
  
  const uint firstCharAnimID = jjAnimSets[ANIM::JAZZ].firstAnim;
  for (uint i = 0; i < RABBIT::Anims.length; ++i)
    jjAnimations[firstCharAnimID + RABBIT::Anims[i]] = jjAnimations[firstCustomCharacterAnimID + i];

  //If replacing Spaz or Lori instead, you'll need to do some extra work because of ANIM::SPAZ2 and ANIM::LORI2.
  //Also don't forget the lives icon.
}