IsUnitSelected

TheOverWhelm

Member
Reaction score
16
Does IsUnitSelected even work? I tried it in the RPing map I've been developing and it doesn't seem to do its job, ever.
Trigger:
  • Custom script: if IsUnitSelected(GetEnumUnit(),Player(bj_forLoopAIndex))==true then
    • Unit Group - Remove (Picked unit) from SelectedUnits[(Integer A)]
    • Custom script: endif

This doesn't even remove them from the group. I've tried it with ==false as well but it still didn't work. I know the loop is working (messages, other conditions/actions too) so I have no idea what's wrong.
 

TheOverWhelm

Member
Reaction score
16
Trigger:
  • Events
    • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in SelectedUnits[AInt]) Not equal to (!=) 0
            • Then - Actions
              • Unit Group - Pick every unit in SelectedUnits[(Integer A)] and do (Actions)
                • Loop - Actions
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Multiple ConditionsOr - Any (Conditions) are true
                        • Conditions
                          • (Owner of (Picked unit)) Equal to (==) Neutral Hostile
                          • (Owner of (Picked unit)) Equal to (==) Neutral Passive
                          • ((Owner of (Picked unit)) slot status) Equal to (==) Has left the game
                          • ((Owner of (Picked unit)) slot status) Equal to (==) Is unused
                          • (Owner of (Picked unit)) Equal to (==) (Player((Integer A)))
                    • Then - Actions
                    • Else - Actions
                      • Unit Group - Remove (Picked unit) from SelectedUnits[(Integer A)]
                  • Custom script: if IsUnitSelected(GetEnumUnit(),Player(bj_forLoopAIndex))==true then
                  • Unit Group - Remove (Picked unit) from SelectedUnits[(Integer A)]
                  • Custom script: endif
            • Else - Actions
 

Bribe

vJass errors are legion
Reaction score
67
Post it in JASS, this is not the GUI forum. And also post the trigger that adds units to SelectedUnits (in JASS, of course).
 

TheOverWhelm

Member
Reaction score
16
The question I asked involved that, and there is JASS in there so it involves JASS and belongs in the JASS forum, nonetheless, here's the periodic trigger in JASS.
JASS:
function Trig_OtherSelectionSet2Periodic_Func001Func001Func001Func001Func002C takes nothing returns boolean
    if ( ( GetOwningPlayer(GetEnumUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetEnumUnit()) == Player(PLAYER_NEUTRAL_PASSIVE) ) ) then
        return true
    endif
    if ( ( GetPlayerSlotState(GetOwningPlayer(GetEnumUnit())) == PLAYER_SLOT_STATE_LEFT ) ) then
        return true
    endif
    if ( ( GetPlayerSlotState(GetOwningPlayer(GetEnumUnit())) == PLAYER_SLOT_STATE_EMPTY ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetEnumUnit()) == ConvertedPlayer(GetForLoopIndexA()) ) ) then
        return true
    endif
    return false
endfunction

function Trig_OtherSelectionSet2Periodic_Func001Func001Func001Func001C takes nothing returns boolean
    if ( not Trig_OtherSelectionSet2Periodic_Func001Func001Func001Func001Func002C() ) then
        return false
    endif
    return true
endfunction

function Trig_OtherSelectionSet2Periodic_Func001Func001Func001A takes nothing returns nothing
    if ( Trig_OtherSelectionSet2Periodic_Func001Func001Func001Func001C() ) then
    else
        call GroupRemoveUnitSimple( GetEnumUnit(), udg_SelectedUnits[GetForLoopIndexA()] )
    endif
endfunction

function Trig_OtherSelectionSet2Periodic_Func001Func001C takes nothing returns boolean
    if ( not ( CountUnitsInGroup(udg_SelectedUnits[udg_AInt]) != 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_OtherSelectionSet2Periodic_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 12
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if ( Trig_OtherSelectionSet2Periodic_Func001Func001C() ) then
            call ForGroupBJ( udg_SelectedUnits[GetForLoopIndexA()], function Trig_OtherSelectionSet2Periodic_Func001Func001Func001A )
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_OtherSelectionSet2Periodic takes nothing returns nothing
    set gg_trg_OtherSelectionSet2Periodic = CreateTrigger(  )
    call DisableTrigger( gg_trg_OtherSelectionSet2Periodic )
    call TriggerRegisterTimerEventPeriodic( gg_trg_OtherSelectionSet2Periodic, 1.00 )
    call TriggerAddAction( gg_trg_OtherSelectionSet2Periodic, function Trig_OtherSelectionSet2Periodic_Actions )
endfunction

The trigger that adds works perfectly.
 

Bribe

vJass errors are legion
Reaction score
67
Well, most JASS-ers (maybe all but one or two) have a much easier time looking at actual script, not GUI nor a corrupted demonchild of GUI and JASS.

Your first problem (if it's not intentional) you are using SelectedUnits[AInt] within the loop - don't you mean to use Integer A instead, because AInt is found only in this one place.

I will take a look around to see if I can find more.

1. You don't need to check if the group is empty before that "pick every unit". If the group is empty, nothing will happen, so there's no problem :)
 

TheOverWhelm

Member
Reaction score
16
I'm one of those few, then.
It was not intentional, fixed nonetheless.
The reason I check it is because checking something instead of performing a "nothing" is faster.
Err, I think I see it. I should add +1 to the Playernumber, since Player1 in GUI is not == Player1 in JASS.
 

Bribe

vJass errors are legion
Reaction score
67
It is not faster, because in "checking" it you're running the Jass "ForGroup" (count units in group) and in not checking it you're using "ForGroup" yet again. If you take out the "Is Group Empty" you will be running with higher efficiency & speed.

You're obviously not "one of those few" because you wrote this in GUI, not JASS, though I'm not going to get started on that so forget it.

Yes, now that I see that Player number thing, you should do:

Trigger:
  • Custom script: if IsUnitSelected(GetEnumUnit(),Player(bj_forLoopAIndex - 1)) then


You never need == true, that's just some nonsense GUI throws in. You also don't need == false, you just type "not" before the statement, like this:

JASS:
if not (check) or not (other check) then


It's faster to type & you can do more tricks with the "not" command.
 

Jedi

New Member
Reaction score
63
GUI has that condition.Under boolean comparasions, Unit - Unit Selected By Player.
 
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