public Person getSuperiorInSociety(Society society) { if (society.getCapital() != null && society.getCapital().province == this.province) { return(society.getSovereign()); } foreach (Title t in society.titles) { if (t is Title_ProvinceRuler) { Title_ProvinceRuler t2 = (Title_ProvinceRuler)t; if (t2.province == this.province) { return(t2.heldBy); } } } return(null); }
public void computeThreats() { //Actually do the evaluations here List <ThreatItem> rems = new List <ThreatItem>(); foreach (ThreatItem item in threatEvaluations) { item.threat = 0; item.reasons.Clear(); if (item.group != null && (map.socialGroups.Contains(item.group) == false)) { rems.Add(item); continue; } if (item.group == null) { if (item.form == ThreatItem.formTypes.ENSHADOWED_NOBLES) { if (this.state == personState.broken) { continue; } //Broken minded can't fear the darkness double totalSus = 0; foreach (Person p in this.society.people) { RelObj rel = this.getRelation(p); double sus = rel.suspicion * map.param.person_threatFromSuspicion; item.threat += sus; totalSus += sus; } if (totalSus > 1) { item.reasons.Add(new ReasonMsg("Supicion of enshadowed nobles (+" + (int)(totalSus) + ")", totalSus)); } } if (item.form == ThreatItem.formTypes.AGENTS) { if (this.state == personState.broken) { continue; } //Broken minded can't fear the darkness double mult = 1 - shadow; item.threat += mult * item.generatedThreat; item.reasons.Add(new ReasonMsg("Evidence found (+" + (int)(mult * item.generatedThreat) + ")", (mult * item.generatedThreat))); } if (item.form == ThreatItem.formTypes.PLAGUE) { double u = 0; double socU = 0; double neighbourU = 0; double worldU = 0; item.threat = 0; foreach (Location l2 in map.locations) { if (l2 == this.getLocation()) { foreach (Property pr in l2.properties) { u = pr.proto.plagueThreat * 8;; item.threat += u; if (pr.proto.plagueThreat > 0) { item.reasons.Add(new ReasonMsg("Plague present in my settlement (+" + (int)(u) + ")", (int)(u))); } } } else if (l2.isNeighbour(this.getLocation())) { foreach (Property pr in l2.properties) { neighbourU += pr.proto.plagueThreat * 5; } } else if (l2.soc == this.society) { foreach (Property pr in l2.properties) { socU += pr.proto.plagueThreat * 2; } } else if (this.society.lastTurnNeighbours.Contains(l2.soc)) { foreach (Property pr in l2.properties) { worldU += pr.proto.plagueThreat * 0.75; } } } if (neighbourU > 0) { item.threat += neighbourU; item.reasons.Add(new ReasonMsg("Plagues in neighbouring settlements (+" + (int)(neighbourU) + ")", (int)(neighbourU))); } if (socU > 0) { item.threat += socU; item.reasons.Add(new ReasonMsg("Plagues in our lands (+" + (int)(socU) + ")", (int)(socU))); } if (worldU > 0) { item.threat += worldU; item.reasons.Add(new ReasonMsg("Neighbouring nation plagues (+" + (int)(worldU) + ")", (int)(worldU))); } if (this.getLocation() != null && this.getLocation().settlement is SettlementHuman) { int settlementSize = ((SettlementHuman)this.getLocation().settlement).population; if (item.threat > 0 && settlementSize <= map.param.unit_rd_redDeathPlagueDur) { item.threat += map.param.threat_smallSettlementVsDisease; item.reasons.Add(new ReasonMsg("My small settlement could easily be wiped out by plague (+" + (int)(map.param.threat_smallSettlementVsDisease) + ")", (int)(map.param.threat_smallSettlementVsDisease))); } } if (item.threat > 200) { item.threat = 200; } if (item.threat < 0) { item.threat = 0; } } } else { double value = item.group.getThreat(null); item.reasons.Add(new ReasonMsg("Social Group's total threat (+" + (int)(value) + ")", value)); Location sourceLoc = null; //Fear things which are nearby if (this.title_land != null) { sourceLoc = title_land.settlement.location; } //If you don't have a landed title you live in the capital if (sourceLoc == null) { sourceLoc = society.getCapital(); } //Fallback to just use the first location, to avoid null exceptions in extreme edge cases if (sourceLoc == null) { sourceLoc = map.locations[0]; } double distance = 0; if (this.getLocation() != null) { if (this.getLocation().distanceToTarget.ContainsKey(item.group)) { distance = getLocation().distanceToTarget[item.group]; } } if (distance < 1) { distance = 1; } int distanceI = (int)distance; distance = Math.Sqrt(distance); double infoAvail = 1 / distance; if (infoAvail < 0.2) { infoAvail = 0.2; } int intInfoAvailability = (int)(infoAvail * 100); item.reasons.Add(new ReasonMsg("Distance (" + (int)(intInfoAvailability) + "% Multiplier)", intInfoAvailability)); value *= infoAvail; double ourMilitary = society.currentMilitary + (society.maxMilitary / 2); double theirMilitary = item.group.currentMilitary + (item.group.maxMilitary / 2); double militaryStrengthMult = theirMilitary / (ourMilitary + 1); //double militaryStrengthMult = 50 / ((society.currentMilitary + (society.maxMilitary / 2)) + 1); if (militaryStrengthMult < 0.5) { militaryStrengthMult = 0.5; } if (militaryStrengthMult > 2.5) { militaryStrengthMult = 2.5; } item.reasons.Add(new ReasonMsg("Relative strengths of social-group's militaries (" + (int)(100 * militaryStrengthMult) + "% Multiplier)", (int)(100 * militaryStrengthMult))); value *= militaryStrengthMult; item.threat = value; if (item.group is Society) { double susThreat = 0; Society soc = (Society)item.group; foreach (Person p in soc.people) { susThreat += this.getRelation(p).suspicion *100; } if (susThreat > 200) { susThreat = 200; } item.reasons.Add(new ReasonMsg("Suspicion that nobles are enshadowed (+" + (int)(susThreat) + ")", (int)susThreat)); item.threat += susThreat; if (soc.offensiveTarget == this.society && soc.posture == Society.militaryPosture.offensive) { double threatAdd = map.param.person_threatFromBeingOffensiveTarget * item.threat; item.reasons.Add(new ReasonMsg("We are their offensive target (" + (int)(threatAdd) + ")", threatAdd)); item.threat += threatAdd; } bool hasKillOrder = false; foreach (KillOrder order in soc.killOrders) { if (order.person == this) { hasKillOrder = true; } } if (hasKillOrder) { item.reasons.Add(new ReasonMsg("They intend to execute me! (+50)", 50)); item.threat += 50; } else { if (item.threat > 75 && (soc.posture != Society.militaryPosture.offensive) && susThreat == 0 && (soc.isAtWar() == false)) { item.reasons.Add(new ReasonMsg("They are at peace, non-offensive and have no suspected dark nobles (cap at 75)", 0)); item.threat = 75; } else if (item.threat > 125 && soc.offensiveTarget != this.society && susThreat == 0) { item.reasons.Add(new ReasonMsg("We are not their offensive target and no suspected dark nobles (cap at 125)", 0)); item.threat = 125; } } } } item.threatBeforeTemporaryDread = item.threat; if (Math.Abs(item.temporaryDread) > 1) { item.threat += item.temporaryDread; item.reasons.Add(new ReasonMsg("Temporary Dread (+" + (int)(item.temporaryDread) + ")", item.temporaryDread)); } if (item.threat < 0) { item.threat = 0; } if (item.threat > 200) { item.threat = 200; } } foreach (ThreatItem item in rems) { threatEvaluations.Remove(item); } threatEvaluations.Sort(); }
public void computeThreats() { //Actually do the evaluations here foreach (ThreatItem item in threatEvaluations) { item.threat = 0; item.reasons.Clear(); if (item.group == null) { if (item.form == ThreatItem.formTypes.ENSHADOWED_NOBLES) { if (this.state == personState.broken) { continue; } //Broken minded can't fear the darkness double totalSus = 0; foreach (Person p in this.society.people) { RelObj rel = this.getRelation(p); double sus = rel.suspicion * map.param.person_threatFromSuspicion; item.threat += sus; totalSus += sus; } if (totalSus > 1) { item.reasons.Add(new ReasonMsg("Supicion of enshadowed nobles", totalSus)); } } } else { double value = item.group.getThreat(null); item.reasons.Add(new ReasonMsg("Social Group's total threat: ", value)); Location sourceLoc = null; //Fear things which are nearby if (this.title_land != null) { sourceLoc = title_land.settlement.location; } //If you don't have a landed title you live in the capital if (sourceLoc == null) { sourceLoc = society.getCapital(); } //Fallback to just use the first location, to avoid null exceptions in extreme edge cases if (sourceLoc == null) { sourceLoc = map.locations[0]; } double infoAvailability = map.getInformationAvailability(sourceLoc, item.group); int intInfoAvailability = (int)(infoAvailability * 100); item.reasons.Add(new ReasonMsg("Information (% kept)", intInfoAvailability)); value *= infoAvailability; double militaryStrengthMult = 50 / ((society.currentMilitary + (society.maxMilitary / 2)) + 1); if (militaryStrengthMult < 0.5) { militaryStrengthMult = 0.5; } item.reasons.Add(new ReasonMsg("Military Strength Comparison (% multiplier)", (int)(100 * militaryStrengthMult))); value *= militaryStrengthMult; item.threat = value; if (item.group is Society) { double susThreat = 0; Society soc = (Society)item.group; foreach (Person p in soc.people) { susThreat += this.getRelation(p).suspicion *100; } if (susThreat > 200) { susThreat = 200; } item.reasons.Add(new ReasonMsg("Suspicion that nobles are enshadowed", (int)susThreat)); item.threat += susThreat; } } if (Math.Abs(item.temporaryDread) > 1) { item.threat += item.temporaryDread; item.reasons.Add(new ReasonMsg("Temporary Dread", item.temporaryDread)); } if (item.threat < 0) { item.threat = 0; } if (item.threat > 200) { item.threat = 200; } } threatEvaluations.Sort(); }
public override void implement(VoteOption option) { base.implement(option); if (option.group != null) { Society receiver = (Society)option.group; bool canVassalise = false; List <Location> trans = new List <Location>(); foreach (Location loc in society.map.locations) { if (loc.soc == society) { trans.Add(loc); } if (loc.soc == receiver && loc.settlement != null) { canVassalise = true; } } if (canVassalise) { World.log(society.getName() + " ALLIES UNDER " + receiver.getName()); society.map.turnMessages.Add(new MsgEvent(society.getName() + " forms alliance under " + receiver.getName() + ", transferring all lands and landed nobles.", MsgEvent.LEVEL_RED, true, receiver.getCapitalHex())); foreach (Location loc in trans) { receiver.map.takeLocationFromOther(receiver, society, loc); } string message = society.getName() + " is allying itself under " + receiver.getName() + ", in response to their fears of the rising darkness. This alliance is made of nations " + " believed to be safe from the shadow"; if (receiver.allianceName == null) { if (receiver.getCapital() != null) { string name = ""; int q = Eleven.random.Next(7); if (q == 0) { name = receiver.getCapital().shortName + " Alliance"; } if (q == 1) { name = receiver.getCapital().shortName + " Concord"; } if (q == 2) { name = receiver.getCapital().shortName + " Guardians"; } if (q == 3) { name = "Alliance of " + receiver.getCapital().shortName; } if (q == 4) { name = receiver.getCapital().shortName + " Entente"; } if (q == 5) { name = "The " + receiver.getCapital().shortName + " League"; } if (q == 6) { name = "The " + receiver.getCapital().shortName + " Compact"; } message += "\nThis alliance will now go by the name of " + name; receiver.allianceName = name; } } society.map.world.prefabStore.popImgMsg(message, "The sheep naturally flock together in times of threat, seeking safety in number. But is the wolf already in their midst?"); } } }
public void dismissGoto() { GraphicalMap.panTo(society.getCapital().hex.x, society.getCapital().hex.y); ui.removeBlocker(this.gameObject); }
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); //} }