public override void process(Person p) { base.process(p); int c = 0; Person victim = null; int nSuspected = 0; foreach (Person p2 in p.society.people) { if (p2 == p) { continue; } RelObj rel = p.getRelation(p2); if (rel.suspicion > 0.5) { nSuspected += 1; } else { c += 1; if (Eleven.random.Next(c) == 0) { victim = p2; } } } if (nSuspected < p.map.param.insanity_nParanoiaTargets && victim != null) { p.getRelation(victim).suspicion = 1; } lashOut(p); }
public void bSwitchUsingLiking() { double uSel = sess.issue.computeUtility(voterBars[0].voter, voteOptBars[0].opt, new List <ReasonMsg>()); double uCurr = sess.issue.computeUtility(voterBars[0].voter, voterBars[0].voter.getVote(sess), new List <ReasonMsg>()); double utilityDelta = uCurr - uSel; if (utilityDelta < 0) { utilityDelta = 0; } double delta = (utilityDelta * world.map.param.voting_likingToSwitchPerU) + world.map.param.voting_likingToSwitchMin; RelObj rel = voterBars[0].voter.getRelation(agent); if (rel.getLiking() >= delta) { rel.addLiking(-delta, "Asked to switch vote", world.map.turn); world.audioStore.playActivate(); } else { world.audioStore.playClick(); world.prefabStore.popMsg(voterBars[0].voter.getFullName() + " does not like " + agent.getFullName() + " to agree to change to this voting option. Their liking is " + (int)(rel.getLiking()) + " but you need " + (int)(delta)); return; } voterBars[0].voter.forcedVoteOption = voteOptBars[0].opt; voterBars[0].voter.forcedVoteSession = sess; checkData(); }
public override double computeUtility(Person voter, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(voter); //Option 1 is "Kill suspect" //Multiply values based on this, as they should be symmetric for most parts double parityMult = 1; if (option.index == 0) { parityMult = -1; } RelObj rel = voter.getRelation(option.person); double apathy = (1 - voter.shadow); /* * This is actually already covered by liking, but caps out at 100. This adds another bonus, purely from suspicion */ double proKill = rel.suspicion * apathy * voter.map.param.utility_killSuspectFromSuspicion * parityMult; msgs.Add(new ReasonMsg("Suspicion towards " + option.person.getFullName(), proKill)); u += proKill; //double reluctance = -voter.map.param.utility_killSuspectRelucatance* parityMult * reluctanceModifier; //msgs.Add(new ReasonMsg("Base reluctance to kill noble", reluctance)); //u += reluctance; double liking = -rel.getLiking() * parityMult; msgs.Add(new ReasonMsg("Opinion of " + option.person.getFullName(), liking)); u += liking; return(u); }
private void computeSuspicionGain() { foreach (SocialGroup sg in map.socialGroups) { if (sg is Society == false) { continue; } Society soc = (Society)sg; foreach (Person p in soc.people) { if (p == this) { continue; } double infoAvail = map.getInformationAvailability(this.getLocation(), sg); RelObj rel = getRelation(p); double evidenceMult = Math.Pow(p.evidence, map.param.person_evidenceExponent);//Make low evidence a bit slower to cause suspicion //Give a bonus to the player, to allow their henchmen to be caught first if (p.state == personState.enthralled) { evidenceMult *= map.param.person_evidenceReduceEnthralled; } double fromTraits = 1; foreach (Trait t in traits) { fromTraits *= t.suspicionMult(); } rel.suspicion += infoAvail * evidenceMult * map.param.person_suspicionPerEvidence * fromTraits; } } }
public override double computeUtility(Person voter, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(voter); double localU = 0; if (option.group == null) { //Null case is "remain independent" localU = -voter.map.param.utility_vassaliseReluctance; msgs.Add(new ReasonMsg("Inherent reluctance", localU)); u += localU; return(u); } localU = voter.map.param.utility_vassaliseReluctance; msgs.Add(new ReasonMsg("Inherent reluctance", localU)); u += localU; Society socTarget = (Society)option.group; foreach (KillOrder order in socTarget.killOrders) { if (order.person == voter) { localU = -1000; msgs.Add(new ReasonMsg("Kill order against " + voter.getFullName(), localU)); u += localU; } } double awarenessU = society.map.param.utility_lightAllianceMult * voter.awareness; msgs.Add(new ReasonMsg("Awareness", awarenessU)); u += awarenessU; double militaryU = option.group.currentMilitary - voter.society.currentMilitary; militaryU *= society.map.param.utility_lightAllianceMilMult * voter.awareness; msgs.Add(new ReasonMsg("Their military might", militaryU)); u += militaryU; double totalSuspicion = 0; foreach (Person p in socTarget.people) { RelObj rel = voter.getRelation(p); totalSuspicion += rel.suspicion; } double susU = -totalSuspicion; susU *= society.map.param.utility_lightAlliancSusMult; msgs.Add(new ReasonMsg("Suspicion of their nobles", susU)); u += susU; return(u); }
public double getDistance(GraphicalSlot a, GraphicalSlot b) { RelObj ra = a.inner.getRelation(b.inner); RelObj rb = b.inner.getRelation(a.inner); double liking = (ra.getLiking() + rb.getLiking()) / 2; return(1.0f + (liking + 100) / 20); }
private void computeSuspicionGain() { foreach (SocialGroup sg in map.socialGroups) { if (sg is Society == false) { continue; } Society soc = (Society)sg; foreach (Person p in soc.people) { if (p == this) { continue; } double distance = 0; if (this.getLocation() != null && this.getLocation().distanceToTarget.ContainsKey(sg)) { distance = getLocation().distanceToTarget[sg]; } if (distance < 1) { distance = 1; } distance = Math.Sqrt(distance); double infoAvail = 1 / distance; if (infoAvail < 0.2) { infoAvail = 0.2; } RelObj rel = getRelation(p); double evidenceMult = Math.Pow(p.evidence, map.param.person_evidenceExponent);//Make low evidence a bit slower to cause suspicion //Give a bonus to the player, to allow their henchmen to be caught first if (p.state == personState.enthralled) { evidenceMult *= map.param.person_evidenceReduceEnthralled; } double fromTraits = 1; foreach (Trait t in traits) { fromTraits *= t.suspicionMult(); } if (rel.suspicion > p.evidence * map.param.relObj_suspicionLimiterMult) { continue; } if (p.getLocation() != null && p.getLocation().hex.cloud != null && p.getLocation().hex.cloud is Cloud_Fog) { fromTraits *= map.param.fog_suspicionIncreaseMult; } rel.suspicion += infoAvail * evidenceMult * map.param.person_suspicionPerEvidence * fromTraits; } } }
internal void set(Person key, RelObj value) { for (int i = 0; i < keys.Count; i++) { if (keys[i].Equals(key)) { values[i] = value; return; } } add(key, value); }
public RelObj getRelation(int other) { if (relations.ContainsKey(other)) { return(relations[other]); } RelObj rel = new RelObj(this, other); relations.Add(other, rel); return(rel); }
public override double computeUtility(Person voter, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(voter); RelObj rel = voter.getRelation(option.person); double liking = -rel.getLiking() * World.staticMap.param.utility_dismissFromCourt; msgs.Add(new ReasonMsg("Opinion of " + option.person.getFullName(), liking)); u += liking; return(u); }
public RelObj getRelation(Person other) { if (other == null) { throw new NullReferenceException(); } if (relations.ContainsKey(other)) { return(relations[other]); } RelObj rel = new RelObj(this, other); relations.Add(other, rel); return(rel); }
public override void castInner(Map map, Person victim) { Society soc = victim.society; victim.getRelation(map.overmind.enthralled).addLiking(-100, "Denounced me", map.turn); foreach (Person p in soc.people) { if (p == victim) { continue; } if (p == map.overmind.enthralled) { continue; } RelObj relEnth = p.getRelation(map.overmind.enthralled); RelObj relVic = p.getRelation(victim); World.log(p.getFullName() + " check " + relVic.suspicion + " " + victim.evidence); if (relVic.suspicion < victim.evidence) { double gain = victim.evidence - relVic.suspicion; gain = Math.Max(0, gain); gain = Math.Min(1, gain); //1 if you're revealling a fully evil person gain = Math.Pow(gain, 0.4); //Bring it closer to 1, get your money's worth relEnth.suspicion *= (1 - gain); //Suspicion drops to 0 if you give up a 100% evidence person with no suspicion on them relVic.suspicion += gain; if (relVic.suspicion > 1) { relVic.suspicion = 1; } relEnth.addLiking(gain * 25, "Revealled evidence of darkness", map.turn); World.log(p.getFullName() + " gain " + gain); } } map.world.prefabStore.popImgMsg( "You denounce another, unexpectedly revealing the evidence of evil which they hold to the world. " + " By denouncing a villain, the suspicion towards your enthralled is reduced.", map.world.wordStore.lookup("SOC_DENOUNCE_OTHER")); }
public RelObj getRelation(Person other) { if (other == null) { throw new NullReferenceException(); } RelObj rel = new RelObj(this, other); if (relations.keys.Count < 0)//ANWSAVE { if (relations.keys.Contains(other)) { return(relations.lookup(other)); } relations.add(other, rel); } return(rel); }
public override void process(Person p) { base.process(p); foreach (Person p2 in p.society.people) { if (p2 == p) { continue; } RelObj rel = p.getRelation(p2); if (p2.prestige > p.prestige) { if (rel.getLiking() > -100) { rel.addLiking(-100, "Grew envious due to higher prestige", p.map.turn); } } } lashOut(p); }
public void decompressPerson(Dictionary <string, string> invertedDictionary, Person p) { foreach (int other in p.relations.Keys) { RelObj rel = p.relations[other]; foreach (RelEvent msg in rel.events) { if (invertedDictionary.ContainsKey(msg.reason)) { msg.reason = invertedDictionary[msg.reason]; } } rel.them = other; } List <ThreatItem> removedItems = new List <ThreatItem>(); foreach (ThreatItem item in p.threatEvaluations) { if (item.groupRandID != 0) { foreach (SocialGroup sg in socialGroups) { if (sg.randID == item.groupRandID) { item.group = sg; } } if (item.group == null) { removedItems.Add(item); //world.prefabStore.popMsg("Unable to rebind threat item group", true); } } } foreach (ThreatItem item in removedItems) { p.threatEvaluations.Remove(item); } }
public override void turnTick(Person person) { if (person.title_land == null) { person.action = null; return; } turns += 1; if (turns >= World.staticMap.param.action_letterWritingTurns) { int c = 0; Person chosenTarget = null; foreach (Location loc in person.getLocation().getNeighbours()) { if (loc.person() != null) { RelObj rel = person.getRelation(loc.person()); if (rel.getLiking() < 10 && loc.person().awareness < person.awareness) { c += 1; if (Eleven.random.Next(c) == 0) { chosenTarget = loc.person(); } } } } if (chosenTarget != null) { double delta = person.map.param.awareness_letterWritingAwarenessGain * chosenTarget.getAwarenessMult() * person.map.param.awareness_master_speed; delta = Math.Min(delta, 1 - chosenTarget.awareness); delta = Math.Min(delta, person.awareness - chosenTarget.awareness);//Can't exceed your own awareness chosenTarget.awareness += delta; person.map.addMessage(person.getFullName() + " writes to " + chosenTarget.getFullName() + " to warn them. " + (int)(delta * 100) + " awareness gained", MsgEvent.LEVEL_ORANGE, false); person.lastLetterTurn = person.map.turn; } person.action = null; } }
private void computeSuspicionGain() { foreach (SocialGroup sg in map.socialGroups) { if (sg is Society == false) { continue; } Society soc = (Society)sg; foreach (Person p in soc.people) { if (p == this) { continue; } double infoAvail = map.getInformationAvailability(this.getLocation(), sg); RelObj rel = getRelation(p); double evidenceMult = Math.Pow(p.evidence, map.param.person_evidenceExponent);//Make low evidence a bit slower to cause suspicion rel.suspicion += infoAvail * evidenceMult * map.param.person_suspicionPerEvidence; } } }
public override double computeUtility(Person voter, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(voter); //Option 1 is "Kill suspect" //Multiply values based on this, as they should be symmetric for most parts RelObj rel = voter.getRelation(target.person); double apathy = (1 - voter.shadow); if (option.index == 0) { double liking = rel.getLiking(); msgs.Add(new ReasonMsg("Opinion of " + target.getName(), liking)); u += liking; } else if (option.index == 1) { /* * This is actually already covered by liking, but caps out at 100. This adds another bonus, purely from suspicion */ double proKill = rel.suspicion * apathy * voter.map.param.utility_exileSuspectFromSuspicion; msgs.Add(new ReasonMsg("Suspicion towards " + target.getName(), proKill)); u += proKill; double liking = -rel.getLiking(); msgs.Add(new ReasonMsg("Opinion of " + target.getName(), liking)); u += liking; double reluctance = -voter.map.param.utility_killSuspectRelucatance; msgs.Add(new ReasonMsg("Base reluctance to exile agent", reluctance)); u += reluctance; } return(u); }
public static void refreshUnlanded(Person nfocus) { clear(); focus = (nfocus != null) ? nfocus : activeSociety.getSovereign(); if (state != viewState.UNLANDED) { originalFocus = focus; } int n = 0; foreach (Person p in activeSociety.people) { if (p != focus && (p.title_land == null || p == originalFocus)) { n += 1; } } focus.outer.gameObject.SetActive(true); focus.outer.targetPosition = Vector3.zero; int i = 0; foreach (Person p in activeSociety.people) { if (p == focus || (p.title_land != null && p != originalFocus)) { continue; } GraphicalSlot ds = p.outer; float radius = 2.5f * zoom; float angle = 6.28f / n * i; float x = Mathf.Cos(angle) * radius; float y = Mathf.Sin(angle) * radius; ds.gameObject.SetActive(true); ds.connection = focus.outer; RelObj rto = focus.getRelation(p); RelObj rfrom = p.getRelation(focus); float to = (float)rto.getLiking(); float from = (float)rfrom.getLiking(); ds.targetPosition = new Vector3(x, y, 0.0f); if (from < 0) { ds.targetStartColor = Color.Lerp(ds.neutralColor, ds.badColor, -from / 100); } else { ds.targetStartColor = Color.Lerp(ds.neutralColor, ds.goodColor, from / 100); } if (to < 0) { ds.targetEndColor = Color.Lerp(ds.neutralColor, ds.badColor, -to / 100); } else { ds.targetEndColor = Color.Lerp(ds.neutralColor, ds.goodColor, to / 100); } ds.targetStartColor.a = ds.targetEndColor.a = 0.5f; ds.upperRightText.text = "liking for center: " + from.ToString("N0") + "%"; ds.upperRightText.text += "\nliking from center: " + to.ToString("N0") + "%"; ds.lowerRightText.text = "suspicion for center: " + rfrom.suspicion.ToString("N0") + "%"; ds.lowerRightText.text += "\nsuspicion from center: " + rto.suspicion.ToString("N0") + "%"; i += 1; } state = viewState.UNLANDED; resetHidden(); refreshOffset(); }
public override void turnTick(Unit unit) { if (unit.person == null) { unit.task = null; return; } if (unit.location.settlement == null) { unit.task = null; return; } if (unit.location.settlement.title == null) { unit.task = null; return; } if (unit.location.settlement.title.heldBy == null) { unit.task = null; return; } if (unit.location.soc is Society == false) { unit.task = null; return; } dur += 1; if (dur >= unit.location.map.param.unit_socialiseAtCourtTime) { Society soc = (Society)unit.location.soc; double maxPrestige = 0; foreach (Person p in soc.people) { if (p.prestige > maxPrestige) { maxPrestige = p.prestige; } } double prestige = unit.location.person().prestige; double scale = 0; if (maxPrestige > 0) { scale = prestige / maxPrestige; scale = 1 - scale;//0 to 1, 1 if prestige is 0, 0 if prestige is MAX scale *= 0.75; scale += 0.25; } RelObj rel = unit.location.settlement.title.heldBy.getRelation(unit.person); double maxGain = World.staticMap.param.unit_socialiseAtCourtGain; double delta = maxGain * scale; delta = Math.Min(delta, 100 - rel.getLiking()); if (delta < 0) { delta = 0; } int iDelta = (int)(delta); rel.addLiking(iDelta, "Socialised at court", unit.location.map.turn); if (unit.isEnthralled()) { unit.location.map.world.prefabStore.popImgMsg(unit.getName() + " finishes socialising at court. " + unit.location.settlement.title.heldBy.getFullName() + "'s liking " + "for them increases by " + iDelta + " and is now " + ((int)rel.getLiking()), unit.location.map.world.wordStore.lookup("ABILITY_UNIT_SOCIALISE_AT_COURT")); } unit.task = 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 override void turnTick(Unit unit) { dur += 1; if (dur >= unit.location.map.param.unit_shareSuspicionTime) { if (unit.person != null && unit.location.person() != null && unit.location.person().state != Person.personState.broken) { foreach (RelObj rel in unit.person.relations.Values) { double them = unit.location.person().getRelation(rel.them).suspicion; double me = rel.suspicion; double gain = (me - them) * 1; RelObj toInv = unit.location.person().getRelation(unit.person); double relLiking = toInv.getLiking(); relLiking += 50; if (relLiking < 0) { relLiking = 0; } relLiking /= 100; if (relLiking > 1) { relLiking = 1; } //0 to 1 gain *= relLiking; if (me > them) { Person themP = World.staticMap.persons[rel.them]; unit.location.map.addMessage(unit.getName() + " warns " + unit.location.person().getFullName() + " about " + themP.getFullName(), MsgEvent.LEVEL_ORANGE, false, unit.location.hex); unit.location.person().getRelation(rel.them).suspicion += gain; } } } if (unit is Unit_Investigator && unit.location.soc != null && unit.location.soc is Society) { Unit_Investigator inv = (Unit_Investigator)unit; Society soc = (Society)inv.location.soc; bool submitted = false; foreach (Evidence ev in inv.evidenceCarried) { if (soc.evidenceSubmitted.Contains(ev) == false) { submitted = true; soc.evidenceSubmitted.Add(ev); soc.lastEvidenceSubmission = unit.location.map.turn; ev.turnSubmitted = unit.location.map.turn; unit.location.addAgentDreadAroundThisLocation(); //double deltaFear = World.staticMap.param.threat_evidencePresented; //if (soc.isDarkEmpire == false) //{ // soc.dread_agents_evidenceFound += deltaFear; //} } } if (submitted) { unit.location.map.addMessage(unit.getName() + " presents evidence to " + soc.getName(), MsgEvent.LEVEL_ORANGE, false, unit.location.hex); } } unit.task = null; } }
public void Add(Person key, RelObj value) { add(key, value); }
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 void add(Person key, RelObj value) { keys.Add(key); values.Add(value); }
public Color getColor(Hex hex) { if (mask == maskType.NONE) { if (GraphicalMap.selectedSelectable != null && GraphicalMap.selectedSelectable is Unit) { if (hex.owner != null && hex.owner.hostileTo((Unit)GraphicalMap.selectedSelectable)) { return(new Color(0.5f, 0.0f, 0f, 0.5f)); } } return(Color.clear); } else if (mask == maskType.NATION) { if (hex.owner != null) { float r = hex.owner.color.r; float g = hex.owner.color.g; float b = hex.owner.color.b; Color color = new Color(r, g, b, 0.8f); return(color); } else { return(new Color(0.5f, 0.5f, 0.5f, 0.5f)); } } else if (mask == maskType.PROVINCE) { return(new Color(hex.province.cr, hex.province.cg, hex.province.cb, 0.5f)); } else if (mask == maskType.VOTE_EFFECT) { if (GraphicalMap.selectedHex != null && GraphicalMap.selectedHex.location != null && GraphicalMap.selectedHex.location.person() != null && hex.location != null && hex.location.soc != null) { if (GraphicalMap.selectedHex == hex) { return(new Color(1f, 1f, 1f, 0.5f)); } Person voter = GraphicalMap.selectedHex.location.person(); if (hex.location.soc == voter.society) { if (hex.location.person() != null && hex.location.soc is Society) { Society soc = (Society)hex.location.soc; if (soc.voteSession == null) { return(new Color(0f, 0f, 0f, 0.75f)); } VoteOption opt = null; foreach (VoteOption o2 in soc.voteSession.issue.options) { if (o2.votesFor.Contains(voter)) { opt = o2; break; } } if (opt == null) { soc.voteSession.assignVoters(); } foreach (VoteOption o2 in soc.voteSession.issue.options) { if (o2.votesFor.Contains(voter)) { opt = o2; break; } } if (soc.voteSession != null) { float delta = (float)soc.voteSession.issue.getLikingDelta(hex.location.person(), opt, soc.voteSession.issue); delta /= 25; if (delta > 1) { delta = 1f; } if (delta < -1) { delta = -1f; } if (delta >= 0) { return(new Color(0f, delta, 0f, 0.75f)); } else { return(new Color(-delta, 0f, 0f, 0.75f)); } } } } } return(new Color(0f, 0f, 0f, 0.75f)); } else if (mask == maskType.THREAT) { if (hex.location != null && GraphicalMap.selectedHex != null && GraphicalMap.selectedHex.location != null && GraphicalMap.selectedHex.location.settlement != null && GraphicalMap.selectedHex.location.settlement.title != null && GraphicalMap.selectedHex.location.settlement.title.heldBy != null) { SocialGroup group = GraphicalMap.selectedHex.location.soc; Person p = GraphicalMap.selectedHex.settlement.title.heldBy; double highestThreat = 0; foreach (ThreatItem item in p.threatEvaluations) { if (item.group != null && item.threat > highestThreat) { highestThreat = item.threat; } } if (highestThreat != 0) { if (hex.location.soc == null) { return(Color.black); } double threat = 0; foreach (ThreatItem item in p.threatEvaluations) { if (item.group == hex.location.soc) { threat = item.threat / highestThreat; break; } } float mult = (float)threat; mult = Mathf.Max(0, mult); mult = Mathf.Min(1, mult); //Color color = new Color(r, g, b, 0.8f); Color color = new Color(mult, 0, 0, 0.5f); return(color); } else { return(Color.black); } } else if (hex.location != null) { return(new Color(0f, 0f, 0f, 1f)); } else { return(new Color(0f, 0f, 0f, 0.75f)); } } else if (mask == maskType.LIKING_THEM) { Color c = new Color(0, 0, 0, 0.5f); try { Person me = null; if (GraphicalMap.selectedSelectable is Unit) { if (((Unit)GraphicalMap.selectedSelectable).person != null) { me = ((Unit)GraphicalMap.selectedSelectable).person; } } else { me = GraphicalMap.selectedHex.location.settlement.title.heldBy; } Person them = hex.location.settlement.title.heldBy; float liking = (float)them.getRelation(me).getLiking(); if (liking > 0) { if (liking > 100) { liking = 100; } liking /= 100; c = new Color(0, liking, 0, 0.5f); } else { liking *= -1; if (liking > 100) { liking = 100; } liking /= 100; c = new Color(liking, 0, 0, 0.5f); } } catch (NullReferenceException e) { } catch (ArgumentNullException e) { } return(c); } else if (mask == maskType.LIKING_ME) { Color c = new Color(0, 0, 0, 0.5f); try { Person me = null; if (GraphicalMap.selectedSelectable is Unit) { if (((Unit)GraphicalMap.selectedSelectable).person != null) { me = ((Unit)GraphicalMap.selectedSelectable).person; } } else { me = GraphicalMap.selectedHex.location.settlement.title.heldBy; } Person them = hex.location.settlement.title.heldBy; float liking = (float)me.getRelation(them).getLiking(); if (liking > 0) { if (liking > 100) { liking = 100; } liking /= 100; c = new Color(0, liking, 0, 0.5f); } else { liking *= -1; if (liking > 100) { liking = 100; } liking /= 100; c = new Color(liking, 0, 0, 0.5f); } } catch (NullReferenceException e) { } catch (ArgumentNullException e) { } return(c); } else if (mask == maskType.AWARENESS) { try { Person them = hex.settlement.title.heldBy; return(new Color((float)them.awareness, 0, 0, 0.9f)); } catch (Exception e) { return(new Color(0, 0, 0, 0.9f)); } } else if (mask == maskType.INFILTRATION) { try { float inf = (float)hex.settlement.infiltration; return(new Color(inf, inf, inf, 0.9f)); } catch (Exception e) { return(new Color(0, 0, 0, 0.9f)); } } else if (mask == maskType.SUSPICION) { try { Person me = GraphicalMap.selectedHex.settlement.title.heldBy; Person them = hex.settlement.title.heldBy; RelObj rel = me.getRelation(them); return(new Color((float)rel.suspicion, 0, 0, 0.5f)); }catch (Exception e) { return(new Color(0, 0, 0, 0.5f)); } } else if (mask == maskType.SUSPICION_FROM) { try { Person them = GraphicalMap.selectedHex.settlement.title.heldBy; Person me = hex.settlement.title.heldBy; RelObj rel = me.getRelation(them); return(new Color((float)rel.suspicion, 0, 0, 0.5f)); } catch (Exception e) { return(new Color(0, 0, 0, 0.5f)); } } else if (mask == maskType.TESTING) { if (hex.location != null) { if (hex.location.debugVal == map.turn) { return(new Color(1, 1, 1, 0.5f)); } else { return(new Color(0, 0, 0, 0.5f)); } } return(new Color(0f, 0f, 0f, 0.75f)); } else { return(new Color(0, 0, 0, 0)); } }
public string getBodyText() { if (mask == maskType.LIKING_ME) { try { Hex hex = GraphicalMap.getHexUnderMouse(Input.mousePosition).hex; Person me = GraphicalMap.selectedHex.location.settlement.title.heldBy; Person them = hex.location.settlement.title.heldBy; if (me.state == Person.personState.enthralled) { return(me.getFullName() + " is enthralled, so does not have normal likings."); } string words = me.getFullName() + " liking for " + them.getFullName(); RelObj rel = me.getRelation(them); words += "\nAmount: " + ((int)rel.getLiking()); double sus = rel.getDislikingFromSuspicion(me); if (sus != 0) { words += "\nFROM SUSPICION: " + sus; } List <RelEvent> sortedEvents = new List <RelEvent>(); sortedEvents.AddRange(rel.events); sortedEvents.Sort(); int nPrinted = 0; foreach (RelEvent ev in sortedEvents) { words += "\n -" + ev.reason + " : " + ((int)ev.amount); nPrinted += 1; if (nPrinted > 6) { break; } } return(words); } catch (Exception e) { return(""); } } else if (mask == maskType.LIKING_THEM) { try { Hex hex = GraphicalMap.getHexUnderMouse(Input.mousePosition).hex; Person them = GraphicalMap.selectedHex.location.settlement.title.heldBy; Person me = hex.location.settlement.title.heldBy; if (me.state == Person.personState.enthralled) { return(me.getFullName() + " is enthralled, so does not have normal likings."); } string words = me.getFullName() + " liking for " + them.getFullName(); RelObj rel = me.getRelation(them); words += "\nAmount: " + ((int)rel.getLiking()); double sus = rel.getDislikingFromSuspicion(me); if (sus != 0) { words += "\nFROM SUSPICION: " + (int)sus; } List <RelEvent> sortedEvents = new List <RelEvent>(); sortedEvents.AddRange(rel.events); sortedEvents.Sort(); int nPrinted = 0; foreach (RelEvent ev in sortedEvents) { words += "\n -" + ev.reason + " : " + ((int)ev.amount); nPrinted += 1; if (nPrinted > 6) { break; } } return(words); } catch (Exception e) { return(""); } } return(""); }
public Color getColor(Hex hex) { if (mask == maskType.NATION) { if (hex.owner != null) { float r = hex.owner.color[0]; float g = hex.owner.color[1]; float b = hex.owner.color[2]; Color color = new Color(r, g, b, 0.8f); return(color); } else { return(new Color(0.5f, 0.5f, 0.5f, 0.5f)); } } else if (mask == maskType.PROVINCE) { return(new Color(hex.province.cr, hex.province.cg, hex.province.cb, 0.5f)); } else if (mask == maskType.INFORMATION) { if (hex.location != null && GraphicalMap.selectedHex != null && GraphicalMap.selectedHex.location != null && GraphicalMap.selectedHex.location.soc != null) { SocialGroup group = GraphicalMap.selectedHex.location.soc; float mult = (float)map.getInformationAvailability(hex.location, group); mult = Mathf.Max(0, mult); mult = Mathf.Min(1, mult); float r = mult; float g = mult; float b = mult; //Color color = new Color(r, g, b, 0.8f); Color color = new Color(0, 0, 0, (1 - mult)); return(color); } else if (hex.location != null) { return(new Color(0f, 0f, 0f, 1f)); } else { return(new Color(0f, 0f, 0f, 0.75f)); } } else if (mask == maskType.THREAT) { if (hex.location != null && GraphicalMap.selectedHex != null && GraphicalMap.selectedHex.location != null && GraphicalMap.selectedHex.location.settlement != null && GraphicalMap.selectedHex.location.settlement.title != null && GraphicalMap.selectedHex.location.settlement.title.heldBy != null) { SocialGroup group = GraphicalMap.selectedHex.location.soc; Person p = GraphicalMap.selectedHex.settlement.title.heldBy; double highestThreat = 0; foreach (ThreatItem item in p.threatEvaluations) { if (item.group != null && item.threat > highestThreat) { highestThreat = item.threat; } } if (highestThreat != 0) { if (hex.location.soc == null) { return(Color.black); } double threat = 0; foreach (ThreatItem item in p.threatEvaluations) { if (item.group == hex.location.soc) { threat = item.threat / highestThreat; break; } } float mult = (float)threat; mult = Mathf.Max(0, mult); mult = Mathf.Min(1, mult); float r = mult; float g = mult; float b = mult; //Color color = new Color(r, g, b, 0.8f); Color color = new Color(mult, 0, 0, 0.5f); return(color); } else { return(Color.black); } } else if (hex.location != null) { return(new Color(0f, 0f, 0f, 1f)); } else { return(new Color(0f, 0f, 0f, 0.75f)); } } else if (mask == maskType.LIKING_THEM) { Color c = new Color(0, 0, 0, 0.5f); try { Person me = GraphicalMap.selectedHex.location.settlement.title.heldBy; Person them = hex.location.settlement.title.heldBy; float liking = (float)them.getRelation(me).getLiking(); if (liking > 0) { if (liking > 100) { liking = 100; } liking /= 100; c = new Color(0, liking, 0, 0.5f); } else { liking *= -1; if (liking > 100) { liking = 100; } liking /= 100; c = new Color(liking, 0, 0, 0.5f); } } catch (NullReferenceException e) { } catch (ArgumentNullException e) { } return(c); } else if (mask == maskType.LIKING_ME) { Color c = new Color(0, 0, 0, 0.5f); try { Person me = GraphicalMap.selectedHex.location.settlement.title.heldBy; Person them = hex.location.settlement.title.heldBy; float liking = (float)me.getRelation(them).getLiking(); if (liking > 0) { if (liking > 100) { liking = 100; } liking /= 100; c = new Color(0, liking, 0, 0.5f); } else { liking *= -1; if (liking > 100) { liking = 100; } liking /= 100; c = new Color(liking, 0, 0, 0.5f); } } catch (NullReferenceException e) { } catch (ArgumentNullException e) { } return(c); } else if (mask == maskType.EVIDENCE) { try { Person them = hex.settlement.title.heldBy; return(new Color((float)them.evidence, 0, 0, 0.5f)); } catch (Exception e) { return(new Color(0, 0, 0, 0.5f)); } } else if (mask == maskType.SUSPICION) { try { Person me = GraphicalMap.selectedHex.settlement.title.heldBy; Person them = hex.settlement.title.heldBy; RelObj rel = me.getRelation(them); return(new Color((float)rel.suspicion, 0, 0, 0.5f)); }catch (Exception e) { return(new Color(0, 0, 0, 0.5f)); } } else if (mask == maskType.SUSPICION_FROM) { try { Person them = GraphicalMap.selectedHex.settlement.title.heldBy; Person me = hex.settlement.title.heldBy; RelObj rel = me.getRelation(them); return(new Color((float)rel.suspicion, 0, 0, 0.5f)); } catch (Exception e) { return(new Color(0, 0, 0, 0.5f)); } } else if (mask == maskType.TESTING) { if (hex.location != null) { if (hex.location.debugVal == map.turn) { return(new Color(1, 1, 1, 0.5f)); } else { return(new Color(0, 0, 0, 0.5f)); } } return(new Color(0f, 0f, 0f, 0.75f)); } else { return(new Color(0, 0, 0, 0)); } }
public string getBodyText() { if (mask == maskType.LIKING_ME) { try { Hex hex = GraphicalMap.getHexUnderMouse(Input.mousePosition).hex; Person me = null; if (GraphicalMap.selectedSelectable is Unit) { if (((Unit)GraphicalMap.selectedSelectable).person != null) { me = ((Unit)GraphicalMap.selectedSelectable).person; } } else { me = GraphicalMap.selectedHex.location.settlement.title.heldBy; } Person them = hex.location.settlement.title.heldBy; if (me.state == Person.personState.enthralled) { return(me.getFullName() + " is enthralled, so does not have normal likings."); } string words = me.getFullName() + " liking for " + them.getFullName(); RelObj rel = me.getRelation(them); words += "\nAmount: " + ((int)rel.getLiking()); double sus = rel.getDislikingFromSuspicion(); if (sus != 0) { words += "\nFROM SUSPICION: " + (int)sus; } List <ReasonMsg> msgs = new List <ReasonMsg>(); RelObj.getLikingModifiers(me, them.index, msgs); foreach (ReasonMsg msg in msgs) { words += "\n\n -" + msg.msg + " " + ((int)msg.value); } List <RelEvent> sortedEvents = new List <RelEvent>(); sortedEvents.AddRange(rel.events); sortedEvents.Sort(); int nPrinted = 0; foreach (RelEvent ev in sortedEvents) { words += "\n\n -" + ev.reason + " : " + ((int)ev.amount); nPrinted += 1; if (nPrinted > 6) { break; } } return(words); } catch (Exception e) { return(""); } } else if (mask == maskType.LIKING_THEM) { try { Hex hex = GraphicalMap.getHexUnderMouse(Input.mousePosition).hex; Person them = null; if (GraphicalMap.selectedSelectable is Unit) { if (((Unit)GraphicalMap.selectedSelectable).person != null) { them = ((Unit)GraphicalMap.selectedSelectable).person; } } else { them = GraphicalMap.selectedHex.location.settlement.title.heldBy; } Person me = hex.location.settlement.title.heldBy; if (me.state == Person.personState.enthralled) { return(me.getFullName() + " is enthralled, so does not have normal likings."); } string words = me.getFullName() + " liking for " + them.getFullName(); RelObj rel = me.getRelation(them); words += "\nAmount: " + ((int)rel.getLiking()); double sus = rel.getDislikingFromSuspicion(); if (sus != 0) { words += "\nFROM SUSPICION: " + (int)sus; } List <ReasonMsg> msgs = new List <ReasonMsg>(); RelObj.getLikingModifiers(me, them.index, msgs); foreach (ReasonMsg msg in msgs) { words += "\n\n -" + msg.msg + " " + ((int)msg.value); } List <RelEvent> sortedEvents = new List <RelEvent>(); sortedEvents.AddRange(rel.events); sortedEvents.Sort(); int nPrinted = 0; foreach (RelEvent ev in sortedEvents) { words += "\n\n -" + ev.reason + " : " + ((int)ev.amount); nPrinted += 1; if (nPrinted > 6) { break; } } return(words); } catch (Exception e) { return(""); } } else if (mask == maskType.VOTE_EFFECT) { if (GraphicalMap.selectedHex != null && GraphicalMap.selectedHex.location != null && GraphicalMap.selectedHex.location.person() != null) { Person voter = GraphicalMap.selectedHex.location.person(); Society soc = (Society)voter.society; if (soc.voteSession == null) { return("No voting currently happening in " + voter.getFullName() + "'s society"); } VoteOption opt = soc.voteSession.issue.options[0]; foreach (VoteOption o2 in soc.voteSession.issue.options) { if (o2.votesFor.Contains(voter)) { opt = o2; break; } } return("The change in liking towards " + voter.getFullName() + " if they vote for their currently preferred option (" + opt.info(soc.voteSession.issue) + ")."); } } return(""); }
public static void refresh(Person pf) { focus = pf; int tn = activeSociety.people.Count - 1; int i = 0; foreach (GraphicalSlot s in loadedSlots) { if (s.inner == focus) { s.targetPosition = Vector3.zero; s.subtitle.text = ""; s.lowerRightText.text = ""; } else { int n, ring; if (i < 12) { n = (tn < 12) ? tn : 12; ring = 0; } else { n = (tn - 12 < 52) ? tn - 12 : 52; ring = 1; } RelObj rel = focus.getRelation(s.inner); float liking = (float)rel.getLiking() / 100; if (i == 0) { Debug.Log(rel.suspicion.ToString()); } float radius = (1.75f * ring + 3.0f); float x = Mathf.Cos(6.28f / n * i + ring * 0.1f) * radius; float y = Mathf.Sin(6.28f / n * i + ring * 0.1f) * radius; s.targetPosition = new Vector3(x, y, 0.0f); if (liking < 0) { s.targetColor = Color.Lerp(s.neutralColor, s.badColor, -liking); } else { s.targetColor = Color.Lerp(s.neutralColor, s.goodColor, liking); } s.targetColor.a = 0.5f; //s.targetColor.a = 0.1f + ((float)rel.suspicion / 100); s.subtitle.text = "Relationship with " + focus.firstName; s.lowerRightText.text = "Liked by: " + focus.getRelation(s.inner).getLiking().ToString("N0") + "%"; s.lowerRightText.text += ", Likes: " + s.inner.getRelation(focus).getLiking().ToString("N0") + "%"; s.lowerRightText.text += "\nSuspected by: " + focus.getRelation(s.inner).suspicion.ToString("N0") + "%"; s.lowerRightText.text += ", Suspects: " + s.inner.getRelation(focus).suspicion.ToString("N0") + "%"; i += 1; } } }