// invalidate destination if necessary ====================================================== // public static bool ValidDestination(this JobDriver_Stumble driver, Zombie zombie) { // find out if we still need to check for 0,0 as an invalid location if (driver.destination.x == 0 && driver.destination.z == 0) { driver.destination = IntVec3.Invalid; } return(zombie.HasValidDestination(driver.destination)); }
// calculate possible moves ================================================================= // public static List <IntVec3> PossibleMoves(this JobDriver_Stumble driver, Zombie zombie) { if (driver.destination.IsValid) { return(new List <IntVec3>()); } var result = new List <IntVec3>(8); var pos = zombie.Position; foreach (var vec in GenAdj.AdjacentCells) { var cell = pos + vec; if (zombie.HasValidDestination(cell)) { result.Add(cell); } } return(result); }
public static bool Track(this JobDriver_Stumble driver, Zombie zombie, PheromoneGrid grid) { if (zombie.EveryNTick(NthTick.Every60) || fadeOff == -1) { fadeOff = Tools.PheromoneFadeoff(); wasColonistFadeoff = fadeOff / 6; agitatedFadeoff = fadeOff / 4; checkSmashableFadeoff1 = agitatedFadeoff / 4; checkSmashableFadeoff2 = agitatedFadeoff * 3 / 4; } var trackingMoves = new List <IntVec3>(8); var currentTicks = Tools.Ticks(); var timeDelta = long.MaxValue; var fmin = long.MaxValue; if (zombie.raging == 0) { for (var i = 0; i < 8; i++) { var pos = zombie.Position + GenAdj.AdjacentCells[i]; if (zombie.HasValidDestination(pos)) { var f = zombie.wasMapPawnBefore ? wasColonistFadeoff : fadeOff; var tdiff = currentTicks - grid.GetTimestamp(pos); fmin = Math.Min(fmin, tdiff); if (tdiff < f) { trackingMoves.Add(pos); } } } } if (trackingMoves.Count > 0) { trackingMoves.Sort((p1, p2) => grid.GetTimestamp(p2).CompareTo(grid.GetTimestamp(p1))); trackingMoves = trackingMoves.Take(Constants.NUMBER_OF_TOP_MOVEMENT_PICKS).ToList(); trackingMoves = trackingMoves.OrderBy(p => grid.GetZombieCount(p)).ToList(); var nextMove = trackingMoves.First(); timeDelta = currentTicks - (grid.GetTimestamp(nextMove)); driver.destination = nextMove; if (zombie.state == ZombieState.Wandering) { Tools.ChainReact(zombie.Map, zombie.Position, nextMove); if (timeDelta <= agitatedFadeoff) { CastBrainzThought(zombie); } } zombie.state = ZombieState.Tracking; } if (driver.destination.IsValid == false) { zombie.state = ZombieState.Wandering; } if (zombie.wasMapPawnBefore) { return(true); } var checkSmashable = timeDelta >= checkSmashableFadeoff1 && timeDelta < checkSmashableFadeoff2; if (ZombieSettings.Values.smashOnlyWhenAgitated) { checkSmashable &= (zombie.state == ZombieState.Tracking || zombie.raging > 0); } return(checkSmashable); }