Custom move - MarklyThomas/Secret-Repo GitHub Wiki
In this section, I'm gonna guide you on how to add a custom ability to your character. We'll do this by giving them a double jump. The final code will be at the bottom of the page.
Contents
- Change the
push
totrue
- Add the checks for control lock, competition mode, and when going super/hyper
- Add the force that'll make your character go up
- Add a check for when your underwater
- The finished code
push
to true
1. Change the //@ Original function taken from sonic3air_dev/scripts/maingame/character/character.lemon
function void ExtraChar.pressedJumpInMidAir_charX()
{
- push(false)
+ push(true) // Change this to 'false' to do one of the base game characters actions
return
}
This makes it so that the ES character doesn't use any of the base game character's moves
2. Add the checks for control lock, competition mode, and when going super/hyper
//@ Original function taken from sonic3air_dev/scripts/maingame/character/character.lemon
function void ExtraChar.pressedJumpInMidAir_charX()
{
+ char.flags &= ~char.flag.CONTROL_LOCK // Removes control lock after rolling then jumping
+#if STANDALONE
+ // Blocks the ability from being used in competition mode
+ if (competition_mode.active)
+ return
+#else
+ if (Character.performSuperTransformation()) // Here so that your character can still go super
+ return
+#endif
+
push(true) // Change this to 'false' to do one of the base game characters actions
return
}
3. Add the force that'll make your character go up
//@ Original function taken from sonic3air_dev/scripts/maingame/character/character.lemon
function void ExtraChar.pressedJumpInMidAir_charX()
{
char.flags &= ~char.flag.CONTROL_LOCK // Remove control lock
#if STANDALONE
// Blocks the ability from being used in competition mode
if (competition_mode.active)
return
#else
if (Character.performSuperTransformation()) // Here so that your character can still go super
return
#endif
+ char.double_jump_state = 1 // Prevents the move from being spamable
+
+ playSound(SFX_JUMP) // Plays the jump sound
+
+ if (super.active)
+ char.velocity.y = -0x680 // Slightly increasing double jump height for Super
+ else
+ char.velocity.y = -0x580
+
+ char.jumping = 0 // Clear this flag to prevent the move from being spamable
push(true) // Change this to 'false' to do one of the base game characters actions
return
}
If you want to have some difference from Super and Hyper forms, you'd do super.active == 1
for Super forms and super.active == 0xff
for Hyper forms. super.active
means the changes for the super form will apply no mater the form. Tails works similarly, but you'd use super.active.tails
instead
4. Add a check for when your underwater
//@ Original function taken from sonic3air_dev/scripts/maingame/character/character.lemon
function void ExtraChar.pressedJumpInMidAir_charX()
{
char.flags &= ~char.flag.CONTROL_LOCK // Remove control lock
#if STANDALONE
// Blocks the ability from being used in competition mode
if (competition_mode.active)
return
#else
if (Character.performSuperTransformation()) // Here so that your character can still go super
return
#endif
char.double_jump_state = 1 // Prevents the move from being spamable
playSound(SFX_JUMP) // Plays the jump sound
if (super.active)
char.velocity.y = -0x680 // Slightly increasing double jump height for Super
else
char.velocity.y = -0x580
+ // Abilities will sometimes need to be nerfed when underwater
+ if (char.flags & char.flag.UNDERWATER)
+ char.velocity.y = char.velocity.y / 2
char.jumping = 0 // Clear this flag to prevent the move from being spamable
push(true) // Change this to 'false' to do one of the base game characters actions
return
}
5. The completed code
//@ Original function taken from sonic3air_dev/scripts/maingame/character/character.lemon
function void ExtraChar.pressedJumpInMidAir_charX()
{
char.flags &= ~char.flag.CONTROL_LOCK // Remove control lock
#if STANDALONE
// Blocks the ability from being used in competition mode
if (competition_mode.active)
return
#else
if (Character.performSuperTransformation()) // Here so that your character can still go super
return
#endif
char.double_jump_state = 1 // Prevents the move from being spamable
playSound(SFX_JUMP) // Plays the jump sound
if (super.active)
char.velocity.y = -0x680 // Slightly increasing double jump height for Super
else
char.velocity.y = -0x580
// Abilities will sometimes need to be nerfed when underwater
if (char.flags & char.flag.UNDERWATER)
char.velocity.y = char.velocity.y / 2
char.jumping = 0 // Clear this flag to prevent the move from being spamable
push(true) // Change this to 'false' to do one of the base game characters actions
return
}