找回密码
 点一下
查看: 1206|回复: 3

为神马循环计时器+范围选取单位会无效

[复制链接]
发表于 2013-7-19 19:58:08 | 显示全部楼层 |阅读模式
本帖最后由 Simonade 于 2013-7-21 00:54 编辑

我是启动周期为0.05s的循环计时器,经过夹逼测试,最后确定是单位选取单位这个动作中断并返回了计时器调用的函数。。。测试了半天,蛋总都扛不住啊。。。
function grow takes nothing returns nothing
    local timer t=GetExpiredTimer()
    local integer T=LoadInteger(h,GetHandleId(t),10)
    local unit target
    local real ang
    set T=T+1
    call SaveInteger(h,GetHandleId(t),10,T)
    call BJDebugMsg(I2S(T))                                                             //Debug"T"T的计数还是不断增长的,没加范围选取单位的时候T增长到300就中断,结果加了之后永不停止了。。。
    call GroupEnumUnitsInRange(g,GetUnitX(dummy),GetUnitY(dummy),500.0+n*100.0,null)                         //就是被这个函数的调用,跳出了grow函数,天坑啊~~~~~~~~~~~
    //call BJDebugMsg(GetUnitName(FirstOfGroup(g)))
    call BJDebugMsg("我擦")
    if T==300 then
        call BJDebugMsg("次奥终结")
        call PauseTimer(t)
        call DestroyTimer(t)
        call FlushChildHashtable(h,GetHandleId(t))
    endif
    set t=null   
endfunction
function Start takes nothing returns nothing
    local location point
    local group g
    local timer t
    if GetSpellAbilityId()!='AUdd' then
        return
    endif
        set point=GetSpellTargetLoc()
        set dummy=CreateUnit(GetOwningPlayer(GetTriggerUnit()),'e000',GetLocationX(point),GetLocationY(point),0.0)
        set g=CreateGroup()
        set t=CreateTimer()
        call TimerStart(t,0.05,true,function grow)
        call RemoveLocation(point)
    set point=null
    set t=null
endfunction
//===========================================================================
function InitTrig_blackhole takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddAction(t,function Start)
    set t=null
endfunction//====================================================================================  已 献 个 单 能 谢
//============================================================================================解 上 很 的 以 意
//============================================================================================决 一 简 技 表!
globals
    hashtable h=InitHashtable()
endglobals
//========================================================================
function Scale takes integer n returns nothing
    local unit dummy=LoadUnitHandle(h,0,0)
    call SetUnitScale(dummy,3.0+n*0.0125,3.0+n*0.0125,3.0+n*0.0125)
    set dummy=null
endfunction
//=========================================================================
function IsDrop takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(LoadUnitHandle(h,0,0)))==true   
endfunction
//=========================================================================
function Grow takes nothing returns nothing
    local timer t=GetExpiredTimer()
    local location point=LoadLocationHandle(h,GetHandleId(t),0)
    local integer T=LoadInteger(h,GetHandleId(t),10)
    local integer n=LoadInteger(h,GetHandleId(t),11)
    local group g=CreateGroup()
    local unit u
    local location loc
    local real ang
    set T=T+1
    call SaveInteger(h,GetHandleId(t),10,T)    call Scale(n)
    call GroupEnumUnitsInRange(g,GetLocationX(point),GetLocationY(point),500.0+(n/50.0)*100.0,Condition(function IsDrop))//Condition(function IsDrop)
    loop
        set u=FirstOfGroup(g)
    exitwhen u==null
        set loc=GetUnitLoc(u)
        set ang=Atan2(GetLocationY(point)-GetLocationY(loc),GetLocationX(point)-GetLocationX(loc))
        call SetUnitX(u,GetLocationX(loc)+10.0*Cos(ang))
        call SetUnitY(u,GetLocationY(loc)+10.0*Sin(ang))
        call RemoveLocation(loc)
        call GroupRemoveUnit(g,u)
        set u=null
        set loc=null
        set n=n+1
    endloop
    call SaveInteger(h,GetHandleId(t),11,n)
    if T==520 then
        call PauseTimer(t)
        call DestroyTimer(t)
        call RemoveLocation(point)
        call FlushChildHashtable(h,GetHandleId(t))
        call RemoveUnit(LoadUnitHandle(h,0,0))
    endif
    set t=null
    set point=null
    set g=null
endfunction
//=======================================================
function Start takes nothing returns nothing
    local timer t
    local location point
    local unit dummy
    if GetSpellAbilityId()!='AUdd' then
        return
    endif
        set point=GetSpellTargetLoc()
        set dummy=CreateUnit(GetOwningPlayer(GetTriggerUnit()),'e000',GetLocationX(point),GetLocationY(point),0.0)
        call SaveUnitHandle(h,0,0,dummy)
        set t=CreateTimer()
        call SaveLocationHandle(h,GetHandleId(t),0,point)
        call TimerStart(t,0.05,true,function Grow)
    set t=null
    set point=null
    set dummy=null
endfunction
//===========================================================================
function InitTrig_blackhole takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddAction(t,function Start)
    set t=null
endfunction






太初黑洞无伤害版.w3x

50.21 KB, 下载次数: 7

还没写伤害,只有吸引效果,吸的单位越多作用范围越大。。。可以吸全屏咯!!!

发表于 2013-7-19 22:54:05 | 显示全部楼层
本帖最后由 chyj4747 于 2013-7-19 22:55 编辑

那句GroupEnumUnitsInRange的单位组g是哪来的?n又是哪来的?
直接使用未申明的变量自然就使后面的动作无效了

话说这个编译器应该会报错的吧……编译器不报错魔兽也应该进不了图的吧。。

点评

。。。额,我只发了部分。。。不断的在游戏中测试得到的debug显示,判断出是GroupEnumUnitsInRange()出了问题,额,不过已经搞定了。。。额,我的CreateGroup在初始函数中创建的对象,在其上的函数中调用单  详情 回复 发表于 2013-7-19 23:45
回复

使用道具 举报

 楼主| 发表于 2013-7-19 23:45:18 | 显示全部楼层
本帖最后由 Simonade 于 2013-7-19 23:46 编辑
chyj4747 发表于 2013-7-19 22:54
那句GroupEnumUnitsInRange的单位组g是哪来的?n又是哪来的?
直接使用未申明的变量自然就使后面的动作无 ...

。。。额,谢谢,汗,我只发了部分。。。不断的在游戏中测试得到的debug显示,判断出是GroupEnumUnitsInRange()出了问题,额,不过已经搞定了。。。额,我的CreateGroup在初始函数中创建的对象,在其上的函数中调用单位组g,出现了程序错误,直接返回,全局变量竟然不能像指针一样指向对象吗。。。还是只用局部变量好了。。。很少使用全局变量,今天一用就坑了
回复

使用道具 举报

发表于 2013-7-20 21:09:04 | 显示全部楼层
Simonade 发表于 2013-7-19 23:45
。。。额,谢谢,汗,我只发了部分。。。不断的在游戏中测试得到的debug显示,判断出是GroupEnumUnitsInR ...


你的g是个全局变量?还是Start里那个g?
如果g和n都是全局变量那么那句动作应该是没问题的,如果是后者,明显不行啊,哪个语言允许一个函数直接使用另一个函数里申明的变量的……

另外这跟指针有什么关系。。

还有帖子标题应该改成“解决”而不是“展示”
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-4-28 15:29 , Processed in 0.376477 second(s), 30 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表