本文整理汇总了C#中Aura.Channel.World.Entities.Creature.Shove方法的典型用法代码示例。如果您正苦于以下问题:C# Creature.Shove方法的具体用法?C# Creature.Shove怎么用?C# Creature.Shove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aura.Channel.World.Entities.Creature
的用法示例。
在下文中一共展示了Creature.Shove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleKnockBack
/// <summary>
/// Handles knock back/stun/death.
/// </summary>
protected override void HandleKnockBack(Creature attacker, Creature target, TargetAction tAction, bool overcharge)
{
attacker.Shove(target, KnockbackDistance);
if (target.IsDead)
tAction.Set(TargetOptions.FinishingKnockDown);
else
tAction.Set(TargetOptions.KnockDown);
}
示例2: UseSkillOnTarget
/// <summary>
/// Bolt specific use code.
/// </summary>
/// <param name="attacker"></param>
/// <param name="skill"></param>
/// <param name="target"></param>
protected override void UseSkillOnTarget(Creature attacker, Skill skill, Creature target)
{
attacker.StopMove();
target.StopMove();
// Create actions
var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, target.EntityId);
aAction.Set(AttackerOptions.Result);
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
tAction.Set(TargetOptions.Result);
tAction.Stun = TargetStun;
var cap = new CombatActionPack(attacker, skill.Info.Id, aAction, tAction);
// Damage
var damage = this.GetDamage(attacker, skill);
// Elements
damage *= this.GetElementalDamageMultiplier(attacker, target);
// Reduce damage
SkillHelper.HandleMagicDefenseProtection(target, ref damage);
ManaShield.Handle(target, ref damage, tAction);
ManaDeflector.Handle(attacker, target, ref damage, tAction);
// Deal damage
if (damage > 0)
target.TakeDamage(tAction.Damage = damage, attacker);
target.Aggro(attacker);
// Knock down on deadly
if (target.Conditions.Has(ConditionsA.Deadly))
{
tAction.Set(TargetOptions.KnockDown);
tAction.Stun = TargetStun;
}
// Death/Knockback
attacker.Shove(target, KnockbackDistance);
if (target.IsDead)
tAction.Set(TargetOptions.FinishingKnockDown);
else
tAction.Set(TargetOptions.KnockDown);
// Override stun set by defense
aAction.Stun = AttackerStun;
Send.Effect(attacker, Effect.UseMagic, EffectSkillName);
Send.SkillUseStun(attacker, skill.Info.Id, aAction.Stun, 1);
skill.Stacks = 0;
cap.Handle();
}
示例3: Use
/// <summary>
/// Uses the skill.
/// </summary>
/// <param name="attacker"></param>
/// <param name="skill"></param>
/// <param name="targetEntityId"></param>
/// <returns></returns>
public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
{
// Get target
var target = attacker.Region.GetCreature(targetEntityId);
if (target == null)
return CombatSkillResult.InvalidTarget;
// Actions
var cap = new CombatActionPack(attacker, skill.Info.Id);
var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, targetEntityId);
aAction.Set(AttackerOptions.Result);
aAction.Stun = AttackerStun;
cap.Add(aAction);
// Hit by chance
var chance = attacker.AimMeter.GetAimChance(target);
var rnd = RandomProvider.Get();
if (rnd.NextDouble() * 100 < chance)
{
target.StopMove();
aAction.Set(AttackerOptions.KnockBackHit2);
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
tAction.Set(TargetOptions.Result | TargetOptions.CleanHit);
tAction.Stun = TargetStun;
cap.Add(tAction);
// TODO: Splash damage
// Damage
var damage = this.GetDamage(attacker, skill);
// Elementals
damage *= attacker.CalculateElementalDamageMultiplier(target);
// More damage with fire arrow
// XXX: Does this affect the element?
if (attacker.Temp.FireArrow)
damage *= FireBonus;
// Critical Hit
var critChance = attacker.GetRightCritChance(target.Protection);
CriticalHit.Handle(attacker, critChance, ref damage, tAction);
// Subtract target def/prot
SkillHelper.HandleDefenseProtection(target, ref damage);
// Defense
Defense.Handle(aAction, tAction, ref damage);
// Mana Shield
ManaShield.Handle(target, ref damage, tAction);
// Natural Shield
// Ignore delay reduction, as knock downs shouldn't be shortened
NaturalShield.Handle(attacker, target, ref damage, tAction);
// Deal with it!
if (damage > 0)
{
target.TakeDamage(tAction.Damage = damage, attacker);
SkillHelper.HandleInjury(attacker, target, damage);
}
// Knock down
// If target is using a shield and defense, don't KD.
var targetLeftHand = target.LeftHand;
if (tAction.SkillId != SkillId.Defense || targetLeftHand == null || !targetLeftHand.IsShield)
{
// TODO: We have to calculate knockback distance right
attacker.Shove(target, KnockBackDistance);
tAction.Set(TargetOptions.KnockDownFinish);
}
// Aggro
target.Aggro(attacker);
if (target.IsDead)
{
aAction.Set(AttackerOptions.KnockBackHit1);
tAction.Set(TargetOptions.Finished);
}
}
else
{
aAction.Set(AttackerOptions.Missed);
}
// Reduce arrows
if (attacker.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteArrows && !attacker.Magazine.HasTag("/unlimited_arrow/"))
attacker.Inventory.Decrement(attacker.Magazine);
//.........这里部分代码省略.........
示例4: Use
/// <summary>
/// Uses the skill.
/// </summary>
/// <param name="attacker"></param>
/// <param name="skill"></param>
/// <param name="targetEntityId"></param>
/// <returns></returns>
public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
{
// Get target
var target = attacker.Region.GetCreature(targetEntityId);
if (target == null)
return CombatSkillResult.InvalidTarget;
if (target.IsNotReadyToBeHit)
return CombatSkillResult.Okay;
var targetPos = target.GetPosition();
var attackerPos = attacker.GetPosition();
// Check range
//if (!attackerPos.InRange(targetPos, attacker.RightHand.OptionInfo.EffectiveRange + 100))
// return CombatSkillResult.OutOfRange;
// Actions
var cap = new CombatActionPack(attacker, skill.Info.Id);
var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, skill.Info.Id, targetEntityId);
aAction.Set(AttackerOptions.Result);
aAction.Stun = AttackerStun;
cap.Add(aAction);
// Hit by chance
var chance = attacker.AimMeter.GetAimChance(target);
var rnd = RandomProvider.Get();
if (rnd.NextDouble() * 100 < chance)
{
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
tAction.Set(TargetOptions.Result);
tAction.Stun = TargetStun;
cap.Add(tAction);
// Damage
var damage = attacker.GetRndRangedDamage();
// More damage with fire arrow
if (attacker.Temp.FireArrow)
damage *= FireBonus;
// Critical Hit
var critShieldReduction = (target.LeftHand != null ? target.LeftHand.Data.DefenseBonusCrit : 0);
var critChance = attacker.GetRightCritChance(target.Protection + critShieldReduction);
CriticalHit.Handle(attacker, critChance, ref damage, tAction);
var maxDamage = damage; //Damage without Defense and Protection
// Subtract target def/prot
SkillHelper.HandleDefenseProtection(target, ref damage);
// Defense
Defense.Handle(aAction, tAction, ref damage, true);
// Mana Shield
ManaShield.Handle(target, ref damage, tAction, maxDamage);
// Deal with it!
if (damage > 0)
target.TakeDamage(tAction.Damage = damage, attacker);
// Aggro
target.Aggro(attacker);
// Death/Knockback
if (target.IsDead)
{
tAction.Set(TargetOptions.FinishingKnockDown);
attacker.Shove(target, KnockBackDistance);
}
else
{
// Insta-recover in knock down
// TODO: Tied to stability?
if (target.IsKnockedDown)
{
tAction.Stun = 0;
}
// Knock down if hit repeatedly
else if (target.Stability < 30)
{
tAction.Set(TargetOptions.KnockDown);
}
// Normal stability reduction
else
{
target.Stability -= StabilityReduction;
if (target.IsUnstable)
{
tAction.Set(TargetOptions.KnockBack);
attacker.Shove(target, KnockBackDistance);
}
}
//.........这里部分代码省略.........
示例5: Use
//.........这里部分代码省略.........
var lProp = new Prop(280, attacker.RegionId, poe.X, poe.Y, MabiMath.ByteToRadian(attacker.Direction), 1f, 0f, "single");
attacker.Region.AddProp(lProp);
// Prepare Combat Actions
var cap = new CombatActionPack(attacker, skill.Info.Id);
var targetAreaId = new Location(attacker.RegionId, poe).ToLocationId();
var aAction = new AttackerAction(CombatActionType.SpecialHit, attacker, targetAreaId);
aAction.Set(AttackerOptions.KnockBackHit1 | AttackerOptions.UseEffect);
aAction.PropId = lProp.EntityId;
cap.Add(aAction);
// Get targets in Polygon - includes collission check
var targets = attacker.Region.GetCreaturesInPolygon(p1, p2, p3, p4).Where(x => attacker.CanTarget(x) && !attacker.Region.Collisions.Any(attacker.GetPosition(), x.GetPosition())).ToList();
var rnd = RandomProvider.Get();
// Check crit
var crit = false;
var critSkill = attacker.Skills.Get(SkillId.CriticalHit);
if (critSkill != null && critSkill.Info.Rank > SkillRank.Novice)
{
var critChance = Math2.Clamp(0, 30, attacker.GetTotalCritChance(0));
if (rnd.NextDouble() * 100 < critChance)
crit = true;
}
foreach (var target in targets)
{
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, SkillId.CombatMastery);
tAction.Set(TargetOptions.None);
tAction.AttackerSkillId = skill.Info.Id;
cap.Add(tAction);
var damage = attacker.GetRndMagicDamage(skill, skill.RankData.Var1, skill.RankData.Var2);
// Add damage if the skill is fully charged
var dmgMultiplier = skill.RankData.Var4 / 100f;
if (attacker.Temp.LightningRodFullCharge)
{
damage += (damage * dmgMultiplier);
}
// Critical Hit
if (crit)
{
var bonus = critSkill.RankData.Var1 / 100f;
damage = damage + (damage * bonus);
tAction.Set(TargetOptions.Critical);
}
// MDef and MProt
SkillHelper.HandleMagicDefenseProtection(target, ref damage);
// Conditions
SkillHelper.HandleConditions(attacker, target, ref damage);
// Mana Deflector
var delayReduction = ManaDeflector.Handle(attacker, target, ref damage, tAction);
// Mana Shield
ManaShield.Handle(target, ref damage, tAction);
// Apply Damage
target.TakeDamage(tAction.Damage = damage, attacker);
// Stun Time
tAction.Stun = TargetStun;
// Death or Knockback
if (target.IsDead)
{
tAction.Set(TargetOptions.FinishingKnockDown);
attacker.Shove(target, KnockbackDistance);
}
else
{
// Always knock down
if (target.Is(RaceStands.KnockDownable))
{
tAction.Set(TargetOptions.KnockDown);
attacker.Shove(target, KnockbackDistance);
}
}
}
// Update current weapon
SkillHelper.UpdateWeapon(attacker, targets.FirstOrDefault(), ProficiencyGainType.Melee, attacker.RightHand);
cap.Handle();
Send.Effect(attacker, Effect.LightningRod, (int)LightningRodEffect.Attack, poe.X, poe.Y);
Send.SkillUse(attacker, skill.Info.Id, targetAreaId, 0, 1);
skill.Train(1); // Use the Skill
attacker.Region.RemoveProp(lProp);
}
示例6: Use
/// <summary>
/// Handles skill usage.
/// </summary>
/// <param name="attacker"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Use(Creature attacker, Skill skill, Packet packet)
{
var targetAreaEntityId = packet.GetLong();
Send.Effect(attacker, 5, (byte)1, targetAreaEntityId);
var cap = new CombatActionPack(attacker, skill.Info.Id);
var aAction = new AttackerAction(CombatActionType.Attacker, attacker, skill.Info.Id, targetAreaEntityId);
aAction.Options |= AttackerOptions.Result;
aAction.Stun = UseStun;
cap.Add(aAction);
var attackerPosition = attacker.GetPosition();
// Calculate rectangular target area
var targetAreaPos = new Position(targetAreaEntityId);
var poe = targetAreaPos.GetRelative(attackerPosition, -800);
var r = (Math.PI / 2) + Math.Atan2(attackerPosition.Y - targetAreaPos.Y, attackerPosition.X - targetAreaPos.X);
var pivot = new Point(poe.X, poe.Y);
var p1 = new Point(pivot.X - LaserRectWidth / 2, pivot.Y - LaserRectHeight / 2);
var p2 = new Point(pivot.X - LaserRectWidth / 2, pivot.Y + LaserRectHeight / 2);
var p3 = new Point(pivot.X + LaserRectWidth / 2, pivot.Y + LaserRectHeight / 2);
var p4 = new Point(pivot.X + LaserRectWidth / 2, pivot.Y - LaserRectHeight / 2);
p1 = this.RotatePoint(p1, pivot, r);
p2 = this.RotatePoint(p2, pivot, r);
p3 = this.RotatePoint(p3, pivot, r);
p4 = this.RotatePoint(p4, pivot, r);
// Attack targets
var targets = attacker.Region.GetCreaturesInPolygon(p1, p2, p3, p4);
foreach (var target in targets.Where(cr => !cr.IsDead && !cr.Has(CreatureStates.NamedNpc)))
{
var targetPosition = target.GetPosition();
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
tAction.Options = TargetOptions.Result | TargetOptions.KnockDown;
tAction.Stun = TargetStun;
tAction.Delay = 1200;
cap.Add(tAction);
// Var2: 300/1000, based on rank. Could be damage?
var damage = skill.RankData.Var2;
// Increase damage
CriticalHit.Handle(attacker, attacker.GetTotalCritChance(target.Protection), ref damage, tAction);
// Reduce damage
SkillHelper.HandleDefenseProtection(target, ref damage);
ManaShield.Handle(target, ref damage, tAction);
// Apply damage
target.TakeDamage(tAction.Damage = 300, attacker);
target.Stability = Creature.MinStability;
// Aggro
target.Aggro(attacker);
// Check death
if (target.IsDead)
tAction.Options |= TargetOptions.FinishingKnockDown;
// Knock back
attacker.Shove(target, KnockbackDistance);
}
cap.Handle();
Send.SkillUse(attacker, skill.Info.Id, 0);
}
示例7: Use
/// <summary>
/// Uses WM, attacking targets.
/// </summary>
/// <param name="attacker"></param>
/// <param name="skill"></param>
/// <param name="targetAreaId"></param>
/// <param name="unkInt1"></param>
/// <param name="unkInt2"></param>
public void Use(Creature attacker, Skill skill, long targetAreaId, int unkInt1, int unkInt2)
{
var range = this.GetRange(attacker, skill);
var targets = attacker.GetTargetableCreaturesInRange(range, true);
// Check targets
if (targets.Count == 0)
{
Send.Notice(attacker, Localization.Get("There isn't a target nearby to use that on."));
Send.SkillUseSilentCancel(attacker);
return;
}
// Create actions
var cap = new CombatActionPack(attacker, skill.Info.Id);
var aAction = new AttackerAction(CombatActionType.SpecialHit, attacker, skill.Info.Id, targetAreaId);
aAction.Set(AttackerOptions.Result);
cap.Add(aAction);
var survived = new List<Creature>();
foreach (var target in targets)
{
target.StopMove();
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
tAction.Delay = 300; // Usually 300, sometimes 350?
// Calculate damage
var damage = attacker.GetRndTotalDamage();
damage *= skill.RankData.Var1 / 100f;
// Handle skills and reductions
CriticalHit.Handle(attacker, attacker.GetTotalCritChance(0), ref damage, tAction);
SkillHelper.HandleDefenseProtection(target, ref damage);
Defense.Handle(aAction, tAction, ref damage);
ManaShield.Handle(target, ref damage, tAction);
// Clean Hit if not defended nor critical
if (tAction.SkillId != SkillId.Defense && !tAction.Has(TargetOptions.Critical))
tAction.Set(TargetOptions.CleanHit);
// Take damage if any is left
if (damage > 0)
target.TakeDamage(tAction.Damage = damage, attacker);
// Finish if dead, knock down if not defended
if (target.IsDead)
tAction.Set(TargetOptions.KnockDownFinish);
else if (tAction.SkillId != SkillId.Defense)
tAction.Set(TargetOptions.KnockDown);
// Anger Management
if (!target.IsDead)
survived.Add(target);
// Stun & knock back
aAction.Stun = CombatMastery.GetAttackerStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);
if (tAction.SkillId != SkillId.Defense)
{
tAction.Stun = CombatMastery.GetTargetStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);
target.Stability = Creature.MinStability;
attacker.Shove(target, KnockbackDistance);
}
// Add action
cap.Add(tAction);
}
// Only select a random aggro if there is no aggro yet,
// WM only aggroes one target at a time.
if (survived.Count != 0 && attacker.Region.CountAggro(attacker) < 1)
{
var rnd = RandomProvider.Get();
var aggroTarget = survived.Random();
aggroTarget.Aggro(attacker);
}
// Reduce life in old combat system
if (!AuraData.FeaturesDb.IsEnabled("CombatSystemRenewal"))
{
var amount = (attacker.LifeMax < 10 ? 2 : attacker.LifeMax / 10);
attacker.ModifyLife(-amount);
// TODO: Invincibility
}
// Spin it~
Send.UseMotion(attacker, 8, 4);
//.........这里部分代码省略.........
示例8: Use
//.........这里部分代码省略.........
if (attacker.Temp.FireArrow)
damage *= FireBonus;
// Critical Hit
var critChance = attacker.GetRightCritChance(target.Protection);
CriticalHit.Handle(attacker, critChance, ref damage, tAction);
// Subtract target def/prot
SkillHelper.HandleDefenseProtection(target, ref damage);
// Defense
Defense.Handle(aAction, tAction, ref damage);
// Mana Shield
ManaShield.Handle(target, ref damage, tAction);
// Natural Shield
var delayReduction = NaturalShield.Handle(attacker, target, ref damage, tAction);
// Deal with it!
if (damage > 0)
{
target.TakeDamage(tAction.Damage = damage, attacker);
SkillHelper.HandleInjury(attacker, target, damage);
}
// Aggro
target.Aggro(attacker);
// Knock down on deadly
if (target.Conditions.Has(ConditionsA.Deadly))
tAction.Set(TargetOptions.KnockDown);
// Death/Knockback
if (target.IsDead)
{
tAction.Set(TargetOptions.FinishingKnockDown);
}
else
{
// Insta-recover in knock down
if (target.IsKnockedDown)
{
tAction.Stun = 0;
}
// Knock down if hit repeatedly
else if (target.Stability < 30)
{
tAction.Set(TargetOptions.KnockDown);
}
// Normal stability reduction
else
{
var stabilityReduction = StabilityReduction;
// Reduce reduction, based on ping
// According to the Wiki, "the Knockdown Gauge
// [does not] build up", but it's still possible
// to knock back with repeated hits. The stability
// reduction is probably reduced, just like stun.
if (delayReduction > 0)
stabilityReduction = (short)Math.Max(0, stabilityReduction - (stabilityReduction / 100 * delayReduction));
target.Stability -= stabilityReduction;
if (target.IsUnstable)
{
tAction.Set(TargetOptions.KnockBack);
}
}
}
// Knock Back
if (tAction.IsKnockBack)
attacker.Shove(target, KnockBackDistance);
// Reduce stun, based on ping
if (delayReduction > 0)
tAction.Stun = (short)Math.Max(0, tAction.Stun - (tAction.Stun / 100 * delayReduction));
}
// Skill training
if (skill.Info.Rank == SkillRank.RF)
skill.Train(1); // Try attacking with Arrow Revolver.
// Reduce arrows
if (attacker.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteArrows && !attacker.Magazine.HasTag("/unlimited_arrow/"))
attacker.Inventory.Decrement(attacker.Magazine);
// Reduce stack
skill.Stacks--;
// Handle
cap.Handle();
// Disable fire arrow effect
if (attacker.Temp.FireArrow)
Send.Effect(attacker, Effect.FireArrow, false);
return CombatSkillResult.Okay;
}
示例9: UseSkillOnTarget
/// <summary>
/// Bolt specific use code.
/// </summary>
/// <param name="attacker"></param>
/// <param name="skill"></param>
/// <param name="target"></param>
protected override void UseSkillOnTarget(Creature attacker, Skill skill, Creature target)
{
attacker.StopMove();
target.StopMove();
// Create actions
var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, target.EntityId);
aAction.Set(AttackerOptions.Result);
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
tAction.Set(TargetOptions.Result);
tAction.Stun = TargetStun;
var cap = new CombatActionPack(attacker, skill.Info.Id, aAction, tAction);
// Damage
var damage = this.GetDamage(attacker, skill);
// Elements
damage *= this.GetElementalDamageMultiplier(attacker, target);
// Critical Hit
var critChance = attacker.GetTotalCritChance(target.Protection, true);
CriticalHit.Handle(attacker, critChance, ref damage, tAction);
// Reduce damage
Defense.Handle(aAction, tAction, ref damage);
SkillHelper.HandleMagicDefenseProtection(target, ref damage);
ManaShield.Handle(target, ref damage, tAction);
// Mana Deflector
var delayReduction = ManaDeflector.Handle(attacker, target, ref damage, tAction);
// Deal damage
if (damage > 0)
target.TakeDamage(tAction.Damage = damage, attacker);
target.Aggro(attacker);
// Knock down on deadly
if (target.Conditions.Has(ConditionsA.Deadly))
{
tAction.Set(TargetOptions.KnockDown);
tAction.Stun = TargetStun;
}
// Reduce stun, based on ping
if (delayReduction > 0)
tAction.Stun = (short)Math.Max(0, tAction.Stun - (tAction.Stun / 100 * delayReduction));
// Death/Knockback
if (target.IsDead)
{
tAction.Set(TargetOptions.FinishingKnockDown);
}
else
{
// If knocked down, instant recovery,
// if repeat hit, knock down,
// otherwise potential knock back.
if (target.IsKnockedDown)
{
tAction.Stun = 0;
}
else if (target.Stability < MinStability)
{
tAction.Set(TargetOptions.KnockDown);
}
else
{
var stabilityReduction = StabilityReduction;
// Reduce reduction, based on ping
// While the Wiki says that "the Knockdown Gauge [does not]
// build up", tests show that it does. However, it's
// reduced, assumedly based on the MD rank.
if (delayReduction > 0)
stabilityReduction = (short)Math.Max(0, stabilityReduction - (stabilityReduction / 100 * delayReduction));
target.Stability -= stabilityReduction;
if (target.IsUnstable)
{
tAction.Set(TargetOptions.KnockBack);
}
}
}
if (tAction.IsKnockBack)
attacker.Shove(target, KnockbackDistance);
// Override stun set by defense
aAction.Stun = AttackerStun;
Send.Effect(attacker, Effect.UseMagic, EffectSkillName);
//.........这里部分代码省略.........
示例10: Use
/// <summary>
/// Uses the skill.
/// </summary>
/// <param name="attacker"></param>
/// <param name="skill"></param>
/// <param name="targetEntityId"></param>
/// <returns></returns>
public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
{
// Get target
var target = attacker.Region.GetCreature(targetEntityId);
if (target == null)
return CombatSkillResult.InvalidTarget;
// Actions
var cap = new CombatActionPack(attacker, skill.Info.Id);
var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, skill.Info.Id, targetEntityId);
aAction.Set(AttackerOptions.Result);
aAction.Stun = AttackerStun;
cap.Add(aAction);
// Hit by chance
var chance = attacker.AimMeter.GetAimChance(target);
var rnd = RandomProvider.Get();
if (rnd.NextDouble() * 100 < chance)
{
target.StopMove();
aAction.Set(AttackerOptions.KnockBackHit2);
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
tAction.Set(TargetOptions.Result | TargetOptions.CleanHit);
tAction.Stun = TargetStun;
cap.Add(tAction);
// TODO: Splash damage
// Damage
var damage = this.GetDamage(attacker, skill);
// More damage with fire arrow
if (attacker.Temp.FireArrow)
damage *= FireBonus;
// Critical Hit
var critChance = attacker.GetRightCritChance(target.Protection);
CriticalHit.Handle(attacker, critChance, ref damage, tAction);
// Subtract target def/prot
SkillHelper.HandleDefenseProtection(target, ref damage);
// Defense
Defense.Handle(aAction, tAction, ref damage);
// Mana Shield
ManaShield.Handle(target, ref damage, tAction);
// Deal with it!
if (damage > 0)
target.TakeDamage(tAction.Damage = damage, attacker);
// TODO: We have to calculate knockback distance right
// TODO: Target with Defense and shield shouldn't be knocked back
attacker.Shove(target, KnockBackDistance);
// Aggro
target.Aggro(attacker);
tAction.Set(TargetOptions.KnockDownFinish);
if (target.IsDead)
{
aAction.Set(AttackerOptions.KnockBackHit1);
tAction.Set(TargetOptions.Finished);
}
}
else
{
aAction.Set(AttackerOptions.Missed);
}
// Reduce arrows
if (attacker.Magazine != null && !ChannelServer.Instance.Conf.World.InfiniteArrows)
attacker.Inventory.Decrement(attacker.Magazine);
// Disable fire arrow effect
if (attacker.Temp.FireArrow)
Send.Effect(attacker, Effect.FireArrow, false);
// "Cancels" the skill
// 800 = old load time? == aAction.Stun? Varies? Doesn't seem to be a stun.
Send.SkillUse(attacker, skill.Info.Id, 800, 1);
cap.Handle();
return CombatSkillResult.Okay;
}
示例11: Use
/// <summary>
/// Handles usage of the skill.
/// </summary>
/// <param name="attacker"></param>
/// <param name="target"></param>
public void Use(Creature attacker, Creature target)
{
// Updating unlock because of the updating lock for pre-renovation
// Has to be done here because we can't have an updating unlock
// after the combat action, it resets the stun.
if (!AuraData.FeaturesDb.IsEnabled("TalentRenovationCloseCombat"))
attacker.Unlock(Locks.Move, true);
var skill = attacker.Skills.Get(SkillId.Counterattack);
var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, SkillId.Counterattack, target.EntityId);
aAction.Options |= AttackerOptions.Result | AttackerOptions.KnockBackHit2;
var tAction = new TargetAction(CombatActionType.CounteredHit2, target, attacker, target.Skills.IsReady(SkillId.Smash) ? SkillId.Smash : SkillId.CombatMastery);
tAction.Options |= TargetOptions.Result | TargetOptions.Smash;
var cap = new CombatActionPack(attacker, skill.Info.Id);
cap.Add(aAction, tAction);
var damage =
(attacker.GetRndTotalDamage() * (skill.RankData.Var2 / 100f)) +
(target.GetRndTotalDamage() * (skill.RankData.Var1 / 100f));
var critChance = attacker.GetTotalCritChance(target.Protection) + skill.RankData.Var3;
CriticalHit.Handle(attacker, critChance, ref damage, tAction, true);
SkillHelper.HandleDefenseProtection(target, ref damage, true, true);
target.TakeDamage(tAction.Damage = damage, attacker);
target.Aggro(attacker);
if (target.IsDead)
tAction.Options |= TargetOptions.FinishingKnockDown;
aAction.Stun = StunTime;
tAction.Stun = StunTime;
target.Stability = Creature.MinStability;
attacker.Shove(target, KnockbackDistance);
// Update both weapons
SkillHelper.UpdateWeapon(attacker, target, attacker.RightHand, attacker.LeftHand);
Send.SkillUseStun(attacker, skill.Info.Id, StunTime, 1);
this.Training(aAction, tAction);
cap.Handle();
}
示例12: Use
//.........这里部分代码省略.........
target.Stability -= this.GetStabilityReduction(attacker, weapon) / maxHits;
// React normal for CombatMastery, knock down if
// FH and not dual wield, don't knock at all if dual.
if (skill.Info.Id != SkillId.FinalHit)
{
// Originally we thought you knock enemies back, unless it's a critical
// hit, but apparently you knock *down* under normal circumstances.
// More research to be done.
if (target.IsUnstable && target.Is(RaceStands.KnockBackable))
//tAction.Set(tAction.Has(TargetOptions.Critical) ? TargetOptions.KnockDown : TargetOptions.KnockBack);
tAction.Set(TargetOptions.KnockDown);
if (target.Life < 0)
tAction.Set(TargetOptions.KnockDown);
}
else if (!dualWield && !weaponIsKnuckle)
{
target.Stability = Creature.MinStability;
tAction.Set(TargetOptions.KnockDown);
}
}
}
}
else
{
tAction.Set(TargetOptions.FinishingKnockDown);
}
// React to knock back
if (tAction.IsKnockBack && tAction.Type != CombatActionType.Defended)
{
if (!target.Skills.IsReady(SkillId.FinalHit))
{
attacker.Shove(target, KnockBackDistance);
}
aAction.Set(AttackerOptions.KnockBackHit2);
// Remove dual wield option if last hit doesn't come from
// the second weapon.
if (cap.MaxHits != cap.Hit)
aAction.Options &= ~AttackerOptions.DualWield;
}
else if (tAction.Type == CombatActionType.Defended)
{
// Remove dual wield option if last hit doesn't come from
// the second weapon.
if (cap.MaxHits != cap.Hit)
aAction.Options &= ~AttackerOptions.DualWield;
}
// Set stun time
if (tAction.Type != CombatActionType.Defended)
{
if (simultaneousAttackStun == 0)
{
aAction.Stun = GetAttackerStun(attacker, weapon, tAction.IsKnockBack && ((skill.Info.Id != SkillId.FinalHit) && !target.IsDead || AuraData.FeaturesDb.IsEnabled("CombatSystemRenewal")));
}
else
{
aAction.Stun = (short)simultaneousAttackStun;
}
if (!target.Skills.IsReady(SkillId.FinalHit))
示例13: Use
/// <summary>
/// Handles usage of the skill.
/// </summary>
/// <param name="attacker"></param>
/// <param name="target"></param>
public void Use(Creature attacker, Creature target)
{
// Updating unlock because of the updating lock for pre-renovation
// Has to be done here because we can't have an updating unlock
// after the combat action, it resets the stun.
if (!AuraData.FeaturesDb.IsEnabled("TalentRenovationCloseCombat"))
{
attacker.Unlock(Locks.Run, true);
attacker.Unlock(Locks.Move, true);
}
var skill = attacker.Skills.Get(SkillId.Counterattack);
var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, SkillId.Counterattack, target.EntityId);
aAction.Options |= AttackerOptions.Result | AttackerOptions.KnockBackHit2;
var tAction = new TargetAction(CombatActionType.CounteredHit2, target, attacker, target.Skills.IsReady(SkillId.Smash) ? SkillId.Smash : SkillId.CombatMastery);
tAction.Options |= TargetOptions.Result | TargetOptions.Smash;
var cap = new CombatActionPack(attacker, skill.Info.Id);
cap.Add(aAction, tAction);
float damage;
if (attacker.RightHand != null && attacker.RightHand.Data.HasTag("/weapon/gun/")) //TODO: Only do this when out of ammo.
{
damage = (attacker.GetRndBareHandDamage() * (skill.RankData.Var2 / 100f)) +
(target.GetRndTotalDamage() * (skill.RankData.Var1 / 100f));
}
else
{
damage = (attacker.GetRndTotalDamage() * (skill.RankData.Var2 / 100f)) +
(target.GetRndTotalDamage() * (skill.RankData.Var1 / 100f));
}
var critShieldReduction = (target.LeftHand != null ? target.LeftHand.Data.DefenseBonusCrit : 0);
var critChance = attacker.GetTotalCritChance(target.Protection + critShieldReduction) + skill.RankData.Var3;
CriticalHit.Handle(attacker, critChance, ref damage, tAction, true);
var maxDamage = damage; //Damage without Defense and Protection
SkillHelper.HandleDefenseProtection(target, ref damage, true, true);
ManaShield.Handle(target, ref damage, tAction, maxDamage);
target.TakeDamage(tAction.Damage = damage, attacker);
target.Aggro(attacker);
if (target.IsDead)
tAction.Options |= TargetOptions.FinishingKnockDown;
if (attacker.IsCharacter && AuraData.FeaturesDb.IsEnabled("CombatSystemRenewal"))
{
aAction.Stun = 2000;
}
else
{
aAction.Stun = AttackStunTime;
}
tAction.Stun = StunTime;
target.Stability = Creature.MinStability;
attacker.Shove(target, KnockbackDistance);
// Update both weapons
SkillHelper.UpdateWeapon(attacker, target, attacker.RightHand, attacker.LeftHand);
Send.SkillUseStun(attacker, skill.Info.Id, aAction.Stun, 1);
this.Training(aAction, tAction);
cap.Handle();
}
示例14: Use
//.........这里部分代码省略.........
attacker.RightHand.Data.HasTag("/weapon/bow/") ||
attacker.RightHand.Data.HasTag("/weapon/crossbow/") ||
attacker.RightHand.Data.HasTag("/weapon/shuriken/") ||
attacker.RightHand.Data.HasTag("/weapon/atlatl/") ||
attacker.RightHand.Data.HasTag("/weapon/gun/dualgun/")))
{
damage = attacker.GetRndBareHandDamage();
}
else
{
damage = attacker.GetRndTotalDamage();
}
damage *= skill.RankData.Var1 / 100f;
// Handle skills and reductions
var allCrit = false;
var critSkill = target.Skills.Get(SkillId.CriticalHit);
if (allCrit)
{
// Add crit bonus
var bonus = critSkill.RankData.Var1 / 100f;
damage = damage + (damage * bonus);
// Set target option
tAction.Set(TargetOptions.Critical);
}
else if (i == 1)
{
CriticalHit.Handle(attacker, attacker.GetTotalCritChance(0), ref damage, tAction);
if (tAction.Has(TargetOptions.Critical))
allCrit = true;
}
var maxDamage = damage; //Damage without Defense and Protection
SkillHelper.HandleDefenseProtection(target, ref damage);
Defense.Handle(aAction, tAction, ref damage);
ManaShield.Handle(target, ref damage, tAction, maxDamage);
// Clean Hit if not defended nor critical
if (!tAction.Is(CombatActionType.Defended) && !tAction.Has(TargetOptions.Critical))
tAction.Set(TargetOptions.CleanHit);
// Take damage if any is left
if (damage > 0)
target.TakeDamage(tAction.Damage = damage, attacker);
// Finish if dead, knock down if not defended
if (target.IsDead)
tAction.Set(TargetOptions.KnockDownFinish);
else if (!tAction.Is(CombatActionType.Defended))
tAction.Set(TargetOptions.KnockDown);
// Anger Management
if (!target.IsDead)
survived.Add(target);
if (target.UseBattleStanceFromAOE)
target.IsInBattleStance = true;
// Stun & knock back
aAction.Stun = CombatMastery.GetAttackerStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);
if (!tAction.Is(CombatActionType.Defended))
{
tAction.Stun = CombatMastery.GetTargetStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);
target.Stability = Creature.MinStability;
attacker.Shove(target, KnockbackDistance);
}
// Add action
cap.Add(tAction);
}
// Only select a random aggro if there is no aggro yet,
// WM only aggroes one target at a time.
if (survived.Count != 0 && attacker.Region.CountAggro(attacker) < 1)
{
var rnd = RandomProvider.Get();
var aggroTarget = survived.Random();
aggroTarget.Aggro(attacker);
}
// Reduce life in old combat system
if (!AuraData.FeaturesDb.IsEnabled("CombatSystemRenewal"))
{
var amount = (attacker.LifeMax < 10 ? 2 : attacker.LifeMax / 10);
attacker.ModifyLife(-amount);
attacker.InvincibilityTime = DateTime.Now.AddMilliseconds(2300);
}
// Spin it~
Send.UseMotion(attacker, 8, 4);
cap.Handle();
Send.SkillUse(attacker, skill.Info.Id, targetAreaId, unkInt1, unkInt2);
skill.Stacks = 0;
}
示例15: Use
//.........这里部分代码省略.........
var aAction = new AttackerAction(CombatActionType.HardHit, attacker, skill.Info.Id, targetEntityId);
aAction.Set(AttackerOptions.Result | AttackerOptions.KnockBackHit2);
TargetAction tAction;
if (attacker.InterceptingSkillId == SkillId.Smash)
{
aAction.Options |= AttackerOptions.Result;
tAction = new TargetAction(CombatActionType.CounteredHit, target, attacker, SkillId.Smash);
}
else
{
tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
}
tAction.Set(TargetOptions.Result | TargetOptions.Smash);
attacker.InterceptingSkillId = SkillId.None;
var cap = new CombatActionPack(attacker, skill.Info.Id, tAction, aAction);
// Calculate damage
var damage = this.GetDamage(attacker, skill);
var critChance = this.GetCritChance(attacker, target, skill);
// Critical Hit
CriticalHit.Handle(attacker, critChance, ref damage, tAction);
var maxDamage = damage; //Damage without Defense and Protection
// Subtract target def/prot
SkillHelper.HandleDefenseProtection(target, ref damage);
// Mana Shield
ManaShield.Handle(target, ref damage, tAction, maxDamage);
// Apply damage
target.TakeDamage(tAction.Damage = damage, attacker);
// Aggro
target.Aggro(attacker);
if (target.IsDead)
tAction.Set(TargetOptions.FinishingHit | TargetOptions.Finished);
// Set Stun/Knockback
attacker.Stun = aAction.Stun = StunTime;
target.Stun = tAction.Stun = StunTime;
target.Stability = Creature.MinStability;
// Set knockbacked position
attacker.Shove(target, KnockbackDistance);
// Response
Send.SkillUseStun(attacker, skill.Info.Id, AfterUseStun, 1);
// Update both weapons
SkillHelper.UpdateWeapon(attacker, target, attacker.RightHand, attacker.LeftHand);
var critSkill = attacker.Skills.Get(SkillId.CriticalHit);
if (skill.Info.Rank >= SkillRank.R5 && weapon != null && weapon.Data.SplashRadius != 0 && weapon.Data.SplashAngle != 0)
{
foreach (var splashTarget in targets)
{
if (splashTarget != target)
{
if (splashTarget.IsNotReadyToBeHit)
continue;
TargetAction tSplashAction = new TargetAction(CombatActionType.TakeHit, splashTarget, attacker, skill.Info.Id);
tSplashAction.Set(TargetOptions.Result | TargetOptions.Smash);
// Base damage
float damageSplash = this.GetDamage(attacker, skill);
attacker.CalculateSplashDamage(splashTarget, ref damageSplash, skill, critSkill, aAction, tAction, tSplashAction);
// Deal with it!
if (damageSplash > 0)
splashTarget.TakeDamage(tSplashAction.Damage = damageSplash, attacker);
// Alert
splashTarget.Aggro(attacker, true);
if (splashTarget.IsDead)
tSplashAction.Set(TargetOptions.FinishingHit | TargetOptions.Finished);
splashTarget.Stun = tSplashAction.Stun = StunTime;
splashTarget.Stability = Creature.MinStability;
// Set knockbacked position
attacker.Shove(splashTarget, KnockbackDistance);
cap.Add(tSplashAction);
}
}
}
// Action!
cap.Handle();
return CombatSkillResult.Okay;
}