Exemplo n.º 1
0
        public virtual void disband(Map map, string msg)
        {
            if (person != null)
            {
                person.isDead = true;
            }
            map.remove(this);
            location.units.Remove(this);
            if (location.units.Contains(this))
            {
                throw new Exception("Double-presence in list " + this.getName());
            }
            if (msg != null)
            {
                bool positive = person == null || person.state != Person.personState.enthralledAgent;
                map.addMessage(msg, MsgEvent.LEVEL_GREEN, positive, location.hex);

                if (this.isEnthralled())
                {
                    map.world.prefabStore.popMsg(this.getName() + " is gone.\n" + msg);
                }
            }
            foreach (Location loc in map.locations)
            {
                if (loc.units.Contains(this))
                {
                    throw new Exception("My loc " + this.location.getName() + " but am at " + loc.getName());
                }
            }
        }
Exemplo n.º 2
0
        public void die(Map map, string v)
        {
            isDead = true;

            if (GraphicalMap.selectedSelectable == this)
            {
                GraphicalMap.selectedSelectable = null;
            }
            if (person != null)
            {
                person.die(v, false);
            }
            disband(map, null);
            bool positive = person == null || person.state != Person.personState.enthralledAgent;

            if (society.isDark())
            {
                positive = false;
            }
            map.addMessage(this.getName() + " dies! " + v, MsgEvent.LEVEL_GREEN, positive, location.hex);

            if (this.person != null && person.isWatched())
            {
                //map.world.prefabStore.popMsg(this.getName() + " dies!\n" + v);
                map.world.prefabStore.popMsgAgentDeath(this, this.getName() + " dies!\n" + v);
            }
        }
Exemplo n.º 3
0
        public void die(Map map, string v)
        {
            person.die(v);
            disband(map, null);
            bool positive = person == null || person.state != Person.personState.enthralledAgent;

            map.addMessage(this.getName() + " dies! " + v, MsgEvent.LEVEL_GREEN, positive);

            if (this.isEnthralled())
            {
                map.world.prefabStore.popMsg(this.getName() + " dies!\n" + v);
            }
        }
Exemplo n.º 4
0
        public virtual void disband(Map map, string msg)
        {
            person.isDead = true;
            map.remove(this);
            location.units.Remove(this);
            if (msg != null)
            {
                bool positive = person == null || person.state != Person.personState.enthralledAgent;
                map.addMessage(msg, MsgEvent.LEVEL_GREEN, positive);

                if (this.isEnthralled())
                {
                    map.world.prefabStore.popMsg(this.getName() + " is gone.\n" + msg);
                }
            }
        }
Exemplo n.º 5
0
        public virtual bool checkForDisband(Map map)
        {
            if (parentLocation != null)
            {
                if (parentLocation.soc == null)
                {
                    if (person.state == Person.personState.enthralledAgent)
                    {
                        map.world.prefabStore.popMsg(this.getName() + " disbands as the location they depended on, " + parentLocation.getName() + ", is lost.");
                    }
                    disband(map, this.getName() + " disbands as their home is lost.");
                    return(true);
                }
                else
                {
                    if (this.society != parentLocation.soc)
                    {
                        this.society = parentLocation.soc;
                        map.addMessage(this.getName() + " switches society to " + this.society.getName(), MsgEvent.LEVEL_GRAY, false);
                    }
                }
                return(false);
            }

            if (map.socialGroups.Contains(society) == false)
            {
                if (person != null)
                {
                    if (person.state == Person.personState.enthralledAgent)
                    {
                        map.world.prefabStore.popMsg(this.getName() + " disbands as the society they depended on, " + this.society.getName() + ", is no more.");
                    }
                    disband(map, this.getName() + " disbands as their society is gone");
                    return(true);
                }
            }
            return(false);
        }
        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);
        }
        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);
        }