rmRandInt(10,20); //随机返回其中一个数值,50%几率。例如返回20
rmRandInt(1,2); //随机返回其中一个数值,50%几率。例如返回1
rmRandFloat(0,5); //随机返回范围内一个数值,例如返回3.25(完全随机)
rmRandFloat(30,70); //随机返回范围内一个数值,例如返回50.11(完全随机)/*帝国3命令:
[( )] rmRandInt(int min, int max): Returns a random integer between min and max.
[( )] rmRandFloat(float min, float max): Returns a random float between min and max.
*/
这个是设定地图大小:
int playerTiles = 12500; //定义定义playerTiles=12500
if(cNumberNonGaiaPlayers >4) playerTiles = 11500; //如果玩家人数大于4,改变playerTiles为11500(在这之前必须先用int定义playerTiles)。
if (cNumberNonGaiaPlayers >6) playerTiles = 10500; //如果玩家人数大于6,改变playerTiles为10500。//重点来了,帝国3地图设定大小命令:[( )] rmSetMapSize( int x, int z ): Sets the size of the map.
rmSetMapSize((2*sqrt(cNumberNonGaiaPlayers*playerTiles)), (2*sqrt(cNumberNonGaiaPlayers*playerTiles)));
//设定地图X大小为2×√(玩家人数×playerTiles),Z为2×√(玩家人数×playerTiles)//sqrt的全称是Square Root Calculations,一个非负实数的平方根。这是帝国3的sqrt命令:[( )] sqrt(float x): Returns the square root of x.
这个是设定河流、湖、海平面等高度:
rmSetSeaLevel(-6.0); // this is height of river surface compared to surrounding land. River depth is in the river XML.不用我说了吧,自己把-6修改成其他。
rmSetSubCiv(0, "Shaolin");//定义subCiv0 = Shaolin土著,只有定义了Shaolin才能建造少林寺贸易站
rmSetSubCiv(1, "Zen");//定义subCiv1 = Zen土著,只有定义了Zen才能建造禅宗贸易站
rmSetSubCiv(2, "Jesuit");//定义subCiv2 = Jesuit土著,只有定义了Jesuit才能建造耶稣会贸易站//帝国3命令:[( )] rmSetSubCiv(int index, string civName, bool big) : Sets a given sub civ in the world.//命令表是这样写的,但是我也不知道第三个bool big有什么用。另外,留意一下string civName,你看见string没有?说明第二个值必须加引号,否则会出错。
定义规则
int AVTC=rmCreateTypeDistanceConstraint("LALLTOTC", "TownCenter", 30.0);//定义AVTC规则,距离地图上以生成TownCenter的大于等于30。//帝国3命令:[(int )] rmCreateTypeDistanceConstraint(string name, int classID, float distance): Make a type distance constraint.//第一个string name是规则名称,要加双引号,而且不能出现相同的规则名称,虽然不会导致出错,但是会导致后面与这个名称相同的规则失效。
//第二个int classID可以直接加上双引号,然后写上单位标签或调用名;也可以使用rmClassID("XXXXX")在这之前你必须先用rmDefineClass("")把XXXXX定义了,否者无效,例如:int ABCD = rmDefineClass("XXXXX");,然后调用这个规则时,会避开有rmClassID("XXXXX")的设定【依然是距离大于或等于rmClassID("XXXXX")某个数值(特意用上某个数值这个词,其实就是第三个float distance)】;你必须使用rmAddAreaToClass将classID添加到生成单位、地形、河流等设定中。这样才会避开带有这个class的设定。看不懂?地图就是这么乱七八糟的,基本上无法解释清楚的,只能靠你自己编辑地图去理解。你自己在一些地图搜索一下Class应该就会懂了。//第三个float distance就是距离,没什么好说的。/*
(知识扩展)帝国3命令:
[(int )] rmDefineClass(string className): Define a class with the given name.
[( )] rmClassID(string name): Gets class ID for given class name.
[(bool )] rmAddAreaToClass(int areaID, int classID): Add given area to specified class.
*/
int HerdTaiwanID = rmCreateObjectDef("HerdTaiwan");
rmAddObjectDefItem(HerdTaiwanID, "ypGiantSalamander", 5, 8.0);
rmSetObjectDefMinDistance(HerdTaiwanID, 0.0);
rmSetObjectDefMaxDistance(HerdTaiwanID, rmXFractionToMeters(0.05));
rmSetObjectDefCreateHerd(HerdTaiwanID, true);
rmPlaceObjectDefAtLoc(HerdTaiwanID, 0, 0.46, 0.11, 1);
与上面的差不多,不过多了一个rmSetObjectDefCreateHerd(HerdTaiwanID, true);,这个是用来定义猎物被打猎或者受到伤害会跑。
另外还可以这样写的,多添加几个单位,而不是创建一个新定义,注意一下每一组的范围,不能一样,否则会导致某些单位无法生成:
int GoldID = rmCreateObjectDef("LandGold ");
rmAddObjectDefItem(GoldID, "mineGold", 1, 5.0);
rmAddObjectDefItem(GoldID, "MineTin", 1, 8.0);
rmAddObjectDefItem(GoldID, "MineCopper", 1, 11.0);
rmAddObjectDefItem(GoldID, "ypSPCRockCrate", 10, 13.0);
rmSetObjectDefMinDistance(GoldID, 0.0);
rmSetObjectDefMaxDistance(GoldID, rmXFractionToMeters(0.01));
rmPlaceObjectDefAtLoc(GoldID, 0, 0.46, 0.66, 1);
(知识扩展)帝国3命令:
[( )] rmCreateObjectDef(string name): Creates an object definition.
[( )] rmAddObjectDefItem(int defID, string unitName, int count, float clusterDistance): Add item to object definition.
[( )] rmSetObjectDefMinDistance(int defID, float dist): Set the minimum distance for the object definition (in meters).
[( )] rmSetObjectDefMaxDistance(int defID, float dist): Set the maximum distance for the object definition (in meters).
[( )] rmSetObjectDefCreateHerd(int defID, bool on): Creates a herd out of all units placed in this object def.
[( )] rmPlaceObjectDefAtLoc(int defID, int playerID, float xFraction, float zFraction, int placeCount): Place object definition at specific location for given player.
[( )] rmXFractionToMeters(float meters): Converts a fraction of the map in the x direction to meters.
(知识扩展)帝国3命令:
[( )] rmCreateArea(string name, int parentAreaID): Creates an area.
[( )] rmSetAreaSize(float minFraction, float maxFraction): Set the area size to a min/max fraction of the map.
[( )] rmSetAreaLocation(int areaID, float xFraction, float zFraction): Set the area location.
[( )] rmSetAreaWarnFailure(int areaID, bool warn): Sets whether the area build process will warn if it fails.
[( )] rmSetAreaSmoothDistance(int areaID, int smoothDistance): Sets area edge smoothing distance (distance is number of neighboring points to consider in each direction).
[( )] rmSetAreaCoherence(int areaID, float coherence): Sets area coherence (0-1).
[( )] rmSetAreaMix(int areaID, string mixName): Sets the mix for an area. Overrides terrain type if it is also set.
[( )] rmSetAreaElevationType(int areaID, int type): Sets the area elevation variation type (cElevNormal, cElevFractalSum, cElevTurbulence).
[( )] rmSetAreaElevationVariation(int areaID, float variation): Sets the area elevation variation height (amount to vary +- from area base height).
[( )] rmSetAreaBaseHeight(int areaID, float height): Sets the base height for an area.
[( )] rmSetAreaElevationOctaves(int areaID, int octaves): Sets the area elevation variation noise octaves.
[( )] rmSetAreaObeyWorldCircleConstraint(int areaID, bool constrain): Determines whether an area obeys world circle constraint.
[( )] rmAddAreaInfluenceSegment(int areaID, float xFraction1, float zFraction1, float xFraction2, float zFraction2): Adds an area influence segment.
[( )] rmBuildArea(int areaID): Builds the specified area.
*/