Skip to main content

Effects

Alta.Alchemy in Root.Township. Applied on the server.

An effect is a ScriptableObject that does one thing to whatever receives it: change a stat, poison, teleport, burn. Food, liquids, stews, garnishes and some areas carry lists of EffectDefinitionApplications, each an effect plus a strength. The receiver is an EffectHandler on the body.

EffectDefinition​

Alta.Alchemy.EffectDefinition : HashedGeneralValue<EffectDefinition>, abstract. Assets live under Cooking/Effects.

MemberWhat it does
virtual void CheckApply(EffectHandler target, float strength)Entry point. By default calls Apply. Subclasses use it to gate (chance, build-up, needs health).
protected abstract void Apply(EffectHandler target, float strength)Does the effect.
Glyph effectGlyphThe icon shown for it.

What strength means depends on the subclass: a size for StatChangeEffect and StatSetEffect, a duration in seconds for StatMultiplierEffect, a probability for ChanceBasedEffectDefinition and TeleportEffect, and a poison stack for PoisonEffect.

Subclasses in Alta.Alchemy:

TypeWhat it does with strength
StatEffectAbstract. Finds StatToAffect on the target's StatManager and calls ModifyStat.
StatChangeEffectAdds strength to the stat's Base. This is how food fills hunger and fullness.
StatSetEffectSets the stat's Base to strength.
StatMultiplierEffectApplies a timed StatModifier of its own modifierValue, lasting strength seconds.
PoisonEffectPositive strength adds a poison stack, negative removes one. Needs target.Health.
BurnEffectPositive strength starts adding to the "burn" stat every tick, negative stops it. The game has no BurnEffect asset and the player body has no "burn" stat, so it does nothing in vanilla.
TeleportEffectA ChanceBasedEffectDefinition: with chance strength * chanceMultiplier, teleports the target to its baked-in landingTarget (a SpawnAreaIdentifier). Home uses the player's spawn point (not for spirits), a missing area falls back to RespawnPoint, and the rest resolve through SpawnArea.InstanceMap.
RevealEffectRaises the handler's OnReveal.
InateEffectDoes nothing.
ChanceBasedEffectDefinition, BuildUpconcoctionEffectBases that gate on a random roll, or add up strengths and fire once they pass minStrengthToApply (0.8 on BuildupTeleportToOverworld), clearing after buildupDuration (1 second).

IndirectStatModifierDefinition (in Alta.StatSystem) is also an EffectDefinition: it adds an indirect, curve-shaped modifier to a stat.

The game's effect assets​

Asset values

Build main-1.7.2.1.42203, checked against a live server's registry (13 effects). The stat effects are also in Stats.

AssetTypeWhat it does
NourishStatChangeEffectAdds to hunger (0 to 2).
FeedStatChangeEffectAdds to fullness (0 to 6).
HealStatChangeEffectAdds to health (0 to 2).
Damage Indirect effect, Damage Protection Indirect effect, Speed Indirect Effect, Luminosiy indirect effectIndirectStatModifierDefinitionA modifier of baseValue * strength (base 1, or 2 for luminosity) on damage, damage protection, speed or luminosity, for 900 stat ticks (15 minutes).
Poison over TimePoisonEffectA poison stack. The player's handler deals poison damage every 1.5 seconds (poisonFrequency).
Teleport Home, Teleport Original RespawnTeleportEffectThe teleport potion.
Reveal EffectRevealEffect
BuildupTeleportToOverworldBuildupTeleportEffectBuilds up, then teleports.
InateInateEffectNothing.

Liquids carry these too: the Health Potion liquid is one Heal at strength 1 (half of the 2 health), with isConsumableThroughSkin set.

The four indirect modifiers are saved with the player's StatManager, and their timers carry over a logout (IndirectStatModifier, TimedStatModifier), so a running buff keeps going after a reconnect.

EffectDefinitionApplication​

[Serializable] class. An effect with a strength and an optional duration.

MemberWhat it doesNotes
EffectDefinitionApplication(EffectDefinition effectToModify, float strengthMultiplier, int durationInSeconds = 0)Makes one.
EffectDefinition EffectToModify { get; }The effect.
float StrengthMultiplier { get; set; }The strength.Sent over the network in -100 to 100, to 0.001.
virtual void CheckApply(EffectHandler target, float strength)Duration 0: applies once at strength * StrengthMultiplier. Otherwise splits it into one-second steps over the duration.
EffectDefinitionApplication Copy()A copy.

Durations queue per effect on the handler: a second drink of the same timed effect starts after the first finishes.

EffectHandler​

Alta.Alchemy.EffectHandler : MonoBehaviour. On anything effects can reach. Players have the subclass PlayerEffectController, which sits next to the body's PlayerCharacter and adds the teleport effect and PlayerRepositioned.

MemberWhat it doesNotes
StatManager StatManager { get; }Where stat effects go.
HealthObject Health { get; }For poison.
int PoisonStacks { get; }Current poison stacks.
virtual void PoisonOverTime(float strength)Adds or removes a stack. While stacked, a coroutine deals damage every poisonFrequency seconds.
virtual void Teleport(Vector3 position, float strength, TeleportType teleportType)Moves the target, at most once every 2 seconds. Only the server moves it.
virtual void Reveal()Raises OnReveal.

Prefabs can make a handler immune to poison, teleport or reveal.

Who applies effects​

Client visuals​

The buff and debuff glow a player wears is drawn only on clients. PlayerEffectManager, on the player's body, destroys itself on a headless server, so none of this runs there. It holds a StatEffectsDefinition asset: a list of StatEffectHolders, one per watched stat, each pairing a buff and a debuff StatDrivenEffect (a pooled particle effect, a value-to-size curve and a shell setting).

For each, a PlayerEffectManager.StatEffectApplication (two per stat, buff and debuff) listens to the stat's Changed event. Its ValueChanged works out the buff part of the value and turns the glow on, off or resizes it. So the glow is decided by which stat moved and its buff channel (see Stats), not by what caused the change: anything that raises a given stat glows the same way, and a change written to the stat's Base instead of through its buff channel produces no glow at all.

There are two layers. The floating particles come from the StatDrivenEffect. The shell is a second skin: StatEffectShellAnimator (a ShellAnimator) clones the player's clothing renderers with a shell material and animates its _Progress, tuned by a StatEffectShellSetting. Only one shell shows at a time; StatEffectShellAnimator is a priority queue, so overlapping effects wait their turn. The shared shell material comes from PlayerSpecialEffectsController.

A server mod changes effects and stats, which clients then render; it can't change how the glow looks for a vanilla client, because none of this runs on the server.

Hooking it​

See also​