ShadowMario / FNF-PsychEngine

Engine originally used on Mind Games mod
Apache License 2.0
1.15k stars 2.21k forks source link

Play note animations without hitting actual notes #11925

Closed LORAY-guy closed 1 year ago

LORAY-guy commented 1 year ago

Describe your problem here.

Is there a way to trigger certain animations from the player's notes without actually having to press a real note ? If not, do they have a name so i can try to play them using playAnim code ? (not the animations when you press in the void, the actual confirm animation)

Are you modding a build from source or with Lua?

Lua

What is your build target?

Windows x64

Did you edit anything in this build? If so, mention or summarize your changes.

No response

Drawoon2 commented 1 year ago
runHaxeCode('game.playerStrums.members['..key..'].playAnim("confirm", true);')
    setPropertyFromGroup('playerStrums',key,'resetAnim',0)
LORAY-guy commented 1 year ago

Do i have to replace key by the name of the supposed pressed key ?

Drawoon2 commented 1 year ago

Do i have to replace key by the name of the supposed pressed key ?

"pressed" for pressed and "static" for idle anim

LORAY-guy commented 1 year ago

Ok, i had to replace 'key' with noteData % 4 for it to work, thanks a lot and one more thing, is there a way i could get the splash to work too ?

Drawoon2 commented 1 year ago

runHaxeCode([[ var strum = playerStrums.members[]]..noteData..[[]; if(strum != null) { spawnNoteSplash(strum.x, strum.y, ]]..noteData..[[); } ]]) I'm not very sure that it works but this would be the basis of what you ask for

LORAY-guy commented 1 year ago

Nah, doesn't work for what i'm doing, here's the entire script so you can see what i'm actually trying to go for :

local playing = false

function onUpdate()
    if getProperty('gf.animation.curAnim.name') == "danceLeft" and getProperty('gf.animation.curAnim.curFrame') == 0 and playing == false then
        characterPlayAnim('boyfriend', 'idle')
    end
end

local stopAnimTimer = 0
local targetTime = 0

function onUpdatePost(elapsed)
    -- end of "update"
    setProperty('boyfriend.stunned', true) --stop boyfriend from hitting notes normally, and stops his animations from happening
    mouseX = getMouseX('hud') - 25
    mouseY = getMouseY('hud') - 50
    noteCount = getProperty('notes.length')

    for i = 0, noteCount-1 do
        if getPropertyFromGroup('notes', i, 'mustPress') then
            noteX = getPropertyFromGroup('notes', i, 'x')
            noteY = getPropertyFromGroup('notes', i, 'y')

            hitbox = 75
            isSustainNote = getPropertyFromGroup('notes', i, 'isSustainNote')
            if isSustainNote then
                noteX = noteX - 30
            else
                noteX = noteX - 10
                noteY = noteY + 20
            end

            if math.abs(noteX - mouseX) <= hitbox and math.abs(noteY - mouseY) <= hitbox and mouseY > -45 and mouseY < 100 then
                addScore(350)
                addHits(1)

                noteData = getPropertyFromGroup('notes', i, 'noteData')
                noteType = getPropertyFromGroup('notes', i, 'noteType')
                if noteType == 'Hurt Note' then
                    characterPlayAnim('boyfriend', 'hurt', true)
                else
                    if noteData == 0 then
                        characterPlayAnim('boyfriend', 'singLEFT', true)
                        runHaxeCode('game.playerStrums.members['..(noteData % 4)..'].playAnim("confirm", true);')
                        setPropertyFromGroup('playerStrums',(noteData % 4),'resetAnim',0.175)
                        playing = true
                    elseif noteData == 1 then
                        characterPlayAnim('boyfriend', 'singDOWN', true)
                        runHaxeCode('game.playerStrums.members['..(noteData % 4)..'].playAnim("confirm", true);')
                        setPropertyFromGroup('playerStrums',(noteData % 4),'resetAnim',0.175)
                        playing = true
                    elseif noteData == 2 then
                        characterPlayAnim('boyfriend', 'singUP', true)
                        runHaxeCode('game.playerStrums.members['..(noteData % 4)..'].playAnim("confirm", true);')
                        setPropertyFromGroup('playerStrums',(noteData % 4),'resetAnim',0.175)
                        playing = true
                    elseif noteData == 3 then
                        characterPlayAnim('boyfriend', 'singRIGHT', true)
                        runHaxeCode('game.playerStrums.members['..(noteData % 4)..'].playAnim("confirm", true);')
                        setPropertyFromGroup('playerStrums',(noteData % 4),'resetAnim',0.175)
                        playing = true
                    end
                    stopAnimTimer = 0
                    targetTime = stepCrochet * 0.001 * getProperty('boyfriend.singDuration')
                end

                if noteType == 'Hey!' then
                    characterPlayAnim('boyfriend', 'hey', true)
                    setProperty('boyfriend.heyTimer', 0.6)
                    characterPlayAnim('gf', 'hey', true)
                    setProperty('gf.heyTimer', 0.6)
                elseif noteType == 'Hurt Note' then
                    if not isSustainNote then
                        setProperty('health', getProperty('health') - 0.15)
                    else
                        setProperty('health', getProperty('health') - 0.03)
                    end
                else
                    if not isSustainNote then
                        setProperty('health', getProperty('health') + 0.023)
                    else
                        setProperty('health', getProperty('health') + 0.004)
                    end
                end
                removeFromGroup('notes', i)
                setProperty('vocals.volume', 1)
                break
            end
        end
    end

    stopAnimTimer = stopAnimTimer + elapsed
    if targetTime > 0 and stopAnimTimer > targetTime then
        characterPlayAnim('boyfriend', 'idle')
        playing = false
        targetTime = 0
        stopAnimTimer = 0
    end
end

Place that in the script folder, it works on any songs