收起左侧

新人求助,关于未知地图开局赠马车

[复制链接]
1536118发表于 2023-4-16 10:07:43
萌新第一次发帖,请大佬们见谅。我现在搞懂了未知地图开局送马车的原理是everyoneGetsAWagon,但是我现在想要做到开局赠送好几种马车的效果,樱桃园、橡胶园和使馆各一个那种,现在我就不知道怎么做了。是在原有的everyonegetsawagon上做修改吗,还是说我要去新建触发啥的。修改圣典我才刚开始看,谢谢大佬们了。还有大佬们能稍微解释下这个everyonegetsawagon的原理吗,以及我想在未知地图的xs文件里找到指挥部开局那种特殊变体,这种特殊变体的代码我应该去文件的哪里去找。萌新在此谢过!
こはね发表于 2023-4-16 11:03:07
//定义everyoneGetsAWagon数值,随机返回950-1000整数
int everyoneGetsAWagon = rmRandInt(950,1000);

//如果everyoneGetsAWagon不等于981,变更everyoneGetsAWagon数值
// Bonus Wagon
if (everyoneGetsAWagon != 981)
{
if (rmRandFloat(0,1) <= 0.001)
everyoneGetsAWagon = 111; // factory wagon
if (rmRandFloat(0,1) <= 0.005)
everyoneGetsAWagon = 69; // jeff wagons (1 food age 1, 1 wood age 3, 1 coin age 4, all 3 age 5)
if (oceanRing == 1 && rmRandFloat(0,1) <= 0.25)
everyoneGetsAWagon = 1001;
// if (oceanOffCenter == 1 && rmRandFloat(0,1) <= 0.25 && bayChance == 1)
if (rmRandFloat(0,1) <= 0.25 && bayChance == 1)
everyoneGetsAWagon = 1001;
// if (oceanMiddle == 1 && rmRandFloat(0,1) <= 0.25 && oceanChance == 1)
if (rmRandFloat(0,1) <= 0.25 && oceanChance == 1)
everyoneGetsAWagon = 1001;
if (dekkanMap == 1 && rmRandFloat(0,1) <= 0.25 && rmGetIsTreaty() == true)
everyoneGetsAWagon = 1002;
if (trollMap == 1 || rmRandFloat(0,1) <= 0.001)
everyoneGetsAWagon = 1003;
if (tpORnot == 5 && rmRandFloat(0,1) <= 0.10)
everyoneGetsAWagon = 990;
if (rmRandFloat(0,1) <= 0.01)
everyoneGetsAWagon = 666; // military wagon age 2
if (rmRandFloat(0,1) <= 0.001)
everyoneGetsAWagon = 888; // crazy 8s - TC wagon plus BL+1
if (rmRandFloat(0,1) <= 0.001)
everyoneGetsAWagon = 8888; // crazier 8s - TC wagon plus BL+1 when age up
}
rmEchoInfo("everyoneGetsAWagon = "+everyoneGetsAWagon);

if (rmRandFloat(0,1) <= 0.001 || trollMap == 1 || everyoneGetsAWagon == 888 || everyoneGetsAWagon == 8888)
{
rmSetNumberInitialColonies(rmRandInt(2,11));
}

int butOnlySometimes = rmRandInt(1,5);
butOnlySometimes = 3; // for testing // nevermind let's keep it active always for some fun

//判断everyoneGetsAWagon数值,获取不同效果
int playerWagonID=rmCreateObjectDef("starting wagon");
if (everyoneGetsAWagon == 888)
rmAddObjectDefItem(playerWagonID, "CoveredWagon", 1, 0.0);
else if (everyoneGetsAWagon == 8888)
rmAddObjectDefItem(playerWagonID, propz, 1, 0.0);
else if (everyoneGetsAWagon == 666)
{
rmAddObjectDefItem(playerWagonID, "SPCCasualtyCart", 1, 2.0);
rmAddObjectDefItem(playerWagonID, "deNatEUPropVilGuards", 1, 3.0);
}
else if (everyoneGetsAWagon == 69)
{
rmAddObjectDefItem(playerWagonID, "dePropsResourceCratesFood", 1, 3.0);
rmAddObjectDefItem(playerWagonID, "FirewoodPile", 1, 3.0);
rmAddObjectDefItem(playerWagonID, "dePropsResourceCratesGold", 1, 3.0);
}
else if (everyoneGetsAWagon == 111)
rmAddObjectDefItem(playerWagonID, "FactoryWagon", 1, 0.0);
else if (everyoneGetsAWagon <= 970)
rmAddObjectDefItem(playerWagonID, "deTradingPostWagon", 1, 0.0);
else if (everyoneGetsAWagon <= 971)
{
// rmAddObjectDefItem(playerWagonID, "ypChurchWagon", 1, 0.0);
}
else if (everyoneGetsAWagon <= 972)
rmAddObjectDefItem(playerWagonID, "Envoy", 1, 0.0);
else if (everyoneGetsAWagon == 973)
rmAddObjectDefItem(playerWagonID, "deUniqueTowerBuilder", 1, 0.0);
else if (everyoneGetsAWagon == 974) // 889
rmAddObjectDefItem(playerWagonID, "ypBerryWagon1", 1, 0.0);
else if (everyoneGetsAWagon == 975) // 890
{
if (autoCattle != 1)
{
rmAddObjectDefItem(playerWagonID, "ypVillageWagon", 1, 2.0);
rmAddObjectDefItem(playerWagonID, livestockName, 1, 3.0);
}
else
{
everyoneGetsAWagon = 950;
rmAddObjectDefItem(playerWagonID, "deTradingPostWagon", 1, 0.0);
}
}
else if (everyoneGetsAWagon == 976) // 891
{
if (autoCattle != 1)
{
rmAddObjectDefItem(playerWagonID, "deLivestockMarketWagon", 1, 2.0);
rmAddObjectDefItem(playerWagonID, livestockName, 2, 3.0);
}
else
{
everyoneGetsAWagon = 950;
rmAddObjectDefItem(playerWagonID, "deTradingPostWagon", 1, 0.0);
}
}
else if (everyoneGetsAWagon == 977) // 892
{
rmAddObjectDefItem(playerWagonID, "deMountainMonasteryBuilder", 1, 2.0);
if (rmRandFloat(0,1) <= 0.01)
rmAddObjectDefItem(playerWagonID, "deNatBerberSultan", 1, 3.0);
else if (rmRandFloat(0,1) <= 0.10)
rmAddObjectDefItem(playerWagonID, "deAbun", 1, 3.0);
else
rmAddObjectDefItem(playerWagonID, "deNatNomad", 1, 3.0);
}
else if (everyoneGetsAWagon == 978) // 893
{
rmAddObjectDefItem(playerWagonID, "deBuilderKingdom", 1, 2.0);
if (rmRandFloat(0,1) <= 0.01)
rmAddObjectDefItem(playerWagonID, "deNatAkanWarchief", 1, 3.0);
else if (rmRandFloat(0,1) <= 0.10)
rmAddObjectDefItem(playerWagonID, "deGriot", 1, 3.0);
else
rmAddObjectDefItem(playerWagonID, "deNatNomad", 1, 3.0);
}
else if (everyoneGetsAWagon == 979)
{
// rmAddObjectDefItem(playerWagonID, "deAthosMonasteryWagon", 2, 4.0);
}
else if (everyoneGetsAWagon == 980)
{
rmAddObjectDefItem(playerWagonID, "NatHolcanSpearman", 1, 0.0);
}
else if (everyoneGetsAWagon == 981)
rmAddObjectDefItem(playerWagonID, "dePropsResourceCratesGold", 1, 0.0);
else if (everyoneGetsAWagon == 982)
rmAddObjectDefItem(playerWagonID, "deCommanderyWagon", 2, 2.0);
else if (everyoneGetsAWagon == 983)
{
if (autoCattle != 1)
{
rmAddObjectDefItem(playerWagonID, "ypSacredFieldWagon", 1, 2.0);
rmAddObjectDefItem(playerWagonID, livestockName, 2, 3.0);
}
else
{
everyoneGetsAWagon = 950;
rmAddObjectDefItem(playerWagonID, "deTradingPostWagon", 1, 0.0);
}
}
else if (everyoneGetsAWagon == 984)
rmAddObjectDefItem(playerWagonID, "deDepotWagon", 1, 0.0);
else if (everyoneGetsAWagon == 985)
rmAddObjectDefItem(playerWagonID, "SPCDamagedCannons", 1, 0.0);
else if (everyoneGetsAWagon == 986)
rmAddObjectDefItem(playerWagonID, "deCommandWagon", 1, 0.0);
else if (everyoneGetsAWagon == 987)
{
rmAddObjectDefItem(playerWagonID, "deLombardWagon", 1, 2.0);
rmAddObjectDefItem(playerWagonID, "deSPCCityGuard", 1, 2.0);
}
else if (everyoneGetsAWagon == 988)
rmAddObjectDefItem(playerWagonID, "deBatteryTowerWagon", 1, 0.0);
else if (everyoneGetsAWagon == 989)
{
rmAddObjectDefItem(playerWagonID, "deProspectorWagonCoal", 1, 2.0);
rmAddObjectDefItem(playerWagonID, "deMiner", 1, 2.0);
}
else if (everyoneGetsAWagon == 990)
{
rmAddObjectDefItem(playerWagonID, "deEmbassyTravois", 1, 2.0);
if (yellowRiverMap == 1)
rmAddObjectDefItem(playerWagonID, "ypNativeScout", 1, 4.0);
else if (rmRandFloat(0,1) <= 0.10)
rmAddObjectDefItem(playerWagonID, "NativeScout", 1, 4.0);
else
rmAddObjectDefItem(playerWagonID, "deNatSPCLenapeVillager", 1, 4.0);
}
else if (everyoneGetsAWagon == 991)
{
if (autoCattle != 1)
{
rmAddObjectDefItem(playerWagonID, "deHaciendaWagon", 1, 2.0);
rmAddObjectDefItem(playerWagonID, livestockName, 4, 4.0);
}
else
{
everyoneGetsAWagon = 950;
rmAddObjectDefItem(playerWagonID, "deTradingPostWagon", 1, 0.0);
}
}
else if (everyoneGetsAWagon == 992)
{
if (autoCattle != 1)
{
rmAddObjectDefItem(playerWagonID, "deHomesteadWagon", 1, 2.0);
rmAddObjectDefItem(playerWagonID, livestockName, 7, 5.0);
}
else
{
everyoneGetsAWagon = 950;
rmAddObjectDefItem(playerWagonID, "deTradingPostWagon", 1, 0.0);
}
}
else if (everyoneGetsAWagon == 993)
rmAddObjectDefItem(playerWagonID, "deImperialWagon", 1, 0.0);
else if (everyoneGetsAWagon == 994)
rmAddObjectDefItem(playerWagonID, "BankWagon", 1, 0.0);
else if (everyoneGetsAWagon == 995)
rmAddObjectDefItem(playerWagonID, "deTorpWagon", 1, 0.0);
else if (everyoneGetsAWagon == 996)
rmAddObjectDefItem(playerWagonID, "OutpostWagon", 1, 0.0);
else if (everyoneGetsAWagon == 997)
rmAddObjectDefItem(playerWagonID, "deRedSeaWagon", 1, 0.0);
else if (everyoneGetsAWagon == 998)
rmAddObjectDefItem(playerWagonID, "SettlerWagon", 1, 0.0);
else if (everyoneGetsAWagon == 999)
{
if (autoCattle != 1)
{
rmAddObjectDefItem(playerWagonID, "ypShrineWagon", 1, 2.0);
rmAddObjectDefItem(playerWagonID, livestockName, 4, 4.0);
}
else
{
everyoneGetsAWagon = 950;
rmAddObjectDefItem(playerWagonID, "deTradingPostWagon", 1, 0.0);
}
}
else if (everyoneGetsAWagon == 1000)
{
rmAddObjectDefItem(playerWagonID, "YPDojoWagon", 1, 2.0);
rmAddObjectDefItem(playerWagonID, "ypIrregular", 1, 4.0);
rmAddObjectDefItem(playerWagonID, "ypPeasant", 1, 4.0);
}
else if (everyoneGetsAWagon == 1001)
{
rmAddObjectDefItem(playerWagonID, "deDockWagon", 1, 0.0);
rmAddObjectDefItem(playerWagonID, "deCrateofFish", 1, 4.0);
}
else if (everyoneGetsAWagon == 1002)
rmAddObjectDefItem(playerWagonID, "YPGroveWagon", 1, 0.0);
else
rmAddObjectDefItem(playerWagonID, "deREVStarTrekWagon", 1, 0.0);
rmSetObjectDefMinDistance(playerWagonID, 12.0);
rmSetObjectDefMaxDistance(playerWagonID, 24.0);
rmAddObjectDefConstraint(playerWagonID, shortAvoidImpassableLand);
rmAddObjectDefConstraint(playerWagonID, avoidCommandPost);
rmAddObjectDefConstraint(playerWagonID, avoidTC);
rmAddObjectDefConstraint(playerWagonID, avoidCW);
rmAddObjectDefConstraint(playerWagonID, avoidCanyon);
rmAddObjectDefConstraint(playerWagonID, avoidTradeRouteSocketShort);
rmAddObjectDefConstraint(playerWagonID, avoidTradeRoute);
rmAddObjectDefConstraint(playerWagonID, avoidAll);
rmAddObjectDefConstraint(playerWagonID, avoidEdge);

  • 1536118 : 感谢大佬
myonion发表于 2023-4-16 15:51:45
其实未知地图里的everyonegetsawagon只是一个自定义的变量名,用于随机决定执行添加哪个物件定义
实际上开局摆放物件只需要
int sthID = rmCreateObjectDef("这里这段注释可以随便填"); //这行的功能是 int代表变量类型为整数,sthID这里是一个你自己随意定义的变量名想叫什么都行,但不要与已有变量及常用功能名重复 ,等于rmCreateObjectDef() 这个是xs文件预设的功能(或者叫表达式或命令)用于定义一个变量用于存放物件定义
rmAddObjectDefItem(sthID, "ypGiantSalamander", 1, 0.0); //rmAddObjectDefItem(int defID, string unitName, int count, float clusterDistance);的功能就是往定义里塞物件,括号内第一项就是告诉这功能往哪个变量里塞(这里当然就是刚刚定义的sthID)第二项是proto里的单位调用名这里我加了娃娃鱼,第三项是数量,第四项是分散程度,一般多个时才需要大于0。你可以往一个定义塞多组物件,多加几行rmAddObjectDefItem即可
rmSetObjectDefMinDistance(sthID, 4.0);
rmSetObjectDefMaxDistance(sthID, 8.0);//这两项功能可选,作用是定义后面摆放物件时与目标地点的最小最大距离,单位是米(帝三里的一米是半格,一格可以在地图编辑器打开刻度线看到白色边框小格,proto里的obstructionradius基础单位是格,比如TC占地面积就是4*4格/8*8米)

rmPlaceObjectDefPerPlayer(sthID, true, 1); //最后就是摆放,摆放物件的命令有多种,详情自行到盛典的rmCommand栏目搜索rmPlaceObjectDef
  • 1536118 : 大佬我学会加代码行数塞东西了,但是我新加入的马车都没有建造按钮,比方银行樱桃园之类的都不能建造,我这是还要补什么代码之类的吗
  • myonion 回复 1536118 : 因为你没有给玩家启用它们可以建造的对应建筑,要加个触发,在未知地图里搜索Unforbid and Enable Unit找到用例对照着圣典13-5学吧
跳转到