diff --git a/LegendaryDogsDogBuilder.cs b/LegendaryDogsDogBuilder.cs index 1a37bb1..e6db930 100644 --- a/LegendaryDogsDogBuilder.cs +++ b/LegendaryDogsDogBuilder.cs @@ -87,12 +87,23 @@ public class LegendaryDogsDogBuilder "Stub-tailed" }; + public static string BuildTitle() + { + string Title = Titles.GetRandomElement(); + if (Title == "Good") + { + Title = BuildGoodTitle(); + } + return Title; + } + public static string BuildGoodTitle() { StringBuilder VeryGoodBuilder = new StringBuilder(); int Chance = Stat.RandomCosmetic(1, 2); if (Chance == 2) { + MessageQueue.AddPlayerMessage("Very"); VeryGoodBuilder.Append("Very"); Chance = Stat.RandomCosmetic(1, 2); while (Chance == 2) @@ -233,18 +244,6 @@ public static void AddModifiers(GameObject dog) public bool BuildObject(GameObject dog, string Context = null) { - string Title = Titles.GetRandomElement(); - if (Title == "Good") - { - Title = BuildGoodTitle(); - LegendaryDogsDogHero1 heroPart = dog.GetPart(); - heroPart.VeryGoodText = Title.ToLower(); - } - string name = BuildName(dog.DisplayName, Title); - dog.DisplayName = name; - - AddModifiers(dog); - dog.HasProperName = true; return true; diff --git a/LegendaryDogsDogHero1.cs b/LegendaryDogsDogHero1.cs index c214f1e..f66ba03 100644 --- a/LegendaryDogsDogHero1.cs +++ b/LegendaryDogsDogHero1.cs @@ -5,22 +5,21 @@ using XRL.Rules; using XRL.UI; using XRL.World.Effects; +using XRL.Messages; +using XRL.World.Encounters.EncounterObjectBuilders; namespace XRL.World.Parts { [Serializable] public class LegendaryDogsDogHero1 : IPart { - public bool bCreated; public int GoodFactionPenalty; - public string VeryGoodText; + public string Title; public LegendaryDogsDogHero1() { - if (this.VeryGoodText == null) - { - this.VeryGoodText = ""; - } + this.Title = LegendaryDogsDogBuilder.BuildTitle(); + this.GoodFactionPenalty = 0; } public override bool SameAs(IPart p) @@ -32,17 +31,25 @@ public override void Register(GameObject Object) { Object.RegisterPartEvent(this, "BeforeDeathRemoval"); Object.RegisterPartEvent(this, "AfterLookedAt"); + Object.RegisterPartEvent(this, "ObjectCreated"); base.Register(Object); } + + public override bool FireEvent(Event E) { - if (E.ID == "BeforeDeathRemoval" && this.GoodFactionPenalty > 0) + if (E.ID == "ObjectCreated") + { + ParentObject.DisplayName = LegendaryDogsDogBuilder.BuildName(ParentObject.DisplayName, Title); + LegendaryDogsDogBuilder.AddModifiers(ParentObject); + } else if (E.ID == "BeforeDeathRemoval" && this.GoodFactionPenalty > 0) { GameObject gameObjectParameter = E.GetGameObjectParameter("Killer"); if (gameObjectParameter != null && (gameObjectParameter.IsPlayer() || gameObjectParameter.IsPlayerLed())) { - Popup.Show("You murdered a " + VeryGoodText + " dog. You are cursed."); + Popup.Show("You murdered a " + this.Title + " dog. You are cursed."); + // JournalAPI.AddAccomplishment("You murdered the " + ParentObject. + str + ".", HistoricStringExpander.ExpandString("In the month of " + Calendar.getMonth() + " of " + Calendar.getYear().ToString() + ", brave =name= slew " + str + " in single combat."), muralCategory: JournalAccomplishment.MuralCategory.Slays, muralWeight: JournalAccomplishment.MuralWeight.Low); } } else if (E.ID == "AfterLookedAt" && ParentObject.DisplayName.Contains("Loveable")) diff --git a/LegendaryDogsGivesRep.cs b/LegendaryDogsGivesRep.cs index a9f3312..2e3cfde 100644 --- a/LegendaryDogsGivesRep.cs +++ b/LegendaryDogsGivesRep.cs @@ -20,9 +20,10 @@ public void ReplaceFactions() { GivesRep RepPart = this; GameObject dog = ParentObject; + LegendaryDogsDogHero1 HeroPart = dog.GetPart(); - if (HeroPart.GoodFactionPenalty > 0) + if (ParentObject.DisplayName.Contains("Good")) { RepPart.ResetRelatedFactions(); foreach (Faction Faction in Factions.loop()) @@ -32,7 +33,7 @@ public void ReplaceFactions() FriendorFoe FoF = new FriendorFoe(); FoF.faction = Faction.Name; FoF.status = "friend"; - FoF.reason = "for being a " + HeroPart.VeryGoodText + " dog"; + FoF.reason = "for being a " + HeroPart.Title + " dog"; RepPart.relatedFactions.Add(FoF); if (dog.pBrain.FactionFeelings.ContainsKey(Faction.Name)) { diff --git a/LegendaryDogsWorgGivesRep.cs b/LegendaryDogsWorgGivesRep.cs index 936954e..2720097 100644 --- a/LegendaryDogsWorgGivesRep.cs +++ b/LegendaryDogsWorgGivesRep.cs @@ -19,7 +19,6 @@ public void ReplaceFactions() { GivesRep RepPart = this; GameObject dog = ParentObject; - LegendaryDogsWorgHero1 HeroPart = dog.GetPart(); foreach (FriendorFoe FoF in RepPart.relatedFactions) { @@ -34,13 +33,13 @@ public void ReplaceFactions() } } - public override bool HandleEvent(GetShortDescriptionEvent E) - { - if (!FixedRep) { - ReplaceFactions(); - FixedRep = true; - } - return base.HandleEvent(E); - } +public override bool HandleEvent(GetShortDescriptionEvent E) +{ + if (!FixedRep) { + ReplaceFactions(); + FixedRep = true; + } + return base.HandleEvent(E); +} } }