Esempio n. 1
0
 public override void ModifyHitByNPC(Player player, SkillData data, NPC npc, ref int damage, ref bool crit)
 {
     if (data.Level > 5 && MainMod.IsUndead(npc.type))
     {
         damage -= (int)(damage * 0.1f);
     }
 }
Esempio n. 2
0
        public override string GetQuestCurrentObjective(QuestData rawdata)
        {
            BreeStayQuestData data = (BreeStayQuestData)rawdata;
            byte CurFishCount      = (byte)(FishCount - data.FishGiven);

            return("Give " + CurFishCount + " " + MainMod.PluralifyWord(FishName, CurFishCount) + " to Bree, so you convince her to stay.");
        }
Esempio n. 3
0
 public static void Open()
 {
     Main.playerInventory  = false;
     WindowPosition.X      = Main.screenWidth * 0.2f;
     WindowPosition.Y      = Main.screenHeight * 0.2f;
     WindowWidth           = Main.screenWidth - (int)WindowPosition.X * 2;
     WindowHeight          = Main.screenHeight - (int)WindowPosition.Y * 2;
     PossibleGuardianIDs   = MainMod.GetPossibleStarterGuardians();
     PossibleGuardianNames = new string[PossibleGuardianIDs.Length];
     for (int i = 0; i < PossibleGuardianIDs.Length; i++)
     {
         GuardianBase gb = GuardianBase.GetGuardianBase(PossibleGuardianIDs[i].ID, PossibleGuardianIDs[i].ModID);
         if (gb.InvalidGuardian)
         {
             PossibleGuardianNames[i] = "Corrupted Memory";
         }
         else
         {
             PossibleGuardianNames[i] = gb.Name;
         }
     }
     WindowActive = true;
     GameModeInfo = new string[] { "The Buddies Mode is a special game mode where you pick a companion you",
                                   "will play the game with since the beggining of your adventure, until forever.",
                                   "The companion you pick ranges from starter companions, to companions met by other player characters.",
                                   "You wont be able to dismiss It, and takes longer to have others following you, so think well.",
                                   "Becareful, having extra companions with your will reduce the buddy mode benefits.",
                                   "You have 12 in-game hours (12 real life minutes) to decide if you want to try It or not." };;
 }
Esempio n. 4
0
 public override string RequestObjective(RequestData data)
 {
     if (data.IsComplete)
     {
         return("Report back to " + data.RequestGiver.Name + ".");
     }
     return("Slay " + (data.MaxObjectiveCount - data.ObjectiveCount) + " " + MainMod.PluralifyWord(NpcName, data.MaxObjectiveCount - data.ObjectiveCount) + ".");
 }
Esempio n. 5
0
 public override bool BeforeShooting(Terraria.Player player, SkillData data, Terraria.Item weapon, ref int type, ref int damage, ref float knockback, ref Microsoft.Xna.Framework.Vector2 Position, ref float SpeedX, ref float SpeedY)
 {
     damage = (int)(damage * (0.6f + 0.02f * data.Level));
     if (weapon.ranged && MainMod.IsArrow(type))
     {
         Projectile.NewProjectile(Position.X, Position.Y, SpeedX, SpeedY - 0.4f, type, damage, knockback, player.whoAmI);
     }
     return(true);
 }
Esempio n. 6
0
 public int SayMessage(string Text, bool Faster = false)
 {
     MessageText = Text;
     MessageTime = MainMod.CalculateMessageTime(Text);
     if (Faster)
     {
         MessageTime = (int)(MessageTime * 0.8f);
     }
     return(MessageTime);
 }
Esempio n. 7
0
 public override void ModifyHitNPC(Player player, SkillData data, Item item, NPC target, ref int damage, ref float knockback, ref bool crit)
 {
     if (MainMod.IsDemon(target.type))
     {
         damage += (int)(damage * (0.05f + 0.02f * data.Level));
         for (int i = 0; i < 3; i++)
         {
             Dust.NewDust(target.position, target.width, target.height, 270);
         }
     }
 }
Esempio n. 8
0
 public override void ModifyHitNPCWithProj(Player player, SkillData data, Projectile proj, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
 {
     if (MainMod.IsUndead(target.type))
     {
         damage += (int)(damage * (0.05f + 0.02f * data.Level));
         for (int i = 0; i < 3; i++)
         {
             Dust.NewDust(target.position, target.width, target.height, 57);
         }
     }
 }
Esempio n. 9
0
 public override void ModifyTooltips(Item item, List <TooltipLine> tooltips)
 {
     if (Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().Guardian.Active)
     {
         TerraGuardian guardian = Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().Guardian;
         if (item.healLife > 0 && MainMod.IsGuardianItem(item))
         {
             tooltips.Insert(1, new TooltipLine(this.mod, "GuardianHealingValue", "Restores " + (int)(item.healLife * guardian.HealthHealMult) + " Guardian Health."));
         }
     }
     GuardianAccessoryEffects.CheckForAccessoryDescriptionChanges(item, tooltips);
 }
Esempio n. 10
0
        public static bool CheckForStairFloor(int px, int py)
        {
            byte State = 0;

            for (int x = -1; x < 1; x++)
            {
                Tile tile = MainMod.GetTile(px + x, py);
                if (tile != null && tile.active() && tile.type == Terraria.ID.TileID.Platforms && (tile.rightSlope() || tile.leftSlope()))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 11
0
 public override void KillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem)
 {
     if (!fail)
     {
         WorldMod.UpdateTileStateOnGuardianHouses(i, j, false);
         if (Main.tileSign[type] && GuardianBountyQuest.SignID > -1 && Sign.ReadSign(i, j, false) == GuardianBountyQuest.SignID)
         {
             GuardianBountyQuest.SignID = -1;
         }
         if (Main.halloween && (type == Terraria.ID.TileID.ShadowOrbs || type == Terraria.ID.TileID.DemonAltar) && Main.rand.Next(50) == 0)
         {
             MainMod.TriggerAnyPlayerCompanionJS();
         }
     }
 }
Esempio n. 12
0
 public override bool UseItem(Player player)
 {
     if (LoreData != null)
     {
         if (LoreData.IsComplete)
         {
             MainMod.AddClassUnlocked(ClassID, ClassModID);
             MainMod.DeleteClassLoreData(ClassID, ClassModID);
         }
         else
         {
             LoreData.OnBookUsed(player);
         }
         return(player.whoAmI == Main.myPlayer);
     }
     return(false);
 }
Esempio n. 13
0
 public override void AI()
 {
     if (!Detonated)
     {
         if (projectile.velocity.X > 0)
         {
             projectile.direction = 1;
         }
         else
         {
             projectile.direction = -1;
         }
         projectile.position += projectile.velocity;
         bool Collides = false;
         for (int x = 0; x < 2; x++)
         {
             Tile tile = MainMod.GetTile((int)((projectile.position.X + (x == 0 ? 0 : projectile.width)) * (1f / 16)), (int)(projectile.Center.Y * (1f / 16)));
             if (tile == null || (tile.active() && Main.tileSolid[tile.type]))
             {
                 Collides = true;
                 break;
             }
         }
         if (Collides)
         {
             Detonate();
         }
         else
         {
             Frame++;
             if (Frame >= 8 * 3)
             {
                 Frame -= 8 * 3;
             }
         }
     }
     else
     {
         Frame++;
         if (Frame >= (9 + 11) * 3)
         {
             projectile.Kill();
         }
     }
 }
Esempio n. 14
0
        public static bool CheckForSolidGround(int px, int py)
        {
            byte State = 0;

            for (int y = 0; y < 2; y++)
            {
                Tile tile = MainMod.GetTile(px, py + y);
                if (y == 0 && (!tile.active() || !Main.tileSolid[tile.type]))
                {
                    State++;
                }
                if (y == 1 && tile.active() && (Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]))
                {
                    State++;
                }
            }
            return(State >= 2);
        }
Esempio n. 15
0
        public static bool AnyPlatform(int tx, int ty)
        {
            byte PlatformTiles = 0;

            for (int x = -1; x <= 0; x++)
            {
                Tile t = MainMod.GetTile(tx + x, ty);
                if (t == null)
                {
                    return(false);
                }
                if (t.active() && Main.tileSolidTop[t.type])
                {
                    PlatformTiles++;
                }
            }
            return(PlatformTiles > 0);
        }
Esempio n. 16
0
 public static bool CheckForSolidBlocks(int tx, int ty, int Height = 3)
 {
     for (int x = -1; x <= 0; x++)
     {
         for (int y = -(Height - 1); y <= 0; y++)
         {
             Tile t = MainMod.GetTile(tx + x, ty + y);
             if (t == null)
             {
                 return(false);
             }
             if (t.active() && Main.tileSolid[t.type])
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 17
0
        public static void UpdateAndDraw()
        {
            if (!Active)
            {
                return;
            }
            PlayerMod player = Main.player[Main.myPlayer].GetModPlayer <PlayerMod>();

            if (!Main.playerInventory)
            {
                Active = false;
                return;
            }
            if (!Main.playerInventory || !player.MyGuardians.ContainsKey(SelectedGuardian))
            {
                Active = false;
                return;
            }
            if (player.player.chest != -1 || player.player.talkNPC > -1)
            {
                return;
            }
            GuardianData Guardian = player.MyGuardians[SelectedGuardian];

            if (PlayerMod.PlayerHasGuardianSummoned(player.player, Guardian.ID, Guardian.ModID))
            {
                Active = false;
                Main.NewText("You already have the guardian summoned. Manage it through the buttons on bellow the inventory.", Color.Red);
                return;
            }
            float HudStartX = 64, HudStartY = MainMod.InventoryEndY;

            Utils.DrawBorderString(Main.spriteBatch, Guardian.Name + "'s Possessions", new Vector2(HudStartX, HudStartY), Color.White);
            HudStartY += 24f;
            string[] Tabs = Enum.GetNames(typeof(Tab));
            float    TabX = HudStartX;

            for (int i = 0; i < Tabs.Length; i++)
            {
                Vector2 TabPos    = new Vector2(TabX, HudStartY);
                Vector2 Dimension = Utils.DrawBorderString(Main.spriteBatch, Tabs[i], TabPos, Color.White, 0.85f);
                Main.spriteBatch.Draw(Main.blackTileTexture, new Rectangle((int)TabPos.X, (int)TabPos.Y, (int)Dimension.X + 4, (int)Dimension.Y + 4), (i != (int)tab ? Color.Black : Color.White));
                TabPos.X += 2;
                bool MouseOver = false;
                if (Main.mouseX >= TabPos.X && Main.mouseX < TabPos.X + Dimension.X &&
                    Main.mouseY >= TabPos.Y && Main.mouseY < TabPos.Y + Dimension.Y)
                {
                    MouseOver = true;
                    player.player.mouseInterface = true;
                    if (Main.mouseLeft && Main.mouseLeftRelease)
                    {
                        tab = (Tab)i;
                    }
                }
                Utils.DrawBorderString(Main.spriteBatch, Tabs[i], TabPos, (MouseOver ? Color.Cyan : Color.White), 0.85f);

                TabX += Dimension.X + 4;
            }
            HudStartY += 20;
            Item HoverItem = null;

            switch (tab)
            {
            case Tab.Inventory:
            {
                for (int y = 0; y < 5; y++)
                {
                    for (int x = 0; x < 10; x++)
                    {
                        Vector2 SlotPosition = new Vector2(HudStartX, HudStartY);
                        SlotPosition.X += x * 56 * Main.inventoryScale;
                        SlotPosition.Y += y * 56 * Main.inventoryScale + 20;
                        int i = x + y * 10;
                        if (Main.mouseX >= SlotPosition.X && Main.mouseX < SlotPosition.X + 56 * Main.inventoryScale && Main.mouseY >= SlotPosition.Y && Main.mouseY < SlotPosition.Y + 56 * Main.inventoryScale)
                        {
                            Main.player[Main.myPlayer].mouseInterface = true;
                            ItemSlot.OverrideHover(Guardian.Inventory, 0, i);
                            HoverItem = Guardian.Inventory[i];
                            int LastItemID = Main.mouseItem.type;
                            if (Main.mouseLeft && Main.mouseLeftRelease)
                            {
                                if (Main.keyState.IsKeyDown(Main.FavoriteKey))
                                {
                                    Guardian.Inventory[i].favorited = !Guardian.Inventory[i].favorited;
                                }
                                else if (ItemSlot.ShiftInUse)
                                {
                                    if (!Guardian.Inventory[i].favorited && Guardian.Inventory[i].type != 0)
                                    {
                                        Item item = Main.player[Main.myPlayer].GetItem(Main.myPlayer, Guardian.Inventory[i]);
                                        Guardian.Inventory[i] = item;
                                    }
                                }
                                else
                                {
                                    ItemSlot.LeftClick(Guardian.Inventory, 0, i);
                                }
                            }
                            else
                            {
                                ItemSlot.RightClick(Guardian.Inventory, 0, i);
                            }
                            ItemSlot.MouseHover(Guardian.Inventory, 0, i);
                        }
                        ItemSlot.Draw(Main.spriteBatch, Guardian.Inventory, 0, i, SlotPosition);
                    }
                }
            }
            break;

            case Tab.Equipment:
            {
                for (int s = 0; s < 9; s++)
                {
                    Vector2 SlotPosition = new Vector2(HudStartX, HudStartY);
                    SlotPosition.Y += s * 56 * Main.inventoryScale + 20;
                    if (SlotPosition.Y + 56 * Main.inventoryScale >= Main.screenHeight)
                    {
                        SlotPosition.X += 56 * Main.inventoryScale + 20;
                        SlotPosition.Y -= SlotPosition.Y - 20 - HudStartY;
                    }
                    int context = 8;
                    if (s > 2)
                    {
                        context         = 10;
                        SlotPosition.Y += 4;
                    }
                    if (s == 8 && (!player.player.extraAccessory || (!Main.expertMode && Guardian.Equipments[8].type == 0)))
                    {
                        continue;
                    }
                    if (Main.mouseX >= SlotPosition.X && Main.mouseX < SlotPosition.X + 56 * Main.inventoryScale && Main.mouseY >= SlotPosition.Y && Main.mouseY < SlotPosition.Y + 56 * Main.inventoryScale)
                    {
                        Main.player[Main.myPlayer].mouseInterface = true;
                        ItemSlot.OverrideHover(Guardian.Equipments, context, s);
                        HoverItem = Guardian.Equipments[s];
                        if (Main.mouseLeft && Main.mouseLeftRelease)
                        {
                            /*if (Main.mouseItem.type > 0 && !giantsummon.IsGuardianItem(Main.mouseItem))
                             * {
                             *  Main.NewText("This item doesn't fit my Guardian...");
                             * }
                             * else*/
                            {
                                int  HeldItemID = Main.mouseItem.type;
                                bool Allow      = true;   //Main.mouseItem.type == 0 || (s < 3 && Main.mouseItem.modItem is Items.GuardianItemPrefab) || s >= 3;
                                //Main.mouseItem.modItem is Items.GuardianItemPrefab ||
                                if (Allow)
                                {
                                    Allow = false;
                                    switch (s)
                                    {
                                    case 0:
                                        if (Main.mouseItem.type == 0 || Main.mouseItem.headSlot > 0)
                                        {
                                            Allow = true;
                                        }
                                        break;

                                    case 1:
                                        if (Main.mouseItem.type == 0 || Main.mouseItem.bodySlot > 0)
                                        {
                                            Allow = true;
                                        }
                                        break;

                                    case 2:
                                        if (Main.mouseItem.type == 0 || Main.mouseItem.legSlot > 0)
                                        {
                                            Allow = true;
                                        }
                                        break;

                                    default:
                                        if (Main.mouseItem.type == 0 || Main.mouseItem.accessory)
                                        {
                                            Allow = true;
                                            if (Main.mouseItem.type != 0)
                                            {
                                                for (int a = 3; a < 9; a++)
                                                {
                                                    if (Guardian.Equipments[a].type == Main.mouseItem.type)
                                                    {
                                                        Allow = false;
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                                if (Allow)
                                {
                                    Main.mouseItem.favorited = false;
                                    ItemSlot.LeftClick(Guardian.Equipments, 0, s);
                                }
                                else
                                {
                                    Main.NewText("I can't do that...", Color.Red);
                                }
                            }
                            ItemSlot.MouseHover(Guardian.Equipments, context, s);
                        }
                    }
                    ItemSlot.Draw(Main.spriteBatch, Guardian.Equipments, context, s, SlotPosition);
                }
            }
            break;

            case Tab.Skins:
            {
                Vector2 SlotPosition = new Vector2(HudStartX, HudStartY + 22f);
                bool    HasSkin      = false;
                foreach (SkinReqStruct skin in Guardian.Base.SkinList)
                {
                    HasSkin = true;
                    bool IsActive          = Guardian.SkinID == skin.SkinID;
                    bool LastActive        = IsActive;
                    bool RequirementBeaten = skin.Requirement(Guardian, player.player);
                    MainMod.AddOnOffButton(SlotPosition.X, SlotPosition.Y, skin.Name, ref IsActive, RequirementBeaten, !RequirementBeaten);
                    if (IsActive != LastActive)
                    {
                        if (IsActive)
                        {
                            Guardian.SkinID = skin.SkinID;
                        }
                        else
                        {
                            Guardian.SkinID = 0;
                        }
                    }
                    SlotPosition.Y += 20;
                }
                if (!HasSkin)
                {
                    Utils.DrawBorderString(Main.spriteBatch, "This companion has no skin right now.", SlotPosition, Color.White);
                }
            }
            break;

            case Tab.Outfits:
            {
                Vector2 SlotPosition = new Vector2(HudStartX, HudStartY + 22f);
                bool    HasOutfit    = false;
                foreach (SkinReqStruct skin in Guardian.Base.OutfitList)
                {
                    HasOutfit = true;
                    bool IsActive          = Guardian.OutfitID == skin.SkinID;
                    bool LastActive        = IsActive;
                    bool RequirementBeaten = skin.Requirement(Guardian, player.player);
                    MainMod.AddOnOffButton(SlotPosition.X, SlotPosition.Y, skin.Name, ref IsActive, RequirementBeaten, !RequirementBeaten);
                    if (IsActive != LastActive)
                    {
                        if (IsActive)
                        {
                            Guardian.OutfitID = skin.SkinID;
                        }
                        else
                        {
                            Guardian.OutfitID = 0;
                        }
                    }
                    SlotPosition.Y += 20;
                }
                if (!HasOutfit)
                {
                    Utils.DrawBorderString(Main.spriteBatch, "This companion has no outfits right now.", SlotPosition, Color.White);
                }
            }
            break;
            }
            if (HoverItem != null)
            {
            }
        }
Esempio n. 18
0
        public override void Update(TerraGuardian guardian) //Add a overrideable method for custom dialogues.
        {
            this.guardian = guardian;
            bool IsWere        = CastellaBase.OnWerewolfForm(guardian);
            bool LookForVictim = false;

            switch (Step)
            {
            case 0:     //Pick behavior step;
                IgnoreCombat = true;
                if (IsWere)
                {
                    if (StepStart)
                    {
                        Main.NewText("Awooooooooooo!!");
                    }
                    if (Time >= 300)
                    {
                        ChangeStep(1);
                    }
                }
                else
                {
                    InUse = false;
                }
                break;

            case 1:
            {
                IgnoreCombat  = false;
                LookForVictim = true;
            }
            break;

            case 200:
            case 201:
            case 202:
            {
                IgnoreCombat      = true;
                AvoidItemUsage    = true;
                guardian.MoveLeft = guardian.MoveRight = guardian.Jump = guardian.MoveDown = false;
                switch (VictimType)
                {
                case TerraGuardian.TargetTypes.Guardian:
                {
                    if (!MainMod.ActiveGuardians.ContainsKey(VictimID))
                    {
                        ChangeStep(1);
                        return;
                    }
                    TerraGuardian Victim = MainMod.ActiveGuardians[VictimID];
                    Victim.IsBeingPulledByPlayer = false;
                    if (Victim.PlayerMounted)
                    {
                        Victim.ToggleMount(true, false);
                    }
                    Vector2 Position = guardian.GetGuardianBetweenHandPosition;
                    Victim.Position  = Position + new Vector2(0, Victim.Height * 0.5f);
                    Victim.Direction = -guardian.Direction;
                    Victim.Velocity  = Vector2.Zero;
                    Victim.SetFallStart();
                    Victim.AddBuff(Terraria.ID.BuffID.Cursed, 5, true);
                    if (Time == 120)
                    {
                        Victim.EnterDownedState();
                        Victim.KnockedOutCold = true;
                    }
                    if (Time >= 150)
                    {
                        ChangeStep(1);
                    }
                }
                break;

                case TerraGuardian.TargetTypes.Player:
                {
                    if (!Main.player[VictimID].active || Main.player[VictimID].dead)
                    {
                        ChangeStep(1);
                        return;
                    }
                    Player    Victim   = Main.player[VictimID];
                    PlayerMod pm       = Victim.GetModPlayer <PlayerMod>();
                    Vector2   Position = guardian.GetGuardianBetweenHandPosition;
                    Position.X      -= Victim.width * 0.5f;
                    Position.Y      -= Victim.height * 0.5f;
                    Victim.position  = Position;
                    Victim.direction = -guardian.Direction;
                    Victim.velocity  = Vector2.Zero;
                    Victim.fallStart = (int)(Victim.position.Y * (1f / 16));
                    Victim.AddBuff(Terraria.ID.BuffID.Cursed, 5);
                    if (guardian.TalkPlayerID > -1)
                    {
                        ChangeStep(201);
                    }
                    if (Step == 200 || Step == 202)
                    {
                        if (Time == 90)
                        {
                            if (Victim.statLife == 1)
                            {
                                Victim.statLife++;
                            }
                            if (!pm.KnockedOut)
                            {
                                Victim.Hurt(Terraria.DataStructures.PlayerDeathReason.ByCustomReason(Victim.name + " couldn't endure the bite."), 1, 0);
                            }
                            pm.EnterDownedState(true);
                            Victim.statLife = 1;
                            Victim.Bottom   = guardian.Position;
                            if (Main.netMode == 0 && Victim.whoAmI == Main.myPlayer)
                            {
                                foreach (TerraGuardian tg in pm.GetAllGuardianFollowers)
                                {
                                    if (tg.Active)
                                    {
                                        tg.EnterDownedState();
                                    }
                                }
                                if (guardian.IsTownNpc)
                                {
                                    guardian.TeleportHome();
                                }
                                else
                                {
                                    if (Main.rand.Next(3) != 0)
                                    {
                                        NpcMod.DespawnGuardianNPC(guardian);
                                    }
                                }
                                MainMod.DoBlackoutPlayer();
                                WorldMod.SkipTimeUntilMorning();
                                return;
                            }
                        }
                        if (Time >= 120)
                        {
                            ChangeStep(1);
                        }
                    }
                }
                break;
                }
            }
            break;
            }
            if (LookForVictim)
            {
                if (guardian.TargetID > -1 && guardian.TargetType != TerraGuardian.TargetTypes.Npc)
                {
                    AvoidItemUsage = true;
                    Rectangle GrabBox = guardian.HitBox;
                    GrabBox.Width += 8;
                    if (guardian.LookingLeft)
                    {
                        GrabBox.X -= 8;
                    }
                    switch (guardian.TargetType)
                    {
                    case TerraGuardian.TargetTypes.Guardian:
                        if (GrabBox.Intersects(MainMod.ActiveGuardians[guardian.TargetID].HitBox))
                        {
                            VictimID   = guardian.TargetID;
                            VictimType = guardian.TargetType;
                            ChangeStep(200);
                        }
                        break;

                    case TerraGuardian.TargetTypes.Player:
                        if (GrabBox.Intersects(Main.player[guardian.TargetID].getRect()))
                        {
                            VictimID   = guardian.TargetID;
                            VictimType = guardian.TargetType;
                            ChangeStep(200);
                        }
                        break;
                    }
                }
                else
                {
                    AvoidItemUsage = false;
                }
            }
        }
Esempio n. 19
0
 public override string RequestShortDescription(RequestData data)
 {
     return("slay " + (data.MaxObjectiveCount - data.ObjectiveCount) + " " + MainMod.PluralifyWord(NpcName, data.MaxObjectiveCount - data.ObjectiveCount));
 }
Esempio n. 20
0
        public override void AI()
        {
            int NextStep = NpcRecruitStep;

            switch (NpcRecruitStep)
            {
            case IdleStep:
            {
                Idle = true;
                Rectangle SightRange = new Rectangle((int)npc.Center.X, (int)npc.Center.Y, 300, 300);
                SightRange.Y -= (int)(SightRange.Height * 0.5f);
                if (npc.direction < 0)
                {
                    SightRange.X -= SightRange.Width;
                }
                DialogueDuration++;
                if (DialogueDuration >= 600)
                {
                    DialogueDuration -= 600;
                    switch (Main.rand.Next(5))
                    {
                    case 0:
                        SayMessage("*Hm... It must be around here somewhere...*");
                        break;

                    case 1:
                        SayMessage("*Come on... Show up...*");
                        break;

                    case 2:
                        SayMessage("*...It's around here... I smell It.*");
                        break;

                    case 3:
                        SayMessage("*Terrarian, where are you...*");
                        break;

                    case 4:
                        SayMessage("*Once I catch that Terrarian.... Ugh...*");
                        break;
                    }
                }
                for (int p = 0; p < 255; p++)
                {
                    if (Main.player[p].active && !Main.player[p].dead)
                    {
                        if (Main.player[p].getRect().Intersects(SightRange) && Collision.CanHitLine(npc.position, npc.width, npc.height, Main.player[p].position, Main.player[p].width, Main.player[p].height) &&
                            !Main.player[p].GetModPlayer <PlayerMod>().ControllingGuardian)
                        {
                            npc.target = p;
                            NextStep   = CallingOutPlayerStep;
                            break;
                        }
                    }
                }
            }
            break;

            case CallingOutPlayerStep:
            {
                Idle = false;
                if (DialogueDuration == 0)
                {
                    if (PlayerMod.PlayerHasGuardian(Main.player[npc.target], GuardianID, GuardianModID))
                    {
                        SayMessage("*Hey, Terrarian! Over here!*");
                    }
                    else if (Main.player[npc.target].GetModPlayer <PlayerMod>().KnockedOut)
                    {
                        SayMessage("*You there! Hang on!*");
                    }
                    else
                    {
                        if (Main.rand.Next(2) == 0)
                        {
                            SayMessage("*Hey! You there! Stop!*");
                        }
                        else
                        {
                            SayMessage("*Hey! You! Don't move!*");
                        }
                    }
                }
                if (DialogueDuration >= 120)
                {
                    NextStep = ChasingPlayerStep;
                }
                else
                {
                    DialogueDuration++;
                }
                if (Main.player[npc.target].Center.X < npc.Center.X)
                {
                    npc.direction = -1;
                }
                else
                {
                    npc.direction = 1;
                }
                if (!Main.player[npc.target].active)
                {
                    NextStep = IdleStep;
                    SayMessage("*Hm... " + (Main.player[npc.target].Male ? "He" : "She") + " disappeared...*");
                }
                else if (Main.player[npc.target].dead)
                {
                    NextStep = IdleStep;
                    SayMessage("*Well... That's... Horrible...*");
                }
            }
            break;

            case ChasingPlayerStep:
            {
                Player player = Main.player[npc.target];
                if (player.Center.X < npc.Center.X)
                {
                    MoveLeft = true;
                }
                else
                {
                    MoveRight = true;
                }
                if (!player.GetModPlayer <PlayerMod>().KnockedOut&& npc.velocity.Y == 0 && player.velocity.Y != 0)
                {
                    Jump = true;
                }
                if (PlayerMod.PlayerHasGuardian(Main.player[npc.target], GuardianID, GuardianModID) && Math.Abs(player.Center.X - npc.Center.X) < 80)
                {
                    NextStep = SpeakingToAlreadyKnownPlayer;
                }
                else if (player.getRect().Intersects(npc.getRect()))
                {
                    if (Main.halloween)
                    {
                        MainMod.TriggerCompanionJS(GuardianID);
                    }
                    if (PlayerMod.PlayerHasGuardian(Main.player[npc.target], GuardianID, GuardianModID))
                    {
                        NextStep = SpeakingToAlreadyKnownPlayer;
                    }
                    else
                    {
                        NextStep = InvestigatingPlayerStep;
                    }
                }
                if (!player.active)
                {
                    NextStep = IdleStep;
                    SayMessage("*Hm... " + (Main.player[npc.target].Male ? "He" : "She") + " disappeared...*");
                }
                else if (player.dead)
                {
                    NextStep = IdleStep;
                    SayMessage("*Damn, I'm too late...*");
                }
            }
            break;

            case InvestigatingPlayerStep:
            {
                if (DialogueDuration == 0)
                {
                    FindFrame(0);
                }
                Player player = Main.player[npc.target];
                if (player.mount.Active)
                {
                    player.mount.Dismount(player);
                }
                if (player.GetModPlayer <PlayerMod>().MountedOnGuardian)
                {
                    foreach (TerraGuardian tg in player.GetModPlayer <PlayerMod>().GetAllGuardianFollowers)
                    {
                        if (tg.Active && tg.PlayerMounted)
                        {
                            tg.ToggleMount(true, false);
                        }
                    }
                }
                player.immuneTime    = 90;
                player.immuneNoBlink = true;
                Vector2 PlayerPosition = new Vector2(npc.Center.X + 32 * npc.direction, npc.position.Y + npc.height);
                player.fullRotationOrigin = new Vector2(player.width, player.height) * 0.5f;
                player.aggro = -99999;
                if (npc.direction > 0)
                {
                    player.fullRotation = 1.570796f;
                    player.direction    = -1;
                }
                else
                {
                    player.fullRotation = -1.570796f;
                    //PlayerPosition.X *= -1;
                    player.direction = 1;
                }
                DrawInFrontOfPlayers.Add(npc.whoAmI);
                player.velocity = Vector2.Zero;
                player.Center   = PlayerPosition;
                player.statLife++;
                if (player.mount.Active)
                {
                    player.mount.Dismount(player);
                }
                player.gfxOffY = -2;
                player.AddBuff(Terraria.ID.BuffID.Cursed, 5);
                if (npc.velocity.X != 0 || npc.velocity.Y != 0)
                {
                }
                else if (player.GetModPlayer <PlayerMod>().KnockedOut)
                {
                    if (DialogueDuration == 0)
                    {
                        SayMessage("*Better I take care of those wounds first.*");
                        DialogueDuration++;
                    }
                    player.GetModPlayer <PlayerMod>().ReviveBoost++;
                }
                else
                {
                    if (DialogueDuration % 210 == 0)
                    {
                        switch (DialogueDuration / 210)
                        {
                        case 0:
                            SayMessage("*Got you! Now don't move.*");
                            break;

                        case 1:
                            SayMessage("*Hm...*");
                            break;

                        case 2:
                            SayMessage("*Interesting...*");
                            break;

                        case 3:
                            SayMessage("*Uh huh...*");
                            break;

                        case 4:
                            SayMessage("*But you're not the one I'm looking for...*");
                            break;

                        case 5:
                            NextStep                  = IntroductingToPlayerStep;
                            player.fullRotation       = 0;
                            player.fullRotationOrigin = new Vector2(40, 56) * 0.5f;
                            player.position           = npc.Bottom;
                            player.position.Y        -= player.height;
                            player.immuneNoBlink      = false;
                            break;
                        }
                    }
                    DialogueDuration++;
                }
                if (!player.active)
                {
                    NextStep = IdleStep;
                    SayMessage("*" + (Main.player[npc.target].Male ? "He" : "She") + " disappeared!*");
                }
            }
            break;

            case IntroductingToPlayerStep:
            {
                if (DialogueDuration == 0)
                {
                    Main.player[npc.target].talkNPC = npc.whoAmI;
                    DialogueDuration = 1;
                    Main.npcChatText = GetChat();
                }
                if (!Main.player[npc.target].active)
                {
                    npc.TargetClosest(false);
                    DialogueDuration = 1;
                }
                if (DialogueDuration > 1 && Main.player[npc.target].talkNPC != npc.whoAmI)
                {
                    DialogueDuration = 1;
                }
            }
            break;

            case SpeakingToAlreadyKnownPlayer:
            {
                if (DialogueDuration % 180 == 0)
                {
                    switch (DialogueDuration / 180)
                    {
                    case 0:
                        SayMessage("*I didn't expected to see you here.*");
                        break;

                    case 1:
                        SayMessage("*I think I may have caught that Terrarian's scent around here.*");
                        break;

                    case 2:
                        SayMessage("*Or maybe I accidentally caught your scent again.*");
                        break;

                    case 3:
                        SayMessage("*Anyway, If you need me, I'll be around.*");
                        break;

                    case 4:
                    {
                        NpcMod.AddGuardianMet(GuardianID, GuardianModID);
                        WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
                    }
                        return;
                    }
                }
                if (Math.Abs(Main.player[npc.target].Center.X - npc.Center.X) >= 30)
                {
                    Walk = true;
                    if (Main.player[npc.target].Center.X < npc.Center.X)
                    {
                        MoveLeft = true;
                    }
                    else
                    {
                        MoveRight = true;
                    }
                }
                else
                {
                    if (Main.player[npc.target].Center.X < npc.Center.X)
                    {
                        npc.direction = -1;
                    }
                    else
                    {
                        npc.direction = 1;
                    }
                }
                if (!Main.player[npc.target].active)
                {
                    NextStep = IdleStep;
                    SayMessage("*" + (Main.player[npc.target].Male ? "He" : "She") + " disappeared!*");
                }
                DialogueDuration++;
            }
            break;
            }
            if (NextStep != NpcRecruitStep)
            {
                NpcRecruitStep   = NextStep;
                DialogueDuration = 0;
            }
            base.AI();
        }
Esempio n. 21
0
        public static void AskWhichFishBreeWants()
        {
            Dialogue.ShowDialogueWithContinue("You forgot already? I asked you to bring me " + FishCount + " " + MainMod.PluralifyWord(FishName, FishCount) + ".");
            BreeStayQuestData data = (BreeStayQuestData)Data;

            if (data.FishGiven > 0)
            {
                byte NewFishCount = (byte)(FishCount - data.FishGiven);
                Dialogue.ShowDialogueWithContinue("Actually, since you've already given me some, you only need to bring me " + NewFishCount + " " + MainMod.PluralifyWord(FishName, NewFishCount) + ".");
            }
            Dialogue.ShowEndDialogueMessage("Don't let that get out of your head, because I dislike repeating myself.", false);
        }
Esempio n. 22
0
 public bool IsUndead(int MobID)
 {
     return(MainMod.IsUndead(MobID));
 }
Esempio n. 23
0
        public static void BreeGiveFishQuestDialogue()
        {
            BreeStayQuestData data = (BreeStayQuestData)Data;

            Dialogue.ShowDialogueWithContinue("You got the fish? Let me see them.");
            byte   Count  = 0;
            Player player = Main.LocalPlayer;

            for (int i = 0; i < 50; i++)
            {
                if (player.inventory[i].type == FishID)
                {
                    if (player.inventory[i].stack + Count > byte.MaxValue)
                    {
                        Count = 255;
                        break;
                    }
                    else
                    {
                        Count += (byte)player.inventory[i].stack;
                        if (Count >= FishCount)
                        {
                        }
                    }
                }
            }
            if (Count <= FishCount)
            {
                Dialogue.ShowDialogueWithContinue("Ah, so you've got " + Count + " of them.");
            }
            else
            {
                Dialogue.ShowDialogueWithContinue("Wow, you've got quite a lot of them.");
            }
            byte Needed = (byte)(FishCount - data.FishGiven);

            if (Needed < Count)
            {
                Dialogue.ShowDialogueWithContinue("I only need " + Needed + " of them, so let's not get greedy.");
                Count = Needed;
            }
            else if (Needed > Count)
            {
                Dialogue.ShowDialogueWithContinue("It's not enough, but you can always bring me more.");
            }
            else
            {
                Dialogue.ShowDialogueWithContinue("Ah, that's the necessary amount that I was needing.");
            }
            data.FishGiven += Count;
            for (int i = 0; i < 50; i++)
            {
                if (player.inventory[i].type == FishID)
                {
                    int StackToRemove = player.inventory[i].stack;
                    if (StackToRemove > Count)
                    {
                        StackToRemove = Count;
                    }
                    player.inventory[i].stack -= StackToRemove;
                    Count -= (byte)StackToRemove;
                    if (player.inventory[i].stack == 0)
                    {
                        player.inventory[i].SetDefaults(0);
                    }
                }
            }
            if (data.FishGiven >= FishCount)
            {
                data.QuestStep = 2;
                bool SardineAround = PlayerMod.PlayerHasGuardian(Main.LocalPlayer, GuardianBase.Sardine),
                     GlennAround   = PlayerMod.PlayerHasGuardian(Main.LocalPlayer, GuardianBase.Glenn);
                if (SardineAround && GlennAround)
                {
                    data.ConclusionState = 3;
                    Dialogue.ShowDialogueWithContinue("My family and I will enjoy eating those as dinner for two weeks.");
                }
                else if (!SardineAround && GlennAround)
                {
                    data.ConclusionState = 2;
                    Dialogue.ShowDialogueWithContinue("My son and I will enjoy eating those as dinner for two weeks, but I really wanted my husband to be here too.");
                }
                else if (SardineAround && !GlennAround)
                {
                    data.ConclusionState = 1;
                    Dialogue.ShowDialogueWithContinue("My husband and I will enjoy eating those as dinner for two weeks, but my son also should be here dinning with us...");
                }
                else
                {
                    data.ConclusionState = 0;
                    Dialogue.ShowDialogueWithContinue("This will give me a nice dinner for 2 weeks, but I really miss sharing those with my husband and son....");
                }
                Dialogue.ShowDialogueWithContinue("Yes, I know that I promissed to stay here if you brought me all those fishs. You don't need to remind me of that.");
                Dialogue.ShowDialogueWithContinue("I'll store away the things on my bag at my house, when I get back home.");
                Dialogue.ShowDialogueWithContinue("At least I will be able to relieve my back from this heavy bag.");
            }
            else
            {
                Dialogue.ShowDialogueWithContinue("You still have to bring me " + (FishCount - data.FishGiven) + " " + MainMod.PluralifyWord(FishName, FishCount - data.FishGiven) + ", if you want me to stay.");
            }
            Dialogue.ShowEndDialogueMessage("Is there anything else you want to talk to me?", false);
        }
Esempio n. 24
0
        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;
            }
        }
Esempio n. 25
0
        public override string QuestStory(QuestData rawdata)
        {
            string            Story = "";
            BreeStayQuestData data  = (BreeStayQuestData)rawdata;

            if (data.QuestStep == 0)
            {
                Story = "Bree shall talk to you about this when you speak to her, depending on your friendship level with her.";
            }
            else
            {
                Story = "Bree told me that many people in this world are asking her to stay. She seems to be really annoyed by that, and said that if I want her to stay in my world, I should bring her " + FishCount + " " + MainMod.PluralifyWord(FishName, FishCount) + ".";
            }
            if (data.QuestStep >= 2)
            {
                Story += "\n\nI brought Bree the fishs she asked for, and she looked really happy for that. ";
                switch (data.ConclusionState)
                {
                case 0:
                    Story += "She then suddenly got saddened because she ate them alone, while her husband and son were nowhere to be found.";
                    break;

                case 1:
                    Story += "She uses the fishs to dine alongside her husband, but she was partially unhappy because she couldn't have her son to dine with them, too.";
                    break;

                case 2:
                    Story += "She uses the fishs to dine alongside her son, but her worry about wether her husband is safe or not, kept her from enjoying her dinner.";
                    break;

                case 3:
                    Story += "She uses the fishs to dine alongside her husband and son, and they all enjoyed dinning together again.";
                    break;
                }
                if (data.QuestStep == 3)
                {
                    Story += "\n\nLater during that day, Bree untied the bag off her neck, and stored all her belongings on the house, she now calls hers.";
                    Story += "\n\nTHE END";
                }
            }
            return(Story);
        }
Esempio n. 26
0
        public override void AI()
        {
            if (Main.netMode < 2 && FirstFrame)
            {
                FirstFrame = false;
                if (PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID))
                {
                    GuardianData gd = PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID);
                    AgeScale = TerraGuardian.GetAgeSizeValue(gd.GetRealAgeDecimal());
                }
                else
                {
                    float AgeValue = TerraGuardian.GetAgeDecimalValue(Base.Age, Base.Birthday, GuardianGlobalInfos.LifeTime, Base.GetGroup.AgingSpeed);
                    AgeScale = TerraGuardian.GetAgeSizeValue(AgeValue);
                }
            }
            npc.scale = AgeScale * Base.GetScale;
            if (MessageTime > 0)
            {
                MessageTime--;
            }
            float Acceleration = Base.Acceleration, MaxSpeed = Base.MaxSpeed, Deceleration = Base.SlowDown,
                  JumpSpeed = Base.JumpSpeed;

            for (int i = 0; i < 255; i++)
            {
                if (Main.player[i].talkNPC == npc.whoAmI)
                {
                    Idle = false;
                    StareAt(Main.player[i]);
                    break;
                }
            }
            if (Idle)
            {
                if (npc.direction == 0)
                {
                    npc.TargetClosest(true);
                    //npc.direction = (Main.rand.NextDouble() < 0.5 ? -1 : 1);
                }
                if (IdleBehaviorTime <= 0)
                {
                    IdleBehaviorType = (byte)Main.rand.Next(2);
                    IdleBehaviorTime = 200 + Main.rand.Next(200);
                    npc.direction   *= -1;
                }
                if (IdleBehaviorType == 1)
                {
                    Walk = true;
                    if (npc.direction > 0)
                    {
                        MoveRight = true;
                    }
                    else
                    {
                        MoveLeft = true;
                    }
                }
                IdleBehaviorTime--;
                if (MoveLeft || MoveRight)
                {
                    bool HasTileInFront = false;
                    for (int x = 0; x < 3; x++)
                    {
                        for (int y = 0; y < 4; y++)
                        {
                            int  Tx = (int)npc.Center.X / 16 + (2 + x) * npc.direction, Ty = (int)npc.Bottom.Y / 16 + y;
                            Tile tile = MainMod.GetTile(Tx, Ty);
                            if (tile.active() && (Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]))
                            {
                                HasTileInFront = true;
                                break;
                            }
                        }
                    }
                    if (!HasTileInFront)
                    {
                        if (MoveRight)
                        {
                            MoveRight = false;
                            MoveLeft  = true;
                        }
                        else
                        {
                            MoveRight = true;
                            MoveLeft  = false;
                        }
                    }
                }
            }
            if (Walk)
            {
                Acceleration = TerraGuardian.WalkAcceleration;
                MaxSpeed     = TerraGuardian.WalkMaxSpeed;
                Deceleration = TerraGuardian.WalkSlowDown;
            }
            else if (Dash)
            {
                MaxSpeed     *= 2;
                Acceleration *= 2;
            }
            int MaxJumpHeight = Base.MaxJumpHeight;

            if (MoveLeft)
            {
                npc.direction   = -1;
                npc.velocity.X -= Acceleration;
                if (npc.velocity.X < -MaxSpeed)
                {
                    npc.velocity.X = -MaxSpeed;
                }
                if (npc.collideX && npc.velocity.Y == 0)
                {
                    Jump = true;
                }
            }
            if (MoveRight)
            {
                npc.direction   = 1;
                npc.velocity.X += Acceleration;
                if (npc.velocity.X > MaxSpeed)
                {
                    npc.velocity.X = MaxSpeed;
                }
                if (npc.collideX && npc.velocity.Y == 0)
                {
                    Jump = true;
                }
            }
            if (!MoveRight && !MoveLeft)
            {
                if (npc.velocity.X > 0)
                {
                    npc.velocity.X -= Deceleration;
                    if (npc.velocity.X < 0)
                    {
                        npc.velocity.X = 0;
                    }
                }
                if (npc.velocity.X < 0)
                {
                    npc.velocity.X += Deceleration;
                    if (npc.velocity.X > 0)
                    {
                        npc.velocity.X = 0;
                    }
                }
            }
            if (Jump)
            {
                if (JumpTime == 0)
                {
                    if (npc.velocity.Y == 0)
                    {
                        JumpTime       = MaxJumpHeight;
                        npc.velocity.Y = -JumpSpeed;
                    }
                }
                else
                {
                    if (npc.collideY)
                    {
                        JumpTime = 0;
                    }
                    else
                    {
                        JumpTime--;
                        npc.velocity.Y = -JumpSpeed;
                    }
                }
            }
            else
            {
                if (JumpTime != 0)
                {
                    JumpTime = 0;
                }
            }
            IsWalking = Walk;
            MoveLeft  = MoveRight = DropFromPlatform = Jump = Action = Dash = Walk = Idle = false;
            Collision.StepUp(ref npc.position, ref npc.velocity, npc.width, npc.height, ref npc.stepSpeed, ref npc.gfxOffY);
            Vector4 SlopedCollision = Collision.SlopeCollision(npc.position, npc.velocity, npc.width, npc.height, 1f, false);

            npc.position = SlopedCollision.XY();
            npc.velocity = SlopedCollision.ZW();
        }
Esempio n. 27
0
        public static void UseThrowPotion(TerraGuardian Guardian, Player Target)
        {
            int HighestHealingDifference = -1, Potion = -1;

            for (int i = 0; i < 50; i++)
            {
                if (Guardian.Inventory[i].type != 0 && Guardian.Inventory[i].potion && !MainMod.IsGuardianItem(Guardian.Inventory[i]))
                {
                    int PosHealingValue = Math.Abs((Target.statLifeMax2 - Target.statLife) - (int)(Guardian.Inventory[i].healLife * Guardian.HealthHealMult));
                    if (HighestHealingDifference == -1 || PosHealingValue < HighestHealingDifference)
                    {
                        Potion = i;
                        HighestHealingDifference = PosHealingValue;
                    }
                }
            }
            if (Potion < 0)
            {
                return;
            }
            Guardian.DoAction = new ThrowPotionAction(Target, Potion);
        }
Esempio n. 28
0
 public override string RequestShortDescription(RequestData data)
 {
     return("bring me " + data.MaxObjectiveCount + " " + MainMod.PluralifyWord(ItemName, data.MaxObjectiveCount));
 }
Esempio n. 29
0
        public override void AI()
        {
            AlexRecruitScripts.AlexNPCPosition = npc.whoAmI;
            const int Distance = 1024;
            int       SpawnPosX = AlexRecruitScripts.TombstoneTileX * 16, SpawnPosY = AlexRecruitScripts.TombstoneTileY * 16;
            bool      MoveLeft = false, MoveRight = false, Jump = false, Dash = false;
            string    TextToSay     = "";
            bool      PlayerOnFloor = false;

            npc.npcSlots = 1;
            switch ((int)npc.ai[AI_TYPE])
            {
            case 0:     //Wait for Player
                npc.TargetClosest(true);
                bool TeleportToSpawn = false;
                if (npc.target > -1)
                {
                    Player player = Main.player[npc.target];
                    PlayerIsMale = player.Male;
                    Rectangle FoV = new Rectangle(0, -150, 250, 300);
                    if (npc.direction < 0)
                    {
                        FoV.X -= FoV.Width;
                    }
                    FoV.X += (int)npc.Center.X;
                    FoV.Y += (int)npc.Center.Y;
                    if (FoV.Intersects(player.getRect()) && Collision.CanHitLine(npc.position, npc.width, npc.height, player.position, player.width, player.height))
                    {
                        //Chase Player
                        npc.ai[AI_TYPE]  = 1;
                        npc.ai[AI_TIMER] = 0;
                    }
                    else
                    {
                        //Keep looking for player
                        float XDifference = SpawnPosX - npc.Center.X, YDifference = SpawnPosY - npc.Center.Y;
                        if (Math.Abs(XDifference) >= NPC.sWidth || Math.Abs(YDifference) >= NPC.sHeight)
                        {
                            TeleportToSpawn = true;
                        }
                        else if (Math.Abs(XDifference) >= 16 || Math.Abs(YDifference) >= npc.height)
                        {
                            if (XDifference < 0)
                            {
                                MoveLeft = true;
                            }
                            else
                            {
                                MoveRight = true;
                            }
                        }
                    }
                }
                else
                {
                    TeleportToSpawn = Math.Abs(npc.Center.X - SpawnPosX) >= 16 || Math.Abs(npc.Center.Y - SpawnPosY) >= npc.height;
                }
                if (TeleportToSpawn)
                {
                    npc.position.X = AlexRecruitScripts.TombstoneTileX - npc.width * 0.5f;
                    npc.position.Y = AlexRecruitScripts.TombstoneTileY - npc.height;
                }
                break;

            case 1:
                if (npc.target == -1)
                {
                    npc.ai[AI_TYPE]  = 0;
                    npc.ai[AI_TIMER] = 0;
                }
                else
                {
                    Player player = Main.player[npc.target];
                    float  XDifference = player.Center.X - npc.Center.X, YDifference = player.Center.Y - npc.Center.Y;
                    if (Math.Abs(XDifference) >= NPC.sWidth || Math.Abs(YDifference) >= NPC.sHeight)
                    {
                        //TeleportToSpawn = true;
                        npc.ai[AI_TYPE]  = 0;
                        npc.ai[AI_TIMER] = 0;
                    }
                    else
                    {
                        if (XDifference < 0)
                        {
                            MoveLeft = true;
                        }
                        else
                        {
                            MoveRight = true;
                        }
                        if (npc.velocity.Y == 0 && Math.Abs(XDifference) <= AlexGuardianBase.Width * 2 + AlexGuardianBase.JumpSpeed * 2)
                        {
                            Jump = true;
                        }
                        if (npc.Hitbox.Intersects(player.getRect()))
                        {
                            npc.ai[AI_TYPE]  = 2;
                            npc.ai[AI_TIMER] = 0;
                            MessageTime      = 30;
                            if (Main.halloween)
                            {
                                MainMod.TriggerAlexJS();
                            }
                            if (!PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], AlexID))
                            {
                                PlayerOnFloor = true;
                            }
                            if (PlayerMod.PlayerMountedOnGuardian(Main.player[Main.myPlayer]))
                            {
                                Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().MountGuardian.ToggleMount(true, false);
                            }
                        }
                    }
                }
                break;

            case 2:     //Speaks with player
            {
                npc.npcSlots = 200;
                if (npc.target == -1)
                {
                    //Go to the chat where he asks where the player went, then return to AI 0;
                    npc.ai[AI_TYPE]  = 3;
                    npc.ai[AI_TIMER] = 0;
                }
                else
                {
                    if (npc.velocity.X != 0 || npc.velocity.Y != 0)         //Only chat when lands.
                    {
                        break;
                    }
                    int  DialogueTimer      = (int)npc.ai[AI_TIMER] / 30;
                    bool Trigger            = npc.ai[AI_TIMER] % 30 == 15;
                    bool HasAlreadyGuardian = false;
                    if (PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], AlexID))
                    {
                        HasAlreadyGuardian = true;
                    }
                    if (Trigger)
                    {
                        if (HasAlreadyGuardian)
                        {
                            switch (DialogueTimer / 5)
                            {
                            case 0:
                                TextToSay = "Hey buddy-buddy!";
                                break;

                            case 1:
                                TextToSay = "It's good to see your face again.";
                                break;

                            case 2:
                                TextToSay = "Anything you want, I'm here to protect you.";
                                break;

                            case 3:
                                NpcMod.AddGuardianMet(AlexID);
                                WorldMod.TurnNpcIntoGuardianTownNpc(npc, AlexID);
                                //npc.Transform(ModContent.NPCType<GuardianNPC.List.GiantDogGuardian>());
                                break;
                            }
                        }
                        else
                        {
                            switch (DialogueTimer)
                            {
                            case 0:
                                TextToSay = "Hello! Who are you?";
                                break;

                            case 5:
                                TextToSay = "Are you my new friend? Do you want to be my friend?";
                                break;

                            case 10:
                                TextToSay = "You're saying that I'm crushing your chest? Oh! My bad!";
                                break;

                            case 12:
                                npc.velocity.X -= 15f * npc.direction;
                                npc.velocity.Y -= AlexGuardianBase.JumpSpeed;
                                break;

                            case 15:
                                TextToSay = "By the way, I'm " + AlexGuardianBase.Name + ", let's go on an adventure.";
                                break;

                            case 20:
                                //Guardian GET!
                                PlayerMod.AddPlayerGuardian(Main.player[npc.target], AlexID);
                                PlayerMod.GetPlayerGuardian(Main.player[npc.target], AlexID).IncreaseFriendshipProgress(1);
                                WorldMod.TurnNpcIntoGuardianTownNpc(npc, AlexID);
                                NpcMod.AddGuardianMet(AlexID);
                                break;
                            }
                        }
                    }
                    if (!HasAlreadyGuardian && DialogueTimer < 12)
                    {
                        PlayerOnFloor = true;
                    }
                    if (HasAlreadyGuardian)
                    {
                        float XDifference = Main.player[Main.myPlayer].Center.X - npc.Center.X;
                        if (Math.Abs(XDifference) > AlexGuardianBase.Width)
                        {
                            if (XDifference > 0)
                            {
                                MoveRight = true;
                            }
                            else
                            {
                                MoveLeft = true;
                            }
                        }
                    }
                    npc.ai[AI_TIMER]++;
                }
            }
            break;

            case 3:     //Player disappeared/is missing chat
            {
                int  DialogueTimer = (int)npc.ai[AI_TIMER] / 30;
                bool Trigger       = npc.ai[AI_TIMER] % 30 == 15;
                if (Trigger)
                {
                    if (DialogueTimer == 3)
                    {
                        TextToSay = "Where did " + (PlayerIsMale ? "he" : "she") + " go?";
                    }
                    if (DialogueTimer == 7)
                    {
                        TextToSay = "Better I go guard the tombstone then...";
                    }
                    if (DialogueTimer == 13)
                    {
                        npc.ai[AI_TYPE]  = 0;
                        npc.ai[AI_TIMER] = 0;
                    }
                }
                npc.ai[AI_TIMER]++;
            }
            break;
            }
            if (npc.target > -1)
            {
                Player        player   = Main.player[npc.target];
                TerraGuardian guardian = player.GetModPlayer <PlayerMod>().Guardian;
                if (PlayerOnFloor)
                {
                    Vector2 NewPlayerPosition = Vector2.Zero;
                    NewPlayerPosition.X         = npc.Center.X + (26) * npc.direction;
                    NewPlayerPosition.Y         = npc.position.Y + npc.height;
                    player.fullRotationOrigin.X = player.width * 0.5f;
                    player.fullRotationOrigin.Y = player.height * 0.5f;
                    player.velocity             = Vector2.Zero;
                    if (player.mount.Active)
                    {
                        player.mount.Dismount(player);
                    }
                    if (npc.velocity.Y != 0)
                    {
                        player.fullRotation = npc.direction * MathHelper.ToRadians(45);
                    }
                    else
                    {
                        player.fullRotation = npc.direction * MathHelper.ToRadians(90);
                    }
                    player.gfxOffY       = -2;
                    player.Center        = NewPlayerPosition;
                    player.direction     = -npc.direction;
                    player.immuneTime    = 30;
                    player.immuneNoBlink = true;
                    player.fallStart     = (int)player.position.Y / 16;
                    player.breath        = player.breathMax;
                    player.statLife++;
                    if (player.statLife > player.statLifeMax2)
                    {
                        player.statLife = player.statLifeMax2;
                    }
                    if (guardian.Active)
                    {
                        if (guardian.PlayerMounted)
                        {
                            guardian.PlayerMounted = false;
                        }
                        if (guardian.PlayerControl)
                        {
                            guardian.ImmuneTime = 5;
                            guardian.Rotation   = player.fullRotation;
                            guardian.Position.X = player.position.X - guardian.Height * 0.5f * npc.direction;
                            guardian.Position.Y = player.position.Y + guardian.Width * 0.25f;// -guardian.Width * 0.5f;
                        }
                    }
                }
                else if (LastOnFloor)
                {
                    player.fullRotation       = 0;
                    player.velocity.Y        -= 6.5f;
                    player.direction          = -npc.direction;
                    player.fullRotationOrigin = Vector2.Zero;
                    if (guardian.Active)
                    {
                        if (guardian.PlayerControl)
                        {
                            guardian.Rotation   = player.fullRotation;
                            guardian.Position.X = player.position.X;
                            guardian.Position.Y = player.position.Y;// -guardian.Height * 0.5f;
                            guardian.Velocity   = player.velocity;
                        }
                    }
                }
            }
            LastOnFloor = PlayerOnFloor;
            float Acceleration = AlexGuardianBase.Acceleration, MaxSpeed = AlexGuardianBase.MaxSpeed, Deceleration = AlexGuardianBase.SlowDown,
                  JumpSpeed = AlexGuardianBase.JumpSpeed;

            if (Dash)
            {
                MaxSpeed     *= 2;
                Acceleration *= 2;
            }
            int MaxJumpHeight = AlexGuardianBase.MaxJumpHeight;

            if (MoveLeft)
            {
                npc.direction   = -1;
                npc.velocity.X -= Acceleration;
                if (npc.velocity.X < -MaxSpeed)
                {
                    npc.velocity.X = -MaxSpeed;
                }
                if (npc.collideX && npc.velocity.Y == 0)
                {
                    Jump = true;
                }
            }
            if (MoveRight)
            {
                npc.direction   = 1;
                npc.velocity.X += Acceleration;
                if (npc.velocity.X > MaxSpeed)
                {
                    npc.velocity.X = MaxSpeed;
                }
                if (npc.collideX && npc.velocity.Y == 0)
                {
                    Jump = true;
                }
            }
            if (!MoveRight && !MoveLeft)
            {
                if (npc.velocity.X > 0)
                {
                    npc.velocity.X -= Deceleration;
                    if (npc.velocity.X < 0)
                    {
                        npc.velocity.X = 0;
                    }
                }
                if (npc.velocity.X < 0)
                {
                    npc.velocity.X += Deceleration;
                    if (npc.velocity.X > 0)
                    {
                        npc.velocity.X = 0;
                    }
                }
            }
            if (Jump)
            {
                if (JumpTime == 0)
                {
                    if (npc.velocity.Y == 0)
                    {
                        JumpTime        = MaxJumpHeight;
                        npc.velocity.Y -= JumpSpeed;
                    }
                }
                else
                {
                    if (npc.collideY)
                    {
                        JumpTime = 0;
                    }
                    else
                    {
                        JumpTime--;
                        npc.velocity.Y -= JumpSpeed;
                    }
                }
            }
            else
            {
                if (JumpTime != 0)
                {
                    JumpTime = 0;
                }
            }
            float StepSpeed = 2f, gfxOffY = 0f;

            Collision.StepUp(ref npc.position, ref npc.velocity, npc.width, npc.height, ref StepSpeed, ref gfxOffY);
            Vector4 SlopedCollision = Collision.SlopeCollision(npc.position, npc.velocity, npc.width, npc.height, 1f, false);

            npc.position = SlopedCollision.XY();
            npc.velocity = SlopedCollision.ZW();
            if (TextToSay != "")
            {
                MessageTime = 300;
                MessageText = TextToSay;

                /*if (Main.netMode == 0)
                 * {
                 *  Main.NewText("Giant Dog: " + TextToSay);
                 * }
                 * else
                 * {
                 *
                 * }*/
            }
        }
Esempio n. 30
0
        public static void BreeDialogueQuestStart()
        {
            BreeStayQuestData data = (BreeStayQuestData)Data;

            Dialogue.ShowDialogueWithContinue("We have to talk now, [nickname], and I don't care if you're in a hurry or not.");
            Dialogue.ShowDialogueWithContinue("Everyone keeps nagging me to stay here. I already said that I still need to find my house!");
            Dialogue.ShowDialogueWithContinue("If you also think the same too, then bring me " + FishCount + " " + MainMod.PluralifyWord(FishName, FishCount) + " and I might consider staying.");
            Dialogue.ShowDialogueWithContinue("Otherwise, don't nag me with that anymore.");
            data.QuestStep = 1;
            QuestStartedNotification(data);
            Dialogue.ShowEndDialogueMessage("Now that's out of the way, is there something else you want to talk about?", false);
        }