Mods / EffectsHUD

Category: #Other
Author: KenigVovan
Side: Both
Created: Jun 18th at 12:59 PM
Last modified: 5 days ago
Downloads: 83
Follow Unfollow 2

Mod is WIP

Allow register effects(or use default ones) and show them on client in HUD.

Inspired and uses parts of goxmeor 's BuffStuff - https://mods.vintagestory.at/show/mod/633

 

List of default effects - regeneration, miningslow, miningspeed, walkslow, walkspeed, weakmelee, strengthmelee, bleeding.

Set effect on player using command:

/ef effectName durationInMins tier nickname (just for debug)

if you want to set on player -

create new Effect: MiningSlowEffect ef = new MiningSlowEffect();

set duration: ef.SetExpiryInRealMinutes(3);

apply effect on entity: effectshud.src.effectshud.ApplyEffectOnEntity(entity, efslow);

(or using AddEffect of EBEffectsAffected - player's EntityBehavior)

You can set it's tier or duration with (SetExpiryInTicks,SetExpiryInRealMinutes and others)

HUD with effect is shown by default for on/off use "L" button

To register you own effect in StartServerSide you need to call and proved typeId of effect and class

RegisterEntityEffect("myEffectTypeId", typeof(myEffectClass));

in StartClientSide: (typeId again and your icons for every tier of the effect)

RegisterClientEffectData("myEffectTypeId", new string[] { "mymoddomain:effects/tiericon1", "mymoddomain:effects/tiericon2", "mymoddomain:effects/tiericon3" });

Config:

TICK_EVERY_SECONDS - will change how long is tick in real seconds, for now it's 1 real second and for now can not be changed by config.

 

 

Version For Game version Downloads Release date Changelog Download
v1.0.3 18 5 days ago Show effectshud_v1.0.3.zip
v1.0.2 4 5 days ago Show effectshud_v1.0.2.zip
v1.0.1 22 Jun 19th at 10:53 AM Show effectshud_v1.0.1.zip
v1.0.0 27 Jun 18th at 1:00 PM Show effectshud_v1.0.0.zip

3 Comments (oldest first | newest first)

jakecool19, 10 hours ago

Amazing work! I have been hoping we would get a proper status effect system for this game for quite awhile. What is the ultimate finished goal for this one? Will it just be for players, or will it work with all entities?

KenigVovan, Jun 19th at 8:33 AM

It is WIP.
Mod for HUD on which effects (picture of buff/debuff) can be drawn. 
it uses player's WatchedAttributes to track updates.

You can register effect to show by:
RegisterEffect(string watchedBranch, string effectWatchedName, bool showTime, string effectDurationWatchedName, string [] domainAndPath, Vintagestory.API.Common.Func needToShow)

example of use for "miningSpeedMul" in stats:
effectshud.src.effectshud.RegisterEffect("stats", "miningSpeedMul", false, "", new string[] { "canmods:effects/slowmining1", "canmods:effects/slowmining2", "canmods:effects/slowmining3" }, checkminigSpeedMul);

checkminigSpeedMul here is function which is called on branch update and return number of picture which shoud be drawn, if -1 is return that means that effect is not active

public int checkminigSpeedMul()
{
      var t2 = capi.World.Player.Entity.Stats["miningSpeedMul"];
      var t = t2.GetBlended();
      if (t < 0.35)
      {
          return 2;
      }
      else if (t < 0.5)
      {
          return 1;
      }
      else if (t < 0.85)
      {
          return 0;
      }
      return -1;
}

Display of the time is not functinal yet, so choose false for showTime, if you want to try it.

Pictures size used is 64x64.

For HUD to show press "L"

DemonBigj781, Jun 19th at 2:07 AM

whats this?

delete edit