Ambulate In Somnis Posted March 20, 2021 Report Share Posted March 20, 2021 How i can modify players stats on respawn? I had tried make a mod, but i have not found code or settings for change stats. Link to comment Share on other sites More sharing options...
Ambulate In Somnis Posted March 22, 2021 Author Report Share Posted March 22, 2021 Im going further in modding. Im stucked in enumerating players stats. Link to comment Share on other sites More sharing options...
Ambulate In Somnis Posted March 25, 2021 Author Report Share Posted March 25, 2021 I found some interesting mechanics with reviving and saturation Link to comment Share on other sites More sharing options...
Ambulate In Somnis Posted March 25, 2021 Author Report Share Posted March 25, 2021 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 More sharing options...
Ambulate In Somnis Posted March 25, 2021 Author Report Share Posted March 25, 2021 (edited) 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 March 25, 2021 by Ambulate In Somnis Link to comment Share on other sites More sharing options...
goxmeor Posted March 28, 2021 Report Share Posted March 28, 2021 The first is an EntityBehavior. You can add a custom EntityBehavior to player entities on spawn. My TemporalGearSpawnNerf and Pact mods both do this, check out their source. Link to comment Share on other sites More sharing options...
Recommended Posts