|
JASS修行还不够啊……
不知道怎么办?怎么哈希表?怎么把RETURN BUG什么改掉?
希望能帮帮忙!!谢谢了
要帮的忙:1、让此JASS能在1.24e运行
2、教我如何改(似乎挺……)
JASS如下
http://bbs.islga.org/read-htm-ti ... 7C%D6%C7%C4%DC.html
function I2TG takes integer i returns trigger
return i
return null
endfunction
function I2TC takes integer i returns triggercondition
return i
return null
endfunction
function AIOrderRun takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer count = GetStoredInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder_Count")
local integer order
local integer pro
local integer index
local integer i = 0
local integer a = 0
loop
set pro = GetStoredInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder_Probability"+I2S(i))
if GetRandomInt(0,99)*pro/(a+pro) < pro then //算法呀算法~~这样才是正确的概率
set order = GetStoredInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder"+I2S(i))
set index = GetStoredInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder_Index"+I2S(i))
set a = a+pro
endif
set i = i+1
if i >=count then // 1:敌目标 2:点目标 3:无目标 4:自己
if index == 1 then
call IssueTargetOrderById(u,order,GetEventTargetUnit())
elseif index == 2 then
call IssuePointOrderById(u,order,GetUnitX(GetEventTargetUnit()),GetUnitY(GetEventTargetUnit()))
elseif index == 3 then
call IssueImmediateOrderById(u, order)
elseif index == 4 then
call IssueTargetOrderById(u,order,u)
endif
exitwhen true
endif
endloop
set u = null
return false
endfunction
function AddAIOrder takes unit u,string order,integer index,integer probability returns nothing
local integer i = GetStoredInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder_Count")
local trigger trg
if i==0 then
set trg = CreateTrigger()
call TriggerRegisterUnitEvent(trg, u, EVENT_UNIT_TARGET_IN_RANGE) //改用发动攻击为事件
call StoreInteger(udg_GC, I2S(H2I(u)), "MercenaryTrigger",H2I(trg))
call StoreInteger(udg_GC, I2S(H2I(trg)), "TriggerCondition",H2I(TriggerAddCondition(trg, Condition(function AIOrderRun)))) //好吧,这个提升效率是非常明显的
endif
call StoreInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder"+I2S(i), OrderId(order)) //使用OrderId要比OrderString好得多
call StoreInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder_Probability"+I2S(i), probability)
call StoreInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder_Index"+I2S(i), index)
call StoreInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder_Count", i+1)
set trg = null
endfunction
//这个是清空函数
function FlushAIOrder takes unit u returns nothing
local integer i = GetStoredInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder_Count")
local integer trg = GetStoredInteger(udg_GC, I2S(H2I(u)), "MercenaryTrigger")
call TriggerRemoveCondition(I2TG(trg),I2TC(GetStoredInteger(udg_GC, I2S(trg), "TriggerCondition")))
call DestroyTrigger(I2TG(trg))
call FlushStoredMission(udg_GC, I2S(trg))
call FlushStoredInteger(udg_GC, I2S(H2I(u)), "MercenaryTrigger")
call FlushStoredInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder_Count")
loop
set i = i-1
exitwhen i < 0
call FlushStoredInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder"+I2S(i))
call FlushStoredInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder_Probability"+I2S(i))
call FlushStoredInteger(udg_GC, I2S(H2I(u)), "MercenaryAIOrder_Index"+I2S(i))
endloop
endfunction |
|