private void OnSelectedMetalMessage(IServerPlayer player, SelectedMetalMessage message) { EntityBehaviorAllomancy allomancy = (EntityBehaviorAllomancy)(player.Entity.GetBehavior("allomancy")); if (message._metal_id < -1 || message._metal_id >= MistModSystem.METALS.Length) { return; } if (message._metal_id == -1) // The client doesn't know what the selected metal is { string selectedMetal = allomancy.Helper.GetSelectedMetal(); int result = -1; if (selectedMetal != "none") { result = Array.IndexOf(MistModSystem.METALS, selectedMetal); } Channel.SendPacket(new SelectedMetalMessage(result), player); } else // The client does know what the selected metal is. { string selectedMetal = MistModSystem.METALS[message._metal_id]; allomancy.Helper.SetSelectedMetal(selectedMetal); } allomancy.Helper.Debug(); }
public override void OnHeldInteractStop(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel) { // Add the efects once the interaction has finalized. if (secondsUsed > 0.7f && byEntity.World.Side == EnumAppSide.Server) { EntityBehaviorAllomancy allomancy = (EntityBehaviorAllomancy)byEntity.GetBehavior("allomancy"); if (allomancy != null) { allomancy.Helper.EnableAllPowers(); slot.TakeOut(1); allomancy.Helper.Debug(); } } }
private float OnGeneralEntityDamaged(Entity entity, float damage, DamageSource source) { if (source.SourceEntity != null) { if (source.SourceEntity.HasBehavior("allomancy") && source.Type != EnumDamageType.Heal) { EntityBehaviorAllomancy enemyAllomancy = (EntityBehaviorAllomancy)source.SourceEntity.GetBehavior("allomancy"); float damageIncrement = enemyAllomancy.Helper.GetEffectiveBurnStatus("pewter") * (1.0f / 5.0f); enemyAllomancy.Helper.IncreasePewterFatigue(damageIncrement / 2); enemyAllomancy.Helper.IncrementMetalReserve("pewter", -damageIncrement / 4); return(damage + (damage * damageIncrement)); } } return(damage); }
public override void OnHeldInteractStop(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel) { // Add the efects once the interaction has finalized. if (secondsUsed > 0.7f && byEntity.World.Side == EnumAppSide.Server) { EntityBehaviorAllomancy allomancy = (EntityBehaviorAllomancy)byEntity.GetBehavior("allomancy"); if (allomancy != null) { JsonObject attr = slot.Itemstack.Collectible.Attributes; float amount = attr["amount"].AsFloat(); string metal = attr["metal"].AsString(); allomancy.Helper.IncrementMetalReserve(metal, amount); slot.TakeOut(1); allomancy.Helper.Debug(); } } }
/// <summary> Called when the entity has received damage, but after armor damage reduction was applied </summary> public float OnDamageAfterArmor(float damage, DamageSource source) { float newDamage = damage; int effectivePewterBurnStatus = Helper.GetEffectiveBurnStatus("pewter"); if (effectivePewterBurnStatus > 0 && source.Type != EnumDamageType.Heal) { float reductionAmount = (1f / 5.0f * effectivePewterBurnStatus); float reducedDamage = damage * reductionAmount; newDamage -= reducedDamage; Helper.IncreasePewterFatigue(reducedDamage * 2); Helper.IncrementMetalReserve("pewter", -reducedDamage / 4); } EntityBehaviorHealth health = (EntityBehaviorHealth)entity.GetBehavior("health"); if (newDamage > health.Health) { if (Helper.GetPower("pewter") && source.Type != EnumDamageType.Heal) { if (Helper.GetMetalReserve("pewter") > 0) { Helper.SetBurnToggle("pewter", true); Helper.IncrementBurnStatus("pewter", 1); Helper.IncreasePewterFatigue(newDamage * Helper.GetEffectiveBurnStatus("pewter")); Helper.IncrementMetalReserve("pewter", -newDamage); if (Helper.GetMetalReserve("pewter") != 0) { newDamage = health.Health / 2; } } } } if (source.SourceEntity != null) { if (source.SourceEntity.HasBehavior("allomancy")) { EntityBehaviorAllomancy enemyAllomancy = (EntityBehaviorAllomancy)source.SourceEntity.GetBehavior("allomancy"); int effectiveEnemyChromiumBurnStatus = enemyAllomancy.Helper.GetEffectiveBurnStatus("chromium"); if (effectiveEnemyChromiumBurnStatus > 0) { Helper.ClearAllReserves(); } } } return(newDamage); }
private void OnBurnMetalMessage(IServerPlayer player, BurnMessage message) { EntityBehaviorAllomancy allomancy = ((EntityBehaviorAllomancy)player.Entity.GetBehavior("allomancy")); if (message._burn_strength == 1) // Flare the metal { int currentStrength = allomancy.Helper.GetBurnStatus(MistModSystem.METALS[message._metal_id]); allomancy.TryExecuteActiveAllomanticEffect(MistModSystem.METALS[message._metal_id], currentStrength, true); } if (message._burn_strength == 2) // Decrease the burn status { allomancy.Helper.IncrementBurnStatus(MistModSystem.METALS[message._metal_id], -1); } if (message._burn_strength == 3) // Increase the burn status { allomancy.Helper.IncrementBurnStatus(MistModSystem.METALS[message._metal_id], 1); } if (message._burn_strength == 4) // Toggle the burn of the metal { allomancy.Helper.ToggleBurn(MistModSystem.METALS[message._metal_id]); } allomancy.Helper.Debug(); }