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)));
}
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循环全部语句创建多组单位,此方法执行效率最低,应尽量少用
for(i=0; <= cNumberNonGaiaPlayers*3)
{
int goldID = rmCreateObjectDef("gold"+i); //由于不能出现相同的名称,所以for循环给名称加上循环值很重要,不然会导致只会生成一组单位。
rmAddObjectDefItem(goldID, "mine", 1, 0.0);
rmSetObjectDefMinDistance(goldID, rmXFractionToMeters(0.0));
//这里设定最大距离为rmXFractionToMeters(0.5),(从中心点0.5,0.5算起)即为全图
rmSetObjectDefMaxDistance(goldID, rmXFractionToMeters(0.5));
rmAddObjectDefToClass(goldID, classGold);
rmAddObjectDefConstraint(goldID, avoidGoldTypeFar); //矿场与矿场之间间隔45
rmPlaceObjectDefAtLoc(goldID, 0, 0.50, 0.50); //最后面没有设定数量,默认为1组
}
//假设cNumberNonGaiaPlayers=2,求最后循环的数量?
//你的回答是? 6? 7?
//正确答案是7,因为这里是i=0;所以本身就包括0,然后是1、2、3、4、5、6;合计等于7
//第二种:通过使用for循环最后一句“放置单位”来创建多组单位
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); //猎物与猎物间隔45
for(i=1; <= cNumberNonGaiaPlayers*3)
{
rmPlaceObjectDefAtLoc(CenterHerdID, 0, 0.50, 0.50); //只循环这一句,无需加循环值
}
//假设cNumberNonGaiaPlayers=2,求最后循环的数量?
//你的回答是? 6? 7?
//正确答案是6,因为这里是i=1;每次循环+1,第一次循环为1,最终结果是1、2、3、4、5、6
//第三种,直接在最后一句“放置单位”那里设定多组
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); //树木与树木间隔25
rmPlaceObjectDefAtLoc(GreenForestTreeObjectID, 0, 0.50, 0.50, cNumberNonGaiaPlayers*20);
rmSetStatusText("",0.50);//读取地图进度条
rmSetStatusText("",1.00);//读取地图进度条
//愿神兽会保佑你不会出错。
/*----------------------------------------------------------------------------------------------*
* ┏┓ ┏┓ *
* ┏┛┻━━━┛┻┓ *
* ┃ ┃ *
* ┃ ━ ┃ *
* ┃ ┳┛ ┗┳ ┃ *
* ┃ ┃ *
* ┃ ┻ ┃ *
* ┃ ┃ *
* ┗━┓ ┏━┛ Code is far away from bug with the animal protecting *
* ┃ ┃ *
* ┃ ┃ *
* ┃ ┃ *
* ┃ ┃ *
* ┃ ┃ *
* ┃ ┗━━━┓ *
* ┃ ┣┓ *
* ┃ ┏┛ *
* ┗┓┓┏━┳┓┏┛ *
* ┃┫┫ ┃┫┫ *
* ┗┻┛ ┗┻┛ *
*----------------------------------------------------------------------------------------------*/
} //END