public override void TryExecute()
        {
            float customMultiplier = LevelPawnSettings.xpMultiplier > 0 ? LevelPawnSettings.xpMultiplier : 0.5f;
            float xpWon            = pawn.skills.GetSkill(skill).XpRequiredForLevelUp *customMultiplier *((float)Verse.Rand.Range(0.5f, 1.5f));

            xpWon = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, xpWon);

            pawn.skills.Learn(skill, xpWon, true);
            Viewer.TakeViewerCoins(pointsWager);
            Viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);

            SkillRecord record       = pawn.skills.GetSkill(skill);
            string      increaseText = $" Level {record.levelInt}: {(int)record.xpSinceLastLevel} / {(int)record.XpRequiredForLevelUp}.";

            float   percent     = 35;
            string  passionPlus = "";
            Passion passion     = record.passion;

            if (passion == Passion.Minor)
            {
                percent     = 100;
                passionPlus = "+";
            }
            if (passion == Passion.Major)
            {
                percent     = 150;
                passionPlus = "++";
            }

            VariablesHelpers.SendPurchaseMessage($"Increasing skill {skill.LabelCap} for {pawn.LabelCap} with {pointsWager} coins wagered and ({(int)xpWon} * {percent}%){passionPlus} {(int)xpWon * (percent / 100f)} xp purchased by {Viewer.username}. {increaseText}");
            string text = Helper.ReplacePlaceholder("TwitchStoriesDescription55".Translate(), colonist: pawn.Name.ToString(), skill: skill.defName, first: Math.Round(xpWon).ToString());

            Current.Game.letterStack.ReceiveLetter("TwitchToolkitIncreaseSkill".Translate(), text, LetterDefOf.PositiveEvent, pawn);
        }
Beispiel #2
0
        public override void TryExecute()
        {
            pawn.story.traits.GainTrait(trait);

            TraitDegreeData traitDegreeData = traitDef.DataAtDegree(buyableTrait.degree);

            if (traitDegreeData != null)
            {
                if (traitDegreeData.skillGains != null)
                {
                    foreach (KeyValuePair <SkillDef, int> pair in traitDegreeData.skillGains)
                    {
                        SkillRecord skill = pawn.skills.GetSkill(pair.Key);
                        int         num   = TraitHelpers.FinalLevelOfSkill(pawn, pair.Key);
                        skill.Level = num;
                    }
                }
            }

            Viewer.TakeViewerCoins(storeIncident.cost);
            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);
            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} just added the trait " + trait.Label + " to " + pawn.Name + ".");
            string text = $"{Viewer.username} has purchased " + trait.LabelCap + " for " + pawn.Name + ".";

            Current.Game.letterStack.ReceiveLetter("Trait", text, LetterDefOf.PositiveEvent, pawn);
        }
Beispiel #3
0
        public override void TryExecute()
        {
            if (pawn.gender == Gender.Female)
            {
                pawn.gender = Gender.Male;
            }
            else
            {
                pawn.gender = Gender.Female;
            }

            pawn.story.hairColor = PawnHairColors.RandomHairColor(pawn.story.SkinColor, pawn.ageTracker.AgeBiologicalYears);
            pawn.story.hairDef   = PawnHairChooser.RandomHairDefFor(pawn, FactionDefOf.PlayerColony);

            if (pawn.story.adulthood != null)
            {
                pawn.story.bodyType = pawn.story.adulthood.BodyTypeFor(pawn.gender);
            }
            else if (Rand.Value < 0.5f)
            {
                pawn.story.bodyType = BodyTypeDefOf.Thin;
            }
            else
            {
                pawn.story.bodyType = ((pawn.gender != Gender.Female) ? BodyTypeDefOf.Male : BodyTypeDefOf.Female);
            }

            viewer.TakeViewerCoins(storeIncident.cost);
            viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);
            VariablesHelpers.SendPurchaseMessage($"@{viewer.username} has just swapped genders to " + pawn.gender.GetLabel() + ".", separateChannel);
            string text = $"{viewer.username} has just swapped genders to " + pawn.gender.GetLabel() + ".";

            Current.Game.letterStack.ReceiveLetter("GenderSwap", text, LetterDefOf.PositiveEvent, pawn);
        }
Beispiel #4
0
        public override void TryExecute()
        {
            Trait traitToRemove = pawn.story.traits.allTraits.Find(s => s.def.defName == buyableTrait.def.defName);

            if (traitToRemove != null)
            {
                pawn.story.traits.allTraits.Remove(traitToRemove);

                TraitDegreeData traitDegreeData = traitToRemove.def.DataAtDegree(buyableTrait.degree);

                if (traitDegreeData != null)
                {
                    if (traitDegreeData.skillGains != null)
                    {
                        foreach (KeyValuePair <SkillDef, int> pair in traitDegreeData.skillGains)
                        {
                            SkillRecord skill = pawn.skills.GetSkill(pair.Key);
                            skill.Level -= pair.Value;
                        }
                    }
                }
            }
            else
            {
                return;
            }
            Viewer.TakeViewerCoins(storeIncident.cost);
            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);
            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} just removed the trait " + buyableTrait.label.CapitalizeFirst() + " from " + pawn.Name + ".");
            string text = $"{Viewer.username} has purchased trait removal of " + buyableTrait.label.CapitalizeFirst() + " from " + pawn.Name + ".";

            Current.Game.letterStack.ReceiveLetter("Trait", text, LetterDefOf.PositiveEvent, pawn);
        }
Beispiel #5
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 4)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            GameComponentPawns gameComponent = Current.Game.GetComponent <GameComponentPawns>();

            if (!gameComponent.HasUserBeenNamed(viewer.username))
            {
                Toolkit.client.SendMessage($"@{viewer.username} you must be in the colony to use this command.", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[3],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            string          skillKind = command[2].ToLower();
            List <SkillDef> allSkills = DefDatabase <SkillDef> .AllDefs.Where(s =>
                                                                              string.Join("", s.defName.Split(' ')).ToLower() == skillKind ||
                                                                              string.Join("", s.label.Split(' ')).ToLower() == skillKind
                                                                              ).ToList();

            if (allSkills.Count < 1)
            {
                Toolkit.client.SendMessage($"@{viewer.username} skill {skillKind} not found.", separateChannel);
                return(false);
            }

            skill = allSkills[0];
            pawn  = gameComponent.PawnAssignedToUser(viewer.username);

            if (pawn.skills.GetSkill(skill).TotallyDisabled)
            {
                Toolkit.client.SendMessage($"@{viewer.username} skill {skillKind} disabled on your pawn.", separateChannel);
                return(false);
            }

            if (pawn.skills.GetSkill(skill).levelInt >= 20)
            {
                Toolkit.client.SendMessage($"@{viewer.username} skill {skillKind} disabled on your pawn.", separateChannel);
                return(false);
            }

            return(true);
        }
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            ToolkitPatchLogger.Log(incidentDef.defName, "Checking if possible..");
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            ToolkitPatchLogger.Log(incidentDef.defName, $"Got the points wager of '{pointsWager}' and incident of '{storeIncident.abbreviation}:{storeIncident.defName}'");

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            ToolkitPatchLogger.Log(incidentDef.defName, $"Target found '{target.Tile}'");

            parms        = StorytellerUtility.DefaultParmsNow(categoryDef, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);
            if (raidStratDef != null)
            {
                parms.raidStrategy = raidStratDef;
            }
            if (pawnArrivalModeDef != null)
            {
                parms.raidArrivalMode = pawnArrivalModeDef;
            }

            worker     = Activator.CreateInstance <T>();
            worker.def = incidentDef;

            bool success = worker.CanFireNow(parms);

            if (!success)
            {
                WorkerCanFireCheck.CheckDefaultFireNowConditions(worker, parms, incidentDef);
            }

            ToolkitPatchLogger.Log(incidentDef.defName, $"Can fire with params '{parms.ToString()}' on worker {worker.ToString()}? {success}");

            return(success);
        }
        public override void TryExecute()
        {
            worker.TryExecute(parms);

            Viewer.TakeViewerCoins(storeIncident.cost);
            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);

            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} is visiting the colony.");
        }
Beispiel #8
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 4)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[3],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            string animalKind = command[2].ToLower();


            List <PawnKindDef> allAnimals = DefDatabase <PawnKindDef> .AllDefs.Where(
                s => s.RaceProps.Animal &&
                string.Join("", s.defName.Split(' ')).ToLower() == animalKind
                ).ToList();

            if (allAnimals.Count < 1)
            {
                Toolkit.client.SendMessage($"@{viewer.username} no animal {animalKind} found.", separateChannel);
                return(false);
            }

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            float points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, StorytellerUtility.DefaultThreatPointsNow(target));

            pawnKind = allAnimals[0];
            int num = ManhunterPackIncidentUtility.GetAnimalsCount(pawnKind, points);

            worker = new IncidentWorker_SpecificAnimalsWanderIn(null, pawnKind, true, num, false, true);

            worker.def = IncidentDef.Named("FarmAnimalsWanderIn");

            float defaultThreatPoints = StorytellerUtility.DefaultSiteThreatPointsNow();

            parms        = StorytellerUtility.DefaultParmsNow(worker.def.category, target);
            parms.points = points;
            return(worker.CanFireNow(parms));
        }
        public override void TryExecute()
        {
            worker.TryExecute(parms);

            Viewer.TakeViewerCoins(storeIncident.cost);
            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);

            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} is being held prisoner at another faction.");
        }
        public override void TryExecute()
        {
            worker.TryExecute(parms);

            Viewer.TakeViewerCoins(storeIncident.cost);
            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);

            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} has escaped from maximum security space prison.");
        }
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                VariablesHelpers.ViewerDidWrongSyntax(viewer.username, storeIncident.syntax, separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                ToolkitPatchLogger.Log(LOGGER_NAME, "Cannot fire custom manhunter. No valid points wagered");
                return(false);
            }

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                ToolkitPatchLogger.Log(LOGGER_NAME, "Cannot fire custom manhunter. No valid tile");
                return(false);
            }

            parms        = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.RaidBeacon, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);

            IEnumerable <string> animals = Settings.AnimalMap.Where(x => x.Value).Select(x => x.Key);

            ToolkitPatchLogger.Log(LOGGER_NAME, $"{animals.Count()}/{Settings.AnimalMap.Count} animals for selection.");

            string animal = animals.RandomElement();

            ToolkitPatchLogger.Log(LOGGER_NAME, $"Chose animal {animal} for the attack beast");

            ThingDef def = ThingDef.Named(animal);

            worker     = new CustomManhunterIncidentWorker(PawnKindDef.Named(animal));
            worker.def = IncidentDef.Named("BeastAttack");

            bool success = worker.CanFireNow(parms);

            if (!success)
            {
                WorkerCanFireCheck.CheckDefaultFireNowConditions(worker, parms, worker.def);
            }

            return(success);
        }
 public override void TryExecute()
 {
     if (worker.TryExecute(parms))
     {
         viewer.TakeViewerCoins(pointsWager);
         viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
         VariablesHelpers.SendPurchaseMessage($"Starting raid with {pointsWager} points wagered and {(int)parms.points} raid points purchased by {viewer.username}", separateChannel);
         return;
     }
     Toolkit.client.SendMessage($"@{viewer.username} not enough points spent for raid.", separateChannel);
 }
Beispiel #13
0
        public override void TryExecute()
        {
            trait = new Trait(traitDef, PawnGenerator.RandomTraitDegree(traitDef));
            pawn.story.traits.GainTrait(trait);
            viewer.TakeViewerCoins(storeIncident.cost);
            viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);
            VariablesHelpers.SendPurchaseMessage($"{viewer.username} has purchased " + trait.LabelCap + " for " + pawn.Name + ".", separateChannel);
            string text = $"@{viewer.username} just added the trait " + traitDef.LabelCap + " to " + pawn.Name + ".";

            Current.Game.letterStack.ReceiveLetter("Trait", text, LetterDefOf.PositiveEvent, pawn);
        }
Beispiel #14
0
 public override void TryExecute()
 {
     if (worker.TryExecute(parms))
     {
         viewer.TakeViewerCoins(pointsWager);
         viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
         VariablesHelpers.SendPurchaseMessage($"Spawning animal {pawnKind.LabelCap} with {pointsWager} coins wagered and {(int)parms.points} animal points purchased by {viewer.username}", separateChannel);
         return;
     }
     Toolkit.client.SendMessage($"@{viewer.username} not enough points spent for diseases.", separateChannel);
 }
 public override void TryExecute()
 {
     if (worker.TryExecute(parms))
     {
         Viewer.TakeViewerCoins(pointsWager);
         Viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
         VariablesHelpers.SendPurchaseMessage($"Starting infestation raid with {pointsWager} points wagered and {(int)parms.points} raid points purchased by {Viewer.username}", separateChannel);
         return;
     }
     Toolkit.client.SendMessage($"@{Viewer.username} could not generate parms for infestation.", separateChannel);
 }
 public override void TryExecute()
 {
     if (worker.TryExecute(parms))
     {
         Viewer.TakeViewerCoins(pointsWager);
         Viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
         VariablesHelpers.SendPurchaseMessage($"Starting predator pack with {pointsWager} points wagered and {(int)parms.points} raid points purchased by {Viewer.username}");
         return;
     }
     TwitchWrapper.SendChatMessage($"@{Viewer.username} could not generate parms for manhunter pack.");
 }
Beispiel #17
0
 public override void TryExecute()
 {
     if (worker.TryExecute(parms))
     {
         Viewer.TakeViewerCoins(pointsWager);
         Viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
         VariablesHelpers.SendPurchaseMessage($"Starting {worker.def.LabelCap} with {pointsWager} points wagered and {(int)parms.points} disease points purchased by {Viewer.username}");
         return;
     }
     TwitchWrapper.SendChatMessage($"@{Viewer.username} not enough points spent for diseases.");
 }
Beispiel #18
0
        public override void TryExecute()
        {
            System.Random rand  = new System.Random();
            float         xpWon = pawn.skills.GetSkill(skill).XpRequiredForLevelUp *((float)rand.Next(50, 150) / 100f);

            pawn.skills.Learn(skill, xpWon, true);
            viewer.TakeViewerCoins(pointsWager);
            viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
            VariablesHelpers.SendPurchaseMessage($"Increasing skill for {pawn.LabelCap} with {pointsWager} coins wagered and {(int)xpWon} xp for {skill.defName} purchased by {viewer.username}", separateChannel);
            string text = Helper.ReplacePlaceholder("TwitchStoriesDescription55".Translate(), colonist: pawn.Name.ToString(), skill: skill.defName, first: Math.Round(xpWon).ToString());

            Current.Game.letterStack.ReceiveLetter("TwitchToolkitIncreaseSkill".Translate(), text, LetterDefOf.PositiveEvent, pawn);
        }
Beispiel #19
0
        public override void TryExecute()
        {
            ThingDef itemDef   = ThingDef.Named("DropPodIncoming");
            Thing    itemThing = new Thing();

            ThingDef stuff        = null;
            ThingDef itemThingDef = ThingDef.Named(item.defname);

            if (itemThingDef.MadeFromStuff)
            {
                if (!(from x in GenStuff.AllowedStuffsFor(itemThingDef, TechLevel.Undefined)
                      where !PawnWeaponGenerator.IsDerpWeapon(itemThingDef, x)
                      select x).TryRandomElementByWeight((ThingDef x) => x.stuffProps.commonality, out stuff))
                {
                    stuff = GenStuff.RandomStuffByCommonalityFor(itemThingDef, TechLevel.Undefined);
                }
            }

            itemThing = ThingMaker.MakeThing(itemThingDef, (stuff != null) ? stuff : null);

            QualityCategory q = new QualityCategory();

            if (itemThing.TryGetQuality(out q))
            {
                ItemHelper.setItemQualityRandom(itemThing);
            }

            IntVec3 vec;

            if (itemThingDef.Minifiable)
            {
                itemThingDef = itemThingDef.minifiedDef;
                MinifiedThing minifiedThing = (MinifiedThing)ThingMaker.MakeThing(itemThingDef, null);
                minifiedThing.InnerThing = itemThing;
                minifiedThing.stackCount = quantity;
                vec = Helper.Rain(itemDef, minifiedThing);
            }
            else
            {
                itemThing.stackCount = quantity;
                vec = Helper.Rain(itemDef, itemThing);
            }

            string letter = Helper.ReplacePlaceholder("TwitchStoriesDescription80".Translate(), from: viewer.username, amount: quantity.ToString(), item: item.abr.CapitalizeFirst());

            Helper.CarePackage(letter, LetterDefOf.PositiveEvent, vec);

            viewer.TakeViewerCoins(price);
            viewer.CalculateNewKarma(storeIncident.karmaType, price);
            VariablesHelpers.SendPurchaseMessage(Helper.ReplacePlaceholder("TwitchToolkitItemPurchaseConfirm".Translate(), amount: quantity.ToString(), item: item.abr, viewer: viewer.username), separateChannel);
        }
Beispiel #20
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 4)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}");
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[3],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            string diseaseLabel = command[2].ToLower();

            worker = new IncidentWorker_DiseaseHuman();
            List <IncidentDef> allDiseases = DefDatabase <IncidentDef> .AllDefs.Where(s =>
                                                                                      s.category == IncidentCategoryDefOf.DiseaseHuman &&
                                                                                      string.Join("", s.LabelCap.RawText.Split(' ')).ToLower() == diseaseLabel
                                                                                      ).ToList();

            if (allDiseases.Count < 1)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} no disease {diseaseLabel} found.");
                return(false);
            }

            allDiseases.Shuffle();
            worker.def = allDiseases[0];

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            float defaultThreatPoints = StorytellerUtility.DefaultSiteThreatPointsNow();

            parms        = StorytellerUtility.DefaultParmsNow(worker.def.category, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, StorytellerUtility.DefaultThreatPointsNow(target));
            return(worker.CanFireNow(parms));
        }
        public override void TryExecute()
        {
            float customMultiplier = CustomSettings.LookupFloatSetting("Toolkit.LevelPawn.XPMultiplier") > 0 ? CustomSettings.LookupFloatSetting("Toolkit.LevelPawn.XPMultiplier") : 0.5f;
            float xpWon            = pawn.skills.GetSkill(skill).XpRequiredForLevelUp *customMultiplier *((float)Verse.Rand.Range(0.5f, 1.5f));

            xpWon = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, xpWon);
            pawn.skills.Learn(skill, xpWon, true);
            viewer.TakeViewerCoins(pointsWager);
            viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
            VariablesHelpers.SendPurchaseMessage($"Increasing skill for {pawn.LabelCap} with {pointsWager} coins wagered and {(int)xpWon} xp for {skill.defName} purchased by {viewer.username}", separateChannel);
            string text = Helper.ReplacePlaceholder("TwitchStoriesDescription55".Translate(), colonist: pawn.Name.ToString(), skill: skill.defName, first: Math.Round(xpWon).ToString());

            Current.Game.letterStack.ReceiveLetter("TwitchToolkitIncreaseSkill".Translate(), text, LetterDefOf.PositiveEvent, pawn);
        }
        public override void TryExecute()
        {
            bool success = worker.TryExecute(parms);

            ToolkitPatchLogger.Log(incidentDef.defName, $"Executed. Result: {success}");
            if (success)
            {
                Viewer.TakeViewerCoins(pointsWager);
                Viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
                VariablesHelpers.SendPurchaseMessage($"Starting {storeIncident.label} with {pointsWager} points wagered and {(int)parms.points} points purchased by {Viewer.username}", separateChannel);
                return;
            }
            Toolkit.client.SendMessage($"@{Viewer.username} could not generate parms for {storeIncident.label}.", separateChannel);
        }
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            Log.Warning("found target");

            parms        = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, StorytellerUtility.DefaultThreatPointsNow(target));
            parms.forced = true;

            Log.Warning("genned parms");

            worker     = new IncidentWorker_Infestation();
            worker.def = IncidentDef.Named("Infestation");

            bool canFire = worker.CanFireNow(parms);

            if (!canFire)
            {
                Toolkit.client.SendMessage($"@{viewer.username} Found no place for infestation to occur.", separateChannel);
            }

            return(canFire);
        }
        public override void TryExecute()
        {
            // take actions for incident
            List <Pawn> pawns = Helper.AnyPlayerMap.mapPawns.FreeColonistsSpawned.ToList();

            pawns.Shuffle();

            bool           successfulInspiration = false;
            InspirationDef randomAvailableInspirationDef;

            foreach (Pawn pawn in pawns)
            {
                if (pawn.Inspired)
                {
                    continue;
                }

                randomAvailableInspirationDef = (
                    from x in DefDatabase <InspirationDef> .AllDefsListForReading
                    where true
                    select x).RandomElementByWeightWithFallback((InspirationDef x) => x.Worker.CommonalityFor(pawn), null
                                                                );

                if (randomAvailableInspirationDef != null)
                {
                    successfulInspiration = pawn.mindState.inspirationHandler.TryStartInspiration(randomAvailableInspirationDef);
                    if (successfulInspiration)
                    {
                        break;
                    }
                }
            }

            if (successfulInspiration)
            {
                Viewer.TakeViewerCoins(storeIncident.cost);

                // calculate new karma if needed
                Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);

                // send a purchase confirmation message
                VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} purchased a random inspiration.");
            }
            else
            {
                VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} attempted to inspired a pawn, but none were successful.");
            }
        }
        public override void TryExecute()
        {
            if (worker.TryExecute(parms))
            {
                viewer.TakeViewerCoins(pointsWager);
                viewer.CalculateNewKarma(this.storeIncident.karmaType, pointsWager);
                VariablesHelpers.SendPurchaseMessage(
                    Helper.ReplacePlaceholder("TranslationKey".Translate(),
                                              amount: pointsWager.ToString(),
                                              first: Convert.ToInt32(parms.points).ToString(),
                                              viewer: viewer.username),
                    separateChannel);
                return;
            }

            Toolkit.client.SendMessage($"@{viewer.username} not enough points spent for drop raid.", separateChannel);
        }
Beispiel #26
0
        public override void TryExecute()
        {
            Map map = Helper.AnyPlayerMap;
            StorytellerComp_HodlBot storytellerComp = new StorytellerComp_HodlBot();

            storytellerComp.forced = true;
            foreach (FiringIncident incident in storytellerComp.MakeIntervalIncidents(map))
            {
                Ticker.FiringIncidents.Enqueue(incident);
                break;
            }

            Viewer.TakeViewerCoins(storeIncident.cost);

            Viewer.CalculateNewKarma(storeIncident.karmaType, storeIncident.cost);

            VariablesHelpers.SendPurchaseMessage($"@{Viewer.username} purchased a HodlBot Vote.");
        }
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            Log.Warning("Finding target");

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            parms                 = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.RaidBeacon, target);
            parms.points          = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);
            parms.raidStrategy    = RaidStrategyDefOf.ImmediateAttack;
            parms.raidArrivalMode = PawnsArrivalModeDefOf.CenterDrop;
            parms.faction         = Find.FactionManager.RandomEnemyFaction(false, false, false, TechLevel.Industrial);

            worker     = new Incidents.IncidentWorker_RaidEnemy();
            worker.def = IncidentDefOf.RaidEnemy;

            return(worker.CanFireNow(parms));
        }
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}");
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            parms              = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatSmall, target);
            parms.points       = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);
            parms.raidStrategy = DefDatabase <RaidStrategyDef> .GetNamed("Siege");

            //parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeDrop;
            parms.faction = Find.FactionManager.RandomEnemyFaction(false, false, false, TechLevel.Industrial);

            worker     = new Incidents.IncidentWorker_RaidEnemy();
            worker.def = IncidentDefOf.RaidEnemy;

            return(worker.CanFireNow(parms));
        }
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            worker = new IncidentWorker_DiseaseHuman();
            List <IncidentDef> allDiseases = DefDatabase <IncidentDef> .AllDefs.Where(s => s.workerClass == typeof(IncidentWorker_DiseaseHuman)).ToList();

            allDiseases.Shuffle();
            worker.def = allDiseases[0];

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            float defaultThreatPoints = StorytellerUtility.DefaultSiteThreatPointsNow();

            parms        = StorytellerUtility.DefaultParmsNow(worker.def.category, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, StorytellerUtility.DefaultThreatPointsNow(target));
            return(worker.CanFireNow(parms));
        }
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            parms         = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.RaidBeacon, target);
            parms.points  = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);
            parms         = StorytellerUtility.DefaultParmsNow(worker.def.category, target);
            parms.faction = Find.FactionManager.OfInsects;

            worker     = new IncidentWorker_Infestation();
            worker.def = IncidentDef.Named("Infestation");


            return(worker.CanFireNow(parms));
        }