Skip to content

Commit

Permalink
More scripted class character animation
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteMasterEric committed Sep 20, 2024
1 parent a93d283 commit 09dd415
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/21-scripted-classes/21-00-scripted-classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
3 changes: 1 addition & 2 deletions src/21-scripted-classes/21-01-scripted-songs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
32 changes: 32 additions & 0 deletions src/21-scripted-classes/21-05-scripted-characters.md
Original file line number Diff line number Diff line change
@@ -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.
35 changes: 35 additions & 0 deletions src/21-scripted-classes/21-10-scripted-playable-characters.md
Original file line number Diff line number Diff line change
@@ -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');
}
```

0 comments on commit 09dd415

Please sign in to comment.