Skip to content

Commit 2062146

Browse files
committed
Move death haptics to scripts
1 parent 312d5ea commit 2062146

File tree

10 files changed

+198
-2
lines changed

10 files changed

+198
-2
lines changed

preload/scripts/characters/bf-christmas.hxc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import funkin.audio.FunkinSound;
44
import funkin.play.character.MultiSparrowCharacter;
55
import funkin.play.character.CharacterType;
66
import funkin.play.GameOverSubState;
7+
import funkin.util.HapticUtil;
78

89
class BoyfriendChristmasCharacter extends MultiSparrowCharacter
910
{
@@ -12,6 +13,25 @@ class BoyfriendChristmasCharacter extends MultiSparrowCharacter
1213
super('bf-christmas');
1314
}
1415

16+
function onAnimationFrame(name:String, frameNumber:Int, frameIndex:Int)
17+
{
18+
super.onAnimationFrame(name, frameNumber, frameIndex);
19+
20+
if (!HapticUtil.hapticsAvailable) return;
21+
22+
// BF's mic drops.
23+
if (name == 'firstDeath' && frameNumber == 27)
24+
{
25+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
26+
}
27+
28+
// BF's balls pulsating.
29+
if (name == 'deathLoop' && (frameNumber == 0 || frameNumber == 18))
30+
{
31+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
32+
}
33+
}
34+
1535
function onNoteHit(event:HitNoteScriptEvent)
1636
{
1737
if (event.eventCanceled)

preload/scripts/characters/bf-dark.hxc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import funkin.play.character.CharacterDataParser;
88
import funkin.play.character.CharacterType;
99
import funkin.play.PlayState;
1010
import funkin.play.character.MultiSparrowCharacter;
11+
import funkin.util.HapticUtil;
1112

1213
class BoyfriendDarkCharacter extends MultiSparrowCharacter
1314
{
@@ -16,6 +17,25 @@ class BoyfriendDarkCharacter extends MultiSparrowCharacter
1617
super('bf-dark');
1718
}
1819

20+
function onAnimationFrame(name:String, frameNumber:Int, frameIndex:Int)
21+
{
22+
super.onAnimationFrame(name, frameNumber, frameIndex);
23+
24+
if (!HapticUtil.hapticsAvailable) return;
25+
26+
// BF's mic drops.
27+
if (name == 'firstDeath' && frameNumber == 27)
28+
{
29+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
30+
}
31+
32+
// BF's balls pulsating.
33+
if (name == 'deathLoop' && (frameNumber == 0 || frameNumber == 18))
34+
{
35+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
36+
}
37+
}
38+
1939
var normalChar:BaseCharacter;
2040

2141
override function set_alpha(val:Float):Float

preload/scripts/characters/bf-holding-gf.hxc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import funkin.play.character.MultiSparrowCharacter;
55
import funkin.play.GameOverSubState;
66
import funkin.Preferences;
77
import funkin.util.Constants;
8+
import funkin.util.HapticUtil;
89

910
class BFHoldingGFCharacter extends MultiSparrowCharacter
1011
{
@@ -13,6 +14,25 @@ class BFHoldingGFCharacter extends MultiSparrowCharacter
1314
super('bf-holding-gf');
1415
}
1516

17+
function onAnimationFrame(name:String, frameNumber:Int, frameIndex:Int)
18+
{
19+
super.onAnimationFrame(name, frameNumber, frameIndex);
20+
21+
if (!HapticUtil.hapticsAvailable) return;
22+
23+
// BF's mic drops.
24+
if (name == 'firstDeath' && frameNumber == 27)
25+
{
26+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
27+
}
28+
29+
// BF's balls pulsating.
30+
if (name == 'deathLoop' && (frameNumber == 0 || frameNumber == 18))
31+
{
32+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
33+
}
34+
}
35+
1636
override function getDeathQuote():Null<String>
1737
{
1838
var randomCensor:Array<Int> = [];

preload/scripts/characters/bf-pixel.hxc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import funkin.play.character.MultiSparrowCharacter;
22
import funkin.play.PlayState;
33
import funkin.play.GameOverSubState;
44
import funkin.play.PauseSubState;
5+
import funkin.util.HapticUtil;
56
import flixel.FlxSprite;
67
import flixel.FlxG;
78

@@ -12,6 +13,25 @@ class BFPixelCharacter extends MultiSparrowCharacter
1213
super('bf-pixel');
1314
}
1415

16+
function onAnimationFrame(name:String, frameNumber:Int, frameIndex:Int)
17+
{
18+
super.onAnimationFrame(name, frameNumber, frameIndex);
19+
20+
if (!HapticUtil.hapticsAvailable) return;
21+
22+
// BF's mic drops.
23+
if (name == 'firstDeath' && frameNumber == 27)
24+
{
25+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
26+
}
27+
28+
// BF's balls pulsating.
29+
if (name == 'deathLoop' && (frameNumber == 0 || frameNumber == 18))
30+
{
31+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
32+
}
33+
}
34+
1535
function onCreate(event:ScriptEvent)
1636
{
1737
super.onCreate(event);

preload/scripts/characters/bf.hxc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import funkin.play.GameOverSubState;
66
import funkin.play.PlayState;
77
import funkin.Preferences;
88
import funkin.util.Constants;
9+
import funkin.util.HapticUtil;
910

1011
class BoyfriendCharacter extends MultiSparrowCharacter
1112
{
@@ -14,6 +15,25 @@ class BoyfriendCharacter extends MultiSparrowCharacter
1415
super('bf');
1516
}
1617

18+
function onAnimationFrame(name:String, frameNumber:Int, frameIndex:Int)
19+
{
20+
super.onAnimationFrame(name, frameNumber, frameIndex);
21+
22+
if (!HapticUtil.hapticsAvailable) return;
23+
24+
// BF's mic drops.
25+
if (name == 'firstDeath' && frameNumber == 27)
26+
{
27+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
28+
}
29+
30+
// BF's balls pulsating.
31+
if (name == 'deathLoop' && (frameNumber == 0 || frameNumber == 18))
32+
{
33+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
34+
}
35+
}
36+
1737
override function playAnimation(name:String, restart:Bool, ignoreOther:Bool)
1838
{
1939
if (name == "fakeoutDeath" && !this.debug)

preload/scripts/characters/pico-blazin.hxc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import flixel.FlxG;
22
import flixel.util.FlxTimer;
3+
import funkin.util.HapticUtil;
34
import funkin.play.PlayState;
45
import funkin.play.PauseSubState;
56
import funkin.graphics.FunkinSprite;
@@ -133,6 +134,19 @@ class PicoBlazinCharacter extends AnimateAtlasCharacter
133134

134135
// Make sure the death music plays with PERFECT timing.
135136
new FlxTimer().start(1.25, afterPicoDeathGutPunchIntro);
137+
138+
if (HapticUtil.hapticsAvailable) {
139+
new FlxTimer().start(0.5, function(tmr:FlxTimer) {
140+
// Pico falls on his knees.
141+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
142+
143+
new FlxTimer().start(0.6, function(tmr:FlxTimer) {
144+
// Pico falls "asleep". :)
145+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
146+
});
147+
});
148+
}
149+
136150
}
137151
else if (name == "deathConfirm")
138152
{

preload/scripts/characters/pico-christmas.hxc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import flixel.effects.FlxFlicker;
1414
import funkin.play.PauseSubState;
1515
import funkin.modding.module.ModuleHandler;
1616
import flixel.tweens.FlxTween;
17+
import funkin.util.HapticUtil;
1718

1819
class PicoChristmasCharacter extends MultiSparrowCharacter
1920
{
@@ -128,6 +129,23 @@ class PicoChristmasCharacter extends MultiSparrowCharacter
128129
deathSpriteRetry.x = this.x + 195;
129130
deathSpriteRetry.y = this.y - 70;
130131
}
132+
133+
if (!HapticUtil.hapticsAvailable) return;
134+
135+
// Pico falls on his back.
136+
if (name == 'firstDeath' && frameNumber == 20)
137+
{
138+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
139+
}
140+
141+
// Blood firework woohoo!!!!
142+
if (name == 'deathLoop' && frameNumber % 2 == 0)
143+
{
144+
final randomAmplitude:Float = FlxG.random.float(0.1, 0.5);
145+
final randomDuration:Float = FlxG.random.float(0.1, 0.3);
146+
147+
HapticUtil.vibrate(0, randomDuration, randomAmplitude);
148+
}
131149
}
132150

133151
function addToStage(sprite:FlxSprite)

preload/scripts/characters/pico-dark.hxc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import funkin.play.character.CharacterType;
1010
import funkin.graphics.FunkinSprite;
1111
import funkin.play.PauseSubState;
1212
import funkin.play.PlayState;
13+
import funkin.util.HapticUtil;
1314

1415
class PicoDarkCharacter extends MultiSparrowCharacter
1516
{
@@ -142,5 +143,22 @@ class PicoDarkCharacter extends MultiSparrowCharacter
142143
deathSpriteRetry.x = this.x + 195;
143144
deathSpriteRetry.y = this.y - 70;
144145
}
146+
147+
if (!HapticUtil.hapticsAvailable) return;
148+
149+
// Pico falls on his back.
150+
if (name == 'firstDeath' && frameNumber == 20)
151+
{
152+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
153+
}
154+
155+
// Blood firework woohoo!!!!
156+
if (name == 'deathLoop' && frameNumber % 2 == 0)
157+
{
158+
final randomAmplitude:Float = FlxG.random.float(0.1, 0.5);
159+
final randomDuration:Float = FlxG.random.float(0.1, 0.3);
160+
161+
HapticUtil.vibrate(0, randomDuration, randomAmplitude);
162+
}
145163
}
146164
}

preload/scripts/characters/pico-pixel.hxc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import funkin.play.character.SparrowCharacter;
22
import funkin.play.PlayState;
33
import funkin.play.GameOverSubState;
44
import funkin.play.PauseSubState;
5+
import funkin.util.HapticUtil;
56
import flixel.FlxSprite;
67
import funkin.graphics.FunkinSprite;
78
import flixel.FlxG;
@@ -57,4 +58,26 @@ class PicoPixelCharacter extends SparrowCharacter
5758

5859
super.playAnimation(name, restart, ignoreOther);
5960
}
61+
62+
function onAnimationFrame(name:String, frameNumber:Int, frameIndex:Int)
63+
{
64+
super.onAnimationFrame(name, frameNumber, frameIndex);
65+
66+
if (!HapticUtil.hapticsAvailable) return;
67+
68+
// Pico falls on his back.
69+
if (name == 'firstDeath' && frameNumber == 20)
70+
{
71+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
72+
}
73+
74+
// Blood firework woohoo!!!!
75+
if (name == 'deathLoop' && frameNumber % 2 == 0)
76+
{
77+
final randomAmplitude:Float = FlxG.random.float(0.1, 0.5);
78+
final randomDuration:Float = FlxG.random.float(0.1, 0.3);
79+
80+
HapticUtil.vibrate(0, randomDuration, randomAmplitude);
81+
}
82+
}
6083
}

preload/scripts/characters/pico-playable.hxc

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import funkin.play.GameOverSubState;
1515
import funkin.play.PauseSubState;
1616
import funkin.play.PlayState;
1717
import funkin.util.Constants;
18+
import funkin.util.HapticUtil;
1819
import funkin.Preferences;
1920

2021
class PicoPlayerCharacter extends MultiSparrowCharacter
@@ -232,8 +233,13 @@ class PicoPlayerCharacter extends MultiSparrowCharacter
232233
// Move the camera up.
233234
GameOverSubState.instance.cameraFollowPoint.y -= 100;
234235

235-
// Indicates that it is a special game over animation. Used for haptics.
236-
GameOverSubState.instance.isSpecialAnimation = true;
236+
HapticUtil.vibrate(0, 0.5);
237+
238+
// Death by Darnell's can.
239+
new FlxTimer().start(1.85, function(tmr:FlxTimer) {
240+
// Pico falls on his knees.
241+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
242+
});
237243

238244
var picoDeathExplosionPath = Paths.animateAtlas("characters/picoExplosionDeath", "weekend1");
239245
picoDeathExplosion = new FlxAtlasSprite(this.x - 640, this.y - 340, picoDeathExplosionPath);
@@ -331,6 +337,23 @@ class PicoPlayerCharacter extends MultiSparrowCharacter
331337
{
332338
createCasing();
333339
}
340+
341+
if (!HapticUtil.hapticsAvailable || picoDeathExplosion != null) return;
342+
343+
// Pico falls on his back.
344+
if (name == 'firstDeath' && frameNumber == 20)
345+
{
346+
HapticUtil.vibrate(0, 0.1, 0.1, 1);
347+
}
348+
349+
// Blood firework woohoo!!!!
350+
if (name == 'deathLoop' && frameNumber % 2 == 0)
351+
{
352+
final randomAmplitude:Float = FlxG.random.float(0.1, 0.5);
353+
final randomDuration:Float = FlxG.random.float(0.1, 0.3);
354+
355+
HapticUtil.vibrate(0, randomDuration, randomAmplitude);
356+
}
334357
}
335358

336359
var casingGroup:FlxTypedSpriteGroup;

0 commit comments

Comments
 (0)