Esempio n. 1
0
        public override void TakeControl(Actor actor)
        {
            base.TakeControl(actor);

            if (m_Actor.Model.Abilities.ZombieAI_Explore)
            {
                m_Exploration = new ExplorationData(EXPLORATION_LOCATIONS, EXPLORATION_ZONES);
            }
        }
Esempio n. 2
0
        public override void TakeControl(Actor actor)
        {
            base.TakeControl(actor);

            m_SafeTurns   = 0;
            m_Exploration = new ExplorationData(EXPLORATION_MAX_LOCATIONS, EXPLORATION_MAX_ZONES);

            m_LastEnemySaw   = null;
            m_LastItemsSaw   = null;
            m_LastSoldierSaw = null;
            m_LastRaidHeard  = null;
            m_Emotes         = null;
        }
Esempio n. 3
0
        public override void TakeControl(Actor actor)
        {
            base.TakeControl(actor);

            m_Exploration = new ExplorationData(EXPLORATION_LOCATIONS, EXPLORATION_ZONES);
        }
Esempio n. 4
0
        protected ActorAction ExecuteOrder(RogueGame game, ActorOrder order, List <Percept> percepts, ExplorationData exploration)
        {
            // cancel if leader is dead!
            if (m_Actor.Leader == null || m_Actor.Leader.IsDead)
            {
                return(null);
            }

            // execute task.
            switch (order.Task)
            {
            case ActorTasks.BARRICADE_ONE:
                return(ExecuteBarricading(game, order.Location, false));

            case ActorTasks.BARRICADE_MAX:
                return(ExecuteBarricading(game, order.Location, true));

            case ActorTasks.BUILD_SMALL_FORTIFICATION:
                return(ExecuteBuildFortification(game, order.Location, false));

            case ActorTasks.BUILD_LARGE_FORTIFICATION:
                return(ExecuteBuildFortification(game, order.Location, true));

            case ActorTasks.DROP_ALL_ITEMS:
                return(ExecuteDropAllItems(game));

            case ActorTasks.GUARD:
                return(ExecuteGuard(game, order.Location, percepts));

            case ActorTasks.PATROL:
                return(ExecutePatrol(game, order.Location, percepts, exploration));

            case ActorTasks.REPORT_EVENTS:
                return(ExecuteReport(game, percepts));

            case ActorTasks.SLEEP_NOW:
                return(ExecuteSleepNow(game, percepts));

            case ActorTasks.FOLLOW_TOGGLE:
                return(ExecuteToggleFollow(game));

            case ActorTasks.WHERE_ARE_YOU:
                return(ExecuteReportPosition(game));

            default:
                throw new NotImplementedException("order task not handled");
            }
        }
Esempio n. 5
0
        ActorAction ExecutePatrol(RogueGame game, Location location, List <Percept> percepts, ExplorationData exploration)
        {
            ////////////////////////////////
            // Interrupt patrol
            // 1. See enemy => raise alarm.
            ////////////////////////////////

            // 1. See enemy => raise alarm.
            List <Percept> enemies = FilterEnemies(game, percepts);

            if (enemies != null)
            {
                // ALAAAARRMM!!
                SetOrder(null);
                Actor nearestEnemy = FilterNearest(game, enemies).Percepted as Actor;
                if (nearestEnemy == null)
                {
                    throw new InvalidOperationException("null nearest enemy");
                }
                return(new ActionShout(m_Actor, game, String.Format("{0} sighted!!", nearestEnemy.Name)));
            }

            //////////////////////////////
            // Patrol duty actions:
            // Check if patrol position reached.
            // 1. Mimick leader cell phone usage.
            // 2. Move to patrol position.
            // 3. Eat if hungry.
            // 4. Heal if need to.
            // 5. Wander in patrol zone.
            /////////////////////////////

            // Check patrol position reached.
            if (!m_ReachedPatrolPoint)
            {
                m_ReachedPatrolPoint = m_Actor.Location.Position == location.Position;
            }

            // 1. Mimick leader cell phone usage.
            ActorAction phoneAction = BehaviorEquipCellPhone(game);

            if (phoneAction != null)
            {
                m_Actor.Activity = Activity.IDLE;
                return(phoneAction);
            }
            phoneAction = BehaviorUnequipCellPhoneIfLeaderHasNot(game);
            if (phoneAction != null)
            {
                m_Actor.Activity = Activity.IDLE;
                return(phoneAction);
            }

            // 2. Move to patrol position.
            if (!m_ReachedPatrolPoint)
            {
                ActorAction bumpAction = BehaviorIntelligentBumpToward(game, location.Position, false, false);
                if (bumpAction != null)
                {
                    m_Actor.Activity = Activity.IDLE;
                    return(bumpAction);
                }
            }

            // 3. Eat if hungry.
            if (game.Rules.IsActorHungry(m_Actor))
            {
                ActorAction eatAction = BehaviorEat(game);
                if (eatAction != null)
                {
                    m_Actor.Activity = Activity.IDLE;
                    return(eatAction);
                }
            }

            // 4. Heal if need to.
            ActorAction useMedAction = BehaviorUseMedecine(game, 2, 1, 2, 4, 2);

            if (useMedAction != null)
            {
                m_Actor.Activity = Activity.IDLE;
                return(useMedAction);
            }

            // 5. Wander in patrol zones.
            List <Zone> patrolZones = location.Map.GetZonesAt(Order.Location.Position.X, Order.Location.Position.Y);

            return(BehaviorWander(game, (loc) =>
            {
                List <Zone> zonesHere = loc.Map.GetZonesAt(loc.Position.X, loc.Position.Y);
                if (zonesHere == null)
                {
                    return false;
                }
                foreach (Zone zHere in zonesHere)
                {
                    foreach (Zone zPatrol in patrolZones)
                    {
                        if (zHere == zPatrol)
                        {
                            return true;
                        }
                    }
                }
                return false;
            }, exploration
                                  ));
        }