-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sonic Frontiers] Add "Enhanced Homing Attack Rebound" (#119)
* Keep Speed When Jumping Up Slopes * [Sonic Frontiers] "Keep Speed from Enemy Bounce" Code * Code updates Renamed codes, added descriptions, and fixed indentation. * [Sonic Frontiers] Code Changes and Addition Added "Use Swim Animation When Flying Underwater" and modified "Retain Velocity from Enemy Bounce", "Retain Velocity from Enemy Bounce" and "Fix Air Boost Reset" * Fix missing comma in "Fix Air Boost Reset" * Fix "Fix Air Boost Reset" (Again) * [Sonic Frontiers] Add "Enhanced Homing Attack Rebound" * Update Enhanced Homing Attack Rebound.hmm --------- Co-authored-by: Hyper <[email protected]>
- Loading branch information
1 parent
574d015
commit 4288cc0
Showing
1 changed file
with
170 additions
and
0 deletions.
There are no files selected for viewing
170 changes: 170 additions & 0 deletions
170
Source/Sonic Frontiers/Physics/Enhanced Homing Attack Rebound.hmm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
Code "Enhanced Homing Attack Rebound" in "Physics" by "Weezley" does | ||
/* | ||
Increases overall player control during a Homing Attack rebound and reduces Homing Attack hit stop. | ||
|
||
Notes; | ||
- It is recommended that you use this with Tighter Jump Rotation. | ||
- Sonic's combat skills immediately after a Homing Attack will use their default bindings, so keep that in mind when combined with combat mods. | ||
- Reduces homing delay. | ||
*/ | ||
// | ||
#include "BlackboardStatus" noemit | ||
#include "Reflection" noemit | ||
|
||
#lib "AmyParameters" | ||
#lib "HMM" | ||
#lib "KnucklesParameters" | ||
#lib "Lua" | ||
#lib "Player" | ||
#lib "SonicParameters" | ||
#lib "Time" | ||
|
||
#load "System.Numerics.dll" | ||
|
||
using System.Numerics; | ||
using System.Collections.Generic; | ||
|
||
static bool isHomingAttack = false; | ||
static bool isInitialized = false; | ||
static bool useTrickAnim = false; | ||
static float homingTime = 0.3f; | ||
static float currentTime = 0; | ||
static string[] animRand = new[] { "U", "D", "L", "R" }; | ||
static Random rand = new Random(); | ||
// | ||
{ | ||
if (!isInitialized) | ||
{ | ||
useTrickAnim = HMM.GetCodes().Contains("Animation/Sonic/Homing Attack Trick Animations"); | ||
isInitialized = true; | ||
} | ||
|
||
Lua.Init(); | ||
Time.GetDeltaTime(); | ||
|
||
string homingTrickAnim = $"JUMP_TRICK_{animRand[rand.Next(0, 4)]}{rand.Next(0, 3)}"; | ||
|
||
if (BlackboardStatus.IsSuper()) | ||
return; | ||
|
||
if (Player.State.GetCurrentStateID<Sonic.StateID>() == Sonic.StateID.StateHomingFinished && Player.State.GetPreviousStateID<Sonic.StateID>() != Sonic.StateID.StateHomingAttackInStorm) | ||
{ | ||
Player.State.SetState<Sonic.StateID>(Sonic.StateID.StateRecoveryJump); | ||
//Temporarily disable Homing Attack to prevent no delay spamming | ||
Lua.Call("SetPlayerAbilityEnabled", "HomingAttack", false); | ||
} | ||
|
||
if (Player.State.GetCurrentStateID<Sonic.StateID>() == Sonic.StateID.StateRecoveryJump && Player.State.GetPreviousStateID<Sonic.StateID>() == Sonic.StateID.StateHomingFinished) | ||
{ | ||
if (!isHomingAttack) | ||
{ | ||
var kinematics = Player.Kinematics.Get(); | ||
|
||
if (kinematics == null) | ||
return; | ||
|
||
if (Player.GetPlayerType() != Player.PlayerType.Amy) | ||
{ | ||
kinematics->Velocity += new Vector3(0, 3.5f, 0); | ||
} | ||
else | ||
{ | ||
//Amy rebounds way too high so remove vertical speed from hers to be more in line with the others | ||
kinematics->Velocity -= new Vector3(0, 7, 0); | ||
} | ||
|
||
if (useTrickAnim && Player.GetPlayerType() == Player.PlayerType.Sonic) | ||
{ | ||
Player.Animation.SetAnimation(homingTrickAnim); | ||
} | ||
else | ||
{ | ||
Player.Animation.SetAnimation("ATTACK_BOUNCE"); | ||
} | ||
|
||
isHomingAttack = true; | ||
} | ||
} | ||
else | ||
{ | ||
isHomingAttack = false; | ||
currentTime = 0; | ||
} | ||
|
||
if (isHomingAttack) | ||
{ | ||
currentTime += Time.GetDeltaTime(); | ||
if (currentTime >= homingTime) | ||
{ | ||
Lua.Call("SetPlayerAbilityEnabled", "HomingAttack", true); | ||
} | ||
} | ||
else | ||
{ | ||
//Making sure that Homing Attack is restored if the player exits the state before the timer counts up | ||
//I was gonna check and see if there are any places where Homing Attack is forcibly disabled, but it should be fine to always have it enabled anyways | ||
Lua.Call("SetPlayerAbilityEnabled", "HomingAttack", true); | ||
} | ||
|
||
var SonicParametersInfo = Reflection.GetDataInfo<SonicParameters.Root>("player_common"); | ||
var AmyParametersInfo = Reflection.GetDataInfo<AmyParameters.Root>("amy_common"); | ||
var KnucklesParametersInfo = Reflection.GetDataInfo<KnucklesParameters.Root>("knuckles_common"); | ||
|
||
if (SonicParametersInfo.pData != null) | ||
{ | ||
//Restoring the ability to use combo skills out of Homing Attack | ||
RFL_SET_PARAM(SonicParametersInfo, common.commonPackage.attack.homingAttack.hitStopNameDead.pValue, 0); | ||
RFL_SET_PARAM(SonicParametersInfo, common.commonPackage.attack.homingAttackAir.hitStopNameDead.pValue, 0); | ||
RFL_SET_PARAM(SonicParametersInfo, common.combo.comboTable.root.transitExistTarget[0], (isHomingAttack ? SonicParameters.Action.AcceleCombo1 : SonicParameters.Action.HomingAttack)); | ||
RFL_SET_PARAM(SonicParametersInfo, common.combo.comboTable.root.transitExistTarget[1], (isHomingAttack ? SonicParameters.Action.ChargeAttack : SonicParameters.Action.Root)); | ||
RFL_SET_PARAM(SonicParametersInfo, common.combo.comboTable.root.transitExistTarget[2], (isHomingAttack ? SonicParameters.Action.QuickCyloop : SonicParameters.Action.Root)); | ||
RFL_SET_PARAM(SonicParametersInfo, common.combo.comboTable.root.transitExistTarget[3], (isHomingAttack ? SonicParameters.Action.SpinSlash : SonicParameters.Action.Root)); | ||
RFL_SET_PARAM(SonicParametersInfo, common.combo.comboTable.root.transitExistTarget[4], (isHomingAttack ? SonicParameters.Action.Stomping : SonicParameters.Action.Root)); | ||
RFL_SET_PARAM(SonicParametersInfo, common.combo.comboTable.root.transitExistTarget[5], (isHomingAttack ? SonicParameters.Action.SonicBoom : SonicParameters.Action.Root)); | ||
RFL_SET_PARAM(SonicParametersInfo, common.combo.comboTable.root.transitInAir[0], (isHomingAttack ? SonicParameters.Action.AerialAcceleCombo1 : SonicParameters.Action.AerialHomingAttack)); | ||
RFL_SET_PARAM(SonicParametersInfo, common.combo.comboTable.root.transitInAir[1], (isHomingAttack ? SonicParameters.Action.ChargeAttack : SonicParameters.Action.Root)); | ||
RFL_SET_PARAM(SonicParametersInfo, common.combo.comboTable.root.transitInAir[2], (isHomingAttack ? SonicParameters.Action.AerialQuickCyloop : SonicParameters.Action.Root)); | ||
RFL_SET_PARAM(SonicParametersInfo, common.combo.comboTable.root.transitInAir[4], (isHomingAttack ? SonicParameters.Action.Stomping : SonicParameters.Action.Root)); | ||
RFL_SET_PARAM(SonicParametersInfo, common.combo.comboTable.root.transitInAir[5], (isHomingAttack ? SonicParameters.Action.SonicBoom : SonicParameters.Action.Root)); | ||
RFL_SET_PARAM(SonicParametersInfo, forwardView.modePackage.homingAttack.sonicBounce.bounceHorzSpeed, 2.5f); | ||
RFL_SET_PARAM(SonicParametersInfo, cyberspace.modePackage.homingAttack.sonicBounce.bounceHorzSpeed, 2.5f); | ||
RFL_SET_PARAM(SonicParametersInfo, cyberspaceSV.modePackage.homingAttack.sonicBounce.bounceHorzSpeed, -2.5f); | ||
RFL_SET_CONTEXTUAL_PLAYER_PARAM(SonicParametersInfo, modePackage.homingAttack.sonicBounce.bounceVertSpeed, 17.0f); | ||
RFL_SET_CONTEXTUAL_PLAYER_PARAM(SonicParametersInfo, modePackage.homingAttack.sonicBounceWeak.bounceVertSpeed, 12.0f); | ||
RFL_SET_CONTEXTUAL_PLAYER_PARAM(SonicParametersInfo, modePackage.homingAttack.sonicBounceWeak.bounceHorzSpeed, 10.0f); | ||
} | ||
|
||
if (AmyParametersInfo.pData != null) | ||
{ | ||
RFL_SET_PARAM(AmyParametersInfo, common.commonPackage.attack.homingAttack.hitStopNameDead.pValue, 0); | ||
RFL_SET_PARAM(AmyParametersInfo, common.commonPackage.attack.homingAttackAir.hitStopNameDead.pValue, 0); | ||
RFL_SET_PARAM(AmyParametersInfo, common.combo.comboTable.root.transitExistTarget[0], (isHomingAttack ? AmyParameters.Action.AmyTarotAttack : AmyParameters.Action.HomingAttack)); | ||
RFL_SET_PARAM(AmyParametersInfo, common.combo.comboTable.root.transitInAir[0], (isHomingAttack ? AmyParameters.Action.AmyTarotAttack : AmyParameters.Action.HomingAttack)); | ||
RFL_SET_PARAM(AmyParametersInfo, forwardView.modePackage.homingAttack.sonicBounce.bounceVertSpeed, 17.0f); | ||
RFL_SET_PARAM(AmyParametersInfo, forwardView.modePackage.homingAttack.sonicBounce.bounceHorzSpeed, 2.5f); | ||
RFL_SET_PARAM(AmyParametersInfo, forwardView.modePackage.homingAttack.sonicBounceWeak.bounceVertSpeed, 12.0f); | ||
RFL_SET_PARAM(AmyParametersInfo, forwardView.modePackage.homingAttack.sonicBounceWeak.bounceHorzSpeed, 10.0f); | ||
RFL_SET_PARAM(AmyParametersInfo, cyberspaceSV.modePackage.homingAttack.sonicBounce.bounceVertSpeed, 17.0f); | ||
RFL_SET_PARAM(AmyParametersInfo, cyberspaceSV.modePackage.homingAttack.sonicBounce.bounceHorzSpeed, -2.5f); | ||
RFL_SET_PARAM(AmyParametersInfo, cyberspaceSV.modePackage.homingAttack.sonicBounceWeak.bounceVertSpeed, 12.0f); | ||
RFL_SET_PARAM(AmyParametersInfo, cyberspaceSV.modePackage.homingAttack.sonicBounceWeak.bounceHorzSpeed, 10.0f); | ||
} | ||
|
||
if (KnucklesParametersInfo.pData != null) | ||
{ | ||
RFL_SET_PARAM(KnucklesParametersInfo, common.commonPackage.attack.homingAttack.hitStopNameDead.pValue, 0); | ||
RFL_SET_PARAM(KnucklesParametersInfo, common.commonPackage.attack.homingAttackAir.hitStopNameDead.pValue, 0); | ||
RFL_SET_PARAM(KnucklesParametersInfo, common.combo.comboTable.root.transitExistTarget[0], (isHomingAttack ? KnucklesParameters.Action.KnucklesPunch1 : KnucklesParameters.Action.HomingAttack)); | ||
RFL_SET_PARAM(KnucklesParametersInfo, common.combo.comboTable.root.transitExistTarget[4], (isHomingAttack ? KnucklesParameters.Action.Stomping : KnucklesParameters.Action.Root)); | ||
RFL_SET_PARAM(KnucklesParametersInfo, common.combo.comboTable.root.transitInAir[0], (isHomingAttack ? KnucklesParameters.Action.KnucklesPunch1 : KnucklesParameters.Action.HomingAttack)); | ||
RFL_SET_PARAM(KnucklesParametersInfo, common.combo.comboTable.root.transitInAir[4], (isHomingAttack ? KnucklesParameters.Action.Stomping : KnucklesParameters.Action.Root)); | ||
RFL_SET_PARAM(KnucklesParametersInfo, forwardView.modePackage.homingAttack.sonicBounce.bounceVertSpeed, 17.0f); | ||
RFL_SET_PARAM(KnucklesParametersInfo, forwardView.modePackage.homingAttack.sonicBounce.bounceHorzSpeed, 2.5f); | ||
RFL_SET_PARAM(KnucklesParametersInfo, forwardView.modePackage.homingAttack.sonicBounceWeak.bounceVertSpeed, 12.0f); | ||
RFL_SET_PARAM(KnucklesParametersInfo, forwardView.modePackage.homingAttack.sonicBounceWeak.bounceHorzSpeed, 10.0f); | ||
RFL_SET_PARAM(KnucklesParametersInfo, cyberspaceSV.modePackage.homingAttack.sonicBounce.bounceVertSpeed, 17.0f); | ||
RFL_SET_PARAM(KnucklesParametersInfo, cyberspaceSV.modePackage.homingAttack.sonicBounce.bounceHorzSpeed, -2.5f); | ||
RFL_SET_PARAM(KnucklesParametersInfo, cyberspaceSV.modePackage.homingAttack.sonicBounceWeak.bounceVertSpeed, 12.0f); | ||
RFL_SET_PARAM(KnucklesParametersInfo, cyberspaceSV.modePackage.homingAttack.sonicBounceWeak.bounceHorzSpeed, 10.0f); | ||
} | ||
} |