public override bool CanSummonNow(Map map)
 {
     if (TempExecutioner(map) != null)
     {
         MapComponent_SacrificeTracker sacrificeTracker = map.GetComponent <MapComponent_SacrificeTracker>();
         if (sacrificeTracker != null)
         {
             if (sacrificeTracker.unspeakableOathPawns == null)
             {
                 sacrificeTracker.unspeakableOathPawns = new List <Pawn>();
             }
             if (sacrificeTracker.unspeakableOathPawns.Contains(TempExecutioner(map)))
             {
                 Messages.Message("Executioner has already taken an unspeakable oath.", MessageTypeDefOf.RejectInput);
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             Messages.Message("Missing map component.", MessageTypeDefOf.RejectInput);
             return(false);
         }
     }
     else
     {
         Messages.Message("Executioner is unavailable.", MessageTypeDefOf.RejectInput);
         return(false);
     }
 }
        //In-case our component injector doesn't pick up the map component,
        //this method causes a new map component to be generated from a static method.
        public static MapComponent_SacrificeTracker Get(Map map)
        {
            MapComponent_SacrificeTracker mapComponent_SacrificeTracker = map.components.OfType <MapComponent_SacrificeTracker>().FirstOrDefault <MapComponent_SacrificeTracker>();

            if (mapComponent_SacrificeTracker == null)
            {
                mapComponent_SacrificeTracker = new MapComponent_SacrificeTracker(map);
                map.components.Add(mapComponent_SacrificeTracker);
            }
            return(mapComponent_SacrificeTracker);
        }
Beispiel #3
0
        public static void OpenDeitySelectMenu(Building_SacrificialAltar altar, DeityType deityType)
        {
            var list = new List <FloatMenuOption>
            {
                new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate
                {
                    altar.Map.GetComponent <MapComponent_SacrificeTracker>().lastUsedAltar = altar;
                    altar.tempCurrentSacrificeDeity = null;
                })
            };

            foreach (var current in DeityTracker.Get.DeityCache.Keys)
            {
                if (current.discovered == false)
                {
                    continue;
                }

                Action action;
                var    localDeity = current;
                action = delegate
                {
                    MapComponent_SacrificeTracker.Get(altar.Map).lastUsedAltar = altar;
                    switch (deityType)
                    {
                    case DeityType.WorshipDeity:
                        altar.tempCurrentWorshipDeity = localDeity;
                        break;

                    case DeityType.OfferingDeity:
                        altar.tempCurrentOfferingDeity = localDeity;
                        break;

                    case DeityType.SacrificeDeity:
                        altar.tempCurrentSacrificeDeity = localDeity;
                        altar.tempCurrentSpell          = null;
                        break;
                    }
                };

                bool extraPartOnGUI(Rect rect)
                {
                    return(DeityInfoCardButton(rect.x + 5f, rect.y + ((rect.height - 24f) / 2f), current));
                }

                list.Add(new FloatMenuOption(localDeity.LabelCap, action, MenuOptionPriority.Default, null, null, 29f,
                                             extraPartOnGUI));
            }

            Find.WindowStack.Add(new FloatMenu(list));
        }
Beispiel #4
0
        public void ReceiveSacrifice(Pawn sacrifice, Map map, bool favorSpell = false, bool starsAreRight = false,
                                     bool starsAreWrong = false)
        {
            MapComponent_SacrificeTracker tracker = map.GetComponent <MapComponent_SacrificeTracker>();
            float value =
                (sacrifice.MarketValue + SacrificeBonus(sacrifice, map, favorSpell, starsAreRight, starsAreWrong)) /
                DIVIDER_HUMAN;
            bool perfect           = false;
            bool sacrificialDagger = false;

            value += CultUtility.CongregationBonus(tracker.lastUsedAltar.SacrificeData.Congregation, this, out perfect,
                                                   out sacrificialDagger);
            Cthulhu.Utility.DebugReport("Sacrifice Value: " + value.ToString());
            AffectFavor(value);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;
            MapComponent_SacrificeTracker sacrificeTracker = map.GetComponent <MapComponent_SacrificeTracker>();

            if (sacrificeTracker == null)
            {
                return(Cthulhu.Utility.ResultFalseWithReport(new StringBuilder("Missing map component.")));
            }
            if (sacrificeTracker.unspeakableOathPawns == null)
            {
                sacrificeTracker.unspeakableOathPawns = new List <Pawn>();
            }
            if (!Cthulhu.Utility.IsActorAvailable(executioner(map)))
            {
                Messages.Message("Executioner is unavailable.", MessageTypeDefOf.RejectInput);
                return(false);
            }
            executioner(map).story.traits.GainTrait(new Trait(TraitDef.Named("Cults_OathtakerHastur")));
            sacrificeTracker.unspeakableOathPawns.Add(executioner(map));
            return(true);
        }
Beispiel #6
0
        public static void OpenActorSelectMenu(Building_SacrificialAltar altar, ActorType actorType)
        {
            ///
            /// Error Handling
            ///
            if (altar == null)
            {
                Utility.ErrorReport("Altar Null Exception");
                return;
            }

            if (altar.Map == null)
            {
                Utility.ErrorReport("Map Null Exception");
            }

            if (altar.Map.mapPawns == null)
            {
                Utility.ErrorReport("mapPawns Null Exception");
                return;
            }

            if (altar.Map.mapPawns.FreeColonistsSpawned == null)
            {
                Utility.ErrorReport("FreeColonistsSpawned Null Exception");
                return;
            }
            //if (altar.Map.mapPawns.FreeColonistsSpawnedCount <= 0)
            //{
            //    Cthulhu.Utility.ErrorReport("Colonist Count Less Than or Equal To 0 Exception");
            //    return;
            //}

            ///
            /// Get Actor List
            ///

            var actorList = new List <Pawn>();
            var s         = new StringBuilder();

            switch (actorType)
            {
            case ActorType.executioner:
            case ActorType.offerer:
                // Cycle through candidates
                foreach (var candidate in altar.Map.mapPawns.FreeColonistsSpawned)
                {
                    if (!CultUtility.IsCultistAvailable(candidate))
                    {
                        continue;
                    }

                    // Executioners must be able to use tool and move.
                    if (candidate.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) &&
                        candidate.health.capacities.CapableOf(PawnCapacityDefOf.Moving))
                    {
                        // Add the actors.
                        actorList.Add(candidate);
                        Utility.DebugReport("Actor List :: Added " + candidate.Name);
                    }
                }

                Utility.DebugReport(s.ToString());
                break;

            case ActorType.preacher:
                // Cycle through candidates
                foreach (var candidate in altar.Map.mapPawns.FreeColonistsSpawned)
                {
                    if (!CultUtility.IsCultistAvailable(candidate))
                    {
                        continue;
                    }

                    // Preachers must be able to move and talk.
                    if (candidate.health.capacities.CapableOf(PawnCapacityDefOf.Moving) &&
                        candidate.health.capacities.CapableOf(PawnCapacityDefOf.Talking))
                    {
                        // Add the actors.
                        actorList.Add(candidate);
                        Utility.DebugReport("Actor List :: Added " + candidate.Name);
                    }
                }

                Utility.DebugReport(s.ToString());
                break;

            case ActorType.prisoner:
                ///
                /// ERROR HANDLING
                ///

                if (altar.Map.mapPawns.PrisonersOfColonySpawned == null)
                {
                    Messages.Message("No prisoners available.", MessageTypeDefOf.RejectInput);
                    return;
                }

                if (altar.Map.mapPawns.PrisonersOfColonySpawnedCount <= 0)
                {
                    Messages.Message("No prisoners available.", MessageTypeDefOf.RejectInput);
                    return;
                }


                /// Cycle through possible candidates in the map's prisoner list
                foreach (var candidate in altar.Map.mapPawns.PrisonersOfColonySpawned)
                {
                    if (!Utility.IsActorAvailable(candidate, true))
                    {
                        continue;
                    }

                    actorList.Add(candidate);
                }

                break;

            case ActorType.animalSacrifice:
                ///
                /// ERROR HANDLING
                ///

                if (altar.Map.mapPawns.AllPawnsSpawned == null)
                {
                    Messages.Message("No " + actorType + "s available.", MessageTypeDefOf.RejectInput);
                    return;
                }

                if (altar.Map.mapPawns.AllPawnsSpawnedCount <= 0)
                {
                    Messages.Message("No " + actorType + "s available.", MessageTypeDefOf.RejectInput);
                    return;
                }

                /// Cycle through possible candidates in the player's owned animals list.
                foreach (var candidate in altar.Map.mapPawns.AllPawnsSpawned)
                {
                    if (!Utility.IsActorAvailable(candidate, true))
                    {
                        continue;
                    }

                    if (candidate.Faction != Faction.OfPlayer)
                    {
                        continue;
                    }

                    if (candidate.RaceProps == null)
                    {
                        continue;
                    }

                    if (!candidate.RaceProps.Animal)
                    {
                        continue;
                    }

                    actorList.Add(candidate);
                }

                break;
            }

            /// Let the player know there are no prisoners available.
            if (actorList != null)
            {
                if (actorList.Count <= 0)
                {
                    Messages.Message("No " + actorType + "s available.", MessageTypeDefOf.RejectInput);
                    return;
                }
            }

            ///
            /// Create float menus
            ///

            //There must always be a none.
            var list = new List <FloatMenuOption>
            {
                new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate { altar.tempExecutioner = null; })
            };

            foreach (var actor in actorList)
            {
                Action action;
                var    localCol = actor;
                action = delegate
                {
                    switch (actorType)
                    {
                    case ActorType.executioner:
                        MapComponent_SacrificeTracker.Get(altar.Map).lastUsedAltar = altar;
                        altar.tempExecutioner = localCol;
                        break;

                    case ActorType.preacher:
                        altar.tempPreacher = localCol;
                        break;

                    case ActorType.offerer:
                        MapComponent_SacrificeTracker.Get(altar.Map).lastUsedAltar = altar;
                        altar.tempOfferer = localCol;
                        break;

                    case ActorType.prisoner:
                        MapComponent_SacrificeTracker.Get(altar.Map).lastUsedAltar     = altar;
                        MapComponent_SacrificeTracker.Get(altar.Map).lastSacrificeType =
                            CultUtility.SacrificeType.human;
                        altar.tempSacrifice = localCol;
                        break;

                    case ActorType.animalSacrifice:
                        MapComponent_SacrificeTracker.Get(altar.Map).lastUsedAltar     = altar;
                        MapComponent_SacrificeTracker.Get(altar.Map).lastSacrificeType =
                            CultUtility.SacrificeType.animal;
                        altar.tempSacrifice = localCol;
                        break;
                    }
                };
                list.Add(new FloatMenuOption(localCol.LabelShort, action));
            }

            Find.WindowStack.Add(new FloatMenu(list));
        }
Beispiel #7
0
        public float SacrificeBonus(Pawn sacrifice, Map map, bool favorSpell = false, bool starsAreRight = false,
                                    bool starsAreWrong = false)
        {
            StringBuilder s = new StringBuilder();

            s.Append("Sacrifice Bonus Calculation:");
            float result = 0f;

            if (sacrifice == null)
            {
                return(result);
            }
            if (sacrifice.RaceProps == null)
            {
                return(result);
            }
            MapComponent_SacrificeTracker tracker = map.GetComponent <MapComponent_SacrificeTracker>();

            if (tracker == null)
            {
                return(result);
            }
            tracker.lastSacrificeName = sacrifice.LabelShort;

            //Divide by 0 exception
            if (sacrifice.MarketValue == 0f)
            {
                return(result);
            }

            //Animal Sacrifice Bonuses
            if (tracker.lastSacrificeType == CultUtility.SacrificeType.animal)
            {
                //Default Animal Sacrifice Bonus
                result += (sacrifice.MarketValue * MODIFIER_ANIMAL); // 20% bonus for animal sacrifice

                //Pet Bonus handling code
                if (sacrifice.RaceProps.petness > 0f)
                {
                    result += sacrifice.MarketValue * 3; //Triple the sacrifice value of pets sacrificed
                    s.AppendLine();
                    s.Append("Subtotal: " + result.ToString() + " Applied Pet-like Modifier");
                    tracker.ASMwasPet = true;
                    if (sacrifice.playerSettings.Master != null)
                    {
                        result += sacrifice.MarketValue * 2; //Add even more sacrifice value to pets with masters
                        s.AppendLine();
                        s.Append("Subtotal: " + result.ToString() + " Applied Bonded Modifier");
                        tracker.ASMwasBonded = true;
                    }
                    if (tracker.lastUsedAltar.SacrificeData.Executioner.relations.DirectRelationExists(
                            PawnRelationDefOf.Bond, sacrifice))
                    {
                        result += sacrifice.MarketValue * 2; //Even more sacrifice value for sacrificing one's own pet
                        s.AppendLine();
                        s.Append("Subtotal: " + result.ToString() + " Applied Master As Executioner Modifier");
                        tracker.ASMwasExcMaster = true;
                    }
                }
            }
            //Human sacrifice bonuses
            if (tracker.lastSacrificeType == CultUtility.SacrificeType.human)
            {
                //Default human sacrifice bonus
                result += (sacrifice.MarketValue * MODIFIER_HUMAN); // 50% bonus for human sacrifice

                //Family bonus handling code
                Pawn ex = tracker.lastUsedAltar.SacrificeData.Executioner;
                if (ex.relations.FamilyByBlood.Contains(sacrifice))
                {
                    result += sacrifice.MarketValue * 3; //Three times the value for family members
                    ex.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.WitnessedDeathFamily, null);
                    s.AppendLine();

                    PawnRelationDef def = ex.GetMostImportantRelation(sacrifice);
                    s.Append("Subtotal: " + result.ToString() + " Applied Family Member, " + def.label +
                             " as Executioner Modifier");
                    tracker.HSMwasFamily = true;
                    tracker.lastRelation = def;
                }

                //Favor Only Bonus
                if (favorSpell)
                {
                    result += (result * 0.2f); // 20% bonus
                }
            }
            //Stars are right
            if (starsAreRight)
            {
                result += (result * 0.5f); //50% bonus
            }
            //Stars are wrong
            if (starsAreWrong)
            {
                result = result * 0.5f; //Lose 50% of value
            }

            Cthulhu.Utility.DebugReport(s.ToString());
            return(result);
        }