找回密码
 点一下
查看: 1434|回复: 4

写了个钩子技能  遇到个想不通的毛病 郁闷!

[复制链接]
发表于 2010-11-28 19:37:29 | 显示全部楼层 |阅读模式
          用JASS  然后 缓存 和 TimerStart()的使用   制作了一个 支持多人施放的  钩子技能

         效果已经全部达到了   10个人同时玩  不会出现什么明显的纰漏  但是   玩着玩着  会出现一个状况    就是  有个人  被 钩子拉到   暂停了  但是钩子没回来   由于这种事是玩着玩着才出现的  所以我不知道  为什么    我给出代码   高手帮忙看看    (比较长   有空的JASS代码编辑者可以看看  没空 就等有空了再说吧)


function rougoutiaojian1 takes nothing returns boolean
    return (( IsUnitAliveBJ(GetFilterUnit()) == true )and( IsUnitPausedBJ(GetFilterUnit()) == false ))
endfunction
function rougoutiaojian2 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) != true )
endfunction
function rougoutiaojian3 takes nothing returns boolean
    return GetBooleanAnd( rougoutiaojian1(), rougoutiaojian2() )
endfunction

function RouGou3 takes nothing returns nothing
    local timer t1=GetExpiredTimer()
    local integer tmr_hdl1=H2I(t1)
    local string str1=GetStoredString(GC,I2S(tmr_hdl1),"key")
    local real ss1=GetStoredReal(GC,I2S(tmr_hdl1),"ss1")
    local real ss_jl=GetStoredReal(GC,str1,"ss_jl")
    local real ssx=GetStoredReal(GC,I2S(tmr_hdl1),"ssx")
    local real ssy=GetStoredReal(GC,I2S(tmr_hdl1),"ssy")
    local effect eff = H2EFF(I2H(GetStoredInteger(GC,str1,R2S(ss_jl))))
    local location p1 = Location(ssx,ssy )
    local location p2
    local unit u1=H2U(I2H(GetStoredInteger(GC,I2S(tmr_hdl1),"unit1")))
    call DestroyEffect( eff )
    set ss_jl = ss_jl - 1
    set p2 = PolarProjectionBJ(p1, ( 50.00 * ss_jl ), ss1)
    if (u1!=null) then
    call SetUnitPositionLoc( u1, p2 )
    endif
    if (ss_jl <= 0 ) then
        call DestroyTimer(H2TMR(I2H(GetStoredInteger(GC,str1,"tmr"))))
        call PauseTimer(t1)
        call DestroyTimer(t1)
            if (u1!=null) then
                call SetUnitPathing( u1, true )
                call PauseUnitBJ( false, u1 )               
                if ( GetUnitTypeId(u1) == 'H00H' )  then
                call RouBo1()
                call RemoveUnit( u1 )
                endif
            endif
        call FlushStoredMission(GC, str1)
        call FlushStoredMission(GC, I2S(tmr_hdl1))
        
    else
        call StoreReal(GC,str1,"ss_jl",ss_jl)
    endif
   
    set t1= null
    set p1=null
    set p2=null
    set str1=null
    set eff=null
    set u1=null
endfunction
function RouGou2 takes nothing returns nothing
    local timer t1=GetExpiredTimer()
    local timer t2=CreateTimer()
    local integer tmr_hdl1=H2I(t1)
    local integer tmr_hdl2=H2I(t2)
    local integer eff_hdl
    local integer i_xh1
    local integer i_xh2
    local integer u1_hdl
    local real ss1=GetStoredReal(GC,I2S(tmr_hdl1),"ss1")
    local real ss_jl=GetStoredReal(GC,I2S(tmr_hdl1),"ss_jl")
    local real ssx=GetStoredReal(GC,I2S(tmr_hdl1),"ssx")
    local real ssy=GetStoredReal(GC,I2S(tmr_hdl1),"ssy")
    local location p1 = Location(ssx,ssy )
    local location p2 = PolarProjectionBJ(p1, ( 50.00 * ss_jl ), ss1)
    local effect eff
    local group gp
    local unit u1
    local unit u2=H2U(I2H(GetStoredInteger(GC,I2S(tmr_hdl1),"unit2")))
   
    set ss_jl = ( ss_jl + 1 )
    call AddSpecialEffectLocBJ( p2, "Abilities\\Weapons\\ProcMissile\\ProcMissile.mdl" )
    set eff = bj_lastCreatedEffect
    set eff_hdl = H2I(eff)
    call StoreInteger(GC,I2S(tmr_hdl1),R2S(ss_jl),eff_hdl)                          //利用积累实数  存储特效 绑定对应实数
   
    if (ss_jl >= 80.00) then
        call StoreString(GC,I2S(tmr_hdl2),"key",I2S(tmr_hdl1))
        call PauseTimer(t1)
        call TimerStart(t2,0.04,true,function RouGou3)
        call StoreInteger(GC,I2S(tmr_hdl2),"unit1",u1_hdl)
        call StoreInteger(GC,I2S(tmr_hdl2),"tmr",tmr_hdl2)
        call StoreReal(GC,I2S(tmr_hdl2),"ss1",ss1)
        call StoreReal(GC,I2S(tmr_hdl2),"ssx",ssx)
        call StoreReal(GC,I2S(tmr_hdl2),"ssy",ssy)
        
        set gp=null
    else
             set gp = GetUnitsInRangeOfLocMatching(80.00, p2, Condition(function rougoutiaojian3))
             call GroupRemoveUnitSimple( u2, gp )
             if ( CountUnitsInGroup(gp) >= 1 ) then
             set i_xh1 = 1
             set i_xh2 = 8
             call GroupClear( gp )
               loop
                    exitwhen i_xh1 > i_xh2
                    set gp = GetUnitsInRangeOfLocMatching(( ( 9.00 - I2R(i_xh1) ) * 10.00 ), p2, Condition(function rougoutiaojian3))
                    call GroupRemoveUnitSimple( u2, gp )
                    if ( CountUnitsInGroup(gp) == 1 ) then
                       call StoreString(GC,I2S(tmr_hdl2),"key",I2S(tmr_hdl1))
                       set u1 = GroupPickRandomUnit(gp)
                       call SetUnitPathing( u1, false )
                       call PauseUnitBJ( true, u1 )
                       set u1_hdl=H2I(u1)
                       call PauseTimer(t1)
                       call StoreInteger(GC,I2S(tmr_hdl2),"unit1",u1_hdl)
                       call StoreInteger(GC,I2S(tmr_hdl2),"tmr",tmr_hdl2)
                       call StoreReal(GC,I2S(tmr_hdl2),"ss1",ss1)
                       call StoreReal(GC,I2S(tmr_hdl2),"ssx",ssx)
                       call StoreReal(GC,I2S(tmr_hdl2),"ssy",ssy)
                       call TimerStart(t2,0.04,true,function RouGou3)
                       exitwhen true
                   else
                      call DestroyTimer(t2)
                   endif
                   set i_xh1 = i_xh1 + 1
               endloop
             else
                   call DestroyTimer(t2)
           endif
    endif
    call StoreReal(GC,I2S(tmr_hdl1),"ss_jl",ss_jl)
   
    set t1=null
    set t2=null
    set p1=null
    set p2=null
    set eff=null
    set gp=null
    set u1=null
    set u2=null
endfunction

function RouGou1 takes nothing returns nothing                                                  //  这个函数是施放技能的时候被调用  主函数
    local location p1 = GetUnitLoc(GetSpellAbilityUnit())
    local location p2 = GetSpellTargetLoc()
    local real ss1 = AngleBetweenPoints(p1, p2)
    local real ssx = GetUnitX(GetSpellAbilityUnit())
    local real ssy = GetUnitY(GetSpellAbilityUnit())
    local timer t1=CreateTimer()
    local integer tmr_hdl=H2I(t1)
    local real ss_jl = 1
    local unit u1 = GetSpellAbilityUnit()
    local integer u1_hdl=H2I(u1)
    call TimerStart(t1,0.04,true,function RouGou2)
    call StoreInteger(GC,I2S(tmr_hdl),"tmr",tmr_hdl)                        //存储计时器句柄
    call StoreInteger(GC,I2S(tmr_hdl),"unit2",u1_hdl)                     
    call StoreReal(GC,I2S(tmr_hdl),"ss1",ss1)                                  //方向实数
    call StoreReal(GC,I2S(tmr_hdl),"ss_jl",ss_jl)                              //钩子出去距离的积累实数
    call StoreReal(GC,I2S(tmr_hdl),"ssx",ssx)                                    //施法单位的点记录X
    call StoreReal(GC,I2S(tmr_hdl),"ssy",ssy)                                   //施法单位的点记录Y
    set p1=null
    set p2=null
    set t1=null
    set u1=null
endfunction



大致原理是:钩子开始施放  开启2   出去   当距离达到一定数值或 遇到单位    开启3    遇到单位  暂停单位   然后其他人勾的时候判断是否暂停  防止多人勾到   函数3就是回来并清除特效

有时候玩很久都没事   有时候会出现  单位被暂停   钩子不回来了
发表于 2010-11-28 19:45:06 | 显示全部楼层
请用[jass][/jass]包括函数部分
回复

使用道具 举报

发表于 2010-11-28 19:52:09 | 显示全部楼层
超过执行上限溢出了?
回复

使用道具 举报

 楼主| 发表于 2010-11-28 19:56:02 | 显示全部楼层

回 2楼(疯人¢衰人) 的帖子

汗一个   提问后不久 自己去细心看了看  貌似知道为什么了   


前几天怎么检查都检查不出    真是造化弄人啊
回复

使用道具 举报

发表于 2010-12-3 10:23:30 | 显示全部楼层
楼主真厉害,这么厉害的技能呀。。。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-3 14:05 , Processed in 0.069858 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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