public override void cast(Map map, Hex hex) { //base.cast(map, hex); Society soc = map.overmind.enthralled.society; Person proposer = map.overmind.enthralled; VoteIssue issue = null; List <VoteIssue> potentialIssues = new List <VoteIssue>(); if (soc.posture == Society.militaryPosture.offensive && soc.offensiveTarget != null && (soc.isAtWar() == false)) { issue = new VoteIssue_DeclareWar(soc, soc.offensiveTarget, proposer); potentialIssues.Add(issue); VoteOption option_0 = new VoteOption(); option_0.index = 0; issue.options.Add(option_0); VoteOption option_1 = new VoteOption(); option_1.index = 1; issue.options.Add(option_1); } if (proposer.title_land != null) { potentialIssues.AddRange(econIssues(map, proposer, soc)); } //Remove unlanded nobles List <Person> removables = new List <Person>(); foreach (Person p in soc.people) { if (p.title_land == null) { removables.Add(p); } } if (removables.Count != 0) { issue = new VoteIssue_DismissFromCourt(soc, proposer); foreach (Person p in removables) { VoteOption option = new VoteOption(); option.person = p; issue.options.Add(option); } potentialIssues.Add(issue); } issue = new VoteIssue_MilitaryStance(soc, proposer); potentialIssues.Add(issue); for (int i = 0; i < 3; i++) { VoteOption opt = new VoteOption(); opt.index = i; issue.options.Add(opt); } //Check to see if you want to alter offensive military targetting issue = new VoteIssue_SetOffensiveTarget(soc, proposer); foreach (SocialGroup neighbour in map.getExtendedNeighbours(soc)) { VoteOption option = new VoteOption(); option.group = neighbour; issue.options.Add(option); } potentialIssues.Add(issue); //Check to see if you want to alter defensive military targetting issue = new VoteIssue_SetDefensiveTarget(soc, proposer); foreach (ThreatItem item in proposer.threatEvaluations) { if (item.group == null) { continue; } VoteOption option = new VoteOption(); option.group = item.group; issue.options.Add(option); } //Check if you want to vassalise yourself if (soc.offensiveTarget != null && soc.posture == Society.militaryPosture.defensive && (soc.isAtWar() == false)) { foreach (SocialGroup sg in soc.getNeighbours()) { if (sg is Society == false) { continue; } if (sg == soc) { continue; } Society other = (Society)sg; if (other.defensiveTarget == soc.defensiveTarget) { issue = new VoteIssue_Vassalise(soc, other, proposer); VoteOption option_0 = new VoteOption(); option_0.index = 0; issue.options.Add(option_0); VoteOption option_1 = new VoteOption(); option_1.index = 1; issue.options.Add(option_1); potentialIssues.Add(issue); } } } //Check if you want to execute someone if (soc.posture == Society.militaryPosture.introverted) { foreach (Person p in soc.people) { if (p == proposer) { continue; } issue = new VoteIssue_JudgeSuspect(soc, p, proposer); VoteOption option_0 = new VoteOption(); option_0.index = 0; issue.options.Add(option_0); VoteOption option_1 = new VoteOption(); option_1.index = 1; issue.options.Add(option_1); potentialIssues.Add(issue); } } foreach (Title t in soc.titles) { if (t.turnLastAssigned - map.turn > map.param.society_minTimeBetweenTitleReassignments) { issue = new VoteIssue_AssignTitle(soc, proposer, t); potentialIssues.Add(issue); //Everyone is eligible foreach (Person p in soc.people) { VoteOption opt = new VoteOption(); opt.person = p; issue.options.Add(opt); } } } foreach (Location loc in map.locations) { if (loc.soc == soc && loc.settlement != null && loc.settlement.title != null) { issue = new VoteIssue_AssignLandedTitle(soc, proposer, loc.settlement.title); potentialIssues.Add(issue); //Everyone is eligible foreach (Person p in soc.people) { VoteOption opt = new VoteOption(); opt.person = p; issue.options.Add(opt); } } } map.world.ui.addBlocker(map.world.prefabStore.getScrollSet(this, soc, potentialIssues).gameObject); map.overmind.hasTakenAction = false; }
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(); }