Example #1
0
        /// <summary>
        /// ON START WETNESS
        /// ON STOP WETNESS
        /// ON START POISON
        /// ON STOP POISON
        /// ON START RADIATION
        /// ON STOP RADIATION
        /// ON START RADIATION POISON
        /// ON STOP RADIATION POISON
        /// ON START COMFORT
        /// ON STOP COMFORT
        /// ON START BLEEDING
        /// ON STOP BLEEDING
        /// </summary>
        /// <param name="metabolism"></param>
        /// <param name="source"></param>
        void OnRunPlayerMetabolism(PlayerMetabolism metabolism, BaseCombatEntity source)
        {
            if (source is BasePlayer)
            {
                BasePlayer    player = (BasePlayer)source;
                PlayerProfile profile;
                if (onlinePlayers.TryGetValue(player, out profile))
                {
                    if (profile.Metabolism == null)
                    {
                        profile.Metabolism = new ProfileMetabolism(metabolism);
                        return;
                    }

                    Dictionary <string, ProfileMetabolism.MetaAction> changes = profile.Metabolism.DetectChange(metabolism);

                    foreach (KeyValuePair <string, ProfileMetabolism.MetaAction> kvp in changes)
                    {
                        if (kvp.Value == ProfileMetabolism.MetaAction.Start)
                        {
                            Interface.CallHook("OnStart" + kvp.Key, player);
                        }
                        else
                        {
                            Interface.CallHook("OnStop" + kvp.Key, player);
                        }
                    }
                }
            }
        }
        private void OnRunPlayerMetabolism(PlayerMetabolism m, BaseCombatEntity entity)
        {
            var player = entity.ToPlayer();

            if (player == null)
            {
                return;
            }
#if DEBUG
            PrintWarning($"Health before: {player.health}");
            PrintWarning($"Calories before: {player.metabolism.calories.value}");
            PrintWarning($"Hydration before: {player.metabolism.hydration.value}");
#endif
            if (permission.UserHasPermission(player.UserIDString, permBoost))
            {
                player.health     = Mathf.Clamp(player.health + config.HealthGainRate, 0f, 100f);
                m.calories.value  = Mathf.Clamp(m.calories.value - config.CaloriesLossRate, m.calories.min, m.calories.max);
                m.hydration.value = Mathf.Clamp(m.hydration.value - config.HydrationLossRate, m.hydration.min, m.hydration.max);
            }
            else if (permission.UserHasPermission(player.UserIDString, permNone))
            {
                m.calories.value  = m.calories.max;
                m.hydration.value = m.hydration.max;
            }
#if DEBUG
            PrintWarning($"Health after: {player.health}");
            PrintWarning($"Calories after: {player.metabolism.calories.value}");
            PrintWarning($"Hydration after: {player.metabolism.hydration.value}");
#endif
        }
Example #3
0
 public BasePlayer(ProtoBuf.BasePlayer proto)
 {
     protobuf   = proto;
     metabolism = new PlayerMetabolism(proto.metabolism);
     modelState = new BaseModelState(proto.modelState);
     metabolism = new PlayerMetabolism(proto.metabolism);
 }
Example #4
0
 private void Set(PlayerMetabolism metabolism)
 {
     this.wetness          = metabolism.wetness.value;
     this.radiation_poison = metabolism.radiation_poison.value;
     this.radiation_level  = metabolism.radiation_level.value;
     this.poison           = metabolism.poison.value;
     this.comfort          = metabolism.comfort.value;
     this.bleeding         = metabolism.bleeding.value;
 }
Example #5
0
 void Set(PlayerMetabolism metabolism)
 {
     wetness          = metabolism.wetness.value;
     radiation_poison = metabolism.radiation_poison.value;
     radiation_level  = metabolism.radiation_level.value;
     poison           = metabolism.poison.value;
     comfort          = metabolism.comfort.value;
     bleeding         = metabolism.bleeding.value;
 }
Example #6
0
        private void OnRunPlayerMetabolism(PlayerMetabolism m, BaseCombatEntity entity)
        {
            var player = entity.ToPlayer();

            if (player != null && IsInWater(player))
            {
                HandleDamage(player);
            }
        }
Example #7
0
        private void OnRunPlayerMetabolism(PlayerMetabolism m, BaseCombatEntity entity)
        {
            var player = entity.ToPlayer();

            if (player != null)
            {
                WaterCheck(player);
            }
        }
Example #8
0
 public void SendChangesToClient()
 {
     if (!this.HasChanged())
     {
         return;
     }
     this.isDirty = false;
     using (PlayerMetabolism playerMetabolism = this.Save())
         this.baseEntity.ClientRPCPlayer <PlayerMetabolism>((Connection)null, this.baseEntity, "UpdateMetabolism", playerMetabolism);
 }
Example #9
0
        void OnRunPlayerMetabolism(PlayerMetabolism m, BaseCombatEntity entity)
        {
            var player = entity.ToPlayer();

            if (player == null)
            {
                return;
            }
            IemUtils.SetMetabolismNoNutrition(player);
        }
Example #10
0
        object OnRunPlayerMetabolism(PlayerMetabolism metabolism, BaseCombatEntity entity)
        {
            var player = entity.ToPlayer();

            if (!IsGod(player.UserIDString) || !permission.UserHasPermission(player.UserIDString, permUntiring))
            {
                return(null);
            }

            player.SetPlayerFlag(BasePlayer.PlayerFlags.NoSprint, false);
            return(true);
        }
Example #11
0
        object OnRunPlayerMetabolism(PlayerMetabolism metabolism, BaseCombatEntity entity)
        {
            var player = entity.ToPlayer();

            if (gods[player.userID] == null)
            {
                return(null);
            }
            if (infiniteRun)
            {
                player.SetPlayerFlag(BasePlayer.PlayerFlags.NoSprint, false);
            }
            return(true);
        }
Example #12
0
        void OnRunPlayerMetabolism(PlayerMetabolism m, BaseCombatEntity entity)
        {
            var player = entity.ToPlayer();

            if (player == null)
            {
                return;
            }
            if (usePermissions && !permission.UserHasPermission(player.UserIDString, permAllow))
            {
                player.health = Mathf.Clamp(player.health + healthGainRate, 0f, 100f);
            }
            m.calories.value  = Mathf.Clamp(m.calories.value - caloriesLossRate, m.calories.min, m.calories.max);
            m.hydration.value = Mathf.Clamp(m.hydration.value - hydrationLossRate, m.hydration.min, m.hydration.max);
        }
Example #13
0
        private object OnRunPlayerMetabolism(PlayerMetabolism metabolism, BaseCombatEntity entity, float delta)
        {
            var player = entity as BasePlayer;

            if (player == null)
            {
                return(null);
            }

            //PrintWarning($"{player.displayName} health: {player.health}, thirst: {metabolism.hydration.value}, calories: {metabolism.calories.value}," +
            //             $"dirty: {metabolism.isDirty}, poisoned: {(metabolism.poison.value.Equals(1) ? "true" : "false")}");

            HookCalled("OnRunPlayerMetabolism");
            return(null);
        }
Example #14
0
        object OnRunPlayerMetabolism(PlayerMetabolism metabolism, BaseCombatEntity entity)
        {
            var player = entity.ToPlayer();

            if (!IsGod(player.UserIDString) || !permission.UserHasPermission(player.UserIDString, permUntiring))
            {
                return(null);
            }

            var craftLevel = player.currentCraftLevel;

            player.SetPlayerFlag(BasePlayer.PlayerFlags.Workbench1, craftLevel == 1f);
            player.SetPlayerFlag(BasePlayer.PlayerFlags.Workbench2, craftLevel == 2f);
            player.SetPlayerFlag(BasePlayer.PlayerFlags.Workbench3, craftLevel == 3f);
            player.SetPlayerFlag(BasePlayer.PlayerFlags.NoSprint, false);
            return(true);
        }
Example #15
0
        object OnRunPlayerMetabolism(PlayerMetabolism metabolism, BaseCombatEntity entity)
        {
            if (!(entity is BasePlayer))
            {
                return(null);
            }

            var player = entity.ToPlayer();

            player.SetPlayerFlag(BasePlayer.PlayerFlags.NoSprint, false);
            if (infiniteRun && gods[player.UserIDString] != null)
            {
                return(true);
            }

            return(null);
        }
Example #16
0
        private object OnRunPlayerMetabolism(PlayerMetabolism metabolism)
        {
            var basePlayer = metabolism.GetComponent <BasePlayer>();

            if (basePlayer != null && _data.Contains(basePlayer))
            {
                basePlayer.InitializeHealth(100, 100);
                metabolism.oxygen.Add(metabolism.oxygen.max);
                metabolism.wetness.Add(-metabolism.wetness.max);
                metabolism.radiation_level.Add(-metabolism.radiation_level.max);
                metabolism.radiation_poison.Add(-metabolism.radiation_poison.max);
                metabolism.temperature.Reset();
                metabolism.hydration.Add(metabolism.hydration.max);
                metabolism.calories.Add(metabolism.calories.max);
                metabolism.bleeding.Reset();
                return(false);
            }
            return(null);
        }
Example #17
0
 public void Load(PlayerMetabolism s)
 {
     this.calories.SetValue((float)s.calories);
     this.hydration.SetValue((float)s.hydration);
     this.comfort.SetValue((float)s.comfort);
     this.heartrate.value        = (float)s.heartrate;
     this.temperature.value      = (float)s.temperature;
     this.radiation_level.value  = (float)s.radiation_level;
     this.radiation_poison.value = (float)s.radiation_poisoning;
     this.wetness.value          = (float)s.wetness;
     this.dirtyness.value        = (float)s.dirtyness;
     this.oxygen.value           = (float)s.oxygen;
     this.bleeding.value         = (float)s.bleeding;
     this.pending_health.value   = (float)s.pending_health;
     if (!Object.op_Implicit((Object)this.owner))
     {
         return;
     }
     this.owner.health = (float)s.health;
 }
Example #18
0
        private void OnRunPlayerMetabolism(PlayerMetabolism m, BaseCombatEntity entity)
        {
            var player = entity.ToPlayer();

            if (player == null)
            {
                return;
            }

            if (permission.UserHasPermission(player.UserIDString, permBoost))
            {
                player.health     = Mathf.Clamp(player.health + config.HealthGainRate, 0f, 100f);
                m.calories.value  = Mathf.Clamp(m.calories.value - config.CaloriesLossRate, m.calories.min, m.calories.max);
                m.hydration.value = Mathf.Clamp(m.hydration.value - config.HydrationLossRate, m.hydration.min, m.hydration.max);
            }
            else if (permission.UserHasPermission(player.UserIDString, permNone))
            {
                m.calories.value  = m.calories.max;
                m.hydration.value = m.hydration.max;
            }
        }
Example #19
0
    public PlayerMetabolism Save()
    {
        PlayerMetabolism playerMetabolism = (PlayerMetabolism)Pool.Get <PlayerMetabolism>();

        playerMetabolism.calories            = (__Null)(double)this.calories.value;
        playerMetabolism.hydration           = (__Null)(double)this.hydration.value;
        playerMetabolism.heartrate           = (__Null)(double)this.heartrate.value;
        playerMetabolism.temperature         = (__Null)(double)this.temperature.value;
        playerMetabolism.radiation_level     = (__Null)(double)this.radiation_level.value;
        playerMetabolism.radiation_poisoning = (__Null)(double)this.radiation_poison.value;
        playerMetabolism.wetness             = (__Null)(double)this.wetness.value;
        playerMetabolism.dirtyness           = (__Null)(double)this.dirtyness.value;
        playerMetabolism.oxygen         = (__Null)(double)this.oxygen.value;
        playerMetabolism.bleeding       = (__Null)(double)this.bleeding.value;
        playerMetabolism.comfort        = (__Null)(double)this.comfort.value;
        playerMetabolism.pending_health = (__Null)(double)this.pending_health.value;
        if (Object.op_Implicit((Object)this.owner))
        {
            playerMetabolism.health = (__Null)(double)this.owner.Health();
        }
        return(playerMetabolism);
    }
Example #20
0
        private object OnRunPlayerMetabolism(PlayerMetabolism metabolism, BasePlayer player, float delta)
        {
            if (player == null)
            {
                return(null);
            }
            if (!IsGod(player.UserIDString))
            {
                return(null);
            }
            metabolism.hydration.value = 250;
            if (!permission.UserHasPermission(player.UserIDString, permUntiring))
            {
                return(null);
            }
            var craftLevel = player.currentCraftLevel;

            player.SetPlayerFlag(BasePlayer.PlayerFlags.Workbench1, craftLevel == 1f);
            player.SetPlayerFlag(BasePlayer.PlayerFlags.Workbench2, craftLevel == 2f);
            player.SetPlayerFlag(BasePlayer.PlayerFlags.Workbench3, craftLevel == 3f);
            player.SetPlayerFlag(BasePlayer.PlayerFlags.NoSprint, false);
            return(true);
        }
Example #21
0
 void OnRunPlayerMetabolism(PlayerMetabolism metabolism)
 {
     metabolism.temperature.min = 0f; // TODO: Check for actual normal value
 }
Example #22
0
        void OnRunPlayerMetabolism(PlayerMetabolism metabolism)
        {
            // 0 - 1000 -> Decreased Health Regen
            // 1000 - 2000 -> Increased hunger
            // 2000 - 3000 -> Increased thirst
            // 3000 - 4000 -> No Health Regen
            // 4000 - 5000 -> No comfort
            // 5000 - 6000 -> Increased Hunger 2
            // 6000 - 7000 -> Increased Thirst 2
            // 7000 - 8000 -> Cold
            // 8000 - 9000 -> Bleeding
            // 9000+ -> Poison

            /*
             * -- ----------------------------
             * -- Rust default rates
             * -- ----------------------------
             * -- healthgain = 0.03
             * -- caloriesloss = 0 - 0.05
             * -- hydrationloss = 0 - 0.025
             * -- ----------------------------
             */
            BasePlayer  player               = metabolism.GetComponent <BasePlayer>();
            PlayerState state                = playerStates[player.userID];
            int         plagueLevel          = state.getPlagueLevel();
            float       defaultHealthGain    = 0.03f;
            float       defaultCaloriesLoss  = 0.05f;
            float       defaultHydrationLoss = 0.025f;


            //Interface.Oxide.LogInfo("Infection stage " + (plagueLevel / 1000).ToString());

            if (plagueLevel == 0)
            {
                return;
            }

            if (plagueLevel <= 1)
            {
                return;
            }
            //Interface.Oxide.LogInfo("Infection stage 1 " + player.displayName + " " + player.userID);
            metabolism.pending_health.value = metabolism.pending_health.value + (defaultHealthGain / 2f);

            if (plagueLevel <= 1000)
            {
                return;
            }
            //Interface.Oxide.LogInfo("Infection stage 2");
            metabolism.calories.value = metabolism.calories.value - ((defaultCaloriesLoss * 3f) + (metabolism.heartrate.value / 10f));

            if (plagueLevel <= 2000)
            {
                return;
            }
            //Interface.Oxide.LogInfo("Infection stage 3");
            metabolism.hydration.value = metabolism.hydration.value - ((defaultHydrationLoss * 3f) + (metabolism.heartrate.value / 10f));

            if (plagueLevel <= 3000)
            {
                return;
            }
            metabolism.pending_health.value = metabolism.pending_health.value - (defaultHealthGain / 2f);

            if (plagueLevel <= 4000)
            {
                return;
            }
            //Interface.Oxide.LogInfo("Infection stage 5");
            metabolism.comfort.value = -1;

            if (plagueLevel <= 5000)
            {
                return;
            }
            //Interface.Oxide.LogInfo("Infection stage 6");
            metabolism.calories.value = metabolism.calories.value - ((defaultCaloriesLoss * 5f) + (metabolism.heartrate.value / 10f));

            if (plagueLevel <= 6000)
            {
                return;
            }
            //Interface.Oxide.LogInfo("Infection stage 7");
            metabolism.hydration.value = metabolism.hydration.value - ((defaultHydrationLoss * 5f) + (metabolism.heartrate.value / 10f));

            if (plagueLevel <= 7000)
            {
                return;
            }
            ///Interface.Oxide.LogInfo("Infection stage 8");
            metabolism.temperature.value = metabolism.temperature.value - 0.05f;

            if (plagueLevel <= 8000)
            {
                return;
            }
            //Interface.Oxide.LogInfo("Infection stage 9");
            metabolism.bleeding.value = metabolism.bleeding.value + 0.2f;

            if (plagueLevel < 10000)
            {
                return;
            }
            //Interface.Oxide.LogInfo("Infection stage 10");
            metabolism.poison.value = 2;
        }
Example #23
0
 void OnRunPlayerMetabolism(PlayerMetabolism metabolism)
 {
     metabolism.temperature.Reset();
 }
Example #24
0
 void OnRunPlayerMetabolism(PlayerMetabolism metabolism)
 {
     metabolism.temperature.Reset();
 }
Example #25
0
            public Dictionary <string, MetaAction> DetectChange(PlayerMetabolism metabolism)
            {
                Dictionary <string, MetaAction> actions = new Dictionary <string, MetaAction> ();

                if (metabolism.wetness.value != wetness)
                {
                    if (metabolism.wetness.value == metabolism.wetness.min)
                    {
                        actions.Add("Wetness", MetaAction.Stop);
                    }
                    else if (wetness == metabolism.wetness.min)
                    {
                        actions.Add("Wetness", MetaAction.Start);
                    }
                }

                if (metabolism.poison.value != poison)
                {
                    if (metabolism.poison.value == metabolism.poison.min)
                    {
                        actions.Add("Poison", MetaAction.Stop);
                    }
                    else if (poison == metabolism.poison.min)
                    {
                        actions.Add("Poison", MetaAction.Start);
                    }
                }

                if (metabolism.oxygen.value != oxygen)
                {
                    if (metabolism.oxygen.value == metabolism.oxygen.min)
                    {
                        actions.Add("Drowning", MetaAction.Stop);
                    }
                    else if (oxygen == metabolism.oxygen.min)
                    {
                        actions.Add("Drowning", MetaAction.Start);
                    }
                }

                if (metabolism.radiation_level.value != radiation_level)
                {
                    if (metabolism.radiation_level.value == metabolism.radiation_level.min)
                    {
                        actions.Add("Radiation", MetaAction.Stop);
                    }
                    else if (radiation_level == metabolism.radiation_level.min)
                    {
                        actions.Add("Radiation", MetaAction.Start);
                    }
                }

                if (metabolism.radiation_poison.value != radiation_poison)
                {
                    if (metabolism.radiation_poison.value == metabolism.radiation_poison.min)
                    {
                        actions.Add("RadiationPoison", MetaAction.Stop);
                    }
                    else if (radiation_poison == metabolism.radiation_poison.min)
                    {
                        actions.Add("RadiationPoison", MetaAction.Start);
                    }
                }

                if (metabolism.comfort.value != comfort)
                {
                    if (metabolism.comfort.value == metabolism.comfort.min)
                    {
                        actions.Add("Comfort", MetaAction.Stop);
                    }
                    else if (comfort == metabolism.comfort.min)
                    {
                        actions.Add("Comfort", MetaAction.Start);
                    }
                }

                if (metabolism.bleeding.value != bleeding)
                {
                    if (metabolism.bleeding.value == metabolism.bleeding.min)
                    {
                        actions.Add("Bleeding", MetaAction.Stop);
                    }
                    else if (bleeding == metabolism.bleeding.min)
                    {
                        actions.Add("Bleeding", MetaAction.Start);
                    }
                }

                Set(metabolism);

                return(actions);
            }
Example #26
0
 private void OnRunPlayerMetabolism(PlayerMetabolism metabolism, BaseCombatEntity ownerEntity, float delta)
 {
     if (!(ownerEntity is BasePlayer)) return;
     if (metabolism.bleeding.value > 0 && HasPlayerFlag((BasePlayer) ownerEntity, ZoneFlags.NoBleed))
         metabolism.bleeding.value = 0f;
     if (metabolism.oxygen.value < 1 && HasPlayerFlag((BasePlayer) ownerEntity, ZoneFlags.NoDrown))
         metabolism.oxygen.value = 1;
 }
Example #27
0
 public ProfileMetabolism(PlayerMetabolism metabolism)
 {
     Set(metabolism);
 }
Example #28
0
 void OnRunPlayerMetabolism(PlayerMetabolism m, BaseCombatEntity entity)
 {
 }
Example #29
0
 private void OnRunPlayerMetabolism(PlayerMetabolism metabolism)
 {
     HookCalled("OnRunPlayerMetabolism");
     // TODO: Print new metabolism values
 }
Example #30
0
 private void OnRunPlayerMetabolism(PlayerMetabolism metabolism)
 {
     HookCalled("OnRunPlayerMetabolism");
     // TODO: Print new metabolism values
 }