D'oh, Pedrunn! If I had been able to follow this discussion more closely I could have told you ages ago how the CreateUnit event works. You don't really need the unit variable, it has no real value there (although it couldn't have hurt, I agree)! You should use the integers to find out if the unit is a Settler or similar, as I did in the old version of the Militia code:
Code:
// if a settler type unit is built, update # of Militia units if needed HandleEvent(CreateUnit) 'MM2_MilitiaSettlerBuilt' post { // triggers if a unit is created city_t tmpCity; int_t tmpValue; tmpValue = value[0]; tmpCity = city[0]; if (CityIsValid(tmpCity)) { // and it was created from a city (no valid city means unit was created from ruin FE) if (tmpValue == UnitDB(UNIT_SETTLER) || tmpValue == UnitDB(UNIT_URBAN_PLANNER) || tmpValue == UnitDB(UNIT_SEA_ENGINEER)) { // and if unit is settler unit if (tmpCity.population > 0) { // and the city still exists (again not sure if needed) MM2_TryMilitia(tmpCity.population, tmpCity); // update Militias if needed } } } }
Comment