What is the eventid for TriggerRegisterUnitInRange?

chobibo

Level 1 Crypt Lord
Reaction score
48
extract the common.j from your warcraft MPQ or you could look at Jass New Gen's function list.
 

Gwypaas

hook DoNothing MakeGUIUsersCrash
Reaction score
50
Try making a Trigger using TriggerRegisterUnitInRange to fire it and then use GetTriggerEventId() in the action?
 

Magoiche

Member
Reaction score
20
No because my trigger have an initial event to run.
When the first event run. It add another event. In this case TriggerRegisterUnitInRange.
So i have a if. If the eventid = to the TriggerRegisterUnitInRange event id i do something, else i do other things.

JASS:
scope EmoBomb initializer Initial

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A002' or GetTriggerEventId() == EVENT_UNIT_TARGET_IN_RANGE
endfunction

private function KillConditions takes nothing returns boolean
    return IsUnitEnemy( GetFilterUnit(), GetOwningPlayer( GetTriggerUnit() ) ) == true and GetUnitState( GetFilterUnit(), UNIT_STATE_LIFE ) <= 300
endfunction

private function ExplodeConditions takes nothing returns boolean
    return IsUnitEnemy( GetFilterUnit(), GetOwningPlayer( GetTriggerUnit() ) ) == true and GetUnitState( GetFilterUnit(), UNIT_STATE_LIFE ) > 0
endfunction

private function Kill takes nothing returns nothing
    call KillUnit( GetEnumUnit() )
endfunction

private function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local real x
    local real y
    local unit Dummy
    local real Dummyx
    local real Dummyy
    local group UnitsNear
    local integer NOfUnitsNear
    local integer NOfUnitsToExplode = 7 - ( GetUnitAbilityLevel( Caster, 'A002' ) )
    if GetTriggerEventId() == EVENT_UNIT_TARGET_IN_RANGE then
        set UnitsNear = GetUnitsInRangeOfLocMatching( 400, GetUnitLoc( Dummy ) , Condition( function ExplodeConditions ) )
        set NOfUnitsNear = CountUnitsInGroup2( UnitsNear )
            if NOfUnitsNear == NOfUnitsToExplode then
                set Dummyx = GetUnitX( Dummy )
                set Dummyy = GetUnitY( Dummy )
                call KillUnit( Dummy )
                set Dummy = CreateUnit( GetOwningPlayer( Caster ), 'u000', Dummyx, Dummyy, 0 )
                call SetUnitAnimation( Dummy, 'birth' )
                call UnitApplyTimedLife( Dummy, 'BTLF', 5.00 )
                call UnitAddAbility( Dummy, 'A001' )
                call IssueTargetOrder( Dummy, "selfdestruct", Dummy )
                set UnitsNear = GetUnitsInRangeOfLocMatching( 400, GetUnitLoc( Dummy ) , Condition( function KillConditions ) )
                call ForGroup( UnitsNear, function Kill )
            endif
    else
        set Dummy = CreateUnitAtLoc( GetOwningPlayer( Caster ), 'u000', GetSpellTargetLoc(), 0.00 )
        call TriggerRegisterUnitInRange( GetTriggeringTrigger(), Dummy, 400.00, BoolexprTrue )
    endif
endfunction

private function Initial takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions )
    set trig = null
endfunction

endscope


So i want to know exactly what is the eventid for TriggerRegisterUnitInRange.
 

Magoiche

Member
Reaction score
20
No, its not it.
It dont work.

The EVENT_UNIT_TARGET_IN_RANGE its for GetEventTargetUnit events.
So says the commom.j
=]
 

Magoiche

Member
Reaction score
20
Yeah T.T
Maybe there is no eventid for this event(lol?)
So i will have to give up my emo bomb spell.
T.T

Thanks to everyone anyway.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
EVENT_UNIT_TARGET_IN_RANGE is the right event, i've tested, put some BJDebugMsg to know what it happens.
 

Magoiche

Member
Reaction score
20
It do not worked. =/

This is the trigger:
JASS:
scope EmoBomb initializer Initial

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A002' or GetTriggerEventId() == ConvertUnitEvent( 61 )
endfunction

private function KillConditions takes nothing returns boolean
    return GetUnitState( GetFilterUnit(), UNIT_STATE_LIFE ) <= 300 and IsUnitEnemy( GetFilterUnit(), GetOwningPlayer( GetTriggerUnit() ) ) == true
endfunction

private function ExplodeConditions takes nothing returns boolean
    return GetUnitState( GetFilterUnit(), UNIT_STATE_LIFE ) > 0 and IsUnitEnemy( GetFilterUnit(), GetOwningPlayer( GetTriggerUnit() ) ) == true
endfunction

private function Kill takes nothing returns nothing
    call KillUnit( GetEnumUnit() )
endfunction

private function Actions takes nothing returns nothing
    local unit Caster
    local unit Dummy
    local real Dummyx
    local real Dummyy
    local group UnitsNear
    local integer NOfUnitsToExplode = 2//7 - ( GetUnitAbilityLevel( Caster, 'A002' ) )
    if GetTriggerEventId() == ConvertUnitEvent( 61 ) then
        set UnitsNear = GetUnitsInRangeOfLocMatching( 400, GetUnitLoc( Dummy ) , Condition( function ExplodeConditions ) )
        if CountUnitsInGroup( UnitsNear ) == NOfUnitsToExplode then
            call BJDebugMsg( "Test" )
            set Dummyx = GetUnitX( Dummy )
            set Dummyy = GetUnitY( Dummy )
            call KillUnit( Dummy )
            set Dummy = CreateUnit( GetOwningPlayer( Caster ), 'u001', Dummyx, Dummyy, 0 )
            call SetUnitAnimation( Dummy, "birth" )
            call UnitApplyTimedLife( Dummy, 'BTLF', 10.00 )
            set Dummy = CreateUnit( GetOwningPlayer( Caster ), 'u001', Dummyx, Dummyy, 0 )
            call UnitAddAbility( Dummy, 'A001' )
            call IssueTargetOrder( Dummy, "selfdestruct", Dummy )
            set UnitsNear = GetUnitsInRangeOfLocMatching( 400, GetUnitLoc( Dummy ) , Condition( function KillConditions ) )
            call ForGroup( UnitsNear, function Kill )
        endif
    else
        set Caster = GetTriggerUnit()
        set Dummy = CreateUnitAtLoc( GetOwningPlayer( Caster ), 'u000', GetSpellTargetLoc(), 0.00 )
        call TriggerRegisterUnitInRange( GetTriggeringTrigger(), Dummy, 400.00, BoolexprTrue )
    endif
endfunction

private function Initial takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions )
    set trig = null
endfunction

endscope


This is the part that don't work:
JASS:
        if CountUnitsInGroup( UnitsNear ) == NOfUnitsToExplode then
            call BJDebugMsg( "Test" )
            set Dummyx = GetUnitX( Dummy )
            set Dummyy = GetUnitY( Dummy )
            call KillUnit( Dummy )
            set Dummy = CreateUnit( GetOwningPlayer( Caster ), 'u001', Dummyx, Dummyy, 0 )
            call SetUnitAnimation( Dummy, "birth" )
            call UnitApplyTimedLife( Dummy, 'BTLF', 10.00 )
            set Dummy = CreateUnit( GetOwningPlayer( Caster ), 'u001', Dummyx, Dummyy, 0 )
            call UnitAddAbility( Dummy, 'A001' )
            call IssueTargetOrder( Dummy, "selfdestruct", Dummy )
            set UnitsNear = GetUnitsInRangeOfLocMatching( 400, GetUnitLoc( Dummy ) , Condition( function KillConditions ) )
            call ForGroup( UnitsNear, function Kill )
        endif


I still can't figure what is the problem.
Everything seens just fine.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
if CountUnitsInGroup( UnitsNear ) == NOfUnitsToExplode

I guess there are more or less than 2 units in the group, so the if is false.
And use the constant event to keep the readability of your code.
 

Magoiche

Member
Reaction score
20
Are you saying that locals only exists in that same trigger run?
I didn't know that. x.x

So i made it a global. And it worked! *-*

Thanks everyone i.i

+rep =]
 

Magoiche

Member
Reaction score
20
Yeah... i.i

So... What i have to do? If its not a global i don't know how to make it work.
You know how? x.x
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top