• 🏆 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!

GetSelectedUnit - Problem

Status
Not open for further replies.
Level 16
Joined
May 1, 2008
Messages
1,605
Dudes and girls - uberpros and beginners > I have a problem.

As you see in the title "GetSelectedUnit" mess up. First I remember that someone said "GetSelectedUnit" doesn't exist, but JassHelper itselt say, that "GetSelectedUnit" exist so....

But look at the trigger maybe I can take something different.

JASS:
function Trig_P_Aura_Jass_Actions takes nothing returns nothing
    local unit u = GetSelectedUnit  // Error: Undecleared function
    local location l = GetUnitLoc(u)
    
        if GetUnitTypeId(u) == 'h000' or GetUnitTypeId(u) == 'h001' then
            if GetEventPlayerChatString() == "1" then
                call UnitRemoveAbility(u, 'A000')
                call UnitRemoveAbility(u, 'A002')
                call UnitRemoveAbility(u, 'S000')
                call UnitRemoveAbility(u, 'A003')
                call UnitAddAbility(u, 'A001')
            endif
            if GetEventPlayerChatString() == "2" then
                call UnitRemoveAbility(u, 'A000')
                call UnitRemoveAbility(u, 'A001')
                call UnitRemoveAbility(u, 'S000')
                call UnitRemoveAbility(u, 'A003')
                call UnitAddAbility(u, 'A002')
            endif
            if GetEventPlayerChatString() == "3" then
                call UnitRemoveAbility(u, 'A000')
                call UnitRemoveAbility(u, 'A002')
                call UnitRemoveAbility(u, 'A001')
                call UnitRemoveAbility(u, 'A003')
                call UnitAddAbility(u, 'S000')
            endif
            if GetEventPlayerChatString() == "4" then
                call UnitRemoveAbility(u, 'A000')
                call UnitRemoveAbility(u, 'A002')
                call UnitRemoveAbility(u, 'S000')
                call UnitRemoveAbility(u, 'A001')
                call UnitAddAbility(u, 'A003')
            endif
        call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl" , l))
        set u = null
        call RemoveLocation(l)
        endif 
endfunction

//===========================================================================
function InitTrig_P_Aura_Jass takes nothing returns nothing
    set gg_trg_P_Aura_Jass = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_P_Aura_Jass, Player(0), "", false )
    call TriggerAddAction( gg_trg_P_Aura_Jass, function Trig_P_Aura_Jass_Actions )
endfunction
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
      • Unit - Kill (Triggering unit)
works
just tested it
every time you select a unit the unit will be killed
even works with drag-selection (will kill all selected units so the event will fire once for every selected unit in the selected unit group)

if you want something else or if I just did not understand your question directly (you are using chat events so I am not quite sute):
in GUI there also exists
  • Set g = (Units currently selected by Player 1 (Red))
might help you in any other case
 
Level 16
Joined
May 1, 2008
Messages
1,605
The think is - a player can type 1,2,3,4. For each number, the selected unit (but only if the selected unit is the paladin) the selected unit (the paladin) gets an ability...

I can set g = Unit currently ...... but how can I check the condition that the selected unit TYPE is the paladin ( got 2 different of them ) is true - because I player can select more units at the same time
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
The think is - a player can type 1,2,3,4. For each number, the selected unit (but only if the selected unit is the paladin) the selected unit (the paladin) gets an ability...

I can set g = Unit currently ...... but how can I check the condition that the selected unit TYPE is the paladin ( got 2 different of them ) is true - because I player can select more units at the same time

either save 1/2/3/4 for every player in an array and check on selection event

  • SetEnteredNumber
    • Events
      • Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
    • Conditions
    • Actions
      • Set EnteredNumber[(Player number of (Triggering player))] = (Integer((Entered chat string)))
  • SelectPala
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • EnteredNumber[(Player number of (Triggering player))] Equal to 1
          • (Unit-type of (Triggering unit)) Equal to Paladin
        • Then - Actions
        • Else - Actions

or pick every unit in unitgroup (g is a unitgroup) and check if the picked unit is the unit/unittype you want it to be
  • SelectPala
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
    • Set g = (Units currently selected by Player 1 (Red))
    • Unit Group - Pick every unit in g and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Unit-type of (Picked unit)) Equal to Paladin
          • Then - Actions
          • Else - Actions
you can add a condition
  • Actions
    • Set i = 0
    • Unit Group - Pick every unit in g and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • i Equal to 0
          • Then - Actions
            • Set i = 1
          • Else - Actions
(much easier with a FirstOfGroup JASS enumeration)

you can disable drag selection
  • Game - Disable drag-selection functionality (Disable drag-selection box)
 
Level 6
Joined
Mar 22, 2009
Messages
276
Dr.Boom try reading again your jass code. I can tell that it will not really work. GetSelectedUnit is different from GetSelectedUnit()
I just thought it may be the problem. :)
 
Status
Not open for further replies.
Top