Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENHANCEMENT] Additional changes to Note Kind Scripts #2635

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

lemz1
Copy link
Contributor

@lemz1 lemz1 commented May 31, 2024

this pr adds scripts for note kinds, so we don't have to define the custom behaviour in character or song scripts.
this pr aims to add the functionality described in #2601

NOTE

Since this is a big change to notes, it's probably hard for the @FunkinCrew to review this just by themselves. Any feedback of other contributors or whoever is also appreciated.

TODO

  • make onUpdate work as well
  • make stuff like onUpdate less clunky (thanks @KutikiPlayz )
  • make custom notestyle less clunky
  • make custom note style work in chart editor
  • make custom note style work for hold notes in chart editor
  • fix chart editor note preview
  • update note style of selected notes when changing note kind
  • fix selected hold note when changing notestyles
  • add pixel note style check
  • add custom parameters for the note kinds
  • store param data for each note in charts
  • make custom parameters editable in the chart editor
  • implement String
  • rework code for note params

CUSTOM PARAMETERS

Each note has its own values for the parameters.
For example Play Anim Note:
This note kind could have a parameter animName, which you can set for each note individually. This might be nicer than having 50 different notes for playing custom animations.

Old charts should still work, and not lead to crashes.

EXAMPLE SCRIPT

import funkin.play.notes.notekind.NoteKind;

class Mine extends NoteKind {
  function new() {
    var name:String = 'mine';
    var title:String = 'Mine';
    var noteStyleId:String = 'pixel';
    var params = [
      {
        name: 'mineDamage',
        title: 'Dealt Damage',
        type: 'float',
        min: 0.0,
        max: 2.0,
        step: 0.1,
        precision: 1,
        defaultValue: 2.0
      }
    ];

    super(name, title, noteStyleId, params);
  }

  override function onNoteMiss(event:NoteScriptEvent) {
    event.healthChange = -event.note.getParam('mineDamage');
  }

  override function onUpdate(event:UpdateScriptEvent) {
    for (note in this.getNotes()) {
      note.hsvShader.hue += event.elapsed;
    }
  }
}

PREVIEW

preview.mp4

@lemz1 lemz1 marked this pull request as draft May 31, 2024 18:03
@lemz1
Copy link
Contributor Author

lemz1 commented May 31, 2024

converting this to draft for the time being

@KutikiPlayz
Copy link

could make a function in the NoteKind class that returns an array of all the notes of that kind

  private function getNotesOfKind():Array<NoteSprite>
  {
    var allNotes = PlayState.instance.playerStrumline.notes.members.concat(PlayState.instance.opponentStrumline.notes.members);
    return allNotes.filter(function(note:NoteSprite) {
      return note.noteData.kind == this.noteKind;
    });
  }

that way people at least don't have to manually get the notes (especially if they need all the notes from the opponent as well, that can get pretty long as you can see above)
they'd still have to do the for loop but I don't think there's really a way around that, that is if you don't wanna have to make a specific update event for specifically notes
if you do make a specific update event then you can manually feed in the notes in the event, and any other info you could possibly want

@lemz1 lemz1 marked this pull request as ready for review May 31, 2024 18:34
@lemz1
Copy link
Contributor Author

lemz1 commented May 31, 2024

i guess it can now be reviewed

Copy link
Member

@EliteMasterEric EliteMasterEric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one smaller nitpick but this is extremely useful!

In the future I'd like to add a function, or see someone contribute a function, which lets you override the note graphic based on note kind.

source/funkin/play/PlayState.hx Outdated Show resolved Hide resolved
@EliteMasterEric EliteMasterEric self-assigned this May 31, 2024
@EliteMasterEric EliteMasterEric added type: enhancement Involves an enhancement or new feature. reviewing-internally labels May 31, 2024
@lemz1
Copy link
Contributor Author

lemz1 commented Jun 1, 2024

In the future I'd like to add a function, or see someone contribute a function, which lets you override the note graphic based on note kind.

Im gonna look into it, since hold note assets dont work currently, and that new function could maybe help with that issue

@EliteMasterEric
Copy link
Member

Making it use a different note style is a great idea! This probably won't get into v0.4.0 but this is very exciting.

@nebulazorua
Copy link
Contributor

The Note Style it hink should pull from "chartnotestyle-notekind" notestyle first before pulling from the kind's notestyle. This'd allow you to have like, mine.json as a fallback but then pixel-mine.json to automatically load in a pixel graphic for the mine for songs with the pixel style, for example

@charlesisfeline
Copy link

image

@lemz1
Copy link
Contributor Author

lemz1 commented Jun 11, 2024

hardcoding note style options in dropdown, because i dont want note kind styles to be shown as well

@EliteMasterEric EliteMasterEric added status: reviewing internally Under consideration and testing. and removed reviewing-internally labels Jun 16, 2024
@EliteMasterEric
Copy link
Member

hardcoding note style options in dropdown, because i dont want note kind styles to be shown as well

Won't doing that mean modded note styles won't display anymore?

@KutikiPlayz
Copy link

you should have a check where if the note style has all the asset types filled then it displays in the dropdown, otherwise if it doesn't it wont display
then note kind styles wont be displayed since they probably wouldn't have things like the strum assets

@EliteMasterEric EliteMasterEric removed their assignment Jun 17, 2024
@EliteMasterEric
Copy link
Member

you should have a check where if the note style has all the asset types filled then it displays in the dropdown, otherwise if it doesn't it wont display then note kind styles wont be displayed since they probably wouldn't have things like the strum assets

Pixel inherits some values from the default style.

Now that I think of it, the simplest solution would be to add a "hidden" property to the JSON data that determines whether it shows in the chart editor.

@lemz1
Copy link
Contributor Author

lemz1 commented Jun 18, 2024

Pixel inherits some values from the default style.

Now that I think of it, the simplest solution would be to add a "hidden" property to the JSON data that determines whether it shows in the chart editor.

Currently im checking if it has strum, note and holdnote sprites. If the note style has all of them, then it is shown in the chart editor

But i guess adding a showInEditor property might be better or atleast simpler

@lemz1
Copy link
Contributor Author

lemz1 commented Jun 22, 2024

Should i make the params an Array or a Map

Array might be faster, because there are usually only a few entries in the params

@lemz1 lemz1 changed the title [FEATURE] Note Kind Scripts Note Kind Scripts Jun 22, 2024
@lemz1
Copy link
Contributor Author

lemz1 commented Jun 22, 2024

change to keep in mind (note-data.xml):

From

<grid columns="2" width="100%">

To

<grid id="toolboxNotesGrid" columns="2" width="100%">

@lemz1 lemz1 marked this pull request as draft June 22, 2024 13:38
@lemz1 lemz1 marked this pull request as ready for review June 22, 2024 13:39
@lemz1 lemz1 requested a review from EliteMasterEric June 23, 2024 13:27
@nebulazorua
Copy link
Contributor

I still think that instead of checking for the pixel style in specific, it should just suffix the song's note style so that songs that use modded note styles can have style-specific type graphics.

@lemz1
Copy link
Contributor Author

lemz1 commented Jun 24, 2024

I still think that instead of checking for the pixel style in specific, it should just suffix the song's note style so that songs that use modded note styles can have style-specific type graphics.

Noted, should be a quick addition.

@lemz1
Copy link
Contributor Author

lemz1 commented Jul 23, 2024

Im requesting a review, mainly for the purpose of checking if all other HaxeUI states work, since there might be some new logic that breaks old states.

Although i kind of doubt that they made breaking changes with the newer versions.

By the way the reason for updating to the newer versions is to fix the minimize issue. (The footer was turned visible even though it wasnt supposed to be visible)

@lemz1
Copy link
Contributor Author

lemz1 commented Sep 16, 2024

I guess, I'll just close this, since it has been added internally

@lemz1 lemz1 closed this Sep 16, 2024
@lemz1
Copy link
Contributor Author

lemz1 commented Sep 16, 2024

idk why, but eric is merging a lot of old prs
is it important that they get merged, if yes then i'll just reopen this

i would have thought that it isn't possible to merge old prs, but i guess im just wrong

@lemz1 lemz1 reopened this Sep 16, 2024
@EliteMasterEric
Copy link
Member

I was manually resolving the merges on old PRs

I think this particular one might need to get bumped to v0.5.1 because it includes changes to the note params system that you made after we merged internally

@EliteMasterEric EliteMasterEric added status: reviewing internally Under consideration and testing. and removed status: accepted PR was approved for contribution. If it's not already merged, it may be merged on a private branch. labels Sep 17, 2024
@EliteMasterEric EliteMasterEric changed the title [ENHANCEMENT] Note Kind Scripts [ENHANCEMENT] Additional changes to Note Kind Scripts Sep 17, 2024
@EliteMasterEric EliteMasterEric modified the milestones: 0.5.0, 0.5.1 Sep 17, 2024
@lemz1
Copy link
Contributor Author

lemz1 commented Sep 25, 2024

Im pretty sure the new way of handling params breaks some srcipts, so I guess we need to push this pr to 0.6.0 or later.

@ninjamuffin99 ninjamuffin99 force-pushed the develop branch 2 times, most recently from e0b1b01 to 410cfe9 Compare October 4, 2024 01:25
@github-actions github-actions bot added the pr: haxe PR modifies game code. label Oct 8, 2024
@lemz1 lemz1 force-pushed the note-kind-scripts branch from f89e6ae to 79b80b6 Compare October 9, 2024 23:49
@lemz1 lemz1 changed the base branch from develop to main October 11, 2024 18:04
@lemz1 lemz1 changed the base branch from main to develop October 11, 2024 18:04
@lemz1 lemz1 force-pushed the note-kind-scripts branch 2 times, most recently from 49ecc26 to 85400d5 Compare January 18, 2025 04:55
@AbnormalPoof AbnormalPoof added topic: mods Related to the creation or use of mods. topic: chart editor Related to the operation of the Chart Editor. labels Jan 22, 2025
@lemz1 lemz1 force-pushed the note-kind-scripts branch from 85400d5 to 3b4dbae Compare January 22, 2025 21:11
@AbnormalPoof AbnormalPoof removed the topic: mods Related to the creation or use of mods. label Jan 23, 2025
@lemz1 lemz1 force-pushed the note-kind-scripts branch from 3b4dbae to 2edd465 Compare January 23, 2025 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: haxe PR modifies game code. size: large A large pull request with more than 100 changes. status: reviewing internally Under consideration and testing. topic: chart editor Related to the operation of the Chart Editor. type: enhancement Involves an enhancement or new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants