include "mercenaries.xs";
include "ypAsianInclude.xs";
include "ypKOTHInclude.xs";
void main(void)
{
// ---------------------------------------- Map Info -------------------------------------------
int playerTilesX=13200; //设定地图X大小
int playerTilesZ=13200; //设定地图Z大小(帝国3的Y是高度,Z才是我们平常所用到的Y)
//如果玩家大于4将playerTilesX与playerTilesZ改为11500(同一个值的int只能出现1次,当你需要修改数值的时候,不能再加入int)
if (cNumberNonGaiaPlayers >4){ playerTilesX=11500; playerTilesZ=11500;}
if (cNumberNonGaiaPlayers >6){ playerTilesX=10500; playerTilesZ=10500;} //Modify Map X&Z Size of 6,7,8 Player
int SizeX = 2*sqrt(cNumberNonGaiaPlayers*playerTilesX);
int SizeZ = 2*sqrt(cNumberNonGaiaPlayers*playerTilesZ);
string MapTerrain ="Carolinas\ground_marsh3_car"; //<-------- 地图地形,自己参照剧情编辑器 <--------
string MapLighting ="319a_Snow"; //<-------- 照明,自己参照剧情编辑器 <--------
string PlayerTerrain ="Carolinas\ground_marsh1_car"; //<--------- 玩家范围地形 <---------
//设定地图XZ大小,分别调用上面用int定义的SizeX与SizeZ,即为rmSetMapSize(13200,13200);如果玩家大于4将改为11500
rmSetMapSize(SizeX, SizeZ);
rmSetMapElevationParameters(cElevTurbulence, 0.15, 2.5, 0.35, 3.0); // type, frequency, octaves, persistence, variation
rmSetMapElevationHeightBlend(1.0);
//地形初始化,设定地图初始地形,调用上面用string定义MapTerrain,即为"Carolinas\ground_marsh3_car";
rmTerrainInitialize(MapTerrain,6);
//设定照明,调用上面用string定义MapLighting,即为"319a_Snow"
rmSetLightingSet(MapLighting);
rmSetGlobalRain(0.9); //设定下雨
chooseMercs();
rmSetMapType("yucatan");
rmSetMapType("water");
rmSetMapType("default"); //设定地图类型,地图类型影响到宝藏
rmSetMapType("land");
rmSetMapType("bayou");
rmSetSeaLevel(0); // this is height of river surface compared to surrounding land. River depth is in the river XML.
rmSetStatusText("",0.01);//读取地图进度条
//定义class
int classStartingResource = rmDefineClass("startingResource"); //这个用作开局城镇资源
int PlayerHerd2Class = rmDefineClass("PlayerHerd2C"); //这个用作玩家第二肉群
int classGold = rmDefineClass("Gold"); //这个用作矿场
//定义放置限制/规则【顺便说一句,如果存在两个相同限制/规则名称(不是说int后面那个,如果int出现两个相同你连地图都无法打开,我说的是带英文双引号那个""),只会执行第一个,另一个会失效,甚至会引发毁图效果】
int avoidGold = rmCreateClassDistanceConstraint ("avoid gold", rmClassID("Gold"), 50.0);
int avoidPlayerHerd2Far = rmCreateClassDistanceConstraint("avoid Player Herd2 far", rmClassID("PlayerHerd2C"), 52.0);
int avoidStartingResources = rmCreateClassDistanceConstraint("start resources avoid each other2", rmClassID("startingResource"), 4.0);
//与所有带有gold标签的单位最小间隔距离为45
int avoidGoldTypeFar = rmCreateTypeDistanceConstraint("coin avoids coin far ", "gold", 45.0);
//与所有带有herd标签的单位最小间隔距离为45
int avoidHerdTypeFar = rmCreateTypeDistanceConstraint("herd avoids herd far", "herd", 45.0);
//与所有带有Tree标签的单位最小间隔距离为25
int avoidTreeType = rmCreateTypeDistanceConstraint("Tree avoids Tree ", "Tree", 25.0);
rmPlacePlayersCircular(0.35, 0.35, 0.0); //圆形放置玩家
//玩家范围
float AreaSizePlayer = rmAreaTilesToFraction(700);
for(i=1; <=cNumberNonGaiaPlayers)
{
int id=rmCreateArea("Player"+i);
rmSetPlayerArea(i, id);
rmSetAreaWarnFailure(id, false);
rmSetAreaSize(id, AreaSizePlayer, AreaSizePlayer);
rmSetAreaLocPlayer(id, i);
rmSetAreaCoherence(id, 0.85);
rmSetAreaSmoothDistance(id, 2);
rmSetAreaMinBlobs(id, 1);
rmSetAreaMaxBlobs(id, 1);
rmSetAreaTerrainType(id,PlayerTerrain);
rmBuildArea(id);
}
//定义城镇中心
int TownCenterID = rmCreateObjectDef("player TC");
if (rmGetNomadStart())
{
rmAddObjectDefItem(TownCenterID, "CoveredWagon", 1, 0.0);
}
else
{
rmAddObjectDefItem(TownCenterID, "TownCenter", 1, 0);
}
rmSetObjectDefMinDistance(TownCenterID, 0.0);
rmSetObjectDefMaxDistance(TownCenterID, 20.0);
for(i=1; <=cNumberNonGaiaPlayers)
{
rmPlaceObjectDefAtLoc(TownCenterID, i, rmPlayerLocXFraction(i), rmPlayerLocZFraction(i));
}
//定义起始单位(civs.xml定义那些开局单位)
int startingUnits = rmCreateStartingUnitsObjectDef(5.0);
rmSetObjectDefMinDistance(startingUnits, 6.0);
rmSetObjectDefMaxDistance(startingUnits, 10.0);
int playerherdID = rmCreateObjectDef("starting herd");
rmAddObjectDefItem(playerherdID, "ypWildElephant", 10, 6.0);
rmSetObjectDefMinDistance(playerherdID, 8.0);
rmSetObjectDefMaxDistance(playerherdID, 12.0);
rmSetObjectDefCreateHerd(playerherdID, true);
rmAddObjectDefToClass(playerherdID, classStartingResource);
rmAddObjectDefConstraint(playerherdID, avoidStartingResources);
int playergoldID = rmCreateObjectDef("player mine");
rmAddObjectDefItem(playergoldID, "Minegold", 1, 6);
rmSetObjectDefMinDistance(playergoldID, 18.0);
rmSetObjectDefMaxDistance(playergoldID, 22.0);
rmAddObjectDefToClass(playergoldID, rmDefineClass("startingResource"));
rmAddObjectDefToClass(playergoldID, classGold);
rmAddObjectDefConstraint(playergoldID, avoidStartingResources);
string PlayerTreeType ="TreeRedwood";
int PlayerTreeCount = 8;
int playerTree1ID = rmCreateObjectDef("player trees");
rmAddObjectDefItem(playerTree1ID, PlayerTreeType, PlayerTreeCount, 8.0);
rmSetObjectDefMinDistance(playerTree1ID, 6);
rmSetObjectDefMaxDistance(playerTree1ID, 12);
rmAddObjectDefToClass(playerTree1ID, classStartingResource);
rmAddObjectDefConstraint(playerTree1ID, avoidStartingResources);
int playerBerryID=rmCreateObjectDef("player berries");
rmAddObjectDefItem(playerBerryID, "BerryBush", rmRandInt(3,4), 3.0);
rmSetObjectDefMinDistance(playerBerryID, 12);
rmSetObjectDefMaxDistance(playerBerryID, 14);
rmAddObjectDefToClass(playerBerryID, classStartingResource);
rmAddObjectDefConstraint(playerBerryID, avoidStartingResources);
int playerHerd2ID = rmCreateObjectDef("player Herd2");
rmAddObjectDefItem(playerHerd2ID, "Bison", rmRandInt(10,11), 10.0);
rmSetObjectDefMinDistance(playerHerd2ID, 36);
rmSetObjectDefMaxDistance(playerHerd2ID, 38);
rmSetObjectDefCreateHerd(playerHerd2ID, true);
rmAddObjectDefToClass(playerHerd2ID, PlayerHerd2Class);
int playerHerd3ID = rmCreateObjectDef("player Herd3");
rmAddObjectDefItem(playerHerd3ID, "Turkey", rmRandInt(8,9), 8.0);
rmSetObjectDefMinDistance(playerHerd3ID, 40);
rmSetObjectDefMaxDistance(playerHerd3ID, 42);
rmSetObjectDefCreateHerd(playerHerd3ID, true);
rmAddObjectDefConstraint(playerHerd3ID, avoidPlayerHerd2Far);
int playergold2ID = rmCreateObjectDef("player second mine");
rmAddObjectDefItem(playergold2ID, "mine", 1, 0);
rmSetObjectDefMinDistance(playergold2ID, 58.0);
rmSetObjectDefMaxDistance(playergold2ID, 62.0);
rmAddObjectDefToClass(playergold2ID, classGold);
rmAddObjectDefConstraint(playergold2ID, avoidGold);
int playergold3ID = rmCreateObjectDef("player third mine");
rmAddObjectDefItem(playergold3ID, "mine", 1, 0);
rmSetObjectDefMinDistance(playergold3ID, 68.0);
rmSetObjectDefMaxDistance(playergold3ID, 70.0);
rmAddObjectDefToClass(playergold3ID, classGold);
rmAddObjectDefConstraint(playergold3ID, avoidGold);
for(i=1; <=cNumberNonGaiaPlayers)
{
vector TCLocation = rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TownCenterID, i));
rmPlaceObjectDefAtLoc(startingUnits, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(playerherdID, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(playerTree1ID, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(playergoldID, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(playerBerryID, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(playerHerd2ID, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(playerHerd3ID, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(playergold2ID, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(playergold3ID, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
}
//其实就是在放置金矿、树木、猎物之前先把群组放置了
//所有土著部落不是给了1、2、3、4、5合计5个群组吗,所以我们可以在string名称后面加上那个数字,再搞个随机数,那么就不会一成不变了,另外注意一下群组名称的空格,必须100%对应,你少一个空格都创建不了(village后面、英文双引号前面有个空格,看见没?)。
int NativeCenterID = rmCreateGrouping("Native Center ID", "native aztec village "+rmRandInt(rmRandInt(1,2),rmRandInt(3,rmRandInt(4,5))));
rmSetGroupingMinDistance(NativeCenterID, 0.0);
rmSetGroupingMaxDistance(NativeCenterID, rmXFractionToMeters(0.0));
rmAddGroupingToClass(NativeCenterID, rmDefineClass("natives"));
rmPlaceGroupingAtLoc(NativeCenterID, 0,0.50,0.50);
int FixedGunID = rmCreateObjectDef("FixedGun");
rmAddObjectDefItem(FixedGunID, "SPCFixedGun",1,5.0);
rmSetObjectDefMinDistance(FixedGunID,0.0);
rmSetObjectDefMaxDistance(FixedGunID,30.0);
rmPlaceObjectDefAtLoc(FixedGunID,0,0.50,0.50,1);
for(i=0; <= cNumberNonGaiaPlayers*3)
{
int goldID = rmCreateObjectDef("gold"+i);
rmAddObjectDefItem(goldID, "mine", 1, 0.0);
rmSetObjectDefMinDistance(goldID, rmXFractionToMeters(0.0));
rmSetObjectDefMaxDistance(goldID, rmXFractionToMeters(0.5));
rmAddObjectDefToClass(goldID, classGold);
rmAddObjectDefConstraint(goldID, avoidGoldTypeFar);
rmPlaceObjectDefAtLoc(goldID, 0, 0.50, 0.50);
}
int CenterHerdID = rmCreateObjectDef("Center Herd2");
rmAddObjectDefItem(CenterHerdID, "BighornSheep",10, 8.0);
rmSetObjectDefMinDistance(CenterHerdID, rmXFractionToMeters(0.0));
rmSetObjectDefMaxDistance(CenterHerdID, rmXFractionToMeters(0.45));
rmSetObjectDefCreateHerd(CenterHerdID, true);
rmAddObjectDefConstraint(CenterHerdID, avoidHerdTypeFar);
for(i=1; <= cNumberNonGaiaPlayers*3)
{
rmPlaceObjectDefAtLoc(CenterHerdID, 0, 0.50, 0.50);
}
int GreenForestTreeObjectID = rmCreateObjectDef("Object Green forest trees");
rmAddObjectDefItem(GreenForestTreeObjectID, "TreeRedwood", 8, 15);
rmAddObjectDefItem(GreenForestTreeObjectID, "TreeRedwood", 3, 5);
rmAddObjectDefItem(GreenForestTreeObjectID, "UnderbrushCalifornia", 3, 10);
rmSetObjectDefMinDistance(GreenForestTreeObjectID, rmXFractionToMeters(0.0));
rmSetObjectDefMaxDistance(GreenForestTreeObjectID, rmXFractionToMeters(0.47));
rmAddObjectDefConstraint(GreenForestTreeObjectID, avoidTreeType);
rmPlaceObjectDefAtLoc(GreenForestTreeObjectID, 0, 0.50, 0.50, cNumberNonGaiaPlayers*20);
rmSetStatusText("",0.50);//读取地图进度条
//这几个土著在最后面放置:但是设定最大距离为rmXFractionToMeters(0.5),即为全图,变成从中心点开始,然后根据放置限制的设定随机放置土著,跟随机放置资源是一样的
//将土著加入Class就能让土著避开土著了,设定必须距离Class“natives”最小间隔52。
int avoidNative = rmCreateClassDistanceConstraint("avoid Native", rmClassID("natives"), 52.0);
//再重新设定与矿场、树木的最小间隔距离
int avoidGoldTypeMin = rmCreateTypeDistanceConstraint("coin avoids coin Min", "gold", 15.0);
int avoidTreeTypeMin = rmCreateTypeDistanceConstraint("Tree avoids Min", "Tree", 15.0);
int NativeCenter2ID = rmCreateGrouping("Native Center ID", "native aztec village "+rmRandInt(rmRandInt(1,2),rmRandInt(3,rmRandInt(4,5))));
rmSetGroupingMinDistance(NativeCenter2ID, 0.0);
rmSetGroupingMaxDistance(NativeCenter2ID, rmXFractionToMeters(0.5)); //从中心点算起,rmXFractionToMeters(0.5)为全图范围
//加入到Class“natives”,你回去上面看一下,第一个土著也加入natives这个class。
rmAddGroupingToClass(NativeCenter2ID, rmDefineClass("natives"));
rmAddGroupingConstraint(NativeCenter2ID, avoidNative);
rmAddGroupingConstraint(NativeCenter2ID, avoidGoldTypeMin);
rmAddGroupingConstraint(NativeCenter2ID, avoidTreeTypeMin);
rmPlaceGroupingAtLoc(NativeCenter2ID, 0,0.50,0.50,3); //放置3个土著
rmSetStatusText("",1.00);//读取地图进度条
//愿神兽会保佑你不会出错。
/*----------------------------------------------------------------------------------------------*
* ┏┓ ┏┓ *
* ┏┛┻━━━┛┻┓ *
* ┃ ┃ *
* ┃ ━ ┃ *
* ┃ ┳┛ ┗┳ ┃ *
* ┃ ┃ *
* ┃ ┻ ┃ *
* ┃ ┃ *
* ┗━┓ ┏━┛ Code is far away from bug with the animal protecting *
* ┃ ┃ *
* ┃ ┃ *
* ┃ ┃ *
* ┃ ┃ *
* ┃ ┃ *
* ┃ ┗━━━┓ *
* ┃ ┣┓ *
* ┃ ┏┛ *
* ┗┓┓┏━┳┓┏┛ *
* ┃┫┫ ┃┫┫ *
* ┗┻┛ ┗┻┛ *
*----------------------------------------------------------------------------------------------*/
} //END