Competition mode - MarklyThomas/Secret-Repo GitHub Wiki
By default, extra characters are not available for selection in Competition mode, so you need to manually enable it. |
---|
To enable your character for selection in Competition mode, use the bool ExtraChar.CompetitionMode.isCharacterAvailable(u8 xtrachar)
function.
Return true
to check with your character’s ID to enable it for the Competition mode.
// Sets the availability status of the character for selection in the Competition menu.
function bool ExtraChar.CompetitionMode.isCharacterAvailable(u8 xtrachar)
{
// Character check
if (xtrachar == 0x0X)
return true
// Call the base function
return base.ExtraChar.CompetitionMode.isCharacterAvailable(xtrachar)
}
To set up custom physics for your character, use the void ExtraChar.CompetitionMode.Character.setupPhysics(u8 xtrachar, u16 speedcap, u16 acceleration, u16 deceleration)
function.
// Sets physics in Competition mode for Extra characters.
function void ExtraChar.CompetitionMode.Character.setupPhysics(u8 xtrachar, u16 speedcap, u16 acceleration, u16 deceleration)
{
// Character's physics
if (xtrachar == 0x0X)
{
speedcap = 0x04c0
acceleration = 0x001c
deceleration = 0x0070
}
// Call the base function
base.ExtraChar.CompetitionMode.Character.setupPhysics(xtrachar, speedcap, acceleration, deceleration)
}
// Sets physics in Competition mode for Extra characters.
function void ExtraChar.CompetitionMode.Character.setupPhysics(u8 xtrachar, u16 speedcap, u16 acceleration, u16 deceleration)
{
// Call the base function
base.ExtraChar.CompetitionMode.Character.setupPhysics(xtrachar, speedcap, acceleration, deceleration)
}
Add this function to your mod with a call to the base function. Then add a check of the variable xtrachar
equal to the ID of your character. No additional checks are required here, such as which player A
or B
chose an extra character, the framework has already taken care of this.
Also, never return. You only change the values, below, additional calculations occur in the called base function. When you return, your physics will be broken.
Next, let’s analyze variables such as speedcap
, acceleration
, and deceleration
.
speedcap
is the value corresponding to the maximum running speed of the character. This value increases by two when receiving the “Speed Boots” bonus, and decreases by half when “Slow Boots”.acceleration
is the acceleration power of the character. No matter how large the value is set for it, it will always be limited to the speedcap
value.deceleration
is the power of slowing down your character.
The more values are set, the greater the effect it will give. Experiment! By default, if you don’t specify physics for your character, Sonic physics will be used.