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 override void Update(TerraGuardian guardian) { AvoidItemUsage = true; switch (Step) { case 0: //Reach Target Vector2 TargetPosition = Vector2.Zero; int TargetWidth = 0, TargetHeight = 0; IgnoreCombat = true; if (TargetIsPlayer) { TargetPosition = TargetPlayer.position; TargetWidth = TargetPlayer.width; TargetHeight = TargetPlayer.height; } else { TargetPosition = TargetGuardian.TopLeftPosition; TargetWidth = TargetGuardian.Width; TargetHeight = TargetGuardian.Height; } if (guardian.HitBox.Intersects(new Rectangle((int)TargetPosition.X, (int)TargetPosition.Y, TargetWidth, TargetHeight))) { ChangeStep(); } else { guardian.MoveLeft = guardian.MoveRight = false; if (TargetPosition.X + TargetWidth * 0.5f - guardian.Position.X < 0) { guardian.MoveLeft = true; } else { guardian.MoveRight = true; } if (Time >= 5 * 60) { InUse = false; guardian.DisplayEmotion(TerraGuardian.Emotions.Sad); } } break; case 1: { guardian.MoveLeft = guardian.MoveRight = false; NoAggro = AvoidItemUsage = Immune = true; Vector2 EffectPosition = new Vector2(22 * guardian.Scale * guardian.Direction, 0) + guardian.Position; bool AnimationTrigger = Time == 120 + 8 * 2 || Time == 120 + 8 * 5 + 8 * 2 || Time == 120 + 8 * 10 + 8 * 2; bool RestoreCharacters = false; if (Time >= 120 + 8 * 15) { RestoreCharacters = true; InUse = false; } if (TargetIsPlayer) { Player p = TargetPlayer; if (AnimationTrigger) { int HealthRestored = (int)(p.statLifeMax2 * 0.1f); p.statLife += HealthRestored; p.HealEffect(HealthRestored); } if (RestoreCharacters) { p.position = guardian.Position; p.position.X -= p.width * 0.5f; p.position.Y -= p.height; p.fullRotation = 0; } else { p.Center = EffectPosition; p.direction = -guardian.Direction; p.fullRotation = 1.570796326794897f * guardian.Direction; if (p.immuneTime < 5) { p.immuneTime = 5; } } } else { TerraGuardian g = TargetGuardian; if (AnimationTrigger) { g.RestoreHP((int)(g.MHP * 0.1f)); } if (RestoreCharacters) { g.Position = guardian.Position; g.Rotation = 0; } else { g.Position = EffectPosition; g.Position.Y += g.Height * 0.5f; g.Direction = -g.Direction; g.Rotation = 1.570796326794897f * guardian.Direction; if (g.ImmuneTime < 5) { g.ImmuneTime = 5; } } } } break; } }
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(); } } }