public static void CompanionSaySomething(TerraGuardian Speaker, string Message, bool DisplayOnChat = false, int ExtraDialogueTime = 0) { LastSpeaker = Speaker; Speaker.SaySomething(Message, DisplayOnChat); Speaker.MessageTime += ExtraDialogueTime; while (Speaker.MessageTime > 0) { Thread.Sleep(100); } }
public const int PullMaxTime = 45; //Like his miniboss version public override void Update(TerraGuardian Me) { if (Me.UsingFurniture) { Me.LeaveFurniture(true); } if (Time >= PullMaxTime) { if (Time == PullMaxTime) { if (TargetIsPlayer) { PullStartPosition = TargetPlayer.Center; if (TargetPlayer.GetModPlayer <PlayerMod>().BeingCarriedByGuardian) { InUse = false; return; } } else { PullStartPosition = TargetGuardian.CenterPosition; if (TargetGuardian.BeingCarriedByGuardian) { InUse = false; return; } } } if (TargetIsPlayer) { Player player = TargetPlayer; Vector2 MoveDirection = Me.CenterPosition - player.Center; MoveDirection.Normalize(); Me.LookingLeft = player.Center.X < Me.Position.X; player.velocity = Vector2.Zero; player.position += MoveDirection * 8f; player.fallStart = (int)player.position.Y / 16; player.immuneTime = 5; player.immuneNoBlink = true; if (player.getRect().Intersects(Me.HitBox)) { player.velocity = Vector2.Zero; InUse = false; Me.StartNewGuardianAction(new Actions.CarryDownedAlly(player)); return; } } else { TerraGuardian guardian = TargetGuardian; Vector2 MoveDirection = Me.CenterPosition - guardian.CenterPosition; MoveDirection.Normalize(); Me.LookingLeft = guardian.Position.X < Me.Position.X; guardian.Velocity = Vector2.Zero; guardian.Position += MoveDirection * 8f; guardian.SetFallStart(); guardian.ImmuneTime = 5; guardian.ImmuneNoBlink = true; if (guardian.HitBox.Intersects(Me.HitBox)) { guardian.Velocity = Vector2.Zero; InUse = false; Me.StartNewGuardianAction(new Actions.CarryDownedAlly(guardian)); return; } } } else { if (Time == 30) { switch (Main.rand.Next(5)) { case 0: Me.SaySomething("*Better you stay close to me.*"); break; case 1: Me.SaySomething("*Let's avoid another death.*"); break; case 2: Me.SaySomething("*Come here.*"); break; case 3: Me.SaySomething("*Get over here.*"); break; case 4: Me.SaySomething("*No, you wont.*"); break; } } } }
public override void Update(TerraGuardian guardian) { EffectOnlyMirror = true; CantUseInventory = true; bool TeleportedEffects = false; switch (Step) { case 0: { if (StepStart) { string Message = guardian.GetMessage(GuardianBase.MessageIDs.LeavingToSellLoot); if (Message != "") { guardian.SaySomething(Message); } else { ChangeStep(); } } if (guardian.MessageTime <= 0) { ChangeStep(); } } break; case 1: //Check distance to town, calculate time to sell items. { if (StepStart) { if (guardian.furniturex > -1) { guardian.LeaveFurniture(); } if (!guardian.HasMagicMirror) { TeleportMethod = 1; LastWasPlayerMounted = guardian.PlayerMounted; if (guardian.PlayerMounted) { guardian.ToggleMount(true); } if (guardian.SittingOnPlayerMount) { guardian.DoSitOnPlayerMount(false); } //InUse = false; //return; } else { Vector2 GuardianPos = guardian.CenterPosition; Vector2 ResultPoint = new Vector2(Main.spawnTileX * 16, Main.spawnTileY * 16); int Time = 60 * 10; //Time += (int)Math.Abs(ResultPoint.X - GuardianPos.X) / 128; //Time += (int)Math.Abs(ResultPoint.Y - GuardianPos.Y) / 128; TeleportTime = Time; TeleportMethod = 0; } } if (TeleportMethod == 1) { //make guardian walk away from the player. If It gets away from screen distance, teleport. //If passes 5 seconds and It didn't teleport, make it disappear and calculate the time until nearest vendor. bool DoMove = false; if (this.Time >= 60 * 5) { DoMove = true; } else if (Math.Abs(guardian.Position.X - Main.player[guardian.OwnerPos].Center.X) < NPC.sWidth * 16) { IgnoreCombat = true; CantUseInventory = true; Immune = true; guardian.StuckTimer = 0; guardian.MoveLeft = guardian.MoveRight = false; if (Main.player[guardian.OwnerPos].Center.X - guardian.Position.X < 0) { guardian.MoveRight = true; } else { guardian.MoveLeft = true; } } else { DoMove = true; } if (DoMove) { int NearestTownNPC = -1; float NearestDist = -1; for (int n = 0; n < 200; n++) { if (Main.npc[n].active && Main.npc[n].townNPC && MainMod.VendorNpcs.Contains(Main.npc[n].type)) { float Distance = (guardian.CenterPosition - Main.npc[n].Center).Length(); if (NearestDist == -1 || Distance < NearestDist) { NearestTownNPC = n; NearestDist = Distance; } } } Vector2 ResultPosition = Vector2.Zero; if (NearestTownNPC > -1) { ResultPosition = Main.npc[NearestTownNPC].Center; } else { ResultPosition.X = Main.spawnTileX * 16; ResultPosition.Y = Main.spawnTileY * 16; } float WalkTime = 16f / guardian.MoveSpeed; int Time = (int)((Math.Abs(ResultPosition.X - guardian.Position.X) + Math.Abs(ResultPosition.Y - guardian.CenterY)) * WalkTime) / (16 * 16) + 60 * 7; TeleportTime = Time; //Main.NewText("Teleport time: " + Math.Round((float)Time / 60, 1) + "s."); LastWasPlayerMounted = guardian.PlayerMounted; if (guardian.PlayerMounted) { guardian.ToggleMount(true); } ChangeStep(); TeleportedEffects = true; } } else { if (guardian.ItemAnimationTime <= 0) { guardian.UseMagicMirror(); } if (guardian.MagicMirrorTrigger) { LastWasPlayerMounted = guardian.PlayerMounted; if (guardian.PlayerMounted) { guardian.ToggleMount(true); } ChangeStep(); TeleportedEffects = true; } } } break; case 2: { TeleportedEffects = true; if (Time >= TeleportTime) { bool SendToPiggyBank = guardian.FriendshipGrade >= 3; bool SoldItems = false, SentItemsToPiggyBank = false; int p = 0, g = 0, s = 0, c = 0; int token = 0; int copperstack = 0; for (int i = 10; i < 50; i++) { if (i != guardian.SelectedItem && guardian.Inventory[i].type != 0 && !guardian.Inventory[i].favorited) { if ((guardian.Inventory[i].type <Terraria.ID.ItemID.CopperCoin || guardian.Inventory[i].type> Terraria.ID.ItemID.PlatinumCoin) && guardian.Inventory[i].type != Terraria.ID.ItemID.DefenderMedal) { c += guardian.Inventory[i].value * guardian.Inventory[i].stack; guardian.Inventory[i].SetDefaults(0, true); SoldItems = true; } else if (SendToPiggyBank) { SentItemsToPiggyBank = true; switch (guardian.Inventory[i].type) { case Terraria.ID.ItemID.CopperCoin: copperstack += guardian.Inventory[i].stack; guardian.Inventory[i].SetDefaults(0, true); break; case Terraria.ID.ItemID.SilverCoin: s += guardian.Inventory[i].stack; guardian.Inventory[i].SetDefaults(0, true); break; case Terraria.ID.ItemID.GoldCoin: g += guardian.Inventory[i].stack; guardian.Inventory[i].SetDefaults(0, true); break; case Terraria.ID.ItemID.PlatinumCoin: p += guardian.Inventory[i].stack; guardian.Inventory[i].SetDefaults(0, true); break; case Terraria.ID.ItemID.DefenderMedal: token += guardian.Inventory[i].stack; guardian.Inventory[i].SetDefaults(0, true); break; } } } } c = c / 5 + copperstack; if (c >= 100) { s += c / 100; c -= s * 100; } if (s >= 100) { g += s / 100; s -= g * 100; } if (g >= 100) { p += g / 100; g -= p * 100; } string ResultText = ""; bool First = true; if (p > 0) { First = false; ResultText += p + " Platinum"; } if (g > 0) { if (!First) { ResultText += ", "; } First = false; ResultText += g + " Gold"; } if (s > 0) { if (!First) { ResultText += ", "; } First = false; ResultText += s + " Silver"; } if (c > 0) { if (!First) { ResultText += ", "; } First = false; ResultText += c + " Copper"; } if (SentItemsToPiggyBank && !SoldItems) { ResultText = guardian.Name + " stored " + ResultText + " on your Piggy Bank"; } else if (c == 0 && s == 0 && g == 0 && p == 0) { ResultText = guardian.Name + " gained nothing from selling the items"; } else { ResultText = guardian.Name + " got " + ResultText + " Coins from item sale"; if (SendToPiggyBank) { ResultText += ", and they were sent to your Piggy Bank"; } } if (token > 0) { ResultText += ", and stored " + token + " defender medals"; } Main.NewText(ResultText + ".", Color.Yellow); if (SendToPiggyBank && guardian.OwnerPos != -1) //Store on player piggy bank { Chest bank = Main.player[guardian.OwnerPos].bank; for (byte Coin = 0; Coin < 5; Coin++) { int EmptySlot = -1; int CoinID = Coin + Terraria.ID.ItemID.CopperCoin; if (Coin == 4) { CoinID = Terraria.ID.ItemID.DefenderMedal; } int CoinsToDiscount = 0; switch (Coin) { case 0: CoinsToDiscount = c; c = 0; break; case 1: CoinsToDiscount = s; s = 0; break; case 2: CoinsToDiscount = g; g = 0; break; case 3: CoinsToDiscount = p; p = 0; break; case 4: CoinsToDiscount = token; token = 0; break; } if (CoinsToDiscount == 0) { continue; } for (int i = 0; i < bank.item.Length; i++) { if (bank.item[i].type == 0) { EmptySlot = i; } if (CoinsToDiscount > 0 && bank.item[i].type == CoinID) { bank.item[i].stack += CoinsToDiscount; CoinsToDiscount = 0; if (bank.item[i].stack >= 100 && CoinID != Terraria.ID.ItemID.PlatinumCoin && CoinID != Terraria.ID.ItemID.DefenderMedal) { int NextSum = bank.item[i].stack / 100; bank.item[i].stack -= NextSum * 100; switch (Coin) { case 0: s += NextSum; break; case 1: g += NextSum; break; case 2: p += NextSum; break; } } if (CoinID == Terraria.ID.ItemID.PlatinumCoin && bank.item[i].stack > 1000) { CoinsToDiscount = bank.item[i].stack - 1000; bank.item[i].stack = 1000; } if (CoinID == Terraria.ID.ItemID.DefenderMedal && bank.item[i].stack > 999) { CoinsToDiscount = bank.item[i].stack - 999; bank.item[i].stack = 999; } if (bank.item[i].stack == 0) { bank.item[i].SetDefaults(0, true); } } } while (CoinsToDiscount > 0) { if (EmptySlot > -1) { bank.item[EmptySlot].SetDefaults(CoinID, true); if (CoinsToDiscount > 1000) { bank.item[EmptySlot].stack = 1000; CoinsToDiscount -= 1000; EmptySlot = -1; for (int i = 0; i < bank.item.Length; i++) { if (bank.item[i].type == 0) { EmptySlot = i; } } } else { bank.item[EmptySlot].stack = CoinsToDiscount; CoinsToDiscount = 0; } } else { switch (Coin) { case 0: c = CoinsToDiscount; break; case 1: s = CoinsToDiscount; break; case 2: g = CoinsToDiscount; break; case 3: p = CoinsToDiscount; break; case 4: token = CoinsToDiscount; break; } CoinsToDiscount = 0; } } } } for (int i = 0; i < 50; i++) { switch (guardian.Inventory[i].type) { case Terraria.ID.ItemID.CopperCoin: { c += guardian.Inventory[i].stack; guardian.Inventory[i].SetDefaults(0, true); } break; case Terraria.ID.ItemID.SilverCoin: { s += guardian.Inventory[i].stack; guardian.Inventory[i].SetDefaults(0, true); } break; case Terraria.ID.ItemID.GoldCoin: { g += guardian.Inventory[i].stack; guardian.Inventory[i].SetDefaults(0, true); } break; case Terraria.ID.ItemID.PlatinumCoin: { p += guardian.Inventory[i].stack; guardian.Inventory[i].SetDefaults(0, true); } break; case Terraria.ID.ItemID.DefenderMedal: { token += guardian.Inventory[i].stack; guardian.Inventory[i].SetDefaults(0, true); } break; } } if (c >= 100) { s += c / 100; c -= s * 100; } if (s >= 100) { g += s / 100; s -= g * 100; } if (g >= 100) { p += g / 100; g -= p * 100; } for (int i = 0; i < 50; i++) { if (guardian.Inventory[i].type == 0) { if (token > 0) { guardian.Inventory[i].SetDefaults(Terraria.ID.ItemID.DefenderMedal, true); guardian.Inventory[i].stack = token; token = 0; } else if (p > 0) { guardian.Inventory[i].SetDefaults(Terraria.ID.ItemID.PlatinumCoin, true); guardian.Inventory[i].stack = p; p = 0; } else if (g > 0) { guardian.Inventory[i].SetDefaults(Terraria.ID.ItemID.GoldCoin, true); guardian.Inventory[i].stack = g; g = 0; } else if (s > 0) { guardian.Inventory[i].SetDefaults(Terraria.ID.ItemID.SilverCoin, true); guardian.Inventory[i].stack = s; s = 0; } else if (c > 0) { guardian.Inventory[i].SetDefaults(Terraria.ID.ItemID.CopperCoin, true); guardian.Inventory[i].stack = c; c = 0; } } } for (byte Coin = 0; Coin < 5; Coin++) { int CoinID = Coin + Terraria.ID.ItemID.CopperCoin; if (Coin == 4) { CoinID = Terraria.ID.ItemID.DefenderMedal; } int Stack = 0; switch (Coin) { case 0: Stack = c; break; case 1: Stack = s; break; case 2: Stack = g; break; case 3: Stack = p; if (Stack > 1000) { p -= 1000; Stack = 1000; Coin--; } break; case 4: Stack = token; if (Stack > 999) { token -= 999; Stack = 999; Coin--; } break; } if (Stack > 0) { Item.NewItem(guardian.HitBox, CoinID, Stack); } } ChangeStep(); } } break; case 3: { if (TeleportMethod == 0) { if (guardian.ItemAnimationTime <= 0) { guardian.UseMagicMirror(); } if (guardian.MagicMirrorTrigger) { InUse = false; if (LastWasPlayerMounted) { guardian.ToggleMount(true); } else if (guardian.OwnerPos > -1) { guardian.Velocity = Main.player[guardian.OwnerPos].velocity; } } else { TeleportedEffects = true; } } else { if (StepStart) { TeleportTime = 60 * 5; } if (Time < TeleportTime) { TeleportedEffects = true; } else { Main.NewText(guardian.Name + " has returned."); guardian.StuckTimer = 0; InUse = false; if (LastWasPlayerMounted) { guardian.ToggleMount(); } else if (guardian.OwnerPos > -1) { guardian.Velocity = Main.player[guardian.OwnerPos].velocity; } } } } break; } IgnoreCombat = TeleportedEffects; //AvoidItemUsage = TeleportedEffects; Invisibility = TeleportedEffects; Immune = TeleportedEffects; NoAggro = TeleportedEffects; Inactivity = TeleportedEffects; if (TeleportedEffects) { if (guardian.GuardingPosition.HasValue) { guardian.Position.X = guardian.GuardingPosition.Value.X * 16; guardian.Position.Y = guardian.GuardingPosition.Value.Y * 16; } else { guardian.Position.X = Main.player[guardian.OwnerPos].Center.X; guardian.Position.Y = Main.player[guardian.OwnerPos].position.Y + Main.player[guardian.OwnerPos].height - 1; } guardian.Velocity.X = guardian.Velocity.Y = 0; } }
public override void AI() { TerraGuardian Brutustg = PlayerMod.GetPlayerSummonedGuardian(Main.player[Main.myPlayer], BrutusID); bool PlayerHasBrutusSummoned = Brutustg != null; if (Brutustg == null) { foreach (TerraGuardian tg in WorldMod.GuardianTownNPC) { if (tg.ID == BrutusID && tg.ModID == MainMod.mod.Name) { Brutustg = tg; break; } } } Player player = Main.player[Main.myPlayer]; bool PlayerHasDomino = PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], GuardianBase.Domino); string BrutusChat = ""; if (PlayerHasBrutusSummoned && !DominoDismissed) { if (DialogueStep == -1 && Math.Abs(player.Center.X - npc.Center.X) < 128f) { DialogueStep = 0; DialogueTime = 0; BrutusChat = "*Halt! You there!*"; } } if (DialogueStep == -1 && player.talkNPC != npc.whoAmI) { if (DialogueTime == 0) { if (player.Center.X - npc.Center.X < 0) { npc.direction = -1; } else { npc.direction = 1; } } Walk = true; if (DialogueTime <= 1401) { if (npc.direction < 0) { MoveLeft = true; } else { MoveRight = true; } } if (DialogueTime >= 1401) { DialogueTime -= 1400; } DialogueTime++; } npc.npcSlots = 1; if (DialogueStep >= 0) { npc.npcSlots = 200; DialogueTime++; bool Trigger = false; if (DialogueTime >= DialogueDelay) { Trigger = true; DialogueTime = 0; DialogueStep++; } bool FacePlayer = false; if (PlayerHasDomino) { FacePlayer = true; switch (DialogueStep) { case 0: if (DialogueTime >= 60) { SayMessage("*This again?!*"); } if (DialogueTime >= 90) { DialogueTime = DialogueDelay; } break; case 1: if (Trigger) { if (PlayerHasBrutusSummoned) { BrutusChat = "*You have the audacity of showing up again.*"; } else { SayMessage("*Ah, you're not with him... Good.*"); } } break; case 2: if (Trigger) { if (PlayerHasBrutusSummoned) { SayMessage("*Yeah right, like as If I'm happy for seeing you again.*"); } else { SayMessage("*Since you're here too, I don't think you'll mind if I open my business here too.*"); } } break; case 3: if (Trigger) { if (PlayerHasBrutusSummoned) { SayMessage("*Terrarian, you know the drill. Need me for anything, I will be here.*"); } else { SayMessage("*Or if you need my help for anything, you know where to find me.*"); } } break; case 4: if (Trigger) { if (PlayerHasBrutusSummoned) { BrutusChat = "*Ugh...*"; } NpcMod.AddGuardianMet(GuardianID, GuardianModID); WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID); //npc.Transform(ModContent.NPCType<GuardianNPC.List.DogGuardian>()); } break; } } else if (!PlayerHasDomino && !PlayerHasBrutusSummoned && DialogueStep == -1) { Idle = true; DialogueTime = 0; } else { switch (DialogueStep) { case 0: if (DialogueTime >= 60) { SayMessage("*Uh oh.*"); FacePlayer = true; } if (DialogueTime >= 90) { DialogueTime = DialogueDelay; } break; case 1: { if (Trigger) { BrutusChat = "*After him! Don't let him escape!*"; } if (player.Center.X - npc.Center.X >= 0) { MoveLeft = true; } else { MoveRight = true; } if (Math.Abs(player.Center.X - npc.Center.X) >= NPC.sWidth || Math.Abs(player.Center.Y - npc.Center.Y) >= NPC.sHeight) { npc.active = false; BrutusChat = "*Blast it! He got away! He'll return, I'm sure.*"; } DialogueTime = 5; if (player.getRect().Intersects(npc.getRect())) { DialogueTime = DialogueDelay; } } break; case 2: { if (Trigger) { BrutusChat = "*Got you now! You wont run away anymore!*"; } } break; case 3: { FacePlayer = true; if (Trigger) { SayMessage("*Hey Brutus, didn't you lost your place as a Royal Guard on the Ether Realm?*"); } } break; case 4: { FacePlayer = true; if (Trigger) { BrutusChat = "*If It wasn't for you, I wouldn't have lost my job. Beside, I was already sick of that.*"; } } break; case 5: { FacePlayer = true; if (Trigger) { SayMessage("*You don't need to thank me for that.*"); } } break; case 6: { FacePlayer = true; if (Trigger) { BrutusChat = "*I'm going to have you locked behind bars forever for smuggling.*"; } } break; case 7: { FacePlayer = true; if (Trigger) { SayMessage("*You're no longer a guard or anything, so you can't arrest me.*"); } } break; case 8: { FacePlayer = true; if (Trigger) { BrutusChat = "*Ugh... Uh...*"; SayMessage("*See? You can't arrest me, and the laws of the Ether Realm aren't valid here.*"); } } break; case 9: { FacePlayer = true; if (Trigger) { SayMessage("*Now, If you don't mind, I have something to ask to this Terrarian.*"); } } break; case 10: { if (Trigger) { SayMessage("*Terrarian, come talk to me.*"); } FacePlayer = true; DialogueTime = 5; } break; } if (AcceptedIn) { switch (DialogueStep) { case 11: { FacePlayer = true; if (Trigger) { SayMessage("*Looks like I will be staying here.*"); } } break; case 12: { FacePlayer = true; if (Trigger) { BrutusChat = "*Oh great! Now I will have to share the world with my most hated person.*"; } } break; case 13: { FacePlayer = true; if (Trigger) { SayMessage("*Now If you don't mind, I have some things to move in to this world.*"); } } break; case 14: { FacePlayer = true; if (Trigger) { BrutusChat = "*Mark my words, slide just a little bit, and I will put you behind bars!*"; } } break; case 15: { FacePlayer = true; if (Trigger) { SayMessage("*Yeah, right. I also love having you as a neighbor or something.*"); } } break; case 16: { if (Trigger) { PlayerMod.AddPlayerGuardian(player, GuardianID, GuardianModID); NpcMod.AddGuardianMet(GuardianID, GuardianModID); WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID); //npc.Transform(ModContent.NPCType<GuardianNPC.List.DogGuardian>()); return; } } break; } } else { switch (DialogueStep) { case 11: { if (Trigger) { FacePlayer = true; BrutusChat = "*Hah! The Terrarian said it! Now go away!*"; } } break; case 12: { if (Trigger) { FacePlayer = true; SayMessage("*Sigh... Well, I'm a man of word, anyway. Goodbye.*"); } } break; case 13: { if (Trigger) { DominoDismissed = true; BrutusChat = "*Good riddance.*"; for (int i = 0; i < 5; i++) { Gore.NewGore(npc.Center, new Microsoft.Xna.Framework.Vector2(Main.rand.Next(-40, 40) * 0.01f, Main.rand.Next(-40, 40) * 0.01f), Main.rand.Next(11, 14)); } npc.active = false; } } break; } } } if (FacePlayer) { if (player.Center.X - npc.Center.X >= 0) { npc.direction = 1; } else { npc.direction = -1; } if (Math.Abs(player.Center.X - npc.Center.X) >= 64) { if (player.Center.X - npc.Center.X >= 0) { MoveRight = true; } else { MoveLeft = true; } } } } if (Math.Abs(player.Center.X - npc.Center.X) >= NPC.sWidth + 64 || Math.Abs(player.Center.Y - npc.Center.Y) >= NPC.sHeight + 64) { npc.active = false; } if (BrutusChat != "" && Brutustg != null) { Brutustg.SaySomething(BrutusChat); } base.AI(); }
public override void Update(TerraGuardian guardian) { switch (Step) { case 0: { if (guardian.Inventory[ItemSlot].type == 0 || guardian.Inventory[ItemSlot].stack < ItemStack) { InUse = false; return; } if (guardian.UsingFurniture) { guardian.LeaveFurniture(true); } if (Formally) { ChangeStep(); } else { ChangeStep(2); } } break; case 1: { Vector2 TargetPosition = Vector2.Zero; if (player != null) { TargetPosition = player.Bottom; } else { TargetPosition = tg.Position; } if (guardian.Position.X > TargetPosition.X) { guardian.MoveLeft = true; guardian.MoveRight = false; } else { guardian.MoveRight = true; guardian.MoveLeft = false; } if (Time >= 10 * 60) { guardian.Position = TargetPosition; guardian.SetFallStart(); } if (TargetPosition.X >= guardian.Position.X - guardian.Width * 0.5f && TargetPosition.X < guardian.Position.X + guardian.Width * 0.5f && TargetPosition.Y >= guardian.Position.Y - guardian.Height && TargetPosition.Y - 24 < guardian.Position.Y) { ChangeStep(); } } break; case 2: { if (guardian.Inventory[ItemSlot].type == 0) { InUse = false; //Where's the item I was going to give? guardian.SaySomething(guardian.GetMessage(GuardianBase.MessageIDs.DeliveryItemMissing, "*They seems to have wanted to deliver something, but can't find it in their inventory.*")); return; } if (StepStart) { if (player != null) { byte EmptySlot = 255; byte MaxSlots = 50; if (guardian.Inventory[ItemSlot].ammo > 0) { MaxSlots = 54; } for (byte i = 0; i < MaxSlots; i++) { if (player.inventory[i].type == 0) { EmptySlot = i; } } if (EmptySlot == 255) { string Message = guardian.GetMessage(GuardianBase.MessageIDs.DeliveryInventoryFull, "*It seems like [target] have no room for what they wanted to give.*"). Replace("[target]", (player.whoAmI == Main.myPlayer ? guardian.PersonalNicknameToPlayer : player.name)); guardian.SaySomething(Message); InUse = false; } } else { int EmptySlot = -1; for (int i = 0; i < guardian.Inventory.Length; i++) { if (guardian.Inventory[i].type == 0) { EmptySlot = i; } } if (EmptySlot == 255) { string Message = guardian.GetMessage(GuardianBase.MessageIDs.DeliveryInventoryFull, "*It seems like you have no room for what they wanted to give [target].*").Replace("[target]", tg.Name); guardian.SaySomething(Message); InUse = false; } } } else if (Time >= 60) { if (player != null) { byte EmptySlot = 255; byte MaxSlots = 50; if (guardian.Inventory[ItemSlot].ammo > 0) { MaxSlots = 54; } for (byte i = 0; i < MaxSlots; i++) { if (player.inventory[i].type == 0) { EmptySlot = i; } } if (EmptySlot == 255) { string Message = guardian.GetMessage(GuardianBase.MessageIDs.DeliveryInventoryFull, "*It seems like [target] have no room for what they wanted to give.*"). Replace("[target]", (player.whoAmI == Main.myPlayer ? guardian.PersonalNicknameToPlayer : player.name)); guardian.SaySomething(Message); } else { Item item = guardian.Inventory[ItemSlot].DeepClone(); player.GetItem(player.whoAmI, item); guardian.Inventory[ItemSlot].SetDefaults(0, true); string Message = guardian.GetMessage(GuardianBase.MessageIDs.DeliveryGiveItem, "*" + guardian.Name + " gave [target] some [item].*"). Replace("[target]", (player.whoAmI == Main.myPlayer ? guardian.PersonalNicknameToPlayer : player.name)). Replace("[item]", item.Name); guardian.SaySomething(Message); } } else { int EmptySlot = -1; for (int i = 0; i < guardian.Inventory.Length; i++) { if (guardian.Inventory[i].type == 0) { EmptySlot = i; } } if (EmptySlot == 255) { string Message = guardian.GetMessage(GuardianBase.MessageIDs.DeliveryInventoryFull, "*It seems like [target] have no room for what they wanted to give.*"). Replace("[target]", tg.Name); guardian.SaySomething(Message); } else { Item item = guardian.Inventory[ItemSlot].DeepClone(); tg.Inventory[EmptySlot] = item; guardian.Inventory[EmptySlot].SetDefaults(0, true); string Message = guardian.GetMessage(GuardianBase.MessageIDs.DeliveryGiveItem, "*" + guardian.Name + " gave [target] some [item].*"). Replace("[target]", tg.Name). Replace("[item]", item.Name); guardian.SaySomething(Message); } } InUse = false; } } break; } }
public override void AI() { if (Main.myPlayer == -1) { return; } Player player = Main.player[npc.target]; if (JustSpawned) { //if (IsInPerceptionRange(player)) int NearestPlayer = Main.myPlayer; float NearestDistance = float.MaxValue; Vector2 NpcCenter = npc.Center; for (int p = 0; p < 255; p++) { if (Main.player[p].active) { float Distance = Main.player[p].Distance(NpcCenter); if (Distance < NearestDistance) { NearestDistance = Distance; NearestPlayer = p; } } } if (NearestPlayer > -1) { player = Main.player[NearestPlayer]; npc.target = NearestPlayer; //Main.NewText("A White Cat appeared to the " + GuardianBountyQuest.GetDirectionText(npc.Center - player.Center) + " of " + player.name + " position.", MainMod.MysteryCloseColor); } JustSpawned = false; } if (player.talkNPC == npc.whoAmI) { npc.direction = player.Center.X - npc.Center.X >= 0 ? 1 : -1; } if (SceneStep == SceneIds.NoScene && Math.Abs(player.Center.X - npc.Center.X) <= 152 && ((player.Center.X < npc.Center.X && npc.direction < 0) || (player.Center.X > npc.Center.X && npc.direction >= 0))) { //Found Sardine if (PlayerMod.PlayerHasGuardian(player, 7)) { ChangeScene(SceneIds.BreeSeesFriendlyFace); } else if (PlayerMod.PlayerHasGuardianSummoned(player, GuardianBase.Glenn) && PlayerMod.PlayerHasGuardianSummoned(player, GuardianBase.Sardine)) { ChangeScene(SceneIds.BreeSpotsSardineAndGlenn); SayMessage("Are they... Glenn! Sardine!"); HadSardineSpotted = HadGlennSpotted = true; } else if (PlayerMod.PlayerHasGuardianSummoned(player, GuardianBase.Glenn)) { ChangeScene(SceneIds.GlennSpotted); SayMessage("Gl... Glenn?!"); HadSardineSpotted = false; HadGlennSpotted = true; } else if (PlayerMod.PlayerHasGuardianSummoned(player, 2)) { ChangeScene(0); SayMessage("Sardine! I finally found you!"); HadSardineSpotted = true; HadGlennSpotted = false; } } npc.npcSlots = 1; if (SceneStep >= 0) { npc.npcSlots = 200; StepTime--; bool SceneChange = StepTime == 0; if (false && SceneStep == SceneIds.BreePersuadesThePlayerALittleCloser) { Vector2 PositionOnPlayer = player.Center; npc.direction = -player.direction; PositionOnPlayer.X += 12 * player.direction; PositionOnPlayer.Y += -Base.SpriteHeight + Base.SittingPoint.Y; int XMod = Base.SittingPoint.X; if (npc.direction < 0) { XMod = Base.SpriteWidth - XMod; } PositionOnPlayer.X += XMod - Base.SpriteWidth * 0.5f; npc.position = PositionOnPlayer; } TerraGuardian guardian = PlayerMod.GetPlayerMainGuardian(player), Sardine = PlayerMod.GetPlayerSummonedGuardian(player, GuardianBase.Sardine), Glenn = PlayerMod.GetPlayerSummonedGuardian(player, GuardianBase.Glenn); if (HadGlennSpotted && HadSardineSpotted) { if (Sardine != null && Glenn != null) { bool GlennIsClosest = (Glenn.CenterPosition - player.Center).Length() < (Sardine.CenterPosition - player.Center).Length(); if (GlennIsClosest) { guardian = Glenn; bool IsGlennToTheLeft = guardian.Position.X - npc.Center.X < 0; if (Math.Abs(guardian.Position.X - npc.Center.X) >= 96) { if (!IsGlennToTheLeft) { MoveRight = true; } else { MoveLeft = true; } } if (!guardian.IsAttackingSomething && guardian.Velocity.X == 0) { guardian.FaceDirection(!IsGlennToTheLeft); } if (npc.velocity.X == 0) { npc.direction = !IsGlennToTheLeft ? 1 : -1; } } else { guardian = Sardine; bool IsSardineToTheLeft = guardian.Position.X - npc.Center.X < 0; if (Math.Abs(guardian.Position.X - npc.Center.X) >= 96) { if (!IsSardineToTheLeft) { MoveRight = true; } else { MoveLeft = true; } } if (!guardian.IsAttackingSomething && guardian.Velocity.X == 0) { guardian.FaceDirection(!IsSardineToTheLeft); } if (npc.velocity.X == 0) { npc.direction = !IsSardineToTheLeft ? 1 : -1; } } if (SceneStep >= SceneIds.BreePersuadesThePlayerToCallHimBack && SceneStep <= SceneIds.BreePersuadesThePlayerALittleCloser) { if (InterruptedOnce) { ChangeScene(SceneIds.SardineIsCalledBackByPlayerAfterInterruption); } else { ChangeScene(SceneIds.PlayerCalledSardineBackAfterBreeAsked); } } } else { bool IsPlayerToTheLeft = player.Center.X - npc.Center.X < 0; if (Math.Abs(player.Center.X - npc.Center.X) >= 96) { if (!IsPlayerToTheLeft) { MoveRight = true; } else { MoveLeft = true; } } if (npc.velocity.X == 0) { npc.direction = !IsPlayerToTheLeft ? 1 : -1; } if (SceneStep >= SceneIds.BothAnswers && SceneStep < SceneIds.BreeThenSaysThatTheyShouldStayInTheWorldForAWhileThen) { InterruptedOnce = true; if (Sardine == null) { ChangeScene(SceneIds.PlayerUnsummonedSardine); } else { ChangeScene(SceneIds.PlayerUnsummonedGlenn); } } } } else if (HadGlennSpotted) { if (Glenn != null) { guardian = Glenn; bool IsGlennToTheLeft = guardian.Position.X - npc.Center.X < 0; if (Math.Abs(guardian.Position.X - npc.Center.X) >= 96) { if (!IsGlennToTheLeft) { MoveRight = true; } else { MoveLeft = true; } } if (!guardian.IsAttackingSomething && guardian.Velocity.X == 0) { guardian.FaceDirection(!IsGlennToTheLeft); } if (npc.velocity.X == 0) { npc.direction = !IsGlennToTheLeft ? 1 : -1; } if (SceneStep >= SceneIds.BreePersuadesThePlayerToCallHimBack && SceneStep <= SceneIds.BreePersuadesThePlayerALittleCloser) { if (InterruptedOnce) { ChangeScene(SceneIds.SardineIsCalledBackByPlayerAfterInterruption); } else { ChangeScene(SceneIds.PlayerCalledSardineBackAfterBreeAsked); } } } else { bool IsPlayerToTheLeft = player.Center.X - npc.Center.X < 0; if (Math.Abs(player.Center.X - npc.Center.X) >= 96) { if (!IsPlayerToTheLeft) { MoveRight = true; } else { MoveLeft = true; } } if (npc.velocity.X == 0) { npc.direction = !IsPlayerToTheLeft ? 1 : -1; } if (SceneStep >= SceneIds.GlennAnswer && SceneStep < SceneIds.BreeJoinsToTakeCareOfGlenn) { InterruptedOnce = true; ChangeScene(SceneIds.PlayerUnsummonedGlenn); } } } else if (HadSardineSpotted) { if (Sardine != null) { guardian = Sardine; bool IsSardineToTheLeft = guardian.Position.X - npc.Center.X < 0; if (Math.Abs(guardian.Position.X - npc.Center.X) >= 96) { if (!IsSardineToTheLeft) { MoveRight = true; } else { MoveLeft = true; } } if (!guardian.IsAttackingSomething) { guardian.FaceDirection(!IsSardineToTheLeft); } if (npc.velocity.X == 0) { npc.direction = !IsSardineToTheLeft ? 1 : -1; } if (SceneStep >= SceneIds.BreePersuadesThePlayerToCallHimBack && SceneStep <= SceneIds.BreePersuadesThePlayerALittleCloser) { if (InterruptedOnce) { ChangeScene(SceneIds.SardineIsCalledBackByPlayerAfterInterruption); } else { ChangeScene(SceneIds.PlayerCalledSardineBackAfterBreeAsked); } } } else { bool IsPlayerToTheLeft = player.Center.X - npc.Center.X < 0; if (Math.Abs(player.Center.X - npc.Center.X) >= 96) { if (!IsPlayerToTheLeft) { MoveRight = true; } else { MoveLeft = true; } } if (npc.velocity.X == 0) { npc.direction = !IsPlayerToTheLeft ? 1 : -1; } if (SceneStep >= SceneIds.SardineStaysAndTalksToBree && SceneStep < SceneIds.BreeTurnsToTownNpc) { InterruptedOnce = true; ChangeScene(SceneIds.PlayerUnsummonedSardine); } if (SceneStep == SceneIds.SardineSpotted) { ChangeScene(SceneIds.SardineFlees); } } } if (SceneChange) { switch (SceneStep) { case SceneIds.SardineSpotted: if (guardian.FriendshipLevel < 5 && (!PlayerMod.HasBuddiesModeOn(player) || !PlayerMod.GetPlayerBuddy(player).IsSameID(guardian))) //Tries to flee { ChangeScene(SceneIds.SardineFlees); guardian.SaySomething("Uh oh, I gotta go."); } else //Stays { ChangeScene(SceneIds.SardineStaysAndTalksToBree); guardian.SaySomething("Uh oh."); } break; case SceneIds.SardineFlees: if (PlayerMod.GetPlayerMainGuardian(player).Active) { TerraGuardian SardineRef = null; foreach (TerraGuardian tg in player.GetModPlayer <PlayerMod>().GetAllGuardianFollowers) { if (tg.ID == 2 && tg.ModID == MainMod.mod.Name) { SardineRef = tg; break; } } player.GetModPlayer <PlayerMod>().DismissGuardian(2, ""); if (SardineRef != null && SardineRef.Active) { SardineRef.Spawn(); } } SayMessage("What? Where did he go?"); ChangeScene(SceneIds.BreeAsksWhereSardineWent); break; case SceneIds.BreeAsksWhereSardineWent: SayMessage("You can call him back, right? Do so."); ChangeScene(SceneIds.BreePersuadesThePlayerToCallHimBack); break; case SceneIds.BreePersuadesThePlayerToCallHimBack: SayMessage("Call him back. NOW!"); ChangeScene(SceneIds.BreePersuadesThePlayerToCallHimBackAgain); break; case SceneIds.BreePersuadesThePlayerToCallHimBackAgain: ChangeScene(SceneIds.BreePersuadesThePlayerALittleCloser); SayMessage("I said... NOW!!!!"); break; case SceneIds.BreePersuadesThePlayerALittleCloser: { string Message = ""; switch (SceneRepeatTimes) { case 0: Message = "Call him! JUST. CALL. HIM!"; break; case 1: Message = "You are making me angry.... EVEN MORE ANGRY!!!"; break; case 2: Message = "GRRRRRRR!!! RRRRRRRRRRRRRRRR!!! RRRRRRRRRRRRRRGHHHH!!"; break; case 3: Message = "MY PATIENCE IS ALREADY GOING DOWN THE DRAIN! CALL HIM BACK, NOW!!"; break; case 4: Message = "ENOUGH!! CALL HIM, NOW!"; ChangeScene(SceneIds.BreeForcedPlayerToCallSardineBack); break; } if (SceneStep == SceneIds.BreePersuadesThePlayerALittleCloser && SceneRepeatTimes < 4) { ChangeScene(SceneIds.BreePersuadesThePlayerALittleCloser); } SayMessage(Message); } break; case SceneIds.BreeForcedPlayerToCallSardineBack: { if (HadSardineSpotted) { player.GetModPlayer <PlayerMod>().CallGuardian(2, ""); } if (HadGlennSpotted) { player.GetModPlayer <PlayerMod>().CallGuardian(GuardianBase.Glenn, ""); } SayMessage("Good."); if (HadSardineSpotted && HadGlennSpotted) { ChangeScene(SceneIds.BreeAsksWhereWasSardine); } else if (HadGlennSpotted) { ChangeScene(SceneIds.GlennSpotted); } else { ChangeScene(SceneIds.SardineStaysAndTalksToBree); } } break; case SceneIds.SardineStaysAndTalksToBree: { guardian.SaySomething("H-Hello dear, how have you been latelly?"); ChangeScene(SceneIds.BreeScoldsSardine); } break; case SceneIds.BreeScoldsSardine: { SayMessage("Seriously?! That is all you have to say?"); ChangeScene(SceneIds.BreeContinues); } break; case SceneIds.BreeContinues: { SayMessage("You abandon me and your son at home and that is what you have to say?"); ChangeScene(SceneIds.SardineTriesToApologise); } break; case SceneIds.SardineTriesToApologise: { guardian.SaySomething("I'm sorry?"); ChangeScene(SceneIds.BreeDoesntAcceptTheApology); } break; case SceneIds.BreeDoesntAcceptTheApology: { SayMessage("That is it? You numbskull, you've been missing for " + (guardian.Data.GetBirthdayAge - guardian.Base.Age + 2) + " WHOLE YEARS!!"); ChangeScene(SceneIds.BreeContinuesAfterNotAcceptingTheApology); } break; case SceneIds.BreeContinuesAfterNotAcceptingTheApology: { SayMessage("Do you know how many worlds I travelled trying to find you! Even the planet of the tentacles I had to travel through!"); ChangeScene(SceneIds.SardineTriesToApologiseAgain); } break; case SceneIds.SardineTriesToApologiseAgain: { guardian.SaySomething("I already said that I'm sorry. I... Kind of forgot what world we lived so... I couldn't return."); guardian.DisplayEmotion(TerraGuardian.Emotions.Sweat); ChangeScene(SceneIds.BreeTalksAboutTakingSardineBackWithHer); } break; case SceneIds.BreeTalksAboutTakingSardineBackWithHer: { SayMessage("Then there is no problem, since YOU are going back home with ME!"); ChangeScene(SceneIds.SardineTriesTheButs); } break; case SceneIds.SardineTriesTheButs: { guardian.SaySomething("But... But... I have a job here and..."); ChangeScene(SceneIds.BreeSaysNoToButs); } break; case SceneIds.BreeSaysNoToButs: { SayMessage("No buts! We are going back now! I just need to remember which world we-"); ChangeScene(SceneIds.BreeTakesAPauseToRealizeSheForgotToo); } break; case SceneIds.BreeTakesAPauseToRealizeSheForgotToo: { SayMessage("..."); ChangeScene(SceneIds.BreeForgotTheWorldTheyLived); } break; case SceneIds.BreeForgotTheWorldTheyLived: { SayMessage("This can't be happening... I forgot which world we lived on!"); ChangeScene(SceneIds.SardineLaughsOfBree); } break; case SceneIds.SardineLaughsOfBree: { guardian.SaySomething("Haha! Joke is on you now. Looks like you'll have to say here for a while, until you remember."); guardian.DisplayEmotion(TerraGuardian.Emotions.Happy); ChangeScene(SceneIds.BreeAgrees); } break; case SceneIds.BreeAgrees: { SayMessage("Grrr... Alright! I'll stay for a while, but only until I remember the world we lived!"); ChangeScene(SceneIds.BreeIntroducesHerself); } break; case SceneIds.BreeIntroducesHerself: { SayMessage("My name is " + Base.Name + ", don't expect me to stay for long."); ChangeScene(SceneIds.BreeTurnsToTownNpc); } break; case SceneIds.BreeTurnsToTownNpc: { TransformNPC(); } break; case SceneIds.SardineIsCalledBackByPlayer: { SayMessage("There he is."); ChangeScene(SceneIds.SardineStaysAndTalksToBree); } break; case SceneIds.SardineIsCalledBackByPlayerAfterInterruption: { SayMessage("Don't do that again!"); ChangeScene(SceneIds.BreeTalksAboutSardineGoingBackWithHer); } break; case SceneIds.BreeTalksAboutSardineGoingBackWithHer: { SayMessage("We are returning to home right now!"); ChangeScene(SceneIds.SardineTriesTheButs); } break; case SceneIds.PlayerUnsummonedSardine: { SayMessage("Hey! We were talking!"); InterruptedOnce = true; ChangeScene(SceneIds.BreePersuadesThePlayerToCallHimBack); } break; case SceneIds.PlayerCalledSardineBackAfterBreeAsked: { SayMessage("Thank you. Now where was I?"); ChangeScene(SceneIds.SardineStaysAndTalksToBree); } break; case SceneIds.BreeSeesFriendlyFace: { SayMessage("Oh, It's you again."); ChangeScene(SceneIds.BreeSaysHowSheAppearedThere); } break; case SceneIds.BreeSaysHowSheAppearedThere: { SayMessage("I'm still looking for the world I lived, but It's funny to bump into you on the way."); ChangeScene(SceneIds.BreeJoinsYou); } break; case SceneIds.BreeJoinsYou: { SayMessage("Anyway, I'm here, If you need me."); ChangeScene(SceneIds.BreeTurnsToTownNpc); } break; case SceneIds.GlennSpotted: { SayMessage("Glenn! What are you doing here? You should be at home."); ChangeScene(SceneIds.GlennAnswer); } break; case SceneIds.GlennAnswer: { guardian.SaySomething("You and Dad were taking too long to come home, so I came looking for you two."); ChangeScene(SceneIds.AsksGlennIfHesOkay); } break; case SceneIds.AsksGlennIfHesOkay: { SayMessage("But It's dangerous out there! Are you hurt?"); ChangeScene(SceneIds.GlennSaysThatIsFine); } break; case SceneIds.GlennSaysThatIsFine: { guardian.SaySomething("I'm okay, don't worry. This Terrarian let me stay here, and It's safe here."); ChangeScene(SceneIds.BreeJoinsToTakeCareOfGlenn); } break; case SceneIds.BreeJoinsToTakeCareOfGlenn: { SayMessage("I can't let you stay here alone, I shouldn't have let you stay alone at home either. I'll stay here to take care of you, and look for your father."); ChangeScene(SceneIds.BreeIntroducesHerself); } break; case SceneIds.BreeSpotsSardineAndGlenn: { SayMessage("Are you two alright?"); ChangeScene(SceneIds.BothAnswers); } break; case SceneIds.BothAnswers: { Sardine.SaySomething("Yes, we're fine."); Glenn.SaySomething("I'm okay."); ChangeScene(SceneIds.BreeAsksWhereWasSardine); } break; case SceneIds.BreeAsksWhereWasSardine: { SayMessage("I'm so glad you two are fine. Sardine, where did you go? Why didn't you returned home?"); ChangeScene(SceneIds.SardineAnswers); } break; case SceneIds.SardineAnswers: { Sardine.SaySomething("I was trying to find treasures for you two... And then I was saved by that Terrarian from a bounty hunt that gone wrong."); ChangeScene(SceneIds.BreeThenFeelsRelievedAndAsksGlennWhatIsHeDoingHere); } break; case SceneIds.BreeThenFeelsRelievedAndAsksGlennWhatIsHeDoingHere: { SayMessage("I think I should think you then, Terrarian. Now Glenn, I told you to wait for us at home!"); ChangeScene(SceneIds.GlennAnswers); } break; case SceneIds.GlennAnswers: { Glenn.SaySomething("I stayed at home, but I was worried that you two didn't returned yet, so I explored worlds trying to find you two."); ChangeScene(SceneIds.BreeSuggestsToSpendSomeTimeTogetherBeforeReturningToTheWorld); } break; case SceneIds.BreeSuggestsToSpendSomeTimeTogetherBeforeReturningToTheWorld: { SayMessage("That's really reckless and dangerous, but I'm glad you two are unharmed. Let's spend a little time here and then return home."); ChangeScene(SceneIds.SardineSaysThatForgotWhereTheWorldIsAt); } break; case SceneIds.SardineSaysThatForgotWhereTheWorldIsAt: { Sardine.SaySomething("I hope you know our way home, because I forgot."); ChangeScene(SceneIds.GlennAlsoSaysThatForgot); } break; case SceneIds.GlennAlsoSaysThatForgot: { Glenn.SaySomething("I also forgot my way back home, sorry mom."); ChangeScene(SceneIds.BreeThenSaysThatTheyShouldStayInTheWorldForAWhileThen); } break; case SceneIds.BreeThenSaysThatTheyShouldStayInTheWorldForAWhileThen: { SayMessage("I can't remember either.... Well, I hope you don't mind if we stay here for longer, Terrarian."); ChangeScene(SceneIds.BreeIntroducesHerself); } break; case SceneIds.PlayerUnsummonedGlenn: { SayMessage("Where did you sent my son? Call him back now!"); InterruptedOnce = true; ChangeScene(SceneIds.BreePersuadesThePlayerToCallHimBack); } break; } } if (StepTime <= -600) { SayMessage("Uh... What was I saying? Oh... I remember now."); ChangeScene(SceneStep); } } else { Idle = true; } base.AI(); if (!Main.dayTime) { bool PlayerInRange = false; for (int p = 0; p < 255; p++) { Player pl = Main.player[p]; if ((Math.Abs(pl.Center.X - npc.Center.X) >= NPC.sWidth * 0.5f + NPC.safeRangeX || Math.Abs(pl.Center.Y - npc.Center.Y) >= NPC.sHeight * 0.5f + NPC.safeRangeY)) { PlayerInRange = true; } } if (!PlayerInRange) { //Main.NewText("The White Cat resumed the search for her husband.", Color.OrangeRed); npc.active = false; npc.life = 0; } } }
public override void Update(TerraGuardian guardian) { if (guardian.OwnerPos == -1) { InUse = false; return; } if (!PlayerWasKnockedOut && guardian.AfkCounter < 60) { InUse = false; return; } if (guardian.UsingFurniture) { guardian.LeaveFurniture(false); } Player defended = Main.player[guardian.OwnerPos]; PlayerMod defendedPm = defended.GetModPlayer <PlayerMod>(); /*if (guardian.GrabbingPlayer) * { * guardian.PlayerCanEscapeGrab = true; * DelayBeforePlacingOnTheGround--; * if (guardian.Velocity.X != 0 || guardian.Velocity.Y != 0) * DelayBeforePlacingOnTheGround = 5 * 60; * return; * } * { * int XStart = (int)(defended.position.X * (1f / 16)), XEnd = (int)((defended.position.X + defended.width) * (1f / 16)); * int YCheck = (int)(defended.position.Y * (1f / 16)); * bool TryPickingUpPlayer = false; * for (int x = XStart; x < XEnd; x++) * { * if(MainMod.IsDangerousTile(x, YCheck, defended.fireWalk)) * { * TryPickingUpPlayer = true; * break; * } * } * if (TryPickingUpPlayer) * { * DelayBeforePlacingOnTheGround = 5 * 60; * if(TryReachingPlayer(guardian, defended)) * { * guardian.AttemptToGrabPlayer(); * } * return; * } * }*/ const int Offset = 7 * 2; float DefendX = defended.Center.X - Offset * defended.direction; if (defendedPm.KnockedOut && (defendedPm.BeingCarriedByGuardian || (defendedPm.ControllingGuardian && defendedPm.Guardian.BeingCarriedByGuardian))) { Action = 2; } if (Action == 2) { if (guardian.Position.X + guardian.Velocity.X * 0.5f > DefendX) { guardian.MoveLeft = true; } else { guardian.MoveRight = true; } PlayerMod pm = defendedPm; if (pm.ControllingGuardian) { pm.Guardian.AddBuff(ModContent.BuffType <Buffs.Defended>(), 3, true); if (pm.Guardian.KnockedOut) { pm.Guardian.ReviveBoost++; } else { if (guardian.AfkCounter < ProtectModeAutoTriggerTime && PlayerWasKnockedOut) { InUse = false; } } if (!pm.Guardian.BeingCarriedByGuardian) { Action = 0; } } else { defended.AddBuff(ModContent.BuffType <Buffs.Defended>(), 3); if (pm.KnockedOut) { pm.ReviveBoost++; } else { if (guardian.AfkCounter < ProtectModeAutoTriggerTime && PlayerWasKnockedOut) { InUse = false; } } if (pm.BeingCarriedByGuardian) { Action = 0; } } } else if (Action == 0) { if (guardian.PlayerMounted || guardian.SittingOnPlayerMount) { Action = 1; } else { guardian.MoveLeft = guardian.MoveRight = false; if (guardian.Position.X + guardian.Velocity.X * 0.5f > DefendX) { guardian.MoveLeft = true; } else { guardian.MoveRight = true; } if (Math.Abs(guardian.Position.X - DefendX) < 5 && Math.Abs(guardian.Velocity.X) < 3f) { Action = 1; if (defendedPm.ControllingGuardian) { if (defendedPm.Guardian.ModID == MainMod.mod.Name) { switch (defendedPm.Guardian.ID) { case GuardianBase.Domino: { switch (Main.rand.Next(5)) { case 0: guardian.SaySomething("*I'm only protecting him because of you, [nickname].*"); break; case 1: guardian.SaySomething("*Of anyone you could take direct control, It had to be him?*"); break; case 2: guardian.SaySomething("*Is this some kind of karma?*"); break; case 3: guardian.SaySomething("*Okay, what have I done to you, [nickname]?*"); break; case 4: guardian.SaySomething("*It's funny how I'm treating his wounds, instead of beating his face.*"); break; } } break; } } } } } } else if (Action == 1) { if (!guardian.PlayerMounted && !guardian.SittingOnPlayerMount) { guardian.Position.X = DefendX; if (!guardian.IsAttackingSomething) { guardian.LookingLeft = defended.direction == -1; } } guardian.Jump = false; if (!guardian.SittingOnPlayerMount) { guardian.MoveDown = true; } guardian.OffHandAction = true; PlayerMod pm = defendedPm; if (pm.ControllingGuardian) { pm.Guardian.AddBuff(ModContent.BuffType <Buffs.Defended>(), 3, true); if (pm.Guardian.KnockedOut) { pm.Guardian.ReviveBoost++; } else { if (guardian.AfkCounter < ProtectModeAutoTriggerTime && PlayerWasKnockedOut) { InUse = false; } } } else { defended.AddBuff(ModContent.BuffType <Buffs.Defended>(), 3); if (pm.KnockedOut) { pm.ReviveBoost++; } else { if (guardian.AfkCounter < ProtectModeAutoTriggerTime && PlayerWasKnockedOut) { InUse = false; } } } } }
public override void Update(TerraGuardian guardian) { if (Main.dayTime || Main.time >= 28800) { InUse = false; return; } if (guardian.OwnerPos > -1 && guardian.AfkCounter < 60) { InUse = false; return; } if (guardian.IsAttackingSomething) { return; } switch (Behavior) { case 0: //Wander { if (Time <= 0) { Tile tile = MainMod.GetTile((int)(guardian.Position.X * (1f / 16)), (int)(guardian.CenterY * (1f / 16))); if (tile.wall > 0) { Time = 400; } else if (guardian.HasDoorOpened) { Time = 50; } else { Behavior = 1; Time = 2000; break; } } if (guardian.OwnerPos == -1) { guardian.WalkMode = true; if (guardian.LookingLeft) { guardian.MoveLeft = true; } else { guardian.MoveRight = true; } } Time--; } break; case 1: //Howl { if (Time <= 0) { guardian.LookingLeft = Main.rand.NextDouble() < 0.5; Behavior = 0; Time = 400; break; } if (Time == 890 || Time == 1300 || Time == 1900) { guardian.SaySomething("Awooooooo!!!"); } Time--; } break; } }
public override void Update(TerraGuardian guardian) { if (guardian.TargetID > -1 || guardian.TalkPlayerID > -1 || guardian.IsBeingPulledByPlayer) { InUse = false; return; } bool MakeNpcFocusOnGuardian = false; if (!guardian.PlayerMounted) { guardian.MoveLeft = guardian.MoveRight = false; } if (guardian.IsBeingPulledByPlayer) { InUse = false; return; } switch (Step) { case 0: //Try reaching npc { NPC npc = Main.npc[NpcPosition]; if (!npc.active) { InUse = false; return; } Vector2 NpcBottom = npc.Bottom; if (guardian.PlayerMounted) { if (StepStart) { string Message = guardian.GetMessage(GuardianBase.MessageIDs.AskPlayerToGetCloserToShopNpc, "*This companion wants to buy from [shop]'s store.\nGet closer to It so they can buy from It.*"); Message.Replace("[shop]", npc.GivenOrTypeName); guardian.SaySomething(Message); } if (Math.Abs(guardian.Position.X - NpcBottom.X) >= 500) { guardian.DisplayEmotion(TerraGuardian.Emotions.Neutral); InUse = false; return; } } if (!guardian.PlayerMounted && Time == 5 * 60) { guardian.Position = NpcBottom; guardian.SetFallStart(); } else if (!guardian.PlayerMounted && Math.Abs(NpcBottom.X - guardian.Position.X) < 16) { if (guardian.Position.X >= NpcBottom.X) { guardian.MoveRight = true; } else { guardian.MoveLeft = true; } } else if (Math.Abs(NpcBottom.X - guardian.Position.X) >= 16f + guardian.Width * 0.5f) { if (!guardian.PlayerMounted) { if (guardian.Position.X < NpcBottom.X) { guardian.MoveRight = true; } else { guardian.MoveLeft = true; } } } else { MakeNpcFocusOnGuardian = true; ChangeStep(); if (guardian.PlayerMounted) { string Message = guardian.GetMessage(GuardianBase.MessageIDs.AskPlayerToWaitAMomentWhileCompanionIsShopping, "*They ask you to wait a moment.*"); Message = Message.Replace("[shop]", npc.GivenOrTypeName); guardian.SaySomething(Message); } } if (!guardian.PlayerMounted && Math.Abs(NpcBottom.Y - guardian.Position.Y) > 8) { if (guardian.Position.Y < NpcBottom.Y) { if (guardian.Velocity.Y == 0) { bool SolidBlockBellow = false; int CheckY = (int)(guardian.Position.Y + 2) / 16; for (int i = 0; i < guardian.Width / 16; i++) { int CheckX = (int)(guardian.TopLeftPosition.X / 16) + i; if (Main.tile[CheckX, CheckY].active() && Main.tileSolid[Main.tile[CheckX, CheckY].type] && !Terraria.ID.TileID.Sets.Platforms[Main.tile[CheckX, CheckY].type]) { SolidBlockBellow = true; break; } } if (!SolidBlockBellow) { guardian.MoveDown = true; guardian.Jump = true; } } } else { int CheckX = (int)(guardian.Position.X / 16); if (guardian.JumpHeight == 0 && !guardian.Jump || guardian.JumpHeight > 0) { for (int i = 1; i < 6; i++) { int CheckY = (int)(guardian.Position.Y / 16) - i; if (Main.tile[CheckX, CheckY].active() && Terraria.ID.TileID.Sets.Platforms[Main.tile[CheckX, CheckY].type]) { guardian.Jump = true; break; } } } } } } break; case 1: { NPC npc = Main.npc[NpcPosition]; MakeNpcFocusOnGuardian = true; Vector2 NpcCenter = npc.Center; if (Math.Abs(guardian.Position.X - NpcCenter.X) < 16) { if (guardian.Position.X < NpcCenter.X) { guardian.MoveLeft = true; } else { guardian.MoveRight = true; } } else if (guardian.Velocity.X == 0) { guardian.LookingLeft = guardian.Position.X >= NpcCenter.X; } if (Time == 60) { guardian.BuyItem(ItemID, BuyPrice, BuyStack, true); } if (Time >= (int)(1.5f * 60)) { InUse = false; if (guardian.PlayerMounted) { guardian.SaySomething(guardian.GetMessage(GuardianBase.MessageIDs.GenericThankYou, "*They thanked you.*")); } return; } } break; default: InUse = false; return; } if (MakeNpcFocusOnGuardian) { NPC npc = Main.npc[NpcPosition]; if (npc.ai[0] != 0) { npc.netUpdate = true; } npc.ai[0] = 0; npc.ai[1] = 300; npc.localAI[3] = 100; if (npc.Center.X < guardian.Position.X) { npc.direction = 1; } else { npc.direction = -1; } } }
public override void Update(TerraGuardian guardian) { if (guardian.furniturex > -1) { guardian.LeaveFurniture(false); } if (guardian.KnockedOut || guardian.IsBeingPulledByPlayer) { InUse = false; return; } if ((guardian.OwnerPos > -1 && guardian.PlayerMounted && !Main.player[guardian.OwnerPos].GetModPlayer <PlayerMod>().KnockedOut) || guardian.Is2PControlled) { if (!guardian.MoveDown) { InUse = false; return; } } if (guardian.ItemAnimationTime > 0) { return; } Vector2 TargetPosition = Vector2.Zero; int TargetWidth = 0, TargetHeight = 0; bool TryReaching = false; bool IsMountedPlayer = false; bool AffectedByNegativeHealing = false; if (TargetIsPlayer) { PlayerMod pm = RevivePlayer.GetModPlayer <PlayerMod>(); AffectedByNegativeHealing = pm.NegativeReviveBoost; TargetPosition = RevivePlayer.position; TargetWidth = RevivePlayer.width; TargetHeight = RevivePlayer.height; if (RevivePlayer.dead || !RevivePlayer.active || !pm.KnockedOut) { InUse = false; return; } if (guardian.PlayerMounted && RevivePlayer.whoAmI == guardian.OwnerPos) { IsMountedPlayer = true; } } else { TargetPosition = ReviveGuardian.TopLeftPosition; TargetWidth = ReviveGuardian.Width; TargetHeight = ReviveGuardian.Height; if (!ReviveGuardian.Active || ReviveGuardian.Downed || !ReviveGuardian.KnockedOut) { InUse = false; return; } if (ReviveGuardian.OwnerPos == guardian.OwnerPos && ReviveGuardian.PlayerControl && guardian.PlayerMounted) { IsMountedPlayer = true; } } bool RepelingEnemies = false; guardian.MoveLeft = guardian.MoveRight = false; if (guardian.TargetID > -1 && !AffectedByNegativeHealing) { Vector2 EnemyPosition; int EnemyWidth, EnemyHeight; guardian.GetTargetInformation(out EnemyPosition, out EnemyWidth, out EnemyHeight); EnemyPosition.X += EnemyWidth * 0.5f; EnemyPosition.Y += EnemyHeight * 0.5f; if (IsMountedPlayer || (Math.Abs(EnemyPosition.X - guardian.Position.X) < 168f + (EnemyWidth + guardian.Width) * 0.5f && Math.Abs(EnemyPosition.Y - guardian.CenterY) < 168f + (EnemyHeight + guardian.Height) * 0.5f)) { RepelingEnemies = true; IgnoreCombat = false; guardian.AttackingTarget = true; } else { IgnoreCombat = true; } } else { IgnoreCombat = false; } if (!RepelingEnemies) { bool OffSetToTheLeft = TargetPosition.X + TargetWidth * 0.5f < guardian.Position.X; { int Animation = guardian.Base.StandingFrame; int ArmAnimation = -1; if (IsMountedPlayer) { ArmAnimation = guardian.Base.ItemUseFrames[2]; } else { if (guardian.Base.ReviveFrame > -1) { Animation = guardian.Base.ReviveFrame; } else if (guardian.Base.DuckingFrame > -1) { Animation = guardian.Base.DuckingFrame; ArmAnimation = guardian.Base.DuckingSwingFrames[2]; } } if (ArmAnimation == -1) { ArmAnimation = Animation; } guardian.Base.GetBetweenHandsPosition(ArmAnimation, out int x, out int y); float ArmXDistance = (x - guardian.SpriteWidth * 0.5f) * guardian.Scale; if (ArmXDistance > 0) { TargetWidth += (int)ArmXDistance; if (OffSetToTheLeft) { TargetPosition.X -= ArmXDistance; } } } if (IsMountedPlayer || new Rectangle((int)TargetPosition.X, (int)TargetPosition.Y, TargetWidth, TargetHeight).Intersects(guardian.HitBox))//(MainMod.RectangleIntersects(guardian.TopLeftPosition, guardian.Width, guardian.Height, TargetPosition, TargetWidth, TargetHeight)) { guardian.Jump = false; float DistanceFromTarget = Math.Abs(guardian.Position.X - (TargetPosition.X + TargetWidth * 0.5f)); if (DistanceFromTarget < 8) { if (Math.Abs(guardian.Velocity.X) < 2f) { if (guardian.Position.X < TargetPosition.X + TargetWidth * 0.5f) { guardian.MoveLeft = true; } else { guardian.MoveRight = true; } } } else if (guardian.Velocity.X != 0) { if (Math.Abs(guardian.Position.X + guardian.Velocity.X - (TargetPosition.X + TargetWidth * 0.5f)) < 12) { guardian.MoveLeft = guardian.MoveRight = false; guardian.Velocity.X *= 0.8f; } } else if (guardian.Velocity.X == 0) { { Vector2 FacingLeftPosition = guardian.GetLeftHandPosition(guardian.Base.ReviveFrame, true), FacingRightPosition = FacingLeftPosition; FacingLeftPosition.X *= -1; FacingLeftPosition.X += guardian.Position.X - (TargetPosition.X + TargetWidth * 0.5f); FacingRightPosition.X += guardian.Position.X - (TargetPosition.X + TargetWidth * 0.5f); guardian.FaceDirection(Math.Abs(FacingLeftPosition.X) < Math.Abs(FacingRightPosition.X)); } byte ReviveBoost = 1; if (!guardian.IsAttackingSomething) { ReviveBoost += 2; } bool IsMounted = guardian.PlayerMounted; if (TargetIsPlayer) { RevivePlayer.GetModPlayer <PlayerMod>().ReviveBoost += ReviveBoost; } else { ReviveGuardian.ReviveBoost += ReviveBoost; } guardian.StuckTimer = 0; guardian.OffHandAction = false; if (SpeakToFallen) { SpeakToFallen = false; if (MainMod.CompanionsSpeaksWhileReviving) { guardian.SaySomething(guardian.Base.ReviveMessage(guardian, TargetIsPlayer, (TargetIsPlayer ? RevivePlayer : null), (!TargetIsPlayer ? ReviveGuardian : null))); } } } } else { TryReaching = true; } } if (TryReaching) { if (ResTime >= 5 * 60) { guardian.Position.X = TargetPosition.X + Main.rand.Next(TargetWidth); guardian.Position.Y = TargetPosition.Y + TargetHeight - 1; guardian.FallStart = (int)guardian.Position.Y / 16; } else if (TargetPosition.X + TargetWidth * 0.5f - guardian.Position.X < 0) { guardian.MoveLeft = true; } else { guardian.MoveRight = true; } guardian.WalkMode = false; ResTime++; } else { ResTime = 0; } }
public override void Update(TerraGuardian guardian) { ProceedIdleAIDuringDialogue = true; NpcCanFacePlayer = false; guardian.AddDrawMomentToPlayer(Target); const int BuffRefreshTime = 10 * 60; if (Time >= BuffRefreshTime && Time % BuffRefreshTime == 0) { int Stack = Time / BuffRefreshTime; if (Stack > 3) { Stack = 3; } Target.AddBuff(ModContent.BuffType <Buffs.WellBeing>(), 3600 * 30 * Stack); PlayerMod pm = Target.GetModPlayer <PlayerMod>(); if (pm.ControllingGuardian) { pm.Guardian.AddBuff(ModContent.BuffType <Buffs.WellBeing>(), 3600 * 30 * Stack); } } VladimirBase.VladimirData data = (VladimirBase.VladimirData)guardian.Data; bool End = Target.controlJump; //if (PlayerMod.PlayerHasGuardianSummoned(player, guardian.ID, guardian.ModID)) // End = true; if (Main.bloodMoon) { End = false; } if (End) { InUse = false; Target.Bottom = guardian.Position; if (guardian.BodyAnimationFrame == guardian.Base.ChairSittingFrame) { Target.position.Y -= guardian.SpriteHeight - guardian.Base.SittingPoint.Y * guardian.Scale; } PlayerMod pm = Target.GetModPlayer <PlayerMod>(); if (pm.ControllingGuardian) { pm.Guardian.Position = guardian.Position; } guardian.SaySomething(((Companions.VladimirBase)guardian.Base).GetEndHugMessage(guardian)); } else { if (Target.mount.Active) { Target.mount.Dismount(Target); } PlayerMod pm = Target.GetModPlayer <PlayerMod>(); bool FaceBear = (guardian.BodyAnimationFrame != 20 && guardian.BodyAnimationFrame != 21) || guardian.BodyAnimationFrame == 25; if (pm.ControllingGuardian) { pm.Guardian.Position = guardian.GetGuardianShoulderPosition; pm.Guardian.Position.Y += guardian.Height * 0.5f; pm.Guardian.Velocity.Y = -pm.Guardian.Mass; if (data.CarrySomeone) { pm.Guardian.Position.X -= 6 * guardian.Direction; } pm.Guardian.FallStart = (int)pm.Guardian.Position.Y / 16; if (pm.Guardian.ItemAnimationTime == 0 && !pm.Guardian.MoveLeft && !pm.Guardian.MoveRight) { pm.Guardian.FaceDirection((guardian.Direction * (FaceBear ? -1 : 1)) == -1); } pm.Guardian.AddBuff(ModContent.BuffType <Buffs.Hug>(), 5, true); if (pm.Guardian.KnockedOut) { pm.Guardian.ReviveBoost += 3; } if (!Main.bloodMoon) { pm.Guardian.ImmuneTime = 3; pm.Guardian.ImmuneNoBlink = true; } } else { Target.gfxOffY = 0; Target.Center = guardian.GetGuardianShoulderPosition; Target.velocity.Y = -Player.defaultGravity; Target.fallStart = (int)Target.Center.Y / 16; if (data.CarrySomeone) { Target.position.X -= 6 * guardian.Direction; } if (Target.itemAnimation == 0 && !Target.controlLeft && !Target.controlRight) { Target.ChangeDir(guardian.Direction * (FaceBear ? -1 : 1)); } Target.AddBuff(ModContent.BuffType <Buffs.Hug>(), 5); if (pm.KnockedOut) { pm.ReviveBoost += 3; } if (!Main.bloodMoon) { Target.immuneTime = 3; Target.immuneNoBlink = true; } } if ((guardian.MessageTime == 0 || Main.bloodMoon) && (Target.controlLeft || Target.controlRight || Target.controlUp || Target.controlDown || (Main.bloodMoon && Target.controlJump))) { if (Main.bloodMoon) { Target.controlJump = false; bool Defeated = false, Hurt = false; if (pm.ControllingGuardian) { pm.Guardian.FriendlyDuelDefeat = true; Hurt = 0 != pm.Guardian.Hurt((int)(pm.Guardian.MHP * 0.22f), guardian.Direction, false, true, " were crushed by " + guardian.Name + "'s arms."); if (pm.Guardian.Downed) { Defeated = true; } } else { Target.GetModPlayer <PlayerMod>().FriendlyDuelDefeat = true; Hurt = 0 != Target.Hurt(Terraria.DataStructures.PlayerDeathReason.ByCustomReason(Target.name + " were crushed by " + guardian.Name + "'s arms."), (int)(Target.statLifeMax2 * 0.22f), guardian.Direction); if (Target.dead) { Defeated = true; } } if (Hurt) { if (!Defeated) { if (guardian.BodyAnimationFrame == guardian.Base.ChairSittingFrame) { switch (Main.rand.Next(5)) { case 0: guardian.SaySomething("*I'll crush you if you move again!*"); break; case 1: guardian.SaySomething("*I'll hurt you worser than those monsters would If you keep moving!*"); break; case 2: guardian.SaySomething("*I can crush you with my arms or my legs, you pick!*"); break; case 3: guardian.SaySomething("*Want me to turn your bones to dust?*"); break; case 4: guardian.SaySomething("*You are angering me, more than this night does!*"); break; } } else { switch (Main.rand.Next(5)) { case 0: guardian.SaySomething("*Stay quiet!*"); break; case 1: guardian.SaySomething("*I'll crush your bones If you continue doing that!*"); break; case 2: guardian.SaySomething("*I have my arms around you, I can pull them against my body, and you wont like it!*"); break; case 3: guardian.SaySomething("*Want to try that again?*"); break; case 4: guardian.SaySomething("*This is what you want?*"); break; } } } else { switch (Main.rand.Next(5)) { case 0: guardian.SaySomething("*Finally! You got quiet!*"); break; case 1: guardian.SaySomething("*See what you made me do?!*"); break; case 2: guardian.SaySomething("*My mood is already bad, you didn't helped either!*"); break; case 3: guardian.SaySomething("*At least you stopped moving around!*"); break; case 4: guardian.SaySomething("*You behave better when unconscious!*"); break; } } } } else { guardian.SaySomething("*Press Jump button If that's enough.*"); } } if (Target.whoAmI == Main.myPlayer) { MainMod.FocusCameraPosition = guardian.CenterPosition; MainMod.FocusCameraPosition.X -= Main.screenWidth * 0.5f; MainMod.FocusCameraPosition.Y -= Main.screenHeight * 0.5f; ChatTime--; const int InitialTime = 300; if (ChatTime == -1) { ChatTime = InitialTime; } else if (ChatTime < 1) { ChatTime = 60 * 10; // + Main.rand.Next(InitialTime) FriendshipPoints++; if (FriendshipPoints >= 10 + guardian.FriendshipLevel / 3) { FriendshipPoints = 0; guardian.IncreaseFriendshipProgress(1); } string Message = GuardianMouseOverAndDialogueInterface.MessageParser(Main.rand.Next(10) == 0 ? guardian.Base.TalkMessage(Target, guardian) : guardian.Base.NormalMessage(Target, guardian), guardian); //if (Target.talkNPC > -1 && Main.npc[Target.talkNPC].type == ModContent.NPCType<GuardianNPC.List.BearNPC>()) //PlayerMod pm = Target.GetModPlayer<PlayerMod>(); if (pm.IsTalkingToAGuardian && pm.TalkingGuardianPosition == guardian.WhoAmID) { GuardianMouseOverAndDialogueInterface.SetDialogue(Message); } else { //guardian.SaySomething(Message); } } else { } } } }
public override void Update(TerraGuardian guardian) { if ((guardian.Position - Target.Position).Length() < 20) { guardian.WalkMode = true; } if (guardian.UsingFurniture) { guardian.LeaveFurniture(true); } guardian.StuckTimer = 0; if (guardian.IsBeingPulledByPlayer) { guardian.SaySomething("*Alright, I'm coming, I'm coming.*"); InUse = false; return; } guardian.MoveLeft = guardian.MoveRight = false; Sleuthing = false; if (!Target.KnockedOut && !Target.IsSleeping) { if (SleuthPercent > 70) { guardian.SaySomething("*...So close...*"); } else { guardian.SaySomething(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingFail, "*I... Was just checking if you were fine.*")); } InUse = false; return; } if (Target.Downed) { InUse = false; guardian.SaySomething("*...I should have helped instead...*"); return; } if (Math.Abs(guardian.Position.X - Target.Position.X) < 8f) { if (guardian.Velocity.X == 0 && guardian.Velocity.Y == 0) { Sleuthing = true; guardian.LookingLeft = (Target.Position.X < guardian.Position.X); float LastSleuthPercent = SleuthPercent; float FillSpeed = guardian.IsSleeping ? 0.07f : 0.2f; SleuthPercent += Main.rand.NextFloat() * FillSpeed; if (SleuthPercent >= 100) { AlexanderBase.AlexanderData data = (AlexanderBase.AlexanderData)guardian.Data; data.AddIdentifiedGuardian(Target.MyID); InUse = false; guardian.SaySomething(GuardianMouseOverAndDialogueInterface.MessageParser(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingProgressFinished, "*Okay, so that's how you work.*"), guardian)); guardian.UpdateStatus = true; } else if (SleuthPercent >= 70 && LastSleuthPercent < 70) { guardian.SaySomething(GuardianMouseOverAndDialogueInterface.MessageParser(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingProgressNearlyDone, "*Hm... Interesting...*"), guardian)); } else if (SleuthPercent >= 35 && LastSleuthPercent < 35) { guardian.SaySomething(GuardianMouseOverAndDialogueInterface.MessageParser(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingProgress, "*Uh huh...*"), guardian)); } else if (SleuthPercent > 0 && LastSleuthPercent <= 0) { guardian.SaySomething(GuardianMouseOverAndDialogueInterface.MessageParser(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingStart, "*Let's see how you work...*"), guardian)); } } } else { if (Target.Position.X < guardian.Position.X) { guardian.MoveLeft = true; } else { guardian.MoveRight = true; } } }
public override void Update(TerraGuardian guardian) { bool TargetIsKod = true; if (guardian.UsingFurniture) { guardian.LeaveFurniture(true); } if (CarriedPlayer != null) { PlayerMod pm = CarriedPlayer.GetModPlayer <PlayerMod>(); TargetIsKod = pm.KnockedOut; if (CarriedPlayer.dead) { InUse = false; if (guardian.TargetID != -1) { guardian.CheckIfSomeoneNeedsPickup(); } return; } bool BeingCarriedByMe = false; if (!PlayerMod.IsBeingCarriedBySomeone(CarriedPlayer) || (BeingCarriedByMe = PlayerMod.IsBeingCarriedByThisGuardian(CarriedPlayer, guardian))) { pm.CarriedByGuardianID = guardian.WhoAmID; pm.BeingCarriedByGuardian = false; if (!BeingCarriedByMe) { guardian.SaySomething(guardian.GetMessage(GuardianBase.MessageIDs.RescueComingMessage)); } } else { InUse = false; return; } if (CarriedPlayer.whoAmI == guardian.OwnerPos) { guardian.StuckTimer = 0; } } else { TargetIsKod = CarriedGuardian.KnockedOut; if (CarriedGuardian.Downed) { InUse = false; return; } bool BeingCarriedByMe = false; if (!CarriedGuardian.IsBeingCarriedBySomeone() || (BeingCarriedByMe = CarriedGuardian.IsBeingCarriedByThisGuardian(guardian))) { CarriedGuardian.CarriedByGuardianID = guardian.WhoAmID; CarriedGuardian.BeingCarriedByGuardian = false; if (!BeingCarriedByMe) { guardian.SaySomething(guardian.GetMessage(GuardianBase.MessageIDs.RescueComingMessage)); } } else { InUse = false; return; } } if (!Carrying) { float TargetX = CarriedPlayer != null ? CarriedPlayer.Center.X : CarriedGuardian.Position.X; float TargetY = CarriedPlayer != null ? CarriedPlayer.Bottom.Y : CarriedGuardian.Position.Y; if (Math.Abs(guardian.Position.X - TargetX) < 16 && Math.Abs(guardian.Position.Y - TargetY) < guardian.Height * 0.5f) { Carrying = true; guardian.SaySomething(guardian.GetMessage(GuardianBase.MessageIDs.RescueGotMessage)); ChangeStep(); } else { IgnoreCombat = true; guardian.MoveRight = guardian.MoveLeft = false; if (TargetX < guardian.Position.X) { guardian.MoveLeft = true; } else { guardian.MoveRight = true; } if (Time >= 5 * 60) { guardian.Position = new Microsoft.Xna.Framework.Vector2(TargetX, TargetY); guardian.SetFallStart(); Carrying = true; ChangeStep(); } else { return; } } DelayBeforePlacingOnGround = MaxDelay; } IgnoreCombat = false; bool SafeToPlaceAllyDown = true; { if (guardian.Velocity.Y == 0) { int StartCheckX = (int)((guardian.Position.X - guardian.CollisionWidth * 0.5f) * TerraGuardian.DivisionBy16), EndCheckX = (int)((guardian.Position.X + guardian.CollisionWidth * 0.5f + 1) * TerraGuardian.DivisionBy16); int CheckY = (int)((guardian.Position.Y + 1) * TerraGuardian.DivisionBy16); for (int x = StartCheckX; x < EndCheckX; x++) { if (MainMod.IsDangerousTile(x, CheckY, false)) { SafeToPlaceAllyDown = false; break; } /*Tile tile = MainMod.GetTile(x, CheckY); * if (tile.liquid >= 20) * { * SafeToPlaceAllyDown = false; * break; * }*/ } } else { SafeToPlaceAllyDown = false; } if (!TargetIsKod && DelayBeforePlacingOnGround > 2.5f * 60) { DelayBeforePlacingOnGround = (int)(2.5f * 60); } if (SafeToPlaceAllyDown && TargetIsKod) { for (int n = 0; n < 200; n++) { if (Main.npc[n].active && guardian.IsNpcHostile(Main.npc[n]) && guardian.Distance(Main.npc[n].Center) < 400 && (Main.npc[n].noTileCollide || Collision.CanHitLine(Main.npc[n].position, Main.npc[n].width, Main.npc[n].height, guardian.TopLeftPosition, guardian.Width, guardian.Height))) { SafeToPlaceAllyDown = false; break; } } } } if (SafeToPlaceAllyDown) { guardian.MoveLeft = guardian.MoveRight = false; if (DelayBeforePlacingOnGround <= 0) { if (CarriedPlayer != null) { CarriedPlayer.position.X = guardian.Position.X - CarriedPlayer.width * 0.5f; CarriedPlayer.position.Y = guardian.Position.Y - CarriedPlayer.height; InUse = false; return; } CarriedGuardian.Position.X = guardian.Position.X; CarriedGuardian.Position.Y = guardian.Position.Y; InUse = false; return; } DelayBeforePlacingOnGround--; } else { if (TargetIsKod) { DelayBeforePlacingOnGround = MaxDelay; } bool AllyIsDying = CarriedPlayer != null ? CarriedPlayer.statLife < CarriedPlayer.statLifeMax2 * 0.35f : CarriedGuardian.HP < CarriedGuardian.MHP * 0.35f; ForcedTactic = AllyIsDying ? CombatTactic.Snipe : CombatTactic.Assist; } { Vector2 CarryPosition = Vector2.Zero; Vector2 Origin = Vector2.One * 0.5f; if (guardian.Ducking) { CarryPosition = guardian.GetBetweenHandsPosition(guardian.Base.DuckingSwingFrames[2]); } else { CarryPosition = guardian.GetBetweenHandsPosition(guardian.Base.ItemUseFrames[2]); } CarryPosition += guardian.Position; if (CarriedPlayer != null) { CarriedPlayer.position.X = CarryPosition.X - CarriedPlayer.width * Origin.X + guardian.OffsetX; CarriedPlayer.position.Y = CarryPosition.Y - CarriedPlayer.height * Origin.Y + guardian.OffsetY; CarriedPlayer.fallStart = (int)(CarriedPlayer.position.Y * TerraGuardian.DivisionBy16); CarriedPlayer.direction = guardian.Direction; CarriedPlayer.immune = true; CarriedPlayer.immuneTime = 3; CarriedPlayer.immuneNoBlink = true; PlayerMod pm = CarriedPlayer.GetModPlayer <PlayerMod>(); pm.ReviveBoost++; pm.BeingCarriedByGuardian = true; MainMod.DrawMoment.Add(new GuardianDrawMoment(guardian.WhoAmID, TerraGuardian.TargetTypes.Player, CarriedPlayer.whoAmI)); } else { CarriedGuardian.IsBeingPulledByPlayer = false; CarriedGuardian.Position.X = CarryPosition.X - (CarriedGuardian.Width * (Origin.X - 0.5f)) + guardian.OffsetX; CarriedGuardian.Position.Y = CarryPosition.Y + (CarriedGuardian.Height * (1.1f - Origin.Y)) + guardian.OffsetY; CarriedGuardian.SetFallStart(); CarriedGuardian.Direction = guardian.Direction; CarriedGuardian.ReviveBoost++; CarriedGuardian.BeingCarriedByGuardian = true; CarriedGuardian.ImmuneTime = 3; CarriedGuardian.ImmuneNoBlink = true; MainMod.DrawMoment.Add(new GuardianDrawMoment(guardian.WhoAmID, TerraGuardian.TargetTypes.Guardian, CarriedGuardian.WhoAmID, true)); } } }
public override void AI() { if (npc.direction == 0) { npc.direction = Main.rand.NextDouble() < 0.5 ? -1 : 1; } if (SceneID == SceneIDs.NoScene) { Idle = true; npc.TargetClosest(false); if (Main.player[npc.target].Distance(npc.Center) < 200) { PlayerHasLeopold = false; if (PlayerMod.PlayerHasGuardian(Main.player[npc.target], 10)) { PlayerHasLeopold = true; ChangeScene(SceneIDs.KnownPlayerSpottedByLeopold); SayMessage("*Aaahhh!!! What is that?!**"); } else { ChangeScene(SceneIDs.LeopoldSpotsThePlayer); SayMessage("*Ack! W-what is that?!*"); } } } else { if (SceneID != SceneIDs.LeopoldFreeForRecruit && SceneID != SceneIDs.Flee) { npc.npcSlots = 100; } Player player = Main.player[npc.target]; if (SceneID < SceneIDs.ThinksAboutTryingToTalk) { if (player.Distance(npc.Center) < 150) { SayMessage("*Ah!! It approached.*"); ChangeScene(SceneIDs.WondersIfPlayerWillAttackHim); Jump = true; } } if (SceneID >= SceneIDs.GotScaredUponPlayerApproach && SceneID < SceneIDs.PlayerDoesNothing) { if (player.Distance(npc.Center) < 150) { if (player.Center.X - npc.Center.X < 0) { MoveRight = true; } else { MoveLeft = true; } } } if (SceneID >= SceneIDs.GotScaredUponPlayerApproach && SceneID < SceneIDs.AttemptsToRunAway1) { if (player.Distance(npc.Center) < 100) { SayMessage("*Yaah!!! Please, Don't kill me...*"); ChangeScene(SceneIDs.Crying1); Jump = true; } } npc.FaceTarget(); if (SceneTime <= 0) { switch (SceneID) { case SceneIDs.LeopoldSpotsThePlayer: SayMessage("*It's a funny kind of creature.*"); ChangeScene(SceneIDs.LeopoldSaysNeverSawAnythingLikeThat); break; case SceneIDs.LeopoldSaysNeverSawAnythingLikeThat: SayMessage("*I've never seen something like that.*"); ChangeScene(SceneIDs.LeopoldQuestionsHimselfAboutCreature); break; case SceneIDs.LeopoldQuestionsHimselfAboutCreature: SayMessage("*What kind of creature is it?*"); ChangeScene(SceneIDs.IsItTerrarian); break; case SceneIDs.IsItTerrarian: SayMessage("*Could It be a Terrarian?*"); ChangeScene(SceneIDs.NoticesOutfit); break; case SceneIDs.NoticesOutfit: SayMessage("*It surelly have unusual outfit...*"); ChangeScene(SceneIDs.QuestionsIfIsReallyATerrarian); break; case SceneIDs.QuestionsIfIsReallyATerrarian: SayMessage("*Maybe, It is said that they inhabit this world.*"); if (player.GetModPlayer <PlayerMod>().Guardian.Active&& player.GetModPlayer <PlayerMod>().Guardian.Base.IsTerraGuardian) { ChangeScene(SceneIDs.NoticesOtherGuardians); } else { ChangeScene(SceneIDs.NoticesPlayerLooking); } break; case SceneIDs.NoticesPlayerLooking: SayMessage("*It is looking at me.*"); ChangeScene(SceneIDs.WondersPlayerReaction); break; case SceneIDs.WondersPlayerReaction: SayMessage("*What is it planning to do?*"); ChangeScene(SceneIDs.IsPreparingAttack); break; case SceneIDs.IsPreparingAttack: SayMessage("*Is it preparing to attack?*"); ChangeScene(SceneIDs.ThreatenUseSpell); break; case SceneIDs.ThreatenUseSpell: SayMessage("*If It tries to attack, I will blow It with my spells.*"); ChangeScene(SceneIDs.FindsWeirdTheNoReaction, true); break; case SceneIDs.FindsWeirdTheNoReaction: SayMessage("*Weird, It isn't doing anything.*"); ChangeScene(SceneIDs.ThinksAboutTryingToTalk); break; case SceneIDs.ThinksAboutTryingToTalk: SayMessage("*Maybe If I try talking...*"); ChangeScene(SceneIDs.WondersIftheySpeak); break; case SceneIDs.WondersIftheySpeak: SayMessage("*No... Wait, I don't even know if they can speak.*"); ChangeScene(SceneIDs.MentionsABook); break; case SceneIDs.MentionsABook: SayMessage("*There is a book that theorizes that but...*"); ChangeScene(SceneIDs.ThinksAboutTrying); break; case SceneIDs.ThinksAboutTrying: SayMessage("*Maybe If I try...*"); ChangeScene(SceneIDs.TriesTalking); break; case SceneIDs.TriesTalking: SayMessage("*H-hey... Can you hear me?*"); ChangeScene(SceneIDs.WondersIfIsScared, true); break; case SceneIDs.WondersIfIsScared: SayMessage("*(Maybe It's scared...)*"); ChangeScene(SceneIDs.SaysWontHurt); break; case SceneIDs.SaysWontHurt: SayMessage("*Come here.. I wont hurt you...*"); ChangeScene(SceneIDs.TriesHidingFear, true); break; case SceneIDs.TriesHidingFear: SayMessage("*(..Don't shake... You don't want to scare it...)*"); ChangeScene(SceneIDs.NoticesDidntWorked); break; case SceneIDs.NoticesDidntWorked: SayMessage("*(Huh? Didn't worked? Maybe If...)*"); ChangeScene(SceneIDs.TriesGivingFood); break; case SceneIDs.TriesGivingFood: SayMessage("*Uh... I... Got some food.. Do you want it...?*"); ChangeScene(SceneIDs.WondersHowStupidHisActionWas); break; case SceneIDs.WondersHowStupidHisActionWas: SayMessage("*(Got some food?! What am I thinking?!)*"); ChangeScene(SceneIDs.WaitsAFewMoments); break; case SceneIDs.WaitsAFewMoments: SayMessage("*...*"); ChangeScene(SceneIDs.ThinksThePlayerDidntUnderstandHim); break; case SceneIDs.ThinksThePlayerDidntUnderstandHim: SayMessage("*I guess It can't understand me at all.*"); ChangeScene(SceneIDs.TalksAboutWalkingAway); break; case SceneIDs.TalksAboutWalkingAway: SayMessage("*Maybe If I just walk away...*"); ChangeScene(SceneIDs.Flee); break; //////////////////// case SceneIDs.GotScaredUponPlayerApproach: SayMessage("*Ah!! It approached.*"); ChangeScene(SceneIDs.WondersIfPlayerWillAttackHim); break; case SceneIDs.WondersIfPlayerWillAttackHim: SayMessage("*Is it going to attack me?!*"); ChangeScene(SceneIDs.FearPlayerAttack1); break; case SceneIDs.FearPlayerAttack1: SayMessage("*No!! I'm too young to die!!*"); ChangeScene(SceneIDs.FearPlayerAttack2); break; case SceneIDs.FearPlayerAttack2: SayMessage("*I didn't even finished the mysteries of the Terra Realm.*"); ChangeScene(SceneIDs.FearPlayerAttack3); break; case SceneIDs.FearPlayerAttack3: SayMessage("*This... This is how I'm going to die?!*"); ChangeScene(SceneIDs.FearPlayerAttack4); break; case SceneIDs.FearPlayerAttack4: SayMessage("*The great Leopold... Devoured by a Terrarian...*"); ChangeScene(SceneIDs.FearPlayerAttack5); break; case SceneIDs.FearPlayerAttack5: SayMessage("*Oh... What a cruel world...*"); ChangeScene(SceneIDs.PlayerDoesNothing, true); break; case SceneIDs.PlayerDoesNothing: SayMessage("...."); ChangeScene(SceneIDs.PlayerDoesNothing2); break; case SceneIDs.PlayerDoesNothing2: SayMessage("*Uh...*"); ChangeScene(SceneIDs.WondersIfPlayerWillAttack); break; case SceneIDs.WondersIfPlayerWillAttack: SayMessage("*Is... It going to try attacking me?*"); ChangeScene(SceneIDs.WondersIfScaredPlayer); break; case SceneIDs.WondersIfScaredPlayer: SayMessage("*Maybe... I scared it?*"); ChangeScene(SceneIDs.ThreatensPlayer); break; case SceneIDs.ThreatensPlayer: SayMessage("*Yeah!! Don't you dare get near me, or I'll show you some thing!*"); ChangeScene(SceneIDs.RealizesHowStupidWhatHeSaidWas); break; case SceneIDs.RealizesHowStupidWhatHeSaidWas: SayMessage("*(Show It something?! What were I thinking?)*"); ChangeScene(SceneIDs.SeesIfPlayerReacts, true); break; case SceneIDs.SeesIfPlayerReacts: SayMessage("..."); ChangeScene(SceneIDs.WonderIfAngeredPlayer); break; case SceneIDs.WonderIfAngeredPlayer: SayMessage("*(Did I anger it?)*"); ChangeScene(SceneIDs.SeesIfPlayerReactsAgain, true); break; case SceneIDs.SeesIfPlayerReactsAgain: SayMessage("..."); ChangeScene(SceneIDs.WonderIfPlayerIsFrozenInFear); break; case SceneIDs.WonderIfPlayerIsFrozenInFear: SayMessage("*(Maybe It's frozen in fear?)*"); ChangeScene(SceneIDs.SeesIfPlayerReactsAgainAgain, true); break; case SceneIDs.SeesIfPlayerReactsAgainAgain: SayMessage("..."); ChangeScene(SceneIDs.AttemptsToRunAway1); break; case SceneIDs.AttemptsToRunAway1: SayMessage("*I... Kind of have more things to do... so...*"); ChangeScene(SceneIDs.AttemptsToRunAway2); break; case SceneIDs.AttemptsToRunAway2: SayMessage("*Well, I'm gone!*"); ChangeScene(SceneIDs.Flee); break; ////////////////////////////// case SceneIDs.FearsAboutPlayerAttackingHim: SayMessage("*Yaah!!! Please, Don't kill me...*"); ChangeScene(SceneIDs.Crying1); break; case SceneIDs.Crying1: SayMessage("*(Sniffle... Sob...)*"); ChangeScene(SceneIDs.Crying2); break; case SceneIDs.Crying2: SayMessage("*(Snif...)*"); ChangeScene(SceneIDs.WaitingForReaction, true); break; case SceneIDs.WaitingForReaction: SayMessage("..."); ChangeScene(SceneIDs.AsksIfPlayerIsGoingToAttackHim); break; case SceneIDs.AsksIfPlayerIsGoingToAttackHim: SayMessage("*You... Aren't going to attack me... Right...?*"); ChangeScene(SceneIDs.AsksIfPlayerUnderstandWhatHeSays); break; case SceneIDs.AsksIfPlayerUnderstandWhatHeSays: SayMessage("*Can... You even understand me...?*"); ChangeScene(SceneIDs.WaitingForReactionAgain, true); break; case SceneIDs.WaitingForReactionAgain: SayMessage("*...*"); ChangeScene(SceneIDs.TellsThatIsgoingToFlee); break; case SceneIDs.TellsThatIsgoingToFlee: SayMessage("*I'm.. Going to... Walk... Backaway... *"); ChangeScene(SceneIDs.RunsWhileScreaming); break; case SceneIDs.RunsWhileScreaming: SayMessage("*Waaaaaaaaaahhh!!!*"); ChangeScene(SceneIDs.Flee); break; ///////////////////////////////// case SceneIDs.NoticesOtherGuardians: SayMessage("*Wait, are those... TerraGuardians?*"); ChangeScene(SceneIDs.WondersWhyGuardiansFollowsPlayer); break; case SceneIDs.WondersWhyGuardiansFollowsPlayer: SayMessage("*Why are those TerraGuardians with that Terrarian?*"); ChangeScene(SceneIDs.ThinksPlayerIsGuardiansPet); break; case SceneIDs.ThinksPlayerIsGuardiansPet: SayMessage("*Maybe It's their little pet?*"); ChangeScene(SceneIDs.IgnoresTheAboveIdea); break; case SceneIDs.IgnoresTheAboveIdea: SayMessage("*It... Doesn't look like it...*"); ChangeScene(SceneIDs.ThinksPlayerEnslavedGuardians); break; case SceneIDs.ThinksPlayerEnslavedGuardians: SayMessage("*Maybe... Oh no... The Terrarian enslaved them!*"); ChangeScene(SceneIDs.YellsThatIsGoingToSaveGuardians); break; case SceneIDs.YellsThatIsGoingToSaveGuardians: SayMessage("*Don't worry friends, I will save you all!*"); ChangeScene(SceneIDs.WondersHowToSaveGuardians); break; case SceneIDs.WondersHowToSaveGuardians: SayMessage("*I should save them, but how...*"); ChangeScene(SceneIDs.PlayerMainGuardianTalksToLeopold); break; case SceneIDs.PlayerMainGuardianTalksToLeopold: { TerraGuardian Guardian = PlayerMod.GetPlayerMainGuardian(player); string Message = ""; if (Guardian.ModID == MainMod.mod.Name) { switch (Guardian.ID) //What about moving those dialogues to a separate method, so It's easier to find them. { default: Message = Guardian.GetMessage(GuardianBase.MessageIDs.LeopoldMessage1, "*" + Guardian.Name + " is saying that you're It's friend.*"); break; case GuardianBase.Rococo: Message = "*" + Guardian.Name + " looks very confused.*"; break; case GuardianBase.Blue: Message = "*" + Guardian.Name + " seems to be enjoying the show.*"; break; case GuardianBase.Sardine: Message = "I think the way we met isn't that weird now, right pal?"; break; case GuardianBase.Zacks: Message = "*Boss, can I eat that stupid bunny?*"; break; case GuardianBase.Alex: Message = "Save me? Save me from what? Who's threatening me and my friend?!"; break; case GuardianBase.Brutus: Message = "*Are you missing some rivets, long eared guy?*"; break; case GuardianBase.Bree: Message = "Have you finished making yourself into a fool."; break; case GuardianBase.Mabel: Message = "*Hello, Teehee. Do you have a problem, bunny guy?*"; break; case GuardianBase.Domino: Message = "*Don't look at me, I stopped selling the kind of merchandise that caused that long ago.*"; break; case GuardianBase.Vladimir: Message = "*I think that guy needs a hug. Maybe It will end up fixing his head, I guess.*"; break; case GuardianBase.Malisha: Message = "*And he still fears even his own shadow.*"; break; } } Guardian.SaySomething(Message); } ChangeScene(SceneIDs.LeopoldAnswersTheGuardian); break; case SceneIDs.LeopoldAnswersTheGuardian: { TerraGuardian Guardian = PlayerMod.GetPlayerMainGuardian(player); string Message = ""; if (Guardian.ModID == MainMod.mod.Name) { switch (Guardian.ID) { default: Message = Guardian.GetMessage(GuardianBase.MessageIDs.LeopoldMessage2, "*You're friends of that Terrarian?*"); break; case GuardianBase.Rococo: Message = "*Uh... What is it with the look in your face?*"; break; case GuardianBase.Blue: Message = "*Wait, why are you laughing?*"; break; case GuardianBase.Sardine: Message = "*Wait, \"pal\"? You're that Terrarian's friend?!*"; break; case GuardianBase.Zacks: Message = "*Wait, you...Yaaaaaah!! It's a zombie!!!*"; break; case GuardianBase.Alex: Message = "*F..Friend?!*"; break; case GuardianBase.Brutus: Message = "*I...I'm not crazy?! What are you doing with that Terrarian?*"; break; case GuardianBase.Bree: Message = "*Hey! I'm not a fool!*"; break; case GuardianBase.Mabel: Message = "*Ah... Uh... No... Uh... Just... I'm... Fine...*"; break; case GuardianBase.Domino: Message = "*H-hey! I would never use such thing!*"; break; case GuardianBase.Vladimir: Message = "*How can you think of hugs at a moment like this?*"; break; case GuardianBase.Malisha: Message = "*W-what the! What are you doing here? And who's that?*"; break; } } SayMessage(Message); } ChangeScene(SceneIDs.MainGuardianSaysThatPlayerHasBeenHearingAllTheTime); break; case SceneIDs.MainGuardianSaysThatPlayerHasBeenHearingAllTheTime: { TerraGuardian Guardian = PlayerMod.GetPlayerMainGuardian(player); string Message = ""; if (Guardian.ModID == MainMod.mod.Name) { switch (Guardian.ID) { default: Message = Guardian.GetMessage(GuardianBase.MessageIDs.LeopoldMessage3, "*" + Guardian.Name + " also said that you heard everything he said.*"); break; case GuardianBase.Rococo: Message = "*" + Guardian.Name + " is asking you what is his problem.*"; break; case GuardianBase.Blue: Message = "*" + Guardian.Name + " explains that you're her friend, and that you can understand what they are talking about.*"; break; case GuardianBase.Sardine: Message = "Yes, and It heard everything you said as clear as day."; break; case GuardianBase.Zacks: Message = "*That guy is making me sick, my boss isn't a troglodyte, do you hear?*"; break; case GuardianBase.Alex: Message = "Yes, me and my friend here were watching you talking to self all that time."; break; case GuardianBase.Brutus: Message = "*I was hired by it to be his bodyguard, you fool.*"; break; case GuardianBase.Bree: Message = "Of course you are, how can you think that the Terrarian is a fool?"; break; case GuardianBase.Mabel: Message = "*Hey friend, I can't understand that guy, can you explain to me what is his problem?*"; break; case GuardianBase.Domino: Message = "*Then why were you fooling yourself a while ago? Terrarians aren't stupid.*"; break; case GuardianBase.Vladimir: Message = "*What moment like this, the Terrarian is my buddy. And can understand what we are talking.*"; break; case GuardianBase.Malisha: Message = "*I moved to here for a vacation, then this Terrarian let me live here.*"; break; } } Guardian.SaySomething(Message); } ChangeScene(SceneIDs.LeopoldGetsSurprisedThatPlayerHasBeenHearingAllTime); break; case SceneIDs.LeopoldGetsSurprisedThatPlayerHasBeenHearingAllTime: SayMessage("*What?! That Terrarian can understand what we are saying?!*"); ChangeScene(SceneIDs.LeopoldTellsToForgetEverything); break; case SceneIDs.LeopoldTellsToForgetEverything: SayMessage("*I nearly thought... Oh... Nevermind... Does It matter anyway?*"); ChangeScene(SceneIDs.LeopoldPresentsHimself); break; case SceneIDs.LeopoldPresentsHimself: SayMessage("*I'm Leopold, the Sage. Please disconsider what I debated with myself earlier. If you can.*"); ChangeScene(SceneIDs.LeopoldFreeForRecruit); break; case SceneIDs.KnownPlayerSpottedByLeopold: SayMessage("*Wait... I know that face...*"); ChangeScene(SceneIDs.LeopoldRecognizesTerrarian); break; case SceneIDs.LeopoldRecognizesTerrarian: SayMessage("*Oh, It is that Terrarian again.*"); ChangeScene(SceneIDs.LeopoldGreetsPlayer); break; case SceneIDs.LeopoldGreetsPlayer: SayMessage("*Hello, I didn't expected to see you here.*"); ChangeScene(SceneIDs.LeopoldTellsThatIsGoingToPlayerTown); break; case SceneIDs.LeopoldTellsThatIsGoingToPlayerTown: SayMessage("*Since you're here, I think you have some town around this world, so... See you there.*"); ChangeScene(SceneIDs.LeopoldTurnsToTownNPC, true); break; case SceneIDs.LeopoldTurnsToTownNPC: NpcMod.AddGuardianMet(10); PlayerMod.AddPlayerGuardian(player, GuardianID, GuardianModID); PlayerMod.GetPlayerGuardian(player, GuardianID, GuardianModID).IncreaseFriendshipProgress(1); WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID); //npc.Transform(ModContent.NPCType<GuardianNPC.List.BunnyGuardian>()); break; ////////////////////////////////// case SceneIDs.Flee: { } break; } } if (SceneID == SceneIDs.Flee) { if (player.Center.X - npc.Center.X < 0) { MoveRight = true; } else { MoveLeft = true; } if (player.Distance(npc.Center) >= Main.screenWidth) { npc.active = false; Main.NewText("The Bunny Guardian has escaped.", Microsoft.Xna.Framework.Color.Red); return; } } SceneTime--; } base.AI(); }
public override void Update(TerraGuardian guardian) { LiebreBase.ReaperGuardianData data = (LiebreBase.ReaperGuardianData)guardian.Data; switch (Step) { case 0: if (StepStart) { SoulsValue = data.SoulsLoaded; if (SoulsValue >= LiebreBase.MaxSoulsContainedValue) { guardian.SaySomething("*I must go, now!*"); } else if (SoulsValue >= LiebreBase.MaxSoulsContainedValue * 0.9f) { guardian.SaySomething("*I'll unload those souls, I feel like I'm reaching my capacity.*"); } else { guardian.SaySomething("*I'll be right back.*"); } } IgnoreCombat = true; if (Main.rand.NextDouble() < 0.333) { Dust.NewDust(guardian.TopLeftPosition, guardian.Width, guardian.Height, 192, 0, -0.2f, Scale: Main.rand.NextFloat(0.8f, 1.2f)); } if (Time >= 3 * 60) { ChangeStep(); data.SoulsLoaded = 0; Invisibility = true; LastWasPlayerMounted = guardian.PlayerMounted; guardian.ToggleMount(true); guardian.ClearMessagesSaid(); } break; case 1: Invisibility = true; IgnoreCombat = true; Inactivity = true; if (guardian.OwnerPos > -1) { guardian.Position = Main.player[guardian.OwnerPos].Bottom; } if (Time >= 10 * 60) { ChangeStep(); } break; case 2: Invisibility = false; IgnoreCombat = false; Inactivity = false; if (StepStart) { guardian.Spawn(); if (guardian.OwnerPos > -1) { guardian.Position = Main.player[guardian.OwnerPos].Bottom; if (LastWasPlayerMounted) { guardian.ToggleMount(true, false); } } } if (Time >= 30) { if (SoulsValue >= LiebreBase.MaxSoulsContainedValue) { guardian.SaySomething("*I felt like about to blow...*"); } else if (SoulsValue >= LiebreBase.MaxSoulsContainedValue * 0.9f) { guardian.SaySomething("*I'm glad I managed to do the delivery in time.*"); } else { guardian.SaySomething("*I returned.*"); } } if (Time % 10 == 0) { float HeightVal = Time / 10 * 0.1f * guardian.Height; for (int i = -1; i < 2; i++) { Vector2 EffectPosition = new Vector2(guardian.Position.X, guardian.Position.Y); EffectPosition.Y -= HeightVal; EffectPosition.X += guardian.Width * 0.6f * i; Dust.NewDust(EffectPosition, 1, 1, 192, 0, -0.2f, 192, Scale: Main.rand.NextFloat(0.8f, 1.2f)); } } if (Time >= 100) { { float CapacityPercentage = (float)SoulsValue / LiebreBase.MaxSoulsContainedValue; int BuffDuration = (int)(CapacityPercentage * 900) * 60; if (SoulsValue > LiebreBase.MaxSoulsContainedValue) { BuffDuration = (int)(BuffDuration * 0.75f); } for (int i = 0; i < CapacityPercentage * 5; i++) { int BuffID = Utils.SelectRandom(Main.rand, new int[] { Terraria.ID.BuffID.Lifeforce, Terraria.ID.BuffID.Regeneration, Terraria.ID.BuffID.Endurance, Terraria.ID.BuffID.ManaRegeneration, Terraria.ID.BuffID.Mining, Terraria.ID.BuffID.ObsidianSkin, Terraria.ID.BuffID.Thorns }); for (int p = 0; p < 255; p++) { if (Main.player[p].active && !guardian.IsPlayerHostile(Main.player[p])) { Main.player[p].AddBuff(BuffID, BuffDuration); } } foreach (TerraGuardian g in MainMod.ActiveGuardians.Values) { if (g.OwnerPos == guardian.OwnerPos && !g.IsGuardianHostile(guardian)) { g.AddBuff(BuffID, BuffDuration); } } } guardian.SaySomethingCanSchedule("*Take this blessing as a reward for helping me.*"); } guardian.DoAction.InUse = false; } break; } }