public static void TrySpawningMichelle()
 {
     if (NpcMod.HasMetGuardian(GuardianBase.Michelle) || WorldMod.IsGuardianNpcInWorld(GuardianBase.Michelle))
     {
         return;
     }
     if (Main.fastForwardTime || Main.eclipse || !Main.dayTime || Main.time >= 27000 || Main.time % 60 > 0)
     {
         return;
     }
     if (Main.invasionType > 0 && Main.invasionDelay == 0 && Main.invasionSize > 0)
     {
         return;
     }
     if (Main.rand.Next(17) == 0)
     {
         bool HasPlayerWithDefense = false;
         for (int p = 0; p < 255; p++)
         {
             if (Main.player[p].active && Main.player[p].statDefense > 0)
             {
                 HasPlayerWithDefense = true;
                 break;
             }
         }
         if (HasPlayerWithDefense)
         {
             NpcMod.SpawnGuardianNPC(Main.spawnTileX * 16, Main.spawnTileY * 16, GuardianBase.Michelle);
             //NPC.NewNPC(Main.spawnTileX * 16, Main.spawnTileY * 16, ModContent.NPCType<MichelleGuardian>());
             Main.NewText("Michelle has logged in.", 255, 255, 0);
         }
     }
 }
Esempio n. 2
0
        public static void TrySpawningBrutus()
        {
            if (Main.netMode == 1 || NpcMod.HasMetGuardian(6, "") || WorldMod.IsGuardianNpcInWorld(GuardianBase.Brutus))
            {
                return;
            }
            const int SpawnTime = 3 * 3600;

            if (Main.fastForwardTime || Main.eclipse || !Main.dayTime || (Main.time < SpawnTime || WorldMod.LastTime >= 7.5))
            {
                return;
            }
            if (Main.invasionType > 0 && Main.invasionDelay == 0 && Main.invasionSize > 0)
            {
                return;
            }
            int NpcCount = (int)(NpcMod.GetCompanionNPCCount() * 0.5f);

            for (int n = 0; n < 200; n++)
            {
                if (Main.npc[n].active && Main.npc[n].townNPC)
                {
                    NpcCount++;
                }
            }
            if (NpcCount < TownNpcsForBrutusToBeginAppearing)
            {
                return;
            }
            int SpawnChance = 20 - ChanceCounter() / 2;

            if (SpawnChance > 0 && Main.rand.Next(SpawnChance) > (NpcCount - TownNpcsForBrutusToBeginAppearing) * 0.5f)
            {
                return;
            }
            List <int> NpcsToSpawnOn = new List <int>();

            for (int i = 0; i < 200; i++)
            {
                if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType <BrutusNPC>())
                {
                    return;
                }
                if (Main.npc[i].active && Main.npc[i].townNPC && !Main.npc[i].homeless && Main.npc[i].type != 37)
                {
                    byte PickedPlayer = Player.FindClosest(Main.npc[i].position, Main.npc[i].width, Main.npc[i].height);
                    if (Math.Abs(Main.player[PickedPlayer].Center.X - Main.npc[i].Center.X) >= NPC.sWidth * 0.5f ||
                        Math.Abs(Main.player[PickedPlayer].Center.Y - Main.npc[i].Center.Y) >= NPC.sHeight * 0.5f)
                    {
                        NpcsToSpawnOn.Add(i);
                    }
                }
            }
            if (NpcsToSpawnOn.Count == 0)
            {
                return;
            }
            int PickedNPC = NpcsToSpawnOn[Main.rand.Next(NpcsToSpawnOn.Count)];
            int SpawnPosX = (int)Main.npc[PickedNPC].Center.X,
                SpawnPosY = (int)(Main.npc[PickedNPC].position.Y + Main.npc[PickedNPC].height);
            int    npcPos = NPC.NewNPC(SpawnPosX, SpawnPosY, ModContent.NPCType <BrutusNPC>());
            string Text   = "<Brutus> *If someone is interessed in having a body guard, come see me near " + Main.npc[PickedNPC].GivenOrTypeName + ".*";

            if (Main.netMode == 0)
            {
                Main.NewText(Text, MainMod.MysteryCloseColor);
            }
            else
            {
                NetMessage.SendData(25, -1, -1, Terraria.Localization.NetworkText.FromLiteral(Text), MainMod.MysteryCloseColor.R, MainMod.MysteryCloseColor.G, MainMod.MysteryCloseColor.B, 255);
            }
            WarnedAboutBrutus = true;
        }
 public static void DrawBannerGame()
 {
     if (!ManagingGuardianHouses)
     {
         return;
     }
     try
     {
         string MouseText = "";
         for (int g = 0; g < WorldMod.MaxGuardianNpcsInWorld; g++)
         {
             WorldMod.GuardianTownNpcState townnpc = WorldMod.GuardianNPCsInWorld[g];
             if (townnpc != null && !townnpc.Homeless && WorldMod.IsGuardianNpcInWorld(townnpc.CharID))
             {
                 int BannerX = townnpc.HomeX, BannerY = townnpc.HomeY;
                 if (BannerX < 0 || BannerY < 0)
                 {
                     continue;
                 }
                 BannerY--;
                 if (Main.tile[BannerX, BannerY] == null)
                 {
                     continue;
                 }
                 bool EndsOnNullTile = false;
                 while (!Main.tile[BannerX, BannerY].active() || !Main.tileSolid[(int)Main.tile[BannerX, BannerY].type])
                 {
                     BannerY--;
                     if (BannerY < 10)
                     {
                         break;
                     }
                     if (Main.tile[BannerX, BannerY] == null)
                     {
                         EndsOnNullTile = true;
                         break;
                     }
                 }
                 if (EndsOnNullTile)
                 {
                     continue;
                 }
                 TerraGuardian guardian = null;
                 foreach (TerraGuardian tg in WorldMod.GuardianTownNPC)
                 {
                     if (townnpc.IsID(tg.ID, tg.ModID))
                     {
                         guardian = tg;
                         break;
                     }
                 }
                 if (guardian == null)
                 {
                     continue;
                 }
                 const int PaddingX = 8;
                 int       PaddingY = 18;
                 if (Main.tile[BannerX, BannerY].type == 19)
                 {
                     PaddingY -= 8;
                 }
                 BannerY++;
                 Vector2 BannerPosition = new Vector2(BannerX * 16 + PaddingX, BannerY * 16 + PaddingY) - Main.screenPosition;
                 DrawBanner(guardian, BannerPosition, Lighting.GetColor(BannerX, BannerY));
                 BannerPosition -= new Vector2(Main.HouseBannerTexture[1].Width * 0.5f, Main.HouseBannerTexture[1].Height * 0.5f);
                 if (Main.mouseX >= BannerPosition.X && Main.mouseX < BannerPosition.X + Main.HouseBannerTexture[1].Width &&
                     Main.mouseY >= BannerPosition.Y && Main.mouseY < BannerPosition.Y + Main.HouseBannerTexture[1].Height)
                 {
                     //MainPlayer.mouseInterface = true;
                     MouseText = guardian.Name;
                     if (Main.mouseRight && Main.mouseRightRelease)
                     {
                         if (!guardian.IsStarter && !guardian.IsPlayerBuddy(Main.LocalPlayer) && guardian.FriendshipLevel < guardian.Base.MoveInLevel)
                         {
                             Main.NewText(guardian.Name + (Main.rand.Next(2) == 0 ? " refuses to leave their house." : " doesn't want to be kicked out of their house."), Color.PaleVioletRed);
                         }
                         else
                         {
                             townnpc.Homeless  = true;
                             townnpc.HomeX     =
                                 townnpc.HomeY = -1;
                             townnpc.ValidateHouse();
                             Main.PlaySound(12, -1, -1, 1, 1f, 0f);
                         }
                     }
                 }
             }
         }
         if (MouseText != "")
         {
             Utils.DrawBorderString(Main.spriteBatch, MouseText, new Vector2(Main.mouseX, Main.mouseY + 16), Color.White, 1f, 0.5f);
         }
     }
     catch
     {
     }
 }
Esempio n. 4
0
 public bool ShouldScheduleVisit()
 {
     return(request.state == RequestData.RequestState.Active && WorldMod.HourChange && !WorldMod.IsGuardianNpcInWorld(MyID) && !WorldMod.ScheduledVisits.Contains(MyID));
 }