游戏崩溃·求大佬看看
魔兽地图编辑器吧
全部回复
仅看楼主
level 1
myjlwf 楼主
在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
2021年07月11日 07点07分 1
1