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 { } } } }
public override void Update(TerraGuardian guardian) { if (TargetPlayer != null) { if (TargetPlayer.dead || !TargetPlayer.active) { InUse = false; return; } } if (TargetGuardian != null) { if (!TargetGuardian.Active || TargetGuardian.Downed) { InUse = false; return; } } switch (Step) { case 0: { if (StepStart) { LastPlayerFollower = guardian.OwnerPos > -1; } Rectangle TargetHitbox; Vector2 TargetPosition; if (guardian.UsingFurniture) { guardian.LeaveFurniture(); } if (TargetPlayer != null) { TargetPosition = TargetPlayer.Center; TargetHitbox = TargetPlayer.getRect(); } else { TargetPosition = TargetGuardian.CenterPosition; TargetHitbox = TargetGuardian.HitBox; } if (TargetHitbox.Intersects(guardian.HitBox) || Time >= 10 * 60) { ChangeStep(); guardian.AddFlag(GuardianFlags.IgnoreGfx); } else if (guardian.Position.X > TargetPosition.X) { guardian.MoveLeft = true; guardian.MoveRight = false; } else { guardian.MoveRight = true; guardian.MoveLeft = false; } } break; case 1: { if (guardian.OwnerPos > -1 != LastPlayerFollower) { InUse = false; return; } guardian.IsBeingPulledByPlayer = false; if (!ByPlayerOrder && Time >= DurationTime) { if (TargetPlayer != null) { guardian.Position = TargetPlayer.Bottom; } else { guardian.Position = TargetGuardian.Position; } InUse = false; return; } guardian.MoveLeft = guardian.MoveRight = guardian.Jump = false; guardian.ChangeIdleAction(TerraGuardian.IdleActions.Wait, 300); Vector2 MountedPosition = guardian.Base.GetBetweenHandsPositionVector(Reviving ? guardian.Base.ReviveFrame : guardian.Base.PlayerMountedArmAnimation); MountedPosition.X = MountedPosition.X - guardian.Base.SpriteWidth * 0.5f; Vector2 HauntPosition = Vector2.Zero; if (TargetPlayer != null) { if (Reviving) { if (guardian.ItemAnimationTime == 0) { guardian.Direction = -TargetPlayer.direction; } HauntPosition = TargetPlayer.Center; } else { if (guardian.ItemAnimationTime == 0) { guardian.Direction = TargetPlayer.direction; } HauntPosition = TargetPlayer.position; } if (guardian.Direction > 0) { MountedPosition.X *= -1; } HauntPosition.X += TargetPlayer.width * 0.5f; HauntPosition.Y += TargetPlayer.height + (guardian.Base.SpriteHeight - MountedPosition.Y - 30) * guardian.Scale; HauntPosition.X += (MountedPosition.X - 6 * guardian.Direction) * guardian.Scale; guardian.AddDrawMomentToPlayer(TargetPlayer); TargetPlayer.AddBuff(Terraria.ModLoader.ModContent.BuffType <Buffs.GhostFoxHaunts.FriendlyHaunt>(), 5); Reviving = TargetPlayer.GetModPlayer <PlayerMod>().KnockedOut; } else { if (Reviving) { if (guardian.ItemAnimationTime == 0) { guardian.Direction = -TargetGuardian.Direction; } HauntPosition = TargetGuardian.CenterPosition; } else { if (guardian.ItemAnimationTime == 0) { guardian.Direction = TargetGuardian.Direction; } HauntPosition = TargetGuardian.Position; } if (guardian.Direction > 0) { MountedPosition.X *= -1; } HauntPosition.X += MountedPosition.X * guardian.Scale - TargetGuardian.Width * 0.2f * guardian.Direction; //HauntPosition.X += (MountedPosition.X - (TargetGuardian.Width * 0.5f - 8) * guardian.Direction) * guardian.Scale; //- 8 HauntPosition.Y += MountedPosition.Y * guardian.Scale - TargetGuardian.Height * 0.95f; guardian.AddDrawMomentToTerraGuardian(TargetGuardian); TargetGuardian.AddBuff(Terraria.ModLoader.ModContent.BuffType <Buffs.GhostFoxHaunts.FriendlyHaunt>(), 5, true); Reviving = TargetGuardian.KnockedOut || TargetGuardian.IsUsingBed; } guardian.Velocity = Vector2.Zero; guardian.Position = HauntPosition; } break; } LastPlayerFollower = guardian.OwnerPos > -1; }