private void OnOrderAdding(OrderAddingEventArgs e) { var order = e.Order; if (order.IsQueued || !e.Process) { return; } try { switch (order.Type) { case OrderType.AttackTarget: { SetTarget(order.Units, order.Target.Handle); break; } case OrderType.Hold: case OrderType.Stop: { var units = order.Units; DropTarget(units); StopChanneling(units); break; } case OrderType.MovePosition: case OrderType.MoveTarget: { DropTarget(order.Units); break; } case OrderType.CastTarget: { var target = EntityManager9.GetUnitFast(order.Target.Handle); if (target?.IsLinkensProtected == true) { return; } StartChanneling(order.Ability.Handle); break; } case OrderType.Cast: case OrderType.CastPosition: { StartChanneling(order.Ability.Handle); break; } } } catch (Exception ex) { Logger.Error(ex); } }
private void OnHandlePropertyChange(Entity sender, HandlePropertyChangeEventArgs args) { if (sender.Team == this.allyTeam || args.NewValue == args.OldValue || !args.OldValue.IsValid || args.PropertyName != "m_hKillCamUnit") { return; } try { // respawn var handle = ((Player)sender).Hero?.Handle; var unit = (Hero9)EntityManager9.GetUnitFast(handle); if (unit == null) { return; } UpdateManager.BeginInvoke(() => RespawnUnit(unit), 500); } catch (Exception e) { Logger.Error(e); } }
public bool ShouldBlock(ExecuteOrderEventArgs args) { if (!this.menu.BlockTooFastReaction) { return(false); } switch (args.OrderId) { case OrderId.AttackTarget: case OrderId.AbilityTarget: case OrderId.MoveTarget: { var target = EntityManager9.GetUnitFast(args.Target.Handle); if (target == null) { return(false); } if (Game.RawGameTime - target.LastNotVisibleTime < RNG.Randomize(0.25f, 0.03f)) { return(true); } break; } } return(false); }
// Token: 0x060003B9 RID: 953 RVA: 0x0001D1F8 File Offset: 0x0001B3F8 private void OnExecuteOrder(Player sender, ExecuteOrderEventArgs args) { if (args.IsQueued) { return; } try { OrderId orderId = args.OrderId; switch (orderId) { case OrderId.MoveLocation: case OrderId.MoveTarget: UnitMonitor.DropTarget(args.Entities); goto IL_DE; case OrderId.AttackLocation: case OrderId.AbilityTargetTree: case OrderId.ToggleAbility: goto IL_DE; case OrderId.AttackTarget: UnitMonitor.SetTarget(args.Entities, args.Target.Handle); goto IL_DE; case OrderId.AbilityLocation: case OrderId.Ability: UnitMonitor.StartChanneling(args.Ability.Handle); goto IL_DE; case OrderId.AbilityTarget: { Unit9 unitFast = EntityManager9.GetUnitFast(args.Target.Handle); if (unitFast != null && unitFast.IsLinkensProtected) { return; } UnitMonitor.StartChanneling(args.Ability.Handle); goto IL_DE; } case OrderId.Hold: break; default: if (orderId != OrderId.Stop) { goto IL_DE; } break; } UnitMonitor.DropTarget(args.Entities); UnitMonitor.StopChanneling(args.Entities); IL_DE :; } catch (Exception exception) { Logger.Error(exception, null); } }
private void OnGameEvent(GameEventEventArgs e) { try { var gameEvent = e.GameEvent; switch (gameEvent.Name) { case "dota_player_kill": case "dota_player_deny": { var id = gameEvent.GetInt32("victim_userid"); var handle = EntityManager.GetPlayerById(id)?.Hero?.Handle; var unit = (Hero9)EntityManager9.GetUnitFast(handle); if (unit == null || unit.Team == this.allyTeam) { break; } unit.BaseIsAlive = false; if (unit.IsVisible) { var delay = (int)(((unit.BaseHero.RespawnTime - GameManager.RawGameTime) + 0.5f) * 1000); if (delay <= 0) { break; } UpdateManager.BeginInvoke(delay, () => RespawnUnit(unit)); } } break; case "dota_buyback": { var id = gameEvent.GetInt32("player_id"); var handle = EntityManager.GetPlayerById(id)?.Hero?.Handle; var unit = EntityManager9.GetUnitFast(handle); if (unit == null || unit.Team == this.allyTeam) { break; } unit.BaseIsAlive = true; unit.BaseHealth = unit.MaximumHealth; unit.BaseMana = unit.MaximumMana; } break; } } catch (Exception ex) { Logger.Error(ex); } }
// Token: 0x060003BA RID: 954 RVA: 0x0001D300 File Offset: 0x0001B500 private void OnInt32PropertyChange(Entity sender, Int32PropertyChangeEventArgs args) { int newValue = args.NewValue; if (newValue == args.OldValue) { return; } try { Unit9 unitFast = EntityManager9.GetUnitFast(sender.Handle); if (!(unitFast == null)) { string propertyName = args.PropertyName; if (!(propertyName == "m_iHealth")) { if (propertyName == "m_NetworkActivity") { if (unitFast.IsValid) { if (this.attackActivities.Contains(newValue)) { this.AttackStarted(unitFast); } else { this.AttackStopped(unitFast); } } } } else if (newValue > 0) { UnitMonitor.HealthEventHandler unitHealthChange = this.UnitHealthChange; if (unitHealthChange != null) { unitHealthChange(unitFast, (float)newValue); } } else { unitFast.DeathTime = Game.RawGameTime; this.AttackStopped(unitFast); this.attackSleeper.Remove(unitFast.Handle); UnitMonitor.EventHandler unitDied = this.UnitDied; if (unitDied != null) { unitDied(unitFast); } } } } catch (Exception exception) { Logger.Error(exception, sender, null); } }
private static void OnExecuteOrder(Player sender, ExecuteOrderEventArgs args) { if (args.IsQueued || !args.Process) { return; } try { switch (args.OrderId) { case OrderId.AttackTarget: { SetTarget(args.Entities, args.Target.Handle); break; } case OrderId.Hold: case OrderId.Stop: { DropTarget(args.Entities); StopChanneling(args.Entities); break; } case OrderId.MoveLocation: case OrderId.MoveTarget: { DropTarget(args.Entities); break; } case OrderId.AbilityTarget: { var target = EntityManager9.GetUnitFast(args.Target.Handle); if (target?.IsLinkensProtected == true) { return; } StartChanneling(args.Ability.Handle); break; } case OrderId.Ability: case OrderId.AbilityLocation: { StartChanneling(args.Ability.Handle); break; } } } catch (Exception e) { Logger.Error(e); } }
private void OnInt32PropertyChange(Entity sender, Int32PropertyChangeEventArgs args) { var newValue = args.NewValue; if (newValue == args.OldValue) { return; } try { var unit = EntityManager9.GetUnitFast(sender.Handle); if (unit == null) { return; } switch (args.PropertyName) { case "m_iHealth": { if (newValue > 0) { this.UnitHealthChange?.Invoke(unit, newValue); break; } unit.DeathTime = Game.RawGameTime; this.AttackStopped(unit); this.attackSleeper.Remove(unit.Handle); this.UnitDied?.Invoke(unit); break; } case "m_NetworkActivity": { if (this.attackActivities.Contains(newValue)) { this.AttackStarted(unit); } else { this.AttackStopped(unit); } break; } } } catch (Exception e) { Logger.Error(e, sender); } }
internal void Morphed(bool added) { this.IsRanged = this.BaseUnit.IsRanged; this.IsMorphed = added; if (this.IsMorphed) { this.MorphedHero = EntityManager9.GetUnitFast(this.BaseHero.ReplicateFrom?.Handle); } }
// Token: 0x060003B3 RID: 947 RVA: 0x0001CE70 File Offset: 0x0001B070 private static void StopChanneling(IEnumerable <Entity> entities) { foreach (Entity entity in entities) { Unit9 unitFast = EntityManager9.GetUnitFast(entity.Handle); if (!(unitFast == null)) { unitFast.ChannelEndTime = 0f; unitFast.ChannelActivatesOnCast = false; } } }
// Token: 0x060003AF RID: 943 RVA: 0x0001CCA4 File Offset: 0x0001AEA4 private static void DropTarget(IEnumerable <Entity> entities) { foreach (Entity entity in entities) { Unit9 unitFast = EntityManager9.GetUnitFast(entity.Handle); if (unitFast != null) { unitFast.Target = null; unitFast.IsAttacking = false; } } }
private static void StopChanneling(IEnumerable <Entity> entities) { foreach (var entity in entities) { var unit = EntityManager9.GetUnitFast(entity.Handle); if (unit == null) { continue; } unit.ChannelEndTime = 0; unit.ChannelActivatesOnCast = false; } }
private static void OnBoolPropertyChange(Entity sender, BoolPropertyChangeEventArgs args) { if (args.NewValue == args.OldValue) { return; } try { switch (args.PropertyName) { case "m_bReincarnating": { var unit = (Hero9)EntityManager9.GetUnitFast(sender.Handle); if (unit == null) { return; } unit.IsReincarnating = args.NewValue; break; } //case "m_bIsWaitingToSpawn": //{ // if (args.NewValue) // { // return; // } // var unit = EntityManager9.GetUnitFast(sender.Handle); // if (unit == null) // { // return; // } // unit.IsSpawned = true; // break; //} } } catch (Exception e) { Logger.Error(e); } }
// Token: 0x060003B1 RID: 945 RVA: 0x0001CDB8 File Offset: 0x0001AFB8 private static void SetTarget(IEnumerable <Entity> entities, uint targetHandle) { Unit9 unit = EntityManager9.GetUnit(targetHandle); if (unit == null || !unit.IsAlive) { return; } foreach (Entity entity in entities) { Unit9 unitFast = EntityManager9.GetUnitFast(entity.Handle); if (unitFast != null && unitFast.IsEnemy(unit)) { unitFast.Target = unit; unitFast.IsAttacking = true; } } }
public VengefulSpirit(Hero baseHero) : base(baseHero) { if (this.IsIllusion) { if (!this.HasModifier("modifier_vengefulspirit_hybrid_special")) { return; } var mainHero = EntityManager9.GetUnitFast(baseHero.ReplicateFrom?.Handle); if (mainHero == null) { return; } this.CanUseAbilities = mainHero.GetAbilityById(AbilityId.special_bonus_unique_vengeful_spirit_7)?.Level > 0; } }
private static void SetTarget(IEnumerable <Entity> entities, uint targetHandle) { var target = EntityManager9.GetUnit(targetHandle); if (target?.IsAlive != true) { return; } foreach (var entity in entities) { var unit = EntityManager9.GetUnitFast(entity.Handle); if (unit == null) { continue; } unit.Target = target; unit.IsAttacking = true; } }
private void OnInt32PropertyChange(Entity sender, Int32PropertyChangeEventArgs args) { if (args.NewValue == args.OldValue || args.PropertyName != "m_iParity") { return; } var owner = EntityManager9.GetUnitFast(sender.Handle); if (owner == null) { return; } UpdateManager.BeginInvoke( () => { try { var inventory = owner.BaseInventory; var checkedItems = new List <uint>(); foreach (var handle in this.GetInventoryItems(inventory).Select(x => x.Handle)) { var item = EntityManager9.GetAbilityFast(handle); if (item == null) { continue; } checkedItems.Add(handle); if (item.Owner == owner) { item.IsAvailable = true; continue; } EntityManager9.RemoveAbility(item.BaseAbility); EntityManager9.AddAbility(item.BaseAbility); } foreach (var handle in this.GetStashItems(inventory).Select(x => x.Handle)) { var item = EntityManager9.GetAbilityFast(handle); if (item == null) { continue; } checkedItems.Add(handle); if (item.Owner == owner) { item.IsAvailable = false; continue; } EntityManager9.RemoveAbility(item.BaseAbility); EntityManager9.AddAbility(item.BaseAbility); } // stashed neutral items foreach (var item in owner.AbilitiesFast.Where( x => x.IsItem && x.IsAvailable && !checkedItems.Contains(x.Handle))) { item.IsAvailable = false; } } catch (Exception e) { Logger.Error(e); } }); }
private void CheckModifier(uint senderHandle, Modifier modifier, bool added) { var modifierName = modifier.Name; var unit = EntityManager9.GetUnitFast(senderHandle); if (unit == null) { return; } if (this.specialModifiers.TryGetValue(modifierName, out var action)) { action(unit, modifier, added); } var range = this.rangeFactory.GetRange(modifierName); if (range != null) { unit.Range(range, added); return; } if (modifier.IsHidden) { return; } var disable = this.damageFactory.GetDisable(modifierName); if (disable != null) { var invulnerability = disable is IDisable disableAbility && (disableAbility.AppliesUnitState & UnitState.Invulnerable) != 0; unit.Disabler(modifier, added, invulnerability); return; } if (modifier.IsStunDebuff) { unit.Disabler(modifier, added, false); return; } var amplifier = this.damageFactory.GetAmplifier(modifierName); if (amplifier != null) { unit.Amplifier(amplifier, added); return; } var passive = this.damageFactory.GetPassive(modifierName); if (passive != null) { unit.Passive(passive, added); return; } var blocker = this.damageFactory.GetBlocker(modifierName); if (blocker != null) { unit.Blocker(blocker, added); return; } }
// Token: 0x060003B6 RID: 950 RVA: 0x0001D02C File Offset: 0x0001B22C private void CheckModifier(uint senderHandle, Modifier modifier, bool added) { string name = modifier.Name; Unit9 unitFast = EntityManager9.GetUnitFast(senderHandle); if (unitFast == null) { return; } Action <Unit9, bool> action; if (this.specialModifiers.TryGetValue(name, out action)) { action(unitFast, added); } IHasRangeIncrease range = this.rangeFactory.GetRange(name); if (range != null) { unitFast.Range(range, added); return; } if (modifier.IsHidden) { return; } IAppliesImmobility disable = this.damageFactory.GetDisable(name); if (disable != null) { IDisable disable2; bool invulnerability = (disable2 = (disable as IDisable)) != null && (disable2.AppliesUnitState & UnitState.Invulnerable) > (UnitState)0UL; unitFast.Disabler(modifier, added, invulnerability); return; } if (modifier.IsStunDebuff) { unitFast.Disabler(modifier, added, false); return; } IHasDamageAmplify amplifier = this.damageFactory.GetAmplifier(name); if (amplifier != null) { unitFast.Amplifier(amplifier, added); return; } IHasPassiveDamageIncrease passive = this.damageFactory.GetPassive(name); if (passive != null) { unitFast.Passive(passive, added); return; } IHasDamageBlock blocker = this.damageFactory.GetBlocker(name); if (blocker != null) { unitFast.Blocker(blocker, added); return; } }
private void OnNetworkPropertyChanged(Entity sender, NetworkPropertyChangedEventArgs e) { switch (e.PropertyName) { case "m_bReincarnating": { var newValue = e.NewValue.GetBoolean(); if (newValue == e.OldValue.GetBoolean()) { break; } UpdateManager.BeginInvoke(() => { var unit = (Hero9)EntityManager9.GetUnitFast(sender.Handle); if (unit == null) { return; } unit.IsReincarnating = newValue; }); } break; case "m_iIsControllableByPlayer64": { if (e.NewValue.GetInt64() == e.OldValue.GetInt64()) { break; } UpdateManager.BeginInvoke(() => { EntityManager9.ChangeEntityControl(sender); }); } break; case "m_hKillCamUnit": { if (e.NewValue.GetUInt32() == e.OldValue.GetUInt32()) { break; } UpdateManager.BeginInvoke(() => { if (sender.Team == this.allyTeam) { return; } var entity = e.NewValue.GetEntity(); if (entity == null || !entity.IsValid) { return; } var handle = ((Player)sender).Hero?.Handle; var unit = (Hero9)EntityManager9.GetUnitFast(handle); if (unit == null) { return; } UpdateManager.BeginInvoke(500, () => RespawnUnit(unit)); }); } break; case "m_iHealth": { var newValue = e.NewValue.GetInt32(); if (newValue == e.OldValue.GetInt32()) { break; } UpdateManager.BeginInvoke(() => { var unit = EntityManager9.GetUnitFast(sender.Handle); if (unit == null) { return; } if (newValue > 0) { this.UnitHealthChange?.Invoke(unit, newValue); } else { unit.DeathTime = GameManager.RawGameTime; this.AttackStopped(unit); this.attackSleeper.Remove(unit.Handle); this.UnitDied?.Invoke(unit); } }); } break; case "m_NetworkActivity": { var newValue = e.NewValue.GetInt32(); if (newValue == e.OldValue.GetInt32()) { break; } UpdateManager.BeginInvoke(() => { var unit = EntityManager9.GetUnitFast(sender.Handle); if (unit == null) { return; } if (this.attackActivities.Contains(newValue)) { this.AttackStarted(unit); } else { this.AttackStopped(unit); } }); } break; } }
private void OnNetworkPropertyChanged(Entity sender, NetworkPropertyChangedEventArgs e) { switch (e.PropertyName) { case "m_bToggleState": { var newValue = e.NewValue.GetBoolean(); if (!newValue || newValue == e.OldValue.GetBoolean()) { break; } UpdateManager.BeginInvoke(() => { var ability = EntityManager9.GetAbilityFast(sender.Handle); if (ability == null) { return; } this.AbilityCasted?.Invoke(ability); }); } break; case "m_bInAbilityPhase": { var newValue = e.NewValue.GetBoolean(); if (newValue == e.OldValue.GetBoolean()) { break; } UpdateManager.BeginInvoke(() => { var ability = EntityManager9.GetAbilityFast(sender.Handle); if (ability == null) { return; } ability.IsCasting = newValue; ability.Owner.IsCasting = newValue; this.AbilityCastChange?.Invoke(ability); }); } break; case "m_flEnableTime": { var newValue = e.NewValue.GetSingle(); if (newValue == e.OldValue.GetSingle()) { break; } UpdateManager.BeginInvoke(() => { var ability = EntityManager9.GetAbilityFast(sender.Handle); if (ability == null) { return; } ability.ItemEnableTimeSleeper.SleepUntil(newValue); }); } break; case "m_flCastStartTime": { var newValue = e.NewValue.GetSingle(); var oldValue = e.OldValue.GetSingle(); if (newValue == oldValue) { break; } UpdateManager.BeginInvoke(() => { if (this.AbilityCasted == null) { return; } var ability = EntityManager9.GetAbilityFast(sender.Handle); if (ability == null) { return; } if (!ability.IsDisplayingCharges) { return; } var castTime = newValue - oldValue; if (castTime < 0 || oldValue < 0) { return; } var visibleTime = GameManager.RawGameTime - ability.Owner.LastNotVisibleTime; if (visibleTime < 0.05f) { return; } if (ability.CastPoint <= 0) { this.AbilityCasted(ability); } else { if (Math.Abs(ability.CastPoint - castTime) < 0.03f) { this.AbilityCasted(ability); } } }); } break; case "m_fCooldown": { var newValue = e.NewValue.GetSingle(); var oldValue = e.OldValue.GetSingle(); if (newValue == oldValue) { break; } UpdateManager.BeginInvoke(() => { if (this.AbilityCasted == null) { return; } if (newValue <= oldValue || oldValue > 0) { return; } var ability = EntityManager9.GetAbilityFast(sender.Handle); if (ability == null) { return; } var visibleTime = GameManager.RawGameTime - ability.Owner.LastNotVisibleTime; if (visibleTime < 0.05f) { return; } this.AbilityCasted(ability); }); } break; case "m_flChannelStartTime": { var newValue = e.NewValue.GetSingle(); if (newValue == e.OldValue.GetSingle()) { break; } UpdateManager.BeginInvoke(() => { var ability = EntityManager9.GetAbilityFast(sender.Handle); if (ability == null) { return; } if (!(ability is IChanneled channeled)) { return; } if (newValue > 0) { ability.IsChanneling = true; channeled.Owner.ChannelEndTime = newValue + channeled.ChannelTime; channeled.Owner.ChannelActivatesOnCast = channeled.IsActivatesOnChannelStart; this.AbilityChannel?.Invoke(ability); } else { ability.IsChanneling = false; channeled.Owner.ChannelEndTime = 0; channeled.Owner.ChannelActivatesOnCast = false; } }); } break; case "m_iParity": { if (e.NewValue.GetInt32() == e.OldValue.GetInt32()) { break; } UpdateManager.BeginInvoke(() => { var owner = EntityManager9.GetUnitFast(sender.Handle); if (owner == null) { return; } var inventory = owner.BaseInventory; var checkedItems = new List <uint>(); foreach (var handle in this.GetInventoryItems(inventory).Select(x => x.Handle)) { var item = EntityManager9.GetAbilityFast(handle); if (item == null) { continue; } checkedItems.Add(handle); if (item.Owner == owner) { item.IsAvailable = true; //UpdateManager.BeginInvoke(100, () => InventoryChanged?.Invoke(null, EventArgs.Empty)); continue; } EntityManager9.RemoveAbility(item.BaseAbility); EntityManager9.AddAbility(item.BaseAbility); } foreach (var handle in this.GetStashItems(inventory).Select(x => x.Handle)) { var item = EntityManager9.GetAbilityFast(handle); if (item == null) { continue; } checkedItems.Add(handle); if (item.Owner == owner) { item.IsAvailable = false; //UpdateManager.BeginInvoke(100, () => InventoryChanged?.Invoke(null, EventArgs.Empty)); continue; } EntityManager9.RemoveAbility(item.BaseAbility); EntityManager9.AddAbility(item.BaseAbility); } // stashed neutral items foreach (var item in owner.AbilitiesFast.Where(x => x.IsItem && x.IsAvailable && !checkedItems.Contains(x.Handle))) { item.IsAvailable = false; //UpdateManager.BeginInvoke(100, () => InventoryChanged?.Invoke(null, EventArgs.Empty)); } }); } break; } }