/// <summary> /// Iterates through the provided effect dictionary and sets every stat provided /// </summary> public void setTempStats() { //This calculates a correct percentage of max health to increase if (effectedList.ContainsKey("maxhealthExtraPoints")) { effectedList["maxhealthExtraPoints"] = (14f + effectedEntity.Stats.GetBlended("maxhealthExtraPoints")) * effectedList["maxhealthExtraPoints"]; } foreach (KeyValuePair <string, float> stat in effectedList) { switch (stat.Key) { case "glow": effectedEntity.WatchedAttributes.SetBool("glow", true); break; case "recall": break; case "duration": break; default: effectedEntity.Stats.Set(stat.Key, "potionmod", stat.Value, false); break; } } //This is required everytime max health is changes if (effectedList.ContainsKey("maxhealthExtraPoints")) { EntityBehaviorHealth ebh = effectedEntity.GetBehavior <EntityBehaviorHealth>(); ebh.MarkDirty(); } }
public void reset(EntityPlayer entity, bool message) { foreach (var stats in entity.Stats) { entity.Stats.Remove(stats.Key, "potionmod"); } EntityBehaviorHealth ebh = entity.GetBehavior <EntityBehaviorHealth>(); ebh.MarkDirty(); if (entity.WatchedAttributes.HasAttribute("glow")) { entity.WatchedAttributes.RemoveAttribute("glow"); } if (entity.WatchedAttributes.HasAttribute("potionid")) { long effectIdGametick = entity.WatchedAttributes.GetLong("potionid"); entity.World.UnregisterGameTickListener(effectIdGametick); effectDuration = 0; effectHealth = 0; effectTickSec = 0; entity.WatchedAttributes.RemoveAttribute("potionid"); } if (message) { IServerPlayer player = (entity.World.PlayerByUid((entity as EntityPlayer).PlayerUID) as IServerPlayer); player.SendMessage(GlobalConstants.InfoLogChatGroup, "You feel the effects of the potion disapate", EnumChatType.Notification); } }