Skip to content

Instantly share code, notes, and snippets.

@Xane123
Created Jan 19, 2021
Embed
What would you like to do?
A comparison of Magical Mary 1's old and new mid-air ability script.
script "JumpAndAbility" ENTER
//This script handles both jumping (variable-height) and mid-air abilities like the Air Dash, depending on if the player's grounded or not.
{ //The order for these arrays is Mary, Xane, then the adult scale tester. Basuically, the same internal character order as everywhere else.
int var_velocity[3] = { 7.78, 1.7, 7.78 };
int var_decrease_velocity[3] = { 0.05, 0.14, 0.05 };
int var_remaining_tics[3] = { 7, 9, 7 };
int remaining_tics; //How many tics are left in this jump.
int velocity = 0.0; //Current jump velocity.
While(1)
{
//Print(f:GetActorVelZ(0), s:" / ", d:openInput_CurrentKeysR[PlayerNumber()]);
If(openInput_CurrentKeysR[PlayerNumber()] & BT_JUMP && !(openInput_PreviousKeysR[PlayerNumber()] & BT_JUMP))
{
If(lateJumpTimer[PlayerNumber()])
{ //If on the ground, try to perform a variable-height jump, given conditions are met below.
if(!disableJumping[PlayerNumber()])
{
lateJumpTimer[PlayerNumber()] = 0; //Prevent accidentally doing a mid-air double jump by setting this to 0.
velocity = var_velocity[PlayerClass(PlayerNumber())]; //Set to the player's initial jump velocity.
If(GetSpeed(0, GS_HORIZONTAL) < 100 || openInput_ForwardMove[PlayerNumber()] <= 0) jumpCount[PlayerNumber()] = 0;
//Log(d:GetSpeed(0, GS_HORIZONTAL), s:" / dJump ", d:disableJumping[0], s:" / dMisc ", d:disableMiscellaneous[0]);
Switch(jumpCount[PlayerNumber()])
{
Case 0: //Standard
PlaySound(0,"*scripted_jump",CHAN_BODY,1.0,FALSE,1.05);
Break;
Case 1: //Double
PlaySound(0,"*double_jump",CHAN_BODY,1.0,FALSE,0.95);
velocity += 2.75;
Break;
Case 2: //Triple
PlaySound(0,"*triple_jump",CHAN_BODY,1.0,FALSE,0.9);
velocity += 5.25;
Break;
}
//Log(s:"A jump has started!");
//SetActorState(0, "JumpAnimation",FALSE);
remaining_tics = var_remaining_tics[PlayerClass(PlayerNumber())];
//velocity = var_velocity[PlayerClass(PlayerNumber())];
cancelJump[PlayerNumber()] = FALSE;
Until(remaining_tics==0 || ( (StrParam(l:"MOBILE")!="YES"||GetCVAR("cl_demo")==TRUE) &&!(openInput_CurrentKeysR[PlayerNumber()] & BT_JUMP) )||cancelJump[PlayerNumber()]==TRUE||disableJumping[PlayerNumber()]||SpringLock[PlayerNumber()])
{
Print(s:"REMAINING: ", d:remaining_tics, s:"\nVELOCITY ADDED: ", f:velocity, s:"\nJUMP NUMBER: ", d:jumpCount[0]);
remaining_tics--;
velocity -= var_decrease_velocity[PlayerClass(PlayerNumber())];
SetActorVelocity(1000+PlayerNumber(),GetActorVelX(0),GetActorVelY(0),velocity,FALSE,FALSE);
Delay(1);
}
If(cancelJump[PlayerNumber()]==TRUE)
{
Log(s:"Jump cancelled.");
cancelJump[PlayerNumber()] = FALSE;
}
jumpCount[PlayerNumber()]++; //Advance to the next jump in case the player jumps again!
If(jumpCount[PlayerNumber()]>2) jumpCount[PlayerNumber()] = 0; //After a triple jump, revert to a normal jump.
}
}
Else
{ //If in the air, perform your mid-air ability (such as the Air Dash).
If(AbilityUses[PlayerNumber()]>-1)
{
Switch(PlayerClass(PlayerNumber()))
{
Case CHAR_MARY:
Case CHAR_SCALETEST:
If(ACS_NamedExecuteWithResult("PowerAttackCheck",1,12,TRUE,0)==TRUE && !AbilityUses[PlayerNumber()])
{
ACS_NamedExecuteAlways("PowerAttackCheck",2,12,TRUE); //Take away the 12 power promised above.
If(SpringLock[PlayerNumber()]) { SpringLock[PlayerNumber()] = FALSE; SetPlayerProperty(FALSE,OFF,PROP_FROZEN); } //Was the player locked by a spring? Unlock them.
GiveInventory("Animation1",1); //Force Mary into her Air Dash pose/state.
LocalAmbientSound("sonic/thok",127);
disableWallJump[PlayerNumber()] = 3;
SetActorVelocity(1000+PlayerNumber(),0,0,0,FALSE,TRUE);
If(CheckActorInventory(1000+PlayerNumber(),"SuperX")==0) //If not transformed
{
If(PlayerUpgrades[0]==TRUE&&openInput_ForwardMove[PlayerNumber()]==0)
{ //Second Jump (neutral jump with upgrade only)
ThrustThingZ(1000+PlayerNumber(),70,0,1);
ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,15,0,1000+PlayerNumber());
}
Else If(PlayerUpgrades[0]==TRUE&&openInput_ForwardMove[PlayerNumber()]<0)
{ //Downward Burst (backward+jump with upgrade only)
ThrustThingZ(1000+PlayerNumber(),-45,0,1);
ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,26,0,1000+PlayerNumber());
LandingBehavior[PlayerNumber()] = 2; //Dash forward upon landing.
}
Else
{ //Normal Air Dash, performed with forward+upgrade or no upgrade. Behaves like upward Air Dash before v2.0-dev.
ThrustThingZ(1000+PlayerNumber(),50,0,1);
ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,30,0,1000+PlayerNumber());
}
}
Else //If transformed (yes, duplicated code)
{
If(PlayerUpgrades[0]==TRUE&&openInput_ForwardMove[PlayerNumber()]==0)
{ //Upward Air Dash (neutral jump with upgrade only)
ThrustThingZ(1000+PlayerNumber(),90,0,1);
ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,25,0,1000+PlayerNumber());
}
Else If(PlayerUpgrades[0]==TRUE&&openInput_ForwardMove[PlayerNumber()]<0)
{ //Downward Air Dash (backward+jump with upgrade only)
ThrustThingZ(1000+PlayerNumber(),-52,0,1);
ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,35,0,1000+PlayerNumber());
LandingBehavior[PlayerNumber()] = 2; //Dash forward upon landing.
}
Else
{ //Normal Air Dash, performed with forward+upgrade or no upgrade.
ThrustThingZ(1000+PlayerNumber(),60,0,1); //Otherwise,just do the normal Air Dash.
ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,40,0,1000+PlayerNumber());
}
}
//SetActorState(1000+PlayerNumber(),"AllowJumps",TRUE); //Required to allow the Air Dash state.
AbilityUses[PlayerNumber()]++; //Only one Air Dash is allowed per jump.
JumpCount[PlayerNumber()] = 1; //A double jump is guaranteed after an Air Dash, no Triple Jump.
Delay(12);
}
Break;
Case CHAR_XANE:
Break;
}
}
}
}
Delay(1);
}
}
//////////////////////////////////////////////////////////////////////////////////////////
//BELOW IS THE OLD, MESSY SCRIPT FROM WORLD OF KIRBYCRAFT AND MARY'S MAGICAL ADVENTURE. //
//It is so hackish with its restarts, strange loops, and "detected" variable. //
//////////////////////////////////////////////////////////////////////////////////////////
script "MidAirAbility" ENTER //Previously script 67(?). This script is such a mess with hackish "restarting", but due to its complexity, has to stay, lest something goes wrong.
{
//upgrades[20] = TRUE; //DEBUG
int marydboost_tics; //Remaining tics for downward Air Dash thrust upon hitting ground.
int esc_loop = 0; //1 = jumped; 2 = landed. Why is this so hackish-looking?
While(1)
{
if(no_scripts[PlayerNumber()] == TRUE) Delay(3);
if(no_scripts[PlayerNumber()] == FALSE)
{
esc_loop = 0; //Force esc_loop to 0 to prevent restart loop or constant ability use.
Until(GetActorZ(1000+PlayerNumber())-GetActorFloorZ(1000+PlayerNumber())>16.0) Delay(1);
if(detected[PlayerNumber()]==0)
{
detected[PlayerNumber()] = 1;
rem_pflaps[PlayerNumber()] = 5; //Setup Xane's "power flaps" variable here.
Delay(1);
Restart;
}
//openInput[PlayerNumber()] = GetPlayerInput(PlayerNumber(),INPUT_BUTTONS);
If(PlayerClass(PlayerNumber())!=CHAR_XANE || (PlayerClass(PlayerNumber())==CHAR_XANE&&detected[PlayerNumber()]<2) )
{ //If not Xane, or if Xane without a single flap performed, don't count the jump unless the player releases it first.
While(openInput[PlayerNumber()] & BT_JUMP) //If the player's holding jump, don't count it!
{
//if(no_scripts[PlayerNumber()] == FALSE) input[PlayerNumber()] = GetPlayerInput(PlayerNumber(),INPUT_BUTTONS);
Delay(1);
}
}
Until(esc_loop != 0)
{
//if(no_scripts[PlayerNumber()] == FALSE) input[PlayerNumber()] = GetPlayerInput(PlayerNumber(),INPUT_BUTTONS);
if(openInput[PlayerNumber()] & BT_JUMP) esc_loop = 1;
if(GetActorZ(0)-GetActorFloorZ(0) < 4.0) esc_loop = 2;
Delay(1);
}
if(esc_loop == 2) Restart;
If(detected[PlayerNumber()]<3) detected[PlayerNumber()]++;
If(detected[PlayerNumber()]>1) cancelJump[PlayerNumber()] = TRUE; //If an ability is about to be used, cancel the playr's jump. This only matters on mobile.
If(detected[PlayerNumber()]>1&&detected[PlayerNumber()]<4&&PlayerClass(PlayerNumber())==CHAR_XANE) //Wing Flap
{
//PrintBold(d:detected[PlayerNumber()]);
if(detected[PlayerNumber()]==2) ACS_NamedExecute("Xane_TempAirControlChange",0,0,0,0);
//if(detected[PlSayerNumber()]==6) ActivatorSound("xane/jump5",127);
if(meter[PlayerNumber()]>0&&detected[PlayerNumber()]>1&&detected[PlayerNumber()]<10)
{
If(spring_lock[PlayerNumber()]) { spring_lock[PlayerNumber()] = FALSE; SetPlayerProperty(FALSE,OFF,PROP_FROZEN); } //Was the player locked by a spring? Unlock them.
ActivatorSound("xane/fly",256); //Always play "flapping" sounds.
If(GetActorVelZ(1000+PlayerNumber())<-4.0) SetActorVelocity(1000+PlayerNumber(),GetActorVelX(0),GetActorVelY(0),0.0,FALSE,FALSE);
If(progression!=1)
{
Switch(rem_pflaps[PlayerNumber()]) //Xane's force depends on how much energy he has during his current flight.
{
Case 5: SetActorVelocity(1000+PlayerNumber(),FixedMul(GetActorVelX(1000+PlayerNumber()),1.025),FixedMul(GetActorVelY(1000+PlayerNumber()),1.025),10.5,FALSE,FALSE); Break;
Case 4: SetActorVelocity(1000+PlayerNumber(),FixedMul(GetActorVelX(1000+PlayerNumber()),1.03),FixedMul(GetActorVelY(1000+PlayerNumber()),1.03),10.0,FALSE,FALSE); Break;
Case 3: SetActorVelocity(1000+PlayerNumber(),FixedMul(GetActorVelX(1000+PlayerNumber()),1.04),FixedMul(GetActorVelY(1000+PlayerNumber()),1.04),9.75,FALSE,FALSE); Break;
Case 2: SetActorVelocity(1000+PlayerNumber(),FixedMul(GetActorVelX(1000+PlayerNumber()),1.06),FixedMul(GetActorVelY(1000+PlayerNumber()),1.06),9.66,FALSE,FALSE); Break;
Case 1: SetActorVelocity(1000+PlayerNumber(),FixedMul(GetActorVelX(1000+PlayerNumber()),1.1),FixedMul(GetActorVelY(1000+PlayerNumber()),1.1),9.6,FALSE,FALSE); Break;
Default: SetActorVelocity(1000+PlayerNumber(),FixedMul(GetActorVelX(1000+PlayerNumber()),1.15),FixedMul(GetActorVelY(1000+PlayerNumber()),1.15),9.55,FALSE,FALSE); Break;
}
}
Else If(rem_pflaps[PlayerNumber()]==5) //During progression #1, Xane's flight is very limited due to wing damage, making his volcano section harder.
{
SetActorVelocity(1000+PlayerNumber(),FixedMul(GetActorVelX(1000+PlayerNumber()),1.033),FixedMul(GetActorVelY(1000+PlayerNumber()),1.033),15,FALSE,FALSE); Break;
}
If(meter[PlayerNumber()]<10||rem_pflaps[PlayerNumber()]>0) meter[PlayerNumber()]--;
Else meter[PlayerNumber()] -= 2;
If(rem_pflaps[PlayerNumber()]>0) rem_pflaps[PlayerNumber()]--;
If(progression!=1)
{
int temp_xtics = 0;
While(openInput[MAX_PLAYERS*4+PlayerNumber()] & BT_JUMP && temp_xtics<15)
{
Log(d:temp_xtics);
temp_xtics++;
Delay(1);
}
If(temp_xtics>=10) Restart; //It's hackish, but this will make Xane automatically flap again if the jump button is still being held.
}
}
}
if(detected[PlayerNumber()]==2 && (PlayerClass(PlayerNumber())==CHAR_MARY||PlayerClass(PlayerNumber())==CHAR_SCALETEST) ) //Air Dash
{
If(ACS_NamedExecuteWithResult("PowerAttackCheck",0,12,TRUE,0)==TRUE)
{
If(spring_lock[PlayerNumber()]) { spring_lock[PlayerNumber()] = FALSE; SetPlayerProperty(FALSE,OFF,PROP_FROZEN); } //Was the player locked by a spring? Unlock them.
GiveInventory("Animation1",1); //Force Mary into her Air Dash pose/state.
LocalAmbientSound("sonic/thok",127);
//kjumped[PlayerNumber()] = 70;
hammermove[PlayerNumber()] = 3;
SetActorVelocity(1000+PlayerNumber(),0,0,0,FALSE,TRUE);
If(CheckActorInventory(1000+PlayerNumber(),"SuperX")==0)
{
If(upgrades[5]==TRUE&&movement[PlayerNumber()]==0&movement[MAX_PLAYERS+PlayerNumber()]==0)
{ //Second Jump (neutral jump with upgrade only)
ThrustThingZ(1000+PlayerNumber(),70,0,1);
ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,15,0,1000+PlayerNumber());
}
Else If(upgrades[5]==TRUE&&movement[PlayerNumber()]==0&&movement[MAX_PLAYERS+PlayerNumber()]>0)
{ //Downward Burst (backward+jump with upgrade only)
ThrustThingZ(1000+PlayerNumber(),-45,0,1);
ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,26,0,1000+PlayerNumber());
Until(GetActorZ(0)-GetActorFloorZ(0)<1.0||(GetActorVelZ(0)<2.25&&GetActorVelZ(0)>-2.25)) Delay(1);
marydboost_tics = 3;
While(marydboost_tics>0) { ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,10,0,1000+PlayerNumber()); marydboost_tics--; Delay(1); }
}
Else
{ //Normal Air Dash, performed with forward+upgrade or no upgrade. Behaves like upward Air Dash before v2.0-dev.
ThrustThingZ(1000+PlayerNumber(),50,0,1);
ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,30,0,1000+PlayerNumber());
}
}
Else
{
If(upgrades[5]==TRUE&&movement[PlayerNumber()]==0&movement[MAX_PLAYERS+PlayerNumber()]==0)
{ //Upward Air Dash (neutral jump with upgrade only)
ThrustThingZ(1000+PlayerNumber(),90,0,1);
ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,25,0,1000+PlayerNumber());
}
Else If(upgrades[5]==TRUE&&movement[PlayerNumber()]==0&&movement[MAX_PLAYERS+PlayerNumber()]>0)
{ //Downward Air Dash (backward+jump with upgrade only)
ThrustThingZ(1000+PlayerNumber(),-52,0,1);
ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,35,0,1000+PlayerNumber());
Until(GetActorZ(0)-GetActorFloorZ(0)<1.0||(GetActorVelZ(0)<2.25&&GetActorVelZ(0)>-2.25)) Delay(1);
marydboost_tics = 3;
While(marydboost_tics>0) { ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,15,0,1000+PlayerNumber()); marydboost_tics--; Delay(1); }
}
Else
{ //Normal Air Dash, performed with forward+upgrade or no upgrade.
ThrustThingZ(1000+PlayerNumber(),60,0,1); //Otherwise,just do the normal Air Dash.
ThrustThing(GetActorAngle(1000+PlayerNumber())>>8,40,0,1000+PlayerNumber());
}
}
SetActorState(1000+PlayerNumber(),"AllowJumps",TRUE); //Required to allow the Air Dash state.
remjumps[PlayerNumber()]--;
Delay(12);
}
}
Delay(1);
}
While(openInput[PlayerNumber()] & BT_JUMP) Delay(1); //If the player is still holding jump, wait until they aren't before restarting.
//Restart;
Delay(1);
}
//There was a delay here but it isn't needed since this is outside the "while" loop.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment