Exemplo n.º 1
0
        public override void Update(TerraGuardian guardian)
        {
            ProceedIdleAIDuringDialogue = true;
            NpcCanFacePlayer            = false;
            guardian.AddDrawMomentToPlayer(Target);
            const int BuffRefreshTime = 10 * 60;

            if (Time >= BuffRefreshTime && Time % BuffRefreshTime == 0)
            {
                int Stack = Time / BuffRefreshTime;
                if (Stack > 3)
                {
                    Stack = 3;
                }
                Target.AddBuff(ModContent.BuffType <Buffs.WellBeing>(), 3600 * 30 * Stack);
                PlayerMod pm = Target.GetModPlayer <PlayerMod>();
                if (pm.ControllingGuardian)
                {
                    pm.Guardian.AddBuff(ModContent.BuffType <Buffs.WellBeing>(), 3600 * 30 * Stack);
                }
            }
            VladimirBase.VladimirData data = (VladimirBase.VladimirData)guardian.Data;
            bool End = Target.controlJump;

            //if (PlayerMod.PlayerHasGuardianSummoned(player, guardian.ID, guardian.ModID))
            //    End = true;
            if (Main.bloodMoon)
            {
                End = false;
            }
            if (End)
            {
                InUse         = false;
                Target.Bottom = guardian.Position;
                if (guardian.BodyAnimationFrame == guardian.Base.ChairSittingFrame)
                {
                    Target.position.Y -= guardian.SpriteHeight - guardian.Base.SittingPoint.Y * guardian.Scale;
                }
                PlayerMod pm = Target.GetModPlayer <PlayerMod>();
                if (pm.ControllingGuardian)
                {
                    pm.Guardian.Position = guardian.Position;
                }
                guardian.SaySomething(((Companions.VladimirBase)guardian.Base).GetEndHugMessage(guardian));
            }
            else
            {
                if (Target.mount.Active)
                {
                    Target.mount.Dismount(Target);
                }
                PlayerMod pm       = Target.GetModPlayer <PlayerMod>();
                bool      FaceBear = (guardian.BodyAnimationFrame != 20 && guardian.BodyAnimationFrame != 21) || guardian.BodyAnimationFrame == 25;
                if (pm.ControllingGuardian)
                {
                    pm.Guardian.Position    = guardian.GetGuardianShoulderPosition;
                    pm.Guardian.Position.Y += guardian.Height * 0.5f;
                    pm.Guardian.Velocity.Y  = -pm.Guardian.Mass;
                    if (data.CarrySomeone)
                    {
                        pm.Guardian.Position.X -= 6 * guardian.Direction;
                    }
                    pm.Guardian.FallStart = (int)pm.Guardian.Position.Y / 16;
                    if (pm.Guardian.ItemAnimationTime == 0 && !pm.Guardian.MoveLeft && !pm.Guardian.MoveRight)
                    {
                        pm.Guardian.FaceDirection((guardian.Direction * (FaceBear ? -1 : 1)) == -1);
                    }
                    pm.Guardian.AddBuff(ModContent.BuffType <Buffs.Hug>(), 5, true);
                    if (pm.Guardian.KnockedOut)
                    {
                        pm.Guardian.ReviveBoost += 3;
                    }
                    if (!Main.bloodMoon)
                    {
                        pm.Guardian.ImmuneTime    = 3;
                        pm.Guardian.ImmuneNoBlink = true;
                    }
                }
                else
                {
                    Target.gfxOffY    = 0;
                    Target.Center     = guardian.GetGuardianShoulderPosition;
                    Target.velocity.Y = -Player.defaultGravity;
                    Target.fallStart  = (int)Target.Center.Y / 16;
                    if (data.CarrySomeone)
                    {
                        Target.position.X -= 6 * guardian.Direction;
                    }
                    if (Target.itemAnimation == 0 && !Target.controlLeft && !Target.controlRight)
                    {
                        Target.ChangeDir(guardian.Direction * (FaceBear ? -1 : 1));
                    }
                    Target.AddBuff(ModContent.BuffType <Buffs.Hug>(), 5);
                    if (pm.KnockedOut)
                    {
                        pm.ReviveBoost += 3;
                    }
                    if (!Main.bloodMoon)
                    {
                        Target.immuneTime    = 3;
                        Target.immuneNoBlink = true;
                    }
                }
                if ((guardian.MessageTime == 0 || Main.bloodMoon) && (Target.controlLeft || Target.controlRight || Target.controlUp || Target.controlDown || (Main.bloodMoon && Target.controlJump)))
                {
                    if (Main.bloodMoon)
                    {
                        Target.controlJump = false;
                        bool Defeated = false, Hurt = false;
                        if (pm.ControllingGuardian)
                        {
                            pm.Guardian.FriendlyDuelDefeat = true;
                            Hurt = 0 != pm.Guardian.Hurt((int)(pm.Guardian.MHP * 0.22f), guardian.Direction, false, true, " were crushed by " + guardian.Name + "'s arms.");
                            if (pm.Guardian.Downed)
                            {
                                Defeated = true;
                            }
                        }
                        else
                        {
                            Target.GetModPlayer <PlayerMod>().FriendlyDuelDefeat = true;
                            Hurt = 0 != Target.Hurt(Terraria.DataStructures.PlayerDeathReason.ByCustomReason(Target.name + " were crushed by " + guardian.Name + "'s arms."), (int)(Target.statLifeMax2 * 0.22f), guardian.Direction);
                            if (Target.dead)
                            {
                                Defeated = true;
                            }
                        }
                        if (Hurt)
                        {
                            if (!Defeated)
                            {
                                if (guardian.BodyAnimationFrame == guardian.Base.ChairSittingFrame)
                                {
                                    switch (Main.rand.Next(5))
                                    {
                                    case 0:
                                        guardian.SaySomething("*I'll crush you if you move again!*");
                                        break;

                                    case 1:
                                        guardian.SaySomething("*I'll hurt you worser than those monsters would If you keep moving!*");
                                        break;

                                    case 2:
                                        guardian.SaySomething("*I can crush you with my arms or my legs, you pick!*");
                                        break;

                                    case 3:
                                        guardian.SaySomething("*Want me to turn your bones to dust?*");
                                        break;

                                    case 4:
                                        guardian.SaySomething("*You are angering me, more than this night does!*");
                                        break;
                                    }
                                }
                                else
                                {
                                    switch (Main.rand.Next(5))
                                    {
                                    case 0:
                                        guardian.SaySomething("*Stay quiet!*");
                                        break;

                                    case 1:
                                        guardian.SaySomething("*I'll crush your bones If you continue doing that!*");
                                        break;

                                    case 2:
                                        guardian.SaySomething("*I have my arms around you, I can pull them against my body, and you wont like it!*");
                                        break;

                                    case 3:
                                        guardian.SaySomething("*Want to try that again?*");
                                        break;

                                    case 4:
                                        guardian.SaySomething("*This is what you want?*");
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                switch (Main.rand.Next(5))
                                {
                                case 0:
                                    guardian.SaySomething("*Finally! You got quiet!*");
                                    break;

                                case 1:
                                    guardian.SaySomething("*See what you made me do?!*");
                                    break;

                                case 2:
                                    guardian.SaySomething("*My mood is already bad, you didn't helped either!*");
                                    break;

                                case 3:
                                    guardian.SaySomething("*At least you stopped moving around!*");
                                    break;

                                case 4:
                                    guardian.SaySomething("*You behave better when unconscious!*");
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        guardian.SaySomething("*Press Jump button If that's enough.*");
                    }
                }
                if (Target.whoAmI == Main.myPlayer)
                {
                    MainMod.FocusCameraPosition    = guardian.CenterPosition;
                    MainMod.FocusCameraPosition.X -= Main.screenWidth * 0.5f;
                    MainMod.FocusCameraPosition.Y -= Main.screenHeight * 0.5f;
                    ChatTime--;
                    const int InitialTime = 300;
                    if (ChatTime == -1)
                    {
                        ChatTime = InitialTime;
                    }
                    else if (ChatTime < 1)
                    {
                        ChatTime = 60 * 10; // + Main.rand.Next(InitialTime)
                        FriendshipPoints++;
                        if (FriendshipPoints >= 10 + guardian.FriendshipLevel / 3)
                        {
                            FriendshipPoints = 0;
                            guardian.IncreaseFriendshipProgress(1);
                        }
                        string Message = GuardianMouseOverAndDialogueInterface.MessageParser(Main.rand.Next(10) == 0 ? guardian.Base.TalkMessage(Target, guardian) : guardian.Base.NormalMessage(Target, guardian), guardian);
                        //if (Target.talkNPC > -1 && Main.npc[Target.talkNPC].type == ModContent.NPCType<GuardianNPC.List.BearNPC>())
                        //PlayerMod pm = Target.GetModPlayer<PlayerMod>();
                        if (pm.IsTalkingToAGuardian && pm.TalkingGuardianPosition == guardian.WhoAmID)
                        {
                            GuardianMouseOverAndDialogueInterface.SetDialogue(Message);
                        }
                        else
                        {
                            //guardian.SaySomething(Message);
                        }
                    }
                    else
                    {
                    }
                }
            }
        }
Exemplo n.º 2
0
 public override void Update(TerraGuardian guardian)
 {
     if ((guardian.Position - Target.Position).Length() < 20)
     {
         guardian.WalkMode = true;
     }
     if (guardian.UsingFurniture)
     {
         guardian.LeaveFurniture(true);
     }
     guardian.StuckTimer = 0;
     if (guardian.IsBeingPulledByPlayer)
     {
         guardian.SaySomething("*Alright, I'm coming, I'm coming.*");
         InUse = false;
         return;
     }
     guardian.MoveLeft = guardian.MoveRight = false;
     Sleuthing         = false;
     if (!Target.KnockedOut && !Target.IsSleeping)
     {
         if (SleuthPercent > 70)
         {
             guardian.SaySomething("*...So close...*");
         }
         else
         {
             guardian.SaySomething(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingFail, "*I... Was just checking if you were fine.*"));
         }
         InUse = false;
         return;
     }
     if (Target.Downed)
     {
         InUse = false;
         guardian.SaySomething("*...I should have helped instead...*");
         return;
     }
     if (Math.Abs(guardian.Position.X - Target.Position.X) < 8f)
     {
         if (guardian.Velocity.X == 0 && guardian.Velocity.Y == 0)
         {
             Sleuthing            = true;
             guardian.LookingLeft = (Target.Position.X < guardian.Position.X);
             float LastSleuthPercent = SleuthPercent;
             float FillSpeed         = guardian.IsSleeping ? 0.07f : 0.2f;
             SleuthPercent += Main.rand.NextFloat() * FillSpeed;
             if (SleuthPercent >= 100)
             {
                 AlexanderBase.AlexanderData data = (AlexanderBase.AlexanderData)guardian.Data;
                 data.AddIdentifiedGuardian(Target.MyID);
                 InUse = false;
                 guardian.SaySomething(GuardianMouseOverAndDialogueInterface.MessageParser(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingProgressFinished, "*Okay, so that's how you work.*"), guardian));
                 guardian.UpdateStatus = true;
             }
             else if (SleuthPercent >= 70 && LastSleuthPercent < 70)
             {
                 guardian.SaySomething(GuardianMouseOverAndDialogueInterface.MessageParser(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingProgressNearlyDone, "*Hm... Interesting...*"), guardian));
             }
             else if (SleuthPercent >= 35 && LastSleuthPercent < 35)
             {
                 guardian.SaySomething(GuardianMouseOverAndDialogueInterface.MessageParser(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingProgress, "*Uh huh...*"), guardian));
             }
             else if (SleuthPercent > 0 && LastSleuthPercent <= 0)
             {
                 guardian.SaySomething(GuardianMouseOverAndDialogueInterface.MessageParser(Target.GetMessage(GuardianBase.MessageIDs.AlexanderSleuthingStart, "*Let's see how you work...*"), guardian));
             }
         }
     }
     else
     {
         if (Target.Position.X < guardian.Position.X)
         {
             guardian.MoveLeft = true;
         }
         else
         {
             guardian.MoveRight = true;
         }
     }
 }