Renendaru
(Evol)ution is nothing without love.
- Reaction score
- 309
I'm having some issues with my hero selection trigger at the moment. The local animation show and stopping other hero's animations is what goes wrong.
JASS:
scope AnimationShow initializer Init
globals
private boolean IsSelected = false
endglobals
struct Data
//! runtextmacro PUI()
unit SelectedUnit
player SelectingPlayer
method onDestroy takes nothing returns nothing
set .SelectedUnit = null
set .SelectingPlayer = null
endmethod
endstruct
private function IsDeselected takes nothing returns boolean
local Data d = KT_GetData()
local unit u
local group g = CreateGroup()
local string s = "stand"
call GroupAddGroup(Pool, g)
if IsUnitSelected( d.SelectedUnit, d.SelectingPlayer) != true then
if GetLocalPlayer() != d.SelectingPlayer then
else
call ClearTextMessages()
loop
set u = FirstOfGroup(g)
exitwhen u == null
if d.SelectedUnit == u then
set s = ""
endif
if s == "" then
call GroupRemoveUnit(g, u)
else
call SetUnitAnimation(u, "stand")
call GroupRemoveUnit(g, u)
endif
endloop
if IsUnitInGroup(SelectedUnit[GetPlayerId(d.SelectingPlayer)], Pool) == true then
call DisplayTimedTextToPlayer( d.SelectingPlayer, 0, 0, 99999, Story[GetUnitIndex(SelectedUnit[GetPlayerId(d.SelectingPlayer)])])
return true
endif
endif
call d.release()
call DestroyGroup(g)
else
endif
return false
endfunction
private function Actions takes nothing returns boolean
local Data d
local string s = "stand ready"
if Hero[GetPlayerId(GetTriggerPlayer())] == null then
set d = Data[GetTriggerUnit()]
if d == 0 then
set d = Data.create()
set Data[GetTriggerUnit()] = d
endif
if GetLocalPlayer() != GetTriggerPlayer() then
else
call ClearTextMessages()
endif
set d.SelectingPlayer = GetTriggerPlayer()
set d.SelectedUnit = GetTriggerUnit()
if GetLocalPlayer() != d.SelectingPlayer then
set s = ""
endif
call SetUnitAnimation(d.SelectedUnit, s)
call BJDebugMsg("Current Index: " + I2S(GetUnitIndex(GetTriggerUnit())))
set IsSelected = true
call DisplayTimedTextToPlayer( d.SelectingPlayer, 0, 0, 99999, Story[GetUnitIndex(GetTriggerUnit())])
call KT_Add(function IsDeselected, d, .03125)
endif
return false
endfunction
private function Conditions takes nothing returns boolean
return IsUnitInGroup( GetTriggerUnit(), Pool) == true
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerAddAction( t, function Actions )
call TriggerAddCondition( t, Condition(function Conditions))
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SELECTED)
endfunction
endscope