//=================================================================== // THIS STUFF CAN, OR PERHAPS EVEN SHOULD GO IN THE TOP OF THE MAIN // LOTR SLIC FILE. //=================================================================== int_t HumanIsGondor; int_t HumanIsMordor; void_f GetHumanCiv() { int_t i; HumanIsMordor=0; HumanIsGondor=0; for(i = 0; i < preference("numplayers"); i = i + 1){ if(IsHumanPlayer(i) && PlayerCivilization(i) == CivilizationIndex("GONDOR")){ HumanIsGondor=1; } elseif (IsHumanPlayer(i) && PlayerCivilization(i) == CivilizationIndex("MORDOR")){ HumanIsMordor=1; } } } HandleEvent(BeginTurn) 'LOTR_civsetup' pre{ GetHumanCiv(); DisableTrigger('LOTR_civsetup'); } //=================================================================== //=================================================================== // THIS IS COPIED FROM THE MILITIA CODING, AND SHOULD PREVENT // THE AI FROM MOVING CERTAIN UNITS. //=================================================================== // // This could well be too complex, but it should cover all bases // If its too much, simply change the names from place to place, or // delete bits entirely // int_f LOTR_IsZeroMovementUnit(int_t type) { // IMMOBILE MORDOR UNITS WHEN NOT HUMAN-CONTROLLED if(type == UnitDB(UNIT_SAURON) || type == UnitDB(UNIT_CATAPHRACT) || type == UnitDB(UNIT_DEF_ORCS) || type == UnitDB(UNIT_DEF_TROLLS) || type == UnitDB(UNIT_DEF_ARCHER_MO) ){ if(HumanIsGondor){ return 1; } else { return 0; } } // IMMOBILE GONDOR UNITS WHEN NOT HUMAN-CONTROLLED elseif(type == UnitDB(UNIT_DENETHOR) || type == UnitDB(UNIT_ELROND) || type == UnitDB(UNIT_GALADRIAL) ){ if(HumanIsMordor){ return 1; } else { return 0; } } // IMMOBILE UNITS ALL THE TIME elseif(type == UnitDB(UNIT_HURRICANE) || type == UnitDB(UNIT_SHELOB) || type == UnitDB(UNIT_BALROG) || type == UnitDB(UNIT_WATCHER) || type == UnitDB(UNIT_MOUTHPIECE_OF_SAURON) || type == UnitDB(UNIT_MILITIA_I) || type == UnitDB(UNIT_MILITIA_II) || type == UnitDB(UNIT_SAURUMAN)){ return 1; } else { return 0; } } // prevent 0m units from moving through numpad commands HandleEvent(MoveToOrder) 'LOTR_MilitiaMoveNumpad' pre { // triggers right before an army moves int_t i; unit_t tmpUnit; army_t tmpArmy; tmpArmy = army[0]; for (i = 0; i < tmpArmy.size; i = i + 1) { // cycle through all units in this army GetUnitFromArmy(tmpArmy, i, tmpUnit); if (LOTR_IsZeroMovementUnit(tmpUnit.type)) { // if any of the units in this army is a Militia return STOP; // don't allow army to move } } } // prevent 0m units from moving // bug fixed: MoveUnits changed to MoveOrder, prevents ZOC problems HandleEvent(MoveOrder) 'LOTR_MilitiaMove' pre { // triggers right before an army moves int_t i; unit_t tmpUnit; army_t tmpArmy; tmpArmy = army[0]; for (i = 0; i < tmpArmy.size; i = i + 1) { // cycle through all units in this army GetUnitFromArmy(tmpArmy, i, tmpUnit); if (LOTR_IsZeroMovementUnit(tmpUnit.type)) { // if any of the units in this army is a Militia return STOP; // don't allow army to move } } } // prevent 0m units from boarding a transport HandleEvent(MoveIntoTransport) 'LOTR_MilitiaBoard' pre { // triggers right before an army boards a transport int_t j; unit_t tmpUnit2; army_t tmpArmy2; tmpArmy2 = army[0]; for (j = 0; j < tmpArmy2.size; j = j + 1) { // cycle through all units in this army GetUnitFromArmy(tmpArmy2, j, tmpUnit2); if (LOTR_IsZeroMovementUnit(tmpUnit2.type)) { // if any of the units in this army is a Militia return STOP; // don't allow army to board } } } // prevent 0m units from attacking HandleEvent(Battle) 'LOTR_MilitiaBattle' pre { // triggers right before a battle takes place int_t k; unit_t tmpUnit3; army_t tmpArmy3; tmpArmy3 = army[0]; // look at the attacking army for (k = 0; k < tmpArmy3.size; k = k + 1) { // cycle through all units in this army GetUnitFromArmy(tmpArmy3, k, tmpUnit3); if (LOTR_IsZeroMovementUnit(tmpUnit3.type)) { // if any of the units in this army is a Militia return STOP; // don't allow army to attack } } } // prevent 0m units from sleeping - just in case it boards a transport this way (note to self: check if really needed) HandleEvent(SleepUnit) 'LOTR_MilitiaSleep' pre { // triggers right before a unit sleeps unit_t tmpUnit4; tmpUnit4 = unit[0]; if (LOTR_IsZeroMovementUnit(tmpUnit4.type)) { // if the unit is a Militia return STOP; // don't allow it to sleep } }