public static bool Intercept_Raid(IncidentParms parms, bool splitInGroups = false)
        {
            if (parms.faction.PlayerRelationKind != FactionRelationKind.Hostile)
            {
                return(false);
            }
            InterceptedIncident incident;

            if (splitInGroups)
            {
                incident = new InterceptedIncident_HumanCrowd_RaidEnemy_Groups();
            }
            else
            {
                incident = new InterceptedIncident_HumanCrowd_RaidEnemy();
            }
            incident.incidentDef = CurrentIncidentDef;
            incident.parms       = parms;
            if (!incident.ManualDeterminParams())
            {
                return(false);
            }
            RaidingGoalUtility.ResolveRaidGoal(incident as InterceptedIncident_HumanCrowd_RaidEnemy);
            if (!IncidentCaravanUtility.AddNewIncidentCaravan(incident))
            {
                Log.Error("Fail to create Incident Caravan");
                return(false);
            }
            IsHoaxingStoryTeller = true;
            if (PES_Settings.DebugModeOn)
            {
                Messages.Message("PES_Debug: Successfully intercepted a raid Incident", MessageTypeDefOf.NeutralEvent);
            }
            return(true);
        }
예제 #2
0
        public static bool Intercept_Raid(IncidentParms parms, bool splitInGroups = false)
        {
            if (PES_Settings.DebugModeOn)
            {
                Log.Message("-=PS=- Intercept_Raid Start", false);
            }
            if (parms.faction == null)
            {
                if (parms.traderKind != null)
                {
                    Log.Message("-=PS=- parms.traderKind=" + parms.traderKind.ToString(), false);
                }
                Log.Message("-=PS=- parms.faction == null", false);
                return(false);
            }
            if (parms != null && parms.questTag != null)             //Lt. Bob - "Temporary" bypass fix? for Quest handling
            {
                Log.Message("-=PS=- Intercept_Raid - questTag!=Null == " + parms.questTag);
            }
            if (parms.faction.PlayerRelationKind != FactionRelationKind.Hostile)
            {
                return(false);
            }
            InterceptedIncident incident;

            if (splitInGroups)
            {
                incident = new InterceptedIncident_HumanCrowd_RaidEnemy_Groups();
            }
            else
            {
                incident = new InterceptedIncident_HumanCrowd_RaidEnemy();
            }

            if (CurrentIncidentDef == null)
            {
                Log.Error("PES: A raid incident that is not compatible with Preemptive Strike is trying to execute. So this incident won't be intercepted by PES and will be executed in it vanilla way");
                return(false); //Fix v1.1.4: In some mods, their raids are implemented without a incidentworker
            }

            incident.incidentDef = CurrentIncidentDef;
            incident.parms       = parms;
            if (!incident.ManualDeterminParams())
            {
                return(false);
            }
            RaidingGoalUtility.ResolveRaidGoal(incident as InterceptedIncident_HumanCrowd_RaidEnemy);
            if (!IncidentCaravanUtility.AddNewIncidentCaravan(incident))
            {
                Log.Error("Fail to create Incident Caravan");
                return(false);
            }
            IsHoaxingStoryTeller = true;
            if (PES_Settings.DebugModeOn)
            {
                Messages.Message("PES_Debug: Successfully intercepted a raid Incident", MessageTypeDefOf.NeutralEvent);
            }
            return(true);
        }
        public static DiaNode RebuffNode()
        {
            TravelingIncidentCaravan caravan = DialogUtilities.tempCaravan;
            Pawn pawn = DialogUtilities.tempPawn;
            InterceptedIncident_HumanCrowd_RaidEnemy incident = caravan.incident as InterceptedIncident_HumanCrowd_RaidEnemy;

            if (incident == null)
            {
                return(null);
            }
            if (incident.raidGoalType == RaidGoalType.Smite)
            {
                return(null);
            }
            StringBuilder sb = new StringBuilder("PES_RaidNeg_Rebuff_Confirmation".Translate());

            sb.AppendLine();
            if (incident.raidGoalType == RaidGoalType.Rescue)
            {
                Log.Message(incident.raidGoalType.ToString());
                sb.AppendLine("PES_RaidNeg_Rebuff_Confirmation_Rescue".Translate());
                RaidingGoal_Rescue goal = incident.goal as RaidingGoal_Rescue;
                foreach (var p in goal.Prisoners)
                {
                    sb.AppendLine("    " + p.Name.ToStringShort);
                }
            }
            sb.AppendLine();
            sb.Append(@"<i>");
            sb.Append("PES_RaidNeg_Rebuff_Explanation".Translate(pawn.Name.ToStringShort));
            sb.Append(@"</i>");
            DiaNode diaNode = new DiaNode(sb.ToString());

            void rebuffAction()
            {
                RaidingGoalUtility.RebuffDemandAndSmiteThePlayer(caravan, pawn);
            }

            DiaOption option = new DiaOption("PES_SimpleConfirm".Translate());

            option.action      = rebuffAction;
            option.resolveTree = true;
            //if (pawn.story.WorkTagIsDisabled(WorkTags.Violent))	//Lt. Bob: 1.1 - Replaced with below
            if (pawn.WorkTagIsDisabled(WorkTags.Violent))                       //Lt. Bob: 1.1
            {
                option.Disable("PES_RaidNeg_Rebuff_Rescue_Fail".Translate());
            }
            diaNode.options.Add(option);
            diaNode.options.Add(DialogUtilities.CurtOption("PES_Cancel", null, null, true));
            return(diaNode);
        }
예제 #4
0
        public override void ExecuteNow()
        {
            IncidentInterceptorUtility.IsIntercepting_IncidentExcecution = false;
            IncidentInterceptorUtility.IsIntercepting_PawnGeneration     = GeneratorPatchFlag.ReturnTempList;
            IncidentInterceptorUtility.tmpPawnList = this.pawnList;

            if (incidentDef != null && this.parms != null)
            {
                if (incidentDef.Worker.TryExecute(this.parms))
                {
                    RaidingGoalUtility.CombatMoralResolver(this);
                }
            }
            else
            {
                Log.Error("No IncidentDef or parms in InterceptedIncident!");
            }

            IncidentInterceptorUtility.tmpPawnList = null;
            IncidentInterceptorUtility.IsIntercepting_PawnGeneration     = GeneratorPatchFlag.Generate;
            IncidentInterceptorUtility.IsIntercepting_IncidentExcecution = true;
        }