public override void castInner(Map map, Unit u) { Task_SellCargo task = new Task_SellCargo(); u.task = task; Unit_Merchant merchant = (Unit_Merchant)u; merchant.hasSoldCargo = true; float profit = task.getSaleValue(u.society, u.location); u.location.map.world.prefabStore.popImgMsg(u.getName() + " begins selling cargo, generating wealth. Every turn they will sell 10% of their cargo, with a proft of " + ((int)(100 * profit)) + "%. Metropoles, cities and towns give greater profit, and selling in your home nation generates less than selling in foreign lands." , u.location.map.world.wordStore.lookup("ABILITY_UNIT_SELL_CARGO"), 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); } } }