• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] JASS question(s)

Status
Not open for further replies.
Level 1
Joined
May 5, 2005
Messages
1
I'm not exactly familiar with what is and isn't possible using JASS, but today while working on stuff I ran into a problem that is quite annoying. Blizzard doesn't have a premade Event Response - Selected Unit, and I was wondering if it would be possible to make my own after converting to custom text.

While I'm on these boards with so many smart people, I might as well ask another question of mine. Sometimes when I make triggers I find that variables of mine don't show up in dropdown menus when I feel they should. The very same trigger above has this problem. Event: Player X selects a unit. I have quite a few "player" variables but none of them show up. So just to check I made a playercolor and playergroup variable to see if they would show up, of course, they don't either.

Annoyed, I changed the trigger to custom text and made it use my global veriable. I'm not sure if Blizzard doesn't want you using your variables or what, but hopefully that isn't the case and this will work.
Code:
call TriggerRegisterPlayerSelectionEventBJ( gg_trg_NokThaloose, udg_WhoownsNok, true )

Any explanations or ideas as to why the WE does this?
 
Level 9
Joined
Aug 27, 2004
Messages
471
Selected unit is a unit-group funciton. You must convert the unit-group into a single unit.

Just get the group, and use first of group:
JASS:
function GetSelectedSingle takes group whichgroup, integer player returns unit
local unit PSU = FirstOfGroup(whichgroup)
set PSU = udg_EventResponse_PlayerSelectedUnit[(I2S(player))]
endfunction

How this works: Make a unit array called EventRespone_PlayerSelectedUnit, the usual way you make a variable for gui. Make it an array. Now in map initialization set EventRespone_PlayerSelectedUnit[1-max player] to "No unit".

Then call this function like normal jass, and you should be golden.
(This was not tested so im not 100% sure it works :P tell me if you get issues)
 
Level 3
Joined
Mar 27, 2004
Messages
70
Hmm.. somehow Modeler's post got messed up it seems.

Anyway, the selected unit can be gotten using: Event Response - Triggering Unit
The player who selected the unit can be gotten using: Event Response - Triggering Player

If you try to use a global in an event, it will not work because the global will be = null (aka No Unit) to begin with, and therefore will be equivalent of "Player X selects No Unit". Changing the variable later on will not affect the event.
 
Status
Not open for further replies.
Top