Exemplo n.º 1
0
        public override void castInner(Map map, Unit u)
        {
            Task_SpendWealth task = new Task_SpendWealth();

            u.task = task;

            Unit_Merchant merchant = (Unit_Merchant)u;

            merchant.hasSpendWealth = true;
            if (merchant.hasSpendWealth && merchant.hasSoldCargo && merchant.hasLoadedCargo)
            {
                AchievementManager.unlockAchievement(SteamManager.achievement_key.MERCANTILISM);
            }

            u.location.map.world.prefabStore.popImgMsg(u.getName() + " begins spending their wealth, in lavish banquets, gifts and fine silks. They enjoy the company of the local noble, who" +
                                                       " benefits from increased taxes and excellent festivals. The economy booms, to be spent on swords or favours."
                                                       , u.location.map.world.wordStore.lookup("ABILITY_UNIT_SPEND_WEALTH"), 1);
        }
Exemplo n.º 2
0
        public override void turnTickInner(Map map)
        {
            if (home.soc != this.society || home.settlement == null || home.settlement.attachedUnit != this)
            {
                this.disband(map, "Disbanded due to loss of home");
                if (home != null && home.settlement != null && home.settlement.attachedUnit == this)
                {
                    home.settlement.attachedUnit = null;
                }
                return;
            }

            if (location.soc != null && this.society.getRel(location.soc).state == DipRel.dipState.war)
            {
                int nHumanSettlementsPrior = 0;
                foreach (Location loc in map.locations)
                {
                    if (loc.soc != null && loc.settlement != null && (loc.settlement is Set_Ruins == false) && (loc.settlement is Set_CityRuins == false) && loc.soc is Society)
                    {
                        nHumanSettlementsPrior += 1;
                    }
                }

                location.map.takeLocationFromOther(society, location.soc, location);

                int nHumanSettlements = 0;
                foreach (Location loc in map.locations)
                {
                    if (loc.soc != null && loc.settlement != null && (loc.settlement is Set_Ruins == false) && (loc.settlement is Set_CityRuins == false) && loc.soc is Society)
                    {
                        nHumanSettlements += 1;
                    }
                }

                if (nHumanSettlementsPrior > 0 && nHumanSettlements == 0)
                {
                    AchievementManager.unlockAchievement(SteamManager.achievement_key.FLESH_VICTORY);
                }
            }
        }
        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;
            }
            if (unit.location.person() == null)
            {
                unit.task = null; return;
            }

            Unit_Vampire vampire = (Unit_Vampire)unit;

            bool wasInsane = unit.location.person().sanity == 0;

            unit.location.person().sanity -= 1;

            if (unit.location.person().sanity < 1)
            {
                if (!wasInsane)
                {
                    if (unit.location.person().society.sovereign.heldBy == unit.location.person())
                    {
                        if (unit.location.person().society.getLevel() > 0)
                        {
                            AchievementManager.unlockAchievement(SteamManager.achievement_key.ROYAL_BLOOD);
                        }
                    }
                }
                unit.location.person().sanity = 0;
                unit.location.map.world.prefabStore.popImgMsg(unit.getName() + " breaks the mind of " + unit.location.person().getFullName() +
                                                              ". They are now driven to madness.",
                                                              unit.location.map.world.wordStore.lookup("ABILITY_VAMP_INSANITY"));
                unit.task = null;
            }
        }
Exemplo n.º 4
0
        public void Start()
        {
            Screen.SetResolution(1920, 1080, true);
            self = this;

            if (Directory.Exists("advdata") == false)
            {
                advancedEdition = false; World.log("Setting to standard edition as not advanced data folder was detected");
            }

            Log("User folder attempt: " + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));

            specificStartup();
            ui.setToMainMenu();
            //Thread t = new Thread(musicPlayer.loadMusic);
            //t.Start();//Do not f**k me over here, Unity, I'm not feeling like spending a whole day debugging your shit
            musicPlayer.loadMusic(); //How did I know?

            //Log(String.Join(" ", EventParser.tokenize("(shadow = false) | 27.5").ConvertAll(e => e.type.ToString()).ToArray()));
            // var tree = EventParser.parse(EventParser.tokenize("(location.shadow = false) | 27.5"));
            // Log(printTree(tree, 0));

            // var root = EventParser.parse(EventParser.tokenize("true & true | (true & false)"));
            // bool res = EventRuntime.evaluate(root, null);
            // Log("got result: " + res.ToString());

            EventManager.load("." + separator + "data" + separator + "events");

            AchievementManager.setup();
            musicPlayer.playTheme();

            //PopupIOOptions.loadEarly();

            DateTime time = DateTime.Now;

            if (time.Day == 1 && time.Month == 4)
            {
                //We could, in principle, active cyclops mode here
            }
        }
        public void clicked(Map map)
        {
            //selector.selected(person,agent);
            map.world.audioStore.playActivate();
            Hex hex = GraphicalMap.selectedHex;

            if (hex != null && hex.location != null)
            {
                if (index == Ab_Over_CreateAgent.VAMPIRE)
                {
                    Unit agent = new Unit_Vampire(hex.location, map.soc_dark);
                    map.world.prefabStore.popImgMsg(
                        "You draw upon the creatures of darkness, and choose one to serve as your instrument in this world",
                        map.world.wordStore.lookup("ABILITY_CREATE_AGENT"));

                    agent.person       = new Person(map.soc_dark);
                    agent.person.state = Person.personState.enthralledAgent;
                    agent.person.unit  = agent;
                    agent.person.traits.Clear();
                    map.units.Add(agent);

                    Evidence ev = new Evidence(map.turn);
                    ev.pointsTo = agent;
                    ev.weight   = 0.66;
                    agent.location.evidence.Add(ev);

                    agent.task = null;
                    GraphicalMap.selectedSelectable = agent;
                }

                if (index == Ab_Over_CreateAgent.DOCTOR)
                {
                    Unit agent = new Unit_NecroDoctor(hex.location, map.soc_dark);
                    map.world.prefabStore.popImgMsg(
                        "You draw upon the creatures of darkness, and choose one to serve as your instrument in this world",
                        map.world.wordStore.lookup("ABILITY_CREATE_AGENT"));

                    agent.person       = new Person(map.soc_dark);
                    agent.person.state = Person.personState.enthralledAgent;
                    agent.person.unit  = agent;
                    agent.person.traits.Clear();
                    map.units.Add(agent);

                    Evidence ev = new Evidence(map.turn);
                    ev.pointsTo = agent;
                    ev.weight   = 0.66;
                    agent.location.evidence.Add(ev);

                    agent.task = null;
                    GraphicalMap.selectedSelectable = agent;
                }

                if (index == Ab_Over_CreateAgent.SEEKER)
                {
                    Unit agent = new Unit_Seeker(hex.location, map.soc_dark);
                    map.world.prefabStore.popImgMsg(
                        "You draw upon the creatures of darkness, and choose one to serve as your instrument in this world",
                        map.world.wordStore.lookup("ABILITY_CREATE_AGENT"));

                    agent.person       = new Person(map.soc_dark);
                    agent.person.state = Person.personState.enthralledAgent;
                    agent.person.unit  = agent;
                    agent.person.traits.Clear();
                    map.units.Add(agent);

                    Unit_Seeker.addForgottenSecrets(map);

                    Evidence ev = new Evidence(map.turn);
                    ev.pointsTo = agent;
                    ev.weight   = 0.66;
                    agent.location.evidence.Add(ev);

                    agent.task = null;
                    GraphicalMap.selectedSelectable = agent;
                }

                if (index == Ab_Over_CreateAgent.PUMPKIN)
                {
                    Unit agent = new Unit_HeadlessHorseman(hex.location, map.soc_dark);
                    map.world.prefabStore.popImgMsg(
                        "You draw upon the creatures of darkness, and choose one to serve as your instrument in this world",
                        "The horseman rides again!", 3);

                    agent.person       = new Person(map.soc_dark);
                    agent.person.state = Person.personState.enthralledAgent;
                    agent.person.unit  = agent;
                    agent.person.traits.Clear();
                    map.units.Add(agent);


                    Evidence ev = new Evidence(map.turn);
                    ev.pointsTo = agent;
                    ev.weight   = 0.66;
                    agent.location.evidence.Add(ev);

                    agent.task = null;
                    GraphicalMap.selectedSelectable = agent;
                }
                if (index == Ab_Over_CreateAgent.HEIROPHANT)
                {
                    Unit agent = new Unit_DarkHeirophant(hex.location, map.soc_dark);
                    map.world.prefabStore.popImgMsg(
                        "You draw upon the creatures of darkness, and choose one to serve as your instrument in this world",
                        "The cult begins, its hidden shrines to the dark powers are raised, and await the worshippers.", 4);

                    agent.person       = new Person(map.soc_dark);
                    agent.person.state = Person.personState.enthralledAgent;
                    agent.person.unit  = agent;
                    agent.person.traits.Clear();
                    map.units.Add(agent);


                    Evidence ev = new Evidence(map.turn);
                    ev.pointsTo = agent;
                    ev.weight   = 0.66;
                    agent.location.evidence.Add(ev);

                    agent.task = null;
                    GraphicalMap.selectedSelectable = agent;
                }
                if (index == Ab_Over_CreateAgent.REDDEATH)
                {
                    Unit agent = new Unit_RedDeath(hex.location, map.soc_dark);
                    map.world.prefabStore.popImgMsg(
                        "You draw upon the creatures of darkness, and choose one to serve as your instrument in this world",
                        "The Masque of the Red Death arises, the spirit of the terrible disease. It will spread where the Masque goes, and terrifies commoner and noble alike.",
                        5);

                    agent.person       = new Person(map.soc_dark);
                    agent.person.state = Person.personState.enthralledAgent;
                    agent.person.unit  = agent;
                    agent.person.traits.Clear();
                    map.units.Add(agent);


                    Evidence ev = new Evidence(map.turn);
                    ev.pointsTo = agent;
                    ev.weight   = 0.66;
                    agent.location.evidence.Add(ev);

                    agent.task = null;
                    GraphicalMap.selectedSelectable = agent;
                }
                if (index == Ab_Over_CreateAgent.SAVIOUR)
                {
                    Unit agent = new Unit_Saviour(hex.location, map.soc_dark);
                    map.world.prefabStore.popImgMsg(
                        "You draw upon the creatures of darkness, and choose one to serve as your instrument in this world",
                        "The Saviour is designed to sabotage one of your strategies to allow another. They can save a small nation you are invading, to make all nobles in the society and in neighbouring settlements adore The Saviour (at the cost of your military)," +
                        "or to cure a disease to also gain liking. Once support is gained, they can exploit it, by influencing votes, by infiltrating effectively, or by granting prestige to your enthralled noble.",
                        7);

                    agent.person       = new Person(map.soc_dark);
                    agent.person.state = Person.personState.enthralledAgent;
                    agent.person.unit  = agent;
                    agent.person.traits.Clear();
                    map.units.Add(agent);


                    Evidence ev = new Evidence(map.turn);
                    ev.pointsTo = agent;
                    ev.weight   = 0.66;
                    agent.location.evidence.Add(ev);

                    agent.task = null;
                    GraphicalMap.selectedSelectable = agent;
                }
                if (!map.overmind.isFirstEnthralledAgent)
                {
                    foreach (Ability a in map.overmind.powers)
                    {
                        if (a is Ab_Over_CreateAgent)
                        {
                            a.turnLastCast = map.turn;
                        }
                    }
                }
                map.overmind.availableEnthrallments -= 1;
                map.hasEnthralledAnAgent             = true;

                AchievementManager.unlockAchievement(SteamManager.achievement_key.FIRST_AGENT);
            }
        }
Exemplo n.º 6
0
        private void processEnshadowment()
        {
            evidence += shadow * map.param.person_evidencePerShadow;
            if (evidence > 1)
            {
                evidence = 1;
            }
            if (state == personState.lightbringer)
            {
                shadow = 0;
                return;
            }
            foreach (Person p in society.people)
            {
                if (p == this)
                {
                    continue;
                }
                if (p.shadow == 0)
                {
                    continue;
                }                               //Can't inherit if they don't have any, skip to save CPU
                if (p.shadow <= shadow)
                {
                    continue;
                }
                if (p.prestige < prestige)
                {
                    continue;
                }

                /*
                 * double basePrestige = 100;
                 * if (society.getSovereign() != null) { basePrestige = society.getSovereign().prestige; }
                 * if (basePrestige < 10) { basePrestige = 10; }
                 * double multFromPrestige = p.prestige / basePrestige;
                 * if (multFromPrestige < 0) { multFromPrestige = 0; }
                 * if (multFromPrestige > 1) { multFromPrestige = 1; }
                 */

                double likingMult = Math.Max(0, this.getRelation(p).getLiking()) / 100;


                double shadowDelta = p.shadow * likingMult * map.param.person_shadowContagionMult; //You get enshadowed by people you like/trust
                this.shadow = Math.Min(p.shadow, shadow + shadowDelta);                            //Don't exceed your donor's shadow
                if (this.shadow > 1)
                {
                    this.shadow = 1;
                }
            }
            if (society.isDarkEmpire)
            {
                //if (society.getSovereign() != null && society.getSovereign().shadow > shadow)
                //{
                shadow += Eleven.random.NextDouble() * map.param.ability_avrgDarkEmpireShadowPerTurn;
                //}
                if (shadow > 1)
                {
                    shadow = 1;
                }
            }

            if (state == personState.normal && shadow == 1)
            {
                this.state = personState.broken;
                map.turnMessages.Add(new MsgEvent(this.getFullName() + " has been fully enshadowed, their soul can no longer resist the dark", MsgEvent.LEVEL_GREEN, true, getLocation().hex));
                if (!map.hasBrokenSoul)
                {
                    AchievementManager.unlockAchievement(SteamManager.achievement_key.BROKEN_SOUL);
                    map.hasBrokenSoul = true;
                }
            }
            //If you've not broken yet, decay the shadow away
            if (state != personState.broken && state != personState.enthralled)
            {
                shadow -= map.param.person_shadowDecayPerTurn;
                if (shadow < 0)
                {
                    shadow = 0;
                }
            }

            if (state == personState.broken || state == personState.enthralled)
            {
                if (this.title_land != null)
                {
                    this.title_land.settlement.infiltration = 1;
                }
            }
        }
Exemplo n.º 7
0
        public override void castInner(Map map, Unit u)
        {
            Society soc = (Society)u.location.soc;

            SocialGroup enemy = null;

            foreach (SocialGroup sg in map.socialGroups)
            {
                if (sg.getRel(u.location.soc).state == DipRel.dipState.war)
                {
                    bool controlled = false;
                    if (sg is Society)
                    {
                        Society sgSoc = (Society)sg;
                        if (sgSoc.isDarkEmpire)
                        {
                            controlled = true;
                        }
                    }
                    else
                    {
                        controlled = sg.isDark();
                    }
                    if (controlled && sg.currentMilitary > u.location.soc.currentMilitary)
                    {
                        enemy = sg;
                    }
                }
            }
            if (enemy == null)
            {
                map.world.prefabStore.popMsg(soc.getName() + " is not at war with a superior military you control."); return;
            }

            HashSet <Person> targets = new HashSet <Person>();

            foreach (Person p in soc.people)
            {
                targets.Add(p);
            }
            int nSaved = 0;

            foreach (Location loc in map.locations)
            {
                if (loc.soc == soc)
                {
                    foreach (Location l2 in loc.getNeighbours())
                    {
                        if (l2.soc != soc)
                        {
                            if (l2.person() != null)
                            {
                                targets.Add(l2.person());
                            }
                        }
                    }
                    nSaved += 1;
                }
            }
            if (nSaved >= 10)
            {
                AchievementManager.unlockAchievement(SteamManager.achievement_key.SAVIOUR);
            }

            foreach (Person p in targets)
            {
                double boost = 100;
                //Let's not overcomplicate this one
                //foreach (ThreatItem item in p.threatEvaluations)
                //{
                //    if (item.group == enemy)
                //    {
                //        boost = item.threat;
                //    }
                //}
                //if (boost > 150) { boost = 150; }
                //if (boost < 25) { boost = 25; }
                p.getRelation(u.person).addLiking(boost, "Our Saviour!", map.turn, RelObj.STACK_REPLACE, true);
            }

            DipRel rel = soc.getRel(enemy);

            if (rel.war != null)
            {
                rel.war.startTurn = map.turn;
            }
            List <Unit> rems = new List <Unit>();

            foreach (Unit u2 in map.units)
            {
                if (u2.society == enemy && u2.isMilitary)
                {
                    rems.Add(u2);
                }
                else if (u2.society == soc && u2 is Unit_Army)
                {
                    u2.task = null;//Retask, to drop the 'defend the homeland' defensive task and go on the offensive
                }
            }
            foreach (Unit u2 in rems)
            {
                u2.die(map, "Killed by The Saviour");
            }
            soc.posture = Society.militaryPosture.offensive;//Flip to assault mode to ruin the dark forces

            Evidence e2 = new Evidence(map.turn);

            e2.pointsTo = u;
            e2.weight   = u.location.map.param.unit_majorEvidence;
            u.location.evidence.Add(e2);

            u.location.map.world.prefabStore.popImgMsg(u.getName() + " saves " + soc.getName() + " from invasion by " + enemy.getName() + "."
                                                       + "\nNobles within the nation, and those adjacent to it gain liking for " + soc.getName() + ". " + targets.Count + " nobles affected. " + rems.Count + " units killed."
                                                       + soc.getName() + " will now wage this war with renewed vigour, driving back their dark enemy",
                                                       u.location.map.world.wordStore.lookup("ABILITY_SAVIOUR_INVASION"), 7);
        }