Stardew Valley
0 of 0

File information

Last updated

Original upload

Created by

Datamancer

Uploaded by

Datamancer1110

Virus scan

Safe to use

About this mod

Makes map tiles dynamic - change tile, tile sheet, and properties on-the-fly; tiles can be pushed and blown up; heal or hurt; give items and money; play sounds and change music; show custom events; trigger buffs, debuffs, emotes, and teleports; speed up, slow down, and move farmers; and more!

Originally created by Aedenthorn

Requirements
Permissions and credits
Changelogs
Donations
This mod was originally created by Aedenthorn

I've merely updated it for SDV 1.6. This is a fairly complex mod, and if I'm understanding the scene correctly, some of the sprite maps may have changed, meaning some of this stuff (read: any of it, really) might not work as expected.

Still, I did my best, and I will continue to do my best to support this mod moving forward.

The only major difference regarding functionality is that Chests can no longer contain money as of SDV 1.6 - entries that attempt to do so will be ignored (as far as I know). It would be best to remove them.

Any support of any nature is appreciated. If you feel moved to support me financially (which, please feel no obligation to do so), I have a Ko-fi

Original description, as written by Aedenthorn (who truly deserves all the credit) follows:

This mod is a framework that lets you easily create dynamic game mechanics simply by assigning tile properties to individual map tiles.

Functionality currently includes:

  • changing the tile index of one or more tiles (works with animated tiles)
  • changing tile properties of one or more tiles
  • allowing a tile to be destroyed by bombs
  • causing an explosion
  • allowing a tile to be pushed
  • playing a sound
  • playing a temporary sprite animation
  • instantly teleporting a farmer to anywhere on the map
  • giving an item
  • taking the held object
  • spawning a chest
  • showing a message
  • playing a custom event string
  • setting a mail flag
  • invalidating an asset
  • changing the music
  • healing or damaging a farmer's health or stamina all at once or over time
  • applying a buff to a farmer
  • modifying a farmer's movement speed while on a tile
  • moving a farmer in a direction while on a tile
  • making a farmer emote
  • making a tile slippery


Here's two videos showing examples of some of the above:





An example of a mod that uses this framework is Chest Room for Additional Mine Maps.


Setting Tile Properties

The simplest way to implement this mod's features is using Content Patcher to modify map tile properties. E.g.:

{
    "Format": "1.23.0",
    "Changes": [
        {
            "Action": "EditMap",
            "Target": "Maps/Farm",
            "MapTiles": [
                {
                    "Position": { "X": 72, "Y": 15 },
                    "Layer": "Back",
                    "SetProperties": {
                        "DMT/changeIndexOn": "69"
                    }
                }
            ]
        },
    ]
}

This changes the tile index of 72,15 on the Farm to 69 when the farmer steps on it.

This mod also offers a means of adding tile properties automatically using Content Patcher:

{
"Format": "1.23.0",
"Changes": [
{
"Action": "EditData",
"Target": "aedenthorn.DynamicMapTiles/dictionary",
"Entries": {
"aedenthorn.IceTiles": {
"locations": [
"Forest"
],
"layers": [
"Back"
],
"tileSheets": [
"fest"
],
"tileSheetPaths": [
"Festivals"
],
"indexes": [
226,
227
],
"rectangles": [
{
"X": 0,
"Y": 0,
"Width": 100,
"Height": 100,
}
],
"properties": {
"DMT/slippery": "0.25"
}
}
}
}
]
}

This example sets the property DMT/slippery to 0.25 on all tiles that fit the parameters above (in Forest, on Back layer, with indexes 226 and 227 on tilesheet "fest" with path containing "Festivals", with x and y coordinates within the given rectangle). Any parameter can be omitted if not used.


Key Triggering


Trigger Once

Any of the property keys below can be suffixed with Once to have the property be removed once it has been triggered once.


Conditional Triggers

Both ordinary keys and those with the Once suffix can then take one of the following suffixes to determine how they are triggered:

  • Explode - triggered when the tile is destroyed by an explosion (tiles that have the DMT/explode key)
  • Push - triggered when the tile is pushed
  • Pushed - triggered once a tile has finished being pushed
  • On - triggered when the farmer steps on the tile (Back tiles only)
  • Off - triggered when the farmer steps off the tile (Back tiles only)

Some keys are triggered in other ways and do not require a suffix.


Tool Triggers

Most keys can be triggered when using a tool on a tile, by adding the class name of a tool (not the language specific display name) as a suffix. E.g.:

"DMT/soundOnceWateringCan": "steam"

will trigger when one waters the tile with a watering can.

Tool class names in the vanilla code are:

  • MagnifyingGlass
  • Shears
  • MilkPail
  • Axe
  • Wand
  • Hoe
  • FishingRod
  • MeleeWeapon
  • Pan
  • Pickaxe
  • WateringCan
  • Slingshot
  • GenericTool


Object Triggers

Most keys can be triggered when acting on a tile while holding a specific object by adding "Object" plus either the held object's index number or its name (not display name). E.g.:

"DMT/soundObjectPrismatic Shard": "yoba"

To have the object be removed on trigger, combine this with the DMT/take key. E.g.:

"DMT/takeObjectPrismatic Shard": "" - this will take the player's active object if the tile is acted on while holding a Prismatic Shard.


Action Triggers

Most keys can be triggered simply by acting on the tile by adding "Action" to the end of the key. E.g.:

"DMT/soundAction": "yoba"


SMAPI C# Triggers

To trigger any tile's keys from another C# mod, you can use SMAPI's mod API interface. The API interface for this mod is:

    public interface IDynamicMapTilesApi
    {
        public bool TriggerActions(List<Layer> layers, Farmer farmer, Point tilePos, List<string> suffixes);
    }

suffixes should be a list of all the kinds of trigger outlined above that you want to trigger.


Key List

All possible keys are explained in detail below, organized as follows:

  • Buffs
  • Cache Invalidation
  • Emotes
  • Events
  • Explosions
  • Health and Stamina
  • Items & Chests
  • Mail
  • Messages
  • Music
  • Pushing
  • Sound
  • Speed & Movement
  • Temporary Sprite Animations
  • Teleportation
  • Tile Indexes
  • Tile Properties


Buffs

DMT/buff

The above key can be used to add a buff/debuff to the player. The value should be the integer index of the buff/debuff. Buff indexes are as follows:

  • 6 Full
  • 7 Quenched
  • 12 Burnt
  • 13 Slimed
  • 14 Jinxed
  • 17 Tipsy
  • 18 Spooked
  • 19 Frozen
  • 20 Warrior Energy
  • 21 Yoba's Blessing
  • 22 Adrenaline Rush
  • 23 Oil of Garlic
  • 24 Monster Musk
  • 25 Nauseous
  • 26 Darkness
  • 27 Weakness
  • 28 Squid Ink Ravioli

E.g.:

"DMT/buffOn": "13" - triggers the slimed buff when stepping on the tile. 


Cache Invalidation

DMT/invalidate

You can trigger the invalidation of cached game assets using DMT/invalidate. The value should be a list of asset paths separated by the pipe symbol "|".


Emotes

DMT/emote

This key causes a farmer to emote. The value should be the integer index of the specific emote. Emote indexes are:

  • 4 empty can
  • 8 question mark
  • 12 angry
  • 16 exclamation
  • 20 heart
  • 24 sleep
  • 28 sad
  • 32 happy
  • 36 x
  • 40 pause
  • 44 not used
  • 48 not used
  • 52 videogame
  • 56 music note
  • 60 blush


Events

DMT/event

Use the above key to trigger a custom event. See Modding:Event data on the wiki. E.g.:

"DMT/eventOn": "playful/20 57/Harvey 25 57 3/skippable/pause 200/speak Harvey \"Hey, why are you stepping there, @?\"/pause 500/end"


Explosions

DMT/explode
DMT/explosion

Tiles can be marked as explodable by adding the property DMT/explode to the tile. The tile will be removed when affected by a bomb. Tiles on different layers will be checked individually.

The value of the key should be left blank "" unless you want the mod to set a mail flag for the player - then set the value to the mail id to be sent. This can be useful for making the explosion persistent, as Content Patcher can then check for the flag and remove the tile on next load.

You can trigger other properties on explode by adding "Explode" to the end of the property key; tiles with properties ending with Explode will be triggered when DMT/explode is triggered on that tile. E.g.:

"DMT/explode": "",
"DMT/soundExplode": "yoba"

Tiles can trigger an explosion somewhere in the map when stepped on by adding the property DMT/explosion. The value of the property should be the following:

<TileX> <TileY> <radius> <damagesFarmer(true or false)> <damageAmount> 

e.g.:

"DMT/explosionOnceOn": "17 26 8 false -1"


Health and Stamina

DMT/health
DMT/stamina
DMT/healthPerSecond
DMT/staminaPerSecond

These keys can be used to affect the player health and stamina all at once or when standing on a tile over time (the PerSecond keys should be used on the "Back" layer only and will be triggered while standing on the tile; they should not take a suffix).

The property value should be a positive or negative integer.


Items & Chests

DMT/give
DMT/chest
DMT/take

Give

To give the player an item, use the key DMT/give. The item will be held up by the farmer and placed in their inventory (or on the ground if full).

For ordinary objects, the value should be either the index in ObjectInformation or the name of the object in ObjectInformation.

To give other types of items, use <ItemType>/<IndexOrName>. The following types are supported:

  • Hat
  • Clothing
  • Craftable
  • Furniture
  • Weapon
  • Money

E.g.:

"DMT/giveOn": "Clothing/Skull Shirt"

Chest

To spawn a chest somewhere in the map, use DMT/chest. The syntax is:

<TileX> <TileY>=<item1> <item2>...

Item syntax is the same as for DMT/give except you can specify an amount using <item>,<amount> E.g.:

"DMT/chestOn": "8 26=Money/1000 Clothing/Skull Shirt 378,10" - this spawns a chest with 1000 coins, a skull shirt, and 10 copper ore.

Take

To take one of the player's held item use DMT/take. If the value is empty, the item will be taken no matter what it is. If the value is either a specific object index or name, it will only take if the held item index or name matches. This is useful for combining with Object<nameOrIndex> suffixed triggers so that the item is consumed and something else happens as a result.


Mail

DMT/mail
DMT/mailbox

Use the above keys to send mail. The value is the id for the mail to be sent.

The first key will simply set a mail flag as having been received. The second key will actually put the mail with that id into the mailbox. The first is useful for setting flags to tell Content Patcher mods that the tile has been stepped on before.


Messages

DMT/message

Use the above key to show a  HUD message.


Music

DMT/music

Use the above key to change the currently playing music track. The value should be the id of a music track in the game.


Pushing

DMT/push
DMT/pushAlso
DMT/pushOthers
DMT/pushable

Only tiles on the Buildings layer can use the property DMT/push, which lets you push them by walking into them. The value of the property should be a comma-separated list of all tiles (X Y) that the tile is pushable to. E.g.:

"DMT/push": "1 1,1 2,2 1,2 2" - this tile can be pushed to any of the four tiles in the list.

You can trigger pushing other tiles when a tile is pushed using DMT/pushAlso. The format for DMT/pushAlso value is:

<tile1layer> <tile1xOffset> <tile1yOffset>,<tile2layer> <tile2xOffset> <tile2yOffset>...

E.g.:

"DMT/pushAlso": "Buildings -1 0,Front -1 -1,Front 0 -1" - pushes three other tiles when this tile is pushed, with x y tile positions relative to this tile.

Tiles that are included in another tile's pushAlso list should have the property "DMT/pushable" added to them if there is a concern with different sets of pushable tiles colliding and erasing each other. Tiles without this property will be overridden by tiles pushed into their position. 

You can trigger other properties on push by adding "Push" to the end of the property key; exploded tiles with properties ending with Push will be triggered when DMT/push is triggered on that tile. E.g.:

"DMT/soundPush": "furnace"

You can trigger other properties when a tile is finished being pushed by adding "Pushed" to the end of the property key; exploded tiles with properties ending with Pushed will be triggered when a tile being push reaches its destination tile. E.g.:

"DMT/soundPushed": "yoba"

Push and Pushed suffixes can also be added to tiles on other layers, so that when you push a tile onto or off of another tile it triggers the properties on that tile. E.g.:

"DMT/explosionOncePushed": "17 26 8 false -1" - this can be added to a tile on the Back layer so that when a tile on the Buildings layer is pushed onto it, it triggers an explosion once. Push suffix will be triggered on tiles when a tile is pushed off of them instead.

To trigger the pushing of tiles other than the triggering tile use DMT/pushOthers. This key takes a list of Layer X Y values separated by commas like pushAlso. Note that each tile pushed this way will trigger its own pushAlso key, so there is no need to push all joined tiles with this trigger.


Sound

DMT/sound

To play a sound, use one of the above keys. The value should be a valid vanilla sound key (see Modding:Audio on the wiki).

Playing a sound once means the property will be removed once the sound has been played. This is not persistent (the sound will be able to play again if the map is reloaded). Use mail flags and Content Patcher for persistence.


Speed & Movement

DMT/speed
DMT/move
DMT/slippery

The speed key can be used to affect the player's movement speed while moving over a tile. The value should be the decimal multiplier (1 is no change, 0.5 is half speed, etc.).

The move key can be used to apply directional velocity while on a tile. The value should be decimal x and y values separated by a space. E.g.:

"DMT/move": "2.5 0" - applies 2.5x velocity towards the right while on the tile with this property.

The slippery key can be used to make tiles slippery. The value should be a decimal, which seems to be equivalent to a fraction of the player's ordinary move speed. E.g.:

"DMT/slippery": "0.25" - this simulates ordinary ice tiles


Temporary Sprite Animations

DMT/animation

Animations are complex things - they are not difficult to code, just have many possible parameters. I've added two options for triggering animations, one with 16 parameters and one with 29 (!) parameters. Parameters should be separated by commas. For multiple animations, separate them using the pipe symbol "|".

Indexed Animations

Indexed animations use the game's built in animations data sheet. If you want to trigger any of those, look at the TileSheets/animations file. The parameters should be:

[int rowInAnimationTexture],[int position.X],[int position.Y],[int color.R],[int color.G],[int color.B],[int color.A],[int animationLength],[bool flipped],[float animationInterval],[int numberOfLoops],[int sourceRectWidth],[float layerDepth], [int sourceRectHeight],[int delay],[int ID]


Custom Animations

For animations using custom textures, use the following parameters:

[string textureName],[int sourceRect.X],[int sourceRect.Y],[int sourceRect.Width],[int sourceRect.Height],[float animationInterval],[int animationLength],[int numberOfLoops],[int position.X],[int position.Y],[bool flicker],[bool flipped],[float layerDepth],[float alphaFade],[int color.R],[int color.G],[int color.B],[int color.A],[float scale],[float scaleChange],[float rotation],[float rotationChange],[bool local],[float motion.X],[float motion.Y],[float acceleration.X],[float acceleration.Y],[int delayBeforeAnimationStart],[int ID]


So, here's an attempt at recreating the steam on watering a lava tile:

"DMT/animationOnceWateringCan": "LooseSprites\\Cursors,372,1956,10,10,99999,1,0,{{Random:{{Range:1152,1216}}|key=a1}},{{Random:{{Range:768,832}}|key=a6}},false,false,-1,0.007,255,255,255,255,4,0.02,0,0.012,false,0,0,0,0,35,4205|LooseSprites\\Cursors,372,1956,10,10,99999,1,0,{{Random:{{Range:1152,1216}}|key=a2}},{{Random:{{Range:768,832}}|key=a7}},false,false,-1,0.007,255,255,255,255,4,0.02,0,0.012,false,0,0,0,0,35,4206|LooseSprites\\Cursors,372,1956,10,10,99999,1,0,{{Random:{{Range:1152,1216}}|key=a3}},{{Random:{{Range:768,832}}|key=a8}},false,false,-1,0.007,255,255,255,255,4,0.02,0,0.012,false,0,0,0,0,35,4207|LooseSprites\\Cursors,372,1956,10,10,99999,1,0,{{Random:{{Range:1152,1216}}|key=a4}},{{Random:{{Range:768,832}}|key=a9}},false,false,-1,0.007,255,255,255,255,4,0.02,0,0.012,false,0,0,0,0,35,4208|LooseSprites\\Cursors,372,1956,10,10,99999,1,0,{{Random:{{Range:1152,1216}}|key=a5}},{{Random:{{Range:768,832}}|key=a10}},false,false,-1,0.007,255,255,255,255,4,0.02,0,0.012,false,0,0,0,0,35,4209"

This creates five different animations using Content Patcher randomization for position.


Teleportation

DMT/teleport
DMT/teleportTile

To instantly teleport anywhere on the current map when stepping on a tile, use the above key.  For the first key, the value should be the exact x y coordinates to teleport to. For the second key, use the tile x y coordinates instead. E.g.:

"DMT/teleportTileOn": "10 10" and "DMT/teleportOn": "640 640" - both teleport the player to the tile 10,10 when stepping on the tile with this property. With the second key you can of course use non-multiples of 64 for precise teleportation (Heisenberg compensator sold seperately).


Tile Indexes

DMT/changeIndex
DMT/changeMultipleIndex


DMT/changeIndex

To change the tile index to another index on the same tile sheet, the value should be the new integer index. e.g:

"DMT/changeIndexOn": "69"

To change to a different tile sheet, use the following syntax:

tileSheetName/index

e.g.:

"DMT/changeIndexOn": "Landscape/69" - will change the tile to use index 69 on the Landscape tile sheet when the farmer steps on it.

For animated tiles, use the following syntaxes instead:

staticIndex1 staticIndex2 staticIndex3,duration

or

tileSheetName/staticIndex1 tileSheetName/staticIndex2 tileSheetName/staticIndex3,duration

e.g.:

"DMT/changeIndexOn": "Landscape/67 Landscape/68 Landscape/69,100" - will change the tile to an animated tile using three static tile indexes from the Landscape tile sheet, 100ms per tile

To remove a tile, leave the entire value blank "".


DMT/changeMultipleIndex

The syntax is similar to that above. Info for each tile being changed is separated by the pipe symbol "|":

<tileInfo1>|<tileInfo2>

Each tile info is separated into two parts by an equals sign:

<layerXY>=<indexDuration>

The part before the equals sign is separated by spaces, containing the layer name, x coordinate, and y coordinate. The part after the equals sign is the same as the section on changing single tiles above (either idx or idx1 idx2 idx3,duration). E.g.:

"DMT/changeMultipleIndexOn": "Back 5 10=150|Buildings 6 9=Landscape/67 Landscape/68 Landscape/69,100" - changes one back tile (5,10) to a static tile and one building tile (6,9) to an animated tile using the data given, when the farmer steps on the tile with this property.

To remove a tile, just don't put anything after the equals sign.


Tile Properties

DMT/changeProperties
DMT/changeMultipleProperties

Similar to the previous section, use these keys for changing the current tile properties, or changing multiple tiles' properties.

For the current tile's properties:

Properties are split by the pipe symbol "|". Each property has a key and value:

prop1key=prop1value|prop2key=prop2value

E.g.:

"DMT/changePropertiesOn": "Action=Crib|Passable=T"

To remove a property, omit the equal sign and the value:

"DMT/changePropertiesOn": "Action|Passable" - removes both these properties from the stepped on tile.


For multiple tile properties, separate tile info using the pipe sign as before, "|". The info for each tile is almost the same as above, except it contains the tile info as well, separated using commas (because idk if the key might have spaces in it):

tile1layer,tile1x,tile1y,prop1key=prop1value|tile2layer,tile2x,tile2y,prop2key=prop2value

E.g.:

"DMT/changeMultiplePropertiesOff": "Buildings,6,9,Action=Crib|Back,9,6,Passable=T" - sets two different properties on two different tiles on two different layers.

To remove a property, just don't put anything after the equals sign.


Technical

Requires SMAPI.

Compatible with Mod Updater for automatic updates.

Code is at https://github.com/aedenthorn/StardewValleyMods.

If you want to complain or ask for help or help me test my mods, you can visit my Discord server.

A list of all my mods for Stardew Valley is available at https://www.nexusmods.com/stardewvalley/articles/895.