Effects
A status effect is something that changes how the player sees or feels the world, such as being drunk or being in the wasteland.
Effects read and change status effects
Use it to read which status effects are on and how strong they look, to turn the wasteland on or off, and to hear when an effect changes.
public static class Effects
{
public static bool IsAvailable { get; }
public static bool IsActive(Effect effect);
public static float Strength(Effect effect);
public static List<Effect> Active();
public static bool Apply(Effect effect);
public static bool Clear(Effect effect);
public static event Action<EffectChangedArgs> Changed;
}
| Property | Type | What it means |
|---|---|---|
IsAvailable | bool | false when the effect change event could not be set up. |
| Method | Returns | What it does |
|---|---|---|
IsActive(effect) | bool | true when the effect is on now. |
Strength(effect) | float | How strong the effect is, from 0 to 1. It is 0 when the effect is not on. |
Active() | List<Effect> | Every effect that is on now. |
Apply(effect) | bool | Turns an effect on. Only the wasteland works. |
Clear(effect) | bool | Turns an effect off. Only the wasteland works. |
| Event | Gives you | When it fires |
|---|---|---|
Changed | EffectChangedArgs | An effect turns on or off. args.Effect is the effect and args.Active is its new state. |
Effect the status effects
Pass one of these to Effects.IsActive, Effects.Strength, Effects.Apply or Effects.Clear. EffectChangedArgs tells you which one changed.
public enum Effect
{
Drunk,
Mushroom,
Sleepy,
Depression,
LowHealth,
Wasteland,
OrangeMushroom
}
| Value | Meaning |
|---|---|
Drunk | The player is drunk. |
Mushroom | The player is high on mushrooms. |
Sleepy | The player is very tired. |
Depression | The player has low mood. |
LowHealth | The player has low health. |
Wasteland | The wasteland effect (SMV). |
OrangeMushroom | The player is high on the orange mushroom. |
Example: if (Effects.IsActive(Effect.OrangeMushroom)) Log.Info("orange mushroom high");
Things to know
Changedfires only when an effect really turns on or off. After each save load and on the main menu, the framework reads the drunk, mushroom, orange mushroom and wasteland effects again, and firesChangedfor any that is different from the last value it reported. (It is raised from postfixes on the game’s drunk, mushroom and orange mushroom start and stop methods, onSMVEffects.WastelandActive, and on the end of theSMVEffects.StopEffectcoroutine for the wasteland stop.)Wastelandcan be turned on and off.Applystarts the wasteland effect with the game’s usual settings, and the game’s own start rules still apply.Clearstops it even if the player has made progress with SMV. (ApplycallsSMVEffects.EnableWasteland().ClearcallsSMVEffects.StopWasteland(enableStop: true, ignoreSMV: true).)OrangeMushroomis the orange mushroom high.IsActiveis on while the orange mushroom stats are above zero. (IsActivereads itsshroomsEnabledfield. The drain isDeltaSeconds.)Strengthis how strong the effect looks on screen, from 0 to 1. It matches the game’s own on-screen weight for the effect. It returns 0 for a value it does not know and never throws. By effect:DrunkandMushroom: the weight of the effect’s screen filter. It can be above 0 while the effect fades out after the game turns it off, and it is 0 once the fade ends.OrangeMushroom: the larger of its two filters’ weights, read the same way, so it can also be above 0 while the effect fades out.Sleepy: 0 at tiredness 50 or below, then(tiredness / 100 - 0.5) / 0.5. It reaches 1 at tiredness 100.Depression: 0 at mental health 50 or below, thenmental health / 100 - 0.5. It tops out at 0.5, at mental health 100.LowHealth: 1 whenever the effect is on, because it is only on at health 50 or below. For a gradual value, read the health stat itself.Wasteland: 1 while it is on. The framework does not read a wasteland strength. (ForDrunkandMushroomthe weight is read without checkingIsActive.LowHealthis1.5 - health / 100, clamped, but the effect is on only at health 50 or below, so that formula gives 1 for every value where it is on.)
- If a screen filter is missing, one line goes to the log and the strength reads 0.
Limits
- The game decides when
Drunk,Mushroom,Sleepy,DepressionandLowHealthare on, soApplyandClearreturnfalsefor them. The game works them out every frame from the player’s stats. To change one, change the stat withSurvival.Set.IsActivereads the same state the game uses. (DrunkisDrunkEffect.drunkEnabled(set above 15 alcohol).MushroomisMushroomEffect.shroomsEnabled(set while mushrooms are high). For the three screen effects (Sleepy,Depression,LowHealth), the effect is on when its weight leaves zero, which happens when tiredness, mood or health crosses 50 out of 100.) OrangeMushroomis driven by the game every frame, likeMushroom, soApplyandClearreturnfalsefor it. You can’t read how fast its time runs down.