public void Kill(PowerContext context = null, bool lootAndExp = false) { var deathload = new DeathPayload(context, Powers.DamageType.Physical, this, lootAndExp); deathload.Apply(); }
public void Apply() { // play damage number message if (this.Context.User is Player) { // TODO: handle player getting hit? maybe broadcast red message (this.Context.User as Player).InGameClient.SendMessage(new FloatingNumberMessage { ActorID = this.Target.DynamicID, Number = this.TotalDamage, Type = this.IsCriticalHit ? FloatingNumberMessage.FloatType.WhiteCritical : FloatingNumberMessage.FloatType.White }); } if (this.AutomaticHitEffects) { // play override hit effect it power context has one if (this.Context.EvalTag(PowerKeys.OverrideHitEffects) > 0) { int efg = this.Context.EvalTag(PowerKeys.HitEffect); if (efg != -1) this.Target.PlayEffectGroup(efg); } else { this.Target.PlayHitEffect((int)this.DominantDamageType.HitEffect, this.Context.User); } // TODO: sound effects // play hit animation if the actor has one int hitAni = this.Target.AnimationSet.GetAniSNO(Mooege.Common.MPQ.FileFormats.AnimationTags.GetHit); if (hitAni != -1) { this.Target.World.BroadcastIfRevealed(new PlayAnimationMessage() { ActorID = this.Target.DynamicID, Field1 = 0x6, Field2 = 0, tAnim = new PlayAnimationMessageSpec[1] { new PlayAnimationMessageSpec() { Field0 = 40, // HACK: harded animation length, we need to read these from .ani Field1 = hitAni, Field2 = 0x0, Field3 = 1f // TODO: vary this based on hit recovery } } }, this.Target); } } // TODO: critical hit special element buff/effects // update hp float new_hp = Math.Max(this.Target.Attributes[GameAttribute.Hitpoints_Cur] - this.TotalDamage, 0f); this.Target.Attributes[GameAttribute.Hitpoints_Cur] = new_hp; this.Target.Attributes.BroadcastChangedIfRevealed(); // if hp=0 do death if (new_hp == 0f) { var deathload = new DeathPayload(this.Context, this.DominantDamageType, this.Target); if (OnDeath != null) OnDeath(deathload); deathload.Apply(); } // TODO: if target survives and it's a AI monster, give it aggro }
public void Apply() { if (this.Target.World != null) this.Target.World.BuffManager.SendTargetPayload(this.Target, this); // floating damage number if (this.Target.World != null) { this.Target.World.BroadcastIfRevealed(new FloatingNumberMessage { ActorID = this.Target.DynamicID, Number = this.TotalDamage, // make player damage red, all other damage white Type = this.IsCriticalHit ? (this.Target is Player) ? FloatingNumberMessage.FloatType.RedCritical : FloatingNumberMessage.FloatType.Golden : (this.Target is Player) ? FloatingNumberMessage.FloatType.Red : FloatingNumberMessage.FloatType.White }, this.Target); } if (this.AutomaticHitEffects) { // play override hit effect it power context has one if (this.Context.EvalTag(PowerKeys.OverrideHitEffects) > 0) { int efg = this.Context.EvalTag(PowerKeys.HitEffect); if (efg != -1) this.Target.PlayEffectGroup(efg); } else { this.Target.PlayHitEffect((int)this.DominantDamageType.HitEffect, this.Context.User); } if (this.TotalDamage > 0f) { // play override hitsound if any, otherwise just default to playing metal weapon hit for now int overridenSound = this.Context.EvalTag(PowerKeys.HitsoundOverride); int hitsound = overridenSound != -1 ? overridenSound : 1; if (hitsound > 0) this.Target.PlayEffect(Net.GS.Message.Definitions.Effect.Effect.Hit, hitsound); } } // TODO: critical hit special element buff/effects // update hp float new_hp = Math.Max(this.Target.Attributes[GameAttribute.Hitpoints_Cur] - this.TotalDamage, 0f); this.Target.Attributes[GameAttribute.Hitpoints_Cur] = new_hp; this.Target.Attributes.BroadcastChangedIfRevealed(); // if hp=0 do death if (new_hp == 0f) { var deathload = new DeathPayload(this.Context, this.DominantDamageType, this.Target); if (OnDeath != null) OnDeath(deathload); deathload.Apply(); } else if (this.AutomaticHitEffects && this.Target.World != null) { // HACK: reduce hit effect rate for Player to 10% so they don't get perma hit-sun locked. if (this.Target is Player && PowerContext.Rand.NextDouble() < 0.9) return; // target didn't die, so play hit animation if the actor has one if (this.Target.World.BuffManager.GetFirstBuff<Implementations.KnockbackBuff>(this.Target) == null && this.Target.AnimationSet != null) { if (this.Target.AnimationSet.TagMapAnimDefault.ContainsKey(AnimationSetKeys.GetHit)) { int hitAni = this.Target.AnimationSet.TagMapAnimDefault[AnimationSetKeys.GetHit]; if (hitAni != -1) { // HACK: hardcoded animation speed/ticks, need to base those off hit recovery speed this.Target.PlayAnimation(6, hitAni, 1.0f, 40); } } } } // TODO: if target survives and it's a AI monster, give it aggro }
public void Apply() { if (this.Target.World != null) { this.Target.World.BuffManager.SendTargetPayload(this.Target, this); } // floating damage number if (this.Target.World != null) { this.Target.World.BroadcastIfRevealed(new FloatingNumberMessage { ActorID = this.Target.DynamicID, Number = this.TotalDamage, // make player damage red, all other damage white Type = this.IsCriticalHit ? (this.Target is Player) ? FloatingNumberMessage.FloatType.RedCritical : FloatingNumberMessage.FloatType.Golden : (this.Target is Player) ? FloatingNumberMessage.FloatType.Red : FloatingNumberMessage.FloatType.White }, this.Target); } if (this.AutomaticHitEffects) { // play override hit effect it power context has one if (this.Context.EvalTag(PowerKeys.OverrideHitEffects) > 0) { int efg = this.Context.EvalTag(PowerKeys.HitEffect); if (efg != -1) { this.Target.PlayEffectGroup(efg); } } else { this.Target.PlayHitEffect((int)this.DominantDamageType.HitEffect, this.Context.User); } if (this.TotalDamage > 0f) { // play override hitsound if any, otherwise just default to playing metal weapon hit for now int overridenSound = this.Context.EvalTag(PowerKeys.HitsoundOverride); int hitsound = overridenSound != -1 ? overridenSound : 1; if (hitsound > 0) { this.Target.PlayEffect(Net.GS.Message.Definitions.Effect.Effect.Hit, hitsound); } } } // TODO: critical hit special element buff/effects // update hp float new_hp = Math.Max(this.Target.Attributes[GameAttribute.Hitpoints_Cur] - this.TotalDamage, 0f); this.Target.Attributes[GameAttribute.Hitpoints_Cur] = new_hp; this.Target.Attributes.BroadcastChangedIfRevealed(); // if hp=0 do death if (new_hp == 0f) { var deathload = new DeathPayload(this.Context, this.DominantDamageType, this.Target); if (OnDeath != null) { OnDeath(deathload); } deathload.Apply(); } else if (this.AutomaticHitEffects && this.Target.World != null) { // HACK: reduce hit effect rate for Player to 10% so they don't get perma hit-sun locked. if (this.Target is Player && PowerContext.Rand.NextDouble() < 0.9) { return; } // target didn't die, so play hit animation if the actor has one if (this.Target.World.BuffManager.GetFirstBuff <Implementations.KnockbackBuff>(this.Target) == null && this.Target.AnimationSet != null) { if (this.Target.AnimationSet.TagMapAnimDefault.ContainsKey(AnimationSetKeys.GetHit)) { int hitAni = this.Target.AnimationSet.TagMapAnimDefault[AnimationSetKeys.GetHit]; if (hitAni != -1) { // HACK: hardcoded animation speed/ticks, need to base those off hit recovery speed this.Target.PlayAnimation(6, hitAni, 1.0f, 40); } } } } // TODO: if target survives and it's a AI monster, give it aggro }