HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

vJass Code Issue.

12-16-2016, 07:56 PM#1
DenisHellman
Hello everybody.

Move my topic to the correct thread, if I posted it wrong.

I'm super-new to vJASS. I decided to stop use GUI and now learning for code.

And I have 2 questions.

1. How to attach the effect to the hero that was just revieved after death and what native is best in my case. (code will be below the message)
2. How to simplify my code:

call TriggerRegisterPlayerUnitEventSimple( t, Player(0), EVENT_PLAYER_UNIT_DEATH )

As you can see, I'm just spam this 12 times for all players on the map, if there is any possible way to somehow make it more simple?

Explain and send me the finished fixed version, if possiblee.....

Collapse JASS:
scope GlobalRespawn initializer Init

private function Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true
endfunction

private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    call TriggerSleepAction( 10.00 )
    call ReviveHeroLoc( u, GetRandomLocInRect(GetPlayableMapRect()), true )
    call SetUnitManaPercent( u, 100 )
    call PanCameraToTimedLocForPlayer( GetOwningPlayer(u), GetUnitLoc(u), 0 )
    call AddSpecialEffectTarget( "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl", "origin", GetUnitX(u), GetUnitY(u) )
    call ClearSelectionForPlayer( GetOwningPlayer(u) )
    call SelectUnitForPlayerSingle( u, GetOwningPlayer(u)) )
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigget t = CreateTrigger()
    call TriggerRegisterPlayerUnitEventSimple( t, Player(0), EVENT_PLAYER_UNIT_DEATH )
    call TriggerRegisterPlayerUnitEventSimple( t, Player(1), EVENT_PLAYER_UNIT_DEATH )
    call TriggerRegisterPlayerUnitEventSimple( t, Player(2), EVENT_PLAYER_UNIT_DEATH )
    call TriggerRegisterPlayerUnitEventSimple( t, Player(3), EVENT_PLAYER_UNIT_DEATH )
    call TriggerRegisterPlayerUnitEventSimple( t, Player(4), EVENT_PLAYER_UNIT_DEATH )
    call TriggerRegisterPlayerUnitEventSimple( t, Player(5), EVENT_PLAYER_UNIT_DEATH )
    call TriggerRegisterPlayerUnitEventSimple( t, Player(6), EVENT_PLAYER_UNIT_DEATH )
    call TriggerRegisterPlayerUnitEventSimple( t, Player(7), EVENT_PLAYER_UNIT_DEATH )
    call TriggerRegisterPlayerUnitEventSimple( t, Player(8), EVENT_PLAYER_UNIT_DEATH )
    call TriggerRegisterPlayerUnitEventSimple( t, Player(9), EVENT_PLAYER_UNIT_DEATH )
    call TriggerRegisterPlayerUnitEventSimple( t, Player(10), EVENT_PLAYER_UNIT_DEATH )
    call TriggerRegisterPlayerUnitEventSimple( t, Player(11), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
endfunction

endscope

Thank you all!
01-06-2017, 07:18 PM#2
Anitarf
1. You could simply give the hero an ability that attaches an effect.
2. call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )