public void warAI_defend() { if (this.location.soc == this.parentSG) { task = null; return; } else { task = new Task_GoToSocialGroup(this.parentSG); return; } }
public override void turnTickAI(Map map) { if (this.location.soc == society) { sinceHome = 0; /* * if (person != null && location.person() != null && location.person().state != Person.personState.broken){ * foreach (RelObj rel in person.relations.Values) * { * double them = location.person().getRelation(rel.them).suspicion; * double me = rel.suspicion; * if (me > them) * { * map.addMessage(this.getName() + " warns " + location.person().getFullName() + " about " + rel.them.getFullName(),MsgEvent.LEVEL_ORANGE,false); * location.person().getRelation(rel.them).suspicion = me; * } * } * } */ } else { sinceHome += 1; } //Scan local units foreach (Unit u in location.units) { if (u.isEnthralled()) { if (this.person != null && u.person != null) { this.person.getRelation(u.person).suspicion = Math.Min(1, this.person.getRelation(u.person).suspicion + map.param.unit_suspicionFromProximity); map.addMessage(this.getName() + " has gained suspicion of " + u.getName(), MsgEvent.LEVEL_RED, false); } } } if (task != null) { task.turnTick(this); return; } if (location.evidence.Count > 0) { task = new Task_Investigate(); } else if (sinceHome > wanderDur) { task = new Task_GoToSocialGroup(society); } else { task = new Task_Wander(); } task.turnTick(this); }
public void turnTickAI_Basic(Map map) { foreach (Evidence ev in evidenceCarried) { if (ev.pointsTo != null && ev.pointsTo != this) { if (huntableSuspects.Contains(ev.pointsTo) == false) { huntableSuspects.Add(ev.pointsTo); } } } if (this.location.soc == society) { sinceHome = 0; if (this.hp < maxHp && task == null && location.settlement != null) { task = new Task_Resupply(); } } else { sinceHome += 1; } if (task == null || task is Task_Wander) { bool onDisease = false; foreach (Property pr in location.properties) { if (pr.proto.isDisease) { onDisease = true; break; } } if (onDisease) { task = new Task_TreatDisease(); task.turnTick(this); return; } } if (task != null) { task.turnTick(this); return; } else if (society.isAtWar()) { task = new Task_SupportMilitary(); } else if (location.evidence.Count > 0) { task = new Task_Investigate(); } else if (sinceHome > wanderDur) { task = new Task_GoToSocialGroup(society); } else { task = new Task_Wander(); } task.turnTick(this); }
public override void turnTickAI(Map map) { if (task != null) { task.turnTick(this); return; } if (location.settlement == null && location.isForSocieties && location.soc == null && location.hex.getHabilitability() > map.param.mapGen_minHabitabilityForHumans) { task = new Task_EstablishNewSettlement(); task.turnTick(this); return; } if (Eleven.random.NextDouble() < map.param.unit_merchantChanceToExpandIntoNeighbouring) { int c = 0; Location target = null; //foreach (Location loc in society.lastTurnLocs) //{ foreach (Location l2 in map.locations) { if (l2.settlement == null && l2.isForSocieties && l2.soc == null && l2.hex.getHabilitability() > map.param.mapGen_minHabitabilityForHumans) { c += 1; if (Eleven.random.Next(c) == 0) { target = l2; } } } //} task = new Task_GoToLocation(target); task.turnTick(this); return; } if (this.cash >= 50) { if (location.soc == society) { task = new Task_SpendWealth(); return; } else { task = new Task_GoToSocialGroup(society); return; } } if (this.cargo >= 50) { if (location.soc != null && location.soc != society) { task = new Task_SellCargo(); return; } double bestV = 0; Location bestLoc = null; foreach (Location l2 in map.locations) { if (l2.soc is Society && l2.soc != society && (l2.soc.hostileTo(this) == false)) { double v = Eleven.random.NextDouble() * location.map.getDist(location.hex, l2.hex); if (v > bestV) { bestV = v; bestLoc = l2; } } } if (bestLoc != null) { task = new Task_GoToLocation(bestLoc); return; } //Otherwise if (location.soc is Society && (location.soc.hostileTo(this) == false) && location.settlement != null) { //Couldn't find anywhere better task = new Task_SellCargo(); return; } } else { if (location.soc == society) { task = new Task_LoadCargo(); return; } else { task = new Task_GoToSocialGroup(society); } } }
public void turnTickAI_Investigator(Map map) { foreach (Evidence ev in evidenceCarried) { if (ev.pointsTo != null && ev.pointsTo != this) { if (huntableSuspects.Contains(ev.pointsTo) == false) { huntableSuspects.Add(ev.pointsTo); } } } if (this.location.soc == society) { sinceHome = 0; if (this.hp < maxHp && task == null && location.settlement != null) { task = new Task_Resupply(); } } else { sinceHome += 1; } //Scan local units if (map.param.unit_investigatorsSeeEnthralled == 1) { foreach (Unit u in location.units) { if (u.isEnthralled() && u.person != null && this.person.getRelation(u.person).suspicion > 0) { if (this.person != null && u.person != null) { this.person.getRelation(u.person).suspicion = Math.Min(1, this.person.getRelation(u.person).suspicion + map.param.unit_suspicionFromProximity); map.addMessage(this.getName() + " has gained suspicion of " + u.getName(), MsgEvent.LEVEL_ORANGE, false, location.hex); } } } } if (task != null) { task.turnTick(this); return; } if (shouldBePaladin(map)) { Unit target = null; double bestDist = -1; foreach (Unit u in huntableSuspects) { if (map.units.Contains(u)) { double dist = map.getStepDist(u.location, location); if (bestDist == -1 || dist < bestDist) { bestDist = dist; target = u; } } } task = new Task_HuntEnthralled_PaladinState(this, target); paladinTarget = target; state = unitState.paladin; lastTurnPromoted = map.turn; if (hostility.Contains(paladinTarget) == false) { hostility.Add(paladinTarget); } paladinDuration = map.param.unit_paladin_promotionDuration; map.world.prefabStore.popMsgAgent(this, target, this.getName() + " has found evidence that " + paladinTarget.getName() + " is in league with the darkness," + " and has been granted the powers of the paladin, to hunt them down for a duration. They are currently in " + location.getName() + "."); //Update your graphic if (this.outer != null) { this.outer.checkData(); } return; } else if (location.evidence.Count > 0) { task = new Task_Investigate(); } else if (sinceHome > wanderDur) { task = new Task_GoToSocialGroup(society); } else { task = new Task_Wander(); } task.turnTick(this); }