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 GuardianUpdateScript(TerraGuardian guardian) { CilleData data = (CilleData)guardian.Data; if (data.InBeastState) { if (guardian.KnockedOut) { data.InBeastState = false; } else if (!TriggerBeastState(guardian)) { data.InBeastState = false; if (!guardian.KnockedOut && !guardian.Downed) { 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)); } /*if (!guardian.DoAction.InUse) * { * data.InBeastState = false; * }*/ } else { 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 { if (TriggerBeastState(guardian)) { if (!guardian.DoAction.InUse) { guardian.StartNewGuardianAction(new Companions.Creatures.Cille.BeastStateAction(), BeastStateID); } } } }
public override void Update(TerraGuardian guardian) { LiebreBase.ReaperGuardianData data = (LiebreBase.ReaperGuardianData)guardian.Data; switch (Step) { case 0: if (StepStart) { SoulsValue = data.SoulsLoaded; if (SoulsValue >= LiebreBase.MaxSoulsContainedValue) { guardian.SaySomething("*I must go, now!*"); } else if (SoulsValue >= LiebreBase.MaxSoulsContainedValue * 0.9f) { guardian.SaySomething("*I'll unload those souls, I feel like I'm reaching my capacity.*"); } else { guardian.SaySomething("*I'll be right back.*"); } } IgnoreCombat = true; if (Main.rand.NextDouble() < 0.333) { Dust.NewDust(guardian.TopLeftPosition, guardian.Width, guardian.Height, 192, 0, -0.2f, Scale: Main.rand.NextFloat(0.8f, 1.2f)); } if (Time >= 3 * 60) { ChangeStep(); data.SoulsLoaded = 0; Invisibility = true; LastWasPlayerMounted = guardian.PlayerMounted; guardian.ToggleMount(true); guardian.ClearMessagesSaid(); } break; case 1: Invisibility = true; IgnoreCombat = true; Inactivity = true; if (guardian.OwnerPos > -1) { guardian.Position = Main.player[guardian.OwnerPos].Bottom; } if (Time >= 10 * 60) { ChangeStep(); } break; case 2: Invisibility = false; IgnoreCombat = false; Inactivity = false; if (StepStart) { guardian.Spawn(); if (guardian.OwnerPos > -1) { guardian.Position = Main.player[guardian.OwnerPos].Bottom; if (LastWasPlayerMounted) { guardian.ToggleMount(true, false); } } } if (Time >= 30) { if (SoulsValue >= LiebreBase.MaxSoulsContainedValue) { guardian.SaySomething("*I felt like about to blow...*"); } else if (SoulsValue >= LiebreBase.MaxSoulsContainedValue * 0.9f) { guardian.SaySomething("*I'm glad I managed to do the delivery in time.*"); } else { guardian.SaySomething("*I returned.*"); } } if (Time % 10 == 0) { float HeightVal = Time / 10 * 0.1f * guardian.Height; for (int i = -1; i < 2; i++) { Vector2 EffectPosition = new Vector2(guardian.Position.X, guardian.Position.Y); EffectPosition.Y -= HeightVal; EffectPosition.X += guardian.Width * 0.6f * i; Dust.NewDust(EffectPosition, 1, 1, 192, 0, -0.2f, 192, Scale: Main.rand.NextFloat(0.8f, 1.2f)); } } if (Time >= 100) { { float CapacityPercentage = (float)SoulsValue / LiebreBase.MaxSoulsContainedValue; int BuffDuration = (int)(CapacityPercentage * 900) * 60; if (SoulsValue > LiebreBase.MaxSoulsContainedValue) { BuffDuration = (int)(BuffDuration * 0.75f); } for (int i = 0; i < CapacityPercentage * 5; i++) { int BuffID = Utils.SelectRandom(Main.rand, new int[] { Terraria.ID.BuffID.Lifeforce, Terraria.ID.BuffID.Regeneration, Terraria.ID.BuffID.Endurance, Terraria.ID.BuffID.ManaRegeneration, Terraria.ID.BuffID.Mining, Terraria.ID.BuffID.ObsidianSkin, Terraria.ID.BuffID.Thorns }); for (int p = 0; p < 255; p++) { if (Main.player[p].active && !guardian.IsPlayerHostile(Main.player[p])) { Main.player[p].AddBuff(BuffID, BuffDuration); } } foreach (TerraGuardian g in MainMod.ActiveGuardians.Values) { if (g.OwnerPos == guardian.OwnerPos && !g.IsGuardianHostile(guardian)) { g.AddBuff(BuffID, BuffDuration); } } } guardian.SaySomethingCanSchedule("*Take this blessing as a reward for helping me.*"); } guardian.DoAction.InUse = false; } break; } }