public override void castInner(Map map, Unit u) { Task_SpendWealth task = new Task_SpendWealth(); u.task = task; Unit_Merchant merchant = (Unit_Merchant)u; merchant.hasSpendWealth = true; if (merchant.hasSpendWealth && merchant.hasSoldCargo && merchant.hasLoadedCargo) { AchievementManager.unlockAchievement(SteamManager.achievement_key.MERCANTILISM); } u.location.map.world.prefabStore.popImgMsg(u.getName() + " begins spending their wealth, in lavish banquets, gifts and fine silks. They enjoy the company of the local noble, who" + " benefits from increased taxes and excellent festivals. The economy booms, to be spent on swords or favours." , u.location.map.world.wordStore.lookup("ABILITY_UNIT_SPEND_WEALTH"), 1); }
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); } } }