• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[JASS] Select Hero Skill Menu Bug

Status
Not open for further replies.
Hi,

I recently added a trigger that selects the hero skill menu each time the owner of a specific unit selects that unit. Because I didn't find the order string for it, I searched for the order id for hero skill menu, which is 852000.

The bug is that every other player also gets kicked into the hero skill menu of their respective hero, whenever the trigger is executed.

No idea why that happens. Does anyone know a workaround? Is there some other function that I should be using instead?

JASS:
//on hero initialization
call CreateNUnitsAtLoc( 1, 'H019', GetOwningPlayer(udg_wolflord), udg_temppoint, bj_UNIT_FACING )
set udg_companiontalents = GetLastCreatedUnit()
call TriggerRegisterUnitEvent( gg_trg_select_companion_talents, udg_companiontalents, EVENT_UNIT_SELECTED )

//the trigger itself
function Trig_select_companion_talents_Conditions takes nothing returns boolean
    if ( not ( GetHeroSkillPoints(udg_companiontalents) != 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_select_companion_talents_Actions takes nothing returns nothing
   call IssueImmediateOrderById(udg_companiontalents , 852000)
endfunction

//===========================================================================
function InitTrig_select_companion_talents takes nothing returns nothing
    set gg_trg_select_companion_talents = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_select_companion_talents, Condition( function Trig_select_companion_talents_Conditions ) )
    call TriggerAddAction( gg_trg_select_companion_talents, function Trig_select_companion_talents_Actions )
endfunction
 
Level 13
Joined
May 10, 2009
Messages
868
I guess the problem is that such event works for all users, and your trigger condition is only checking if the hero unspent point amount is not equal to 0, which means any player could force that hero to open the "skill menu". Now, that event will be a headache to you, because GetTriggerPlayer function will return the owner of triggering unit, which is pointless.

EDIT:
Use
  • Player - Player X Selects a unit
Then, in the conditions block you check if GetTriggerUnit() == udg_yourHeroVar and GetOwningPlayer(GetTriggerUnit()) == GetTriggerPlayer().

That way GetTriggerPlayer() returns the player who actually selected that specific hero.
 
Last edited:
Thanks for the replies!

To clarify, the other players get forced into their skill menu whenever the owner of companiontalents selects that unit. The others players cannot select it because it is invisible. When they open the skill menu by their own volition, everything is fine.

So, I don't think the event is what is broken but the action
JASS:
   call IssueImmediateOrderById(udg_companiontalents , 852000)

You probably overwrote "udg_companiontalents" variable mutiple times. Is this: call TriggerRegisterUnitEvent( gg_trg_select_companion_talents, udg_companiontalents, EVENT_UNIT_SELECTED ) called only once?
Double-checked the j-file by searching for "set udg_companiontalents". Didn't find anything that shouldn't be so.
 
Level 13
Joined
May 10, 2009
Messages
868
Yeah... that's the first time I witness such bug. It seems the order id forces all currently selected heroes to open their skill menu. Though, ordering normal units to perform that action won't do anything to others at all.

Well, detecting whether a hero has their skill menu open is the tough part. Otherwise, it'd be kinda easy to work around it.

Also, call IssueNeutralImmediateOrderById(GetOwningPlayer(GetTriggerUnit()), GetTriggerUnit(), 852000) gives the same result.
 
Level 13
Joined
May 10, 2009
Messages
868
I was actually trying to find a way of fixing that bug. Working around it would be possible with dialogs, trackables + floating texts, spell books, as you said, forcing a local player to press the exact hotkey for opening the skill menu, etc.
 
Last edited:
It seems the order id forces all currently selected heroes to open their skill menu.
I can confirm that. 852000 is useless.
I got simple solution but with one limit. To trigger open-menu action player is supposed to select only one hero. Because drag-selection and shift+click add to select actions may cause bugs I guess this limitation is acceptable.
(I don't know if allied players have shared unit's control from begining, or maybe when player left)
JASS:
globals
    string array    g_playerHotKey
endglobals

function InitHotKeys takes nothing returns nothing
    set g_playerHotKey[0] = "O"
    set g_playerHotKey[1] = "I"
    set g_playerHotKey[2] = "U"
    //etc..
endfunction
//--------------------------------------------------------------

function Trig_selection_Conditions takes nothing returns boolean
    return GetHeroSkillPoints(GetTriggerUnit())>0 and GetTriggerPlayer()==GetOwningPlayer(GetTriggerUnit())  
endfunction

//restrict open-menu action when player has only one hero selected
//--------------------------------------------------------------
function Trig_selection_Actions takes nothing returns nothing
    local unit u=GetTriggerUnit()
    local player p=GetOwningPlayer(u)
    local group g = CreateGroup()
  
    call SyncSelections()
    call GroupEnumUnitsSelected(g, p, null)
    if CountUnitsInGroup(g)==1 and IsUnitSelected(u, p) then  
        if (GetLocalPlayer() == p) then
            // Use only local code (no net traffic) within this block to avoid desyncs.
            call ForceUIKey(g_playerHotKey[GetPlayerId(p)])
        endif
    endif
  
    call DestroyGroup(g)
    set g=null
    set u=null
    set p=null
endfunction
//===========================================================================
function InitTrig_selection takes nothing returns nothing
    set gg_trg_selection = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_selection, Condition( function Trig_selection_Conditions ) )
    call TriggerAddAction( gg_trg_selection, function Trig_selection_Actions )
  
    call InitHotKeys()
  
endfunction

I used IsUnitSelected cause SyncSelection is not instant.
And remember to not use the same letter like "O" for any of hero skills (if player select already selected hero it will learn "O" ability), cause "O" opens skill menu.
 
Status
Not open for further replies.
Top