myjlwf myjlwf
May the Vulcan be with human
关注数: 0 粉丝数: 114 发帖数: 1,685 关注贴吧数: 4
游戏崩溃·求大佬看看 在AI编辑器的脚本上做的修改,因重置版没有了直接买单位和买物品的函数,只能用中介命令代替 但是运行后游戏会中途崩溃,很可能10分钟之后,此时AI很可能已经给两个英雄买过物品了 如果把 CALL BUYWUPIN 和 call PurchaseZe 写在生产程序里( function WorkerAssignment ),就不会崩溃,但写在攻击里( function AttackAssignment )就会崩溃 试过单独删掉以下代码,还是崩溃 function isunithaveitem 整段 function UnithaveitemCount 整段 function buywupin里的 call IssuePointOrderByIdLoc(whichUnit, 851986, udg_dian) call RemoveLocation(GetUnitLoc(udg_uaa)) //清除点,排泄 call RemoveLocation(udg_dian) call Sleep( 6 ) call IssueNeutralTargetOrderById(Player(GetAiPlayer()), udg_uaa, 852566, whichUnit) //852566是任意商店-选择单位动作的ID ,命令商店选择指定英雄,即哪个英雄买哪个商品 call Sleep( 1 ) call IssueNeutralImmediateOrderById(Player(GetAiPlayer()), udg_uaa, itemId) set whichUnit = null set itemId = 0 这是代码 function isunithaveitem takes unit whichUnit, integer itemId returns boolean //英雄物品栏有没有指定物品 local integer index = 0 loop if (UnitItemInSlot(whichUnit, index) != null) and (GetItemTypeId(UnitItemInSlot(whichUnit, index)) == itemId) then//判断这一格是否有这样物品 return true endif set index = index + 1 exitwhen index > 5 //从第一到第六格 endloop return false endfunction function UnithaveitemCount takes unit whichUnit returns integer //英雄物品栏是否满了 local integer indext = 0 local integer countt = 0 loop if (UnitItemInSlot(whichUnit, indext) != null) then//如果这一格物品栏不为空 set countt = countt + 1//记录物品数量+1 endif set indext = indext + 1 exitwhen indext >5 //6格物品栏,未涉及高级物品栏 endloop return countt endfunction 买物品 function buywupin takes unit whichUnit, integer itemId returns nothing //英雄买物品 if isunithaveitem(whichUnit, itemId) == true then if itemId == 'i000' then if it == 1 then set i000a = 1 //意思是1英雄已经有了球 elseif it == 2 then set i000b = 1 elseif it == 3 then set i000c = 1 //当d=3后,说明三英雄都有了球,不用再跑买球了 endif endif set whichUnit = null return endif if UnithaveitemCount(whichUnit) == 6 then set whichUnit = null return endif if imc == 1 and GetUnitCountDone('h001') < 1 then //商店被拆除后,除非三英雄都有球,否则重新定义单位 set udg_uaa = null set udg_dian = null set imc = 0 endif if ihc == 0 then call GroupEnumUnitsOfPlayer(udg_h0,Player(GetAiPlayer()),null) call GroupRemoveUnit(udg_h0,udg_hero4[1]) //移除已经定义的英雄,防止重复定义 call GroupRemoveUnit(udg_h0,udg_hero4[2]) call GroupRemoveUnit(udg_h0,udg_hero4[3]) loop set udg_hero0=FirstOfGroup(udg_h0) exitwhen udg_hero0 == null if IsUnitType(udg_hero0,UNIT_TYPE_HERO)==true then //如果单位是英雄 set im = im + 1 set udg_hero4[im] = udg_hero0 call GroupRemoveUnit(udg_h0,udg_hero0) else call GroupRemoveUnit(udg_h0,udg_hero0) endif endloop call DestroyGroup(udg_h0) //删除单位组及单位,排泄 set udg_h0 = null set udg_hero0 = null if im == 3 then //三个英雄全部定义后,不再运行这段指令 set ihc = 1 endif endif if imc == 0 then if GetUnitCount('h001') > 0 then //商店(含在建)数量大于0 call GroupEnumUnitsOfPlayer(udg_ga, Player(GetAiPlayer()), null) loop set udg_ua = FirstOfGroup(udg_ga) exitwhen udg_ua == null if GetUnitTypeId(udg_ua) == 'h001' then set udg_uaa = udg_ua set udg_dian = GetUnitLoc(udg_uaa) call GroupRemoveUnit(udg_ga, udg_ua) else call GroupRemoveUnit(udg_ga, udg_ua) endif endloop call DestroyGroup(udg_ga) set udg_ga = null set udg_ua = null set imc = 1 //不进入循环 endif endif call IssuePointOrderByIdLoc(whichUnit, 851986, udg_dian) call RemoveLocation(GetUnitLoc(udg_uaa)) //清除点,排泄 call RemoveLocation(udg_dian) call Sleep( 6 ) call IssueNeutralTargetOrderById(Player(GetAiPlayer()), udg_uaa, 852566, whichUnit) //852566是任意商店-选择单位动作的ID ,命令商店选择指定英雄,即哪个英雄买哪个商品 call Sleep( 1 ) call IssueNeutralImmediateOrderById(Player(GetAiPlayer()), udg_uaa, itemId) set whichUnit = null set itemId = 0 endfunction 买伐木机 function PurchaseZe takes nothing returns nothing local integer i = 0 if ixcc == 0 then call GroupEnumUnitsOfPlayer(udg_g, Player(PLAYER_NEUTRAL_PASSIVE), null) //将中立被动玩家所有单位添加到单位组g中 loop set udg_u = FirstOfGroup(udg_g) exitwhen udg_u == null if GetUnitTypeId(udg_u) == 'ngad' then //如果u是地精研究院 set i = i + 1 set ix = i //用于记录中立被动玩家一共有几个地精研究院 set udg_us[i] = udg_u call GroupRemoveUnit(udg_g, udg_u) else call GroupRemoveUnit(udg_g, udg_u) endif endloop call DestroyGroup(udg_g) set udg_g = null set udg_u = null set ixcc = 1 endif if ix != 0 then //规避没有地精研究院的地图 set ixc = GetRandomInt(1,ix) //不知道地图一共有几个地精研究院,随机找,会有点慢的,制造程序数量和地精研究院的数量都会影响,但千万别用循环,会卡,也别把买放进循环里,不会买 call IssueNeutralImmediateOrderById(Player(GetAiPlayer()), udg_us[ixc], 'ngir') //让AI在中立被动玩家的随机一个地精研究院买一个伐木机,前提是地精研究院正常出售伐木机,这里用布尔值【 set XXX = 】也可以 endif endfunction CALL的代码这样写的 if i000d != 3 and in002d > 0 and GetGold( ) > 550 then set it = it + 1 call buywupin(udg_hero4[it],'I000') //这是自定义的球,为了保证英雄对空能力,每个英雄都应该买1个 call Sleep( 1 ) endif if in002d > 0 and GetGold( ) > 550 then call buywupin(udg_hero4[it],'I003') //这是自定义的群补,没了就让AI买 if it == 3 then set it = 1 endif call Sleep( 1 ) endif 买伐木机,ZE是让AI最多拥有1台 if GetUnitCount(ZE) < 1 and ( FoodUsed( ) + 5 ) < c_renkou and GetGold( ) > 500 and GetWood( ) > 300 then call Trace("purchase zep\n") //xxx //c_renkou是当前可用人数数量,防止人口到顶了还去买 call PurchaseZe() endif
随机英雄生产·CALL()怎么用 AI编辑器是在混论之治就没更新了,所以只能设置3个英雄的随机 混乱的3选3乱序没问题 但是冰封王座是4选3 靠满足不了 我参考了暴雪的ai 想把那部分代码融合到编辑器的脚本里 替代英雄生产 暴雪的代码写在common.ai里 种族的AI只是引用 common.ai代码我记得是这样的 设置各种族 heroes[1]=英雄1 heroes[2]=英雄2 heroes[3]=英雄3 heroes[4]=英雄4 没有种族 SET HERO_id=0 定义本地参数 first second third last heroesarray SET first SET second SET third SET last 如果是混乱 SET last=3 如果是冰封 SET last=4 roll 随机整数(1,last) roll 随机整数(1,last-1) roll 随机整数(1,last-2) SET heroes[first]=[last] SET HERO_id=heroes[first] SET [second]=[last-1] SET HERO_id2=heroes[second] SET [third]=[last-2] SET HERO_id3=heroes[third] 编辑器生成的AI是这样定义英雄及生产顺序的概率 roll int(1 ,100) if roll<50 CALL(1 , 'n000') CALL(2 , 'n001') CALL(3 , 'n002') if roll<20 CALL(1 , 'n000') CALL(2 , 'n002') CALL(3 , 'n001') 我把整段改成了 heroes[1]=英雄1 heroes[2]=英雄2 heroes[3]=英雄3 heroes[4]=英雄4 定义本地参数 first second third last heroesarray SET first SET second SET third SET last 如果是混乱 SET last=3 如果是冰封 SET last=4 roll 随机整数(1,last) roll 随机整数(1,last-1) roll 随机整数(1,last-2) SET heroes[first]=[last] SET HERO_id=heroes[first] SET [second]=[last-1] SET HERO_id2=heroes[second] SET [third]=[last-2] SET HERO_id3=heroes[third] CALL(1 , heroes[first]) CALL(2 , heroes[second]) CALL(3 , heroes[third]) 但是AI不运行 我把call改了, 依旧不运行 CALL(1 , HERO_id) CALL(1 , HERO_id2) CALL(1 , HERO_id3) CALL是不是一定要具体到单位??而且不能带数组[]或者带数组要加什么参数 比如 call int 我不想用判断,太长了,每个数要判断4次,判断3个数··12次 还是说这段代码本身写在com里,我在脚本里这样用是非法的?
1 下一页