本文整理汇总了C#中Unit.HasModifier方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.HasModifier方法的具体用法?C# Unit.HasModifier怎么用?C# Unit.HasModifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.HasModifier方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: All
public static bool All(string name, Unit hero, Ability ability = null)
{
if ((name == "item_diffusal_blade" || name == "item_diffusal_blade_2")
&& hero.HasModifier("modifier_item_diffusal_blade_slow"))
{
return false;
}
if (name == "slardar_amplify_damage" && hero.HasModifier("modifier_slardar_amplify_damage"))
{
return false;
}
if (name == "bloodseeker_bloodrage" && hero.HasModifier("modifier_bloodseeker_bloodrage"))
{
return false;
}
if (name == "axe_battle_hunger" && hero.HasModifier("modifier_axe_battle_hunger"))
{
return false;
}
if (name == "bounty_hunter_track" && hero.HasModifier("modifier_bounty_hunter_track"))
{
return false;
}
if (name == "visage_soul_assumption" && ability != null)
{
var modif = AbilityMain.Me.FindModifier("modifier_visage_soul_assumption");
if (modif == null || modif.StackCount < ability.GetAbilityData("stack_limit"))
{
return false;
}
}
return true;
}
示例2: AddEffect
public void AddEffect(Unit target, ParticleEffect eff, float range)
{
var handle = target.Handle;
ParticleEffect effect;
if (!_effectDictionary.TryGetValue(handle, out effect))
{
_effectDictionary.Add(handle, eff);
Printer.Print($"[{_name}][NewEffect]: {target.Name}");
Game.OnUpdate += args =>
{
if (!Game.IsInGame) return;
try
{
if (eff == null || !eff.IsValid || eff.IsDestroyed) return;
if (target.HasModifier("modifier_boots_of_travel_incoming"))
{
RemoveEffect(target);
return;
}
var frontPoint = Helper.InFront(Members.MyHero, target, range);
eff.SetControlPoint(1, target.Position);
eff.SetControlPoint(2, frontPoint);
}
catch (Exception)
{
}
};
}
else
{
effect.Dispose();
_effectDictionary.Remove(handle);
AddEffect(target, eff);
Printer.Print($"[{_name}][Remove&NewEffect]: {target.Name}");
}
}
示例3: CanIncreaseMagicDmg
private bool CanIncreaseMagicDmg(Hero source, Unit target)
{
//var orchid = source.FindItem("item_orchid") ?? source.FindItem("item_bloodthorn");
var veil = source.FindItem("item_veil_of_discord");
ethereal = source.FindItem("item_ethereal_blade");
return (//(orchid != null && orchid.CanBeCasted() && !target.HasModifier("modifier_orchid_malevolence_debuff"))||
(veil != null && veil.CanBeCasted() && !target.HasModifier("modifier_item_veil_of_discord_debuff"))
|| (ethereal != null && ethereal.CanBeCasted() && !IsDisembodied(target))
)
&& source.CanUseItems();
}
示例4: CastStun
/// <summary>
/// Uses given ability in case enemy is not disabled or would be chain stunned.
/// </summary>
/// <param name="ability">
/// The ability.
/// </param>
/// <param name="target">
/// The target.
/// </param>
/// <param name="sourcePosition">
/// The source Position.
/// </param>
/// <param name="straightTimeforSkillShot">
/// The straight Time for Skill Shot.
/// </param>
/// <param name="chainStun">
/// The chain Stun.
/// </param>
/// <param name="useSleep">
/// The use Sleep.
/// </param>
/// <param name="abilityName">
/// The ability Name.
/// </param>
/// <param name="soulRing">
/// The soul Ring.
/// </param>
/// <param name="otherTargets">
/// The other Targets.
/// </param>
/// <returns>
/// returns true in case of successful cast
/// </returns>
public static bool CastStun(
this Ability ability,
Unit target,
Vector3 sourcePosition,
float straightTimeforSkillShot = 0,
bool chainStun = true,
bool useSleep = true,
string abilityName = null,
Ability soulRing = null,
List<Unit> otherTargets = null)
{
if (!ability.CanBeCasted())
{
return false;
}
if (target == null || !target.IsValid)
{
return false;
}
var name = abilityName ?? ability.StoredName();
var delay = ability.GetHitDelay(target, name) + 0.1f;
var canUse = Utils.ChainStun(target, delay, null, false, name);
if (!canUse && chainStun
&& (!target.HasModifier("modifier_pudge_meat_hook")
|| (ability.StoredName() != "pudge_dismember" && ability.StoredName() != "pudge_rot")))
{
return false;
}
if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name) && name != "lion_impale"
&& !target.IsInvul())
{
if (!ability.CanHit(target, sourcePosition))
{
return false;
}
if (ability.ManaCost > 0 && soulRing.CanBeCasted())
{
soulRing.UseAbility();
}
ability.UseAbility(target);
}
else if (ability.IsAbilityBehavior(AbilityBehavior.AreaOfEffect, name)
|| ability.IsAbilityBehavior(AbilityBehavior.Point, name) || name == "lion_impale"
|| (name == "earthshaker_enchant_totem" && (ability.Owner as Hero).AghanimState())
|| ability.IsSkillShot())
{
var stunned = target.IsStunned() || target.IsInvul() || target.IsRooted() || target.IsHexed();
if ((!(Prediction.StraightTime(target) > straightTimeforSkillShot * 1000) && !stunned)
|| !ability.CastSkillShot(target, name, soulRing, otherTargets))
{
return false;
}
if (useSleep)
{
Utils.Sleep(Math.Max(delay, 0.2) * 1000 + 250, "CHAINSTUN_SLEEP");
}
return true;
}
else if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
{
//.........这里部分代码省略.........
示例5: CanHit
/// <summary>
/// Checks if you could hit hero with given ability
/// </summary>
/// <param name="ability">
/// The ability.
/// </param>
/// <param name="target">
/// The target.
/// </param>
/// <param name="sourcePosition">
/// The source Position.
/// </param>
/// <param name="abilityName">
/// The ability Name.
/// </param>
/// <returns>
/// The <see cref="bool" />.
/// </returns>
public static bool CanHit(this Ability ability, Unit target, Vector3 sourcePosition, string abilityName = null)
{
if (ability == null || !ability.IsValid)
{
return false;
}
if (target == null || !target.IsValid)
{
return false;
}
var name = abilityName ?? ability.StoredName();
if (ability.Owner.Equals(target))
{
return true;
}
var id = ability.Handle + target.Handle;
if (sleeper.Sleeping(id))
{
return canHitDictionary[id];
}
var position = sourcePosition;
if (ability.IsAbilityBehavior(AbilityBehavior.Point, name) || name == "lion_impale"
|| (name == "earthshaker_enchant_totem" && (ability.Owner as Hero).AghanimState()))
{
var pred = ability.GetPrediction(target, abilityName: name);
var lion = name == "lion_impale" ? ability.GetAbilityData("length_buffer") : 0;
return position.Distance2D(pred)
<= ability.TravelDistance() + ability.GetRadius(name) + lion + target.HullRadius;
}
if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
{
var pred = ability.GetPrediction(target, abilityName: name);
var distanceXyz = position.Distance2D(pred);
var radius = ability.GetRadius(name);
var range = ability.GetCastRange(name);
if (name.StartsWith("nevermore_shadowraze"))
{
range += radius / 2;
}
if (distanceXyz <= range && position.Distance2D(target.Position) <= range)
{
canHitDictionary[id] = true;
sleeper.Sleep(50, id);
return true;
}
canHitDictionary[id] = name == "pudge_rot" && target.HasModifier("modifier_pudge_meat_hook")
&& position.Distance2D(target) < 1500;
sleeper.Sleep(50, id);
return canHitDictionary[id];
}
if (!ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name))
{
canHitDictionary[id] = false;
sleeper.Sleep(50, id);
return false;
}
if (target.IsInvul())
{
canHitDictionary[id] = false;
sleeper.Sleep(50, id);
return false;
}
if (position.Distance2D(target.Position) <= ability.GetCastRange(name) + 100)
{
canHitDictionary[id] = true;
sleeper.Sleep(50, id);
return true;
}
canHitDictionary[id] = name == "pudge_dismember" && target.HasModifier("modifier_pudge_meat_hook")
&& position.Distance2D(target) < 600;
sleeper.Sleep(50, id);
//.........这里部分代码省略.........
示例6: PredictedXYZ
/// <summary>
/// Returns predicted location of given unit after given delay in ms
/// </summary>
/// <param name="unit">
/// The unit.
/// </param>
/// <param name="delay">
/// The delay.
/// </param>
/// <returns>
/// The <see cref="Vector3" />.
/// </returns>
public static Vector3 PredictedXYZ(Unit unit, float delay)
{
if (IsIdle(unit))
{
return unit.Position;
}
var targetSpeed = new Vector3();
if (!lastRotRDictionary.ContainsKey(unit.Handle))
{
lastRotRDictionary.Add(unit.Handle, unit.RotationRad);
}
var straightTime = StraightTime(unit);
if (straightTime > 180)
{
lastRotRDictionary[unit.Handle] = unit.RotationRad;
}
lastRotRDictionary[unit.Handle] = unit.RotationRad;
if ((unit.ClassID == ClassID.CDOTA_Unit_Hero_StormSpirit || unit.ClassID == ClassID.CDOTA_Unit_Hero_Rubick)
&& unit.HasModifier("modifier_storm_spirit_ball_lightning"))
{
var ballLightning = unit.FindSpell("storm_spirit_ball_lightning", true);
var firstOrDefault =
ballLightning.AbilitySpecialData.FirstOrDefault(x => x.Name == "ball_lightning_move_speed");
if (firstOrDefault != null)
{
var ballSpeed = firstOrDefault.GetValue(ballLightning.Level - 1);
var newpredict = unit.Vector3FromPolarAngle() * (ballSpeed / 1000f);
targetSpeed = newpredict;
}
}
else
{
targetSpeed = unit.Vector3FromPolarAngle() * (unit.MovementSpeed / 1000f);
}
var v = unit.Position + (targetSpeed * delay);
return new Vector3(v.X, v.Y, 0);
}
示例7: Cast
public static bool Cast(Ability ability, Unit target, string name)
{
if (target.HasModifier("modifier_item_blade_mail_reflect")
&& AbilityDamage.CalculateDamage(ability, AbilityMain.Me, target) > AbilityMain.Me.Health)
{
return false;
}
if (target.HasModifier("modifier_nyx_assassin_spiked_carapace"))
{
return false;
}
if (ability.Name == "sniper_assassinate")
{
if (AbilityMain.Me.Distance2D(target) <= AbilityMain.Me.GetAttackRange() + 100)
{
return false;
}
}
if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name) && ability.Name != "lion_impale")
{
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
SoulRing.Cast(ability);
ability.UseAbility(target);
DelayAction.Add(
new DelayActionItem(300, () => { AbilityMain.LaunchSnowball(); }, CancellationToken.None));
return true;
}
if ((ability.IsAbilityBehavior(AbilityBehavior.AreaOfEffect, name)
|| ability.IsAbilityBehavior(AbilityBehavior.Point, name))
&& (Prediction.StraightTime(target) > 600 || target.MovementSpeed < 200))
{
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
var casted = ability.CastSkillShot(target, name, SoulRing.Check(ability) ? MyAbilities.SoulRing : null);
if (casted)
{
if (Utils.SleepCheck(ability.Handle.ToString())
&& ability.GetCastDelay(AbilityMain.Me, target, true) * 1000 - Game.Ping > 0.1)
{
DelayAction.Add(
new DelayActionItem(
(int)
(ability.GetCastDelay(AbilityMain.Me, target, true) * 1000 - Math.Max(50, Game.Ping)),
() =>
{
if (Prediction.StraightTime(target)
< (600
+ (ability.GetCastDelay(AbilityMain.Me, target, true) * 1000
- Math.Max(50, Game.Ping))) && target.MovementSpeed > 200)
{
AbilityMain.Me.Stop();
}
},
CancellationToken.None));
}
}
return casted;
}
if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
{
if (ability.Name == "templar_assassin_meld")
{
if (
!(target.Distance2D(MyHeroInfo.Position)
< (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius))
|| Orbwalking.AttackOnCooldown(target) || AbilityMain.Me.IsAttacking()
|| (target.Predict(Game.Ping).Distance2D(MyHeroInfo.Position)
> (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius))
|| !Utils.SleepCheck("GlobalCasting"))
{
return false;
}
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
ability.UseAbility();
DelayAction.Add(
new DelayActionItem(
(int)ability.GetCastDelay(AbilityMain.Me, target) * 1000,
() => { AbilityMain.Me.Attack(target); },
CancellationToken.None));
Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000, "GlobalCasting");
Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "casting");
Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "Ability.Move");
Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "cancelorder");
return true;
}
if (ability.Name.Contains("nevermore_shadowraze"))
{
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
return ability.CastSkillShot(target, name);
//.........这里部分代码省略.........
示例8: Cast
public static bool Cast(
Ability ability,
Unit target,
Unit buffTarget,
string name,
bool togglearmlet = false)
{
if (name == "item_armlet")
{
if (buffTarget.HasModifier("modifier_ice_blast"))
{
return false;
}
if (!togglearmlet && buffTarget.Distance2D(target) > Math.Max(buffTarget.GetAttackRange() + 150, 500))
{
return false;
}
var armlettoggled = buffTarget.HasModifier("modifier_item_armlet_unholy_strength") && ability.IsToggled;
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
if (armlettoggled)
{
ability.ToggleAbility();
ability.ToggleAbility();
return true;
}
ability.ToggleAbility();
return true;
}
if (!(buffTarget.Distance2D(target) < MyHeroInfo.AttackRange() + 150))
{
return false;
}
SoulRing.Cast(ability);
if (ability.Name == "templar_assassin_refraction")
{
var meld = AbilityMain.Me.Spellbook.Spell2;
if (meld != null && meld.CanBeCasted())
{
if (
!(target.Distance2D(MyHeroInfo.Position)
< (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius))
|| Orbwalking.AttackOnCooldown(target) || AbilityMain.Me.IsAttacking()
|| (target.Predict(Game.Ping).Distance2D(MyHeroInfo.Position)
> (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius))
|| !Utils.SleepCheck("GlobalCasting"))
{
return false;
}
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
ability.UseAbility();
if (Nuke.Cast(meld, target, NameManager.Name(meld)))
{
DelayAction.Add(
new DelayActionItem(
(int)meld.GetCastDelay(AbilityMain.Me, target) * 1000 + 100,
() => { AbilityMain.Me.Attack(target); },
CancellationToken.None));
}
Utils.Sleep(meld.GetCastDelay(AbilityMain.Me, target) * 1000, "GlobalCasting");
Utils.Sleep(meld.GetHitDelay(target, name) * 1000 + 200, "casting");
Utils.Sleep(meld.GetHitDelay(target, name) * 1000 + 200, ability.Handle.ToString());
Utils.Sleep(meld.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "cancelorder");
return true;
}
}
if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
{
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
ability.UseAbility();
return true;
}
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
ability.UseAbility(buffTarget);
return true;
}
示例9: CanHit
/// <summary>
/// Checks if you could hit hero with given ability
/// </summary>
/// <param name="ability"></param>
/// <param name="target"></param>
/// <param name="sourcePosition"></param>
/// <param name="abilityName"></param>
/// <returns></returns>
public static bool CanHit(this Ability ability, Unit target, Vector3 sourcePosition, string abilityName = null)
{
var name = abilityName ?? ability.StoredName();
if (ability.Owner.Equals(target))
{
return true;
}
var position = sourcePosition;
if (ability.IsAbilityBehavior(AbilityBehavior.Point, name) || name == "lion_impale")
{
var pred = ability.GetPrediction(target, abilityName: name);
var lion = name == "lion_impale" ? ability.GetAbilityData("length_buffer") : 0;
if (position.Distance2D(pred)
<= ability.GetCastRange(name) + ability.GetRadius(name) + lion + target.HullRadius)
{
return true;
}
return false;
}
if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
{
var pred = ability.GetPrediction(target, abilityName: name);
var distanceXyz = position.Distance2D(pred);
var radius = ability.GetRadius(name);
var range = ability.GetCastRange(name);
if (name.StartsWith("nevermore_shadowraze"))
{
range += radius / 2;
}
if (distanceXyz <= range && position.Distance2D(target.Position) <= range)
{
return true;
}
if (name == "pudge_rot" && target.HasModifier("modifier_pudge_meat_hook")
&& position.Distance2D(target) < 600)
{
return true;
}
return false;
}
if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name))
{
if (position.Distance2D(target.Position) <= ability.GetCastRange(name) + 100)
{
return true;
}
if (name == "pudge_dismember" && target.HasModifier("modifier_pudge_meat_hook")
&& position.Distance2D(target) < 600)
{
return true;
}
return false;
}
return false;
}