• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] Why doesn't it work?

Status
Not open for further replies.
Level 8
Joined
Jul 28, 2008
Messages
211
I tried making a spell similar to one i saw in a map i played.
It's simple, it's supposed to block all damage the caster takes for some time.
But, it doesn't work. Here's my script :

JASS:
function Trig_Wave_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'shie'
endfunction

function Wave_Child takes nothing returns nothing
    local real damage = GetEventDamage()
    local unit u = GetHandleUnit( GetTriggeringTrigger(), "cache")
    call SetUnitState( u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE) + damage )
endfunction

function Trig_Wave_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local timer time = CreateTimer()
    local trigger trig = CreateTrigger()
    local triggeraction ta
    call SetHandleHandle(trig, "cache", caster)
    
    set ta = TriggerAddAction( trig, function Wave_Child )
    call TriggerRegisterUnitEvent( trig, caster, EVENT_UNIT_ATTACKED )



    call TimerStart( time, 15, false, null )
    loop
      exitwhen TimerGetRemaining(time) == 0
      call TriggerSleepAction(0.1)
    endloop
    set ta = null
    set trig = null
    set caster = null
    call DestroyTimer(time)
    set time = null
endfunction

//===========================================================================
function InitTrig_Shield takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition ( function Trig_Wave_Conditions ) )
    call TriggerAddAction( t, function Trig_Wave_Actions )
endfunction

Thx in advance
 
I tried making a spell similar to one i saw in a map i played.
It's simple, it's supposed to block all damage the caster takes for some time.
But, it doesn't work. Here's my script :

JASS:
Destoyer95 script
Thx in advance
I tried copying your script into my WE but it gives me a Syntax error; is your problem in the syntax or it doesn't work when testing the map.
 
Actualy, it gave me an error too. It said that functions SetHandleHandle and GetHandleUnit do not exist or something like that ( i copied them into my map ). I closed the editor and tried to run it again, and it worked. I saved my map with no syntax errors and when i tried to cast the spell in game, it didn't block damage.

Oh yea i almost forgot, you need to copy kattana's system to your map so it wouldn't give you syntax errors.
 
JASS:
    call TimerStart( time, 15, false, null )
    loop
      exitwhen TimerGetRemaining(time) == 0
      call TriggerSleepAction(0.1)
    endloop

What are you thinking or what are you trying to do? I see you are using LHV, it's a old outdated resource use TimerUtils instead.

JASS:
    set ta = TriggerAddAction( trig, function Wave_Child )
    call TriggerRegisterUnitEvent( trig, caster, EVENT_UNIT_ATTACKED )

?? You can move that TriggerAddAction to your initialization and are you sure trig is created? Meaning you did a CreateTrigger().

EVEN_UNIT_ATTACK fires before a missle or damage gets to the target so it wouldn't work, use EVENT_UNIT_DAMAGED
 
Status
Not open for further replies.
Back
Top