Animation showing issues

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
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
I know it's messy, I've been playing around with it alot. The problem is only where it's supposed to play the local animations, and then stop them when you click on another unit.
 

quraji

zap
Reaction score
144
Well, assuming that you actually can play local animations, try this:

JASS:

scope AnimationShow initializer Init

globals
    private constant integer MAX_PLAYERS = 12
    private constant string ANIM_ACTIVE = "stand ready"
    private constant string ANIM_IDLE = "stand"

    private unit array SelectedUnit [MAX_PLAYERS] //one unit for each player
endglobals

private function callback takes nothing returns nothing
    local unit u = GetEnumUnit()
    local integer i = 0
    local string anim = ANIM_IDLE
    loop
        exitwhen (i==MAX_PLAYERS)
        if (u==SelectedUnit<i> and GetLocalPlayer()==Player(i)) then
            set anim = ANIM_ACTIVE
            exitwhen (true)
        endif
        set i = i+1
    endloop
    call SetUnitAnimation(u, anim)
endfunction

private function Actions takes nothing returns nothing
    local player  p = GetTriggerPlayer()
    local integer id = GetPlayerId(p)
    
    set SelectedUnit[id] = GetTriggerUnit()
    if (GetLocalPlayer()==p) then
        call ClearTextMessages()
    endif
    call DisplayTimedTextToPlayer(p, 0., 0., 99999., Story[GetUnitIndex(SelectedUnit[id])])
    call ForGroup(Pool, function callback)    
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


</i>
 
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