MasterOfRa
New Member
- Reaction score
- 10
im working on a map, that uses custom enemy stats, like damage min, damage max, crit, critmult, and i have a multiboard for all players that displays those stats for them when they click on a enemy. it also hides it when they deselect it. However, if they select a enemy, and said enemy dies, then they select a allied unit, the multiboard stays. what can i do about this?
here is my code
here is my code
JASS:
library EnemySelection initializer init uses EnemyProperties
globals
private multiboard array MULTIBOARD
endglobals
private function ActionsSelected takes nothing returns nothing
local EnemyProperties data = GetUnitIndex(GetTriggerUnit())
local integer clicker = GetPlayerId(GetTriggerPlayer())
set MULTIBOARD[clicker] = CreateMultiboard()
call MultiboardSetRowCount( MULTIBOARD[clicker], 4)
call MultiboardSetColumnCount( MULTIBOARD[clicker], 2)
call MultiboardSetTitleText( MULTIBOARD[clicker], "Enemy Stats" )
call MultiboardSetItemIconBJ( MULTIBOARD[clicker], 1, 1, "ReplaceableTextures\\CommandButtons\\BTNThoriumMelee.blp" )
call MultiboardSetItemIconBJ( MULTIBOARD[clicker], 1, 2, "ReplaceableTextures\\CommandButtons\\BTNArcaniteMelee.blp" )
call MultiboardSetItemIconBJ( MULTIBOARD[clicker], 1, 3, "ReplaceableTextures\\CommandButtons\\BTNCleavingAttack.blp" )
call MultiboardSetItemIconBJ( MULTIBOARD[clicker], 1, 4, "ReplaceableTextures\\CommandButtons\\BTNCriticalStrike.blp" )
call MultiboardSetItemWidthBJ( MULTIBOARD[clicker], 1, 0, 9.00 )
call MultiboardSetItemValueBJ( MULTIBOARD[clicker], 1, 1, "Min Damage" )
call MultiboardSetItemValueBJ( MULTIBOARD[clicker], 1, 2, "Max Damage" )
call MultiboardSetItemValueBJ( MULTIBOARD[clicker], 1, 3, "Crit Chance" )
call MultiboardSetItemValueBJ( MULTIBOARD[clicker], 1, 4, "Crit Mult" )
call MultiboardSetItemStyleBJ( MULTIBOARD[clicker], 2, 0, true, false )
call MultiboardSetItemWidthBJ( MULTIBOARD[clicker], 2, 0, 5.00 )
call MultiboardSetItemValueBJ( MULTIBOARD[clicker], 2, 1, R2SW(data.damageMin ,1,1 ))
call MultiboardSetItemValueBJ( MULTIBOARD[clicker], 2, 2, R2SW(data.damageMax ,1,1 ))
call MultiboardSetItemValueBJ( MULTIBOARD[clicker], 2, 3, I2S(data.critChance ))
call MultiboardSetItemValueBJ( MULTIBOARD[clicker], 2, 4, R2SW(data.critMult ,1,1 ))
if GetLocalPlayer() == GetTriggerPlayer() then
call MultiboardDisplay(MULTIBOARD[clicker],true)
endif
endfunction
function ActionsDeselected takes nothing returns nothing
local integer clicker = GetPlayerId(GetTriggerPlayer())
call MultiboardDisplay(MULTIBOARD[clicker],false)
call DestroyMultiboard(MULTIBOARD[clicker])
endfunction
private function Conditions takes nothing returns boolean
if GetOwningPlayer(GetTriggerUnit()) == Player(11) then
return true
endif
return false
endfunction
private function init takes nothing returns nothing
local trigger trigSelect = CreateTrigger()
local trigger trigDeselect = CreateTrigger()
local integer count = 0
loop
exitwhen count >= 8
call TriggerRegisterPlayerUnitEvent(trigSelect , Player(count), EVENT_PLAYER_UNIT_SELECTED, null)
call TriggerRegisterPlayerUnitEvent(trigDeselect, Player(count), EVENT_PLAYER_UNIT_DESELECTED, null)
set count = count + 1
endloop
call TriggerAddCondition( trigSelect, Condition( function Conditions ) )
call TriggerAddAction( trigSelect, function ActionsSelected )
call TriggerAddCondition( trigDeselect, Condition( function Conditions ) )
call TriggerAddAction( trigDeselect, function ActionsDeselected )
endfunction
endlibrary