Jump to content

Death punishment


Recommended Posts

    public class test : ModSystem
    {
        //public override bool ShouldLoad(EnumAppSide side) => side == EnumAppSide.Server;
        public override void StartServerSide(ICoreServerAPI api)
        {
            
            api.Event.PlayerRespawn += new PlayerDelegate(OnEntityReceiveDamage);
        }

            

        public void OnEntityReceiveDamage(IServerPlayer player)                 
        {
            System.Threading.Thread.Sleep(2000);
            EntityBehaviorHunger player_data_hunger = player.Entity.GetBehavior<EntityBehaviorHunger>();
            EntityBehaviorHealth player_data_health = player.Entity.GetBehavior<EntityBehaviorHealth>();

            float MaxSaturation = player_data_hunger.MaxSaturation;
            
            player_data_hunger.SaturationLossDelayFruit = 600f;
            player_data_hunger.SaturationLossDelayVegetable = 600f;
            player_data_hunger.SaturationLossDelayProtein = 600f;
            player_data_hunger.SaturationLossDelayGrain = 600f;
            player_data_hunger.SaturationLossDelayDairy = 600f;
        
            player_data_hunger.Saturation = MaxSaturation / 10f;
            player_data_hunger.VegetableLevel = 2f;
            player_data_hunger.ProteinLevel = 2f;
            player_data_hunger.FruitLevel = 2f;
            player_data_hunger.DairyLevel = 2f;
            
            player_data_health.MarkDirty();
        }

Hmm, stats was removed, but health and saturation still fillings up.
is this a bug?
@Tyron

Link to comment
Share on other sites

VS API  -> Entity - >BehaviorHunger.cs
This method calls when player respawns and get healed by

Revive()

in API lib.
 

        public override void OnEntityReceiveDamage(DamageSource damageSource, float damage)
        {
            if (damageSource.Type == EnumDamageType.Heal && damageSource.Source == EnumDamageSource.Revive)
            {
                SaturationLossDelayFruit = 60;
                SaturationLossDelayVegetable = 60;
                SaturationLossDelayProtein = 60;
                SaturationLossDelayGrain = 60;
                SaturationLossDelayDairy = 60;

                Saturation = MaxSaturation / 2;
                VegetableLevel /= 2;
                ProteinLevel /= 2;
                FruitLevel /= 2;
                DairyLevel /= 2;
            }
        }


VS API Entite -> Entity.cs

This method heals when player was respawned

        public virtual void Revive()
        {
            Alive = true;
            ReceiveDamage(new DamageSource() { Source = EnumDamageSource.Revive, Type = EnumDamageType.Heal }, 9999);
            AnimManager?.StopAnimation("die");
            IsOnFire = false;

            foreach (EntityBehavior behavior in SidedProperties.Behaviors)
            {
                behavior.OnEntityRevive();
            }
        }

 

How override this methods?
 

Edited by Ambulate In Somnis
Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.