Moosh's NPC Script
Overview
Creator:
Moosh
Updated: 02 Dec 2021
Tags:
FFC
Downloads: 439
|
View Script
Download Example (1.55 MB) |
Information
I made this script as an alternative to an older script by Lemmy Koopa. The script lets you have NPCs that you can talk to as well as NPCs that block your path and appear and disappear depending on what items you have. It also did away with a pretty serious bug that allowed sequence breaking.
Update: Added simplified version of the script and an example add-on script for trade sequences.
Update: Added simplified version of the script and an example add-on script for trade sequences.
Description Setup Reviews Comments
Settings Constants:
This is the original full NPC script with all the fancy features.
Constants:
Set LAYER_NPC to 1 or 2 depending on which layer you want to use for NPC solidity. (Or you can use -1 to use it like an old fashioned NPC script where you set the solidity yourself)
Set CMB_NPC_HIDDEN to an invisible combo with no solidity.
Set CMB_NPC_SOLID to an invisible combo that's fully solid
Set LAYER_NPC_CANTALK, CMB_NPC_CANTALK, and CS_NPC_CANTALK to the layer, combo, and CSet the speech icon should appear in.
Placement:
Place FFCs on the 16*16 pixel grid. You can select View->Show Grid or press the ~ key to make the grid visible.
Be sure that you have the Run Script at Screen Init FFC flag checked and the Messages Freeze All Action and Messages Disappear quest rules checked.
FFC Arguments:
This is a simplified version of the original script with the extra stuff stripped off. It doesn't do automatic solidity, moving NPCs or appearing/disappearing NPCs, but it's more flexible for attaching scripts to because it can pass all its extra arguments to them.
Constants:
Set LAYER_NPC_CANTALK, CMB_NPC_CANTALK, and CS_NPC_CANTALK to the layer, combo, and CSet the speech icon should appear in.
Placement:
Place FFCs on the 16*16 pixel grid. You can select View->Show Grid or press the ~ key to make the grid visible. Since this version doesn't have the automatic solidity, you'll have to place down solid combos under it yourself.
FFC Arguments:
This is an example of an add-on script that can be called by the simplified NPC script. It makes an NPC that takes one of your items, gives you a new one with a hold up animation, and remembers that you've traded with it.
Constants:
Set D_TRADE to an unused Screen->D value 0-7 if you have other scripts using Screen->D.
Setup:
Instead of being placed on the screen as an FFC, this script is called by another FFC using the NPCScript_Simple script. Set D1 on that FFC to this script's slot and D2-D6 to this script's D0-D4.
FFC Arguments:
- RESET_NPC_LAYER_ON_ENTRY: If set to 1, the script will reset NPC solidity when entering a screen. This fixes screens that share layer screens.
- NPCSCRIPT_ITEMCHECK_ONLY_UPDATES_ON_SCREEN_ENTRY: If set to 1, NPCs that disappear when Link collects an item on the same screen won't disappear until you scroll off the screen.
- NPCSCRIPT_WAITS_UNTIL_SCRIPTS_FINISH: If set to 1, FFC scripts run by the NPC script will interrupt the NPC script running until they finish. This prevents talking to the NPC while these scripts are running.
This is the original full NPC script with all the fancy features.
Constants:
Set LAYER_NPC to 1 or 2 depending on which layer you want to use for NPC solidity. (Or you can use -1 to use it like an old fashioned NPC script where you set the solidity yourself)
Set CMB_NPC_HIDDEN to an invisible combo with no solidity.
Set CMB_NPC_SOLID to an invisible combo that's fully solid
Set LAYER_NPC_CANTALK, CMB_NPC_CANTALK, and CS_NPC_CANTALK to the layer, combo, and CSet the speech icon should appear in.
Placement:
Place FFCs on the 16*16 pixel grid. You can select View->Show Grid or press the ~ key to make the grid visible.
Be sure that you have the Run Script at Screen Init FFC flag checked and the Messages Freeze All Action and Messages Disappear quest rules checked.
FFC Arguments:
- D0: Set this to the string that should play when you talk to the NPC.
- D1: Set this to the item that makes the NPC disappear. Make the number negative to make the NPC appear when you have the item instead.
- D2: Set this to the type of NPC it will be:
- 0 - None - Does nothing special
- 1 - Face Link - Faces Link when you get close (the FFC's combo should be the first of four facing: Up, Down, Left, Right)
- 2 - Guard H - Follows Link on the X-Axis
- 3 - Guard V - Follows Link on the Y-Axis
- D3: Argument 1 for the NPC's movement type:
- None - Does nothing
- Face Link - Default direction the NPC should face (You can set this to 4 to give it a custom default state)
- Guard H - Min X position in tiles
- Guard V - Min Y position in tiles
- D4: Argument 2 for the NPC's movement type:
- None - Does nothing
- Face Link - Distance in pixels at which the NPC will turn to face Link
- Guard H - Max X position in tiles
- Guard V - Max Y position in tiles
- D5: Set this to 1 if you don't want the NPC to be solid.
- D6: Set this to a number greater than 0 to call that script when you talk to the NPC
- D7: Argument D0 for the FFC script called by D6
This is a simplified version of the original script with the extra stuff stripped off. It doesn't do automatic solidity, moving NPCs or appearing/disappearing NPCs, but it's more flexible for attaching scripts to because it can pass all its extra arguments to them.
Constants:
Set LAYER_NPC_CANTALK, CMB_NPC_CANTALK, and CS_NPC_CANTALK to the layer, combo, and CSet the speech icon should appear in.
Placement:
Place FFCs on the 16*16 pixel grid. You can select View->Show Grid or press the ~ key to make the grid visible. Since this version doesn't have the automatic solidity, you'll have to place down solid combos under it yourself.
FFC Arguments:
- D0: Set this to the string that should play when you talk to the NPC.
- D1: Set this to a number greater than 0 to call that script when you talk to the NPC.
- D2-D7: If you call a script with D1, these work as that script's D0-D5.
This is an example of an add-on script that can be called by the simplified NPC script. It makes an NPC that takes one of your items, gives you a new one with a hold up animation, and remembers that you've traded with it.
Constants:
Set D_TRADE to an unused Screen->D value 0-7 if you have other scripts using Screen->D.
Setup:
Instead of being placed on the screen as an FFC, this script is called by another FFC using the NPCScript_Simple script. Set D1 on that FFC to this script's slot and D2-D6 to this script's D0-D4.
FFC Arguments:
- D0: The item ID of the item to check for in the trade.
- D1: The item ID of the item to give in the trade
- D2: The string that plays when the player doesn't have the required item
- D3: The string that plays when the player has the required item
- D4: The string that plays when the player talks to the NPC again after making the trade




