• 🏆 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!

need help jass trig wont work!!

Status
Not open for further replies.
Level 1
Joined
Nov 2, 2009
Messages
2
need help with this trig

shield damage

JASS:
function GetShieldBuff takes nothing returns integer
    return 'B00Y'
endfunction
function GetShieldDeadFixer takes nothing returns integer
    return 'A02X'
endfunction
//====================================================
function Trig_Shield_Damage_Actions_Child takes nothing returns nothing
    local timer x = GetExpiredTimer()
    local real special = GetHandleReal( x, "special" )
    local unit ouch = GetHandleUnit( x, "unit" )
    local real dmg = GetHandleReal( x, "dmg" )
    if special < 0.00 then
        call SetUnitLifeBJ( ouch, ( GetUnitStateSwap(UNIT_STATE_LIFE, ouch) + dmg ) )
        set special = RAbsBJ(special)
        call SetUnitLifeBJ( ouch, ( GetUnitStateSwap(UNIT_STATE_LIFE, ouch) - special ) )
        set special = 0.00
        call UnitRemoveBuffBJ( GetShieldBuff(), ouch )
        call SetHandleReal( GetTriggerUnit(), "shieldmax", 0.00)
        set udg_retrive = GetHandleTextTag( ouch, "float" )
        call SetHandleHandle( ouch, "float", null)
        call DestroyTextTagBJ( udg_retrive )
    else
        call SetUnitLifeBJ( ouch, ( GetUnitStateSwap(UNIT_STATE_LIFE, ouch) + dmg ) )
    endif
    call UnitRemoveAbilityBJ( GetShieldDeadFixer(), ouch )
    call SetHandleReal( ouch, "shield", special )
    set x = null
endfunction

function Trig_Shield_Damage_Actions takes nothing returns nothing
    local timer x = CreateTimer()
    local real special = GetHandleReal(  GetTriggerUnit(), "shield" )
    local effect fx
    call UnitAddAbilityBJ( GetShieldDeadFixer(), GetTriggerUnit() )
    if GetEventDamage() == 0 then
        call UnitRemoveAbilityBJ( GetShieldDeadFixer(), GetTriggerUnit() )
        set x = null
        return
    endif
    if special == 0 then
        call UnitRemoveAbilityBJ( GetShieldDeadFixer(), GetTriggerUnit())
        set x = null
        return
    endif
    if UnitHasBuffBJ(GetTriggerUnit(), GetShieldBuff()) == false then
        call SetHandleReal( GetTriggerUnit(), "shieldmax", 0.00)
        set udg_retrive = GetHandleTextTag( GetTriggerUnit(), "float" )
        call SetHandleHandle( GetTriggerUnit(), "float", null)
        call DestroyTextTagBJ( udg_retrive )
        call UnitRemoveAbilityBJ( GetShieldDeadFixer(), GetTriggerUnit() )
        set x = null
        return
    endif
    set fx = AddSpecialEffectTargetUnitBJ( "origin", GetTriggerUnit(), "Abilities\\Spells\\Human\\Defend\\DefendCaster.mdl" )
    call DestroyEffectBJ( fx )
    set special = special - GetEventDamage()
    call SetHandleHandle( x, "unit", GetTriggerUnit() )
    call SetHandleReal( x, "special", special )
    call SetHandleReal( x, "dmg", GetEventDamage() )
    call TimerStart(x, 0.01, false, function Trig_Shield_Damage_Actions_Child)
    set x = null
endfunction

//===========================================================================
function InitTrig_Shield_Damage takes nothing returns nothing
    set gg_trg_Shield_Damage = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Shield_Damage, function Trig_Shield_Damage_Actions )
endfunction
//===========================================================================
 
Status
Not open for further replies.
Top