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

[General] Not choosing specific player

Status
Not open for further replies.

Ardenian

A

Ardenian

  • Hero Choice
    • Events
      • Player - (Player(1)) selects a unit
    • Bedingungen
      • ((Owner of (Triggering unit)) controller) Equal Computer
    • Actions
      • Unit - Change ownership of (Triggering unit) to (Player(1)) and Change color
I would like to know how can I make this trigger work for every player and not only for a specific one.

I think it has something to do with unitgroup or unit index, but I would be glad if you could help me.
 

Ardenian

A

Ardenian

In the events, you need 12 events (one for each player)
In the actions, use "Event Response - Triggering Player"

Wait what ? You can use multiple events for one trigger ? o_O

Haha, if I had known this before...

Thank you!
 
Level 4
Joined
Jul 9, 2007
Messages
50
also, you can create those events with a loop in an initialisation trigger:
just do a For Each integer variable my_int loop with the action:
Trigger - Add the event: Player(my_int) selects a unit
you could also use integer A but this is faster

i always used this when i had multiple triggers for all players like chat commands
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
I wonder..

I have not tested this, this is 101% wild speculation. But I think you can use GetLocalPlayer() selects a unit. Then you would only need one event.

Basically convert the trigger to jass and then find the following linecall TriggerRegisterPlayerSelectionEventBJ(>trigger name<, Player(0) true )

Then just replace Player(x) with GetLocalPlayer()

call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Untitled_Trigger_001, GetLocalPlayer(), true )

It works for me in single player at least.

It's quite handy since it filters out players that aren't in the game automatically.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Yes it does work... but GetLocalPlayer() can only be done in JASS or custom scripts and we are talking about events in GUI.

If you indeed have an initialisation trigger which Varimathras mentioned, then you can use GetLocalPlayer()... but still have a custom script.
Unless you put GetLocalPlayer() inside a global variable which you can use over and over again the whole game without using GetLocalPlayer() during gametime.
Those tricks are awesome.

EDIT:
However... on the other hand it is quite dangerous.
The trigger only runs for the player who selects a unit.
That means that the selected unit is still of the original player for everyone else which causes the game to crash and disconnect people.
So one way, yes, it works, but it is dangerous.
 
Level 4
Joined
Jul 9, 2007
Messages
50
no, GetLocalPlayer() does not work
the trigger would only run on the computer of the player that selects the unit so the game will immediately desync the first time the trigger runs
GetLocalPlayer() can be only used for local functions like text messages, that do not affect the game itself
so just forget about this as you are not using JASS anyways
 

Ardenian

A

Ardenian

Hm, I see. I will think about it once more.

Thank you guys!
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
The trigger only runs for the player who selects a unit.

I doubt you to be honest. GetLocalPlayer doesn't automatically filter out things. It does if you check if TriggeringPlayer == GetLocalPlayer. However, we don't.

edit: or actually, as I re-read it, I am not so sure about my own statement tbh.

GetLocalPlayer() can be only used for local functions like text messages, that do not affect the game itself

I don't see how selecting a unit affects the game. It's true that you might need to work around a desync in worst case scenario though. (as said I have not tested this in multiplayer)

so just forget about this as you are not using JASS anyways
He did not specify that it had to be GUI. And there's nothing wrong with telling him of other options. I am not saying this method is the best.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I doubt you to be honest. GetLocalPlayer doesn't automatically filter out things. It does if you check if TriggeringPlayer == GetLocalPlayer. However, we don't.
Then you misunderstood the concept of GetLocalPlayer() completely.

My WC3 creates a trigger that runs when I select a unit.
Your WC3 creates a trigger that runs when you select a unit.
When I select a unit, your trigger does NOT run.
When you select a unit, my trigger does NOT run.
So the actions are only ran for you.

edit: or actually, as I re-read it, I am not so sure about my own statement tbh.
:D

I don't see how selecting a unit affects the game. It's true that you might need to work around a desync in worst case scenario though. (as said I have not tested this in multiplayer)
As I said, the event should work.
Running a trigger locally (because that is what happens) might create a desync.
If that is true, then the action referenced to the event bugs out and disconnects people... which makes the event totally useless.
Changing a unit's owner locally afects handles' behavior which does desync people for sure.
That is what the action does so this one would never work with GetLocalPlayer().

He did not specify that it had to be GUI. And there's nothing wrong with telling him of other options. I am not saying this method is the best.
But you know damn well that he is inexperienced in JASS and therefor has no way he will be wanting it for such a thing.
...
just some assumption that is 99% right :D
 

Ardenian

A

Ardenian

I am sorry, Chaosy, I thought it is clear because I posted a simple trigger.

Yeah, Wietlol, you are a 100% right, I didn't get a single fact of the Jass stuff.
Thanks anyway, I will just use the multiple events solution, although it is pretty difficult ( for me) to re-write the trigger so it won't run again for the same player ( without using player food). Had a hard time, trying it with buffs and so on, but solved it somehow.

Thank you guys!
 
Status
Not open for further replies.
Top