Renendaru
(Evol)ution is nothing without love.
- Reaction score
- 309
I've attempted to add a new value so when a play reclicks a unit it won't redisplay the message, it works but only for the second click. If you need to see the area in question look for first scope.
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()
if IsUnitSelected( d.SelectedUnit, d.SelectingPlayer) != true then
if GetLocalPlayer() != d.SelectingPlayer then
else
call ClearTextMessages()
if IsUnitInGroup(SelectedUnit[GetPlayerId(d.SelectingPlayer)], Pool) == true then
call DisplayTimedTextToPlayer( d.SelectingPlayer, 0, 0, 99999, Story[GetUnitIndex(SelectedUnit[GetPlayerId(d.SelectingPlayer)])])
endif
endif
set IsSelected = false
call d.release()
return true
else
return false
endif
endfunction
private function Actions takes nothing returns nothing
local Data d
local string s = "stand ready"
if IsSelected == false then
set d = Data[GetTriggerUnit()]
if d == 0 then
set d = Data.create()
set Data[GetTriggerUnit()] = d
endif
set d.SelectingPlayer = GetTriggerPlayer()
set d.SelectedUnit = GetTriggerUnit()
if GetLocalPlayer() != d.SelectingPlayer then
set s = ""
endif
call SetUnitAnimation(d.SelectedUnit, s)
call BJDebugMsg(I2S(GetUnitIndex(GetTriggerUnit())))
set IsSelected = true
call DisplayTimedTextToPlayer( d.SelectingPlayer, 0, 0, 99999, Story[GetUnitIndex(GetTriggerUnit())])
call KT_Add(function IsDeselected, d, .03125)
endif
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
//===========================================================================
scope PickHero initializer Init
//! runtextmacro PUI_PROPERTY("public", "boolean", "hasHero", "false")
private function Actions takes nothing returns nothing
local integer ut = GetUnitTypeId(GetTriggerUnit())
if hasHero[Hero[GetPlayerId(GetTriggerPlayer())]] == false then
call RemoveUnit(GetTriggerUnit())
set Hero[GetPlayerId(GetTriggerPlayer())] = CreateUnit( GetTriggerPlayer(), ut, -13765., 14239., 0.)
set hasHero[Hero[GetPlayerId(GetTriggerPlayer())]] = true
call BJDebugMsg(GetPlayerName(GetTriggerPlayer()) + " has chosen " + GetHeroProperName(Hero[GetPlayerId(GetTriggerPlayer())]) + "!")
else
endif
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 TriggerRegisterDoubleClickEvent(t)
endfunction
endscope
scope GetSelectedUnit initializer Init
globals
unit array SelectedUnit[11]
endglobals
private function Actions takes nothing returns boolean
set SelectedUnit[GetPlayerId(GetTriggerPlayer())] = GetTriggerUnit()
return false
endfunction
//==============================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerAddAction( t, function Actions)
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SELECTED)
endfunction
endscope