public override void Update(TerraGuardian tg, GuardianSpecialAttackData d) { if (d.FirstFrame && d.Step == 1) { CaptainStenchBase.CaptainStenchData data = (CaptainStenchBase.CaptainStenchData)tg.Data; Rectangle AttackHitbox = new Rectangle((int)(-16 * tg.Direction * tg.Scale) + (int)tg.Position.X, (int)(-110 * tg.Scale + tg.Position.Y + tg.Base.CharacterPositionYDiscount), (int)(78 * tg.Scale), (int)(94 * tg.Scale)); if (tg.LookingLeft) { AttackHitbox.X -= AttackHitbox.Width; } for (int i = 0; i < 4; i++) { Vector2 Position = new Vector2(AttackHitbox.X, AttackHitbox.Y); switch (i) { case 1: Position.X += AttackHitbox.Width; break; case 2: Position.Y += AttackHitbox.Height; break; case 3: Position.X += AttackHitbox.Width; Position.Y += AttackHitbox.Height; break; } Dust dust = Dust.NewDustDirect(Position, 1, 1, 50); dust.noGravity = true; dust.velocity = Vector2.Zero; } int Damage = d.Damage; int CriticalRate = 4 + tg.MeleeCriticalRate; float Knockback = 8f; byte SwordID = data.SwordID; if (SwordID > 0) { switch (SwordID) { case CaptainStenchBase.AmethystFalchion: break; case CaptainStenchBase.TopazFalchion: Knockback += 12f; break; case CaptainStenchBase.SapphireFalchion: //Knockback *= 0.11f; break; case CaptainStenchBase.EmeraldFalchion: CriticalRate += 50; break; } } bool HitSomething = false; for (int n = 0; n < 200; n++) { if (Main.npc[n].active && !Main.npc[n].friendly && !tg.NpcHasBeenHit(n) && Main.npc[n].getRect().Intersects(AttackHitbox)) { if (!Main.npc[n].dontTakeDamage) { int HitDirection = tg.Direction; if ((HitDirection == -1 && tg.Position.X < Main.npc[n].Center.X) || (HitDirection == 1 && tg.Position.X > Main.npc[n].Center.X)) { HitDirection *= -1; } bool Critical = (Main.rand.Next(100) < CriticalRate); int NewDamage = Damage; if (tg.OwnerPos > -1 && !MainMod.DisableDamageReductionByNumberOfCompanions) { float DamageMult = Main.player[tg.OwnerPos].GetModPlayer <PlayerMod>().DamageMod; NewDamage = (int)(NewDamage * DamageMult); } HitSomething = true; double result = Main.npc[n].StrikeNPC(NewDamage, Knockback, HitDirection, Critical); if (result > 0) { if (SwordID == CaptainStenchBase.AmethystFalchion) { if (Main.rand.NextDouble() < 0.4) { Main.npc[n].AddBuff(Terraria.ID.BuffID.ShadowFlame, 10 * 60); } } else if (SwordID == CaptainStenchBase.RubyFalchion) { int HealthRecover = (int)(Math.Max(1, result * 0.05f)); tg.RestoreHP(HealthRecover); } else if (SwordID == CaptainStenchBase.DiamondFalchion) { if (Main.rand.NextDouble() < 0.5) { Main.npc[n].AddBuff(Terraria.ID.BuffID.Dazed, 3 * 60); } } Main.PlaySound(Main.npc[n].HitSound, Main.npc[n].Center); } tg.AddNpcHit(n); tg.IncreaseDamageStacker((int)result, Main.npc[n].lifeMax); if (result > 0) { if (tg.HasFlag(GuardianFlags.BeetleOffenseEffect)) { tg.IncreaseCooldownValue(GuardianCooldownManager.CooldownType.BeetleCounter, (int)result); } tg.OnHitSomething(Main.npc[n]); tg.AddSkillProgress((float)result, GuardianSkills.SkillTypes.Strength); //(float)result if (SwordID == CaptainStenchBase.AmethystFalchion) { tg.AddSkillProgress((float)result * 0.15f, GuardianSkills.SkillTypes.Mysticism); } if (Critical) { tg.AddSkillProgress((float)result, GuardianSkills.SkillTypes.Luck); //(float)result } } } else { } } } if (HitSomething) { if (SwordID == CaptainStenchBase.SapphireFalchion) { tg.ChangeSubAttackCooldown(CaptainStenchBase.GPSubAttack, -0.25f); tg.MP += (int)(2 * tg.ManaHealMult); if (tg.MP > tg.MMP) { tg.MP = tg.MMP; } } } } if (d.Step < 2) { if (d.Time >= 4) { d.ChangeStep(); } } else { if (d.Time >= 8) { d.EndUse(); } } }
public GuardianSpecialAttackData.AffectedTargets[] AreaDamage(TerraGuardian Caster, int Damage, float Knockback, Rectangle Hitbox, byte CriticalRate = 0, bool AffectAllies = false, bool BlockConsecutiveHits = true) { List <GuardianSpecialAttackData.AffectedTargets> Targets = new List <GuardianSpecialAttackData.AffectedTargets>(); float StackedDamage = 0; float StackedCritical = 0; int NewDamage = Damage; if (Caster.OwnerPos > -1 && !MainMod.DisableDamageReductionByNumberOfCompanions) { float DamageMult = Main.player[Caster.OwnerPos].GetModPlayer <PlayerMod>().DamageMod; NewDamage = (int)(NewDamage * DamageMult); } for (int i = 0; i < 255; i++) { if (Main.player[i].active && !Main.player[i].dead) { Player player = Main.player[i]; if ((!BlockConsecutiveHits || !Caster.PlayerHasBeenHit(i)) && (AffectAllies || Caster.IsPlayerHostile(player)) && player.getRect().Intersects(Hitbox)) { int HitDirection = Caster.Direction; if ((HitDirection == 1 && player.Center.X < Caster.Position.X) || (HitDirection == -1 && player.Center.X > Caster.Position.X)) { HitDirection *= -1; } bool Critical = Main.rand.Next(100) < CriticalRate; double result = player.Hurt(Terraria.DataStructures.PlayerDeathReason.ByCustomReason(" didn't survived " + Caster.Name + "'s attack."), NewDamage, HitDirection, false, false, Critical); if (result > 0) { GuardianSpecialAttackData.AffectedTargets affected = new GuardianSpecialAttackData.AffectedTargets(player); affected.SetDamage((int)result); Targets.Add(affected); if (BlockConsecutiveHits) { Caster.AddPlayerHit(player.whoAmI); } Caster.IncreaseDamageStacker((int)result, player.statLifeMax2); StackedDamage += (float)result; if (Critical) { StackedCritical += (float)result; } } } } if (i < 200 && Main.npc[i].active) { NPC npc = Main.npc[i]; if ((!BlockConsecutiveHits || !Caster.NpcHasBeenHit(i)) && Caster.IsNpcHostile(npc) && npc.getRect().Intersects(Hitbox)) { int HitDirection = Caster.Direction; if ((HitDirection == 1 && npc.Center.X < Caster.Position.X) || (HitDirection == -1 && npc.Center.X > Caster.Position.X)) { HitDirection *= -1; } bool Critical = Main.rand.Next(100) < CriticalRate; double result = npc.StrikeNPC(NewDamage, Knockback, HitDirection, Critical); if (result > 0) { GuardianSpecialAttackData.AffectedTargets affected = new GuardianSpecialAttackData.AffectedTargets(npc); affected.SetDamage((int)result); Targets.Add(affected); if (BlockConsecutiveHits) { Caster.AddNpcHit(npc.whoAmI); } Caster.IncreaseDamageStacker((int)result, npc.lifeMax); StackedDamage += (float)result; if (Critical) { StackedCritical += (float)result; } } } } } foreach (int i in MainMod.ActiveGuardians.Keys) { if (i != Caster.WhoAmID && (AffectAllies || Caster.IsGuardianHostile(MainMod.ActiveGuardians[i]))) { TerraGuardian tg = MainMod.ActiveGuardians[i]; if (tg.HitBox.Intersects(Hitbox)) { int HitDirection = Caster.Direction; if ((HitDirection == 1 && tg.Position.X < Caster.Position.X) || (HitDirection == -1 && tg.Position.X > Caster.Position.X)) { HitDirection *= -1; } bool Critical = Main.rand.Next(100) < CriticalRate; double result = tg.Hurt(NewDamage, HitDirection, Critical, DeathMessage: " didn't survived " + Caster.Name + "'s attack."); if (result > 0) { GuardianSpecialAttackData.AffectedTargets affected = new GuardianSpecialAttackData.AffectedTargets(tg); affected.SetDamage((int)result); Targets.Add(affected); Caster.IncreaseDamageStacker((int)result, tg.MHP); StackedDamage += (float)result; if (Critical) { StackedCritical += (float)result; } } } } } if (StackedDamage > 0) { GuardianSkills.SkillTypes AttackSkill = GuardianSkills.SkillTypes.Strength; switch (AttackType) { case SubAttackCombatType.Ranged: AttackSkill = GuardianSkills.SkillTypes.Ballistic; break; case SubAttackCombatType.Magic: AttackSkill = GuardianSkills.SkillTypes.Mysticism; break; } Caster.AddSkillProgress(StackedDamage, AttackSkill); if (StackedCritical > 0) { Caster.AddSkillProgress(StackedDamage, GuardianSkills.SkillTypes.Luck); } } return(Targets.ToArray()); }
public override void Update(TerraGuardian tg, GuardianSpecialAttackData d) { if (d.FirstFrame) { if (d.Step == 5) { CaptainStenchBase.CaptainStenchData data = (CaptainStenchBase.CaptainStenchData)tg.Data; Rectangle AttackHitbox = new Rectangle((int)(-32 * tg.Direction * tg.Scale) + (int)tg.Position.X, (int)(-102 * tg.Scale + tg.Position.Y), (int)(104 * tg.Scale), (int)(98 * tg.Scale)); if (tg.LookingLeft) { AttackHitbox.X -= AttackHitbox.Width; } int Damage = d.Damage; int CriticalRate = 4 + tg.MeleeCriticalRate; float Knockback = 8f; byte SwordID = data.SwordID; Main.PlaySound(2, tg.CenterPosition, 1); if (SwordID > 0) { switch (SwordID) { case CaptainStenchBase.AmethystFalchion: { Vector2 SpawnPos = tg.PositionWithOffset; float Scale = (float)tg.Height / 74 * tg.Scale * 1.5f; SpawnPos.Y -= 39 * Scale; //78 int p = Projectile.NewProjectile(SpawnPos, new Vector2(16f * tg.Direction, 0), Terraria.ModLoader.ModContent.ProjectileType <Projectiles.AmethystGP>(), (int)(Damage * 1.333f), Knockback, tg.GetSomeoneToSpawnProjectileFor); Main.PlaySound(2, tg.CenterPosition, 101); Main.projectile[p].scale = Scale; Main.projectile[p].netUpdate = true; } break; case CaptainStenchBase.TopazFalchion: { Knockback += 12f; for (int s = 0; s < 4; s++) { Vector2 ShardSpawnPosition = tg.PositionWithOffset; ShardSpawnPosition.X += Main.rand.Next((int)(tg.Width * -0.5f), (int)(tg.Width * 0.5f)); ShardSpawnPosition.Y -= Main.rand.Next(8, tg.Height - 8); int p = Projectile.NewProjectile(ShardSpawnPosition, new Vector2(4f * tg.Direction, 0), Terraria.ModLoader.ModContent.ProjectileType <Projectiles.TopazGP>(), (int)(Damage * 0.25f), Knockback, tg.GetSomeoneToSpawnProjectileFor); Main.projectile[p].scale = tg.Scale; Main.projectile[p].netUpdate = true; Main.PlaySound(2, tg.CenterPosition, 101); } } break; case CaptainStenchBase.SapphireFalchion: { //Knockback *= 0.11f; int p = Projectile.NewProjectile(tg.CenterPosition, new Vector2(8f * tg.Direction, 0), Terraria.ModLoader.ModContent.ProjectileType <Projectiles.SapphireGP>(), Damage, Knockback, tg.GetSomeoneToSpawnProjectileFor); Main.projectile[p].scale = tg.Scale; Main.projectile[p].netUpdate = true; Main.PlaySound(2, tg.CenterPosition, 39); } break; case CaptainStenchBase.EmeraldFalchion: { CriticalRate += 50; Vector2 SpawnPosition = tg.PositionWithOffset; SpawnPosition.Y -= 40 * tg.Scale * 1.5f; //78 int p = Projectile.NewProjectile(SpawnPosition, new Vector2(1f * tg.Direction, 0), Terraria.ModLoader.ModContent.ProjectileType <Projectiles.EmeraldGP>(), (int)(Damage * 0.75f), Knockback * 0.9f, tg.GetSomeoneToSpawnProjectileFor); Main.projectile[p].scale = tg.Scale * 1.5f; Main.projectile[p].netUpdate = true; } break; case CaptainStenchBase.DiamondFalchion: { Damage += (int)(tg.MHP * 0.05f); } break; } } for (int n = 0; n < 200; n++) { if (Main.npc[n].active && !Main.npc[n].friendly && !tg.NpcHasBeenHit(n) && Main.npc[n].getRect().Intersects(AttackHitbox)) { if (!Main.npc[n].dontTakeDamage) { int HitDirection = tg.Direction; if ((HitDirection == -1 && tg.Position.X < Main.npc[n].Center.X) || (HitDirection == 1 && tg.Position.X > Main.npc[n].Center.X)) { HitDirection *= -1; } bool Critical = (Main.rand.Next(100) < CriticalRate); int NewDamage = Damage; if (tg.OwnerPos > -1 && !MainMod.DisableDamageReductionByNumberOfCompanions) { float DamageMult = Main.player[tg.OwnerPos].GetModPlayer <PlayerMod>().DamageMod; NewDamage = (int)(NewDamage * DamageMult); } double result = Main.npc[n].StrikeNPC(NewDamage, Knockback, HitDirection, Critical); if (result > 0) { if (SwordID == CaptainStenchBase.AmethystFalchion) { if (Main.rand.NextDouble() < 0.4) { Main.npc[n].AddBuff(Terraria.ID.BuffID.ShadowFlame, 10 * 60); } } else if (SwordID == CaptainStenchBase.RubyFalchion) { float HealthRecover = 0.1f; Rectangle SweetSpotPosition = new Rectangle((int)(tg.Position.X + tg.Direction * (48 + 40) * tg.Scale), (int)(tg.CenterY - 40 * tg.Scale), (int)(32 * tg.Scale), (int)(32 * tg.Scale)); if (tg.LookingLeft) { SweetSpotPosition.X -= SweetSpotPosition.Width; } if (Main.npc[n].getRect().Intersects(SweetSpotPosition)) { HealthRecover = 0.5f; Main.PlaySound(1, tg.CenterPosition); for (int i = 0; i < 25; i++) { Dust.NewDust(Main.npc[n].position, Main.npc[n].width, Main.npc[n].height, Terraria.ID.DustID.Blood); } } if (HealthRecover * result >= 1) { tg.RestoreHP((int)(HealthRecover * result)); } else { tg.RestoreHP(1); } tg.AddBuff(Terraria.ModLoader.ModContent.BuffType <Buffs.DrainingHealth>(), 60); } else if (SwordID == CaptainStenchBase.DiamondFalchion) { Main.npc[n].AddBuff(Terraria.ID.BuffID.Confused, 3 * 60); } } Main.PlaySound(Main.npc[n].HitSound, Main.npc[n].Center); tg.AddNpcHit(n); tg.IncreaseDamageStacker((int)result, Main.npc[n].lifeMax); if (result > 0) { if (tg.HasFlag(GuardianFlags.BeetleOffenseEffect)) { tg.IncreaseCooldownValue(GuardianCooldownManager.CooldownType.BeetleCounter, (int)result); } tg.OnHitSomething(Main.npc[n]); tg.AddSkillProgress((float)result, GuardianSkills.SkillTypes.Strength); //(float)result if (SwordID == CaptainStenchBase.AmethystFalchion) { tg.AddSkillProgress((float)result * 0.15f, GuardianSkills.SkillTypes.Mysticism); } if (Critical) { tg.AddSkillProgress((float)result, GuardianSkills.SkillTypes.Luck); //(float)result } } } else { } } } } } if (d.Step < 10) { if (d.Time >= AnimationTime) { d.ChangeStep(); } } else { d.EndUse(); } }
public override void Update(TerraGuardian tg, GuardianSpecialAttackData data) { tg.Velocity = Vector2.Zero; if (data.Step >= 4) { tg.TrailDelay = 2; tg.TrailLength = 10; tg.ImmuneTime = 30; tg.ImmuneNoBlink = true; Vector2 Velocity = Collision.TileCollision(tg.TopLeftPosition, new Vector2(tg.Direction * 20, 0), tg.CollisionWidth, tg.CollisionHeight); tg.Position += Velocity; tg.Velocity = Vector2.Zero; if (Collision.SolidCollision(tg.TopLeftPosition, tg.CollisionWidth, tg.CollisionHeight)) { if (tg.LookingLeft) { tg.Position.X = (int)(tg.Position.X * 0.0625f) * 16 + 16 + tg.CollisionWidth * 0.5f; } else { tg.Position.X = (int)(tg.Position.X * 0.0625f) * 16 + tg.CollisionWidth - tg.CollisionWidth * 0.5f; } } Rectangle rect = tg.HitBox; int Damage = data.Damage; float Knockback = 1.5f; int CriticalRate = 65 + tg.MeleeCriticalRate; int SwordID = (tg.Data as CaptainStenchBase.CaptainStenchData).SwordID; for (int n = 0; n < 200; n++) { if (Main.npc[n].active && !Main.npc[n].friendly && !tg.NpcHasBeenHit(n) && Main.npc[n].getRect().Intersects(rect)) { if (!Main.npc[n].dontTakeDamage) { int HitDirection = tg.Direction; if ((HitDirection == -1 && tg.Position.X < Main.npc[n].Center.X) || (HitDirection == 1 && tg.Position.X > Main.npc[n].Center.X)) { HitDirection *= -1; } bool Critical = (Main.rand.Next(100) < CriticalRate); int NewDamage = Damage; if (tg.OwnerPos > -1 && !MainMod.DisableDamageReductionByNumberOfCompanions) { float DamageMult = Main.player[tg.OwnerPos].GetModPlayer <PlayerMod>().DamageMod; NewDamage = (int)(NewDamage * DamageMult); } double result = Main.npc[n].StrikeNPC(NewDamage, Knockback, HitDirection, Critical); if (result > 0) { if (SwordID == CaptainStenchBase.AmethystFalchion) { if (Main.rand.NextDouble() < 0.4) { Main.npc[n].AddBuff(Terraria.ID.BuffID.ShadowFlame, 10 * 60); } } else if (SwordID == CaptainStenchBase.RubyFalchion) { int HealthRecover = (int)(Math.Max(1, result * 0.05f)); tg.RestoreHP(HealthRecover); } else if (SwordID == CaptainStenchBase.DiamondFalchion) { Main.npc[n].AddBuff(Terraria.ID.BuffID.Confused, 3 * 60); } } Main.PlaySound(Main.npc[n].HitSound, Main.npc[n].Center); tg.AddNpcHit(n); tg.IncreaseDamageStacker((int)result, Main.npc[n].lifeMax); if (result > 0) { if (tg.HasFlag(GuardianFlags.BeetleOffenseEffect)) { tg.IncreaseCooldownValue(GuardianCooldownManager.CooldownType.BeetleCounter, (int)result); } tg.OnHitSomething(Main.npc[n]); tg.AddSkillProgress((float)result, GuardianSkills.SkillTypes.Strength); //(float)result if (SwordID == CaptainStenchBase.AmethystFalchion) { tg.AddSkillProgress((float)result * 0.15f, GuardianSkills.SkillTypes.Mysticism); } if (Critical) { tg.AddSkillProgress((float)result, GuardianSkills.SkillTypes.Luck); //(float)result } } } } } } if (data.Time >= 3) { if (data.Step < 10) { data.ChangeStep(); } else { data.EndUse(); } } }