コード例 #1
0
        public void turnTickAI_Basic(Map map)
        {
            foreach (Evidence ev in evidenceCarried)
            {
                if (ev.pointsTo != null && ev.pointsTo != this)
                {
                    if (huntableSuspects.Contains(ev.pointsTo) == false)
                    {
                        huntableSuspects.Add(ev.pointsTo);
                    }
                }
            }

            if (this.location.soc == society)
            {
                sinceHome = 0;
                if (this.hp < maxHp && task == null && location.settlement != null)
                {
                    task = new Task_Resupply();
                }
            }
            else
            {
                sinceHome += 1;
            }

            if (task == null || task is Task_Wander)
            {
                bool onDisease = false;
                foreach (Property pr in location.properties)
                {
                    if (pr.proto.isDisease)
                    {
                        onDisease = true;
                        break;
                    }
                }
                if (onDisease)
                {
                    task = new Task_TreatDisease();
                    task.turnTick(this);
                    return;
                }
            }

            if (task != null)
            {
                task.turnTick(this);
                return;
            }
            else if (society.isAtWar())
            {
                task = new Task_SupportMilitary();
            }
            else if (location.evidence.Count > 0)
            {
                task = new Task_Investigate();
            }
            else if (sinceHome > wanderDur)
            {
                task = new Task_GoToSocialGroup(society);
            }
            else
            {
                task = new Task_Wander();
            }


            task.turnTick(this);
        }
コード例 #2
0
        public override void turnTickAI(Map map)
        {
            if (this.location.soc == society)
            {
                sinceHome = 0;

                /*
                 * if (person != null && location.person() != null && location.person().state != Person.personState.broken){
                 *  foreach (RelObj rel in person.relations.Values)
                 *  {
                 *      double them = location.person().getRelation(rel.them).suspicion;
                 *      double me = rel.suspicion;
                 *      if (me > them)
                 *      {
                 *          map.addMessage(this.getName() + " warns " + location.person().getFullName() + " about " + rel.them.getFullName(),MsgEvent.LEVEL_ORANGE,false);
                 *          location.person().getRelation(rel.them).suspicion = me;
                 *      }
                 *  }
                 * }
                 */
            }
            else
            {
                sinceHome += 1;
            }

            //Scan local units
            foreach (Unit u in location.units)
            {
                if (u.isEnthralled())
                {
                    if (this.person != null && u.person != null)
                    {
                        this.person.getRelation(u.person).suspicion = Math.Min(1, this.person.getRelation(u.person).suspicion + map.param.unit_suspicionFromProximity);
                        map.addMessage(this.getName() + " has gained suspicion of " + u.getName(), MsgEvent.LEVEL_RED, false);
                    }
                }
            }


            if (task != null)
            {
                task.turnTick(this);
                return;
            }

            if (location.evidence.Count > 0)
            {
                task = new Task_Investigate();
            }
            else if (sinceHome > wanderDur)
            {
                task = new Task_GoToSocialGroup(society);
            }
            else
            {
                task = new Task_Wander();
            }


            task.turnTick(this);
        }
コード例 #3
0
        public void turnTickAI_Investigator(Map map)
        {
            foreach (Evidence ev in evidenceCarried)
            {
                if (ev.pointsTo != null && ev.pointsTo != this)
                {
                    if (huntableSuspects.Contains(ev.pointsTo) == false)
                    {
                        huntableSuspects.Add(ev.pointsTo);
                    }
                }
            }

            if (this.location.soc == society)
            {
                sinceHome = 0;
                if (this.hp < maxHp && task == null && location.settlement != null)
                {
                    task = new Task_Resupply();
                }
            }
            else
            {
                sinceHome += 1;
            }

            //Scan local units
            if (map.param.unit_investigatorsSeeEnthralled == 1)
            {
                foreach (Unit u in location.units)
                {
                    if (u.isEnthralled() && u.person != null && this.person.getRelation(u.person).suspicion > 0)
                    {
                        if (this.person != null && u.person != null)
                        {
                            this.person.getRelation(u.person).suspicion = Math.Min(1, this.person.getRelation(u.person).suspicion + map.param.unit_suspicionFromProximity);
                            map.addMessage(this.getName() + " has gained suspicion of " + u.getName(), MsgEvent.LEVEL_ORANGE, false, location.hex);
                        }
                    }
                }
            }


            if (task != null)
            {
                task.turnTick(this);
                return;
            }

            if (shouldBePaladin(map))
            {
                Unit   target   = null;
                double bestDist = -1;
                foreach (Unit u in huntableSuspects)
                {
                    if (map.units.Contains(u))
                    {
                        double dist = map.getStepDist(u.location, location);
                        if (bestDist == -1 || dist < bestDist)
                        {
                            bestDist = dist;
                            target   = u;
                        }
                    }
                }

                task             = new Task_HuntEnthralled_PaladinState(this, target);
                paladinTarget    = target;
                state            = unitState.paladin;
                lastTurnPromoted = map.turn;
                if (hostility.Contains(paladinTarget) == false)
                {
                    hostility.Add(paladinTarget);
                }
                paladinDuration = map.param.unit_paladin_promotionDuration;
                map.world.prefabStore.popMsgAgent(this, target, this.getName() + " has found evidence that " + paladinTarget.getName() + " is in league with the darkness," +
                                                  " and has been granted the powers of the paladin, to hunt them down for a duration. They are currently in " + location.getName() + ".");

                //Update your graphic
                if (this.outer != null)
                {
                    this.outer.checkData();
                }
                return;
            }
            else if (location.evidence.Count > 0)
            {
                task = new Task_Investigate();
            }
            else if (sinceHome > wanderDur)
            {
                task = new Task_GoToSocialGroup(society);
            }
            else
            {
                task = new Task_Wander();
            }


            task.turnTick(this);
        }