diff --git a/src/21-scripted-classes/21-00-scripted-classes.md b/src/21-scripted-classes/21-00-scripted-classes.md index 42910b2..a4364b2 100644 --- a/src/21-scripted-classes/21-00-scripted-classes.md +++ b/src/21-scripted-classes/21-00-scripted-classes.md @@ -30,6 +30,7 @@ There is a predefined list of classes which the game has set up to be scriptable - `funkin.play.character.MultiSparrowCharacter` is used for characters that have several Sparrow spritesheet animations to combine into one character. - `funkin.play.character.PackerCharacter` is used for characters that have Packer spritesheet animations. - `funkin.play.character.AnimateAtlasCharacter` is used for characters that have Adobe Animate texture atlases. + - `funkin.play.character.BaseCharacter` has empty stubs for all the rendering and animation handlers, and is only useful for people who want to reimplement their character's animation system by hand. - `funkin.play.stage.Stage` for providing unique behavior to custom stages, such as creating custom moving props and defining when props animate or when sound effects play in sync with the stage. See [Scripted Stages](21-scripted-classes/24-06-scripted-stages.md). - `funkin.ui.story.Level` for providing unique behavior to levels in Story Mode. See [Scripted Story Levels](21-scripted-classes/25-07-scripted-story-levels.md). - `funkin.play.notes.notekind.NoteKind` for providing unique visuals and behavior to certain kinds of notes, which can then be placed in the Chart Editor. See [Custom Note Kinds](21-scripted-classes/26-00-custom-note-kinds.md). diff --git a/src/21-scripted-classes/21-01-scripted-songs.md b/src/21-scripted-classes/21-01-scripted-songs.md index 696c541..26f07ac 100644 --- a/src/21-scripted-classes/21-01-scripted-songs.md +++ b/src/21-scripted-classes/21-01-scripted-songs.md @@ -21,5 +21,4 @@ class BallisticSong extends Song { } ``` -You can then add override functions to perform custom behavior. Here are some useful snippets: - +You can then add override functions to perform custom behavior. diff --git a/src/21-scripted-classes/21-05-scripted-characters.md b/src/21-scripted-classes/21-05-scripted-characters.md index 60f430f..2ea6f60 100644 --- a/src/21-scripted-classes/21-05-scripted-characters.md +++ b/src/21-scripted-classes/21-05-scripted-characters.md @@ -1,3 +1,35 @@ # Creating a Friday Night Funkin' Mod - Scripted Characters This chapter will walk you through the process of adding a script to a Character, and giving examples of the kind of custom behavior which can be implemented with this functionality. + +Start by creating a scripted class file with the `.hxc` extension (in the `mods/mymod/scripts/characters` if you want to keep things organized). + +```haxe +// Remember to import each class you want to reference in your script! +import funkin.play.character.SparrowCharacter; + +// Choose a name for your scripted class that will be unique, and make sure to specifically extend the correct character class. +// SparrowCharacter is the one to use for XML-based characters. +// This class's functions will override the default behavior for the character. +class WhittyCharacter extends SparrowCharacter { + public function new() { + // The constructor gets called whenever the character is spawned. + // The constructor takes one parameter, which is the song ID for the song you are applying the script to. + super('whitty'); + } + + // Add override functions here! +} +``` + +You can then add override functions to perform custom behavior. + +## Character Classes + +If you use a different animation type for a character, you need to specify a different base script class, otherwise the character will fail to load. + +- `funkin.play.character.SparrowCharacter` is used for characters that have Sparrow spritesheet animations. +- `funkin.play.character.MultiSparrowCharacter` is used for characters that have several Sparrow spritesheet animations to combine into one character. +- `funkin.play.character.PackerCharacter` is used for characters that have Packer spritesheet animations. +- `funkin.play.character.AnimateAtlasCharacter` is used for characters that have Adobe Animate texture atlases. +- `funkin.play.character.BaseCharacter` has empty stubs for all the rendering and animation handlers, and is only useful for people who want to reimplement their character's animation system by hand. \ No newline at end of file diff --git a/src/21-scripted-classes/21-10-scripted-playable-characters.md b/src/21-scripted-classes/21-10-scripted-playable-characters.md index b43fc8e..977db69 100644 --- a/src/21-scripted-classes/21-10-scripted-playable-characters.md +++ b/src/21-scripted-classes/21-10-scripted-playable-characters.md @@ -1,3 +1,38 @@ # Creating a Friday Night Funkin' Mod - Scripted Playable Characters This chapter will walk you through the process of adding a script to a Playable Character, and giving examples of the kind of custom behavior which can be implemented with this functionality. + +Start by creating a scripted class file with the `.hxc` extension (in the `mods/mymod/scripts/characters` if you want to keep things organized). + +```haxe +// Remember to import each class you want to reference in your script! +import funkin.play.character.SparrowCharacter; + +// Choose a name for your scripted class that will be unique, and make sure to specifically extend the correct character class. +// SparrowCharacter is the one to use for XML-based characters. +// This class's functions will override the default behavior for the character. +class WhittyCharacter extends SparrowCharacter { + public function new() { + // The constructor gets called whenever the character is spawned. + // The constructor takes one parameter, which is the song ID for the song you are applying the script to. + super('whitty'); + } + + // Add override functions here! +} +``` + +You can then add override functions to perform custom behavior. + +## Custom Unlock Behavior + +The most important thing to override here is the `isUnlocked` function, which lets you define whether the player can access the given character in Freeplay. + +```haxe + // An example of overriding the `isUnlocked` function. + // This is the logic for Pico, which requires checking the completion status of a given story week. + // You can put any logic you want here. + override function isUnlocked():Bool { + return Save.instance.hasBeatenLevel('weekend1'); + } +```