- Joined
- Jun 26, 2020
- Messages
- 1,928
I have these 3 triggers to select a reviving hero (and another things) only if the player doesn't have selected a controllable unit, but they doesn't work fine because it happens even without complying with this rule, what's wrong?
When you select a unit:
When you deselect and don't have selected a unit
The trigger to select the reviving hero:
When you select a unit:
vJASS:
function Trig_Para_no_deseleccionar_Actions takes nothing returns nothing
if GetOwningPlayer(GetTriggerUnit())==GetTriggerPlayer() or GetPlayerAlliance(GetOwningPlayer(GetTriggerUnit()),GetTriggerPlayer(),ALLIANCE_SHARED_CONTROL) then
set udg_Tengo_a_alguien_seleccionado[GetConvertedPlayerId(GetTriggerPlayer())]=true
else
set udg_Tengo_a_alguien_seleccionado[GetConvertedPlayerId(GetTriggerPlayer())]=false
endif
endfunction
//===========================================================================
function InitTrig_Para_no_deseleccionar takes nothing returns nothing
local integer i=1
set gg_trg_Para_no_deseleccionar=CreateTrigger()
loop
exitwhen i>11
if i!=6 then
call TriggerRegisterPlayerSelectionEventBJ(gg_trg_Para_no_deseleccionar,Player(i),true)
endif
set i=i+1
endloop
call TriggerAddAction(gg_trg_Para_no_deseleccionar,function Trig_Para_no_deseleccionar_Actions)
endfunction
vJASS:
function Trig_Ya_no_Conditions takes nothing returns boolean
return IsUnitSelected(null,GetTriggerPlayer())
endfunction
function Trig_Ya_no_Actions takes nothing returns nothing
set udg_Tengo_a_alguien_seleccionado[GetConvertedPlayerId(GetTriggerPlayer())]=false
endfunction
//===========================================================================
function InitTrig_Ya_no takes nothing returns nothing
local integer i=1
set gg_trg_Ya_no=CreateTrigger()
loop
exitwhen i>11
if i!=6 then
call TriggerRegisterPlayerSelectionEventBJ(gg_trg_Ya_no,Player(i),false)
endif
set i=i+1
endloop
call TriggerAddCondition(gg_trg_Ya_no,Condition(function Trig_Ya_no_Conditions))
call TriggerAddAction(gg_trg_Ya_no,function Trig_Ya_no_Actions)
endfunction
vJASS:
function Trig_Seleccion_Actions takes nothing returns nothing
local location l
local unit h=GetRevivingUnit()
local player p=GetOwningPlayer(h)
if not udg_Tengo_a_alguien_seleccionado[GetConvertedPlayerId(p)] then
if LocalPlayer==p then
call ClearSelection()
call SelectUnit(h,true)
endif
set l=GetUnitLoc(h)
call PanCameraToTimedLocForPlayer(p,l,0)
call RemoveLocation(l)
else
call DisplayTextToPlayer(p,0,0,"|cff61dbffYour hero has resurrected|r")
endif
set l=null
endfunction
//===========================================================================
function InitTrig_Seleccion takes nothing returns nothing
set gg_trg_Seleccion=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Seleccion,EVENT_PLAYER_HERO_REVIVE_FINISH)
call TriggerAddAction(gg_trg_Seleccion,function Trig_Seleccion_Actions)
endfunction