public override void AI() { projectile.velocity.Y -= 0.006f; if (projectile.velocity.Y < -0.65f) { projectile.velocity.Y = -0.65f; } projectile.scale += 0.23f * (Main.expertMode ? 1.5f : 1); for (int p = 0; p < 255; p++) { if (!Main.player[p].active) { continue; } if (!Main.player[p].dead && !Main.player[p].ghost) { Vector2 NosePosition = Main.player[p].Center; NosePosition.Y -= Main.player[p].height * 0.25f; if (NosePosition.X >= ScaledPosition.X && NosePosition.X < ScaledPosition.X + projectile.width * projectile.scale && NosePosition.Y >= ScaledPosition.Y && NosePosition.Y < ScaledPosition.Y + projectile.height * projectile.scale) { Main.player[p].AddBuff(Terraria.ID.BuffID.Suffocation, 5); Main.player[p].AddBuff(Terraria.ID.BuffID.Weak, (Main.expertMode ? 75 : 15) * 60); Main.player[p].AddBuff(Terraria.ID.BuffID.Slow, 5); Main.player[p].AddBuff(Terraria.ID.BuffID.Stinky, 60 * 10); if (Main.expertMode) { Main.player[p].AddBuff(Terraria.ID.BuffID.Poisoned, 60); } } } } foreach (int g in MainMod.ActiveGuardians.Keys) { TerraGuardian Guardian = MainMod.ActiveGuardians[g]; if (Guardian.Active && !Guardian.Downed) { Vector2 NosePosition = Guardian.Position; NosePosition.Y -= Guardian.Height * 0.75f; if (NosePosition.X >= ScaledPosition.X && NosePosition.X < ScaledPosition.X + projectile.width * projectile.scale && NosePosition.Y >= ScaledPosition.Y && NosePosition.Y < ScaledPosition.Y + projectile.height * projectile.scale) { Guardian.AddBuff(BuffID.Suffocation, 5, true); Guardian.AddBuff(BuffID.Weak, (Main.expertMode ? 75 : 15) * 60, true); Guardian.AddBuff(BuffID.Slow, 5, true); Guardian.AddBuff(BuffID.Stinky, 60 * 10, true); if (Main.expertMode) { Guardian.AddBuff(BuffID.Poisoned, 60, true); } } } } }
public void SetMount(int m, TerraGuardian tg, bool FaceLeft = false) { if (this._type == m || m <= -1 || m >= maxMounts) { return; } if (m == 8) //Re-Logic... { return; } if (m == 5 && tg.Wet) { return; } if (this._active) { tg.Rotation = 0; _mountSpecificData = null; } else { this._active = true; } this._flyTime = 0; this._type = m; this._data = mounts[m]; this._fatigueMax = (float)this._data.fatigueMax; if (this.Cart && !FaceLeft && !this.Directional) { tg.AddBuff(this._data.extraBuff, 3600); this._flipDraw = true; } else { tg.AddBuff(this._data.buff, 3600); this._flipDraw = false; } if (this._type == 9 && this._abilityCooldown < 20) { this._abilityCooldown = 20; } if (this._type == 7 || this._type == 8) { //mountedPlayer.fullRotationOrigin = new Vector2((float)(mountedPlayer.width / 2), (float)(mountedPlayer.height / 2)); } /*if (this._type == 8) * { * this._mountSpecificData = new Mount.DrillMountData(); * }*/ bool SkipDust = false; Terraria.ModLoader.MountLoader.SetMount(this, dummyPlayer, ref SkipDust); }
public static void TrySimulatingProjectileDamageOnGuardian(Projectile p, TerraGuardian g) { Player dummy = Main.player[255]; try { if (p.owner > -1 && Main.player[p.owner].hostile) { p.StatusPvP(255); } else { p.StatusPlayer(255); } } catch { } for (int b = 0; b < dummy.buffType.Length; b++) { if (dummy.buffType[b] > 0) { g.AddBuff(dummy.buffType[b], dummy.buffTime[b], true); } dummy.buffType[b] = 0; dummy.buffTime[b] = 0; } }
public override bool GuardianWhenAttackedGuardian(TerraGuardian guardian, int Damage, bool Critical, TerraGuardian Attacker) { if (Main.rand.Next(5) == 0) { Attacker.AddBuff(Terraria.ModLoader.ModContent.BuffType <Buffs.Love>(), 10 * 60); } return(true); }
/*public void BackupPetSummonData(Player player, TerraGuardian guardian) * { * //Get * bunny = player.bunny; * penguin = player.penguin; * puppy = player.puppy; * grinch = player.grinch; * turtle = player.turtle; * eater = player.eater; * skeletron = player.skeletron; * hornet = player.hornet; * tiki = player.tiki; * lizard = player.lizard; * parrot = player.parrot; * truffle = player.truffle; * sapling = player.sapling; * cSapling = player.cSapling; * spider = player.spider; * squashling = player.squashling; * wisp = player.wisp; * dino = player.dino; * babyFaceMonster = player.babyFaceMonster; * slime = player.slime; * eyeSpring; * snowman; * blackCat; * zephyrfish; * pygmy; * spiderMinion; * miniMinotaur; * //Set * bunny; * penguin; * puppy; * grinch; * turtle; * eater; * skeletron; * hornet; * tiki; * lizard; * parrot; * truffle; * sapling; * cSapling; * spider; * squashling; * wisp; * dino; * babyFaceMonster; * slime; * eyeSpring; * snowman; * blackCat; * zephyrfish; * pygmy; * spiderMinion; * miniMinotaur; * }*/ public void RestorePlayerStatus() { //guardian.NumMinions = player.numMinions - maxMinions; guardian.HeldProj = player.heldProj; for (int b = 0; b < player.buffType.Length; b++) { if (player.buffType[b] != BuffTypes[b] && player.buffTime[b] > 0) { guardian.AddBuff(player.buffType[b], player.buffTime[b], true); } } guardian.Position.X = player.position.X + player.width * 0.5f; guardian.Position.Y = player.position.Y + player.height; guardian.Velocity = player.velocity; guardian.SetCooldownValue(GuardianCooldownManager.CooldownType.PhantasmCooldown, player.phantasmTime); player.position = Position; player.velocity = Velocity; player.direction = Direction; player.itemLocation = ItemPosition; player.width = Width; player.height = Height; //player.numMinions = numMinions; //player.maxMinions = maxMinions; //player.slotsMinions = SlotsMinion; player.wet = Wet; player.active = Active; player.dead = Dead; Main.mouseX = MouseX; Main.mouseY = MouseY; player.frostArmor = FrostBurn; player.meleeEnchant = MeleeEnchantment; player.itemAnimation = ItemAnimation; player.itemAnimationMax = ItemAnimationMax; player.itemTime = ItemTime; player.itemRotation = ItemRotation; player.heldProj = HeldProj; player.channel = channel; player.townNPCs = townNPCs; player.activeNPCs = activeNPCs; player.zone1 = Zone1; player.zone2 = Zone2; player.zone3 = Zone3; player.zone4 = Zone4; player.buffType = BuffTypes; player.buffTime = BuffTimes; player.phantasmTime = phantasmTime; player.ghostHeal = ghostHeal; player.ghostHurt = ghostHurt; player.lifeSteal = LifeStealRate; player.ghostDmg = GhostDamage; }
public static void GetGuardianBuffUpdate(BinaryReader reader, int SenderWhoAmI) { int WhoAmID = reader.ReadInt32(); int BuffID = reader.ReadInt32(); int BuffTime = reader.ReadInt32(); if (!MainMod.ActiveGuardians.ContainsKey(WhoAmID)) { return; } TerraGuardian tg = MainMod.ActiveGuardians[WhoAmID]; tg.AddBuff(BuffID, BuffTime, true); if (Main.netMode == 2) { SendGuardianBuffUpdate(WhoAmID, BuffID, BuffTime, -1, SenderWhoAmI); } }
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 guardian) //Add a overrideable method for custom dialogues. { this.guardian = guardian; bool IsWere = CastellaBase.OnWerewolfForm(guardian); bool LookForVictim = false; switch (Step) { case 0: //Pick behavior step; IgnoreCombat = true; if (IsWere) { if (StepStart) { Main.NewText("Awooooooooooo!!"); } if (Time >= 300) { ChangeStep(1); } } else { InUse = false; } break; case 1: { IgnoreCombat = false; LookForVictim = true; } break; case 200: case 201: case 202: { IgnoreCombat = true; AvoidItemUsage = true; guardian.MoveLeft = guardian.MoveRight = guardian.Jump = guardian.MoveDown = false; switch (VictimType) { case TerraGuardian.TargetTypes.Guardian: { if (!MainMod.ActiveGuardians.ContainsKey(VictimID)) { ChangeStep(1); return; } TerraGuardian Victim = MainMod.ActiveGuardians[VictimID]; Victim.IsBeingPulledByPlayer = false; if (Victim.PlayerMounted) { Victim.ToggleMount(true, false); } Vector2 Position = guardian.GetGuardianBetweenHandPosition; Victim.Position = Position + new Vector2(0, Victim.Height * 0.5f); Victim.Direction = -guardian.Direction; Victim.Velocity = Vector2.Zero; Victim.SetFallStart(); Victim.AddBuff(Terraria.ID.BuffID.Cursed, 5, true); if (Time == 120) { Victim.EnterDownedState(); Victim.KnockedOutCold = true; } if (Time >= 150) { ChangeStep(1); } } break; case TerraGuardian.TargetTypes.Player: { if (!Main.player[VictimID].active || Main.player[VictimID].dead) { ChangeStep(1); return; } Player Victim = Main.player[VictimID]; PlayerMod pm = Victim.GetModPlayer <PlayerMod>(); Vector2 Position = guardian.GetGuardianBetweenHandPosition; Position.X -= Victim.width * 0.5f; Position.Y -= Victim.height * 0.5f; Victim.position = Position; Victim.direction = -guardian.Direction; Victim.velocity = Vector2.Zero; Victim.fallStart = (int)(Victim.position.Y * (1f / 16)); Victim.AddBuff(Terraria.ID.BuffID.Cursed, 5); if (guardian.TalkPlayerID > -1) { ChangeStep(201); } if (Step == 200 || Step == 202) { if (Time == 90) { if (Victim.statLife == 1) { Victim.statLife++; } if (!pm.KnockedOut) { Victim.Hurt(Terraria.DataStructures.PlayerDeathReason.ByCustomReason(Victim.name + " couldn't endure the bite."), 1, 0); } pm.EnterDownedState(true); Victim.statLife = 1; Victim.Bottom = guardian.Position; if (Main.netMode == 0 && Victim.whoAmI == Main.myPlayer) { foreach (TerraGuardian tg in pm.GetAllGuardianFollowers) { if (tg.Active) { tg.EnterDownedState(); } } if (guardian.IsTownNpc) { guardian.TeleportHome(); } else { if (Main.rand.Next(3) != 0) { NpcMod.DespawnGuardianNPC(guardian); } } MainMod.DoBlackoutPlayer(); WorldMod.SkipTimeUntilMorning(); return; } } if (Time >= 120) { ChangeStep(1); } } } break; } } break; } if (LookForVictim) { if (guardian.TargetID > -1 && guardian.TargetType != TerraGuardian.TargetTypes.Npc) { AvoidItemUsage = true; Rectangle GrabBox = guardian.HitBox; GrabBox.Width += 8; if (guardian.LookingLeft) { GrabBox.X -= 8; } switch (guardian.TargetType) { case TerraGuardian.TargetTypes.Guardian: if (GrabBox.Intersects(MainMod.ActiveGuardians[guardian.TargetID].HitBox)) { VictimID = guardian.TargetID; VictimType = guardian.TargetType; ChangeStep(200); } break; case TerraGuardian.TargetTypes.Player: if (GrabBox.Intersects(Main.player[guardian.TargetID].getRect())) { VictimID = guardian.TargetID; VictimType = guardian.TargetType; ChangeStep(200); } break; } } else { AvoidItemUsage = false; } } }
public override void WhenGuardianUses(TerraGuardian guardian) { guardian.Data.Injury -= 16; guardian.AddBuff(ModContent.BuffType <Buffs.FirstAidCooldown>(), 8 * 3600); }
public override void Update(TerraGuardian guardian) { if (TargetPlayer != null) { if (TargetPlayer.dead || !TargetPlayer.active) { InUse = false; return; } } if (TargetGuardian != null) { if (!TargetGuardian.Active || TargetGuardian.Downed) { InUse = false; return; } } switch (Step) { case 0: { if (StepStart) { LastPlayerFollower = guardian.OwnerPos > -1; } Rectangle TargetHitbox; Vector2 TargetPosition; if (guardian.UsingFurniture) { guardian.LeaveFurniture(); } if (TargetPlayer != null) { TargetPosition = TargetPlayer.Center; TargetHitbox = TargetPlayer.getRect(); } else { TargetPosition = TargetGuardian.CenterPosition; TargetHitbox = TargetGuardian.HitBox; } if (TargetHitbox.Intersects(guardian.HitBox) || Time >= 10 * 60) { ChangeStep(); guardian.AddFlag(GuardianFlags.IgnoreGfx); } else if (guardian.Position.X > TargetPosition.X) { guardian.MoveLeft = true; guardian.MoveRight = false; } else { guardian.MoveRight = true; guardian.MoveLeft = false; } } break; case 1: { if (guardian.OwnerPos > -1 != LastPlayerFollower) { InUse = false; return; } guardian.IsBeingPulledByPlayer = false; if (!ByPlayerOrder && Time >= DurationTime) { if (TargetPlayer != null) { guardian.Position = TargetPlayer.Bottom; } else { guardian.Position = TargetGuardian.Position; } InUse = false; return; } guardian.MoveLeft = guardian.MoveRight = guardian.Jump = false; guardian.ChangeIdleAction(TerraGuardian.IdleActions.Wait, 300); Vector2 MountedPosition = guardian.Base.GetBetweenHandsPositionVector(Reviving ? guardian.Base.ReviveFrame : guardian.Base.PlayerMountedArmAnimation); MountedPosition.X = MountedPosition.X - guardian.Base.SpriteWidth * 0.5f; Vector2 HauntPosition = Vector2.Zero; if (TargetPlayer != null) { if (Reviving) { if (guardian.ItemAnimationTime == 0) { guardian.Direction = -TargetPlayer.direction; } HauntPosition = TargetPlayer.Center; } else { if (guardian.ItemAnimationTime == 0) { guardian.Direction = TargetPlayer.direction; } HauntPosition = TargetPlayer.position; } if (guardian.Direction > 0) { MountedPosition.X *= -1; } HauntPosition.X += TargetPlayer.width * 0.5f; HauntPosition.Y += TargetPlayer.height + (guardian.Base.SpriteHeight - MountedPosition.Y - 30) * guardian.Scale; HauntPosition.X += (MountedPosition.X - 6 * guardian.Direction) * guardian.Scale; guardian.AddDrawMomentToPlayer(TargetPlayer); TargetPlayer.AddBuff(Terraria.ModLoader.ModContent.BuffType <Buffs.GhostFoxHaunts.FriendlyHaunt>(), 5); Reviving = TargetPlayer.GetModPlayer <PlayerMod>().KnockedOut; } else { if (Reviving) { if (guardian.ItemAnimationTime == 0) { guardian.Direction = -TargetGuardian.Direction; } HauntPosition = TargetGuardian.CenterPosition; } else { if (guardian.ItemAnimationTime == 0) { guardian.Direction = TargetGuardian.Direction; } HauntPosition = TargetGuardian.Position; } if (guardian.Direction > 0) { MountedPosition.X *= -1; } HauntPosition.X += MountedPosition.X * guardian.Scale - TargetGuardian.Width * 0.2f * guardian.Direction; //HauntPosition.X += (MountedPosition.X - (TargetGuardian.Width * 0.5f - 8) * guardian.Direction) * guardian.Scale; //- 8 HauntPosition.Y += MountedPosition.Y * guardian.Scale - TargetGuardian.Height * 0.95f; guardian.AddDrawMomentToTerraGuardian(TargetGuardian); TargetGuardian.AddBuff(Terraria.ModLoader.ModContent.BuffType <Buffs.GhostFoxHaunts.FriendlyHaunt>(), 5, true); Reviving = TargetGuardian.KnockedOut || TargetGuardian.IsUsingBed; } guardian.Velocity = Vector2.Zero; guardian.Position = HauntPosition; } break; } LastPlayerFollower = guardian.OwnerPos > -1; }