Esempio n. 1
0
        private void StartFleeingBecauseOfPawnAction(Thing instigator)
        {
            List <Thing> threats = new List <Thing>
            {
                instigator
            };
            IntVec3 fleeDest = CellFinderLoose.GetFleeDest(this.pawn, threats, this.pawn.Position.DistanceTo(instigator.Position) + 14f);

            if (fleeDest != this.pawn.Position)
            {
                this.pawn.jobs.StartJob(new Job(JobDefOf.Flee, fleeDest, instigator), JobCondition.InterruptOptional, null, false, true, null, null, false);
            }
            if (this.pawn.RaceProps.herdAnimal && Rand.Chance(0.1f))
            {
                foreach (Pawn current in this.GetPackmates(this.pawn, 24f))
                {
                    if (Pawn_MindState.CanStartFleeingBecauseOfPawnAction(current))
                    {
                        IntVec3 fleeDest2 = CellFinderLoose.GetFleeDest(current, threats, current.Position.DistanceTo(instigator.Position) + 14f);
                        if (fleeDest2 != current.Position)
                        {
                            current.jobs.StartJob(new Job(JobDefOf.Flee, fleeDest2, instigator), JobCondition.InterruptOptional, null, false, true, null, null, false);
                        }
                    }
                }
            }
        }
        private void StartFleeingBecauseOfPawnAction(Thing instigator)
        {
            List <Thing> list = new List <Thing>();

            list.Add(instigator);
            List <Thing> threats  = list;
            IntVec3      fleeDest = CellFinderLoose.GetFleeDest(this.pawn, threats, (float)(this.pawn.Position.DistanceTo(instigator.Position) + 14.0));

            if (fleeDest != this.pawn.Position)
            {
                this.pawn.jobs.StartJob(new Job(JobDefOf.Flee, fleeDest, instigator), JobCondition.InterruptOptional, null, false, true, null, null, false);
            }
            if (this.pawn.RaceProps.herdAnimal && Rand.Chance(0.1f))
            {
                foreach (Pawn packmate in this.GetPackmates(this.pawn, 24f))
                {
                    if (Pawn_MindState.CanStartFleeingBecauseOfPawnAction(packmate))
                    {
                        IntVec3 fleeDest2 = CellFinderLoose.GetFleeDest(packmate, threats, (float)(packmate.Position.DistanceTo(instigator.Position) + 14.0));
                        if (fleeDest2 != packmate.Position)
                        {
                            packmate.jobs.StartJob(new Job(JobDefOf.Flee, fleeDest2, instigator), JobCondition.InterruptOptional, null, false, true, null, null, false);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 public void Notify_Explosion(Explosion explosion)
 {
     if (this.pawn.Faction == null)
     {
         if (explosion.radius >= 3.5f && this.pawn.Position.InHorDistOf(explosion.Position, explosion.radius + 7f))
         {
             if (Pawn_MindState.CanStartFleeingBecauseOfPawnAction(this.pawn))
             {
                 this.StartFleeingBecauseOfPawnAction(explosion);
             }
         }
     }
 }
Esempio n. 4
0
 public void Notify_DamageTaken(DamageInfo dinfo)
 {
     if (dinfo.Def.externalViolence)
     {
         this.lastHarmTick = Find.TickManager.TicksGame;
         Pawn pawn = dinfo.Instigator as Pawn;
         if (!this.mentalStateHandler.InMentalState && dinfo.Instigator != null && (pawn != null || dinfo.Instigator is Building_Turret) && dinfo.Instigator.Faction != null && (dinfo.Instigator.Faction.def.humanlikeFaction || (pawn != null && pawn.def.race.intelligence >= Intelligence.ToolUser)) && this.pawn.Faction == null && (this.pawn.CurJob == null || this.pawn.CurJob.def != JobDefOf.PredatorHunt) && Rand.Chance(this.GetManhunterOnDamageChance(this.pawn) * Find.Storyteller.difficulty.manhunterChanceOnDamageFactor))
         {
             this.StartManhunterBecauseOfPawnAction("AnimalManhunterFromDamage");
         }
         else if (dinfo.Instigator != null && Pawn_MindState.CanStartFleeingBecauseOfPawnAction(this.pawn))
         {
             this.StartFleeingBecauseOfPawnAction(dinfo.Instigator);
         }
         if (this.pawn.GetPosture() != PawnPosture.Standing)
         {
             this.lastDisturbanceTick = Find.TickManager.TicksGame;
         }
     }
 }
 public void Notify_Explosion(Explosion explosion)
 {
     if (this.pawn.Faction == null && !(explosion.radius < 3.5) && this.pawn.Position.InHorDistOf(explosion.Position, (float)(explosion.radius + 7.0)) && Pawn_MindState.CanStartFleeingBecauseOfPawnAction(this.pawn))
     {
         this.StartFleeingBecauseOfPawnAction(explosion);
     }
 }
 public void Notify_DamageTaken(DamageInfo dinfo)
 {
     this.mentalStateHandler.Notify_DamageTaken(dinfo);
     if (dinfo.Def.ExternalViolenceFor(this.pawn))
     {
         this.lastHarmTick = Find.TickManager.TicksGame;
         if (this.pawn.Spawned)
         {
             Pawn pawn = dinfo.Instigator as Pawn;
             if (!this.mentalStateHandler.InMentalState && dinfo.Instigator != null && (pawn != null || dinfo.Instigator is Building_Turret) && dinfo.Instigator.Faction != null && (dinfo.Instigator.Faction.def.humanlikeFaction || (pawn != null && pawn.def.race.intelligence >= Intelligence.ToolUser)) && this.pawn.Faction == null && (this.pawn.RaceProps.Animal || this.pawn.IsWildMan()) && (this.pawn.CurJob == null || this.pawn.CurJob.def != JobDefOf.PredatorHunt || dinfo.Instigator != ((JobDriver_PredatorHunt)this.pawn.jobs.curDriver).Prey) && Rand.Chance(PawnUtility.GetManhunterOnDamageChance(this.pawn, dinfo.Instigator)))
             {
                 this.StartManhunterBecauseOfPawnAction("AnimalManhunterFromDamage");
             }
             else if (dinfo.Instigator != null && dinfo.Def.makesAnimalsFlee && Pawn_MindState.CanStartFleeingBecauseOfPawnAction(this.pawn))
             {
                 this.StartFleeingBecauseOfPawnAction(dinfo.Instigator);
             }
         }
         if (this.pawn.GetPosture() != PawnPosture.Standing)
         {
             this.lastDisturbanceTick = Find.TickManager.TicksGame;
         }
     }
 }