public override void castInner(Map map, Unit u)
        {
            Property.addProperty(map, u.location, "Rotting Sickness");
            u.location.map.world.prefabStore.popImgMsg("The first victim of this wave of the Rotting Sickness is in " + u.location.getName() + "."
                                                       + " The disease will spread between cities (unless quarantined or immune), and will decrease the city's population by 1 every 2 turns.",
                                                       u.location.map.world.wordStore.lookup("ABILITY_DOCTOR_ROTTING_SICKNESS"));

            if (u.location.soc != null && u.location.soc is Society)
            {
                Society soc = (Society)u.location.soc;
                soc.crisisPlague     = "Plagues have appeared in our lands";
                soc.crisisPlagueLong = "Diseases are spreading throughout our lands";
            }

            if (u is Unit_NecroDoctor doc)
            {
                doc.corpses -= map.param.unit_doctor_rottingDeadReq;
            }

            double   amount = map.param.unit_majorEvidence;
            Evidence e2     = new Evidence(map.turn);

            e2.pointsTo = u;
            e2.weight   = amount;
            u.location.evidence.Add(e2);
        }
        public override void cast(Map map, Hex hex)
        {
            base.cast(map, hex);

            Property.addProperty(map, hex.location, "Cult of the Deep");
            World.log("Properties: " + hex.location.properties.Count);

            map.world.prefabStore.popImgMsg("You call to the land, starting a cult in " + hex.location.getName() + ". Humans will slowly convert and join your Deep One Forces, but the rest will fear them.",
                                            map.world.wordStore.lookup("ABILITY_FISHMAN_CALL"));
        }
        public override void cast(Map map, Hex hex)
        {
            base.cast(map, hex);

            Property.addProperty(map, hex.location, "Cult of the Deep");
            World.log("Properties: " + hex.location.properties.Count);

            map.world.prefabStore.popImgMsg("You call to the land, starting a cult in " + hex.location.getName() + ". " +
                                            "Humans will slowly convert and join your Deep One Forces, but the rest will fear them. Those which are present allow you to gain access to the settlement, as they yield to your dark will, increasing infiltration.",
                                            map.world.wordStore.lookup("ABILITY_FISHMAN_CALL"));
        }
Пример #4
0
        public override void cast(Map map, Hex hex)
        {
            base.cast(map, hex);

            Property.addProperty(map, map.overmind.enthralled.getLocation(), "Military Aid Outgoing");
            Property.addProperty(map, hex.location, "Military Aid");

            map.world.prefabStore.popImgMsg(
                "You add military support to " + hex.getName() + ". This will increase its military cap, allowing more levies, once the men-at-arms are recruited. It also gives aid to nobles who"
                + " would rebel against their nation.",
                map.world.wordStore.lookup("ABILITY_MILITARY_AID"));
        }
        public override void cast(Map map, Hex hex)
        {
            base.cast(map, hex);
            if (!castable(map, hex))
            {
                return;
            }


            Property.addProperty(map, hex.location, "Haunting Song");

            map.world.prefabStore.popImgMsg("The song of the Deep Ones at " + hex.location.getName() + " grows to a maddening pitch, constant regardless of obstruction. " + hex.location.person().getFullName() + "'s sanity will drop over time as the song persists.",
                                            map.world.wordStore.lookup("ABILITY_FISHMAN_HAUNTING_SONG"));
        }
Пример #6
0
        public override void cast(Map map, Hex hex)
        {
            base.cast(map, hex);
            if (!castable(map, hex))
            {
                return;
            }

            Property.addProperty(map, hex.location, "Trapped Fog");

            map.world.prefabStore.popImgMsg(
                "The fog will remain in this location for a while, keeping this location available for your agents and nobles to benefit from it, without risk of it being swept away by the winds.",
                map.world.wordStore.lookup("FOG_TRAP_FOG"), 6);
        }
Пример #7
0
        public override void cast(Map map, Hex hex)
        {
            base.cast(map, hex);
            if (!castable(map, hex))
            {
                return;
            }

            Property.addProperty(map, hex.location, "Well of Fog");

            map.world.prefabStore.popImgMsg(
                "This location is now a source of fog. Fog will pour out from here, as long as the noble remains under your influence. Fog decreases locations' security, " +
                "allows your agents to operate in areas they were exiled from and slows the rate at which nobles become suspicious.",
                map.world.wordStore.lookup("FOG_WELL_OF_FOG"), 6);
        }
        public override void cast(Map map, Hex hex)
        {
            base.cast(map, hex);
            if (!castable(map, hex))
            {
                return;
            }


            Property.addProperty(map, hex.location, "Abyssal Sirens");

            map.world.prefabStore.popImgMsg("The cult of the Deep at " + hex.location.getName() + " now takes over the minds of the population, including " + hex.location.person().getFullName() + "."
                                            + " They will now slowly fall into shadow.",
                                            map.world.wordStore.lookup("ABILITY_FISHMAN_ABYSSAL_SIRENS"));
        }
        public override void cast(Map map, Hex hex)
        {
            base.cast(map, hex);

            Property.addProperty(map, hex.location, "Information Blackout");
            foreach (SocialGroup sg in map.socialGroups)
            {
                map.recomputeInformationAvailability(sg);
            }

            map.world.prefabStore.popImgMsg(
                hex.getName() + " loses touch with the world, preventing information from getting through."
                + "Messengers get lost, carrier pidgeons never arrive. Nobles will fear groups less if they have less information about them.",
                map.world.wordStore.lookup("ABILITY_INFORMATION_BLACKOUT"));
        }
Пример #10
0
        public override void turnTick(Unit unit)
        {
            if (unit.location.soc == null || (unit.location.soc is Society == false))
            {
                unit.task = null; return;
            }
            if (unit.location.settlement == null)
            {
                unit.task = null;  return;
            }


            dur += 1;
            if (dur >= unit.location.settlement.getSecurity(new List <ReasonMsg>()))
            {
                foreach (string str in diseasesToSpread)
                {
                    Property.addProperty(unit.location.map, unit.location, str);
                }
                unit.location.map.world.prefabStore.popImgMsg(unit.getName() + " has circumvented security, and spread disease to " + unit.location.getName(),
                                                              unit.location.map.world.wordStore.lookup("ABILITY_RED_OUTBREAK"), 5);
                unit.task = null;

                List <Property> rems = new List <Property>();
                foreach (Property pr in unit.location.properties)
                {
                    if (pr.proto.isImmunity)
                    {
                        rems.Add(pr);
                    }
                }
                foreach (Property pr in rems)
                {
                    pr.proto.endProperty(unit.location, pr);
                    unit.location.properties.Remove(pr);
                }

                Society soc = (Society)unit.location.soc;
                soc.crisisPlague     = "Plagues are spreading";
                soc.crisisPlagueLong = "Diseases are spreading throughout our lands, carried by some unknown ghastly apparition";

                Evidence e = new Evidence(unit.location.map.turn);
                e.pointsTo = unit;
                e.weight   = unit.location.map.param.unit_minorEvidence;
                unit.location.evidence.Add(e);
            }
        }
        public override void castInner(Map map, Unit u)
        {
            Unit_NecroDoctor doc = (Unit_NecroDoctor)u;

            Property.addProperty(map, u.location, "Empty Graves");


            doc.corpses += map.param.unit_doctor_lootBodiesAmount;
            if (doc.corpses > doc.maxCorpses)
            {
                doc.corpses = doc.maxCorpses;
            }

            u.location.map.world.prefabStore.popImgMsg(u.getName() + " removes the bodies from " + u.location.getName() + ", using official documents (forged or otherwise) to justify their actions." +
                                                       " Therefore no evidence is left behind. They have " + doc.corpses + "/" + doc.maxCorpses
                                                       + " corpses, these should be carried to a corpseroot field before they decay.",
                                                       u.location.map.world.wordStore.lookup("ABILITY_DOCTOR_LEGAL_REMOVAL"));
        }
Пример #12
0
        public override void castInner(Map map, Unit u)
        {
            Property.addProperty(map, u.location, "Red Death");
            u.location.map.world.prefabStore.popImgMsg("The nobles of " + u.location.soc.getName() + " are now faced with a terrible choice. One, and only one, noble with the disease can be cure. But who to choose?" +
                                                       " They must vote on who is saved, giving you ample room to cause conflict and resentment, especially if the nobles are corrupt.",
                                                       u.location.map.world.wordStore.lookup("ABILITY_RED_SINGLE_USE_CURE"), 5);

            if (u.location.soc != null && u.location.soc is Society)
            {
                Society     soc   = (Society)u.location.soc;
                VoteSession sess  = new VoteSession();
                VoteIssue   issue = new VoteIssue_Crisis_SingleUseMedicine(soc, u.location.person());
                sess.issue      = issue;
                soc.voteSession = sess;

                foreach (Location loc in map.locations)
                {
                    if (loc.soc != soc)
                    {
                        continue;
                    }
                    if (loc.settlement != null && loc.person() != null)
                    {
                        bool diseased = false;
                        foreach (Property pr in loc.properties)
                        {
                            if (pr.proto.isDisease)
                            {
                                diseased = true;
                                break;
                            }
                        }

                        if (diseased)
                        {
                            VoteOption opt = new VoteOption();
                            opt.person = loc.person();
                            issue.options.Add(opt);
                        }
                    }
                }
            }
        }
        public override void cast(Map map, Hex hex)
        {
            base.cast(map, hex);
            if (!castable(map, hex))
            {
                return;
            }

            Property.addProperty(hex.map, hex.location, "Blizzard");

            hex.location.recomputeLinkDisabling();
            foreach (Link l in hex.location.links)
            {
                l.other(hex.location).recomputeLinkDisabling();
            }

            int      nDisabled     = 0;
            Location disabledOther = null;

            foreach (Link l in hex.location.links)
            {
                if (l.disabled)
                {
                    nDisabled += 1; disabledOther = l.other(hex.location);
                }
            }

            string add = "";

            if (nDisabled == 1)
            {
                add = "\nIts links to " + disabledOther.getName() + " has been severed.";
            }
            if (nDisabled > 1)
            {
                add = "\nIts links to " + nDisabled + " other locations has been severed.";
            }
            map.world.prefabStore.popImgMsg("The snow falls deep in " + hex.location.getName() + ", and is driven by icy winds. Roads risk being inundated beneath impassable walls of snowfall if the blizzard moves across the land to nearby settlements."
                                            + add,
                                            map.world.wordStore.lookup("ABILITY_ICE_BLIZZARD"));
        }
        public override void castInner(Map map, Unit u)
        {
            Property.addProperty(map, u.location, "Red Death");
            u.location.map.world.prefabStore.popImgMsg("The first victim of this wave of the Red Death is in " + u.location.getName() + "."
                                                       + " The disease will spread between cities (unless quarantined or immune), and will decrease the city's population by 1 per turn.",
                                                       u.location.map.world.wordStore.lookup("ABILITY_RED_DEATH_ORIGIN"), 5);

            if (u.location.soc != null && u.location.soc is Society)
            {
                Society soc = (Society)u.location.soc;
                soc.crisisPlague     = "Plagues have appeared in our lands";
                soc.crisisPlagueLong = "Diseases are spreading throughout our lands, carried by some unknown ghastly apparition";
            }

            double   amount = map.param.unit_majorEvidence;
            Evidence e2     = new Evidence(map.turn);

            e2.pointsTo = u;
            e2.weight   = amount;
            u.location.evidence.Add(e2);
        }
Пример #15
0
        public void processKillOrders()
        {
            foreach (KillOrder order in killOrders)
            {
                if (people.Contains(order.person))
                {
                    bool makePumpkin = false;
                    if (order.votedByNobles)
                    {
                        foreach (Unit u in map.units)
                        {
                            if (u is Unit_HeadlessHorseman)
                            {
                                makePumpkin = true;
                            }
                        }
                    }
                    if (order.person.shadow > 0.3)
                    {
                        makePumpkin = false;
                    }
                    if (order.person.state != Person.personState.normal && order.person.state != Person.personState.lightbringer)
                    {
                        makePumpkin = false;
                    }
                    if (makePumpkin)
                    {
                        Property.addProperty(map, order.person.getLocation(), "Pumpkin");
                        map.world.prefabStore.popImgMsg("The society of " + getName() + " has executed " + order.person.getFullName() + "! Their head-pumpkin is now available in " +
                                                        order.person.getLocation().getName() + " for the horseman to steal!",
                                                        "\"If you take my head, I'll take yours! All of yours!\"", 3);
                    }

                    order.person.die("Executed by " + this.getName() + ". Reason: " + order.reason, true);
                }
            }
        }
Пример #16
0
        public override void castInner(Map map, Unit u)
        {
            Unit_NecroDoctor doc = (Unit_NecroDoctor)u;

            Property.addProperty(map, u.location, "Empty Graves");


            double   amount = map.param.unit_minorEvidence;
            Evidence e2     = new Evidence(map.turn);

            e2.pointsTo = u;
            e2.weight   = amount;
            u.location.evidence.Add(e2);

            int security = 0;

            if (u.location.settlement != null)
            {
                security = u.location.settlement.getSecurity(new System.Collections.Generic.List <ReasonMsg>());
            }
            int nStolen = map.param.unit_doctor_lootBodiesAmount - security;

            if (nStolen < 1)
            {
                nStolen = 1;
            }
            doc.corpses += nStolen;
            if (doc.corpses > doc.maxCorpses)
            {
                doc.corpses = doc.maxCorpses;
            }

            u.location.map.world.prefabStore.popImgMsg(u.getName() + " loots " + nStolen + " bodies from " + u.location.getName() + " (Maximum is " + map.param.unit_doctor_lootBodiesAmount
                                                       + " location security is " + security + "). They have " + doc.corpses + "/" + doc.maxCorpses
                                                       + " corpses, these should be carried to a corpseroot field before they decay.",
                                                       u.location.map.world.wordStore.lookup("ABILITY_DOCTOR_ROB_GRAVES"));
        }
        public override void implement(VoteOption option)
        {
            base.implement(option);

            society.lastEvidenceResponse = society.map.turn;
            foreach (Evidence ev in foundEvidence)
            {
                society.handledEvidence.Add(ev);
            }

            if (option.index == DEFEND_PROVINCE)
            {
                World.log(society.getName() + " implements crisis legislation, increasing security to " + society.map.provinces[option.province].name);
                foreach (Location loc in society.map.locations)
                {
                    if (loc.province.index == option.province && loc.soc == society)
                    {
                        Property.addProperty(society.map, loc, "Major Security Boost");
                    }
                }
                society.map.addMessage(society.getName() + " raises " + society.map.provinces[option.province].name + " security level", MsgEvent.LEVEL_ORANGE, false, society.map.provinces[option.province].coreHex);
            }
            if (option.index == NATIONWIDE_SECURITY)
            {
                World.log(society.getName() + " implements crisis legislation, increasing security nationwide");
                foreach (Location loc in society.map.locations)
                {
                    if (loc.province.index == option.province && loc.soc == society)
                    {
                        Property.addProperty(society.map, loc, "Minor Security Boost");
                    }
                }
                society.map.addMessage(society.getName() + " raises its security level nationwide", MsgEvent.LEVEL_ORANGE, false, society.getCapitalHex());
            }
            if (option.index == NO_RESPONSE)
            {
                World.log(society.getName() + " implements crisis legislation, does nothing");
            }
            if (option.index == EXPELL_ALL_FOREIGN_AGENTS)
            {
                bool agentsExpelled = false;
                foreach (Unit u in society.map.units)
                {
                    if (u.society != society && society.enemies.Contains(u) == false)
                    {
                        society.enemies.Add(u);
                        if (u.isEnthralled())
                        {
                            agentsExpelled = true;
                        }
                    }
                }
                if (agentsExpelled)
                {
                    society.map.world.prefabStore.popMsg(society.getName() + " expells all foreign agents, in response to evidence discovered." +
                                                         " All your existing agents will now be attacked on sight if they enter or are in its lands. New agents will still be acceptable.");
                }
                World.log(society.getName() + " implements crisis legislation, expelling all foreign agents");
                society.map.addMessage(society.getName() + " outlaws all foreign agents", MsgEvent.LEVEL_RED, false, society.getCapitalHex());
            }
            if (option.index == INVESTIGATOR_HOSTILITY)
            {
                foreach (Evidence ev in foundEvidence)
                {
                    if (ev.discoveredBy.society == society && ev.discoveredBy != null && ev.pointsTo != null && (ev.discoveredBy.hostileTo(ev.pointsTo) == false))
                    {
                        ev.discoveredBy.hostility.Add(ev.pointsTo);
                        society.map.addMessage(ev.discoveredBy.getName() + " permitted to attack " + ev.pointsTo.getName(), MsgEvent.LEVEL_RED, !ev.pointsTo.isEnthralled());
                        if (ev.pointsTo.isEnthralled())
                        {
                            society.map.world.prefabStore.popMsg("The nobles of " + society.getName() + " have given permission their agent, " + ev.discoveredBy.getName()
                                                                 + " to attack " + ev.pointsTo.getName() + " on sight, if they encounter them during investigations.");
                        }
                    }
                }
            }
            if (option.index == LOCKDOWN_PROVINCE)
            {
                World.log(society.getName() + " implements crisis legislation, fully locking down " + society.map.provinces[option.province].name);
                Unit enthralledVic = null;
                foreach (Location loc in society.map.locations)
                {
                    if (loc.province.index == option.province && loc.soc == society)
                    {
                        Property.addProperty(society.map, loc, "Lockdown");
                        foreach (Unit u in loc.units)
                        {
                            if (u.isEnthralled())
                            {
                                enthralledVic = u;
                            }
                        }
                    }
                }
                society.map.addMessage(society.getName() + " locks down " + society.map.provinces[option.province].name, MsgEvent.LEVEL_ORANGE, false, society.map.provinces[option.province].coreHex);
                if (enthralledVic != null)
                {
                    society.map.world.prefabStore.popMsg(society.getName() + " has imposed a complete lockdown in the province " + society.map.provinces[option.province].name +
                                                         " which impacts your agent " + enthralledVic.getName() + "'s ability to operate until the lockdown is over.");
                }
            }

            if (option.index == AGENT_TO_INVESTIGATOR)
            {
                Unit_Investigator inv = (Unit_Investigator)option.unit;
                inv.changeState(Unit_Investigator.unitState.investigator);
                World.self.prefabStore.popMsgAgent(option.unit, option.unit, option.unit.getName() + " has been assigned the role of Investigator, by the nobles of " + option.unit.society.getName() +
                                                   " in response to external threats. Investigators are experts at combatting your agents. They can recognise evidence and spot your agents if they are in the same location.");
            }
            if (option.index == AGENT_TO_BASIC)
            {
                Unit_Investigator inv = (Unit_Investigator)option.unit;
                inv.changeState(Unit_Investigator.unitState.basic);
                if (inv.person.isWatched())
                {
                    World.self.prefabStore.popMsgAgent(option.unit, option.unit, option.unit.getName() + " has been assigned the role of Agent, by the nobles of " + option.unit.society.getName() +
                                                       " in response to external threats. Standard agents are general-purpose units. They can investigate your agents' evidence, and can assist in wars. They can be promoted "
                                                       + " to specalists by vote.");
                }
            }
        }
        public void combatAction(Unit u, Unit u2, Location loc)
        {
            if (u is Unit_Merchant && (u.isEnthralled() == false))
            {
                return;
            }
            if (u.isMilitary == false && u2.isMilitary == false && u.isEnthralled() && u2.society == loc.soc)
            {
                //Enthralled attacking an agent in their homeland
                //Can be defended by military units locally stationned
                Unit defender = null;
                if (loc.settlement != null && loc.settlement.embeddedUnit != null)
                {
                    defender = loc.settlement.embeddedUnit;
                }
                foreach (Unit u3 in loc.units)
                {
                    if (u3.isMilitary && u3.society == u2.society)
                    {
                        defender = u3;
                    }
                }
                if (defender != null)
                {
                    loc.map.world.prefabStore.popMsg("You agent cannot attack " + u2.getName() + " as they are defended the military unit present (" + defender.getName() + ")");
                    u.movesTaken -= 1;
                    return;
                }
            }

            double lethality    = loc.map.param.combat_lethality;
            double lethalityDef = loc.map.param.combat_lethalityDefensive;

            bool hadAttackBonus = false;

            foreach (Unit bonusU in u.location.units)
            {
                if (bonusU.society == u.society && bonusU is Unit_Investigator && bonusU.task is Task_SupportMilitary)
                {
                    if (((Unit_Investigator)bonusU).state == Unit_Investigator.unitState.knight)
                    {
                        lethality     *= param.unit_knightCombatBonus;
                        hadAttackBonus = true;
                        break;
                    }
                    if (((Unit_Investigator)bonusU).state == Unit_Investigator.unitState.basic)
                    {
                        lethality     *= param.unit_agentCombatBonus;
                        hadAttackBonus = true;
                        break;
                    }
                }
            }
            foreach (Unit bonusU in u2.location.units)
            {
                if (bonusU.society == u2.society && bonusU is Unit_Investigator && bonusU.task is Task_SupportMilitary)
                {
                    if (((Unit_Investigator)bonusU).state == Unit_Investigator.unitState.knight)
                    {
                        lethalityDef  *= param.unit_knightCombatBonus;
                        hadAttackBonus = true;
                        break;
                    }
                    if (((Unit_Investigator)bonusU).state == Unit_Investigator.unitState.basic)
                    {
                        lethalityDef  *= param.unit_agentCombatBonus;
                        hadAttackBonus = true;
                        break;
                    }
                }
            }

            if (burnInComplete)
            {
                world.prefabStore.particleCombat(u.location.hex, u2.location.hex);
            }
            int dmgDone = (int)(u.hp * (lethality + (Eleven.random.NextDouble() * lethality)));

            if (u2.isMilitary)
            {
                if (loc.settlement != null && loc.settlement.defensiveStrengthCurrent > 0 && u2.society == loc.soc)
                {
                    double ablated = Math.Min(loc.settlement.defensiveStrengthCurrent, dmgDone / 2d);
                    dmgDone -= (int)ablated;
                    loc.settlement.defensiveStrengthCurrent -= ablated;
                }

                int dmgReplied = (int)(u2.hp * (lethalityDef + (Eleven.random.NextDouble() * lethalityDef)));
                if (dmgReplied >= u.hp)
                {
                    dmgReplied = u.hp - 1;
                    if (dmgReplied < 0)
                    {
                        dmgReplied = 0;
                    }
                }
                u.hp -= dmgReplied;
            }


            if (dmgDone < 1)
            {
                dmgDone = 1;
            }

            bool kicked = false;

            if (dmgDone > 1 && (u2.isMilitary == false))
            {
                dmgDone = 1; kicked = true;
            }


            u2.hp -= dmgDone;
            if (u2.isEnthralled())
            {
                world.prefabStore.popMsgAgent(u, u2, u.getName() + " attacks " + u2.getName() + ", inflicting " + dmgDone + " HP damage!");
                //world.prefabStore.popMsg(u.getName() + " attacks " + u2.getName() + ", inflicting " + dmgDone + " HP damage!");
            }
            if (u.isEnthralled() && u2 is Unit_Investigator && u.person != null && u2.person != null)
            {
                u2.person.getRelation(u.person).suspicion = 1;
            }
            if (u.hp <= 0)
            {
                u.die(this, "Took damage attacking " + u2.getName());
            }

            if (u2.hp <= 0)
            {
                u2.die(this, "Attacked by " + u.getName());
            }
            else if (kicked)
            {
                int      c        = 0;
                Location kickedTo = null;
                foreach (Location l2 in u2.location.getNeighbours())
                {
                    bool bad = false;
                    foreach (Unit u3 in l2.units)
                    {
                        if (u3.hostileTo(u2) || u2.hostileTo(u3))
                        {
                            bad = true; break;
                        }
                    }
                    if (!bad)
                    {
                        c += 1;
                        if (Eleven.random.Next(c) == 0)
                        {
                            kickedTo = l2;
                        }
                    }
                }
                if (kickedTo != null)
                {
                    u2.task = null;
                    adjacentMoveTo(u2, kickedTo);
                    if (u2.isEnthralled())
                    {
                        world.prefabStore.popMsgAgent(u, u2, u2.getName() + " is forced to retreat, and is now in " + u2.location.getName());
                        //world.prefabStore.popMsg(u2.getName() + " is forced to retreat, and is now in " + u2.location.getName());
                    }
                }
            }

            if (u.isMilitary && loc.settlement != null)
            {
                //if (loc.settlement is Set_City)
                //{
                //    Set_City city = (Set_City)loc.settlement;
                //    //city.infrastructure *= (int)((Eleven.random.NextDouble() * 0.25) + 0.7);//0.05 to 0.3 dmg
                //    city.population *= (int)((Eleven.random.NextDouble() * 0.25) + 0.7);//0.05 to 0.3 dmg
                //    //if (city.infrastructure < 1) { city.infrastructure = 1; }
                //    if (city.population < 1) { city.population = 1; }
                //}
                loc.settlement.takeAssault(u.society, loc.soc, dmgDone);
            }

            if (u.isMilitary && u2.isMilitary && u.society is Society && u2.society is Society)
            {
                Property.addProperty(this, loc, "Recent Human Battle");
            }
        }
Пример #19
0
        public static void takeCommand(Map map, string command)
        {
            World.log("cheat command registered: " + command);


            try
            {
                if (command == "power")
                {
                    map.overmind.power = 100;
                }
                if (command == "testsave")
                {
                    map.world.save("testSave.sv");
                }
                if (command == "testload")
                {
                    map.world.load("testSave.sv");
                }
                if (command == "shadow")
                {
                    GraphicalMap.selectedHex.location.person().shadow = 1;
                }
                if (command == "aware")
                {
                    GraphicalMap.selectedHex.location.person().awareness = 1;
                }
                if (command == "testproperty")
                {
                    Property.addProperty(map, GraphicalMap.selectedHex.location, "Military Aid");
                    World.staticMap.world.ui.checkData();
                }
                if (command == "playback")
                {
                    World.staticMap.world.ui.addBlocker(World.staticMap.world.prefabStore.getPlayback(World.staticMap.world, World.staticMap).gameObject);
                }
                if (command == "uivoting")
                {
                    World.staticMap.world.ui.uiVoting.populate((Society)GraphicalMap.selectedHex.location.soc, GraphicalMap.selectedHex.location.person());
                    World.staticMap.world.ui.setToVoting();
                }
                if (command == "100")
                {
                    World.staticMap.world.b100Turns();
                }
                if (command == "enthrall")
                {
                    if (GraphicalMap.selectedHex.location.person() == null)
                    {
                        int    c      = 0;
                        Person choice = null;
                        foreach (Person p in ((Society)GraphicalMap.selectedHex.location.soc).people)
                        {
                            if (p.getLocation() == GraphicalMap.selectedHex.location)
                            {
                                c += 1;
                                if (Eleven.random.Next(c) == 0)
                                {
                                    choice = p;
                                }
                            }
                        }
                        choice.state            = Person.personState.enthralled;
                        map.overmind.enthralled = choice;
                    }
                    else
                    {
                        map.overmind.enthralled       = GraphicalMap.selectedHex.location.person();
                        map.overmind.enthralled.state = Person.personState.enthralled;
                    }
                }
                if (command == "love")
                {
                    foreach (Person p in map.overmind.enthralled.society.people)
                    {
                        p.getRelation(map.overmind.enthralled).addLiking(100, "Cheat love", map.turn);
                    }
                }
                if (command == "insanity")
                {
                    GraphicalMap.selectedHex.location.person().goInsane();
                }
                if (command == "hot")
                {
                    for (int i = 0; i < map.tempMap.Length; i++)
                    {
                        for (int j = 0; j < map.tempMap[0].Length; j++)
                        {
                            map.tempMap[i][j] += 0.1f;
                            if (map.tempMap[i][j] > 1)
                            {
                                map.tempMap[i][j] = 1;
                            }
                        }
                    }
                    map.assignTerrainFromClimate();
                    map.world.ui.checkData();
                }
                if (command == "cold")
                {
                    for (int i = 0; i < map.tempMap.Length; i++)
                    {
                        for (int j = 0; j < map.tempMap[0].Length; j++)
                        {
                            map.tempMap[i][j] -= 0.1f;
                            if (map.tempMap[i][j] < 0)
                            {
                                map.tempMap[i][j] = 0;
                            }
                        }
                    }
                    map.assignTerrainFromClimate();
                    map.world.ui.checkData();
                }
                if (command == "min sanity")
                {
                    GraphicalMap.selectedHex.location.person().sanity = 0.01;
                }
                if (command == "die")
                {
                    GraphicalMap.selectedHex.location.person().die("Killed by console");
                }
                if (command == "evidence")
                {
                    GraphicalMap.selectedHex.location.person().evidence = 1;
                }
                if (command == "10 evidence")
                {
                    GraphicalMap.selectedHex.location.person().evidence += 0.1;
                    if (GraphicalMap.selectedHex.location.person().evidence > 1)
                    {
                        GraphicalMap.selectedHex.location.person().evidence = 1;
                    }
                }
                if (command == "refresh")
                {
                    World.staticMap.overmind.hasTakenAction = false;
                }
                if (command == "unit")
                {
                    Unit u = new Unit_Investigator(GraphicalMap.selectedHex.location, (Society)GraphicalMap.selectedHex.location.soc);
                    map.units.Add(u);
                    GraphicalMap.selectedHex.location.units.Add(u);
                }
                if (command == "victory")
                {
                    World.staticMap.overmind.victory();
                }
                if (command == "placeevidence")
                {
                    GraphicalMap.selectedHex.location.evidence.Add(new Evidence(map.turn));
                    World.log("Placing evidence");
                }
                if (command == "vote")
                {
                    Society soc = map.overmind.enthralled.society;
                    if (soc.voteSession != null)
                    {
                        soc.voteSession.assignVoters();
                        World.log("Attempting to build blocker");
                        map.world.ui.addBlocker(map.world.prefabStore.getScrollSet(soc.voteSession, soc.voteSession.issue.options).gameObject);
                    }
                }
                map.world.ui.checkData();
            }
            catch (Exception e)
            {
                World.log(e.Message);
            }
        }
 public override void endProperty(Location location, Property p)
 {
     Property.addProperty(World.staticMap, location, "Rotting Sickness Immunity");
 }
Пример #21
0
        public override void implement(VoteOption option)
        {
            base.implement(option);

            society.crisisPlague         = null;
            society.crisisPlagueLong     = null;
            society.lastEvidenceResponse = society.map.turn;

            if (option.index == AGENT_TO_MEDIC)
            {
                Unit_Investigator inv = (Unit_Investigator)option.unit;
                inv.changeState(Unit_Investigator.unitState.medic);
                if (inv.person.isWatched())
                {
                    World.self.prefabStore.popMsgAgent(option.unit, option.unit, option.unit.getName() + " has been assigned the role of Apothecarian, by the nobles of " + option.unit.society.getName() +
                                                       " in response to external threats. Apothecarians excell in treating plagues, but cannot do anything else.");
                }
            }
            if (option.index == AGENT_TO_BASIC)
            {
                Unit_Investigator inv = (Unit_Investigator)option.unit;
                inv.changeState(Unit_Investigator.unitState.basic);
                if (inv.person.isWatched())
                {
                    World.self.prefabStore.popMsgAgent(option.unit, option.unit, option.unit.getName() + " has been assigned the role of Agent, by the nobles of " + option.unit.society.getName() +
                                                       " in response to external threats. Standard agents are general-purpose units. They can investigate your agents' evidence, and can assist in wars. They can be promoted "
                                                       + " to specalists by vote.");
                }
            }
            if (option.index == QUARANTINE)
            {
                foreach (Location loc in society.map.locations)
                {
                    if (loc.soc == society)
                    {
                        bool hasDisease = false;
                        foreach (Property pr in loc.properties)
                        {
                            if (pr.proto.isDisease)
                            {
                                hasDisease = true; break;
                            }
                        }
                        if (hasDisease)
                        {
                            Property.addProperty(loc.map, loc, "Quarantine");
                        }
                    }
                }
            }
            if (option.index == TREATMENT)
            {
                foreach (Location loc in society.map.locations)
                {
                    if (loc.soc == society)
                    {
                        bool hasDisease = false;
                        foreach (Property pr in loc.properties)
                        {
                            if (pr.proto.isDisease)
                            {
                                hasDisease = true; break;
                            }
                        }
                        if (hasDisease)
                        {
                            Property.addProperty(loc.map, loc, "Medical Aid");
                        }
                    }
                }
            }
        }
Пример #22
0
 public override void endProperty(Location location, Property p)
 {
     Property.addProperty(World.staticMap, location, "Red Death Immunity");
 }
Пример #23
0
        public static void takeCommand(Map map, string command)
        {
            World.log("cheat command registered: " + command);


            //try
            //{
            if (command == "power")
            {
                map.overmind.power = 100;
            }
            if (command == "testsave")
            {
                map.world.save("testSave");
            }
            if (command == "testload")
            {
                map.world.load("testSave");
            }
            if (command == "shadow")
            {
                GraphicalMap.selectedHex.location.person().shadow = 1;
            }
            if (command == "testproperty")
            {
                Property.addProperty(map, GraphicalMap.selectedHex.location, "Military Aid");
                World.staticMap.world.ui.checkData();
            }
            if (command == "playback")
            {
                World.staticMap.world.ui.addBlocker(World.staticMap.world.prefabStore.getPlayback(World.staticMap.world, World.staticMap).gameObject);
            }
            if (command == "100")
            {
                World.staticMap.world.b100Turns();
            }
            if (command == "enthrall")
            {
                if (GraphicalMap.selectedHex.location.person() == null)
                {
                    int    c      = 0;
                    Person choice = null;
                    foreach (Person p in ((Society)GraphicalMap.selectedHex.location.soc).people)
                    {
                        if (p.getLocation() == GraphicalMap.selectedHex.location)
                        {
                            c += 1;
                            if (Eleven.random.Next(c) == 0)
                            {
                                choice = p;
                            }
                        }
                    }
                    choice.state            = Person.personState.enthralled;
                    map.overmind.enthralled = choice;
                }
                else
                {
                    map.overmind.enthralled       = GraphicalMap.selectedHex.location.person();
                    map.overmind.enthralled.state = Person.personState.enthralled;
                }
            }
            if (command == "love")
            {
                foreach (Person p in map.overmind.enthralled.society.people)
                {
                    p.getRelation(map.overmind.enthralled).addLiking(100, "Cheat love", map.turn);
                }
            }
            if (command == "evidence")
            {
                GraphicalMap.selectedHex.location.person().evidence = 1;
            }
            if (command == "10 evidence")
            {
                GraphicalMap.selectedHex.location.person().evidence += 0.1;
                if (GraphicalMap.selectedHex.location.person().evidence > 1)
                {
                    GraphicalMap.selectedHex.location.person().evidence = 1;
                }
            }
            if (command == "refresh")
            {
                World.staticMap.overmind.hasTakenAction = false;
            }
            if (command == "victory")
            {
                World.staticMap.overmind.victory();
            }
            if (command == "vote")
            {
                Society soc = map.overmind.enthralled.society;
                if (soc.voteSession != null)
                {
                    soc.voteSession.assignVoters();
                    World.log("Attempting to build blocker");
                    map.world.ui.addBlocker(map.world.prefabStore.getScrollSet(soc.voteSession, soc.voteSession.issue.options).gameObject);
                }
            }
            //}
            //catch (Exception e)
            //{
            //    World.log(e.Message);
            //}
        }
        public void processWars()
        {
            //Every society decides which other to attack, assuming it is over threshold combat strength
            foreach (SocialGroup sg in socialGroups)
            {
                if (sg.lastBattle == turn)
                {
                    continue;
                }                                       //Only one battle permitted per social group (that they initiate, at least)

                if (checkDefensiveAttackHold(sg))
                {
                    continue;
                }                                              //Should you stop attacking, to conserve strength?

                if (sg.currentMilitary < sg.maxMilitary * param.combat_thresholdAttackStrength)
                {
                    continue;
                }                                                                                            //Below min strength

                sg.lastBattle = turn;

                int      c          = 0;
                Location attackFrom = null;
                Location attackTo   = null;
                foreach (Location l in locations)
                {
                    if (l.soc == sg)
                    {
                        foreach (Link link in l.links)
                        {
                            if (link.other(l).soc != null && link.other(l).soc != sg && link.other(l).soc.getRel(sg).state == DipRel.dipState.war)
                            {
                                if (link.other(l).lastTaken == turn)
                                {
                                    continue;
                                }                                                 //Can't retake on this turn
                                c += 1;
                                if (Eleven.random.Next(c) == 0)
                                {
                                    attackFrom = l;
                                    attackTo   = link.other(l);
                                }
                            }
                        }
                    }
                }
                if (attackFrom != null)
                {
                    SocialGroup defender = attackTo.soc;

                    //sg.lastBattle = turn;
                    //defender.lastBattle = turn;

                    World.log(sg.getName() + " attacking into " + attackTo.getName());
                    double myStr    = sg.currentMilitary * Eleven.random.NextDouble();
                    double theirStr = defender.currentMilitary * Eleven.random.NextDouble();
                    if (myStr < 1)
                    {
                        myStr = Math.Min(1, sg.currentMilitary);
                    }
                    if (theirStr < 1)
                    {
                        theirStr = Math.Min(1, defender.currentMilitary);
                    }

                    //Note the defensive fortifications only reduce losses, not increase chance of taking territory
                    double myLosses = theirStr * param.combat_lethality;
                    sg.currentMilitary -= myLosses;
                    if (sg.currentMilitary < 0)
                    {
                        sg.currentMilitary = 0;
                    }
                    double theirLosses = myStr * param.combat_lethality;
                    theirLosses = computeDefensiveBonuses(theirLosses, sg, defender);
                    theirLosses = attackTo.takeMilitaryDamage(theirLosses);
                    defender.currentMilitary -= theirLosses;
                    if (defender.currentMilitary < 0)
                    {
                        defender.currentMilitary = 0;
                    }

                    addMessage(sg.getName() + " attacks " + defender.getName() + ". Inflicts " + (int)(theirLosses) + " dmg, takes " + (int)(myLosses),
                               MsgEvent.LEVEL_YELLOW, false);

                    if (attackTo.settlement != null)
                    {
                        attackTo.settlement.takeAssault(sg, defender, theirLosses);
                    }
                    //Can only take land if there are no defenses in place
                    if (myStr > theirStr * param.combat_takeLandThreshold && (attackTo.getMilitaryDefence() <= 0.01))
                    {
                        takeLocationFromOther(sg, defender, attackTo);
                        attackTo.lastTaken = turn;
                    }

                    if (sg is Society && defender is Society)
                    {
                        Property.addProperty(this, attackTo, "Recent Human Battle");
                    }

                    world.prefabStore.particleCombat(attackFrom.hex, attackTo.hex);
                }
            }

            foreach (SocialGroup group in socialGroups)
            {
                foreach (DipRel rel in group.getAllRelations())
                {
                    if (rel.state == DipRel.dipState.war && rel.war.canTimeOut)
                    {
                        if (turn - rel.war.startTurn > param.war_defaultLength)
                        {
                            declarePeace(rel);
                        }
                    }
                }
            }
        }
Пример #25
0
 public void ai_testFog()
 {
     if (overmind.power > 0)
     {
         foreach (Location loc in map.locations)
         {
             if (loc.person() != null)
             {
                 bool shouldDrop = false;
                 if (loc.person().state == Person.personState.broken)
                 {
                     shouldDrop = true;
                 }
                 if (loc.person().state == Person.personState.enthralled)
                 {
                     shouldDrop = true;
                 }
                 if (loc.person().shadow > 0.5)
                 {
                     shouldDrop = true;
                 }
                 if (shouldDrop)
                 {
                     foreach (Property pr in loc.properties)
                     {
                         if (pr.proto is Pr_Fog_Source)
                         {
                             shouldDrop = false; break;
                         }
                     }
                 }
                 if (shouldDrop)
                 {
                     overmind.power -= map.param.ability_fog_wellOfFogCost;
                     Property.addProperty(map, loc, "Well of Fog");
                     return;
                 }
             }
         }
     }
     if (overmind.power > map.param.overmind_maxPower * 0.33)
     {
         foreach (Location loc in map.locations)
         {
             if (loc.hex.cloud is Cloud_Fog)
             {
                 bool shouldDrop = true;
                 foreach (Property pr in loc.properties)
                 {
                     if (pr.proto is Pr_Fog_Source)
                     {
                         shouldDrop = false; break;
                     }
                     if (pr.proto is Pr_Fog_Pinned)
                     {
                         shouldDrop = false; break;
                     }
                 }
                 if (shouldDrop)
                 {
                     overmind.power -= map.param.ability_fog_trapCost;
                     Property.addProperty(map, loc, "Trapped Fog");
                     return;
                 }
             }
         }
     }
     //Only spend reserve power on this boondoggle
     if (overmind.power > map.param.overmind_maxPower * 0.66)
     {
         foreach (Unit u in overmind.map.units)
         {
             if (u is Unit_Investigator && u.task is Task_Investigate)
             {
                 u.task          = new Task_Disrupted();
                 overmind.power -= overmind.map.param.ability_disruptAgentCost;
                 break;
             }
         }
     }
 }
Пример #26
0
        public static void takeCommand(Map map, string command)
        {
            World.log("cheat command registered: " + command);


            //try
            {
                if (command == "power")
                {
                    map.overmind.power = 1024;
                    map.overmind.availableEnthrallments = 128;
                }
                if (command == "testsave")
                {
                    map.world.save("testSave.sv");
                    //map.world.prefabStore.popAutosave();
                }
                if (command == "testload")
                {
                    //map.world.load("testSave.sv");
                }
                if (command == "silence")
                {
                    World.self.displayMessages = !World.self.displayMessages;
                }
                if (command == "shadow")
                {
                    GraphicalMap.selectedHex.location.person().shadow = 1;
                }
                if (command == "music")
                {
                    map.world.ui.uiMusic.playTest();
                }
                if (command == "aware")
                {
                    GraphicalMap.selectedHex.location.person().awareness = 1;
                }
                if (command == "testproperty")
                {
                    Property.addProperty(map, GraphicalMap.selectedHex.location, "Military Aid");
                    World.staticMap.world.ui.checkData();
                }
                if (command == "playback")
                {
                    World.staticMap.world.ui.addBlocker(World.staticMap.world.prefabStore.getPlayback(World.staticMap.world, World.staticMap).gameObject);
                }
                if (command == "uivoting")
                {
                    World.staticMap.world.ui.uiVoting.populate((Society)GraphicalMap.selectedHex.location.soc, GraphicalMap.selectedHex.location.person());
                    World.staticMap.world.ui.setToVoting();
                }
                if (command == "100")
                {
                    World.staticMap.world.b100Turns();
                }
                if (command == "enthrall")
                {
                    if (GraphicalMap.selectedHex.location.person() == null)
                    {
                        int    c      = 0;
                        Person choice = null;
                        foreach (Person p in ((Society)GraphicalMap.selectedHex.location.soc).people)
                        {
                            if (p.getLocation() == GraphicalMap.selectedHex.location)
                            {
                                c += 1;
                                if (Eleven.random.Next(c) == 0)
                                {
                                    choice = p;
                                }
                            }
                        }
                        choice.state            = Person.personState.enthralled;
                        map.overmind.enthralled = choice;
                    }
                    else
                    {
                        map.overmind.enthralled       = GraphicalMap.selectedHex.location.person();
                        map.overmind.enthralled.state = Person.personState.enthralled;
                    }
                }
                if (command == "love")
                {
                    foreach (Person p in map.overmind.enthralled.society.people)
                    {
                        p.getRelation(map.overmind.enthralled).addLiking(100, "Cheat love", map.turn);
                    }
                }
                if (command == "hate")
                {
                    foreach (Person p in map.overmind.enthralled.society.people)
                    {
                        p.getRelation(map.overmind.enthralled).addLiking(-100, "Cheat hate", map.turn);
                    }
                }
                if (command == "resetSteamAchievements")
                {
                    SteamManager.reset_all_achievements();
                    World.staticMap.world.prefabStore.popMsg("All steam achievements reset");
                }
                if (command == "thetruth")
                {
                    foreach (Unit u in map.units)
                    {
                        if (u is Unit_Seeker seeker)
                        {
                            seeker.knowsTruth = true;
                        }
                    }
                }
                if (command == "insanity")
                {
                    GraphicalMap.selectedHex.location.person().goInsane();
                }
                if (command == "ruin")
                {
                    GraphicalMap.selectedHex.location.settlement.fallIntoRuin();
                }
                if (command == "redDeath")
                {
                    Property.addProperty(GraphicalMap.map, GraphicalMap.selectedHex.location, "Red Death");
                }
                if (command == "rotting" || command == "rotting sickness")
                {
                    Property.addProperty(GraphicalMap.map, GraphicalMap.selectedHex.location, "Rotting Sickness");
                }
                if (command == "fogSource")
                {
                    Property.addProperty(GraphicalMap.map, GraphicalMap.selectedHex.location, "Well of Fog");
                }
                if (command == "hot")
                {
                    for (int i = 0; i < map.tempMap.Length; i++)
                    {
                        for (int j = 0; j < map.tempMap[0].Length; j++)
                        {
                            map.tempMap[i][j] += 0.1f;
                            if (map.tempMap[i][j] > 1)
                            {
                                map.tempMap[i][j] = 1;
                            }
                        }
                    }
                    map.assignTerrainFromClimate();
                    map.world.ui.checkData();
                }
                if (command == "cold")
                {
                    //for (int i = 0; i < map.tempMap.Length; i++)
                    //{
                    //    for (int j = 0; j < map.tempMap[0].Length; j++)
                    //    {
                    //        map.tempMap[i][j] -= 0.1f;
                    //        if (map.tempMap[i][j] < 0) { map.tempMap[i][j] = 0; }
                    //    }
                    //}
                    foreach (Hex[] row in map.grid)
                    {
                        foreach (Hex h in row)
                        {
                            h.transientTempDelta -= 0.1f;
                        }
                    }
                    map.assignTerrainFromClimate();
                    map.world.ui.checkData();
                }
                if (command == "globalcooling")
                {
                    World.cheat_globalCooling = !World.cheat_globalCooling;
                }
                if (command == "min sanity")
                {
                    GraphicalMap.selectedHex.location.person().sanity = 0.01;
                }
                if (command == "die")
                {
                    GraphicalMap.selectedHex.location.person().die("Killed by console", true);
                }
                if (command == "inquisitor")
                {
                    Unit_Investigator inv = (Unit_Investigator)GraphicalMap.selectedSelectable;
                    inv.changeState(Unit_Investigator.unitState.inquisitor);
                }
                if (command == "civilWar")
                {
                    List <Person> rebels = new List <Person>();
                    Society       soc    = (Society)GraphicalMap.selectedHex.location.soc;
                    int           c      = 0;
                    foreach (Person p in soc.people)
                    {
                        if (p.title_land == null)
                        {
                            continue;
                        }
                        if (p.getLocation().province != soc.getCapital().province)
                        {
                            rebels.Add(p);
                        }
                    }
                    soc.triggerCivilWar(rebels);
                }
                if (command == "evidence")
                {
                    GraphicalMap.selectedHex.location.person().evidence = 1;
                }
                if (command == "disrupt")
                {
                    GraphicalMap.selectedHex.location.person().action = new Act_Disrupted();
                }
                if (command == "10 evidence")
                {
                    GraphicalMap.selectedHex.location.person().evidence += 0.1;
                    if (GraphicalMap.selectedHex.location.person().evidence > 1)
                    {
                        GraphicalMap.selectedHex.location.person().evidence = 1;
                    }
                }
                if (command == "refresh")
                {
                    World.staticMap.overmind.hasTakenAction = false;
                }
                if (command == "nextAge")
                {
                    World.staticMap.overmind.progressToNextAge();
                }
                if (command == "unit")
                {
                    Unit u = new Unit_Investigator(GraphicalMap.selectedHex.location, (Society)GraphicalMap.selectedHex.location.soc);
                    map.units.Add(u);
                    GraphicalMap.selectedHex.location.units.Add(u);
                }
                if (command == "victory")
                {
                    World.staticMap.overmind.victory();
                }
                if (command == "defeat")
                {
                    World.staticMap.overmind.defeat();
                }
                if (command == "course")
                {
                    World.staticMap.world.prefabStore.popEndgameCyclic();
                }
                if (command == "worm")
                {
                    SG_WormHive add = new SG_WormHive(map, GraphicalMap.selectedHex.location);
                    map.socialGroups.Add(add);
                }
                if (command == "placeevidence")
                {
                    GraphicalMap.selectedHex.location.evidence.Add(new Evidence(map.turn));
                    World.log("Placing evidence");
                }
                if (command == "vote")
                {
                    Society soc = map.overmind.enthralled.society;
                    if (soc.voteSession != null)
                    {
                        soc.voteSession.assignVoters();
                        World.log("Attempting to build blocker");
                        map.world.ui.addBlocker(map.world.prefabStore.getScrollSet(soc.voteSession, soc.voteSession.issue.options).gameObject);
                    }
                }
                if (command == "infiltrate")
                {
                    GraphicalMap.selectedHex.location.settlement.infiltration = 1;
                    World.log("Infiltrate");
                }
                if (command == "infiltratehalf")
                {
                    GraphicalMap.selectedHex.location.settlement.infiltration = 0.5;
                    World.log("Infiltrate half");
                }
                map.world.ui.checkData();
            }
            //catch(Exception e)
            //{
            //    World.log(e.Message);
            //}
        }
Пример #27
0
        public override void turnTick(Property p, Location location)
        {
            base.turnTick(p, location);

            bool underQuarantine = false;

            foreach (Property p2 in location.properties)
            {
                if (p2.proto is Pr_Quarantine)
                {
                    underQuarantine = true; break;
                }
            }

            if (location.settlement != null && location.settlement is SettlementHuman)
            {
                SettlementHuman set = (SettlementHuman)location.settlement;
                set.population -= 1;
                if (set.population <= 0)
                {
                    location.map.addMessage(set.location.getName() + " has been eradicated by the Red Death", MsgEvent.LEVEL_RED, true, location.hex);
                    if (set.title != null && set.title.heldBy != null)
                    {
                        set.title.heldBy.die("Died of the Red Death", true);
                    }
                    set.fallIntoRuin();
                }
            }

            foreach (Location l2 in location.getNeighbours())
            {
                if (l2.settlement != null && l2.settlement.isHuman && l2.soc != null && l2.soc is Society)
                {
                    bool canApply = true;
                    foreach (Property p2 in l2.properties)
                    {
                        if (p2.proto is Pr_RedDeath || p2.proto is Pr_RedDeathImmunity)
                        {
                            canApply = false;
                            break;
                        }
                    }
                    double pSpread = World.staticMap.param.unit_rd_redDeathPlaguePSpread;
                    if (underQuarantine)
                    {
                        pSpread /= 2;
                    }
                    if (canApply && Eleven.random.NextDouble() < pSpread)
                    {
                        Property.addProperty(World.staticMap, l2, "Red Death");
                        Society soc = (Society)l2.soc;
                        if (location.map.turn - soc.lastPlagueCrisis > location.map.param.society_crisis_plagueCrisisCooldown)
                        {
                            soc.crisisPlague     = "The Red Death Plague";
                            soc.crisisPlagueLong = "The Red Death plague is spreading in our lands, we must deal with this new crisis. " +
                                                   "We can either quarantine the disased settlements, treat infected patients, or we could deploy our agents as disease curing specialists.";
                            soc.lastPlagueCrisis = location.map.turn;
                        }
                    }
                }
            }
        }
Пример #28
0
        public static void addForgottenSecrets(Map map)
        {
            int             nSecrets  = 0;
            int             nReq      = map.param.unit_seeker_nCreatedSecrets;
            List <Location> available = new List <Location>();

            foreach (Location loc in map.locations)
            {
                if (loc.settlement != null && (loc.settlement is Set_University || loc.settlement is Set_Abbey))
                {
                    available.Add(loc);
                }
            }

            //From these, pick at most nReq
            //Gonna do it badly, because I don't have a random.shuffle(list) implementation at hand
            while (available.Count > 0 && nSecrets < nReq)
            {
                int      q      = Eleven.random.Next(available.Count);
                Location chosen = available[q];
                available.RemoveAt(q);
                nSecrets += 1;
                Property.addProperty(map, chosen, "Forgotten Secret");
            }

            if (nSecrets < nReq)
            {
                available = new List <Location>();
                foreach (Location loc in map.locations)
                {
                    if (loc.settlement == null && (loc.isOcean == false))
                    {
                        available.Add(loc);
                    }
                }
                while (available.Count > 0 && nSecrets < nReq)
                {
                    int      q      = Eleven.random.Next(available.Count);
                    Location chosen = available[q];
                    available.RemoveAt(q);
                    nSecrets += 1;
                    Property.addProperty(map, chosen, "Forgotten Secret");
                }
            }

            //Emergency fallback, make everywhere acceptable
            if (nSecrets < nReq)
            {
                available = new List <Location>();
                foreach (Location loc in map.locations)
                {
                    available.Add(loc);
                }
                while (available.Count > 0 && nSecrets < nReq)
                {
                    int      q      = Eleven.random.Next(available.Count);
                    Location chosen = available[q];
                    available.RemoveAt(q);
                    nSecrets += 1;
                    Property.addProperty(map, chosen, "Forgotten Secret");
                }
            }
        }