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

Detect Local Player Click Event ?

Status
Not open for further replies.

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
Hi Everyone,

I would like to get help on finding a local player event....

Here what i need:
I have a map where team player share their building....
Building have the (shop_ability) wich enable friendly player to use the building ability.
The problem is that i would need to detect wich player used the ability...
if i do (owner of casting unit) it won't work because the building doesn't necessarily belong to the player who click the ability.


Actually there is no way to know wich player did it....
but since the order came from one computer, there should be a way to detect wich player activated the ability by clicking on it.


I suppose JASS is the only way to track this, but i don't know JASS, so could someone who know JASS help me?
Checking wich player selected the building is a way, but many players can select the building at same time wich wouldn't help much...

Thanks for your time...and hoping someone has the solution...
 
Level 11
Joined
May 31, 2008
Messages
698
One way you could do it, is just make a dummy unit and make a dummy item.
So each player would have a dummy unit next to the building, this unit should have no model (its invisible) and it should have the ability "locust". It also needs an inventory.
Now make the "ability" an item. This way, whenever someone uses the "ability", what would actually happen is the dummy unit would buy the item.
And i believe that you can track this and see what player bought the item.
You can trigger the rest of it as far as casting the ability and whatnot, i can explain more if you want
 

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
Actually what you said gave me an idea....
the unit things and items wouldn't work well on my map but....

maybe the Camp wich are selling unit to all player...
if the camp belong to a specific player but is used by another player the unit created will belong to the player who clicked the unit to buy and not the owner of the building...
this way i could detect who clicked the ability by detecting the owner of the sold unit.

^^

but if there are way i can use with normal ability i am interested, it would be annoying to change all the building of my map to create unit instead of using ability...since the ability effect are already triggered and everything is linked... the player detection is just a bonus that would be good to have...
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Actually what you said gave me an idea....
the unit things and items wouldn't work well on my map but....

maybe the Camp wich are selling unit to all player...
if the camp belong to a specific player but is used by another player the unit created will belong to the player who clicked the unit to buy and not the owner of the building...
this way i could detect who clicked the ability by detecting the owner of the sold unit.

^^

but if there are way i can use with normal ability i am interested, it would be annoying to change all the building of my map to create unit instead of using ability...since the ability effect are already triggered and everything is linked... the player detection is just a bonus that would be good to have...

couldn't you just create a selection trigger, put triggering player in a array variable (array because every player can have the building selected at the same time) and in the other trigger check if the triggering player of the selection trigger equals the owner of the abillity being cast?
if the player deselects the building you'll have to remove him from the array, this way you can see who selected your building and maybe who also casted the ability by setting him to a variable ;)?

EDIT: hmm this might not work, I'll try some things :)

EDIT2:
haven't tested this yet because I'm at work, Don't know if this is gonna work...
  • try this
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Custom script: if ( IsUnitSelected(GetTriggerUnit(), GetLocalPlayer()) == true ) then
      • Custom script: call DisplayTextToForce( GetPlayersAll(), GetPlayerName(GetLocalPlayer()) )
      • Custom script: endif
this basically says: if the triggering unit is selected by local player then display the name of the local player who is selecting the triggering unit.
I haven't tested it yet though... :S

So let's say a unit starts the effect of an ability, the local player who has currently selected the triggering unit must be the player who activated the ability right :S?
correct me if I'm wrong, since I'm not sure...
it might be wrong in a situation where 2 players have selected the unit and one of them casts the ability, I have no idea what happens :S
This is a hard problem dude 0.o

if this doesn't work I give up, try wolfman's method :p

EDIT 3:
what if you change the ownership of the unit to the local player who selected it, would this cause a desynch? If not this might be your solution since you can then use owner of casting unit
 
Last edited:
Level 11
Joined
May 31, 2008
Messages
698
Here could be an idea.
So you have the building that is shared between all players, anybody can select it/use it whenever they want.
Make the same building outside of the map boundary, just make your map slightly larger and set the camera view back via triggers.
In the area where players can not see, place one building for each player.
Then make a trigger that selects the players own building whenever they select the shared one they can actually see. It will make it seem like they are selecting the one they can see, but they are actually selecting the hidden one that they actually own.
This way you can just use owner of triggering unit to detect which player uses the spell.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Here could be an idea.
So you have the building that is shared between all players, anybody can select it/use it whenever they want.
Make the same building outside of the map boundary, just make your map slightly larger and set the camera view back via triggers.
In the area where players can not see, place one building for each player.
Then make a trigger that selects the players own building whenever they select the shared one they can actually see. It will make it seem like they are selecting the one they can see, but they are actually selecting the hidden one that they actually own.
This way you can just use owner of triggering unit to detect which player uses the spell.

now thats a good idea :O!
Would totally pown my idea of changing ownership for a local player (which probably desynchs anyways) :D
 

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
Thanks a lot for your answers ^^

Hashjie
Well we don't need to do local job to detect wich player select a building this is just normal GUI.
of course changing the ownership for each local player could help to detect but a building cannot belong to more than one player at same time...(desync)
the easiest would be to give the ownership to the latest player who select the building but that wouldn't mean that the latest player is the one who cast the spell since all player can select the building even if they don't own it...

wolfman
Well the problem is that it is not a one building pre-set map...
it is JTR (Jungle Troll Reborn) a survival game where you building lot of building anywhere on the map, usually one of each type, but can build more than one if want...
there are 3 tribes of 4 players so that a lot of building....


if i would go your solution i would rather use a temporary building for player created at selection of player of the type building, i can make it invi and create it anywhere hidden on the map...
the all crafting methode allready use this system...but that still a bit annoying...
I would have to redo all the crafting trigger that took me 20 hours to make there are +300 recipes.
the problem is that if i want to use the buy unit instead of ability i might have to redo all trigger the same...

but create temp building and removing them each time a player select a building is annoying,
especially since player will see that the selection circle isn't on the building they selected and they wouldn't be able to see the building life if damaged...

so maybe the buy unit is the best option.... :(

strange though that Jass don't have any function to detect a player action like that...
it is possible to do it with trackable, but i can't use trackable on building or ability and trackable are permanent in the area spawned...


So in the End no way to detect player mouse click or move event... and not event ability click by player.... :(

Well if anyone has more ideas :p
if not i will try the sold unit for the building i really need to track player event.
 
Level 11
Joined
May 31, 2008
Messages
698
Well you could maybe make an invulnerable dummy shop and place it right on the other one, you would have to set the health with triggers, make it have no collision, etc. But it might be possible. Plus that way it will show the selection circle. You would also have to make sure to remove it when deselected.
 

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
Well that possible :p
but if the four tribe members select the same building that would make 5 building on top of another...
well i could lower that by allowing the first player to select the real building and oblige other player (from second selection) to select the newly hidden building...

But...hum...if no other option i will think about it...

my dream would be a JASS snippet wich would launch on ability cast and store the triggering player... that would be the best ultimate easiest way...
Any JASS gourou around? can someone tell me if this kind of snippet exist or is possible to do...
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
  • Trigger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Custom script: set udg_PlayerVariable = GetLocalPlayer()
You need variable named PlayerVariable of player type. The player who activated the ability will be assigned to that variable.
You can name the variable whatever you want,but make sure you put in custom script: set udg_[variable name] = GetLocalPlayer()
 
  • Like
Reactions: ABM

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
Well that's exactly what i was looking for ^^
Thanks a lot Garfield1337
:) adding rep to you

Thanks a lot also to wolfman and Hashjie for your time and your Help...
:)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
  • Trigger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Custom script: set udg_PlayerVariable = GetLocalPlayer()
You need variable named PlayerVariable of player type. The player who activated the ability will be assigned to that variable.
You can name the variable whatever you want,but make sure you put in custom script: set udg_[variable name] = GetLocalPlayer()

Does not work. The trigger is run for every player, how else would others see the spell effect if it did not broadcast the unit orders? So this just returns for every player him/herself, indepedent of who pressed the button. Will also desync in case TC wants to use the acquired player in a synchronous matter.

Would totally pown my idea of changing ownership for a local player (which probably desynchs anyways) :D

Same applies to that. Of course, it does. And you would not even need to change owner if you just saved the player in a variable on selection event.
 
Status
Not open for further replies.
Top