Originally posted by Tamerlin
By splitting an army do you mean that "unlocking" the units in the same tile is enough?
By splitting an army do you mean that "unlocking" the units in the same tile is enough?


messagebox 'msgReplaceUnits' { Title(ID_TITLE_upgrade_query); MessageType("TP_QUEUE_EMPTY_AFTER_UNIT"); MessageClass(789); i = 0; onecost = 0; oldunitcount = 0; while (i < player.totalunits) { SetUnitByIndex(1, g.player, i); if (unit.type == oldunittype) { oldunitcount = oldunitcount + 1; } i = i + 1; } if(oldunitcount>0) { if(IsHumanPlayer(g.player)) { onecost = (newunitcost) - (oldunitcost); if (onecost <= player.gold) { KillClass(g.player,987); MessageClass(987); privoldunittype=oldunittype; privnewunittype=newunittype; privoldunitcost=oldunitcost; privnewunitcost=newunitcost; privtotalcost = (privnewunitcost*oldunitcount) - (privoldunitcost*oldunitcount); privonecost = privnewunitcost - privoldunitcost; if (privtotalcost <= player.gold && oldunitcount>1) { Button(ID_BUTTON_Do_upgrade) { AddGold(player, -privtotalcost); i = 0; while (i < player.totalunits) { SetUnitByIndex(1, player, i); if (unit.type == privoldunittype) { oldunitlocation = unit.location; if(UnitsInCell(oldunitlocation)>1) { SetOrder(1, 13); AddOrder(unit, oldunitlocation); } SetOrder(1, 56); AddOrder(unit, oldunitlocation); CreateUnit(player, privnewunittype, oldunitlocation, 0); } else { i = i + 1; } } KillClass(g.player, 987); } } Button(ID_BUTTON_Do_one_upgrade) { AddGold(player, -privonecost); i = 0; while (i < player.totalunits) { SetUnitByIndex(1, g.player, i); if (unit.type == privoldunittype) { oldunitlocation = unit.location; if(UnitsInCell(oldunitlocation)>1) { SetOrder(1, 13); AddOrder(unit, oldunitlocation); } SetOrder(1, 56); AddOrder(unit, oldunitlocation); CreateUnit(player, privnewunittype, oldunitlocation, 0); KillClass(player, 987); message(g.player,'msgReplaceUnits'); } else { i = i + 1; } } } Button(ID_BUTTON_LibraryNew) { LibraryUnit(privnewunittype); } Button(ID_BUTTON_LibraryOld) { LibraryUnit(privoldunittype); } if (oldunitcount>1) { Text(ID_TEXT_upgrade_query); } else { Text(ID_TEXT_upgrade_one_query); } } else { Abort(); } } else { // AI Player KillClass(g.player,978); MessageClass(978); privoldunittype=oldunittype; privnewunittype=newunittype; i = 0; while (i < player.totalunits) { SetUnitByIndex(1, player, i); if (unit.type == privoldunittype) { oldunitlocation = unit.location; KillUnit(unit.1); CreateUnit(player, privnewunittype, oldunitlocation, 0); } else { i = i + 1; } } KillClass(g.player, 978); } } else { Abort(); } }
trigger 'keytest' when (key.3.pressed && unit.selected) // where key.3 = "U" { //do stuff //in here the unit context is invalid? but it works if I remove the key.pressed part of the trigger }
trigger 'keytest' when (key.3.pressed && unit.selected) // where key.3 = "U" { //do stuff //in here the unit context is invalid? but it works if I remove the key.pressed part of the trigger }
trigger 'WarriorUpgrade' when (unit.fortified && HasAdvance(g.player, ID_ADVANCE_IRON_WORKING) && unit.type == UnitType("UNIT_WARRIOR")) { oldunitlocation = unit.location; if(UnitsInCell(oldunitlocation)>1) { SetOrder(1, 13); AddOrder(unit, oldunitlocation); } SetOrder(1, 56); AddOrder(unit, oldunitlocation); CreateUnit(player, UnitType("UNIT_LEGION"), oldunitlocation, 0); }
Comment