public void setTo(ThreatItem item) { titleText.text = item.getTitle(); if (item.threat > World.staticMap.param.person_fearLevel_terrified) { titleText.text += "\n[Terrified]"; } else if (item.threat > World.staticMap.param.person_fearLevel_afraid) { titleText.text += "\n[Afraid]"; } else { titleText.text += "\n[Modest Concern]"; } if (item.p != null) { string t = ""; List <string> list = item.getReasons(); foreach (string s in list) { t += s + "\n\n"; } t += "\nTotal Threat: " + (int)(item.threat); mainText.text = t; } else { mainText.text = "Average Society-wide Threat Estimate:\n" + (int)(item.threat); } }
public override void castInner(Map map, Person person) { ThreatItem item = person.getGreatestThreat(); if (item == null) { return; } double prevThreat = item.threat; double addDread = item.threat * map.param.ability_instillDreadMult; bool hitCap = false; if (item.threat + addDread >= 200) { hitCap = true; item.threat = 200 - item.threat;//Now at 200 } else { item.temporaryDread += addDread; item.threat += addDread; } string msgs = "You draw upon " + person.getFullName() + "'s fears, adding to their dread of " + item.getTitle() + ". Their threat estimate has gone from " + (int)(prevThreat) + " to " + (int)(item.threat) + "."; if (hitCap) { msgs += "\n(It is now at its maximum value)"; } map.world.prefabStore.popImgMsg( msgs, map.world.wordStore.lookup("ABILITY_INSTILL_DREAD")); }
public PopupXBoxThreat getThreatBox(ThreatItem item) { GameObject obj = Instantiate(xBoxThreat) as GameObject; PopupXBoxThreat specific = obj.GetComponent <PopupXBoxThreat>(); specific.setTo(item); specific.body = "The perceived threats and a breakdown of the reasons."; return(specific); }
public override void castInner(Map map, Person person) { Society soc = person.society; int nAffected = 0; double totalV = 0; foreach (Person p in soc.people) { bool affected = false; ThreatItem t = p.getGreatestThreat(); foreach (Person p2 in soc.people) { if (p2 == p) { continue; } if (p2.state == Person.personState.enthralled) { continue; } foreach (ThreatItem t2 in p2.threatEvaluations) { if (t2.isSame(t)) { double delta = t.threat - t2.threat; if (delta > 0) { affected = true; delta *= map.param.ability_polariseByFearMult; p.getRelation(p2).addLiking(-delta, "Polarised by fear of " + t.getTitle(), map.turn); totalV += delta; } break; } } } if (affected) { nAffected += 1; } } double avrg = 0; if (nAffected > 0) { avrg = totalV / nAffected; } map.world.prefabStore.popImgMsg( "You turn the people of " + soc.getName() + " against each other, causing nobles to hate those who do not share their fears.\n" + nAffected + " nobles are affected, with an average liking change of of " + (int)(-avrg), map.world.wordStore.lookup("ABILITY_POLARISE_BY_FEAR")); }
public void testYScroll() { List <ThreatItem> threats = new List <ThreatItem>(); for (int i = 0; i < 5; i++) { Person p = new Person((Society)map.socialGroups[0]); ThreatItem t = new ThreatItem(map, p); threats.Add(t); } ui.addBlocker(prefabStore.getScrollSetThreats(threats).gameObject); }
public Person(Society soc) { this.society = soc; firstName = TextStore.getName(isMale); politics_militarism = Math.Pow(Eleven.random.NextDouble(), 0.75); //Bias towards 0 politics_militarism = 1 - politics_militarism; //0 to 1, bias towards 1 politics_militarism = (2 * politics_militarism) - 1; //1 to -1, bias towards 1 //Add permanent threats threat_enshadowedNobles = new ThreatItem(map, this); threat_enshadowedNobles.form = ThreatItem.formTypes.ENSHADOWED_NOBLES; threat_enshadowedNobles.responseCode = ThreatItem.RESPONSE_DARKNESSWITHIN; threatEvaluations.Add(threat_enshadowedNobles); }
public ThreatItem getGreatestThreat() { ThreatItem g = null; double s = 0.0; foreach (ThreatItem t in threatEvaluations) { if (t.threat > s) { g = t; s = t.threat; } } return(g); }
public void processThreats() { //First up, see if anything needs to be added/removed List <ThreatItem> rems = new List <ThreatItem>(); HashSet <SocialGroup> groups = new HashSet <SocialGroup>(); foreach (ThreatItem item in threatEvaluations) { if (item.group != null) { if (item.group.isGone()) { rems.Add(item); } else if (item.group == society) { rems.Add(item); } else { groups.Add(item.group); } } item.turnTick(); } foreach (ThreatItem item in rems) { threatEvaluations.Remove(item); } foreach (SocialGroup sg in map.socialGroups) { if (groups.Contains(sg) == false && (sg != society)) { ThreatItem item = new ThreatItem(map, this); item.group = sg; threatEvaluations.Add(item); } } foreach (ThreatItem item in threatEvaluations) { item.temporaryDread *= map.param.threat_temporaryDreadDecay; } computeThreats(); }
public PopupXScroll getScrollSetThreats(List <ThreatItem> threats) { PopupXScroll specific = getInnerXScrollSet(); List <ThreatItem> dupe = new List <ThreatItem>(); foreach (ThreatItem item in threats) { dupe.Add(item); } List <ThreatItem> ordered = new List <ThreatItem>(); int viewedCount = 0; while (dupe.Count > 0) { ThreatItem best = dupe[0]; foreach (ThreatItem item in dupe) { if (item.threat > best.threat) { best = item; } } if (best.threat < 75 && best.group != null && best.group is Society && viewedCount >= 3) { //Skip it, we don't need to list all minor factions we aren't scared of } else { viewedCount += 1; ordered.Add(best); } dupe.Remove(best); } foreach (ThreatItem item in ordered) { PopupXBoxThreat box = getThreatBox(item); box.gameObject.transform.SetParent(specific.gameObject.transform); specific.scrollables.Add(box); } return(specific); }
public Person(Society soc) { this.society = soc; firstName = TextStore.getName(isMale); madness = new Insanity_Sane(); maxSanity = Eleven.random.Next(map.param.insanity_maxSanity); sanity = maxSanity; if (World.logging) { log = new LogBox(this); } politics_militarism = Math.Pow(Eleven.random.NextDouble(), 2);//Bias towards 0 //Chance of pacifism if (Eleven.random.NextDouble() < 0.33) { politics_militarism *= -1; } //Add permanent threats threat_enshadowedNobles = new ThreatItem(map, this); threat_enshadowedNobles.form = ThreatItem.formTypes.ENSHADOWED_NOBLES; threat_enshadowedNobles.responseCode = ThreatItem.RESPONSE_DARKNESSWITHIN; threatEvaluations.Add(threat_enshadowedNobles); for (int i = 0; i < 3; i++) { Trait add = map.globalist.getTrait(this); if (add == null) { break; } traits.Add(add); if (Eleven.random.Next(2) == 0) { break; } //50% chance to add another trait } }
public override void castInner(Map map, Person other) { ThreatItem item = other.threatEvaluations[0]; foreach (Person p2 in other.society.people) { foreach (ThreatItem item2 in p2.threatEvaluations) { if (item2.isSame(item)) { item2.temporaryDread += map.param.ability_fearmongerTempThreat; } } p2.computeThreats(); } map.world.prefabStore.popImgMsg( "Your enthralled brings up the fear of " + item.getTitle() + ", causing the nobles of " + other.society.getName() + " to dread it, increasing threat temporarily.", map.world.wordStore.lookup("ABILITY_FEARMONGER")); }
public override void castInner(Map map, Person person) { Society soc = person.society; int nAffected = 0; foreach (Person p in soc.people) { bool affected = false; ThreatItem t = p.getGreatestThreat(); if (t.threat >= map.param.person_fearLevel_terrified) { foreach (Person p2 in soc.people) { if (p2 == p) { continue; } if (p2.state == Person.personState.enthralled) { continue; } if (p2.getMilitarism() < 0) { p.getRelation(p2).addLiking(map.param.ability_denouncePacisfistsLiking, "Pacifists expose us to danger", map.turn); } } if (affected) { nAffected += 1; } } } map.world.prefabStore.popImgMsg( "You call on the nobles of " + soc.getName() + " to reject the pacifists in their midst, explaining that these people are exposing you all to danger by refusing to take up arms against your many foes.\n" + nAffected + " nobles are affected.", map.world.wordStore.lookup("ABILITY_DENOUNCE_PACIFISTS")); }
public void setTo(ThreatItem item) { titleText.text = item.getTitle(); if (item.p != null) { string t = ""; List <string> list = item.getReasons(); foreach (string s in list) { t += s + "\n\n"; } t += "\nTotal Threat: " + (int)(item.threat); t += "\n\nResponse: " + ThreatItem.responseNames[item.responseCode]; mainText.text = t; } else { mainText.text = "Average Society-wide Threat Estimate:\n" + (int)(item.threat); } }
public override void cast(Map map, Hex hex) { base.cast(map, hex); ThreatItem item = hex.location.person().getGreatestThreat(); if (item == null) { return; } string changes = ""; foreach (Location loc in hex.location.getNeighbours()) { if (loc.person() != null) { Person other = loc.person(); foreach (ThreatItem t2 in other.threatEvaluations) { if (t2.isSame(item)) { double delta = item.threat - t2.threat; if (delta <= 0) { continue; } double liking = other.getRelation(hex.location.person()).getLiking(); if (liking <= 0) { continue; } liking /= 100; double prev = t2.threat; delta *= liking; if (t2.threat + delta > 200) { delta = 200 - t2.threat; } t2.threat += delta; t2.temporaryDread += delta; changes += other.getFullName() + " " + (int)(prev) + " -> " + (int)(t2.threat) + "; "; } } } } if (changes.Length > 0) { changes = changes.Substring(0, changes.Length - 2);//Strip the last separator } string msgs = "You spread " + hex.location.person().getFullName() + "'s fears of " + item.getTitle() + " to any neighbour who will listen. "; if (changes.Length > 0) { msgs += "\n" + changes; } else { msgs += "\nBut there are none."; } map.world.prefabStore.popImgMsg( msgs, map.world.wordStore.lookup("ABILITY_SPREAD_FEAR")); }
public void showPersonInfo(Person p) { profileBack.enabled = true; profileMid.enabled = true; profileFore.enabled = true; profileBorder.enabled = true; //Done to unfuck the distortion of images which periodically occurs profileBack.sprite = null; profileMid.sprite = null; profileFore.sprite = null; profileBorder.sprite = null; profileBack.sprite = p.getImageBack(); profileMid.sprite = p.getImageMid(); profileFore.sprite = p.getImageFore(); if (p.society.getSovreign() == p) { profileBorder.sprite = p.map.world.textureStore.slotKing; } else if (p.titles.Count > 0) { profileBorder.sprite = p.map.world.textureStore.slotDuke; } else { profileBorder.sprite = p.map.world.textureStore.slotCount; } personTitle.text = p.getFullName(); TitleLanded title = p.title_land; if (title == null) { locText.text = "No Landed Title"; } else { locText.text = "of " + title.settlement.name; } string bodyText = ""; if (p.getDirectSuperiorIfAny() != null) { bodyText += "\nDirect Superior: " + p.getDirectSuperiorIfAny().getFullName(); } else { bodyText += "\nDirect Superior: None"; } prestigeText.text = "Prestige: " + (int)(p.prestige) + "\nPrestige Moving towards: " + (int)(p.getTargetPrestige(null)); bodyText += "\nShadow: " + (int)(p.shadow * 100) + "%"; bodyText += "\nEvidence: " + (int)(p.evidence * 100) + "%"; bodyText += "\nMilitarism: " + (int)(p.politics_militarism * 100) + "%"; bodyText += " (" + p.getMilitarismInfo() + ")"; bodyText += "\n"; personAwarenss.text = (int)(p.awareness * 100) + "%"; if (p.action == null) { actionText.text = "Not Taking Action"; actionDesc.text = "Characters can take actions if they become aware and world panic is sufficiently high."; actionDesc.text = "\n\nThis character is not taking an action."; } else { actionText.text = p.action.getShort(); actionDesc.text = "Characters can take actions if they become aware and world panic is sufficiently high."; actionDesc.text = "\n\n" + p.action.getLong(); } Society soc = getSociety(GraphicalMap.selectedHex); VoteSession vote = (soc != null) ? soc.voteSession : null; if (vote != null) { bodyText += "\nVoting on: " + vote.issue.ToString(); VoteOption vo = p.getVote(vote); bodyText += "\n\tto " + vo.info(vote.issue); } else { bodyText += "\nNot voting."; } bodyText += "\n"; ThreatItem threat = p.getGreatestThreat(); if (threat != null) { bodyText += "\nBelieved Greatest Threat: " + threat.getTitle(); bodyText += "\nFear of threat: " + (int)threat.threat; if (threat.threat > World.staticMap.param.person_fearLevel_terrified) { bodyText += "\n[Terrified]"; } else if (threat.threat > World.staticMap.param.person_fearLevel_afraid) { bodyText += "\n[Afraid]"; } else { bodyText += "\n[Moderate Concern]"; } } else { bodyText += "\nNot feeling threatened."; } personBody.text = bodyText; insanityText.text = "Sanity state: " + p.madness.name; insanityText.text += "\nSanity: " + ((int)p.sanity) + " Maximum: " + p.maxSanity; insanityDescText.text = p.madness.desc + "\n\n" + "Characters have a sanity score. If this value drops to zero, they become insane, and begin to act in an erratic and dangerous manner. " + "Characters will dislike insane characters to a moderate degree, and insane characters will occasionally lash out, further reducing their relationships." + "\nYou can cause reduce sanity using certain abilities."; personAwarenssDesc.text = "A person's awareness is how much they have realised about the threat their world faces.\nIt allows them to take actions against the darkenss directly." + "\nSome nobles gain awareness each time you expend power, they can also gain awareness by gaining suspicion as they seen evidence, and can be warned by their fellow nobles, especially neighbours." + "\nAwareness gain can be increased by being in a place of learning, or increased or decreased by traits." + "\n\nThis noble has an awareness rate of " + (int)(100 * p.getAwarenessMult()) + "%"; prestigeDescText.text = ""; List <string> prestigeReasons = new List <string>(); p.getTargetPrestige(prestigeReasons); foreach (string s in prestigeReasons) { prestigeDescText.text += "*" + s + "\n"; } for (int i = 0; i < traits.Length; i++) { traits[i].SetActive(false); traitDescBoxes[i].SetActive(false); } for (int i = 0; i < p.traits.Count; i++) { traits[i].SetActive(true); traitNames[i].text = p.traits[i].name; traitDescs[i].text = p.traits[i].desc; } }
public List <MsgEvent> getThreats() { List <MsgEvent> reply = new List <MsgEvent>(); List <Unit> agents = new List <Unit>(); foreach (Unit u in map.units) { if (u.isEnthralled() && (!u.automated)) { agents.Add(u); } else { if (u.task is Task_Investigate) { reply.Add(new MsgEvent(u.getName() + " is investigating evidence at " + u.location.getName(), MsgEvent.LEVEL_ORANGE, false, u.location.hex)); } else if (u.task is Task_ShareSuspicions) { reply.Add(new MsgEvent(u.getName() + " is warning the noble at " + u.location.getName(), MsgEvent.LEVEL_ORANGE, false, u.location.hex)); } else if (u.task is Task_InvestigateNoble) { if (u.location.person() != null) { int level = MsgEvent.LEVEL_ORANGE; if (u.location.person().state == Person.personState.enthralled) { level = MsgEvent.LEVEL_RED; } reply.Add(new MsgEvent(u.getName() + " is investigating the noble at " + u.location.getName(), level, false, u.location.hex)); } } else if (u.task is Task_InvestigateNobleBasic) { if (u.location.person() != null) { int level = MsgEvent.LEVEL_YELLOW; if (u.location.person().state == Person.personState.enthralled) { level = MsgEvent.LEVEL_ORANGE; } reply.Add(new MsgEvent(u.getName() + " is investigating the noble at " + u.location.getName(), level, false, u.location.hex)); } } } } int[] suspicions = new int[agents.Count]; foreach (SocialGroup sg in map.socialGroups) { bool relevant = false; if (sg.hasEnthralled()) { relevant = true; } if (sg is Society) { Society soc = (Society)sg; if (soc.isDarkEmpire) { relevant = true; } foreach (Person p in soc.people) { if (p.state == Person.personState.enthralled || p.state == Person.personState.broken) { continue; } for (int i = 0; i < agents.Count; i++) { Unit u = agents[i]; if (u.person != null) { if (p.getRelation(u.person).suspicion > 0) { suspicions[i] += 1; } } } } if (soc.voteSession != null) { if (soc.voteSession.issue is VoteIssue_CondemnAgent) { VoteIssue_CondemnAgent issue = (VoteIssue_CondemnAgent)soc.voteSession.issue; if (issue.target.isEnthralled()) { reply.Add(new MsgEvent(soc.getName() + " is voting to condemn " + issue.target.getName(), MsgEvent.LEVEL_RED, false, issue.target.location.hex)); } } } } else { if (sg.isDark()) { relevant = true; } } if (relevant) { foreach (SocialGroup s2 in map.socialGroups) { if (s2 == sg) { continue; } if (s2 is Society) { Society soc = (Society)s2; Hex hex = null; if (soc.capital != null) { hex = soc.capital.hex; } if (soc.offensiveTarget == sg) { if (soc.posture == Society.militaryPosture.offensive) { int level = MsgEvent.LEVEL_RED; if (soc.currentMilitary < sg.currentMilitary * 0.75) { level = MsgEvent.LEVEL_ORANGE; } if (soc.currentMilitary < sg.currentMilitary * 0.25) { level = MsgEvent.LEVEL_YELLOW; } reply.Add(new MsgEvent(soc.getName() + " is offensive and targetting " + sg.getName(), MsgEvent.LEVEL_RED, false, hex)); if (soc.voteSession != null && soc.voteSession.issue is VoteIssue_DeclareWar) { reply.Add(new MsgEvent(soc.getName() + " is voting to declare war on " + sg.getName(), MsgEvent.LEVEL_RED, false, hex)); } } else { reply.Add(new MsgEvent(soc.getName() + " is targetting " + sg.getName(), MsgEvent.LEVEL_ORANGE, false, hex)); } } else { int nThreat = 0; foreach (Person p in soc.people) { ThreatItem t = p.getGreatestThreat(); if (t != null && t.group == sg) { nThreat += 1; } } if (nThreat > 0) { reply.Add(new MsgEvent(nThreat + " nobles from " + soc.getName() + " consider " + sg.getName() + " their greatest threat", MsgEvent.LEVEL_YELLOW, false, hex)); } } } } } } for (int i = 0; i < agents.Count; i++) { if (suspicions[i] > 0) { reply.Add(new MsgEvent(suspicions[i] + " nobles are suspicious of " + agents[i].getName(), MsgEvent.LEVEL_YELLOW, false)); } } return(reply); }
public void showPersonInfo(Person p) { uiPerson.setTo(p); //I'm sure there was a reason why this info assignment done in two separate classes //And I'm sure the reason is 'I was too lazy to do a full migration and left it till later' //As I am doing now prestigeText.text = "Prestige: " + (int)(p.prestige) + "\nPrestige Moving towards: " + (int)(p.getTargetPrestige(null)); personShadowAndEvidenceVals.text = (int)(p.shadow * 100) + "%\n" + (int)(p.evidence * 100) + "%"; personAwarenss.text = (int)(p.awareness * 100) + "%"; if (p.action == null) { actionText.text = "Not Taking Action"; actionDesc.text = "Characters can take actions if they become aware and world panic is sufficiently high."; actionDesc.text = "\n\nThis character is not taking an action."; } else { actionText.text = p.action.getShort(); actionDesc.text = "Characters can take actions if they become aware and world panic is sufficiently high."; actionDesc.text = "\n\n" + p.action.getLong(); } string bodyText = ""; //if (p.getDirectSuperiorIfAny() != null) //{ // bodyText += "\nDirect Superior: " + p.getDirectSuperiorIfAny().getFullName(); //} //else //{ // bodyText += "\nDirect Superior: None"; //} //bodyText += "\n"; //bodyText += "\n"; ThreatItem threat = p.getGreatestThreat(); if (threat != null) { bodyText += "\nBelieved Greatest Threat: " + threat.getTitle(); bodyText += "\nFear of threat: " + (int)threat.threat; if (threat.threat > World.staticMap.param.person_fearLevel_terrified) { bodyText += "\n[Terrified]"; } else if (threat.threat > World.staticMap.param.person_fearLevel_afraid) { bodyText += "\n[Afraid]"; } else { bodyText += "\n[Moderate Concern]"; } } else { bodyText += "\nNot feeling threatened."; } personBody.text = bodyText; insanityText.text = "Sanity state: " + p.madness.name; insanityText.text += "\nSanity: " + ((int)p.sanity) + " Maximum: " + p.maxSanity; insanityDescText.text = p.madness.desc + "\n\n" + "Characters have a sanity score. If this value drops to zero, they become insane, and begin to act in an erratic and dangerous manner. " + "Characters will dislike insane characters to a moderate degree, and insane characters will occasionally lash out, further reducing their relationships." + "\nYou can cause reduce sanity using certain abilities."; personAwarenssDesc.text = "A person's awareness is how much they have realised about the threat their world faces.\nIt allows them to take actions against the darkenss directly." + "\nSome nobles gain awareness each time you expend power, they can also gain awareness by gaining suspicion as they seen evidence, and can be warned by their fellow nobles, especially neighbours." + "\nAwareness gain can be increased by being in a place of learning, or increased or decreased by traits." + "\n\nThis noble has an awareness rate of " + (int)(100 * p.getAwarenessMult()) + "%"; prestigeDescText.text = ""; List <string> prestigeReasons = new List <string>(); p.getTargetPrestige(prestigeReasons); foreach (string s in prestigeReasons) { prestigeDescText.text += "*" + s + "\n"; } for (int i = 0; i < traits.Length; i++) { traits[i].SetActive(false); traitDescBoxes[i].SetActive(false); } for (int i = 0; i < p.traits.Count; i++) { traits[i].SetActive(true); traitNames[i].text = p.traits[i].name; traitDescs[i].text = p.traits[i].desc; } }
public Person(Society soc, House assignedHouse = null) { this.society = soc; index = World.staticMap.personIndexCount; World.staticMap.personIndexCount += 1; World.staticMap.persons.Add(this);//I can't believe this awful structure is required, but it is, for serializing. Not allowed references to others firstName = TextStore.getName(isMale); madness = new Insanity_Sane(); maxSanity = Eleven.random.Next(map.param.insanity_maxSanity); sanity = maxSanity; if (World.logging) { log = new LogBox(this); } //politics_militarism = Math.Pow(Eleven.random.NextDouble(), 2);//Bias towards 0 ////Chance of pacifism //if (Eleven.random.NextDouble() < 0.33) { // politics_militarism *= -1; //} if (assignedHouse == null) { assignedHouse = society.houses[Eleven.random.Next(society.houses.Count)]; } house = assignedHouse; if (house != null) { culture = house.culture; } if (culture == null) { culture = map.sampleCulture(soc); } //Add permanent threats threat_agents = new ThreatItem(map, this); threat_agents.form = ThreatItem.formTypes.AGENTS; threatEvaluations.Add(threat_agents); threat_enshadowedNobles = new ThreatItem(map, this); threat_enshadowedNobles.form = ThreatItem.formTypes.ENSHADOWED_NOBLES; threatEvaluations.Add(threat_enshadowedNobles); threat_plague = new ThreatItem(map, this); threat_plague.form = ThreatItem.formTypes.PLAGUE; threatEvaluations.Add(threat_plague); if (!map.simplified) { traits.Add(map.globalist.getTrait_Political(this)); for (int i = 0; i < 2; i++) { Trait add = map.globalist.getTrait(this); if (add == null) { break; } traits.Add(add); if (Eleven.random.Next(2) == 0) { break; } //50% chance to add another trait } } if (World.advancedEdition && culture != null) { assignCulture(); } }
public override double computeUtility(Person voter, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(voter); ThreatItem greatestThreat = voter.getGreatestThreat(); double ourStr = 1 + (voter.society.currentMilitary + (voter.society.maxMilitary / 2)); double offStr = 1; double defStr = 1; if (voter.society.offensiveTarget != null) { offStr = voter.society.offensiveTarget.currentMilitary + (voter.society.offensiveTarget.maxMilitary / 2); } if (voter.society.defensiveTarget != null) { defStr = voter.society.defensiveTarget.currentMilitary + (voter.society.defensiveTarget.maxMilitary / 2); } double defUtility = 0; double defGreatestThreat = 0; if (voter.society.defensiveTarget != null) { //Negative if we are stronger than the one we fear defUtility += (defStr - ourStr) / (ourStr + defStr) * voter.map.param.utility_militaryTargetRelStrengthDefensive; if (defUtility < -50) { defUtility = -50; } if (greatestThreat != null) { if (greatestThreat.group != null && greatestThreat.group.currentMilitary > voter.society.currentMilitary) { defGreatestThreat = World.staticMap.param.utility_greatestThreatDelta; defUtility += defGreatestThreat; if (option.index == 0) { msgs.Add(new ReasonMsg("Our greatest threat (" + greatestThreat.group.getName() + ") is stronger than us, we must defend", defGreatestThreat)); } } } } double offUtility = 0; double offUtilityStr = 0; double offUtilityPersonality = 0; double offUtilityTerritory = 0; double offUtilityInstab = 0; double offGreatestThreat = 0; if (voter.society.offensiveTarget != null) { //Negative if the offensive target is stronger offUtilityStr += (ourStr - offStr) / (ourStr + offStr) * voter.map.param.utility_militaryTargetRelStrengthOffensive; if (voter.society.offensiveTarget is Society) { offUtilityStr = Math.Min(offUtilityStr, voter.map.param.utility_militaryTargetRelStrengthOffensive);//Capped to prevent insanity snowballing } offUtilityPersonality += voter.getMilitarism() * voter.map.param.utility_militarism; //We want to expand into territory we already partially own bool hasOurTerritory = false; foreach (Location loc in voter.society.offensiveTarget.lastTurnLocs) { if (loc.province == voter.getLocation().province) { hasOurTerritory = true; break; } } if (hasOurTerritory) { offUtilityTerritory += society.map.param.utility_militaryTargetCompleteProvince * society.data_societalStability; } if (offUtilityStr > 0 && society.offensiveTarget is Society) { //Counters expansion desire. Value always negative or zero //u = off*stability //u = off + (off*(stability-1)) (Because we are removing 1 from stability mult) //If stab == 0 it's off - off //If stab < 0 it's less than off offUtilityInstab = offUtilityInstab * (society.data_societalStability - 1); } if (greatestThreat != null) { if (greatestThreat.group != null && greatestThreat.group.currentMilitary < voter.society.currentMilitary) { offGreatestThreat += World.staticMap.param.utility_greatestThreatDelta; if (option.index == 1) { msgs.Add(new ReasonMsg("Our greatest threat (" + greatestThreat.group.getName() + ") is weaker than us, we must attack", offGreatestThreat)); } } } offUtility += offGreatestThreat; offUtility += offUtilityStr; offUtility += offUtilityPersonality; offUtility += offUtilityTerritory; offUtility += offUtilityInstab; } double introUtility = 0; double introUtilityStability = 0; if (society.data_societalStability < 0.66) { introUtilityStability = -(society.data_societalStability - 1); //0 if stability is 1, increasing to 1 if civil war is imminent, to 2 if every single person is a traitor } double introGreatestThreat = 0; if (greatestThreat != null) { if (greatestThreat.form == ThreatItem.formTypes.AGENTS || greatestThreat.form == ThreatItem.formTypes.ENSHADOWED_NOBLES) { introGreatestThreat = World.staticMap.param.utility_greatestThreatDelta; introUtility += introGreatestThreat; if (option.index == 2) { msgs.Add(new ReasonMsg("Our greatest threat (" + greatestThreat.getTitle() + ") requires internal security", introGreatestThreat)); } } } introUtilityStability *= voter.map.param.utility_introversionFromInstability; double introFromInnerThreat = voter.threat_enshadowedNobles.threat * voter.map.param.utility_introversionFromSuspicion; introUtility += introUtilityStability; introUtility += introFromInnerThreat; introUtility += 10; //Option 0 is DEFENSIVE //Option 1 is OFFENSIVE //Option 2 is INTROSPECTIVE if (voter.society.posture == Society.militaryPosture.defensive && option.index != 0) { u -= defUtility; msgs.Add(new ReasonMsg("Switching away from defensive", -defUtility)); } if (voter.society.posture == Society.militaryPosture.offensive && option.index != 1) { u -= offUtility; msgs.Add(new ReasonMsg("Switching away from offensive", -offUtility)); } if (voter.society.posture == Society.militaryPosture.introverted && option.index != 2) { u -= introUtility; msgs.Add(new ReasonMsg("Switching away from introversion", -introUtility)); } if (option.index == 0) { if (society.posture != Society.militaryPosture.defensive) { u += defUtility; msgs.Add(new ReasonMsg("Our relative strength against defensive target", defUtility)); if (voter.society.isDarkEmpire) { int value = (int)(-100 * voter.shadow); u += value; msgs.Add(new ReasonMsg("We must expand the Dark Empire", value)); } } else { u += defUtility; msgs.Add(new ReasonMsg("Our relative strength against defensive target", defUtility)); if (voter.society.isDarkEmpire) { int value = (int)(-100 * voter.shadow); u += value; msgs.Add(new ReasonMsg("We must expand the Dark Empire", value)); } msgs.Add(new ReasonMsg("No need to change: It is our current stance", -u)); u = 0; } } if (option.index == 1) { if (society.posture != Society.militaryPosture.offensive) { u += offUtility; msgs.Add(new ReasonMsg("Our relative strength against offensive target", offUtilityStr)); msgs.Add(new ReasonMsg("Risk of instability from expansion", offUtilityInstab)); msgs.Add(new ReasonMsg("Militarism personality", offUtilityPersonality)); msgs.Add(new ReasonMsg("Desire for territory", offUtilityTerritory)); if (voter.society.isDarkEmpire) { int value = (int)(100 * voter.shadow); u += value; msgs.Add(new ReasonMsg("We must expand the Dark Empire", value)); } } else { u += offUtility; msgs.Add(new ReasonMsg("Our relative strength against offensive target", offUtilityStr)); msgs.Add(new ReasonMsg("Risk of instability from expansion", offUtilityInstab)); msgs.Add(new ReasonMsg("Militarism personality", offUtilityPersonality)); msgs.Add(new ReasonMsg("Desire for territory", offUtilityTerritory)); if (voter.society.isDarkEmpire) { int value = (int)(100 * voter.shadow); u += value; msgs.Add(new ReasonMsg("We must expand the Dark Empire", value)); } msgs.Add(new ReasonMsg("No need to change: It is our current stance", -u)); u = 0; } } if (option.index == 2) { msgs.Add(new ReasonMsg("Default position", 10)); if (society.posture != Society.militaryPosture.introverted) { u += introUtility; msgs.Add(new ReasonMsg("Instability internally", introUtilityStability)); msgs.Add(new ReasonMsg("Suspicion of nobles' darkness", introFromInnerThreat)); if (voter.society.isDarkEmpire) { int value = (int)(-100 * voter.shadow); u += value; msgs.Add(new ReasonMsg("We must expand the Dark Empire", value)); } } else { u += introUtility; msgs.Add(new ReasonMsg("Instability internally", introUtilityStability)); msgs.Add(new ReasonMsg("Suspicion of nobles' darkness", introFromInnerThreat)); if (voter.society.isDarkEmpire) { int value = (int)(-100 * voter.shadow); u += value; msgs.Add(new ReasonMsg("We must expand the Dark Empire", value)); } msgs.Add(new ReasonMsg("No need to change: It is our current stance", -u)); u = 0; } } return(u); }
public override void castInner(Map map, Person person) { ThreatItem item = person.getGreatestThreat(); if (item == null) { return; } Society soc = person.society; Person sov = soc.getSovreign(); if (sov == null) { return; } int nAffected = 0; double totalV = 0; double sovFear = 0; foreach (ThreatItem ti in sov.threatEvaluations) { if (item.isSame(ti)) { sovFear = ti.threat; break; } } foreach (Person p in soc.people) { double myFear = 0; foreach (ThreatItem ti in p.threatEvaluations) { if (item.isSame(ti)) { myFear = ti.threat; break; } } double deltaFear = myFear - sovFear; if (deltaFear <= 0) { continue; } double deltaLiking = deltaFear * map.param.ability_denounceLeaderLikingMult; deltaLiking = Math.Min(deltaLiking, map.param.ability_denounceLeaderMax); p.getRelation(sov).addLiking(-deltaLiking, "Doesn't take threat of " + item.getTitle() + " seriously", map.turn); nAffected += 1; totalV += deltaFear; } double avrg = 0; if (nAffected > 0) { avrg = totalV / nAffected; } map.world.prefabStore.popImgMsg( "You rally the people against " + sov.getFullName() + ", denouncing them as unable to defend the people against the threat of " + item.getTitle() + ".\n" + nAffected + " nobles agree, with an average liking change of of " + (int)(-avrg), map.world.wordStore.lookup("ABILITY_DENOUNCE_LEADER")); }
public void showPersonInfo(Person p) { profileBack.enabled = true; profileMid.enabled = true; profileFore.enabled = true; //Done to unfuck the distortion of images which periodically occurs profileBack.sprite = null; profileMid.sprite = null; profileFore.sprite = null; profileBack.sprite = p.getImageBack(); profileMid.sprite = p.getImageMid(); profileFore.sprite = p.getImageFore(); personTitle.text = p.getFullName(); TitleLanded title = p.title_land; if (title == null) { locText.text = "No Landed Title"; } else { locText.text = "of " + title.settlement.name; } string bodyText = "Prestige: " + (int)(p.prestige); bodyText += "\nPrestige Moving towards: " + (int)(p.targetPrestige); bodyText += "\nShadow: " + (int)(p.shadow * 100) + "%"; bodyText += "\nEvidence: " + (int)(p.evidence * 100) + "%"; bodyText += "\nMilitarism: " + (int)(p.politics_militarism * 100) + "%"; bodyText += " (" + p.getMilitarismInfo() + ")"; bodyText += "\n"; Society soc = getSociety(GraphicalMap.selectedHex); VoteSession vote = (soc != null) ? soc.voteSession : null; if (vote != null) { bodyText += "\nVoting on: " + vote.issue.ToString(); VoteOption vo = p.getVote(vote); bodyText += "\n\tto " + vo.info(vote.issue); } else { bodyText += "\nNot voting."; } bodyText += "\n"; ThreatItem threat = p.getGreatestThreat(); if (threat != null) { bodyText += "\nBelieved Greatest Threat: " + threat.getTitle(); } else { bodyText += "\nNot feeling threatened."; } personBody.text = bodyText; }