示例#1
0
        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);
            }
        }
示例#2
0
        /// <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();
            }
        }
示例#3
0
        void HeatEntities(float dt)
        {
            IPlayer[] players = api.World.AllOnlinePlayers;

            foreach (IPlayer curPlayer in players)
            {
                EntityPlayer playerEntity = curPlayer.Entity;
                float        distance     = block.Pos.DistanceTo(playerEntity.Pos.AsBlockPos);

                if (distance > heatRange || !playerEntity.HasBehavior("bodyheat"))
                {
                    continue;
                }

                float distanceModifier = (heatRange - distance) / heatRange;

                switch (block.GetType().Name)
                {
                case "BlockEntityForge":
                    if (((BlockEntityForge)block).IsBurning)
                    {
                        break;
                    }
                    continue;

                case "BlockEntityFirepit":
                    if (((BlockEntityFirepit)block).IsBurning)
                    {
                        break;
                    }
                    continue;

                case "BlockEntityCharcoalPit":
                    if (((BlockEntityCharcoalPit)block).Lit)
                    {
                        break;
                    }
                    continue;

                default:
                    continue;
                }

                playerEntity.GetBehavior <EntityBehaviorBodyheat>()?.HeatUp(heatTemp * distanceModifier);
            }
        }
示例#4
0
        private void applyTraitAttributes(EntityPlayer eplr)
        {
            string         classcode = eplr.WatchedAttributes.GetString("characterClass");
            CharacterClass charclass = characterClasses.FirstOrDefault(c => c.Code == classcode);

            if (charclass == null)
            {
                throw new ArgumentException("Not a valid character class code!");
            }

            // Reset
            foreach (var stats in eplr.Stats)
            {
                foreach (var statmod in stats.Value.ValuesByKey)
                {
                    if (statmod.Key == "trait")
                    {
                        stats.Value.Remove(statmod.Key);
                        break;
                    }
                }
            }



            // Then apply
            string[] extraTraits = eplr.WatchedAttributes.GetStringArray("extraTraits");
            var      allTraits   = extraTraits == null ? charclass.Traits : charclass.Traits.Concat(extraTraits);

            foreach (var traitcode in allTraits)
            {
                Trait trait;
                if (TraitsByCode.TryGetValue(traitcode, out trait))
                {
                    foreach (var val in trait.Attributes)
                    {
                        string attrcode  = val.Key;
                        double attrvalue = val.Value;

                        eplr.Stats.Set(attrcode, "trait", (float)attrvalue, true);
                    }
                }
            }

            eplr.GetBehavior <EntityBehaviorHealth>()?.MarkDirty();
        }