/// <summary> /// The compose new skill. /// </summary> /// <param name="skill"> /// The skill. /// </param> /// <returns> /// The <see cref="IControllableSkill" />. /// </returns> public IControllableSkill CreateNewControllableSkill(Ability skill, IAbilityUnit owner) { var abilitySkill = new ControllableSkill(skill) { // Json = // this.AbilityDatabase.Value.GetSkillData(skill.StoredName()) // ?? new SkillJson(), Json = new SkillJson(), Owner = owner }; // abilitySkill.Json.CastPriority = this.AbilityDatabase.Value.GetCastPriority( // skill.StoredName(), // skill.Owner?.StoredName()); // abilitySkill.Json.GlobalCastPriority = this.AbilityDatabase.Value.GetCastPriority(skill.StoredName()); // abilitySkill.Json.DamageDealtPriority = this.AbilityDatabase.Value.GetDamageDealtPriority( // skill.StoredName()); var composer = this.SkillComposers.FirstOrDefault( x => (!x.Metadata.Owner || x.Metadata.OwnerClassId.Equals(owner.SourceUnit.ClassId)) && x.Metadata.AbilityIds.Contains((uint)skill.GetAbilityId())); if (composer != null) { composer.Value.Compose(abilitySkill); } else { this.defaultSkillComposer.Compose(abilitySkill); } return(abilitySkill); }
public bool IsClosestWolf(IAbilityUnit wolf) { if (!this.Unit.TargetSelector.TargetIsSet || this.Unit.TargetSelector.Target == null) { if (this.closestWolfSleeper.Sleeping) { return(wolf.UnitHandle.Equals(this.closestWolfHandle)); } } var closestWolf = this.wolves.MinOrDefault( x => x.Value.Position.PredictedByLatency.Distance2D( this.Unit.TargetSelector.Target.Position.PredictedByLatency)).Value; if (closestWolf == null) { return(false); } this.closestWolfHandle = closestWolf.UnitHandle; this.closestWolfSleeper.Sleep(500); return(closestWolf.UnitHandle.Equals(wolf.UnitHandle)); }
public ManaBar(IAbilityUnit unit, Vector2 size) { this.Unit = unit; this.manaObserver = new DataObserver <IMana>(this.OnNext); this.Unit.Mana.Subscribe(this.manaObserver); this.Size = size; }
/// <summary>The connect panels.</summary> /// <param name="unit">The unit.</param> private void ConnectPanels(IAbilityUnit unit) { foreach (var unitOverlayElement in unit.Overlay.Panels) { var panelField = unitOverlayElement as PanelField; foreach (var overlayElement in panelField.StoredElements) { // Console.WriteLine("element: " + overlayElement.GetType()); var submenu = this.menuTypes.FirstOrDefault(x => x.Key == overlayElement.GetType()).Value; if (submenu == null && overlayElement.GenerateMenuBool) { this.menuTypes.Add(overlayElement.GetType(), submenu = overlayElement.GenerateMenu(this)); } overlayElement.ConnectToMenu(this, submenu); } } foreach (var unitOverlayElement in unit.Overlay.Elements) { var submenu = this.menuTypes.FirstOrDefault(x => x.Key == unitOverlayElement.GetType()).Value; if (submenu == null && unitOverlayElement.GenerateMenuBool) { this.menuTypes.Add(unitOverlayElement.GetType(), submenu = unitOverlayElement.GenerateMenu(this)); } unitOverlayElement.ConnectToMenu(this, submenu); } }
/// <summary>Initializes a new instance of the <see cref="DamageManipulation" /> class.</summary> /// <param name="unit">The unit.</param> internal DamageManipulation(IAbilityUnit unit) { this.Unit = unit; Action reacter = () => { this.MagicalDamageReductionChanged.Notify(); this.PhysicalDamageReductionChanged.Notify(); this.PureDamageReductionChanged.Notify(); }; this.DamageNegation = new DamageManipulationValues(unit); this.DamageNegation.ValueChanged.Subscribe(reacter); this.DamageAmplification = new DamageManipulationValues(unit); this.DamageAmplification.ValueChanged.Subscribe(reacter); this.DamageReduction = new DamageManipulationValues(unit); this.DamageReduction.ValueChanged.Subscribe(reacter); this.MagicalDamageAbsorb = new DamageManipulationValues(unit); this.MagicalDamageAbsorb.ValueChanged.Subscribe(() => this.MagicalDamageReductionChanged.Notify()); this.AmpFromMe = new DamageManipulationValues(unit); this.ManaShield = new DamageManipulationValues(unit); this.ManaShield.ValueChanged.Subscribe(reacter); }
public virtual double GetPredictedValue(IAbilityUnit source, float damageValue, float time) { var tempValue = this.value; foreach (var modifierValue in this.modifierValues) { if (modifierValue.Value.WillExpire && time >= modifierValue.Value.ExpireTime.Invoke()) { tempValue -= modifierValue.Value.Value; } } if (this.specialSkillValuesAny) { foreach (var specialSkillValue in this.specialSkillValues) { tempValue += specialSkillValue.Value.GetSpecialValue(source, damageValue); } } if (this.specialModifierValuesAny) { foreach (var specialModifierValue in this.specialModifierValues) { if (!specialModifierValue.Value.WillExpire || time < specialModifierValue.Value.ExpireTime.Invoke()) { tempValue += specialModifierValue.Value.GetSpecialValue(source, damageValue); } } } return(tempValue); }
public ItemPanel( IAbilityUnit unit, PanelDirection direction, Vector2 defaultObjectSize, Func <SkillPanelObject, uint> orderFunction = null) : base(unit, direction, defaultObjectSize, skill => { if (!skill.IsItem) { return(false); } // Console.WriteLine(skill.Name + " " + skill.SourceItem.IsHidden); return(skill.IsItem); }, orderFunction, (o, vector2) => { if (o.Skill.Cooldown == null && o.Skill.Charges == null) { return(vector2 * new Vector2(0.65f)); } return(vector2); }) { }
private void UnitRemoved(IAbilityUnit unit) { this.RemoveOrbwalker(unit.Orbwalker); this.ChaseCombo.RemoveOrderIssuer(unit.Orbwalker); this.RetreatCombo.RemoveOrderIssuer(unit.Orbwalker); }
public virtual float ManipulateIncomingMagicalDamage( IAbilityUnit source, float damageValue, double damageAmplification, float minusMagicResistancePerc, float time) { if (this.MagicalDamageShield) { return(0); } var resist = 1 - (1 - this.Unit.SourceUnit.MagicDamageResist) * (1 + minusMagicResistancePerc / 100); return ((float) Math.Max( 0, (damageValue * (1 - this.ManaShield.GetValue(source, damageValue)) * (1 - this.ReduceOther) - this.MagicalDamageAbsorb.GetPredictedValue(source, damageValue, time) - this.DamageNegation.GetPredictedValue(source, damageValue, time)) * (1 + this.DamageAmplification.GetPredictedValue(source, damageValue, time) - this.DamageReduction.GetPredictedValue(source, damageValue, time)) * (1 + damageAmplification) * (1 - resist) - this.ReduceStatic + (this.iceblasted ? this.Aa.GetSpecialValue(source, damageValue) : 0))); }
public RuneTaker(IAbilityUnit unit, IAbilityMapData abilityMapData, bool autoRunToTake) { this.Unit = unit; this.AbilityMapData = abilityMapData; this.AutoRunToTake = autoRunToTake; this.Menu = new AbilitySubMenu("RuneTaker"); }
internal Health(IAbilityUnit abilityUnit) { this.Unit = abilityUnit; this.Maximum = this.Unit.SourceUnit.MaximumHealth; this.Current = this.Unit.SourceUnit.Health; this.Percentage = 100; }
public virtual void UnitAdded(IAbilityUnit unit) { Console.WriteLine("added controllable unit " + unit.Name + " isHero: " + (unit.SourceUnit is Hero)); unit.Owner = this.Unit; this.Units.Add(unit.UnitHandle, unit); this.AddedUnit.Next(unit); }
public RuneTaker(IAbilityUnit unit, IAbilityMapData abilityMapData, bool autoRunToTake, AbilitySubMenu menu) { this.Unit = unit; this.AbilityMapData = abilityMapData; this.AutoRunToTake = autoRunToTake; this.Menu = menu; }
public WolfOrbwalker(IAbilityUnit unit) : base(unit) { this.IssueSleep = 220; this.Unit = unit; this.ControllableUnits = this.Unit.Owner.ControllableUnits as LycanControllableUnits; }
private void UnitAdded(IAbilityUnit unit) { // unit.TargetSelector.Target = this if (unit.Name == "npc_dota_lycan_wolf1" || unit.Name == "npc_dota_lycan_wolf2" || unit.Name == "npc_dota_lycan_wolf3" || unit.Name == "npc_dota_lycan_wolf4") { unit.AddPart <IUnitOrbwalker>(abilityUnit => new WolfOrbwalker(unit)); } else if (unit.UnitCombo != null) { unit.AddPart <IUnitOrbwalker>(abilityUnit => new ControllableUnitSpellsOrbwalker(unit)); } else { unit.AddPart <IUnitOrbwalker>(abilityUnit => new ControllableUnitOrbwalker(unit)); } this.AddOrbwalker(unit.Orbwalker); unit.TargetSelector.Target = this.LocalHero.TargetSelector.Target; unit.Fighting = this.LocalHero.Fighting; this.ChaseCombo.AddOrderIssuer(unit.Orbwalker); this.RetreatCombo.AddOrderIssuer(unit.Orbwalker); if (this.RetreatCombo.Key.Value.Active || this.ChaseCombo.Key.Value.Active) { unit.AddOrderIssuer(unit.Orbwalker); unit.Orbwalker.Enabled = true; } }
public float ManipulateIncomingPhysicalDamage( IAbilityUnit source, float damageValue, double damageAmplification, float minusDamageResistancePerc, float minusArmor, float time) { if (this.IsAttackImmune || this.PhysicalDamageShield) { return(0); } return ((float) Math.Max( 0, (damageValue * (1 - this.ManaShield.GetValue(source, damageValue)) * (1 - this.ReduceOther) - this.DamageNegation.GetPredictedValue(source, damageValue, time)) * (1 + this.DamageAmplification.GetPredictedValue(source, damageValue, time) - this.DamageReduction.GetPredictedValue(source, damageValue, time)) * (1 + damageAmplification) * (1 - this.Unit.SourceUnit.DamageResist * (1 - minusDamageResistancePerc / 100)) + 0.06 * minusArmor / (1 + 0.06 * Math.Abs(minusArmor)) - this.ReduceStatic + (this.iceblasted ? this.Aa.GetSpecialValue(source, damageValue) : 0))); }
/// <summary> /// Checks if skill can be safely used on target and if target is in range /// </summary> /// <param name="target"> /// The target. /// </param> /// <param name="needToMoveCloser"> /// The need To Move Closer. /// </param> /// <returns> /// The <see cref="bool" />. /// </returns> public bool CanCast(IAbilityUnit target, out bool needToMoveCloser) { if (target == null) { needToMoveCloser = false; return(false); } if (target?.SourceUnit == null) { needToMoveCloser = false; return(false); } needToMoveCloser = false; if (target.SourceUnit.IsMagicImmune() && this.SourceAbility.SpellPierceImmunityType != (target.IsEnemy ? SpellPierceImmunityType.EnemiesYes : SpellPierceImmunityType.AlliesYes)) { return(false); } needToMoveCloser = !this.CanHit(target.SourceUnit); return(!needToMoveCloser); }
public void ConnectToUnit(IAbilityUnit unit) { if (unit.OrderQueue != null) { unit.OrderQueue.DrawOrder = new GetValue <bool, bool>(this.enableDraw, b => b); } }
public UnitIconDrawer(IAbilityUnit unit) { this.Unit = unit; var name = this.Unit.SourceUnit.Name.Substring("npc_dota_hero_".Length); this.Icon = unit.SourceUnit is Hero?Textures.GetHeroRoundTexture(this.Unit.Name) : null; this.MinimapIcon = unit.SourceUnit is Hero?Textures.GetTexture("ensage_ui/miniheroes/" + name) : null; this.WorldIconSize = new Vector2(HUDInfo.GetHpBarSizeY() * 6); var icon = (Bitmap)Resources.ResourceManager.GetObject(name); if (icon == null) { Console.WriteLine("Ability#: could not find " + name + " minimap icon"); } else { this.EndSceneIcon = new Render.Sprite(icon, new Vector2(100, 700)); } this.MinimapIconSize = new Vector2((float)(HUDInfo.GetHpBarSizeY() * 1.5)); this.EndSceneIcon.SetSaturation(1.5f); // sprite.Add(); }
/// <summary> /// The compose. /// </summary> /// <param name="unit"> /// The unit. /// </param> public void Compose(IAbilityUnit unit) { // if (unit.SourceUnit.IsControllable && !unit.IsEnemy) // { // this.AssignPart<IUnitControl>(abilityUnit => new UnitControl(abilityUnit)); // } unit.UnitComposer = this; foreach (var keyValuePair in this.Assignments) { keyValuePair.Value.Invoke(unit); } if (unit.IsEnemy) { foreach (var keyValuePair in this.EnemyAssignments) { keyValuePair.Value.Invoke(unit); } } if (!unit.IsEnemy && unit.SourceUnit.IsControllable) { foreach (var keyValuePair in this.ControllableAssignments) { keyValuePair.Value.Invoke(unit); } } // unit.Interaction = new UnitInteraction(unit); // unit.Updater = new AbilityUnitUpdater(unit); }
internal StringDataDamageCalculatorWorker( IAbilitySkill skill, IAbilityUnit target, ISkillManipulatedDamageCalculatorWorker manipulatedDamageWorker) : base(skill, target, manipulatedDamageWorker) { }
private void UnitAdded(IAbilityUnit unit) { //unit.TargetSelector.Target = this if (unit.UnitCombo != null) { unit.AddPart <IUnitOrbwalker>(abilityUnit => new ControllableUnitSpellsOrbwalker(unit)); } else { unit.AddPart <IUnitOrbwalker>(abilityUnit => new ControllableUnitOrbwalker(unit)); } this.AddOrbwalker(unit.Orbwalker); //unit.TargetSelector.Target = this.LocalHero.TargetSelector.Target; //unit.Fighting = this.LocalHero.Fighting; this.BodyBlockCombo.AddOrderIssuer(unit.Orbwalker); this.ChaseCombo.AddOrderIssuer(unit.Orbwalker); this.RetreatCombo.AddOrderIssuer(unit.Orbwalker); if (this.RetreatCombo.Key.Value.Active || this.ChaseCombo.Key.Value.Active || this.BodyBlockCombo.Key.Value.Active) { unit.AddOrderIssuer(unit.Orbwalker); unit.Orbwalker.Enabled = true; } unit.Fighting = this.LocalHero.Fighting; unit.TargetSelector.Target = this.LocalHero.TargetSelector.Target; }
public ManaBurnDamageCalculatorWorker( IAbilitySkill skill, IAbilityUnit target, ISkillManipulatedDamageCalculatorWorker manipulatedDamageWorker, float burnAmount) : base(skill, target, manipulatedDamageWorker) { this.burnAmount = burnAmount; }
public RunForRune(IAbilityUnit unit, RunePosition <T> rune, List <Vector3> path) : base(OrderType.TakeRune, unit, "Running for rune") { this.Path = path; this.RunePosition = rune; this.ShouldExecuteFast = true; this.Color = Color.LightPink; }
public float GetDamage(IAbilityUnit target) { return(target.DamageManipulation.ManipulateIncomingAutoAttackDamage( this.Unit, this.Unit.SourceUnit.DamageAverage + this.Unit.SourceUnit.BonusDamage, 0, 0)); }
/// <summary>The create new modifier.</summary> /// <param name="modifier">The modifier.</param> /// <param name="affectedUnit">The affectedUnit.</param> /// <returns>The <see cref="IAbilityModifier" />.</returns> public IAbilityModifier CreateNewModifier(Modifier modifier, IAbilityUnit affectedUnit) { var abilityModifier = new AbilityModifier.AbilityModifier(modifier) { AffectedUnit = affectedUnit }; return(abilityModifier); }
/// <summary>Initializes a new instance of the <see cref="LeftPanelField" /> class.</summary> /// <param name="unit">The unit.</param> /// <param name="parent">The parent.</param> public LeftPanelField(IAbilityUnit unit, IUnitOverlayElement parent) : base( unit, parent, () => unit.Overlay.HealthBar.Position, PanelDirection.Left, element => - new Vector2(element.Size.X, 0)) { }
public bool IsInAttackRange(IAbilityUnit target) { return (target.Position.Predict((float)(Game.Ping + this.Unit.TurnRate.GetTurnTime(target) * 1000f)) .Distance2D(this.Unit.Position.PredictedByLatency) <= this.Value + target.SourceUnit.HullRadius + this.Unit.SourceUnit.HullRadius + 50 && target.Position.PredictedByLatency.Distance2D(this.Unit.Position.PredictedByLatency) < this.Value + target.SourceUnit.HullRadius + this.Unit.SourceUnit.HullRadius + 50); }
/// <summary> /// The can cast. /// </summary> /// <param name="target"> /// The target. /// </param> /// <returns> /// The <see cref="bool" />. /// </returns> public bool CanCast(IAbilityUnit target) { if (target == null) { return(false); } return(target.SourceUnit.IsAlive && target.SourceUnit.IsVisible && this.CanHit(target.SourceUnit)); }
protected UnitOrderBase(OrderType orderType, IAbilityUnit unit, string name) { this.OrderType = orderType; this.Priority = (uint)orderType; this.Unit = unit; this.Name = name; this.Color = Color.AliceBlue; }