|
强力击的基础技能是ANcl(引导),所以就是纯Jass实现的了
原理就是创建一个箭,不停地向前移动,对箭所在位置的单位造成伤害
很多辅助函数没有给出,还有一些变量没有改名(太懒了)
PS: 刚才看到一个帖子在问怎么让单位只被伤害1次,这些代码就考虑到了这个
[jass]
function windrunnerPowershotDoDamage takes nothing returns nothing // 做出伤害的函数
    if  IsUnitInGroup(GetEnumUnit(), windrunnerPowershotDamagedUnits)  == false and  GetUnitAbilityLevel(GetEnumUnit(), 'Bcyc')  == 0 then
        call doDamage((windrunnerPowershotArrow), (GetEnumUnit()), 1, (((windrunnerPowershotInitialDamage)*1.0))* Pow(0.9, (windrunnerPowershotDamagedUnitCount)) * Pow(0.99, (windrunnerPowershotDamagedDestructableCount)) )
        call GroupAddUnit(windrunnerPowershotDamagedUnits, GetEnumUnit())
        set windrunnerPowershotDamagedUnitCount = windrunnerPowershotDamagedUnitCount + 1
    endif
endfunction
function windrunnerPowershotLoop takes nothing returns boolean  // 箭在飞行的时候
    local trigger t = GetTriggeringTrigger()
    local integer hTrig = GetHandleId(t)
    local unit unitPowershotArrow = ( LoadUnitHandle(hashTable, (hTrig), (45)) )
    local real HMI = ( LoadReal(hashTable, (hTrig), (47)) )
    local real HNI = ( LoadReal(hashTable, (hTrig), (48)) )
    local real LPO = ( LoadReal(hashTable, (hTrig), (13)) )
    local real GFI = ( LoadReal(hashTable, (hTrig), (20)) )
    local integer LN2 = ( LoadInteger(hashTable, (hTrig), (354)) )
    local integer LS2 = ( LoadInteger(hashTable, (hTrig), (355)) )
    local group LQO = ( LoadGroupHandle(hashTable, (hTrig), (187)) )
    local real x = constrainX(GetUnitX(unitPowershotArrow) + (60* Pow(0.9, LS2) * Pow(0.99, LN2) )*Cos(LPO)) // constrainX 防止坐标跑到地图外
    local real y = constrainY(GetUnitY(unitPowershotArrow) + (60* Pow(0.9, LS2) * Pow(0.99, LN2) )*Sin(LPO)) // 同上
    local group g = allocGroup()
    local real d
    if GetTriggerEvalCount(t) > 2 then
        set d = 150
    else
        set d = 75
    endif
    call DestroyEffect( AddSpecialEffect("effects\\Tornado.mdx", x, y) ) // 箭底下的小旋风的效果
    set LN2 = LN2 +  killDestructables(x, y, 75)
    call SaveInteger(hashTable, (hTrig), (354), (LN2))
    set windrunnerPowershotDamagedUnits = LQO  // 这几个变量名很长的都是全局变量,为了给下面的windrunnerPowershotDoDamage函数传递信息
    set windrunnerPowershotArrow = unitPowershotArrow
    set windrunnerPowershotInitialDamage = GFI
    set windrunnerPowershotDamagedDestructableCount = LN2
    set windrunnerPowershotDamagedUnitCount = LS2
    set FK = unitPowershotArrow
    call GroupEnumUnitsInRange(g, x, y, d, Condition(function filterUnitInjurable))
    call ForGroup(g, function windrunnerPowershotDoDamage)
    call releaseGroup(g)
    call SaveInteger(hashTable, (hTrig), (355), (windrunnerPowershotDamagedUnitCount))
    call SetUnitX(unitPowershotArrow, x)
    call SetUnitY(unitPowershotArrow, y)
    if GetTriggerEvalCount(t) > 29 then // 到地方了
        call KillUnit(unitPowershotArrow)
        call releaseGroup(LQO)
        call FlushChildHashtable(hashTable, (hTrig))
        call disableTriggerAndDestroyAfter1Min(t)
    endif
    set t = null
    set unitPowershotArrow = null
    set LQO = null
    set g = null
    return false
endfunction
function windrunnerPowershotStart takes nothing returns nothing // 开始射箭
    local unit u = GetTriggerUnit()
    local real x2 = ( LoadReal(hashTable, (GetHandleId(u)), (356)) )
    local real y2 = ( LoadReal(hashTable, (GetHandleId(u)), (357)) )
    local real damageFactor =  min((TimerGetElapsed(M)) - ( LoadReal(hashTable, (GetHandleId(u)), (358)) ), 1.0)
    // 上一句... 刚才在网上看到有人问,为什么强力击伤害不到360,楼下的人回复说LZ早泄,没有坚持1秒... 就是这一句搞的鬼了
    local real angle =  Atan2(y2 - GetUnitY(u), x2 - GetUnitX(u))
    local trigger t
    local integer hTrig
    local unit VDI
    local integer lvl =  GetUnitAbilityLevel(u, 'A12K') // A12K是强力击技能的id
    local real initialDamage = (40 + 80*lvl)*(damageFactor) // 计算初始伤害的时候考虑了早泄....
    set t = CreateTrigger()
    set hTrig = GetHandleId(t)
    set VDI =  CreateUnit(GetOwningPlayer(u), 'h078', GetUnitX(u), GetUnitY(u), angle*bj_RADTODEG)  // h078是箭的id
    set x2 = GetUnitX(u) + 1700*Cos(angle)
    set y2 = GetUnitY(u) + 1700*Sin(angle)
    call SaveUnitHandle(hashTable, (hTrig), (45), (VDI))
    call SaveReal(hashTable, (hTrig), (47), ((x2)*1.0))
    call SaveReal(hashTable, (hTrig), (48), ((y2)*1.0))
    call SaveReal(hashTable, (hTrig), (13), ((angle)*1.0))
    call SaveReal(hashTable, (hTrig), (20), ((initialDamage)*1.0))
    call SaveInteger(hashTable, (hTrig), (354), (0))
    call SaveInteger(hashTable, (hTrig), (355), (0))
    call SaveGroupHandle(hashTable, (hTrig), (187), (allocGroup()))
    call TriggerRegisterTimerEvent(t, 0.02, true)
    call TriggerAddCondition(t, Condition(function windrunnerPowershotLoop))
    set u = null
    set t = null
    set VDI = null
endfunction
function windrunnerPowershotPrepareFinish takes nothing returns boolean  // 结束吟唱
    local trigger t = GetTriggeringTrigger()
    local integer DMI = GetHandleId(t)
    local unit E1I = ( LoadUnitHandle(hashTable, (DMI), (14)) )
    call SetUnitTimeScale(E1I, 1)
    call FlushChildHashtable(hashTable, (DMI))
    call disableTriggerAndDestroyAfter1Min(t)
    set t = null
    set E1I = null
    return false
endfunction
function windrunnerPowershotPrepare takes nothing returns nothing // 开始吟唱
    local trigger t = CreateTrigger()
    local integer DMI = GetHandleId(t)
    local unit E1I = GetTriggerUnit()
    local location l = GetSpellTargetLoc()
    local real x = GetLocationX(l)
    local real y = GetLocationY(l)
    call RemoveLocation(l)
    call SaveReal(hashTable, (GetHandleId(E1I)), (356), ((x)*1.0))
    call SaveReal(hashTable, (GetHandleId(E1I)), (357), ((y)*1.0))
    call SaveReal(hashTable, (GetHandleId(E1I)), (358), (((TimerGetElapsed(M)))*1.0))
    call SetUnitTimeScale(E1I, 0.75)
    call SaveUnitHandle(hashTable, (DMI), (14), (E1I))
    call TriggerRegisterTimerEvent(t, 0.75, false)
    call TriggerRegisterUnitEvent(t, E1I, EVENT_UNIT_DEATH)
    call TriggerAddCondition(t, Condition(function windrunnerPowershotPrepareFinish))
    set t = null
    set E1I = null
endfunction
function windrunnerPowershot takes nothing returns boolean  // 入口
    if GetSpellAbilityId() == 'A12K' then
        if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_CAST then
            call SaveBoolean(hashTable, (GetHandleId(GetTriggerUnit())), (360), (false))
            call windrunnerPowershotPrepare()
        elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
            call SaveBoolean(hashTable, (GetHandleId(GetTriggerUnit())), (360), (true))
        elseif ( LoadBoolean(hashTable, (GetHandleId(GetTriggerUnit())), (360)) ) == true then
            call windrunnerPowershotStart()
        endif
    endif
    return false
endfunction
function windrunnerPowershotRegister takes nothing returns nothing // 初始化用的函数(在选择英雄选了风行的时候运行一下)
    local trigger t = CreateTrigger()
    call triggerRegisterAnyUnitEvent(t, EVENT_PLAYER_UNIT_SPELL_ENDCAST)
    call triggerRegisterAnyUnitEvent(t, EVENT_PLAYER_UNIT_SPELL_CAST)
    call triggerRegisterAnyUnitEvent(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function windrunnerPowershot))
    set t = null
endfunction
[/jass] |
|