本文整理汇总了C#中Aura.Channel.World.Entities.Creature.AttackRangeFor方法的典型用法代码示例。如果您正苦于以下问题:C# Creature.AttackRangeFor方法的具体用法?C# Creature.AttackRangeFor怎么用?C# Creature.AttackRangeFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aura.Channel.World.Entities.Creature
的用法示例。
在下文中一共展示了Creature.AttackRangeFor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Use
/// <summary>
/// Handles skill usage.
/// </summary>
/// <param name="attacker"></param>
/// <param name="skill"></param>
/// <param name="targetEntityId"></param>
/// <returns></returns>
public override CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
{
// Check target
var mainTarget = attacker.Region.GetCreature(targetEntityId);
if (mainTarget == null)
return CombatSkillResult.InvalidTarget;
// Check range
var targetPosition = mainTarget.GetPosition();
if (!attacker.GetPosition().InRange(targetPosition, attacker.AttackRangeFor(mainTarget)))
return CombatSkillResult.OutOfRange;
// Stop movement
attacker.StopMove();
// Get targets, incl. splash.
// Splash happens from r5 onwards, but we'll base it on Var4,
// which is the splash damage and first != 0 on r5.
var targets = new HashSet<Creature>() { mainTarget };
if (skill.RankData.Var4 != 0)
targets.UnionWith(attacker.GetTargetableCreaturesInCone(mainTarget.GetPosition(), attacker.GetTotalSplashRadius(), attacker.GetTotalSplashAngle()));
// Counter
if (Counterattack.Handle(targets, attacker))
return CombatSkillResult.Okay;
// Prepare combat actions
var aAction = new AttackerAction(CombatActionType.HardHit, attacker, targetEntityId);
aAction.Set(AttackerOptions.Result | AttackerOptions.KnockBackHit2);
aAction.Stun = StunTime;
var cap = new CombatActionPack(attacker, skill.Info.Id, aAction);
// Calculate damage
var mainDamage = this.GetDamage(attacker, skill);
foreach (var target in targets)
{
// Stop movement
target.StopMove();
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
tAction.Set(TargetOptions.Result | TargetOptions.Smash);
cap.Add(tAction);
// Damage
var damage = mainDamage;
// Elementals
damage *= attacker.CalculateElementalDamageMultiplier(target);
// Splash modifier
if (target != mainTarget)
damage *= (skill.RankData.Var4 / 100f);
// Critical Hit
var critChance = this.GetCritChance(attacker, target, skill);
CriticalHit.Handle(attacker, critChance, ref damage, tAction);
// Subtract target def/prot
SkillHelper.HandleDefenseProtection(target, ref damage);
// Mana Shield
ManaShield.Handle(target, ref damage, tAction);
// Heavy Stander
HeavyStander.Handle(attacker, target, ref damage, tAction);
// Apply damage
if (damage > 0)
{
target.TakeDamage(tAction.Damage = damage, attacker);
SkillHelper.HandleInjury(attacker, target, damage);
}
// Aggro
if (target == mainTarget)
target.Aggro(attacker);
if (target.IsDead)
tAction.Set(TargetOptions.FinishingHit | TargetOptions.Finished);
// Set Stun/Knockback
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);
//.........这里部分代码省略.........
示例2: Use
/// <summary>
/// Handles skill usage.
/// </summary>
/// <param name="attacker"></param>
/// <param name="skill"></param>
/// <param name="targetEntityId"></param>
/// <returns></returns>
public override CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
{
// Check target
var target = attacker.Region.GetCreature(targetEntityId);
if (target == null)
return CombatSkillResult.InvalidTarget;
// Check range
var targetPosition = target.GetPosition();
if (!attacker.GetPosition().InRange(targetPosition, attacker.AttackRangeFor(target)))
return CombatSkillResult.OutOfRange;
// Stop movement
attacker.StopMove();
target.StopMove();
// Counter
if (Counterattack.Handle(target, attacker))
return CombatSkillResult.Okay;
// Prepare combat actions
var aAction = new AttackerAction(CombatActionType.HardHit, attacker, targetEntityId);
aAction.Set(AttackerOptions.Result | AttackerOptions.KnockBackHit2);
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
tAction.Set(TargetOptions.Result | TargetOptions.Smash);
var cap = new CombatActionPack(attacker, skill.Info.Id, aAction, tAction);
// Calculate damage
var damage = this.GetDamage(attacker, skill);
// Elementals
damage *= attacker.CalculateElementalDamageMultiplier(target);
// Critical Hit
var critChance = this.GetCritChance(attacker, target, skill);
CriticalHit.Handle(attacker, critChance, ref damage, tAction);
// Subtract target def/prot
SkillHelper.HandleDefenseProtection(target, ref damage);
// Mana Shield
ManaShield.Handle(target, ref damage, tAction);
// Heavy Stander
HeavyStander.Handle(attacker, target, ref damage, tAction);
// Apply damage
if (damage > 0)
{
target.TakeDamage(tAction.Damage = damage, attacker);
SkillHelper.HandleInjury(attacker, target, damage);
}
// 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);
// Action!
cap.Handle();
return CombatSkillResult.Okay;
}
示例3: Use
/// <summary>
/// Handles attack.
/// </summary>
/// <param name="attacker">The creature attacking.</param>
/// <param name="skill">The skill being used.</param>
/// <param name="targetEntityId">The entity id of the target.</param>
/// <returns></returns>
public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
{
if (attacker.IsStunned)
return CombatSkillResult.Okay;
var target = attacker.Region.GetCreature(targetEntityId);
if (target == null)
return CombatSkillResult.Okay;
if (!attacker.GetPosition().InRange(target.GetPosition(), attacker.AttackRangeFor(target)))
return CombatSkillResult.OutOfRange;
attacker.StopMove();
var targetPosition = target.StopMove();
// Counter
if (Counterattack.Handle(target, attacker))
return CombatSkillResult.Okay;
var rightWeapon = attacker.Inventory.RightHand;
var leftWeapon = attacker.Inventory.LeftHand;
var magazine = attacker.Inventory.Magazine;
var dualWield = (rightWeapon != null && leftWeapon != null && leftWeapon.Data.WeaponType != 0);
var maxHits = (byte)(dualWield ? 2 : 1);
int prevId = 0;
for (byte i = 1; i <= maxHits; ++i)
{
var weapon = (i == 1 ? rightWeapon : leftWeapon);
var weaponIsKnuckle = (weapon != null && weapon.Data.HasTag("/knuckle/"));
var aAction = new AttackerAction(CombatActionType.Attacker, attacker, skill.Info.Id, targetEntityId);
aAction.Set(AttackerOptions.Result);
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
tAction.Set(TargetOptions.Result);
var cap = new CombatActionPack(attacker, skill.Info.Id, aAction, tAction);
cap.Hit = i;
cap.Type = (dualWield ? CombatActionPackType.TwinSwordAttack : CombatActionPackType.NormalAttack);
cap.PrevId = prevId;
prevId = cap.Id;
// Default attacker options
aAction.Set(AttackerOptions.Result);
if (dualWield)
{
aAction.Set(AttackerOptions.DualWield);
aAction.WeaponParameterType = (byte)(i == 1 ? 2 : 1);
}
// Base damage
var damage = (i == 1 ? attacker.GetRndRightHandDamage() : attacker.GetRndLeftHandDamage());
// Critical Hit
var critChance = (i == 1 ? attacker.GetRightCritChance(target.Protection) : attacker.GetLeftCritChance(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);
// Aggro
target.Aggro(attacker);
// Evaluate caused damage
if (!target.IsDead)
{
if (tAction.SkillId != SkillId.Defense)
{
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);
}
else if (!dualWield && !weaponIsKnuckle)
//.........这里部分代码省略.........
示例4: Use
/// <summary>
/// Handles skill usage.
/// </summary>
/// <param name="attacker"></param>
/// <param name="skill"></param>
/// <param name="targetEntityId"></param>
/// <returns></returns>
public override CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
{
// Check target
var target = attacker.Region.GetCreature(targetEntityId);
if (target == null)
return CombatSkillResult.InvalidTarget;
if (target.IsNotReadyToBeHit)
return CombatSkillResult.Okay;
if ((attacker.IsStunned || attacker.IsOnAttackDelay) && attacker.InterceptingSkillId == SkillId.None)
return CombatSkillResult.Okay;
// Check range
var attackerPosition = attacker.GetPosition();
var targetPosition = target.GetPosition();
if (!attacker.IgnoreAttackRange &&
(!attackerPosition.InRange(targetPosition, attacker.AttackRangeFor(target))))
{ return CombatSkillResult.OutOfRange; }
if (!attacker.IgnoreAttackRange &&
(attacker.Region.Collisions.Any(attackerPosition, targetPosition) // Check collisions between position
|| target.Conditions.Has(ConditionsA.Invisible))) // Check visiblility (GM)
{ return CombatSkillResult.Okay; }
attacker.IgnoreAttackRange = false;
// Against Normal Attack
Skill combatMastery = target.Skills.Get(SkillId.CombatMastery);
if (combatMastery != null && (target.Skills.ActiveSkill == null || target.Skills.ActiveSkill == combatMastery || target.Skills.IsReady(SkillId.FinalHit)) && target.IsInBattleStance && target.Target == attacker && target.AttemptingAttack && (!target.IsStunned || target.IsKnockedDown))
{
target.InterceptingSkillId = SkillId.Smash;
target.IgnoreAttackRange = true;
var skillHandler = ChannelServer.Instance.SkillManager.GetHandler<ICombatSkill>(combatMastery.Info.Id);
if (skillHandler == null)
{
Log.Error("Smash.Use: Target's skill handler not found for '{0}'.", combatMastery.Info.Id);
return CombatSkillResult.Okay;
}
skillHandler.Use(target, combatMastery, attacker.EntityId);
return CombatSkillResult.Okay;
}
// Against Windmill
//TODO: Change this into the new NPC client system when it comes out if needed.
Skill windmill = target.Skills.Get(SkillId.Windmill);
if (windmill != null && target.Skills.IsReady(SkillId.Windmill) && !target.IsPlayer && target.CanAttack(attacker))
{
target.InterceptingSkillId = SkillId.Smash;
var skillHandler = ChannelServer.Instance.SkillManager.GetHandler<IUseable>(windmill.Info.Id) as Windmill;
if (skillHandler == null)
{
Log.Error("Smash.Use: Target's skill handler not found for '{0}'.", windmill.Info.Id);
return CombatSkillResult.Okay;
}
skillHandler.Use(target, windmill);
return CombatSkillResult.Okay;
}
// Against Smash
Skill smash = target.Skills.Get(SkillId.Smash);
if (smash != null && target.Skills.IsReady(SkillId.Smash) && target.IsInBattleStance && target.Target == attacker && !target.IsStunned && attacker.CanAttack(target))
{
var attackerStunTime = CombatMastery.GetAttackerStun(attacker, attacker.RightHand, false);
var targetStunTime = CombatMastery.GetAttackerStun(target, target.Inventory.RightHand, false);
if ((target.LastKnockedBackBy == attacker && target.KnockDownTime > attacker.KnockDownTime &&
target.KnockDownTime.AddMilliseconds(targetStunTime) < DateTime.Now //If last knocked down within the time it takes for you to finish attacking.
|| attackerStunTime > targetStunTime &&
!Math2.Probability(((2725 - attackerStunTime) / 2500) * 100) //Probability in percentage that you will not lose. 2725 is 2500 (Slowest stun) + 225 (Fastest stun divided by two so that the fastest stun isn't 100%)
&& !(attacker.LastKnockedBackBy == target && attacker.KnockDownTime > target.KnockDownTime && attacker.KnockDownTime.AddMilliseconds(attackerStunTime) < DateTime.Now)))
{
if (target.CanAttack(attacker))
{
target.InterceptingSkillId = SkillId.Smash;
target.IgnoreAttackRange = true;
var skillHandler = ChannelServer.Instance.SkillManager.GetHandler<ICombatSkill>(smash.Info.Id);
if (skillHandler == null)
{
Log.Error("Smash.Use: Target's skill handler not found for '{0}'.", smash.Info.Id);
return CombatSkillResult.Okay;
}
skillHandler.Use(target, smash, attacker.EntityId);
return CombatSkillResult.Okay;
}
}
else
{
attacker.InterceptingSkillId = SkillId.Smash;
}
}
// Stop movement
attacker.StopMove();
target.StopMove();
//.........这里部分代码省略.........
示例5: Use
/// <summary>
/// Handles attack.
/// </summary>
/// <param name="attacker">The creature attacking.</param>
/// <param name="skill">The skill being used.</param>
/// <param name="targetEntityId">The entity id of the target.</param>
/// <returns></returns>
public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
{
var target = attacker.Region.GetCreature(targetEntityId);
if (target == null)
return CombatSkillResult.Okay;
if (target.IsNotReadyToBeHit)
return CombatSkillResult.Okay;
if ((attacker.IsStunned || attacker.IsOnAttackDelay) && attacker.InterceptingSkillId == SkillId.None)
return CombatSkillResult.Okay;
var attackerPosition = attacker.GetPosition();
var targetPosition = target.GetPosition();
if (!attacker.IgnoreAttackRange &&
(!attackerPosition.InRange(targetPosition, attacker.AttackRangeFor(target))))
{ return CombatSkillResult.OutOfRange; }
if (!attacker.IgnoreAttackRange &&
(attacker.Region.Collisions.Any(attackerPosition, targetPosition) // Check collisions between position
|| target.Conditions.Has(ConditionsA.Invisible))) // Check visiblility (GM)
{ return CombatSkillResult.Okay; }
attacker.IgnoreAttackRange = false;
//Against Smash
Skill smash = target.Skills.Get(SkillId.Smash);
if (smash != null && target.Skills.IsReady(SkillId.Smash) && attacker.CanAttack(target))
attacker.InterceptingSkillId = SkillId.Smash;
var rightWeapon = attacker.RightHand;
var leftWeapon = attacker.Inventory.LeftHand;
var dualWield = (rightWeapon != null && leftWeapon != null && leftWeapon.Data.WeaponType != 0 && (leftWeapon.HasTag("/weapon/edged/") || leftWeapon.HasTag("/weapon/blunt/")));
var staminaUsage = (rightWeapon != null && rightWeapon.Data.StaminaUsage != 0 ? rightWeapon.Data.StaminaUsage : 0.7f) + (dualWield ? leftWeapon.Data.StaminaUsage : 0f);
var lowStamina = false;
if (attacker.Stamina < staminaUsage)
{
lowStamina = true;
Send.Notice(attacker, Localization.Get("Your stamina is too low to attack properly!"));
}
attacker.Stamina -= staminaUsage;
Send.StatUpdate(attacker, StatUpdateType.Private, Stat.Stamina);
// Against Combat Mastery
Skill combatMastery = target.Skills.Get(SkillId.CombatMastery);
var simultaneousAttackStun = 0;
if (attacker.InterceptingSkillId != SkillId.CombatMastery && target.InterceptingSkillId != SkillId.CombatMastery)
{
if (combatMastery != null && (target.Skills.ActiveSkill == null || target.Skills.ActiveSkill == combatMastery || target.Skills.IsReady(SkillId.FinalHit)) && target.IsInBattleStance && target.Target == attacker && target.AttemptingAttack && (!target.IsStunned || target.IsKnockedDown) && attacker.CanAttack(target))
{
var attackerStunTime = CombatMastery.GetAttackerStun(attacker, attacker.RightHand, false);
var targetStunTime = CombatMastery.GetAttackerStun(target, target.Inventory.RightHand, false);
if ((target.LastKnockedBackBy == attacker && target.KnockDownTime > attacker.KnockDownTime &&
target.KnockDownTime.AddMilliseconds(targetStunTime) < DateTime.Now //If last knocked down within the time it takes for you to finish attacking.
|| attackerStunTime > targetStunTime &&
!Math2.Probability(((2725 - attackerStunTime) / 2500) * 100) //Probability in percentage that you will not lose. 2725 is 2500 (Slowest stun) + 225 (Fastest stun divided by two so that the fastest stun isn't 100%)
&& !(attacker.LastKnockedBackBy == target && attacker.KnockDownTime > target.KnockDownTime && attacker.KnockDownTime.AddMilliseconds(attackerStunTime) < DateTime.Now)))
{
if (target.CanAttack(attacker))
{
target.InterceptingSkillId = SkillId.CombatMastery;
target.IgnoreAttackRange = true;
var skillHandler = ChannelServer.Instance.SkillManager.GetHandler<ICombatSkill>(combatMastery.Info.Id);
if (skillHandler == null)
{
Log.Error("CombatMastery.Use: Target's skill handler not found for '{0}'.", combatMastery.Info.Id);
return CombatSkillResult.Okay;
}
skillHandler.Use(target, combatMastery, attacker.EntityId);
return CombatSkillResult.Okay;
}
}
else
{
if (Math2.Probability(((2725 - attackerStunTime) / 2500) * 100)) //Probability in percentage that it will be an interception instead of a double hit.
{
attacker.InterceptingSkillId = SkillId.CombatMastery;
}
else
{
attacker.InterceptingSkillId = SkillId.CombatMastery;
if (target.CanAttack(attacker))
{
target.InterceptingSkillId = SkillId.CombatMastery;
target.IgnoreAttackRange = true;
var skillHandler = ChannelServer.Instance.SkillManager.GetHandler<ICombatSkill>(combatMastery.Info.Id);
if (skillHandler == null)
{
Log.Error("CombatMastery.Use: Target's skill handler not found for '{0}'.", combatMastery.Info.Id);
}
else
{
//.........这里部分代码省略.........
示例6: Use
public void Use(Creature creature, Skill skill, long targetEntityId, int unk1, int unk2)
{
if (_cm == null)
_cm = ChannelServer.Instance.SkillManager.GetHandler<CombatMastery>(SkillId.CombatMastery);
var attackResult = false;
var target = creature.Region.GetCreature(targetEntityId);
if (target != null && !creature.IsStunned && !creature.IsOnAttackDelay && creature.CanTarget(target) && creature.CanAttack(target))
{
var pos = creature.GetPosition();
var targetPos = target.GetPosition();
var inRange = (pos.InRange(targetPos, creature.AttackRangeFor(target))
&& !creature.Region.Collisions.Any(pos, targetPos) // Check collisions between position
&& !target.Conditions.Has(ConditionsA.Invisible)); // Check visiblility (GM)
if (!inRange && !target.IsNotReadyToBeHit)
{
var telePos = pos.GetRelative(targetPos, -creature.AttackRangeFor(target) + 100);
// Check teleport distance
if (pos.GetDistance(telePos) > skill.RankData.Var3 + 100)
{
Send.Notice(creature, "Out of range");
}
else
{
Send.Effect(creature, Effect.SilentMoveTeleport, targetEntityId, (byte)0);
creature.SetPosition(telePos.X, telePos.Y);
Send.SkillTeleport(creature, telePos.X, telePos.Y);
inRange = true;
}
}
if (inRange)
attackResult = (_cm.Use(creature, skill, targetEntityId) == CombatSkillResult.Okay);
}
Send.CombatAttackR(creature, attackResult);
Send.SkillUse(creature, skill.Info.Id, targetEntityId, unk1, unk2);
}
示例7: Use
public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
{
if (attacker.IsStunned)
return CombatSkillResult.Okay;
var target = attacker.Region.GetCreature(targetEntityId);
if (target == null)
return CombatSkillResult.Okay;
if (!attacker.GetPosition().InRange(target.GetPosition(), attacker.AttackRangeFor(target)))
return CombatSkillResult.OutOfRange;
attacker.StopMove();
var targetPosition = target.StopMove();
var rightWeapon = attacker.Inventory.RightHand;
var leftWeapon = attacker.Inventory.LeftHand;
var magazine = attacker.Inventory.Magazine;
var dualWield = (rightWeapon != null && leftWeapon != null);
var maxHits = (byte)(dualWield ? 2 : 1);
int prevId = 0;
for (byte i = 1; i <= maxHits; ++i)
{
var weapon = (i == 1 ? rightWeapon : leftWeapon);
var cap = new CombatActionPack(attacker, skill.Info.Id);
var aAction = new AttackerAction(CombatActionType.Hit, attacker, skill.Info.Id, targetEntityId);
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
cap.Add(aAction, tAction);
cap.Hit = i;
cap.MaxHits = maxHits;
cap.PrevId = prevId;
prevId = cap.Id;
aAction.Set(AttackerOptions.Result);
if (dualWield)
aAction.Set(AttackerOptions.DualWield);
var damage = attacker.GetRndDamage(weapon);
tAction.Damage = damage;
target.TakeDamage(tAction.Damage, attacker);
if (!target.IsDead)
{
target.KnockBack += this.GetKnockBack(weapon) / maxHits;
if (target.KnockBack >= 100 && target.Is(RaceStands.KnockBackable))
tAction.Set(tAction.Has(TargetOptions.Critical) ? TargetOptions.KnockDown : TargetOptions.KnockBack);
}
else
{
tAction.Set(TargetOptions.FinishingKnockDown);
}
if (tAction.IsKnockBack)
{
var newPos = attacker.GetPosition().GetRelative(targetPosition, KnockBackDistance);
Position intersection;
if (target.Region.Collissions.Find(targetPosition, newPos, out intersection))
newPos = targetPosition.GetRelative(intersection, -50);
target.SetPosition(newPos.X, newPos.Y);
aAction.Set(AttackerOptions.KnockBackHit2);
cap.MaxHits = cap.Hit;
}
aAction.Stun = this.GetAttackerStun(weapon, tAction.IsKnockBack);
tAction.Stun = this.GetTargetStun(weapon, tAction.IsKnockBack);
cap.Handle();
if (tAction.IsKnockBack)
break;
}
return CombatSkillResult.Okay;
}