public static void OpenShop() { PlayerMod pm = MainPlayer.GetModPlayer <PlayerMod>(); if (pm.IsTalkingToAGuardian && MainMod.ActiveGuardians.ContainsKey(pm.TalkingGuardianPosition)) { TerraGuardian tg = MainMod.ActiveGuardians[pm.TalkingGuardianPosition]; Shop = GuardianShopHandler.GetShop(tg.MyID); if (Shop != null) { bool HasSale = false; for (int i = 0; i < Shop.Items.Count; i++) { Shop.Items[i].ItemOnDisplay = false; if (Shop.Items[i].ItemID != 0 && Shop.Items[i].CanItemBeVisibleAtTheStore(MainPlayer)) { Shop.Items[i].ItemOnDisplay = true; if (Shop.Items[i].SaleTime > 0) { HasSale = true; } } } ShopOpen = true; ShopStartPosition.X = 0; ShopStartPosition.Y = 258; Main.playerInventory = true; if (HasSale) { LastStoreMessage = tg.Base.GetSpecialMessage(GuardianBase.MessageIDs.StoreSaleHappeningMessage); } if (LastStoreMessage == "") { LastStoreMessage = tg.GetMessage(GuardianBase.MessageIDs.StoreOpenMessage); } if (LastStoreMessage == "") { LastStoreMessage = "*That is what I have for sale.*"; } } } else { Shop = null; ShopOpen = false; } }
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 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 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.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 static string GetFeatMessage(FeatMentioning feat, TerraGuardian tg) { string Message = ""; string Subject = feat.FeatSubject; switch (feat.type) { case FeatMentioning.FeatType.BossDefeated: case FeatMentioning.FeatType.MinibossDefeated: Message = tg.GetMessage(GuardianBase.MessageIDs.FeatMentionBossDefeat); break; case FeatMentioning.FeatType.CoinPortalSpawned: Message = tg.GetMessage(GuardianBase.MessageIDs.FeatCoinPortal); break; case FeatMentioning.FeatType.EventFinished: Message = tg.GetMessage(GuardianBase.MessageIDs.FeatEventFinished); break; case FeatMentioning.FeatType.FoundSomethingGood: Message = tg.GetMessage(GuardianBase.MessageIDs.FeatFoundSomethingGood); break; case FeatMentioning.FeatType.MentionPlayer: Message = tg.GetMessage(GuardianBase.MessageIDs.FeatMentionPlayer); break; case FeatMentioning.FeatType.MetSomeoneNew: { if (tg.Base.Name == feat.FeatSubject || tg.Base.PossibleNames.Contains(feat.FeatSubject)) { Message = tg.GetMessage(GuardianBase.MessageIDs.FeatPlayerMetMe); } else { Message = tg.GetMessage(GuardianBase.MessageIDs.FeatMetSomeoneNew); } } break; case FeatMentioning.FeatType.OpenedTemple: Message = tg.GetMessage(GuardianBase.MessageIDs.FeatOpenTemple); break; case FeatMentioning.FeatType.PlayerDied: Message = tg.GetMessage(GuardianBase.MessageIDs.FeatPlayerDied); break; case FeatMentioning.FeatType.SomeonePickedABuddy: { bool IsMe = (tg.Base.Name == feat.FeatSubject || tg.Base.PossibleNames.Contains(feat.FeatSubject)); if (IsMe && feat.PlayerName == Main.player[Main.myPlayer].name) { Message = tg.GetMessage(GuardianBase.MessageIDs.FeatSpeakerPlayerPickedMeAsBuddy); } else { if (!IsMe) { Message = tg.GetMessage(GuardianBase.MessageIDs.FeatMentionSomeonePickedAsBuddy); } } } break; case FeatMentioning.FeatType.SomeoneMovedInToAWorld: { bool IsMe = (tg.Base.Name == Subject || tg.Base.PossibleNames.Contains(Subject)); if (!IsMe && feat.PlayerName != Main.LocalPlayer.name) { string[] SubjectSplit = feat.FeatSubject.Split(':'); Subject = SubjectSplit[0]; string WorldName = SubjectSplit[1]; Message = tg.GetMessage(GuardianBase.MessageIDs.FeatMentionSomeoneMovingIntoAWorld).Replace("[world]", WorldName); } } break; } Message = Message.Replace("[player]", feat.PlayerName).Replace("[subject]", Subject); return(Message); }
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(); }