protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            Pawn pawn = p;

            if (SlaveUtility.HasSlaveCollar(pawn) && SlaveUtility.GetSlaveCollar(pawn).def.thingClass == typeof(SlaveCollar_Explosive))
            {
                if ((SlaveUtility.GetSlaveCollar(pawn) as SlaveCollar_Explosive).armed)
                {
                    return(ThoughtState.ActiveAtStage(1));
                }
                return(SlaveUtility.IsPawnColonySlave(pawn) ? ThoughtState.ActiveAtStage(0) : ThoughtState.ActiveAtStage(2));
            }
            return(ThoughtState.Inactive);
        }
Beispiel #2
0
        // Try to drum up the courage to escape
        public void ConsiderEscape()
        {
            if (!pawn.guest.IsPrisoner && !pawn.GetRoom().isPrisonCell&& !isMovingToEscape && willpower > 0f)
            {
                // moodFactor multiplies the time between escape attempts
                var moodFactor = Math.Min(pawn.needs.mood.CurInstantLevelPercentage + 0.5, 1f);
                //if (true) { // debugging for fast escape attempts
                if (hoursSinceLastEscapeAttempt > minHoursBetweenEscapeAttempts * moodFactor)
                {
                    float combined_bonus = 0;
                    // If we're not in a "room" aka free to run outside, then chance improves
                    if (pawn.GetRoom().TouchesMapEdge)
                    {
                        combined_bonus += 0.1f;
                    }
                    // Bonus from being outside but walled in (for example, a courtyard)
                    else if (pawn.GetRoom().PsychologicallyOutdoors)
                    {
                        combined_bonus += 0.05f;
                    }
                    // Bonus from not wearing slave collar
                    if (SlaveUtility.HasSlaveCollar(pawn))
                    {
                        var collar      = SlaveUtility.GetSlaveCollar(pawn);
                        var collarMalus = new Dictionary <TechLevel, float> {
                            { TechLevel.Neolithic, 0.1f },
                            { TechLevel.Medieval, 0.2f },
                            { TechLevel.Industrial, 0.35f },
                            { TechLevel.Spacer, 0.5f },
                            { TechLevel.Archotech, 0.75f }
                        };
                        if (collarMalus.ContainsKey(collar.def.techLevel))
                        {
                            combined_bonus -= collarMalus[collar.def.techLevel];
                        }
                    }
                    if (pawn.story.traits.HasTrait(TraitDefOf.Nerves))
                    {
                        combined_bonus += ((float)pawn.story.traits.GetTrait(TraitDefOf.Nerves).Degree) / 10f;
                    }
                    // Health malus
                    combined_bonus -= (1f - pawn.health.summaryHealth.SummaryHealthPercent) * 0.5f;
                    //combined_bonus -= (float)((1 - pawn.health.summaryHealth.SummaryHealthPercent) * 50);
                    // Take hours since last attempt into account
                    combined_bonus += Math.Max(hoursSinceLastEscapeAttempt, 72) * willpower * 0.2083f;
                    //combined_bonus += (int)Math.Round((Math.Max(hoursSinceLastEscapeAttempt, 72) * (willpower / 100)) * 0.2083f);

                    // Do a willpower check
                    if (willpower + combined_bonus > Rand.Range(0f, maxWillpower))
                    {
                        if (pawn.GetRoom().TouchesMapEdge)
                        {
                            TryToEscape();
                        }
                        else
                        {
                            MoveToEscape();
                        }
                    }
                }
            }
        }