• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Aphotic Shield needs some fixes...

Level 14
Joined
Jul 19, 2007
Messages
772
I have problem with the "Aphotic Shield" ability I imported into my map because it sometimes happening after about 10 mins of gameplay that the ability isn't working at all, it creates the special sfx-shield on the target but it doesn't absorb any damage anymore or dealing it's absorbed damage to enemies and the special sfx-sheild isn't removed either. Also I want it to NOT damage structures and magic immunity units when it is destroyed. Could some helpful soul fix this?
JASS:
//TESH.scrollpos=70
//TESH.alwaysfold=0
scope AphoticShield initializer Init

function H2I takes handle h returns integer
    return GetHandleId(h)
endfunction

globals
    private constant integer AbilId = 'A0J5'
   
    private trigger array Trig
    private integer I
endglobals
private struct data
    unit u
    integer lvl
    effect sfx
    real hp
    trigger t
   
    method onDestroy takes nothing returns nothing
        call DestroyTriggerEx(.t)
        call DestroyEffect(.sfx)
        set Trig[H2I(.u)-0x100000] = null
    endmethod
endstruct

private function Explode takes nothing returns boolean
    local data d = I
    local unit targ = GetFilterUnit()
   
    if IsUnitEnemy(targ,GetOwningPlayer(d.u)) and GetWidgetLife(targ)>.405 then   
        call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl",targ,"chest"))
        call UnitDamageTargetEx(d.u, targ, d.hp, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_SPELL, false)
    endif
   
    set targ = null
    return false
endfunction
private function Effects takes nothing returns boolean
    local data d=GetTriggerData(GetTriggeringTrigger())
    local group g
   
    if GetTriggerEventId()==EVENT_UNIT_DAMAGED then
        if IsUnitInGroup(d.u,BorrowedTime_G) then
            return false
        elseif d.hp<GetEventDamage() then
            call ShieldUnit(d.u,d.hp,GetEventDamage())
            set d.hp = 80.+30.*d.lvl
            set g = NewGroup()
            set I = d
            call GroupEnumUnitsInRange(g,GetUnitX(d.u),GetUnitY(d.u),700.,Condition(function Explode))
            call ReleaseGroup(g)
            call d.destroy()
        elseif GetEventDamage()>0.01 then
            set d.hp = d.hp - GetEventDamage()
            call ShieldUnit(d.u,GetEventDamage(),GetEventDamage())
        endif
    else
        call d.destroy()
    endif
   
    return false
endfunction
private function Actions takes nothing returns nothing
    local data d = data.create()
   
    if Trig[H2I(GetSpellTargetUnit())-0x100000] != null then
        call TriggerEvaluate(Trig[H2I(GetSpellTargetUnit())-0x100000])
    endif
   
    set d.t=CreateTrigger()
    set d.u=GetSpellTargetUnit()
    set d.lvl=GetUnitAbilityLevel(GetTriggerUnit(),AbilId)
    set d.hp=80.+30.*d.lvl
    set d.sfx=AddSpecialEffectTarget("sfx\\AphoticShield.mdx",d.u,"chest")
   
    call UnitRemoveBuffs(d.u,false,true)
    set Trig[H2I(d.u)-0x100000] = d.t
   
    call SetTriggerData(d.t,d)
    call TriggerRegisterUnitEvent(d.t,d.u,EVENT_UNIT_DAMAGED)
    call TriggerRegisterTimerEvent(d.t,15.,false)
    call TriggerAddCondition(d.t,Condition(function Effects))
endfunction

private function Conds takes nothing returns boolean
    if GetSpellAbilityId()==AbilId then
        call Actions()
    endif
   
    return false
endfunction
private function Init takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t,Condition(function Conds))
endfunction

endscope
 
Last edited:
Top