/// <summary> /// Simplified monster take damage over time function, only called for DoTs currently /// </summary> public virtual void TakeDamageOverTime(float amount, DamageType damageType) { if (IsDead) { return; } TakeDamage(null, damageType, amount); // splatter effects var hitSound = new GameMessageSound(Guid, Sound.HitFlesh1, 0.5f); //var splatter = (PlayScript)Enum.Parse(typeof(PlayScript), "Splatter" + playerSource.GetSplatterHeight() + playerSource.GetSplatterDir(this)); var splatter = new GameMessageScript(Guid, damageType == DamageType.Nether ? PlayScript.HealthDownVoid : PlayScript.DirtyFightingDamageOverTime); EnqueueBroadcast(hitSound, splatter); if (Health.Current <= 0) { return; } if (amount >= Health.MaxValue * 0.25f) { var painSound = (Sound)Enum.Parse(typeof(Sound), "Wound" + ThreadSafeRandom.Next(1, 3), true); EnqueueBroadcast(new GameMessageSound(Guid, painSound, 1.0f)); } }
public void TakeDamage(WorldObject source, DamageType damageType, float _amount, BodyPart bodyPart, bool crit = false) { var amount = (uint)Math.Round(_amount); var percent = (float)amount / Health.MaxValue; // update health Health.Current = (uint)Math.Max(0, (int)Health.Current - amount); if (Health.Current == 0) { HandleActionDie(); return; } // send network messages var msgHealth = new GameMessagePrivateUpdateAttribute2ndLevel(this, Vital.Health, Health.Current); var hitSound = new GameMessageSound(Guid, GetHitSound(source, bodyPart), 1.0f); var creature = source as Creature; var splatter = new GameMessageScript(Guid, (PlayScript)Enum.Parse(typeof(PlayScript), "Splatter" + GetSplatterHeight() + creature.GetSplatterDir(this))); var damageLocation = (DamageLocation)BodyParts.Indices[bodyPart]; var text = new GameEventDefenderNotification(Session, creature.Name, damageType, percent, amount, damageLocation, crit, AttackConditions.None); Session.Network.EnqueueSend(text, msgHealth, hitSound, splatter); if (percent >= 0.1f) { var wound = new GameMessageSound(Guid, Sound.Wound1, 1.0f); Session.Network.EnqueueSend(wound); } }
public static void HandlePlayEffect(Session session, params string[] parameters) { try { string message = ""; float scale = 1f; var effectEvent = new GameMessageScript(session.Player.Guid, PlayScript.Invalid); if (parameters.Length > 1) { if (parameters[1] != "") { scale = float.Parse(parameters[1]); } } message = $"Unable to find a effect called {parameters[0]} to play."; if (Enum.TryParse(parameters[0], true, out PlayScript effect)) { if (Enum.IsDefined(typeof(PlayScript), effect)) { message = $"Playing effect {Enum.GetName(typeof(PlayScript), effect)}"; session.Player.ApplyVisualEffects(effect); } } var sysChatMessage = new GameMessageSystemChat(message, ChatMessageType.Broadcast); session.Network.EnqueueSend(sysChatMessage); } catch (Exception) { // Do Nothing } }
public static void HandleResetPosition(Session session, params string[] parameters) { try { // if (parameters.Length > 1) // if (parameters[1] != "") // scale = float.Parse(parameters[1]); string message = "Error saving position."; PositionType type = new PositionType(); if (Enum.TryParse(parameters[0], true, out type)) { if (Enum.IsDefined(typeof(PositionType), type)) { message = $"Saving position {Enum.GetName(typeof(PositionType), type)}"; session.Player.SetCharacterPosition(type, CharacterPositionExtensions.InvalidPosition(session.Id, type)); } } float scale = 1f; var effectEvent = new GameMessageScript(session.Player.Guid, Network.Enum.PlayScript.AttribDownRed, scale); var sysChatMessage = new GameMessageSystemChat(message, ChatMessageType.Broadcast); session.Network.EnqueueSend(effectEvent, sysChatMessage); } catch (Exception) { // Do Nothing } }
/// <summary> /// Simplified player take damage function, only called for DoTs currently /// </summary> public override void TakeDamageOverTime(float _amount, DamageType damageType) { if (Invincible || IsDead) { return; } // check lifestone protection if (UnderLifestoneProtection) { HandleLifestoneProtection(); return; } var amount = (uint)Math.Round(_amount); var percent = (float)amount / Health.MaxValue; // update health var damageTaken = (uint)-UpdateVitalDelta(Health, (int)-amount); // update stamina UpdateVitalDelta(Stamina, -1); //if (Fellowship != null) //Fellowship.OnVitalUpdate(this); // send damage text message //if (PropertyManager.GetBool("show_dot_messages").Item) //{ var nether = damageType == DamageType.Nether ? "nether " : ""; var chatMessageType = damageType == DamageType.Nether ? ChatMessageType.Magic : ChatMessageType.Combat; var text = new GameMessageSystemChat($"You receive {amount} points of periodic {nether}damage.", chatMessageType); Session.Network.EnqueueSend(text); //} // splatter effects //var splatter = new GameMessageScript(Guid, (PlayScript)Enum.Parse(typeof(PlayScript), "Splatter" + creature.GetSplatterHeight() + creature.GetSplatterDir(this))); // not sent in retail, but great visual indicator? var splatter = new GameMessageScript(Guid, damageType == DamageType.Nether ? ACE.Entity.Enum.PlayScript.HealthDownVoid : ACE.Entity.Enum.PlayScript.DirtyFightingDamageOverTime); EnqueueBroadcast(splatter); if (Health.Current <= 0) { // since damage over time is possibly combined from multiple sources, // sending a message to the last damager here could be tricky.. // TODO: get last damager from dot stack instead? OnDeath(DamageHistory.LastDamager, damageType, false); Die(); return; } if (percent >= 0.1f) { EnqueueBroadcast(new GameMessageSound(Guid, Sound.Wound1, 1.0f)); } }
// plays particle effect like spell casting or bleed etc.. public void PlayParticleEffect(PlayScript effectId, ObjectGuid targetId) { if (CurrentLandblock != null) { var effectEvent = new GameMessageScript(targetId, effectId); CurrentLandblock.EnqueueBroadcast(Location, Landblock.MaxObjectRange, effectEvent); } }
public override void PlayScript(Session session) { if (PlayerScript != Enum.PlayScript.Invalid) { var scriptEvent = new GameMessageScript(Guid, PlayerScript, 1f); session.Network.EnqueueSend(scriptEvent); } }
/// <summary> /// Applies damages to a player from a physical damage source /// </summary> public void TakeDamage(WorldObject source, DamageType damageType, float _amount, BodyPart bodyPart, bool crit = false) { if (Invincible ?? false) { return; } // check lifestone protection if (UnderLifestoneProtection) { HandleLifestoneProtection(); return; } var amount = (uint)Math.Round(_amount); var percent = (float)amount / Health.MaxValue; // update health var damageTaken = (uint)-UpdateVitalDelta(Health, (int)-amount); DamageHistory.Add(source, damageType, damageTaken); // update stamina UpdateVitalDelta(Stamina, -1); if (Fellowship != null) { Fellowship.OnVitalUpdate(this); } if (Health.Current == 0) { OnDeath(source, damageType, crit); Die(); return; } var damageLocation = (DamageLocation)BodyParts.Indices[bodyPart]; // send network messages var creature = source as Creature; var hotspot = source as Hotspot; if (creature != null) { var text = new GameEventDefenderNotification(Session, creature.Name, damageType, percent, amount, damageLocation, crit, AttackConditions.None); Session.Network.EnqueueSend(text); var hitSound = new GameMessageSound(Guid, GetHitSound(source, bodyPart), 1.0f); var splatter = new GameMessageScript(Guid, (PlayScript)Enum.Parse(typeof(PlayScript), "Splatter" + creature.GetSplatterHeight() + creature.GetSplatterDir(this))); EnqueueBroadcast(hitSound, splatter); } if (percent >= 0.1f) { EnqueueBroadcast(new GameMessageSound(Guid, Sound.Wound1, 1.0f)); } }
/// <summary> /// Applies damages to a player from a physical damage source /// </summary> public void TakeDamage(WorldObject source, DamageType damageType, float _amount, BodyPart bodyPart, bool crit = false) { if (Invincible ?? false) { return; } var amount = (uint)Math.Round(_amount); var percent = (float)amount / Health.MaxValue; // update health var damageTaken = (uint)-UpdateVitalDelta(Health, (int)-amount); DamageHistory.Add(source, damageType, damageTaken); if (Health.Current == 0) { OnDeath(source, damageType, crit); Die(); return; } // update stamina UpdateVitalDelta(Stamina, -1); var damageLocation = (DamageLocation)BodyParts.Indices[bodyPart]; // send network messages var creature = source as Creature; var hotspot = source as Hotspot; if (creature != null) { var text = new GameEventDefenderNotification(Session, creature.Name, damageType, percent, amount, damageLocation, crit, AttackConditions.None); Session.Network.EnqueueSend(text); var hitSound = new GameMessageSound(Guid, GetHitSound(source, bodyPart), 1.0f); var splatter = new GameMessageScript(Guid, (PlayScript)Enum.Parse(typeof(PlayScript), "Splatter" + creature.GetSplatterHeight() + creature.GetSplatterDir(this))); EnqueueBroadcast(hitSound, splatter); } else if (hotspot != null) { if (!string.IsNullOrWhiteSpace(hotspot.ActivationTalkString)) { Session.Network.EnqueueSend(new GameMessageSystemChat(hotspot.ActivationTalkString.Replace("%i", amount.ToString()), ChatMessageType.Craft)); } if (!hotspot.Visibility) { hotspot.EnqueueBroadcast(new GameMessageSound(hotspot.Guid, Sound.TriggerActivated, 1.0f)); } } if (percent >= 0.1f) { EnqueueBroadcast(new GameMessageSound(Guid, Sound.Wound1, 1.0f)); } }
public void TakeDamage(WorldObject source, DamageType damageType, float _amount, BodyPart bodyPart, bool crit = false) { if (Invincible ?? false) { return; } var amount = (uint)Math.Round(_amount); var percent = (float)amount / Health.MaxValue; // update health Health.Current = (uint)Math.Max(0, (int)Health.Current - amount); if (Health.Current == 0) { HandleActionDie(); return; } var damageLocation = (DamageLocation)BodyParts.Indices[bodyPart]; // send network messages Session.Network.EnqueueSend(new GameMessagePrivateUpdateAttribute2ndLevel(this, Vital.Health, Health.Current)); var creature = source as Creature; var hotspot = source as Hotspot; if (creature != null) { var hitSound = new GameMessageSound(Guid, GetHitSound(source, bodyPart), 1.0f); var splatter = new GameMessageScript(Guid, (PlayScript)Enum.Parse(typeof(PlayScript), "Splatter" + GetSplatterHeight() + creature.GetSplatterDir(this))); var text = new GameEventDefenderNotification(Session, creature.Name, damageType, percent, amount, damageLocation, crit, AttackConditions.None); Session.Network.EnqueueSend(text, hitSound, splatter); } else if (hotspot != null) { if (!string.IsNullOrWhiteSpace(hotspot.ActivationTalkString)) { Session.Network.EnqueueSend(new GameMessageSystemChat(hotspot.ActivationTalkString.Replace("%i", amount.ToString()), ChatMessageType.Craft)); } if (!(hotspot.Visibility ?? false)) { CurrentLandblock.EnqueueBroadcastSound(hotspot, Sound.TriggerActivated); } } if (percent >= 0.1f) { var wound = new GameMessageSound(Guid, Sound.Wound1, 1.0f); Session.Network.EnqueueSend(wound); } }
/// <summary> /// Simplified player take damage function, only called for DoTs currently /// </summary> public override void TakeDamageOverTime(float _amount, DamageType damageType) { if (Invincible ?? false || IsDead) { return; } var amount = (uint)Math.Round(_amount); var percent = (float)amount / Health.MaxValue; // update health var damageTaken = (uint)-UpdateVitalDelta(Health, (int)-amount); // update stamina UpdateVitalDelta(Stamina, -1); // send damage text message var nether = damageType == DamageType.Nether ? "nether " : ""; var text = new GameMessageSystemChat($"You receive {amount} points of periodic {nether}damage.", ChatMessageType.Combat); Session.Network.EnqueueSend(text); // splatter effects //var splatter = new GameMessageScript(Guid, (PlayScript)Enum.Parse(typeof(PlayScript), "Splatter" + creature.GetSplatterHeight() + creature.GetSplatterDir(this))); // not sent in retail, but great visual indicator? var splatter = new GameMessageScript(Guid, damageType == DamageType.Nether ? ACE.Entity.Enum.PlayScript.HealthDownVoid : ACE.Entity.Enum.PlayScript.DirtyFightingDamageOverTime); EnqueueBroadcast(splatter); if (Health.Current <= 0) { // since damage over time is possibly combined from multiple sources, // sending a message to the last damager here could be tricky.. OnDeath(null, damageType, false); Die(); return; } if (percent >= 0.1f) { EnqueueBroadcast(new GameMessageSound(Guid, Sound.Wound1, 1.0f)); } }
public void SetLandblockMessage(ObjectGuid target) { LandblockMessage = new GameMessageScript(target, Spell.TargetEffect, 1f); }
public void SetTargetPlayer(Player p) { Enchantment.Target = p; SessionMessage = new GameEventMagicUpdateEnchantment(p.Session, Enchantment); LandblockMessage = new GameMessageScript(p.Guid, (PlayScript)SpellBase.TargetEffect, 1f); }