public virtual void takeLocationFromOther(SocialGroup def, Location taken)
        {
            this.temporaryThreat += map.param.threat_takeLocation;

            addHistory("#GRN_We have taken " + taken.getName() + " from " + def.getName());
            def.addHistory("#RED_We have lost " + taken.getName() + " to " + this.getName());
        }
Esempio n. 2
0
        public void takeLocationFromOther(SocialGroup att, SocialGroup def, Location taken)
        {
            World.log(att.getName() + " takes " + taken.getName() + " from " + def.getName());
            int  priority = MsgEvent.LEVEL_YELLOW;
            bool benefit  = !def.hasEnthralled();

            if (att.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_GREEN;
            }
            else if (def.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_RED;
            }
            else
            {
                priority = MsgEvent.LEVEL_YELLOW;
            }


            addMessage(new MsgEvent(att.getName() + " takes " + taken.getName() + " from " + def.getName(), priority, benefit));

            if (taken.settlement != null)
            {
                if (taken.settlement.isHuman == false)
                {
                    taken.settlement = null;//Burn it down
                }
                else if (taken.settlement.title != null && taken.settlement.title.heldBy != null)
                {
                    Person lord = taken.settlement.title.heldBy;
                    if (att is Society)
                    {
                        Society socAtt = (Society)att;
                        lord.prestige *= param.combat_prestigeLossFromConquest;
                        foreach (Title t in lord.titles)
                        {
                            t.heldBy = null;
                        }
                        lord.titles.Clear();


                        movePerson(lord, socAtt);
                    }
                    else
                    {
                        lord.die("Killed by " + att.getName() + " when " + taken.getName() + " fell");
                    }
                }
            }

            taken.soc = att;
            att.takeLocationFromOther(def, taken);
        }
        public string getSecretLocationString()
        {
            double   bestDist = -1;
            Location bestLoc  = null;

            foreach (Location loc in this.location.map.locations)
            {
                foreach (Property p in loc.properties)
                {
                    if (p.proto is Pr_ForgottenSecret)
                    {
                        double dist = Math.Abs(loc.hex.x - this.location.hex.x) + Math.Abs(loc.hex.y - this.location.hex.y);
                        if (dist < bestDist || bestDist == -1)
                        {
                            bestLoc  = loc;
                            bestDist = dist;
                        }
                    }
                }
            }
            string add = "";

            if (bestLoc != null)
            {
                add += "Closest: " + bestLoc.getName() + " (";
                bool dir = false;
                if (bestLoc.hex.y > location.hex.y)
                {
                    add += "South "; dir = true;
                }
                if (bestLoc.hex.y < location.hex.y)
                {
                    add += "North "; dir = true;
                }
                if (bestLoc.hex.x > location.hex.x)
                {
                    add += "West"; dir = true;
                }
                if (bestLoc.hex.x < location.hex.x)
                {
                    add += "East"; dir = true;
                }
                if (!dir)
                {
                    add += "Here";
                }
                add += ")";
            }
            else
            {
                add = "No secrets remain undiscovered";
            }
            return(add);
        }
Esempio n. 4
0
        public override void takeLocationFromOther(SocialGroup def, Location taken)
        {
            base.takeLocationFromOther(def, taken);

            if (taken.settlement != null)
            {
                if (taken.person() != null)
                {
                    taken.person().die("Killed by DeepOnes as they overran " + taken.getName(), true);
                }
                //taken.settlement = new Set_UnholyFlesh_Ganglion(taken);
                //taken.settlement = new Set_Ruins(taken);
                taken.settlement.fallIntoRuin();
            }
        }
        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"));
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
 public override string getShort()
 {
     return("Investigating Evidence in " + target.getName());
 }
Esempio n. 8
0
 public override string getShort()
 {
     return("Marching on " + target.getName());
 }
Esempio n. 9
0
        public override void takeLocationFromOther(SocialGroup def, Location taken)
        {
            base.takeLocationFromOther(def, taken);

            if (taken.settlement != null)
            {
                if (taken.person() != null)
                {
                    taken.person().die("Sacrificed by the Chtonians as they overran " + taken.getName(), true);
                }
                taken.settlement = new Set_EnslavedCity(taken);
                //taken.settlement.fallIntoRuin();
            }
        }
        public void showLocationInfo()
        {
            if (GraphicalMap.selectedHex == null || GraphicalMap.selectedHex.location == null)
            {
                locInfoTitle.text                = "No location selected";
                locInfoBody.text                 = "No location selected";
                locNumsBody.text                 = "";
                locNumsNumbers.text              = "";
                locFlavour.text                  = "";
                infiltrationText.text            = "No Infiltration Possible";
                infiltrationVals.text            = "";
                securityDescText.text            = "";
                personShadowAndEvidenceVals.text = "";
            }
            else
            {
                Map      map = World.staticMap;
                Location loc = GraphicalMap.selectedHex.location;
                locInfoTitle.text = loc.getName();
                string bodyText = "";
                double hab      = loc.hex.getHabilitability() - map.param.mapGen_minHabitabilityForHumans;
                hab *= 1d / (1 - map.param.mapGen_minHabitabilityForHumans);


                string valuesBody    = "";
                string valuesNumbers = "";

                infiltrationText.text = "No Infiltration Possible";
                securityDescText.text = "";
                Hex hex = loc.hex;
                bodyText += "\nProvince: " + hex.province.name;

                foreach (EconTrait t in hex.province.econTraits)
                {
                    bodyText += "\nIndustry: " + t.name;
                }

                if (hex.location != null)
                {
                    if (hex.location.settlement != null)
                    {
                        if (hex.location.settlement.title != null)
                        {
                            if (hex.location.settlement.title.heldBy != null)
                            {
                                bodyText += "\nTitle held by: " + hex.location.settlement.title.heldBy.getFullName();
                            }
                            else
                            {
                                bodyText += "\nTitle currently unheld";
                            }
                        }
                        valuesBody    += "\nPrestige:";
                        valuesNumbers += "\n" + Eleven.toMaxLen(hex.location.settlement.getPrestige(), 4);
                        valuesBody    += "\nBase Prestige:";
                        valuesNumbers += "\n" + Eleven.toMaxLen(hex.location.settlement.basePrestige, 4);
                        valuesBody    += "\nMilitary Cap Add:";
                        valuesNumbers += "\n" + hex.location.settlement.getMilitaryCap();
                        valuesBody    += "\nMilitary Regen";
                        valuesNumbers += "\n" + hex.location.settlement.militaryRegenAdd;
                    }
                }

                if (loc.settlement != null)
                {
                    if (loc.soc != null && loc.soc is Society)
                    {
                        List <ReasonMsg> reasons = new List <ReasonMsg>();
                        int sec = loc.settlement.getSecurity(reasons);
                        infiltrationText.text = "Infiltration:\nSecurity Level:";
                        infiltrationVals.text = "" + (int)(100 * loc.settlement.infiltration) + "%\n" + (int)(sec);
                        securityDescText.text = "Security Level: " + sec;
                        foreach (ReasonMsg msg in reasons)
                        {
                            string sign = "+";
                            if (msg.value < 0)
                            {
                                sign = "";
                            }
                            securityDescText.text += "\n" + sign + (int)(msg.value) + " from " + msg.msg;
                        }
                    }
                    locFlavour.text = loc.settlement.getFlavour();
                    if (loc.settlement is SettlementHuman)
                    {
                        valuesBody    += "\n" + ((SettlementHuman)loc.settlement).getStatsDesc();
                        valuesNumbers += "\n" + ((SettlementHuman)loc.settlement).getStatsValues();
                    }

                    if (hex.location.settlement.embeddedUnit != null)
                    {
                        bodyText += "\nARMY IN GARRISON (Strength " + hex.location.settlement.embeddedUnit.hp + ")";
                    }
                }

                valuesBody    += "\nTemperature ";
                valuesNumbers += "\n" + (int)(loc.hex.getTemperature() * 100) + "%";
                valuesBody    += "\nHabilitability ";
                valuesNumbers += "\n" + (int)(hab * 100) + "%";

                locNumsBody.text    = valuesBody;
                locNumsNumbers.text = valuesNumbers;
                locInfoBody.text    = bodyText;
            }
        }
        public override void turnTick(Unit unit)
        {
            if (unit.location.settlement != null)
            {
                unit.task = null;
                return;
            }

            dur += 1;
            if (dur >= unit.location.map.param.unit_establishNewSettlementTime || (!unit.location.map.burnInComplete))
            {
                unit.task = null;

                Location loc      = unit.location;
                int      c        = 0;
                Society  receiver = null;
                foreach (Location l2 in loc.getNeighbours())
                {
                    if (l2.soc != null && l2.soc is Society)
                    {
                        c += 1;
                        if (Eleven.random.Next(c) == 0)
                        {
                            receiver = (Society)l2.soc;
                        }
                    }
                }
                if (receiver == null)
                {
                    //foreach (SocialGroup sg in loc.map.socialGroups)
                    //{
                    //    if (sg is Society)
                    //    {
                    //        c += 1;
                    //        if (Eleven.random.Next(c) == 0)
                    //        {
                    //            receiver = (Society)sg;
                    //        }
                    //    }
                    //}
                    //Start a fully new colony.
                    //Maybe in time this could have a cool name, like "Merchant republic" and be a free port city or something
                    receiver = new Society(unit.location.map, loc);
                    receiver.setName(loc.shortName);
                    loc.soc = receiver;
                    unit.location.map.socialGroups.Add(receiver);
                }

                if (receiver != null)
                {
                    if (loc.isMajor)
                    {
                        loc.settlement = new Set_City(loc);
                    }
                    else
                    {
                        int      q       = 0;
                        double[] weights = new double[] { 2, 1, 2 };
                        double   roll    = 0;
                        for (int i = 0; i < weights.Length; i++)
                        {
                            roll += weights[i];
                        }
                        roll *= Eleven.random.NextDouble();
                        for (int i = 0; i < weights.Length; i++)
                        {
                            roll -= weights[i]; if (roll <= 0)
                            {
                                q = i; break;
                            }
                        }

                        if (q == 0)
                        {
                            loc.settlement = new Set_Abbey(loc);
                        }
                        else if (q == 1)
                        {
                            loc.settlement = new Set_University(loc);
                        }
                        else
                        {
                            loc.settlement = new Set_Fort(loc);
                        }
                    }

                    loc.soc = receiver;
                    SettlementHuman set = (SettlementHuman)loc.settlement;
                    set.population = 1;//Start at the start
                    loc.map.addMessage(loc.soc.getName() + " expands, add new settlement: " + loc.getName(), MsgEvent.LEVEL_RED, false, loc.hex);
                }
            }
        }
        public void takeLocationFromOther(SocialGroup att, SocialGroup def, Location taken)
        {
            World.log(att.getName() + " takes " + taken.getName() + " from " + def.getName());
            int  priority = MsgEvent.LEVEL_YELLOW;
            bool benefit  = !def.hasEnthralled();

            if (att.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_GREEN;
            }
            else if (def.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_RED;
            }
            else
            {
                priority = MsgEvent.LEVEL_YELLOW;
            }


            turnMessages.Add(new MsgEvent(att.getName() + " takes " + taken.getName() + " from " + def.getName(), priority, benefit));

            if (taken.settlement != null)
            {
                if (taken.settlement.isHuman == false)
                {
                    taken.settlement = null;//Burn it down
                }
                else if (taken.settlement.title != null && taken.settlement.title.heldBy != null)
                {
                    Person lord = taken.settlement.title.heldBy;
                    if (att is Society)
                    {
                        Society socAtt = (Society)att;
                        lord.prestige *= param.combat_prestigeLossFromConquest;
                        if (socAtt.getSovreign() != null)
                        {
                            lord.getRelation(socAtt.getSovreign()).addLiking(param.person_likingFromBeingInvaded, "Their nation invaded mine", turn);
                        }
                        foreach (Title t in lord.titles)
                        {
                            t.heldBy = null;
                        }
                        lord.titles.Clear();


                        movePerson(lord, socAtt);
                    }
                    else
                    {
                        lord.die("Killed by " + att.getName() + " when " + taken.getName() + " fell");
                    }
                }
            }

            taken.soc = att;
            att.takeLocationFromOther(def, taken);

            bool hasRemainingTerritory = false;

            foreach (Location loc in locations)
            {
                if (loc.soc == def)
                {
                    hasRemainingTerritory = true;
                    break;
                }
            }
            if (!hasRemainingTerritory)
            {
                World.log("Last territory taken");
                addMessage(def.getName() + " has lost its last holdings to " + att.getName());

                /*
                 * if (att is Society && def is Society)
                 * {
                 *  Society sAtt = (Society)att;
                 *  Society sDef = (Society)def;
                 *  List<Person> toMove = new List<Person>();
                 *  foreach (Person p in sDef.people)
                 *  {
                 *      if (p.title_land == null)
                 *      {
                 *          toMove.Add(p);
                 *      }
                 *  }
                 *  foreach (Person p in toMove)
                 *  {
                 *      movePerson(p, sAtt);
                 *      addMessage(p.getFullName() + " is now part of the court of " + att.getName(), MsgEvent.LEVEL_GRAY, false);
                 *  }
                 * }
                 */
            }
        }
        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);
                        }
                    }
                }
            }
        }
 public override string getShort()
 {
     return("Travelling to " + target.getName());
 }
Esempio n. 15
0
        public void checkPaladins()
        {
            if (map.param.usePaladins == 0)
            {
                return;
            }
            if (map.turn < map.firstPlayerTurn + map.param.awareness_simplePaladinGracePeriod)
            {
                return;
            }

            int nPaladins = 0;

            int targetPaladins = getTargetPaladins();

            if (targetPaladins > 0)
            {
                bool hasAgents = false;
                foreach (Unit u in map.units)
                {
                    if (u is Unit_Simple_Paladin)
                    {
                        nPaladins += 1;
                    }
                    if (u.isEnthralled())
                    {
                        hasAgents = true;
                    }
                }

                if (hasAgents && nPaladins < targetPaladins)
                {
                    double   bestScore = 0;
                    Location l2        = null;
                    int      c         = 0;
                    foreach (Location loc in map.locations)
                    {
                        double score = 0;
                        if (loc.person() == null)
                        {
                            continue;
                        }
                        if (loc.person().state == Person.personState.enthralled)
                        {
                            continue;
                        }

                        bool occupied = false;
                        foreach (Unit u in loc.units)
                        {
                            if (u.isEnthralled())
                            {
                                occupied = true; break;
                            }
                        }
                        if (occupied)
                        {
                            continue;
                        }

                        score += 0.1;
                        score -= loc.person().shadow;
                        score += loc.person().awareness;

                        if (score > bestScore)
                        {
                            c         = 0;
                            bestScore = score;
                        }
                        if (score == bestScore)
                        {
                            c += 1;
                            if (Eleven.random.Next(c) == 0)
                            {
                                l2 = loc;
                            }
                        }
                    }
                    if (l2 != null)
                    {
                        if (!hasSpawnedPaladin)
                        {
                            map.world.prefabStore.popMsg("A Paladin has arrived in " + l2.getName() + ". A holy warrior, they will hunt down your agents, tracking them across the map. " +
                                                         "You can slow them with powers, and they will lose the trail occasionally, but always be aware and cautious of their presence.");
                        }
                        Unit_Simple_Paladin paladin = new Unit_Simple_Paladin(l2, map.soc_light);
                        paladin.person      = new Person(map.soc_light);
                        paladin.person.unit = paladin;
                        paladin.person.traits.Clear();//Can't see traits, best to have them removed
                        map.units.Add(paladin);
                        hasSpawnedPaladin = true;
                    }
                }
            }
        }
        public void showLocationInfo()
        {
            if (GraphicalMap.selectedHex == null || GraphicalMap.selectedHex.location == null)
            {
                locInfoTitle.text   = "No location selected";
                locInfoBody.text    = "No location selected";
                locNumsBody.text    = "";
                locNumsNumbers.text = "";
                locFlavour.text     = "";
            }
            else
            {
                Map      map = World.staticMap;
                Location loc = GraphicalMap.selectedHex.location;
                locInfoTitle.text = loc.getName();
                string bodyText = "";
                double hab      = loc.hex.getHabilitability() - map.param.mapGen_minHabitabilityForHumans;
                hab *= 1d / (1 - map.param.mapGen_minHabitabilityForHumans);


                string valuesBody    = "";
                string valuesNumbers = "";

                Hex hex = loc.hex;
                bodyText += "\nProvince: " + hex.province.name;
                foreach (EconTrait t in hex.province.econTraits)
                {
                    bodyText += "\nIndustry: " + t.name;
                }

                if (hex.location != null)
                {
                    if (hex.location.settlement != null)
                    {
                        if (hex.location.settlement.title != null)
                        {
                            if (hex.location.settlement.title.heldBy != null)
                            {
                                bodyText += "\nTitle held by: " + hex.location.settlement.title.heldBy.getFullName();
                            }
                            else
                            {
                                bodyText += "\nTitle currently unheld";
                            }
                        }
                        valuesBody    += "\nPrestige:";
                        valuesNumbers += "\n" + Eleven.toMaxLen(hex.location.settlement.getPrestige(), 4);
                        valuesBody    += "\nBase Prestige:";
                        valuesNumbers += "\n" + Eleven.toMaxLen(hex.location.settlement.basePrestige, 4);
                        valuesBody    += "\nMilitary Cap Add:";
                        valuesNumbers += "\n" + hex.location.settlement.getMilitaryCap();
                        valuesBody    += "\nMilitary Regen";
                        valuesNumbers += "\n" + hex.location.settlement.militaryRegenAdd;
                    }
                }

                if (loc.settlement != null)
                {
                    locFlavour.text = loc.settlement.getFlavour();
                    if (loc.settlement is Set_City)
                    {
                        valuesBody    += "\n" + ((Set_City)loc.settlement).getStatsDesc();
                        valuesNumbers += "\n" + ((Set_City)loc.settlement).getStatsValues();
                    }
                }

                valuesBody    += "\nTemperature ";
                valuesNumbers += "\n" + (int)(loc.hex.getTemperature() * 100) + "%";
                valuesBody    += "\nHabilitability ";
                valuesNumbers += "\n" + (int)(hab * 100) + "%";

                locNumsBody.text    = valuesBody;
                locNumsNumbers.text = valuesNumbers;
                locInfoBody.text    = bodyText;
            }
        }