Difference between revisions of "Modding:Event data"

From Stardew Valley Wiki
Jump to navigation Jump to search
Line 528: Line 528:
 
|-
 
|-
 
| <tt>viewport move {{t|x}} {{t|y}} {{t|duration}}</tt>
 
| <tt>viewport move {{t|x}} {{t|y}} {{t|duration}}</tt>
| Pan the the camera for the given duration in milliseconds until it's centered on the given X, Y tile position.
+
| Pan the the camera in the direction (and with the velocity) defined by ''x/y'' for the given duration in milliseconds. Example: ''"viewport move 2 -1 5000"'' moves the camera 2 pixels right and 1 pixel up for 5 seconds.
 
|-
 
|-
 
| <tt>viewport {{t|x}} {{t|y}} [true [unfreeze]&#124;clamp [true&#124;unfreeze]]</tt>
 
| <tt>viewport {{t|x}} {{t|y}} [true [unfreeze]&#124;clamp [true&#124;unfreeze]]</tt>

Revision as of 18:07, 2 September 2018

Index

This page explains how the game stores and parses event data. This is an advanced guide for mod developers.

Source

Events are stored in Content\Data\Events\*.xnb (one file per location), which can be unpacked using XNB Extract.

Here's the raw data for saloon events as of 1.3.27 for reference (excluding XNB headers):

Event preconditions

Each event has a key which includes an event ID and any preconditions. Event preconditions include any number of the following arguments (separated by /). For example, Clint's Saloon heart event preconditions are 97/f Clint 750/t 1900 2300/d Tue Wed Thu Fri Sat Sun, which (per the tables below) means event #97, requires 3 hearts with Clint, between 7pm and 11pm on Monday.

Notes:

  • 'NPC name' means their internal English name, not the translatable display name.
  • Most text is case-sensitive (e.g. Mon is not the same as mon).
  • The game's logic for these codes is in GameLocation::checkEventPrecondition.

Context

These check the current time, date, weather, etc. They're not player-specific.

syntax precondition
A <dialogue ID> The special dialogue event with the given ID is not in progress. This can be a custom event ID, but these are the in-game IDs: cc_Boulder, cc_Bridge, cc_Bus, cc_Greenhouse, cc_Minecart, dumped_Girls, dumped_Guys, Introduction, joja_Begin, pamHouseUpgrade, pamHouseUpgradeAnonymous, secondChance_Girls, secondChance_Guys, willyCrabs.
F Today is not a festival day.
d <day of week> Today is not one of the specified days (may specify multiple days). Valid values: Mon, Tue, Wed, Thu, Fri, Sat, Sun.
r <number> A random probability check, where <number> is the probability between 0 and 1 (e.g. 0.2 for 20% chance).
v <name> The specified NPC is not invisible (regardless of whether they're on-screen).
w <weather> Current weather matches <weather>. Valid values: rainy, sunny.
y <year> If <year> is 1, must be in the first year. Otherwise, year must be at least this value.
z <season> Current season is not <season>.

Current player

These check the current player (the one playing this instance of the game).

syntax precondition
D <name> Current player is dating the given NPC name.
J Current player has finished the Joja Warehouse.
M <number> Current player has at least this much money.
S <secret note ID> Current player has seen the Secret Note with the given ID.
a <x> <y> Current player is on that tile position.
b <number> Current player has reached the bottom floor of the Mines at least that many times.
c <number> Current player has at least that many free inventory slots.
e <event ID> Current player has seen the specified event (may contain multiple event IDs).
f <name> <number> Current player has at least <number> friendship points with the <name> NPC. Can specify multiple name and number pairs, in which case the player must meet all of them.
g <gender> Current player is the specified gender (male or female).
h <pet> Current player does not already have a pet, and their preference matches <pet> ("cat" or "dog").
i <item ID> Current player has specified item in their inventory.
j <number> Current player has played more than <number> days.
k <event ID> Current player has not seen that event (may contain multiple event IDs).
l <letter ID> Current player has not received that mail letter or non-mail flag.
m <number> Current player has earned at least this much money (regardless of how much they currently have).
n <letter ID> Current player has received that mail letter or non-mail flag.
o <name> Current player is not married to that NPC.
p <name> Specified NPC is in the current player's location.
q <dialogue ID> Current player has chosen the given answer in a dialogue. May contain multiple dialogue IDs, in which case they must all have been selected.
s <item ID> <number> Current player has shipped at least <number> of the specified item. Can specify multiple item and number pairs, in which case all of them must be met.
t <min time> <max time> Current time is between between the specified times.
u <day of month> Current day of month is one of the specified values (may contain multiple days).
x <event ID> <letter ID> For the current player: mark the specified ID as seen, add the specified letter to tomorrow's mail, then return false (so the event doesn't trigger).

Host player

These check the host player (the one running a multiplayer farm, not necessarily the current player). If single-player, this is always the current player.

syntax precondition
C Host player has not finished the community center, or has not seen the grand reopening yet.
H Current player is the host player.
Hl <letter ID> Host player has not received that mail letter or non-mail flag.
Hn <letter ID> Host player has received that mail letter or non-mail flag.
*l <letter ID> Host player and current player have not received that mail letter or non-mail flag.
*n <letter ID> Host player and current player have received that mail letter or non-mail flag.

Event scripts

Basic format

Each event has a value which is the event script. This specifies what happens in the event — everything from lighting and music to NPC movement and dialogue. The script consists of multiple commands separated by / characters.

Every script must start with three commands in this exact order:

index syntax description
0 <music ID> The background music to play. Some example values are jaunty, ocean, and rain.
1 <x> <y> The tile coordinates the camera should center on at the start of the event.
2 <npc ID> <x> <y> <direction> Initialises an NPC's starting tile position and direction. The NPC ID can be farmer or an NPC name like Abigail.

Those three commands may be followed by any sequence of the following commands:

command description
addBigProp <x> <y> <object ID> Adds an object at the specified tile.
addCookingRecipe <recipe> Adds the specified cooking recipe to the player.
addCraftingRecipe <recipe> Adds the specified crafting recipe to the player.
addFloorProp <prop index> <x> <y> [solid width] [solid height] [display height] Add a non-solid prop from the current festival texture. Default solid width/height is 1. Default display height is solid height.
addLantern <row in texture> <x> <y> <light radius> Adds a glowing temporary sprite.
addMailReceived <letter ID> Set a letter as received.
addObject <row in texture> <x> <y> Adds a temporary sprite at the specified tile.
addProp <prop index> <x> <y> [solid width] [solid height] [display height] Add a solid prop from the current festival texture. Default solid width/height is 1. Default display height is solid height.
addQuest <quest ID> Add the specified quest to the quest log.
addTemporaryActor <character> <sprite width> <sprite height> <tile x> <tile y> <facing> [breather] [Character|Animal|Monster] [animal name] Add a temporary actor. 'breather' is boolean. The category determines where the texture will be loaded from, default is Character. Animal name only applies to animal.
addToTable <x> <y> <object ID> Places on object on the furniture at a position. If the location is FarmHouse, then it will always be placed on the initial table.
addTool <Sword|Wand> Adds either a Battered Sword or Return Scepter (teleports you to your farm, unobtainable in vanilla) to the player's inventory.
advancedMove <npc> <loop> <x y>... Set multiple movements for an NPC. You can set True to have NPC walk the path continuously. Example: /advancedMove Robin false 0 3 2 0 0 2 -2 0 0 -2 2 0/
ambientLight <r> <g> <b> Modifies the ambient light level. Note that it appears to work by removing colors from the existing light ambience, so /ambientLight 1 80 80/ would reduce green and blue and leave the light with a reddish hue. Further testing required.
animalNaming Show the animal naming menu if no other menu is open. Uses the current location as Coop. Appears to only work for 'hatched' animals.
animate <actor> <flip> <loop> <frame duration> <frames...> Animate a named actor, using the one or more <frames> from their spritesheet, for <frame duration> milliseconds per frame. <flip> indicates whether to flip the sprites along the Y axis; <loop> indicates whether to repeat the animation.
attachCharacterToTempSprite <actor> Attach an actor to the most recent temporary sprite.
awardFestivalPrize Awards the festival prize to the winner for the easter egg hunt and ice fishing contest.
awardFestivalPrize <item type> Awards the specified item to the player. Possible item types are "pan", "sculpture", "rod", "sword", "hero", "joja", and "slimeegg".
bloom <threshold> <blur> <bloom intensity> <base intensity> <bloom saturation> <base saturation> [whiteOnly] Sets the current bloom settings. If 'whiteOnly' is not empty, then BloomSettings.brightWhiteOnly is true.
catQuestion Trigger question about adopting your pet.
cave Trigger the question for the farm cave type. This will work again later, however changing from bats to mushrooms will not remove the mushroom spawning objects.
changeLocation <location> Change to another location and run the remaining event script there.
changeMapTile <layer> <x> <y> <tile index> Change the specified tile to a particular value.
changePortrait <npc> <portrait> Change the NPC's portrait to be from "Portraits/<actor>_<sprite&gt".
changeSprite <actor> <sprite> Change the actor's sprite to be from "Characters/<actor>_<sprite>".
changeToTemporaryMap <map> [pan] Change the location to a temporary one loaded from the map file specified by <map>. The [pan] argument indicates the tile coordinates to pan to (defaults to 0, 0).
changeYSourceRectOffset <npc> <offset> Change the NPC's vertical texture offset (?).
characterSelect Seemingly unused. Sets Game1.gameMode to 5 and Game1.menuChoice = 0.
cutscene <cutscene> Activate a cutscene. See cutscene list. (TODO: Pull list from my event editor)
doAction <x> <y> TODO: Explain GameLocation.checkAction(new Location(x,y), viewport, player)
elliotbooktalk Elliot book talk.
emote <actor> <emote ID> Make the given NPC name perform an emote, which is a little icon shown above the NPC's head. Emotes are stored in Content\TileSheets\emotes.xnb (see list of emotes).
end Ends the current event by fading out, then resumes the game world and places the player on the square where they entered the zone.
end position <x> <y> Ends the current event by fading out, then resumes the game world and places the player on the coordinates specified in x y.
end newDay Ends the current event by fading out, then ends the day (saving the game, selling everything in the sell box, etc).
end dialogue <NPC> <\"Text for next chat\"> Ends the current event by fading out, then resumes the game world and places the player on the square where they entered the zone. Additionally, the NPC will say the line(s) specified at the end of the command. Example usage: end dialogue Abigail \"It was fun talking to you today.$h\"
extendSourceRect <actor> reset Resets the actors sprite.
extendSourceRect <actor> <horizontal> <vertical> [ignoreUpdates] TODO: Explain Character.extendSourceRect
eyes <eyes> <blink> Change the player's eyes.
faceDirection <actor> <direction> [continue] Make a named NPC face a direction. If no parameter is supplied for [continue], the game will pause.
fade [fadeOut] If 'fadeOut' is not specified, it will fade in. (?)
farmerAnimation <anim> Sets the farmer's current animation.
farmerEat <object ID> Make the player eat an object
fork <event ID> [req] End the current command script and starts a different script with the given ID, but only if the [req] condition is met. The [req] condition can be a mail ID or dialogue answer ID; if not specified, it checks if the specialEventVariable1 variable was set (e.g. by a question command). The new script should have the same format as a normal event script, but without the mandatory three start fields.
friendship <npc> <amount> Add the given number of friendship points with the named NPC. (There are 250 points per heart.)
globalFade [speed] Fade to black at a particular speed (default 0.007). If no speed is specified, the event will continue immediately; otherwise, it will continue after the fade is finished. The fade effect disappears when this command is done; to avoid that, use the viewport command to move the camera off-screen.
globalFadeToClear [speed] Fade to clear (unfade?) at a particular speed (default 0.007). If no speed is specified, the event will continue immediately; otherwise, it will continue after the fade is finished.
glow <r> <g> <b> <hold> Make the screen glow once. TODO: Explain hold (true/false).
grabObject <object ID> Causes the player to hold an object.
grandpaCandles Do grandpa candles
grandpaEvaluation Do grandpa evaluation
grandpaEvaluation2 Do grandpa evaluation (manually resummoned)
halt Make everyone stop.
hospitaldeath
itemAboveHead [type] Show an item above the player's head. The [type] can be "pan", "hero", "sculpture", "joja", "slimeEgg", "rod", "sword", or "ore". If no item is specified, then they will 'hold' nothing?
jump <actor> [intensity] Make a the named NPC jump. The default intensity is 8.
loadActors <layer> Load the actors from a layer in the map file.
mail <letter ID> Queue a letter to be received tomorrow (see Content\Data\mail.xnb for available mail).
message "<text>" Show a dialogue box (no speaker). See dialogue format for the <text> format.
minedeath TODO.
move <actor> <x> <y> <facing> <continue> Make a named NPC move by the given tile offset from their current position (along one axis only), and face the given direction when they're done. To move along multiple axes, you must specify multiple move commands. By default the event pauses while a move command is occurring, but if <continue> is set to true the movement is asynchronous and will run simultaneously with other event commands.
pause <duration> Pause the game for the given number of milliseconds.
pixelZoom <zoom> Sets the current pixel zoom.
playMusic <track> Play the specified music track ID. If the track is 'samBand', the track played will change depend on certain dialogue answers (76-79).
playSound <sound> Play a given sound ID from the game's sound bank.
playerControl Give the player control back.
positionOffset <actor> <x> <y> Offset the position of the named NPC by the given number of pixels. This happens instantly, with no walking animation.
proceedPosition <actor> TODO: Explain
question null "<question>#<answer1>#<answer2>" Show a dialogue box with some answers and an optional question. When the player chooses an answer, the event script continues with no other effect.
question fork<answer index> "<question>#<answer 0>#<answer 1>#..." Show a dialogue with some answers and an optional question. When the player chooses the answer matching the fork<answer index> (like fork0 for the first answer), the specialEventVariable1 variable is set. Usually followed by a fork command.
removeItem <object ID> Remove the first of an object from a player's inventory.
removeObject <x> <y> Remove the prop at a position.
removeQuest <quest ID> Remove the specified quest from the quest log.
removeSprite <x> <y> Remove the temporary sprite at a position.
removeTemporarySprites Remove all temporary sprites.
removeTile <x> <y> <layer> Remove a tile from the specified layer.
resetVariable Set the first event variable to false.
rustyKey Gives the player the rusty key. (Sewer key)
screenFlash <alpha> Game1.flashAlpha = alpha;
setRunning Set the player as running.
shake <actor> <duration> Shake the named NPC for the given number of milliseconds.
showFrame farmer flip Flip the farmer's current sprite along the Y axis. TODO: Behavior with farmer looks strange?
showFrame <actor> <frame ID> Set the named NPC's current frame in their Content\Characters\*.xnb spritesheet. Note that setting the farmer's sprite only changes parts of the sprite (some times arms, some times arms and legs and torso but not the head, etc). To avoid this problem use faceDirection farmer <0/1/2/3> to first rotate the farmer in the proper direction, then modify the sprite with showFrame.
showRivalFrame <frame> Set the 'rival' actor's sprite to a specific frame.
skippable Allow skipping this event.
speak <character> "<text>" Show dialogue text from a named NPC; see dialogue format.
specificTemporarySprite <sprite> [other params] Shows the given temporary sprite. Parameters change depending on the sprite.
speed farmer <modifier> Add a speed modifier to the farmer. TODO: for the next action only?
speed <actor> <speed> Sets the named NPC's speed (default speed is 3). Not applicable to the farmer. TODO: for the next action only?
splitSpeak <actor> "<text>" Dialogue, but chosen based on previous answer. ('~' is the separator used.)
startJittering Make the player start jittering.
stopAdvancedMoves Stop movement from advancedMove.
stopAnimation farmer Stop the farmer's current animation.
stopAnimation <actor> <end frame> Stop the named NPC's current animation. Not applicable to the farmer.
stopGlowing Make the screen stop glowing.
stopJittering Make the player stop jittering.
stopMusic Stop any currently playing music.
stopRunning Make the farmer stop running.
stopSwimming <actor> Make an actor stop swimming.
swimming <actor> Make an actor start swimming.
switchEvent <event ID> Changes the current event (ie. event commands) to another event in the same location.
taxvote Trigger voting for or against a 3% shipping tax. (No effect on game?)
temporarySprite <x> <y> <row in texture> <animation length> <animation interval> <flipped> <loop count> Create a temporary sprite with the given parameters.
textAboveHead <actor> "<text>" Show a small text bubble over the named NPC's head with the given text; see dialogue format.
tutorialMenu Show the tutorial menu if no other menu is open.
updateMinigame <event data> Send an event to the current minigame.
viewport move <x> <y> <duration> Pan the the camera in the direction (and with the velocity) defined by x/y for the given duration in milliseconds. Example: "viewport move 2 -1 5000" moves the camera 2 pixels right and 1 pixel up for 5 seconds.
viewport <x> <y> [true [unfreeze]|clamp [true|unfreeze]] Instantly reposition the camera to center on the given X, Y tile position. TODO: explain other parameters.
waitForKey <key> <message on finish> TODO: Explain
waitForOtherPlayers Wait for other players (vanilla MP).
warp <actor> <x> <y> Warp the named NPC to a position to the given X, Y tile coordinate. This can be used to warp characters off-screen.
weddingSprite <frame> Sets the actor known as 'WeddingOutfits' to a particular frame.

Directions

When event commands refer to a facing direction, they'll use one of these values:

Value Meaning
0 looking up
1 looking right
2 looking down
3 looking left

Dialogue format

See Modding:Dialogue#Format.

See also