Skip to content

Commit 09dd415

Browse files
More scripted class character animation
1 parent a93d283 commit 09dd415

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed

src/21-scripted-classes/21-00-scripted-classes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ There is a predefined list of classes which the game has set up to be scriptable
3030
- `funkin.play.character.MultiSparrowCharacter` is used for characters that have several Sparrow spritesheet animations to combine into one character.
3131
- `funkin.play.character.PackerCharacter` is used for characters that have Packer spritesheet animations.
3232
- `funkin.play.character.AnimateAtlasCharacter` is used for characters that have Adobe Animate texture atlases.
33+
- `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.
3334
- `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).
3435
- `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).
3536
- `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).

src/21-scripted-classes/21-01-scripted-songs.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ class BallisticSong extends Song {
2121
}
2222
```
2323

24-
You can then add override functions to perform custom behavior. Here are some useful snippets:
25-
24+
You can then add override functions to perform custom behavior.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
11
# Creating a Friday Night Funkin' Mod - Scripted Characters
22

33
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.
4+
5+
Start by creating a scripted class file with the `.hxc` extension (in the `mods/mymod/scripts/characters` if you want to keep things organized).
6+
7+
```haxe
8+
// Remember to import each class you want to reference in your script!
9+
import funkin.play.character.SparrowCharacter;
10+
11+
// Choose a name for your scripted class that will be unique, and make sure to specifically extend the correct character class.
12+
// SparrowCharacter is the one to use for XML-based characters.
13+
// This class's functions will override the default behavior for the character.
14+
class WhittyCharacter extends SparrowCharacter {
15+
public function new() {
16+
// The constructor gets called whenever the character is spawned.
17+
// The constructor takes one parameter, which is the song ID for the song you are applying the script to.
18+
super('whitty');
19+
}
20+
21+
// Add override functions here!
22+
}
23+
```
24+
25+
You can then add override functions to perform custom behavior.
26+
27+
## Character Classes
28+
29+
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.
30+
31+
- `funkin.play.character.SparrowCharacter` is used for characters that have Sparrow spritesheet animations.
32+
- `funkin.play.character.MultiSparrowCharacter` is used for characters that have several Sparrow spritesheet animations to combine into one character.
33+
- `funkin.play.character.PackerCharacter` is used for characters that have Packer spritesheet animations.
34+
- `funkin.play.character.AnimateAtlasCharacter` is used for characters that have Adobe Animate texture atlases.
35+
- `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.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
11
# Creating a Friday Night Funkin' Mod - Scripted Playable Characters
22

33
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.
4+
5+
Start by creating a scripted class file with the `.hxc` extension (in the `mods/mymod/scripts/characters` if you want to keep things organized).
6+
7+
```haxe
8+
// Remember to import each class you want to reference in your script!
9+
import funkin.play.character.SparrowCharacter;
10+
11+
// Choose a name for your scripted class that will be unique, and make sure to specifically extend the correct character class.
12+
// SparrowCharacter is the one to use for XML-based characters.
13+
// This class's functions will override the default behavior for the character.
14+
class WhittyCharacter extends SparrowCharacter {
15+
public function new() {
16+
// The constructor gets called whenever the character is spawned.
17+
// The constructor takes one parameter, which is the song ID for the song you are applying the script to.
18+
super('whitty');
19+
}
20+
21+
// Add override functions here!
22+
}
23+
```
24+
25+
You can then add override functions to perform custom behavior.
26+
27+
## Custom Unlock Behavior
28+
29+
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.
30+
31+
```haxe
32+
// An example of overriding the `isUnlocked` function.
33+
// This is the logic for Pico, which requires checking the completion status of a given story week.
34+
// You can put any logic you want here.
35+
override function isUnlocked():Bool {
36+
return Save.instance.hasBeatenLevel('weekend1');
37+
}
38+
```

0 commit comments

Comments
 (0)