|
| 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 |
0 commit comments