Mods / EffectsHUD

Category: #Other
Author: KenigVovan
Side: Both
Created: Jun 18th 2022 at 12:59 PM
Last modified: May 14th at 3:04 PM
Downloads: 2834
Follow Unfollow 28

Latest file for v1.18.3:
effectshud_v0.2.3.zip 1-click install


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, thorns(damage the attacker), firedamageimmune, safefall, weight buff(for weight mod), cantemporalcharge(lowers speed of temporal stability drop and speed up restoration), invisibility (hides armor and cloths as well now, idk yet how to leave armor/cloths render there), forgetting (instant effect which lets player to use .charsel 1 more time), extendedmaxbreath

Set effect on player using command:

/ef effectName durationInMins tier nickname (just for debug)

-----------------------------------------------------------------------------------------------------------------------

If you want to apply effect on the player in the code:

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 provide 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 1-click mod install*
v0.2.3 192 May 14th at 3:04 PM Show effectshud_v0.2.3.zip Install now
v0.2.2 86 May 10th at 3:42 PM Show effectshud_v0.2.2.zip Install now
v0.2.1 581 Apr 8th at 9:36 AM Show effectshud_v0.2.1.zip Install now
v0.2.0 291 Mar 1st at 7:30 PM Show effectshud_v0.2.0.zip Install now
v1.0.10 32 Apr 8th at 9:14 AM Show effectshud_v1.0.10.zip Install now
v1.0.8 384 Jan 31st at 5:43 PM Show effectshud_v1.0.8.zip Install now
v1.0.7 340 Nov 13th 2022 at 2:21 PM Show effectshud_v1.0.7.zip Install now
v1.0.6 239 Jul 11th 2022 at 2:04 PM Show effectshud_v1.0.6.zip Install now
v1.0.4 158 Jul 1st 2022 at 7:43 PM Show effectshud_v1.0.4.zip Install now
v1.0.5 88 Jul 10th 2022 at 9:59 AM Show effectshud_v1.0.5.zip Install now
v1.0.3 101 Jun 25th 2022 at 1:37 PM Show effectshud_v1.0.3.zip Install now
v1.0.2 91 Jun 25th 2022 at 9:50 AM Show effectshud_v1.0.2.zip Install now
v1.0.1 116 Jun 19th 2022 at 10:53 AM Show effectshud_v1.0.1.zip Install now
v1.0.0 112 Jun 18th 2022 at 1:00 PM Show effectshud_v1.0.0.zip Install now

6 Comments (oldest first | newest first)

💬 KenigVovan, Jul 3rd 2022 at 6:44 PM

No problems with addons

If you mean to add OnEntityRevive, OnFallToGround, OnInteract, OnEntityReceiveDamage and others from EntityBehavior - i have it in a plan. To make a base for effects like vampirism, protections against(fire, fall, arrows, melee atacks), damage reflection etc.

I'll place source files on git in few days, but it's a mess now

 

💬 jakecool19, Jul 3rd 2022 at 3:50 PM

Would you be ok with mods that add on to this framework? For example adding more hooks to the base Buff class?

💬 KenigVovan, Jul 1st 2022 at 7:48 AM

The main point (at least for now) was to prepare effects handling for potions items.

Mod uses EntityBehavior so it might be expand on other entities, but Effects implementations could require some changes.
(because default Effects here use "Stats" of the player and i'm not 100% sure it's the same with other Entities)

💬 jakecool19, Jun 30th 2022 at 7:21 PM

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 2022 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 2022 at 2:07 AM

whats this?

(edit comment delete)