Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Commit b41a164

Browse files
committed
Revert "refactor: make ghost notes hardcoded"
This reverts commit be452bf.
1 parent 9e80775 commit b41a164

5 files changed

Lines changed: 178 additions & 263 deletions

File tree

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
local boyfriendGhostData = {}
2+
local dadGhostData = {}
3+
local gfGhostData = {}
4+
local sarahGhostData = {}
5+
6+
function goodNoteHit(id, direction, noteType, isSustainNote)
7+
local strumTime = getPropertyFromGroup('notes', id, 'strumTime')
8+
local noteType = getPropertyFromGroup('notes', id, 'noteType')
9+
10+
local isGF = getPropertyFromGroup('notes', id, 'gfNote') or noteType == 'Gf Sing'
11+
local isSarah = getPropertyFromGroup('notes', id, 'sarahNote') or noteType == 'Sarah Sing'
12+
13+
-- BOYFRIEND or DAD
14+
if not isSustainNote and not isGF and not isSarah then
15+
if strumTime == boyfriendGhostData.strumTime then
16+
createGhost(getProperty('characterPlayingAsDad') and 'dad' or 'boyfriend')
17+
end
18+
19+
boyfriendGhostData.strumTime = strumTime
20+
updateGData(getProperty('characterPlayingAsDad') and 'dad' or 'boyfriend')
21+
end
22+
23+
-- GF
24+
if not isSustainNote and isGF and not isSarah then
25+
if strumTime == gfGhostData.strumTime then
26+
createGhost('gf')
27+
end
28+
29+
gfGhostData.strumTime = strumTime
30+
updateGData('gf')
31+
end
32+
33+
-- SARAH
34+
if not isSustainNote and isSarah then
35+
if strumTime == sarahGhostData.strumTime then
36+
createGhost('sarah')
37+
end
38+
39+
sarahGhostData.strumTime = strumTime
40+
updateGData('sarah')
41+
end
42+
end
43+
44+
function opponentNoteHit(id, direction, noteType, isSustainNote)
45+
local strumTime = getPropertyFromGroup('notes', id, 'strumTime')
46+
local noteType = getPropertyFromGroup('notes', id, 'noteType')
47+
48+
local isGF = getPropertyFromGroup('notes', id, 'gfNote') or noteType == 'Gf Sing'
49+
local isSarah = getPropertyFromGroup('notes', id, 'sarahNote') or noteType == 'Sarah Sing'
50+
51+
-- DAD or BOYFRIEND
52+
if not isSustainNote and not isGF and not isSarah then
53+
if strumTime == dadGhostData.strumTime then
54+
createGhost(getProperty('characterPlayingAsDad') and 'boyfriend' or 'dad')
55+
end
56+
57+
dadGhostData.strumTime = strumTime
58+
updateGData(getProperty('characterPlayingAsDad') and 'boyfriend' or 'dad')
59+
end
60+
61+
-- GF
62+
if not isSustainNote and isGF and not isSarah then
63+
if strumTime == gfGhostData.strumTime then
64+
createGhost('gf')
65+
end
66+
67+
gfGhostData.strumTime = strumTime
68+
updateGData('gf')
69+
end
70+
71+
-- SARAH
72+
if not isSustainNote and isSarah then
73+
if strumTime == sarahGhostData.strumTime then
74+
createGhost('sarah')
75+
end
76+
77+
sarahGhostData.strumTime = strumTime
78+
updateGData('sarah')
79+
end
80+
end
81+
82+
function createGhost(char)
83+
local songPos = math.floor(math.abs(getSongPosition()))
84+
local imageFile = getProperty(char .. '.imageFile')
85+
local animName = getProperty(char .. '.animation.curAnim.name')
86+
local isMultiAtlas = getProperty(char .. '.isMultiAtlas')
87+
local newPath = isMultiAtlas and (imageFile:match("(.+)/[^/]+$") or imageFile) .. '/' .. animName or imageFile
88+
89+
local ghostTag = char .. 'Ghost' .. songPos
90+
makeAnimatedLuaSprite(ghostTag, newPath, getProperty(char .. '.x'), getProperty(char .. '.y'))
91+
addLuaSprite(ghostTag, false)
92+
93+
setProperty(ghostTag .. '.scale.x', getProperty(char .. '.scale.x'))
94+
setProperty(ghostTag .. '.scale.y', getProperty(char .. '.scale.y'))
95+
setProperty(ghostTag .. '.flipX', getProperty(char .. '.flipX'))
96+
if getProperty('inSilhouette') then
97+
setProperty(ghostTag .. '.color', 0x000000)
98+
end
99+
setProperty(ghostTag .. '.alpha', 1)
100+
doTweenAlpha(ghostTag .. 'delete', ghostTag, 0, 0.4)
101+
102+
local data = getGhostData(char)
103+
setProperty(ghostTag .. '.animation.frameName', data.frameName)
104+
setProperty(ghostTag .. '.offset.x', data.offsetX)
105+
setProperty(ghostTag .. '.offset.y', data.offsetY)
106+
setObjectOrder(ghostTag, getObjectOrder(char .. 'Group') - 1)
107+
end
108+
109+
function onTweenCompleted(tag)
110+
if tag:sub(-6) == 'delete' then
111+
removeLuaSprite(tag:sub(1, -7), true)
112+
end
113+
end
114+
115+
function updateGData(char)
116+
local data = getGhostData(char)
117+
data.frameName = getProperty(char .. '.animation.frameName')
118+
data.offsetX = getProperty(char .. '.offset.x')
119+
data.offsetY = getProperty(char .. '.offset.y')
120+
end
121+
122+
function getGhostData(char)
123+
if char == 'boyfriend' then
124+
return boyfriendGhostData
125+
elseif char == 'dad' then
126+
return dadGhostData
127+
elseif char == 'gf' then
128+
return gfGhostData
129+
elseif char == 'sarah' then
130+
return sarahGhostData
131+
end
132+
end

source/engine/backend/Conductor.hx

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,11 @@ class Conductor
2020
public static var songPosition:Float = 0;
2121
public static var offset:Float = 0;
2222

23-
public static var ROWS_PER_BEAT = 48; // from Stepmania
24-
public static var BEATS_PER_MEASURE = 4; // TODO: time sigs
25-
public static var ROWS_PER_MEASURE = ROWS_PER_BEAT * BEATS_PER_MEASURE; // from Stepmania
26-
public static var MAX_NOTE_ROW = 1 << 30; // from Stepmania
27-
28-
public inline static function beatToRow(beat:Float):Int return Math.round(beat * ROWS_PER_BEAT);
29-
30-
public inline static function rowToBeat(row:Int):Float return row / ROWS_PER_BEAT;
31-
32-
public inline static function secsToRow(sex:Float):Int return Math.round(getBeat(sex) * ROWS_PER_BEAT);
33-
23+
// public static var safeFrames:Int = 10;
3424
public static var safeZoneOffset:Float = 0; // is calculated in create(), is safeFrames in milliseconds
3525

3626
public static var bpmChangeMap:Array<BPMChangeEvent> = [];
3727

38-
inline public static function beatToNoteRow(beat:Float):Int
39-
{
40-
return Math.round(beat * Conductor.ROWS_PER_BEAT);
41-
}
42-
43-
inline public static function noteRowToBeat(row:Float):Float
44-
{
45-
return row / Conductor.ROWS_PER_BEAT;
46-
}
47-
4828
public static function judgeNote(arr:Array<Rating>, diff:Float = 0):Rating // die
4929
{
5030
var data:Array<Rating> = arr;

0 commit comments

Comments
 (0)