Exemple #1
0
        public override void Update(TerraGuardian guardian)
        {
            if (Step > 0)
            {
                guardian.MoveLeft = guardian.MoveRight = guardian.MoveUp = guardian.MoveDown = guardian.Jump = false;
                IgnoreCombat      = true;
                CantUseInventory  = true;
            }
            switch (Step)
            {
            case 0:
                if (guardian.SittingOnPlayerMount)
                {
                    guardian.DoSitOnPlayerMount(false);
                }
                if (guardian.Velocity.Y == 0)
                {
                    WereTransform = guardian.HasFlag(GuardianFlags.Werewolf);
                    ChangeStep();
                }
                break;

            case 1:
                if (Time >= 11)
                {
                    ChangeStep();
                }
                break;

            case 2:
            case 3:
            case 4:
                if (Time >= 30)
                {
                    if (Step == 2)
                    {
                        guardian.UpdateStatus = true;
                    }
                    ChangeStep();
                }
                break;

            case 5:
                if (Time >= 15)
                {
                    InUse = false;
                }
                break;
            }
        }
 public override void Update(TerraGuardian guardian)
 {
     IgnoreCombat = true;
     if (!MountUser.mount.Active)
     {
         InUse = false;
         return;
     }
     if (TryReachingPlayer(guardian, MountUser))//guardian.HitBox.Intersects(Target.getRect()))
     {
         guardian.DoSitOnPlayerMount(true);
         InUse = false;
     }
     else
     {
         if (guardian.furniturex > -1)
         {
             guardian.LeaveFurniture();
         }
     }
 }
Exemple #3
0
        public override void Update(TerraGuardian guardian)
        {
            if (guardian.SittingOnPlayerMount)
            {
                guardian.DoSitOnPlayerMount(false);
            }
            if (guardian.PlayerMounted)
            {
                guardian.ToggleMount(true);
            }
            IgnoreCombat      = true;
            guardian.MoveLeft = guardian.MoveRight = false;
            switch (Step)
            {
            case 0:
                // guardian.HitBox.Intersects(Target.getRect()) && !guardian.BeingPulledByPlayer
                if (guardian.ItemAnimationTime == 0 && TryReachingPlayer(guardian, Target))
                {
                    ChangeStep();
                }
                else
                {
                    if (guardian.furniturex > -1)
                    {
                        guardian.LeaveFurniture();
                    }

                    /*if (Target.Center.X < guardian.CenterPosition.X)
                     *  guardian.MoveLeft = true;
                     * else
                     *  guardian.MoveRight = true;*/
                }
                break;

            case 1:
                HeldHand hand = HeldHand.Left;
                guardian.PickHandToUse(ref hand);
                Vector2 HandPosition = Vector2.Zero;
                if (hand == HeldHand.Left)
                {
                    HandPosition = guardian.GetGuardianLeftHandPosition;
                }
                else if (hand == HeldHand.Right)
                {
                    HandPosition      = guardian.GetGuardianRightHandPosition;
                    BlockOffHandUsage = true;
                }
                FocusCameraOnGuardian = true;
                if (Time >= 24)
                {
                    InUse = false;
                }
                else if (Time == 12)
                {
                    Target.Center     = HandPosition;
                    Target.velocity.X = guardian.Direction * 12.5f;
                    Target.velocity.Y = guardian.GravityDirection * -16.25f;
                    Target.fallStart  = (int)Target.position.Y / 16;
                }
                else if (Time < 12)
                {
                    Target.direction = guardian.Direction;
                    Target.Center    = HandPosition;
                    Target.fallStart = (int)Target.position.Y / 16;
                }
                break;
            }
        }
Exemple #4
0
        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;
            }
        }
Exemple #5
0
        public override void Update(TerraGuardian guardian)
        {
            switch (Step)
            {
            case 0:
            {
                const float DistanceBonus = 1;         //3
                if (Time == 0)
                {
                    if (guardian.PlayerMounted)
                    {
                        guardian.Dismount();
                    }
                    if (guardian.SittingOnPlayerMount)
                    {
                        guardian.DoSitOnPlayerMount(false);
                    }
                    if (guardian.UsingFurniture)
                    {
                        guardian.LeaveFurniture(false);
                    }
                    if (guardian.IsLeader)
                    {
                        guardian.RemoveFromCommanding();
                    }
                    string Message;
                    switch (Main.rand.Next(3))
                    {
                    default:
                        Message = "*No! Not again! Everyone, stay away from me!*";
                        break;

                    case 1:
                        Message = "*It's happening again! Don't follow me! Leave me alone!*";
                        break;

                    case 2:
                        Message = "*Save yourselves! I'm losing myself again!!*";
                        break;
                    }
                    guardian.SaySomethingCanSchedule(Message, false, Main.rand.Next(60, 180));
                    if (guardian.OwnerPos > -1 && !guardian.IsPlayerBuddy(Main.player[guardian.OwnerPos]))
                    {
                        if (!NpcMod.HasGuardianNPC(guardian.ID, guardian.ModID))
                        {
                            WorldMod.GuardianTownNPC.Add(guardian);
                        }
                        Main.player[guardian.OwnerPos].GetModPlayer <PlayerMod>().DismissGuardian(guardian.ID, guardian.ModID);
                    }
                }
                else
                {
                    bool  FleeToLeft = false;
                    float FarthestAllyLeft = 0, FarthestAllyRight = 0;
                    foreach (TerraGuardian tg in MainMod.ActiveGuardians.Values)
                    {
                        if (guardian.InPerceptionRange(tg.CenterPosition, DistanceBonus))
                        {
                            float Distance = Math.Abs(tg.Position.X - guardian.Position.X);
                            if (tg.Position.X < guardian.Position.X)
                            {
                                if (Distance > FarthestAllyLeft)
                                {
                                    FarthestAllyLeft = Distance;
                                }
                            }
                            else
                            {
                                if (Distance > FarthestAllyRight)
                                {
                                    FarthestAllyRight = Distance;
                                }
                            }
                        }
                    }
                    for (int p = 0; p < 255; p++)
                    {
                        if (Main.player[p].active && !Main.player[p].dead && guardian.InPerceptionRange(Main.player[p].Center, DistanceBonus))
                        {
                            float Distance = Math.Abs(Main.player[p].Center.X - guardian.Position.X);
                            if (Main.player[p].Center.X < guardian.Position.X)
                            {
                                if (Distance > FarthestAllyLeft)
                                {
                                    FarthestAllyLeft = Distance;
                                }
                            }
                            else
                            {
                                if (Distance > FarthestAllyRight)
                                {
                                    FarthestAllyRight = Distance;
                                }
                            }
                        }
                    }
                    FleeToLeft        = FarthestAllyLeft < FarthestAllyRight;  //Run to the position where allies have less distance from her.
                    guardian.MoveLeft = guardian.MoveRight = false;
                    guardian.WalkMode = false;
                    if (FleeToLeft)
                    {
                        guardian.MoveLeft = true;
                    }
                    else
                    {
                        guardian.MoveRight = true;
                    }
                    if (Time >= TimeUntilActivates)
                    {
                        ChangeStep();
                    }
                    IgnoreCombat = true;
                }
            }
            break;

            case 1:
            {
                IgnoreCombat = false;
                CilleBase.CilleData data = (CilleBase.CilleData)guardian.Data;
                if (CilleBase.TriggerBeastState(guardian))
                {
                    data.InBeastState = true;
                    ForcedTactic      = CombatTactic.Charge;
                    if (guardian.TargetID > -1)
                    {
                        guardian.AttackingTarget = true;
                    }
                    //InUse = false;
                }
                else
                {
                    data.InBeastState = false;
                    string Message;
                    switch (Main.rand.Next(3))
                    {
                    default:
                        Message = "*Huh? It's over... I hope I didn't hurt anyone.*";
                        break;

                    case 1:
                        Message = "*What happened? Did someone got hurt?*";
                        break;

                    case 2:
                        Message = "*I'm so glad it's over. I didn't hurt anyone, right?*";
                        break;
                    }
                    guardian.SaySomethingCanSchedule(Message, false, Main.rand.Next(30, 180));
                    InUse = false;
                }
            }
            break;
            }
        }
        public override void Update(TerraGuardian guardian)
        {
            IgnoreCombat   = true;
            AvoidItemUsage = true;
            if (guardian.SittingOnPlayerMount)
            {
                guardian.DoSitOnPlayerMount(false);
            }
            if (guardian.PlayerMounted)
            {
                guardian.ToggleMount(true);
            }
            if (guardian.IsBeingPulledByPlayer)
            {
                guardian.IsBeingPulledByPlayer = false;
            }
            guardian.MoveLeft = guardian.MoveRight = false;
            switch (Step)
            {
            case 0:
                if (guardian.furniturex > -1)
                {
                    guardian.LeaveFurniture();
                }
                if (guardian.ItemAnimationTime == 0 && ((Target != null && TryReachingPlayer(guardian, Target)) || (TargetTg != null && TryReachingTg(guardian, TargetTg))))     //guardian.HitBox.Intersects(p.getRect()) && !guardian.BeingPulledByPlayer &&
                {
                    ChangeStep();
                    if (Target != null && Target.mount.Active)
                    {
                        Target.mount.Dismount(Target);
                    }
                }
                else
                {
                    if (Time >= 300)
                    {
                        InUse = false;
                    }
                }
                break;

            case 1:
                guardian.Ducking = false;
                Vector2 HandPosition = guardian.GetGuardianBetweenHandPosition;
                BlockOffHandUsage = true;
                if (Time < 12)
                {
                    if (Target != null)
                    {
                        Target.Center     = HandPosition;
                        Target.velocity   = Vector2.Zero;
                        Target.velocity.Y = -Player.defaultGravity;
                        Target.fallStart  = (int)Target.position.Y / 16;
                    }
                    else
                    {
                        TargetTg.Position = HandPosition + new Vector2(0, TargetTg.Height * 0.5f);
                        TargetTg.Velocity = Vector2.Zero;
                        TargetTg.SetFallStart();
                    }
                    FocusCameraOnGuardian = true;
                }
                else
                {
                    if (Time == 18 && Target != null && Collision.SolidCollision(Target.position, Target.width, Target.height))
                    {
                        Target.Hurt(Terraria.DataStructures.PlayerDeathReason.ByCustomReason(" should've noticed the ceiling was low, before asking " + guardian.Name + " to lift it up..."), 20, 0);
                        guardian.DisplayEmotion(TerraGuardian.Emotions.Sweat);
                        if (Target.dead || Target.GetModPlayer <PlayerMod>().KnockedOut)
                        {
                            InUse = false;
                        }
                        ChangeStep();
                    }
                    else if (Time == 18 && TargetTg != null && Collision.SolidCollision(TargetTg.TopLeftPosition, TargetTg.Width, TargetTg.Height))
                    {
                        TargetTg.Hurt(20, 0, DeathMessage: " should've noticed the ceiling was low, before asking " + guardian.Name + " to lift it up...");
                        guardian.DisplayEmotion(TerraGuardian.Emotions.Sweat);
                        if (TargetTg.Downed || TargetTg.KnockedOut)
                        {
                            InUse = false;
                        }
                        ChangeStep();
                    }
                    else
                    {
                        FocusCameraOnGuardian = false;
                        if (Target != null)
                        {
                            Target.position.Y = HandPosition.Y - Target.height;
                            Target.position.X = HandPosition.X - Target.width * 0.5f;
                            Target.velocity.Y = -Target.gravity;
                            Target.velocity.X = 0;
                            Target.fallStart  = (int)Target.position.Y / 16;
                            if (Target.controlRight)
                            {
                                guardian.MoveRight = true;
                            }
                            if (Target.controlLeft)
                            {
                                guardian.MoveLeft = true;
                            }
                            if (Target.controlJump)
                            {
                                Target.justJumped = true;
                                Target.velocity.Y = -Player.jumpSpeed * Target.gravDir;
                                Target.jump       = Player.jumpHeight;
                                InUse             = false;
                            }
                        }
                        else
                        {
                            TargetTg.Position   = HandPosition;
                            TargetTg.Velocity.Y = -0.3f;
                            TargetTg.Velocity.X = 0;
                            TargetTg.SetFallStart();
                            if (TargetTg.LastMoveRight)
                            {
                                guardian.MoveRight = true;
                            }
                            if (TargetTg.LastMoveLeft)
                            {
                                guardian.MoveLeft = true;
                            }
                            if (TargetTg.LastJump)
                            {
                                TargetTg.Velocity.Y = -TargetTg.JumpSpeed * TargetTg.GravityDirection;
                                InUse = false;
                            }
                        }
                    }
                }
                break;

            case 2:
                FocusCameraOnGuardian = true;
                if (Time >= 22)
                {
                    if (Target != null)
                    {
                        Target.position.X = guardian.Position.X - Target.width * 0.5f;
                        Target.position.Y = guardian.Position.Y - Target.height;
                        Target.fallStart  = (int)Target.position.Y / 16;
                        Target.velocity   = Vector2.Zero;
                        Target.velocity.Y = -Player.defaultGravity;
                        InUse             = false;
                    }
                    else
                    {
                        TargetTg.Position   = guardian.Position;
                        TargetTg.Velocity.Y = 0;
                        TargetTg.Velocity.X = 0;
                        TargetTg.SetFallStart();
                    }
                }
                else
                {
                    if (Target != null)
                    {
                        Target.Center    = guardian.GetGuardianBetweenHandPosition;
                        Target.fallStart = (int)Target.position.Y / 16;
                    }
                    else
                    {
                        TargetTg.Position = guardian.GetGuardianBetweenHandPosition + new Vector2(0, TargetTg.Height * 0.5f);
                        TargetTg.SetFallStart();
                    }
                }
                break;
            }
        }