• 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.

[Spell] Why this trigger does not work? Just couldn't figure out...

Status
Not open for further replies.
Level 11
Joined
Oct 11, 2012
Messages
711
Don't know why the following trigger does not work. The event just did not fire.... Need help please

JASS:
function bangmang takes nothing returns nothing
    call SetUnitInvulnerable(gg_unit_H00F_0198,false) 
    call DisableTrigger(LoadTriggerHandle(udg_chongfeng1,5,0))
    call DestroyTrigger(LoadTriggerHandle(udg_chongfeng1,5,0))
    call FlushChildHashtable(udg_chongfeng1,5)
    call ReleaseTimer(GetExpiredTimer())   
endfunction
function Trig_bangmang_Actions takes nothing returns boolean
    local timer t =NewTimer()
    call DisplayTimedTextToForce(udg_wanjiazu,1.,"|cFFFF0000Debug!|r")
    call SetUnitState(gg_unit_H00F_0198, UNIT_STATE_LIFE, GetUnitState(gg_unit_H00F_0198, UNIT_STATE_MAX_LIFE))
    call UnitRemoveBuffs(gg_unit_H00F_0198,false,true)
    call DisplayTimedTextToForce(udg_wanjiazu,30,"TRIGSTR_15427")
    call SetUnitInvulnerable(gg_unit_H00F_0198,true)
    call SaveTriggerHandle(udg_chongfeng1,5,0,GetTriggeringTrigger())        
    call TimerStart(t,60.,false,function bangmang)
    set t=null
    return false
endfunction
function InitTrig_bangmang takes nothing returns nothing
    set gg_trg_bangmang=CreateTrigger()
    call TriggerRegisterUnitStateEvent(gg_trg_bangmang,gg_unit_H00F_0198,UNIT_STATE_LIFE,LESS_THAN,80000.)
    call TriggerAddCondition(gg_trg_bangmang,Condition(function Trig_bangmang_Actions))
endfunction

Edit: figured out why it did not work... I declared a local variable as following that made the trigger unable to execute:
local real x = xbase + 450. * Cos((I2R(angleUp)*60.) * bj_DEGTORAD)
 
Last edited:
Level 21
Joined
Mar 2, 2010
Messages
3,069
ok. that is all the information i need to start working. i will create an example map and upload it here but it shouldnt take too long. what i did was create an event that checks the unit`s hp to trigger when it activates then, i added a unit action that made that unit invulnerable followed by a 60 seconds wait after which another action triggeres that makes it vulnerable. i tested it myself and it works perfectly.
 

Attachments

  • invulnerability example.w3x
    16.6 KB · Views: 29
Level 11
Joined
Oct 11, 2012
Messages
711
What was the problem with the local?


Sorry, I didn't clarify that. I declared that local and then used it in a loop and set angleUp=angleUp+1, it looks like the following:
JASS:
function A takes nothing returns nothing
   local real x = xbase + 450. * Cos((I2R(angleUp)*60.) * bj_DEGTORAD)
   ......
   loop
        exitwhen i > X
        call CreateUnit(....x,y,....)
        set angleUp=angleUp+1
        ....
   endloop
endfunction

This caused the problem, it should be like the following:

JASS:
function A takes nothing returns nothing
   local real x
   ......
   loop
        exitwhen i > X
        set x = xbase + 450. * Cos((I2R(angleUp)*60.) * bj_DEGTORAD)
        .....
        call CreateUnit(....x,y,....)
        set angleUp=angleUp+1
        ....
   endloop
endfunction
 
Status
Not open for further replies.
Top