int_f IsLandSettler(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if((MGUnit.type == UnitDB(UNIT_SETTLER) || MGUnit.type == UnitDB(UNIT_URBAN_PLANNER))) { return 1; } return 0; } int_f IsSeaSettler(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(MGUnit.type == UnitDB(UNIT_SEA_ENGINEER)) { return 1; } return 0; } int_f IsSeaTransporter(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(MGUnit.type == UnitDB(UNIT_CATAMARAN) || MGUnit.type == UnitDB(UNIT_COG) || MGUnit.type == UnitDB(UNIT_CORACLE) || MGUnit.type == UnitDB(UNIT_CRAWLER) || MGUnit.type == UnitDB(UNIT_PRIVATEER) || MGUnit.type == UnitDB(UNIT_TROOP_SHIP) || MGUnit.type == UnitDB(UNIT_BATTLESHIP) || MGUnit.type == UnitDB(UNIT_DESTROYER) || MGUnit.type == UnitDB(UNIT_FRIGATE) || MGUnit.type == UnitDB(UNIT_IRONCLAD) || MGUnit.type == UnitDB(UNIT_KRAKEN) || MGUnit.type == UnitDB(UNIT_LONGSHIP) || MGUnit.type == UnitDB(UNIT_SHIP_OF_THE_LINE) || MGUnit.type == UnitDB(UNIT_TRIREME) ) { return 1; } return 0; } int_f IsSpaceTransporter(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(MGUnit.type == UnitDB(UNIT_SPACE_PLANE)) { return 1; } return 0; } int_f IsAirTransporter(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(MGUnit.type == UnitDB(UNIT_CARGO_HELICOPTER)) { return 1; } return 0; } int_f IsRocketPlane(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(MGUnit.type == UnitDB(UNIT_BOMBER) || MGUnit.type == UnitDB(UNIT_JET_BOMBER) || MGUnit.type == UnitDB(UNIT_STEALTH_BOMBER) ) { return 1; } return 0; } int_f IsRocketShip(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(MGUnit.type == UnitDB(UNIT_DREADNAUGHT) || MGUnit.type == UnitDB(UNIT_NUCLEAR_SUBMARINE) || MGUnit.type == UnitDB(UNIT_MISSILE_CRUISER) || MGUnit.type == UnitDB(UNIT_MOREY_STRIKER) || MGUnit.type == UnitDB(UNIT_PLASMA_DESTROYER) || MGUnit.type == UnitDB(UNIT_SUBMARINE) ) { return 1; } return 0; } int_f IsAircraftCarrier(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(MGUnit.type == UnitDB(UNIT_AIRCRAFT_CARRIER)) { return 1; } return 0; } int_f IsRocketCarrier(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(IsRocketShip(MGUnit) || IsRocketPlane(MGUnit) ) { return 1; } return 0; } int_f IsRocket(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(MGUnit.type == UnitDB(UNIT_CRUISE_MISSILE) || MGUnit.type == UnitDB(UNIT_NUKE) ) { return 1; } return 0; } int_f IsSpecialUnit(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(MGUnit.type == UnitDB(UNIT_ABOLITIONIST) || MGUnit.type == UnitDB(UNIT_CLERIC) || MGUnit.type == UnitDB(UNIT_CORPORATE_BRANCH) || MGUnit.type == UnitDB(UNIT_CYBER_NINJA) || MGUnit.type == UnitDB(UNIT_DIPLOMAT) || MGUnit.type == UnitDB(UNIT_ECO_RANGER) || MGUnit.type == UnitDB(UNIT_ECO_TERRORIST) || MGUnit.type == UnitDB(UNIT_EMPATHIC_DIPLOMAT) || MGUnit.type == UnitDB(UNIT_INFECTOR) || MGUnit.type == UnitDB(UNIT_LAWYER) || MGUnit.type == UnitDB(UNIT_NOBLE) || MGUnit.type == UnitDB(UNIT_PARTISAN) || MGUnit.type == UnitDB(UNIT_SECRET_AGENT) || MGUnit.type == UnitDB(UNIT_SLAVER) || MGUnit.type == UnitDB(UNIT_SPY) || MGUnit.type == UnitDB(UNIT_TELEVANGELIST) ) { return 1; } return 0; } int_f IsNonAirTransporter(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(MGUnit.type == UnitDB(UNIT_ATTACK_HELICOPTER) || MGUnit.type == UnitDB(UNIT_DIVE_BOMBER) || MGUnit.type == UnitDB(UNIT_BRITISH_FIGHTER) || MGUnit.type == UnitDB(UNIT_INTERCEPTOR) || MGUnit.type == UnitDB(UNIT_SPY_PLANE) || MGUnit.type == UnitDB(UNIT_STEALTH_FIGHTER) ) { return 1; } return 0; } int_f IsNonSeaTransporter(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(MGUnit.type == UnitDB(UNIT_FIRE_TRIREME) || MGUnit.type == UnitDB(UNIT_MONITOR) || MGUnit.type == UnitDB(UNIT_PT_BOAT) ) { return 1; } return 0; } int_f IsSeaUnit(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(IsNonSeaTransporter(MGUnit) || IsRocketShip(MGUnit) || IsSeaTransporter(MGUnit) || IsSeaSettler(MGUnit) ) { return 1; } return 0; } int_f IsAirUnit(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(IsNonAirTransporter(MGUnit) || IsRocket(MGUnit) || IsRocketPlane(MGUnit) || IsAirTransporter(MGUnit) || IsSpaceTransporter(MGUnit) ) { return 1; } return 0; } int_f IsNonGroupLandUnit(unit_t theUnit) { unit_t MGUnit; MGUnit = theUnit; if(IsAirUnit(MGUnit) || IsSeaUnit(MGUnit) || IsSpecialUnit(MGUnit) || IsSeaSettler(MGUnit) || IsLandSettler(MGUnit) ) { return 1; } return 0; } int_f IsLand(location_t theLoc) { location_t MGLoc; MGLoc = theloc; if((TerrainType(MGLoc)<=9) ||((TerrainType(MGLoc)>=18) && (TerrainType(MGLoc)<=21)) ) { return 1; } return 0; } int_f TileHasLandRoad(location_t theLoc) { location_t MGLoc; MGLoc = theloc; return (TileHasImprovement(MGLoc, TerrainImprovementDB(TILEIMP_ROAD))//if neighbour tile has an improvement of class road || TileHasImprovement(MGLoc, TerrainImprovementDB(TILEIMP_RAILROAD)) || TileHasImprovement(MGLoc, TerrainImprovementDB(TILEIMP_MAGLEV)) ); } void_f MoveArmyToNeighbor(army_t theArmy, int_t IsLand, int_t HasCity, int_t HasLandRoad){ int_t k; int_t MGOwner; int_t MG_OK; int_t MGIsLand; int_t MGHasCity; int_t MGHasLandRoad; army_t MGArmy; unit_t MGUnit2; city_t MGCity; location_t MGLoc; MGArmy = theArmy; MGIsLand = IsLand; MGHasCity = HasCity; MGHasLandRoad = HasLandRoad; MG_OK = 0; for (k=0; k<=7 ; k=k+1) { //cycles thourgh the 8 directions GetNeighbor(MGArmy.location, k, MGLoc); //gets a neighbour tile of the city saved in MGCity in direction j if(UnitsInCell(MGLoc)>0) { GetUnitFromCell(MGLoc, 0, MGUnit2); MGOwner = MGUnit2.owner; } if(UnitsInCell(MGLoc)==0) { MGOwner = -1; } if((IsLand(MGLoc) == MGIsLand || MGIsLand == -1) && (TileHasLandRoad(MGLoc) == MGHasLandRoad || MGHasLandRoad == -1) && (GetCityByLocation(MGLoc, MGCity) == MGHasCity || MGHasCity == -1) && MG_OK == 0 &&(GetUnitsAtLocation(MGLoc)+MGArmy.size)<=12 && (MGArmy.owner == MGOwner || MGOwner == -1) ) { MG_OK = 1; //Event:MoveUnits(MGArmy, MGArmy.location, MGLoc); Event:MovePathOrder(MGArmy, MGLoc); } } } void_f MoveUnitToNeighbor(unit_t theUnit, int_t IsLand, int_t HasCity, int_t HasLandRoad){ int_t k; int_t MGOwner; int_t MG_OK; int_t MGIsLand; int_t MGHasCity; int_t MGHasLandRoad; army_t MGArmy; unit_t MGUnit; unit_t MGUnit2; city_t MGCity; location_t MGLoc; MGUnit = theUnit; MGIsLand = IsLand; MGHasCity = HasCity; MGHasLandRoad = HasLandRoad; GetArmyFromUnit(MGUnit, MGArmy); MG_OK = 0; for (k=0; k<=7 ; k=k+1) { //cycles thourgh the 8 directions GetNeighbor(MGUnit.location, k, MGLoc); //gets a neighbour tile of the city saved in MGCity in direction j if(UnitsInCell(MGLoc)>0) { GetUnitFromCell(MGLoc, 0, MGUnit2); MGOwner = MGUnit2.owner; } if(UnitsInCell(MGLoc)==0) { MGOwner = -1; } if((IsLand(MGLoc) == MGIsLand || MGIsLand == -1) && (TileHasLandRoad(MGLoc) == MGHasLandRoad || MGHasLandRoad == -1) && (GetCityByLocation(MGLoc, MGCity) == MGHasCity || MGHasCity == -1) && MG_OK == 0 && (GetUnitsAtLocation(MGLoc)+1)<=12 && (MGUnit.owner == MGOwner || MGOwner == -1) ) { MG_OK = 1; //Event:MovePathOrder(MGArmy, MGLoc); Event:MoveToOrder(MGArmy, k); } } } int_f IsLandSettlerInStack(army_t theArmy){ int_t i; army_t MGArmy; unit_t MGUnit; MGArmy = theArmy; for (i=0; i= 0; j = j - 1) { // GetUnitFromCell(MGArmy.location, j, MGUnit); // if(j==0) { // GetUnitFromArmy(MGArmy, 0, MGUnit2); // if(IsNonGroupLandUnit(MGUnit2)) { // MGUnitType = MGUnit2.type; // MGUnitOwner = MGUnit2.owner; // MGUnitLoc = MGUnit2.location; // Event:DisbandUnit(MGUnit2); // if(IsLandSettler(MGUnit) || IsSeaSettler(MGUnit)){ // if(!GetCityByLocation(MGUnit.location, MGCity)) { // CreateUnit(MGUnitOwner, MGUnitType, MGUnitLoc, 1, MGUnit3); // } // if(GetCityByLocation(MGUnit.location, MGCity)) { // AddPops(MGCity, 1); // } // } // if(!(IsLandSettler(MGUnit) || IsSeaSettler(MGUnit))) { // CreateUnit(MGUnitOwner, MGUnitType, MGUnitLoc, 1, MGUnit3); // } // } // } // if (IsNonGroupLandUnit(MGUnit)) { // Event:DisbandUnit(MGUnit); //if (TileHasLandRoad(MGUnit.location)&& !GetCityByLocation(MGUnit.location, MGCity)) { // MoveUnitToNeighbor(MGUnit, 1, 0, 0);//MoveUnitToNeighbor(theUnit, IsLand, HasCity, HasLandRoad) //} //unitrecord[5] = MGUnit.type;//no idea if I can figure out if a unit is damges // if (GetCityByLocation(MGUnit.location, MGCity)//if unit is in city //&& (UnitDB(unitrecord[5]).MaxHP >= MGUnit.hp)//no idea if this work, but finally it is not neccessary, I just leave this in for modmakes maybe another one can use it (if it works) // ) { // if(IsSeaUnit(MGUnit) // || IsSeaSettler(MGUnit) // ) { // MoveUnitToNeighbor(MGUnit, 0, 0, -1);//MoveUnitToNeighbor(theUnit, IsLand, HasCity, HasLandRoad) // }//the function above moves a unit to a neighbor land tile, without a city and no matter if it has a road // if (IsSpecialUnit(MGUnit) // || IsLandSettler(MGUnit) // ) { // MoveUnitToNeighbor(MGUnit, 1, 0, -1);//MoveUnitToNeighbor(theUnit, IsLand, HasCity, HasLandRoad) // }//the function above moves a unit to a neighbor sea tile, without a city and no matter if it has a road // } // j = j-1; //Event:AddUnitToArmy(MGUnit, MGArmy2, j); //Event:GroupUnitOrder(MGArmy2, MGUnit); // PlaySound("SOUND_ID_SCIFI_SCREEN"); // } //if (!IsNonGroupLandUnit(MGUnit)) { // ClearOrders(MGUnit); // Event:AddUnitToArmy(MGUnit, MGArmy, j); //} // } } int_f HasSeaTransporter(location_t theLoc){ int_t j; unit_t MGUnit; location_t MGLoc; MGLoc = theLoc; for(j = GetUnitsAtLocation(MGLoc)-1; j >= 0; j = j - 1) { GetUnitFromCell(MGLoc, j, MGUnit); if(IsSeaTransporter(MGUnit)) { return 1; } } return 0; } int_f NeighborHasSeaTransporter(location_t theLoc){ int_t k; int_t MGOK; location_t MGLoc; location_t MGLoc2; MGLoc = theLoc; MGOK = 0; for (k=0; k<=7 ; k=k+1) { //cycles thourgh the 8 directions GetNeighbor(MGLoc, k, MGLoc2); //gets a neighbour tile of the city saved in MGCity in direction j if(HasSeaTransporter(MGLoc2) && MGOK == 0) { MGOK = 1; return k; } } return 8; } void_f UnifyArmy(army_t theArmy){ int_t j; int_t MGOK; int_t MGTransportCount; army_t MGArmy; army_t MGArmy2; unit_t MGUnit; city_t MGCity; location_t MGLoc; MGArmy = theArmy; MGOK = 0; MGTransportCount = 1; //if(IsGroupLandUnitInStack(MGArmy) //&& IsNonGroupLandUnitInStack(MGArmy) //){ // Event:UngroupOrder(MGArmy); //if(GetNonGroupLandUnitsAtLocation(MGArmy.location) > 0 //&& GetGroupLandUnitsAtLocation(MGArmy.location) > 0 //){ for(j = GetUnitsAtLocation(MGArmy.location)-1; j >= 0; j = j - 1) { GetUnitFromCell(MGArmy.location, j, MGUnit); //if(NeighborHasSeaTransporter(MGUnit.location)>0 &&(MGTransportCount > 0)) { // GetArmyFromUnit(MGUnit, MGArmy2); // army[5] = MGArmy2;//.location;//MGArmy2.location // Event:MoveToOrder(MGArmy2, NeighborHasSeaTransporter(army[5].location)); // MGTransportCount = MGTransportCount - 1; //} if(!IsNonGroupLandUnit(MGUnit) && !IsSlaver(MGUnit) && !GetCityByLocation(MGUnit.location, MGCity) ) { if(MGOK == 0) { MGOK = 1; GetArmyFromUnit(MGUnit, MGArmy2); } ClearOrders(MGUnit); Event:AddUnitToArmy(MGUnit, MGArmy2, j); } if(!IsNonGroupLandUnit(MGUnit) && !IsSlaver(MGUnit) && GetCityByLocation(MGUnit.location, MGCity) && j < 9 ) { if(MGOK == 0) { MGOK = 1; GetArmyFromUnit(MGUnit, MGArmy2); } ClearOrders(MGUnit); Event:AddUnitToArmy(MGUnit, MGArmy2, j); } if(IsNonGroupLandUnit(MGUnit) //&& GetGroupLandUnitsAtLocation(MGArmy.location) > 0 ) { // Event:DisbandUnit(MGUnit); //if (TileHasLandRoad(MGUnit.location)&& !GetCityByLocation(MGUnit.location, MGCity)) { // MoveUnitToNeighbor(MGUnit, 1, 0, 0);//MoveUnitToNeighbor(theUnit, IsLand, HasCity, HasLandRoad) //} //unitrecord[5] = MGUnit.type;//no idea if I can figure out if a unit is damges if (GetCityByLocation(MGUnit.location, MGCity)//if unit is in city //&& (UnitDB(unitrecord[5]).MaxHP >= MGUnit.hp)//no idea if this work, but finally it is not neccessary, I just leave this in for modmakes maybe another one can use it (if it works) ) { //GetCurrentPollutionLevel(MGCity); if(IsSeaUnit(MGUnit) || IsSeaSettler(MGUnit) ) { MoveUnitToNeighbor(MGUnit, 0, 0, -1);//MoveUnitToNeighbor(theUnit, IsLand, HasCity, HasLandRoad) }//the function above moves a unit to a neighbor land tile, without a city and no matter if it has a road if (IsSpecialUnit(MGUnit) || IsLandSettler(MGUnit) ) { MoveUnitToNeighbor(MGUnit, 1, 0, -1);//MoveUnitToNeighbor(theUnit, IsLand, HasCity, HasLandRoad) }//the function above moves a unit to a neighbor sea tile, without a city and no matter if it has a road } // j = j-1; //Event:AddUnitToArmy(MGUnit, MGArmy2, j); // Event:GroupUnitOrder(MGArmy2, MGUnit); // PlaySound("SOUND_ID_SCIFI_SCREEN"); // } } } } HandleEvent(GrantAdvance)'MG_RoadsAroundCities' post { int_t i; int_t j; int_t MGTileImp; city_t MGCity; location_t MGLoc; player[0] = g.player; if(!(IsHumanPlayer(player[0]))&& HasAdvance(player[0], ID_ADVANCE_WHEEL)){ //checks if player is AI and if player has Wheel if ((HasAdvance(player[0], ID_ADVANCE_TRADE)) && (!HasAdvance(player[0], ID_ADVANCE_RAILROAD)) && (!HasAdvance(player[0], ID_ADVANCE_HT_SUPERCONDUCTOR))) { //checks if player has Wheel, hasn't Railroad and hasn't HT Superconductor MGTileImp = TerrainImprovementDB(TILEIMP_ROAD); //If condition above is true than: Gets DB index from TILEIMP_ROAD and saves it into MGTileImp } elseif ((HasAdvance(player[0], ID_ADVANCE_WHEEL)) && (HasAdvance(player[0], ID_ADVANCE_RAILROAD)) && (!HasAdvance(player[0], ID_ADVANCE_HT_SUPERCONDUCTOR))) { //checks if player has Wheel, has Railroad and hasn't HT Superconductor MGTileImp = TerrainImprovementDB(TILEIMP_RAILROAD); //If condition above is true than: Gets DB index from TILEIMP_RAILROAD and saves it into MGTileImp } elseif ((HasAdvance(player[0], ID_ADVANCE_WHEEL)) && (HasAdvance(player[0], ID_ADVANCE_RAILROAD)) && (HasAdvance(player[0], ID_ADVANCE_HT_SUPERCONDUCTOR))) { //checks if player has Wheel, has Railroad and has HT Superconductor MGTileImp = TerrainImprovementDB(TILEIMP_MAGLEV); //If condition above is true than: Gets DB index from TILEIMP_MAGLEV and saves it into MGTileImp } for(i = 0; i < player[0].cities; i = i + 1) { //cycles through all cities for city with index i = 0 up to the last index GetCityByIndex(player[0], i, MGCity); //Get city with index i and saves it to the variable MGCity if(CityIsValid(MGCity)) { //checks if the city still exists and continues if the city is still valid for (j=0; j<=7 ; j=j+1) { //cycles thourgh the 8 directions GetNeighbor(MGCity.location, j, MGLoc); //gets a neighbour tile of the city saved in MGCity in direction j if ((CellOwner(MGLoc)==MGCity.owner)&&((j==1)||(j==3)||(j==4)||(j==6))&&(!TileHasImprovement(MGLoc, MGTileImp))) { //if the neighbour tile lies Northwest, Northeast, Southwest or Southeast of the city and the tile hasn't a tile improvement of type saved in MGTileImp the following line will be executed Event:CreateImprovement(MGCity.owner,MGLoc, MGTileImp,0 ); //creates road, railroad or maglev on tile saved in MGLoc } } } } } } HandleEvent(EntrenchOrder)'MG_DoNotSleepOnTheRoad' pre { int_t i; int_t j; int_t MG_OK; location_t MGLoc; army_t MGArmy; unit_t MGUnit; city_t MGCity; MG_OK = 0; if(!IsHumanPlayer(g.player)) { MGLoc = army[0].location; if( //(TileHasImprovement(army[0].location, TerrainImprovementDB(TILEIMP_ROAD))//if neighbour tile has an improvement of class road //|| TileHasImprovement(army[0].location, TerrainImprovementDB(TILEIMP_RAILROAD)) //|| TileHasImprovement(army[0].location, TerrainImprovementDB(TILEIMP_MAGLEV))) TileHasLandRoad(MGLoc)//the odd thing is that the game crashed with army[0].location &&(!GetCityByLocation(army[0].location, MGCity))) { Event:DetrenchOrder(army[0]); MoveArmyToNeighbor(army[0], 1, 0, 0);//MoveArmyToNeighbor(theArmy, IsLand, HasCity, HasLandRoad) } } } //HandleEvent(BeginTurn)'MG_MoveArmy' pre { //int_t i; //army_t MGArmy; // if (!IsHumanPlayer(g.player)) { // for (i=0; i