Skip to content

Commit 5fcf29b

Browse files
authored
[Sonic Frontiers] Allow Boost to Damage Objects: fixed damage collision not restoring properly (#266)
1 parent 03b5676 commit 5fcf29b

1 file changed

Lines changed: 48 additions & 23 deletions

File tree

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,69 @@
1-
Code "Allow Boost to Damage Objects" in "Gameplay/Skills" by "Hyper & NM" does "Allows the player to damage enemies and harder physics objects by boosting through them."
1+
Code "Allow Boost to Damage Objects" in "Gameplay/Skills" by "Hyper, NM & aleprime2007" does "Allows the player to damage enemies and harder physics objects by boosting through them."
22
//
33
#include "BlackboardStatus" noemit
44

55
#lib "Player"
66

77
using System.Collections.Generic;
88

9-
static bool _isBoostPrevious = false;
9+
static bool _isDamageEnabled = false;
10+
static bool _isDamageOverride = false;
1011

11-
static List<Sonic.StateID> _boostStates = new()
12+
static List<Sonic.StateID> _damageStates = new()
1213
{
13-
Sonic.StateID.StateAirBoost,
14-
Sonic.StateID.StateBumpJump,
15-
Sonic.StateID.StateGrind,
16-
Sonic.StateID.StateGrindDamage,
17-
Sonic.StateID.StateGrindJump,
18-
Sonic.StateID.StateGrindRoot,
19-
Sonic.StateID.StateGrindStep,
2014
Sonic.StateID.StateJump,
21-
Sonic.StateID.StateLeftStepRun,
22-
Sonic.StateID.StateRightStepRun,
15+
Sonic.StateID.StateDoubleJump,
16+
Sonic.StateID.StateSpinAttack,
17+
Sonic.StateID.StateSpinDash,
18+
Sonic.StateID.StateSpinBoostCharge,
19+
Sonic.StateID.StateSpinBoost,
20+
Sonic.StateID.StateHomingAttack,
21+
Sonic.StateID.StateStompingDown,
22+
Sonic.StateID.StateStompingLand,
23+
Sonic.StateID.StateBounceJump,
24+
Sonic.StateID.StateDropDash,
25+
Sonic.StateID.StateSliding
26+
};
27+
28+
static List<Sonic.StateID> _overrideStates = new()
29+
{
2330
Sonic.StateID.StateRun,
24-
Sonic.StateID.StateWallMove
31+
Sonic.StateID.StateAirBoost
2532
};
2633
//
2734
{
28-
Sonic.StateID _stateId = Player.State.GetCurrentStateID<Sonic.StateID>();
29-
if (_boostStates.Contains(_stateId) && IS_STATE_FLAG(IsBoost))
35+
void SetDamage(bool in_isEnabled)
36+
{
37+
var col = in_isEnabled
38+
? Player.CollisionType.Damage
39+
: Player.CollisionType.Default;
40+
41+
Player.Collision.SetCollisionSphere(col, 1.0f);
42+
Player.Collision.SetEntityCollision(!in_isEnabled);
43+
_isDamageEnabled = in_isEnabled;
44+
}
45+
46+
Sonic.StateID stateId = Player.State.GetCurrentStateID<Sonic.StateID>();
47+
48+
if (IS_STATE_FLAG(IsBoost))
3049
{
31-
if (!_isBoostPrevious)
50+
if (_overrideStates.Contains(stateId))
51+
{
52+
if (!_isDamageOverride)
53+
{
54+
SetDamage(true);
55+
_isDamageOverride = true;
56+
}
57+
}
58+
else
3259
{
33-
Player.Collision.SetCollisionSphere(Player.CollisionType.Damage, 1.0f);
34-
Player.Collision.SetEntityCollision(false);
35-
_isBoostPrevious = true;
60+
if (!_isDamageEnabled) SetDamage(true);
61+
_isDamageOverride = false;
3662
}
3763
}
38-
else if (_isBoostPrevious)
64+
else
3965
{
40-
Player.Collision.SetCollisionSphere(Player.CollisionType.Default, 1.0f);
41-
Player.Collision.SetEntityCollision(true);
42-
_isBoostPrevious = false;
66+
if (_isDamageEnabled && !_damageStates.Contains(stateId)) SetDamage(false);
67+
_isDamageOverride = false;
4368
}
4469
}

0 commit comments

Comments
 (0)