int_t AIR_TYPE[]; // Array to hold air unit DB values int_t LANDING_TYPE[]; // Array to hold valid landing sites //thanks to dale for the is airunit command HandleEvent(BeginTurn) 'MM2_AirGameStart' pre { AIR_TYPE[0] = UnitDB(UNIT_BOMBER); AIR_TYPE[1] = UnitDB(UNIT_CARGO_HELICOPTER); AIR_TYPE[2] = UnitDB(UNIT_FIGHTER); AIR_TYPE[3] = UnitDB(UNIT_INTERCEPTOR); AIR_TYPE[4] = UnitDB(UNIT_SPACE_PLANE); AIR_TYPE[5] = UnitDB(UNIT_SPY_PLANE); AIR_TYPE[6] = UnitDB(UNIT_STEALTH_BOMBER); AIR_TYPE[7] = UnitDB(UNIT_STEALTH_FIGHTER); AIR_TYPE[8] = UnitDB(UNIT_CRUISE_MISSILE); AIR_TYPE[9] = UnitDB(UNIT_NUKE); LANDING_TYPE[0] = UnitDB(UNIT_AIRCRAFT_CARRIER); LANDING_TYPE[1] = TerrainImprovementDB(TILEIMP_AIR_BASES); DisableTrigger('MM2_AirGameStart'); } /////////////////////////////////// // Check if air unit /////////////////////////////////// int_f MM2_IsAir(int_t theType) { int_t i; int_t typeOfUnit; typeOfUnit = theType; for (i = 0; i < AIR_TYPE.#; i = i + 1) { // for (i = 0; i < 8; i = i + 1) { if (typeOfUnit == AIR_TYPE[i]) { return 1; } } return 0; } /////////////////////////////////// // Check for landing unit /////////////////////////////////// int_f MM2_IsLandingUnit(location_t theLoc) { int_t i; int_t units; unit_t tmpland; location_t thesite; thesite = theLoc; units = GetUnitsAtLocation(thesite); if(units > 0) { for(i = 0; i < units; i = i + 1) { GetUnitFromCell(thesite, i, tmpland); if(tmpland.type == LANDING_TYPE[0]) { return 1; } } } if(TileHasImprovement(thesite, LANDING_TYPE[1])) { return 1; } return 0; } /////////////////////////////////// // Move Unit event /////////////////////////////////// HandleEvent(MoveOrder) 'MM2_AirMove' pre { int_t i; int_t j; int_t h; int_t x; int_t y; int_t numcities; int_t armycounter; city_t tmpcity; unit_t tmpUnit; army_t tmpArmy; army_t tmpArmy1; location_t tmploc; location_t tmploc1; location_t tmploc3; location_t tmploc4; location_t armyloc; if(ArmyIsValid(army[0])){ armycounter = 0; tmpArmy = army[0]; armyloc = tmpArmy.location; tmploc3 = armyloc; player[1] = g.player; for (i = 0; i < tmpArmy.size; i = i + 1) { GetUnitFromCell(armyloc, i, tmpUnit); if(MM2_IsAir(tmpUnit.type)) { numcities = PlayerCityCount(g.player);//player[1].cities; GetCityByIndex(g.player, 0, tmpcity); tmploc = tmpcity.location; for(h = 0; h < numcities; h = h + 1) { GetCityByIndex(g.player, h, tmpcity); tmploc1 = tmpcity.location; if(CityIsValid(tmpcity) && Distance(tmpUnit.location, tmploc1) < Distance(tmpUnit.location, tmploc)) { tmploc = tmploc1; } } for(j = 0; j < 10; j = j + 1) { GetNeighbor(tmploc3, 3, tmploc4); tmploc3 = tmploc4; } if(MM2_IsLandingUnit(tmploc3)) { if(Distance(tmpUnit.location, tmploc3) < Distance(tmpUnit.location, tmploc)) { tmploc = tmploc3; } } for(x = 0; x < 10; x = x + 1) { for(y = 0; y < 21; y = y + 1) { GetNeighbor(tmploc3, 2, tmploc4); tmploc3 = tmploc4; if(MM2_IsLandingUnit(tmploc3)) { if(Distance(tmpUnit.location, tmploc3) < Distance(tmpUnit.location, tmploc)) { tmploc = tmploc3; } } } GetNeighbor(tmploc3, 7, tmploc4); tmploc3 = tmploc4; if(MM2_IsLandingUnit(tmploc3)) { if(Distance(tmpUnit.location, tmploc3) < Distance(tmpUnit.location, tmploc)) { tmploc = tmploc3; } } for(y = 0; y < 21; y = y + 1) { GetNeighbor(tmploc3, 5, tmploc4); tmploc3 = tmploc4; if(MM2_IsLandingUnit(tmploc3)) { if(Distance(tmpUnit.location, tmploc3) < Distance(tmpUnit.location, tmploc)) { tmploc = tmploc3; } } } GetNeighbor(tmploc3, 7, tmploc4); tmploc3 = tmploc4; if(MM2_IsLandingUnit(tmploc3)) { if(Distance(tmpUnit.location, tmploc3) < Distance(tmpUnit.location, tmploc)) { tmploc = tmploc3; } } } if(armyloc != tmploc) { Event: UngroupOrder(tmpArmy); ClearOrders(tmpUnit); Event: AddUnitToArmy(tmpUnit, tmpArmy1, armycounter); armycounter = armycounter + 1; Event: MovePathOrder(tmpArmy1, tmploc); } } } } } HandleEvent(MoveUnits) 'blowthemhehellup' post { unit_t tmpunit; int_t u; int_t tmprand; int_T x; if(TileHasImprovement(location[1], TerrainImprovementDB(TILEIMP_exmines))) { for(u = 0; u < army[0].size; u = u + 1) {//479 GetUnitFromArmy(army[0], u, tmpunit); if(MM2_IsAir(tmpUnit.type)) { u = u; }else{ x = random(100); tmprand=random(tmpunit.hp ); DamageUnit(tmpunit, tmprand); if(x >= 90) { Event:CutImprovements(location[1]);//673 } } } } } HandleEvent(PillageOrder) 'stopthepillegofmines' pre { if(TileHasImprovement(army[0].location, TerrainImprovementDB(TILEIMP_exmines))) { return STOP; } } #include "SS_msg.slc"