// Update is called once per frame public override void Update(ref Basher basher) { // Increase the resistance by the speed float resistAmount = 1f - Mathf.Log(damagable.Speed) * 0.03f; if (resistAmount < 0.1f) { resistAmount = 0.1f; } // Find this part's ID in the basher parts list int partID = -1; for (int i = 0; i < basher.enchantments.Length; i++) { if (basher.enchantments[i] == this) { partID = i; break; } } if (partID != -1) { basher.ResistMults[Basher.MaxParts + partID] = resistAmount; } }
/// <summary> /// Called on basher initialisation /// </summary> public override void Initialise(ref Basher basher) { base.Initialise(ref basher); ID = 6; basher.SpeedMultiplier *= 1.2f; }
/// <summary> /// Called on basher initialisation /// </summary> public override void Initialise(ref Basher basher) { base.Initialise(ref basher); timer = 0; ID = 2; }
// On impact, sacrifice some health to increase damage dealt public override void PostHit(ref Basher basher, ref Damagable target, float damage) { base.OnHit(ref basher, ref target, damage); // Let's say sacrifice 5% current hp to do 10% more damage damagable.Health *= 0.95f; target.Health -= damage * 0.1f; // resistance doesn't need to be factored in, it was already calculated with the initial damage calculation }
/// <summary> /// Called on basher initialisation /// </summary> public override void Initialise(ref Basher basher) { base.Initialise(ref basher); // Heavy Shield is ID 1 ID = 1; Health = 10; }
// Basic test part: // /* -- Heavy Plating -- * Reduces your basher's damage * taken by 10%. */ /// <summary> /// Called on basher initialisation /// </summary> public override void Initialise(ref Basher basher) { base.Initialise(ref basher); // Heavy Plating is ID 0 ID = 0; // Decrease resistance by 0.1 (make the basher take 10% less) damagable.Resistance *= 0.9f; }
// Update is called once per frame public override void Update(ref Basher basher) { base.Update(ref basher); // Restore 0.5 health every second timer += Time.deltaTime; if (timer > 1) { damagable.Health += 0.5f; timer = 0; } }
// Take away this shield's health instead public override void OnHit(ref Basher basher, ref Damagable target, float damage) { base.OnHit(ref basher, ref target, damage); // If the damage is less than the shield's remaining health, add the // damage to the basher's health. This will effectively bring the damage // taken to 0. if (damage < Health) { damagable.Health += damage; Health -= damage; } // If the damage is greater than the shield's remaining health, just add all // of that to the basher's health and remove it if (damage > Health) { damagable.Health += Health; Health = 0; } // Destroy the shield if its HP goes below 0 if (Health <= 0) { // Find this part's ID in the basher parts list int idToRemove = -1; for (int i = 0; i < basher.parts.Length; i++) { if (basher.parts[i] == this) { idToRemove = i; break; } } // Remove this from the parts list basher.RemovePart(idToRemove); } }
public override async Task ExecuteAsync(CancellationToken token) { try { var sliderValue = this.Config.UseBlinkPrediction.Item.GetValue <Slider>().Value; if (Config.TargetItem.Value.SelectedValue.Contains("Lock") && Context.TargetSelector.IsActive && (!CanExecute || EnemyHero == null || !EnemyHero.IsValid || !EnemyHero.IsAlive)) { EnemyHero = Context.TargetSelector.Active.GetTargets().FirstOrDefault() as Hero; } else if (Config.TargetItem.Value.SelectedValue.Contains("Default") && Context.TargetSelector.IsActive) { EnemyHero = Context.TargetSelector.Active.GetTargets().FirstOrDefault() as Hero; } var Silenced = UnitExtensions.IsSilenced(base.Owner); if (EnemyHero != null) { if (this.BlinkDagger != null && (this.BlinkDagger.CanBeCasted && base.Owner.Distance2D(EnemyHero) <= 1200 + sliderValue && !(base.Owner.Distance2D(EnemyHero) <= 400) && this.Config.ItemToggler.Value.IsEnabled(this.BlinkDagger.Item.Name))) { var l = (this.Owner.Distance2D(EnemyHero) - sliderValue) / sliderValue; var posA = this.Owner.Position; var posB = EnemyHero.Position; var x = (posA.X + (l * posB.X)) / (1 + l); var y = (posA.Y + (l * posB.Y)) / (1 + l); var position = new Vector3((int)x, (int)y, posA.Z); this.BlinkDagger.UseAbility(position); await Await.Delay(BlinkDagger.GetCastDelay(position), token); } if (!Silenced) { if (this.Config.AbilityToggler.Value.IsEnabled(this.Blast.Name) && this.Blast.CanBeCasted() && this.Blast.CanHit(EnemyHero)) { this.Blast.UseAbility(EnemyHero); await Await.Delay(this.GetAbilityDelay(base.Owner, Blast), token); } } if (this.Basher != null && base.Owner.IsAttacking() && this.Basher.CanBeCasted && this.Basher.CanHit(EnemyHero) && this.Config.ItemToggler.Value.IsEnabled(Basher.ToString())) { this.Basher.UseAbility(EnemyHero); await Await.Delay(Basher.GetCastDelay(EnemyHero), token); } if (this.Mjollnir != null && base.Owner.IsAttacking() && this.Mjollnir.CanBeCasted && this.Config.ItemToggler.Value.IsEnabled(Mjollnir.ToString())) { this.Mjollnir.UseAbility(base.Owner); await Await.Delay(Mjollnir.GetCastDelay(Owner), token); } if (!UnitExtensions.IsMagicImmune(EnemyHero) && !EnemyHero.IsInvulnerable() && !UnitExtensions.HasModifier(EnemyHero, "modifier_winter_wyvern_winters_curse")) { if (this.BloodThorn != null && this.BloodThorn.CanBeCasted && this.BloodThorn.CanHit(EnemyHero) && this.Config.ItemToggler.Value.IsEnabled(this.BloodThorn.ToString())) { this.BloodThorn.UseAbility(EnemyHero); await Await.Delay(BloodThorn.GetCastDelay(EnemyHero), token); } if (this.Medalion1 != null && this.Medalion1.CanBeCasted && this.Medalion1.CanHit(EnemyHero) && this.Config.ItemToggler.Value.IsEnabled(this.Medalion1.ToString())) { this.Medalion1.UseAbility(EnemyHero); await Await.Delay(Medalion1.GetCastDelay(EnemyHero), token); } if (this.Medallion2 != null && this.Medallion2.CanBeCasted && this.Medallion2.CanHit(EnemyHero) && this.Config.ItemToggler.Value.IsEnabled(this.Medallion2.ToString())) { this.Medallion2.UseAbility(EnemyHero); await Await.Delay(Medallion2.GetCastDelay(EnemyHero), token); } if (this.DiffBlade != null && this.DiffBlade.CanBeCasted && this.DiffBlade.CanHit(EnemyHero) && this.Config.ItemToggler.Value.IsEnabled("item_diffusal_blade_2")) { this.DiffBlade.UseAbility(EnemyHero); await Await.Delay(DiffBlade.GetCastDelay(EnemyHero), token); } if (this.Orchid != null && this.Orchid.CanBeCasted && this.Orchid.CanHit(EnemyHero) && this.Config.ItemToggler.Value.IsEnabled(Orchid.ToString())) { this.Orchid.UseAbility(EnemyHero); await Await.Delay(Orchid.GetCastDelay(EnemyHero), token); } if (this.Heaven != null && base.Owner.IsAttacking() && this.Heaven.CanBeCasted && this.Heaven.CanHit(EnemyHero) && this.Config.ItemToggler.Value.IsEnabled(Heaven.ToString())) { this.Heaven.UseAbility(EnemyHero); await Await.Delay(Heaven.GetCastDelay(EnemyHero), token); } } if (EnemyHero != null && (EnemyHero.IsInvulnerable() || UnitExtensions.IsAttackImmune(EnemyHero))) { Orbwalker.Move(Game.MousePosition); } else if (EnemyHero != null) { Orbwalker.OrbwalkTo(EnemyHero); } } else { Orbwalker.Move(Game.MousePosition); } } catch (TaskCanceledException) { // canceled } catch (Exception e) { Log.Error(e); } }
/// <summary> /// Called on basher initialisation /// </summary> public override void Initialise(ref Basher basher) { base.Initialise(ref basher); ID = 4; }
// Use this for initialization void Start() { Application.targetFrameRate = 0; _this = this.gameObject.GetComponent <Basher>(); this.GetComponent <Damagable>().IsEnemy = false; if (parts == null) { parts = new BasherPart[MaxParts]; } if (enchantments == null) { enchantments = new BasherPart[MaxEnchantments]; } ResistMults = new float[MaxParts + MaxEnchantments]; // Set default Damagable values for the basher Damagable dmgb = this.GetComponent <Damagable>(); dmgb.Health = 100; dmgb.Resistance = 1; SpeedMultiplier = 1; // Fetch a copy of the player data to shorten the code a bit // and reduce CPU strain (slightly) PlayerData.SPData playerData = GameObject.FindObjectOfType <PlayerData>().playerData; // Add each part to the parts list with the help of the part database PartDatabase partDB = GameObject.FindObjectOfType <PartDatabase>(); // Create the parts for (int i = 0; i < MaxParts; i++) { parts[i] = CreatePart(playerData.Parts[i]); } // Create the enchantments for (int i = 0; i < MaxEnchantments; i++) { enchantments[i] = CreatePart(playerData.Enchantments[i]); } // Go through parts and call the Init function for (int i = 0; i < parts.Length; i++) { if (parts[i] != null) { parts[i].Initialise(ref _this); parts[i].SpawnPrefab(); } // Just set to 1 so we don't automatically become invincible ResistMults[i] = 1; } // Go through enchantments and call the Init function for (int i = 0; i < enchantments.Length; i++) { if (enchantments[i] != null) { enchantments[i].Initialise(ref _this); enchantments[i].SpawnPrefab(); } // Just set to 1 so we don't automatically become invincible ResistMults[MaxParts + i] = 1; } }
/// <summary> /// Called every frame by the Basher /// </summary> public virtual void Update(ref Basher basher) { damagable = basher.GetComponent <Damagable>(); }
/// <summary> /// Triggered after the basher is damaged (e.g from archers) and has taken the damage /// </summary> public virtual void PostDamage(ref Basher basher, float damage) { damagable = basher.GetComponent <Damagable>(); }
/// <summary> /// Triggered after the basher collides with an object and has taken damage /// </summary> public virtual void PostHit(ref Basher basher, ref Damagable target, float damage) { damagable = basher.GetComponent <Damagable>(); }
/// <summary> /// Triggered on startup to modify things /// </summary> public virtual void Initialise(ref Basher basher) { damagable = basher.GetComponent <Damagable>(); }