ShadowMario / FNF-PsychEngine

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

Change note speed #12993

Closed Hazardows closed 11 months ago

Hazardows commented 1 year ago

Describe your problem here.

Is there a way to change the velocity of a specific strum line note. I mean something like making all notes pointing to the right go at a different velocity with an event or something that allows me to change that during gameplay.

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.

Nope

Dsyboot commented 1 year ago

I never seen that in the source code of PlayState.hx, but you can change the general notes speed with this:

value = 2.2 setProperty('songSpeed', value)

Hazardows commented 1 year ago

I know that alredy but i need to change only one strum speed Thanks anyways for answering but this won't work for what i'm tryng to do I'll find how to make it someday (if it's possible)

Dsyboot commented 1 year ago

I know that alredy but i need to change only one strum speed Thanks anyways for answering but this won't work for what i'm tryng to do I'll find how to make it someday (if it's possible)

I will try to help you with that problem, for this I will have to look in PlayState.hx to see if that option already exists, but first of all, what version of psych Engine are you using?

frantastic24 commented 1 year ago
function onCreatePost()
    for i=0, getProperty('unspawnNotes.length')-1 do
        if getPropertyFromGroup('unspawnNotes', i, 'noteData') == 3 then -- changes Right only
            setPropertyFromGroup('unspawnNotes', i, 'multSpeed', 1) -- multiply speed by 1
        end
    end
end
Dsyboot commented 1 year ago

Thanks you frantastic24, using the logic of your code, you can also make random notes speeds like this:

function onCreate()
    for i=0, getProperty('unspawnNotes.length')-1 do
        if getRandomInt(1, 100) == 14 then -- randomly change the speed of a note
            setPropertyFromGroup('unspawnNotes', i, 'multSpeed', 1.25) -- multiply speed by 1.25
        end
    end
end

Obviosly you can change the getRandomInt and the multSpeed, but if you want random speeds for random notes you can use this code:

function onCreate()
    for i=0, getProperty('unspawnNotes.length')-1 do
        if getRandomInt(1, 100) == 14 then -- randomly change the speed of a note
            setPropertyFromGroup('unspawnNotes', i, 'multSpeed', 1.25) -- multiply speed by 1.25
        elseif getRandomInt(1, 100) == 34 then -- randomly change the speed of a note
            setPropertyFromGroup('unspawnNotes', i, 'multSpeed', 1.5) -- multiply speed by 1.5
        end
    end
end

if you made more elseif's you can handle more speeds, but in getRandomInt please change the values to optimal results

Hazardows commented 1 year ago

I know that alredy but i need to change only one strum speed Thanks anyways for answering but this won't work for what i'm tryng to do I'll find how to make it someday (if it's possible)

I will try to help you with that problem, for this I will have to look in PlayState.hx to see if that option already exists, but first of all, what version of psych Engine are you using?

I'm ussing Psych engine 0.6.2, but if You find it for other version i can change to that version

Hazardows commented 1 year ago
function onCreatePost()
    for i=0, getProperty('unspawnNotes.length')-1 do
        if getPropertyFromGroup('unspawnNotes', i, 'noteData') == 3 then -- changes Right only
            setPropertyFromGroup('unspawnNotes', i, 'multSpeed', 1) -- multiply speed by 1
        end
    end
end

how can i do that on an event (with a tween or a time progression)

Dsyboot commented 1 year ago
function onCreatePost()
    for i=0, getProperty('unspawnNotes.length')-1 do
        if getPropertyFromGroup('unspawnNotes', i, 'noteData') == 3 then -- changes Right only
            setPropertyFromGroup('unspawnNotes', i, 'multSpeed', 1) -- multiply speed by 1
        end
    end
end

how can i do that on an event (with a tween or a time progression)

oh, that's uneficient because the game doesn't know what are the note that you want to change, you need to specify the id of the note, example, if my chart haves 3k notes, you need to give the value of the note that you want to change, you can reuse that code, but you can experiment some game freezes for a bit seconds, idk how to get the specific note spawned, i forgotten that code sorry.

I forgotten something, to make it a event you can use this:

--n is the name of the event
--v1 is the id of the note that you want to change
--v2 is the speed of that note
function onEvent(n, v1, v2)
   if n == "Change NoteSpeed" then
      setPropertyFromGroup('unspawnNotes', v1, 'multSpeed', v2) -- multiply speed by v2 (specific double value)
   end
end
frantastic24 commented 1 year ago

It's not really inefficient and this code is ran before the song even loads, you will not be able to tell the difference Your code needs you to manually input every single note you want to change

Dsyboot commented 1 year ago

It's not really inefficient and this code is ran before the song even loads, you will not be able to tell the difference Your code needs you to manually input every single note you want to change

that was the reason i called it "inefficient". Btw these code needs to be placed in "custom_events" folder, that makes you can run the code all the times you want

frantastic24 commented 1 year ago

I completely missed the other reply, my bad You can still do it before the song loads using strumTime instead of guessing their ID, running an event for this will both cause lag and have a delay since some notes have already spawned

function onCreatePost()
    for i=0, getProperty('unspawnNotes.length')-1 do
        if getPropertyFromGroup('unspawnNotes', i, 'strumTime') >=  1000 then -- in milliseconds
            setPropertyFromGroup('unspawnNotes', i, 'multSpeed', 1) -- multiply speed by 1
        end
    end
end
Dsyboot commented 1 year ago

I have a question, how you can now if a note is a sustain in the unspawnNotes group like multSpeed?

frantastic24 commented 1 year ago

Iirc there's no property for it but you can check if the animation name contains hold

Dsyboot commented 1 year ago

Iirc there's no property for it but you can check if the animation name contains hold

I profundices the code of the notes an actually you can know if the note are a sustain: getPropertyFromGroup('unspawnNotes', i, 'isSustainNote')

Btw how I can check the hold animation?

frantastic24 commented 1 year ago

I misremembered, you check the animation name if you only need to get the end of the sustain animation.curAnim.name

Dsyboot commented 1 year ago

I misremembered, you check the animation name if you only need to get the end of the sustain animation.curAnim.name

Thank you, I will make a luaTxt for show all the animations

frantastic24 commented 1 year ago

You could just look at Note.hx, you don't even need to know their exact names you just need to check if they contain end somewhere

Dsyboot commented 1 year ago

You could just look at Note.hx, you don't even need to know their exact names you just need to check if they contain end somewhere

Ohh okey, I will try that

Alltoupload commented 1 year ago

How about if I want to only change the speed of the opponent

Dsyboot commented 1 year ago

How about if I want to only change the speed of the opponent

Use this for boyfriend:

getPropertyFromGroup('unspawnNotes', i, 'mustPress')

And this for dad:

not getPropertyFromGroup('unspawnNotes', i, 'mustPress')

Is the same shit, but with a not, there's a example:

function onCreatePost()
    for i=0, getProperty('unspawnNotes.length')-1 do
        if not getPropertyFromGroup('unspawnNotes', i, 'mustPress') then -- just change for dad (opponent)
            setPropertyFromGroup('unspawnNotes', i, 'multSpeed', 1) -- multiply speed by 1, just change it with the speed you want
        end
    end
end
Alltoupload commented 1 year ago

Thanks!

Dsyboot commented 1 year ago

Thanks!

You're welcome.