 |
|  |
 |
|
TheBirdMan
|
 |
A real Master of CTP-PBEM - together with all the others.....
Sep 1999 time: 05:31
|
|
Try to download Wes W MedMod 4.13 and take a look at the slic-code, which are used for auto-upgrade of the garrisons (or militia units as they are called).
Some of the code comes here:
// This trigger kills all Hoplites, Fyrdmen, Arquebusiers, Musketeers, Riflemen and Machine Gunners and puts a Plasmatica in every (non-space)city (so units outside cities are destroyed)
trigger 'UpgradeMilitiaToPlasmatica' when (player.1 && discovery.type == 191) { // cybernetics
i = 0;
while (i < player.1.totalunits) { // loop through all units
SetUnitByIndex(1, player.1, i);
if (unit.type == UnitType("UNIT_HOPLITE_MILITIA") || unit.type == UnitType("UNIT_FYRDMAN_MILITIA") || unit.type == UnitType("UNIT_ARQUEBUSIER_MILITIA") || unit.type == UnitType("UNIT_MUSKETEERS_MILITIA") || unit.type == UnitType("UNIT_RIFLEMEN_MILITIA") || unit.type == UnitType("UNIT_MACHINE_GUNNER_MILITIA")) {
KillUnit(unit);
} else {
i = i + 1;
}
}
i = 0;
while (i < player.1.cities) { // loop through all cities
SetCityByIndex(1, player.1, i);
if (TerrainType(city.location) != 13) {
if (city.population <= 8) {
number = 1;
} elseif (city.population <= 16) {
number = 2;
} elseif (city.population <= 24) {
number = 3;
} else { // if (city.population > 24) {
number = 4;
}
while (number > 0) {
CreateUnit(player.1, UnitType("UNIT_PLASMATICA_MILITIA"), city.location, 0, militiaunit);
SetOrder(1,4); // Fortify unit
AddOrder(militiaunit, city.location);
number = number - 1;
}
i = i + 1;
}
}
}
// end MILITIA triggers code
You will find the whole thing at the end of the script.slc file in the gamedata subfolder in the Medpack4 folder when you have installed/unpacked the scenario.
You might be able to use this for a mod of you own.
|
|
|  |
 |
|
Locutus
|
|
ACS CTP1/2 Manager & Civ4 Co-Manager
|
 |
Hengelo, The Netherlands
Nov 1999 time: 06:31
|
|
Well, that code is rather specific for militia units, but it can with some effort be adapted for generic unit upgrading:
code: TypeLocation upgradeloc; // only need to define this once
// create one trigger for every upgrade (Warrior to Samurai, Hoplite to Pikeman, Cavalry to Tank, etc)
trigger 'UpgradeWarriorToSamurai' when (player.1 && discovery.type == 6) {
// activate at advance 6th advance from advance.txt (start counting at 0): jurisprudence
i = 0;
while (i < player.1.totalunits) { // loop through all units
SetUnitByIndex(1, player.1, i);
if (unit.type == UnitType("UNIT_WARRIOR")) { // if unit is obsolete
upgradeloc = unit.location;
KillUnit(unit); // kill obsolete unite
CreateUnit(player.1, UnitType("UNIT_SAMURAI"), upgradeloc, 0); // and create a replacement
} else { // if unit isn't obsolete
i = i + 1; // go to the next unit
}
}
}
Note that this code is untested, but in theory it should upgrade all Warriors to Samurai when Jurisprudence is invented. If you add similar triggers for all upgrades you'd like to see, it should work -- providing there are no unexpected bugs (I know in CtP2 there's a problem with advances obtained from goody huts, don't know how that works out in CtP1).
To add new triggers, simply copy the existing one and replace the 6 from "discovery.type == 6" with the appropriate number and UNIT_WARRIOR and UNIT_SAMURAI with the appropriate units. Oh, and make sure every trigger has a unique name ('UpgradeWarriorToSamurai' in this example: it can be anything, as long as it's unique).
Last edited by Locutus on 26-11-2003 at 14:06
|
|
|  |
 |
|  |
All times are GMT. The time now is 05:31. Apolyton Time is 00:31. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|