Exemple #1
0
        //int ticker = 0;
        void TickAction()
        {
            var zombie = (Zombie)pawn;

            if (zombie.state == ZombieState.Emerging)
            {
                return;
            }

            /*
             * // for debugging - let zombies only live for 600 ticks
             * // --------------------------------------------------
             * if (++ticker > 600)
             * {
             *      EndJobWith(JobCondition.InterruptForced);
             *      zombie.Kill(null); return;
             * }
             * // --------------------------------------------------
             */

            if (this.ShouldDie(zombie))
            {
                return;
            }

            if (this.Attack(zombie))
            {
                return;
            }

            if (ZombieStateHandler.Downed(zombie))
            {
                return;
            }

            if (this.ValidDestination(zombie))
            {
                return;
            }

            if (zombie.isMiner && (zombie.story.bodyType == BodyTypeDefOf.Fat || zombie.story.bodyType == BodyTypeDefOf.Hulk))
            {
                if (this.Mine(zombie, true))
                {
                    return;
                }
            }

            var grid = zombie.Map.GetGrid();

            if (this.Eat(zombie, grid))
            {
                return;
            }

            var checkSmashable = true;

            if (zombie.IsTanky == false)
            {
                checkSmashable = this.Track(zombie, grid);
                if (this.Smash(zombie, checkSmashable, true))
                {
                    return;
                }
            }
            else if (this.Smash(zombie, true, false))
            {
                return;
            }

            var possibleMoves = this.PossibleMoves(zombie);

            if (possibleMoves.Count > 0)
            {
                if (zombie.raging > 0 || zombie.IsTanky || (zombie.wasMapPawnBefore && zombie.state != ZombieState.Tracking))
                {
                    if (this.RageMove(zombie, grid, possibleMoves, checkSmashable))
                    {
                        return;
                    }
                }

                if (zombie.raging <= 0)
                {
                    if (zombie.isMiner)
                    {
                        if (this.Mine(zombie, false))
                        {
                            return;
                        }
                    }

                    this.Wander(zombie, grid, possibleMoves);
                }
            }

            this.ExecuteMove(zombie, grid);

            ZombieStateHandler.BeginRage(zombie, grid);
        }
Exemple #2
0
        protected override void DoListingItems()
        {
            base.DoListingItems();

            if (Current.ProgramState != ProgramState.Playing)
            {
                return;
            }

            var map = Find.CurrentMap;

            if (map == null)
            {
                return;
            }

            DoGap();
            DoLabel("Tools - Zombies");

            DebugToolMap("Spawn: Zombie (dig out)", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.Normal, false);
            });
            DebugToolMap("Spawn: Zombie (standing)", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.Normal, true);
            });
            DebugToolMap("Spawn: Suicide bomber", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.SuicideBomber, true);
            });
            DebugToolMap("Spawn: Toxic Splasher", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.ToxicSplasher, true);
            });
            DebugToolMap("Spawn: Tanky Operator", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.TankyOperator, true);
            });
            DebugToolMap("Spawn: Miner", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.Miner, true);
            });
            DebugToolMap("Spawn: Random zombie", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.Random, true);
            });
            DebugToolMap("Spawn: Zombie incident (4)", delegate
            {
                ZombiesRising.TryExecute(map, 4, UI.MouseCell(), true);
            });
            DebugToolMap("Spawn: Zombie incident (25)", delegate
            {
                ZombiesRising.TryExecute(map, 25, UI.MouseCell(), true);
            });
            DebugToolMap("Spawn: Zombie incident (100)", delegate
            {
                ZombiesRising.TryExecute(map, 100, UI.MouseCell(), true);
            });
            DebugToolMap("Spawn: Zombie incident (200)", delegate
            {
                ZombiesRising.TryExecute(map, 200, UI.MouseCell(), true);
            });
            DebugToolMap("Convert: Make Zombie", delegate
            {
                foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()))
                {
                    var pawn = thing as Pawn;
                    if (pawn == null || pawn is Zombie)
                    {
                        continue;
                    }
                    Tools.ConvertToZombie(pawn, true);
                }
            });
            DebugToolMap("Apply: Trigger rotting", delegate
            {
                foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()))
                {
                    var compRottable = thing.TryGetComp <CompRottable>();
                    if (compRottable != null)
                    {
                        compRottable.RotProgress = compRottable.PropsRot.TicksToRotStart;
                    }
                }
            });
            DebugToolMap("Apply: Add infection", delegate
            {
                foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()))
                {
                    var pawn = thing as Pawn;
                    if (pawn == null || pawn is Zombie)
                    {
                        continue;
                    }

                    var bodyPart = pawn.health.hediffSet
                                   .GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined)
                                   .FirstOrDefault(part => part.IsCorePart == false);
                    if (bodyPart == null)
                    {
                        bodyPart = pawn.health.hediffSet
                                   .GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined).RandomElement();
                    }

                    var def  = HediffDef.Named("ZombieBite");
                    var bite = (Hediff_Injury_ZombieBite)HediffMaker.MakeHediff(def, pawn, bodyPart);

                    bite.mayBecomeZombieWhenDead = true;
                    bite.TendDuration.ZombieInfector.MakeHarmfull();
                    var damageInfo = new DamageInfo(Tools.ZombieBiteDamageDef, 2);
                    pawn.health.AddHediff(bite, bodyPart, damageInfo);
                }
            });
            DebugToolMap("Apply: Remove infection", delegate
            {
                foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()))
                {
                    var pawn = thing as Pawn;
                    if (pawn == null || pawn is Zombie)
                    {
                        continue;
                    }
                    pawn.health.hediffSet
                    .GetHediffs <Hediff_Injury_ZombieBite>()
                    .Do(bite =>
                    {
                        bite.mayBecomeZombieWhenDead = false;
                        var tendDuration             = bite.TryGetComp <HediffComp_Zombie_TendDuration>();
                        tendDuration.ZombieInfector.MakeHarmless();
                    });
                }
            });
            DebugToolMap("Apply: Zombie raging", delegate
            {
                foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()))
                {
                    var zombie = thing as Zombie;
                    if (zombie == null)
                    {
                        continue;
                    }
                    ZombieStateHandler.StartRage(zombie);
                }
            });
        }