Detect what player uses a neutral building

Level 14
Joined
Oct 16, 2010
Messages
749
Hi,

Is it possible to detect who activates an ability on a neutral building?

I want to be able to use a neutral building to select another unit, the ability works perfectly when owned by a player but I'd like to put it on a neutral building instead

Getting the owner of the casting unit obviously just gets neutral passive... and I can't use an item purchase for this as I need to be able to target a unit other than the purchasing unit...

Any ideas?
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Triggering Player may actually work here. In most scenarios it is identical to GetOwningPlayer(GetTriggerUnit()) but there maybe be a difference with this event. You could probably also make N variants of the ability with each disabled for all but one player (the unit has all such abilities but each player can only see their specific non-disabled version. This may also require the abilities to have different base orders so they’d need to be based on Channel.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Hi,

Is it possible to detect who activates an ability on a neutral building?

I want to be able to use a neutral building to select another unit, the ability works perfectly when owned by a player but I'd like to put it on a neutral building instead

Getting the owner of the casting unit obviously just gets neutral passive... and I can't use an item purchase for this as I need to be able to target a unit other than the purchasing unit...

Any ideas?
There's no easy solution as far as I know. But I don't fully understand what you're trying to achieve. It sounds like there's a better mechanic that could be used instead of relying on a Neutral unit / Ability.

Anyway, here's the start of an idea:
  • Press Shop Ability Button
    • Events
      • Game - Button for ability Banish and order Human Blood Mage - Banish pressed.
    • Conditions
    • Actions
      • Set VariableSet Shop_Last_Player = (Triggering player)
      • Game - Display to (All players) for 30.00 seconds the text: (Name of Shop_Last_Player)
  • Use Shop Ability
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Banish
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: (Name of Shop_Last_Player)
The issue here is that the Variable will be easily overwritten by someone else, say if two Players were trying to use the ability at the same time.
 
Last edited:
Level 14
Joined
Oct 16, 2010
Messages
749
There's no easy solution as far as I know. But I don't fully understand what you're trying to achieve. It sounds like there's a better mechanic that could be used instead of relying on a Neutral unit / Ability.

Anyway, here's the start of an idea:
  • Press Shop Ability Button
    • Events
      • Game - Button for ability Banish and order Human Blood Mage - Banish pressed.
    • Conditions
    • Actions
      • Set VariableSet Shop_Last_Player = (Triggering player)
      • Game - Display to (All players) for 30.00 seconds the text: (Name of Shop_Last_Player)
  • Use Shop Ability
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Banish
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: (Name of Shop_Last_Player)
The issue here is that the Variable will be easily overwritten by someone else, say if two Players were trying to use the ability at the same time.

I will give this a go and see how it works!


EDIT - Triggering player doesn't seem to work to be able to set the variable, I've got the line to show the name of the player and it doesn't display anything. However just putting "test" does work so the event does work...

Looks like I'll have to try and think of a different method for this
 
Last edited:
Level 14
Joined
Oct 16, 2010
Messages
749
Hello again - bringing this back


My idea now is to buy an item that sets a Blooean as true, you then select the hero you want from your storage to pull it out. As there are multiple buildings able to use this function my plan was to have the item be purchased that then sets the Blooean for the player, however this means I need to use "selling unit" instead of "unit aquires item".

How do I work out the unit that the item was sold to? Hero manipulating item did not work (and I understand why!)

If this doesn't work I could try having you buy a unit that is imediately removed, I guess that way I can still get the unit/player details of the buying unit as well as the shop
 
Level 24
Joined
Feb 27, 2019
Messages
833
Hello again - bringing this back


My idea now is to buy an item that sets a Blooean as true, you then select the hero you want from your storage to pull it out. As there are multiple buildings able to use this function my plan was to have the item be purchased that then sets the Blooean for the player, however this means I need to use "selling unit" instead of "unit aquires item".

How do I work out the unit that the item was sold to? Hero manipulating item did not work (and I understand why!)

If this doesn't work I could try having you buy a unit that is imediately removed, I guess that way I can still get the unit/player details of the buying unit as well as the shop
Buying unit
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
You can always use (Triggering unit) when you're in doubt, it's always set to the first Unit mentioned in the Event and is treated like a local variable meaning it will continue to work even with Waits in your trigger.
  • Unit - A unit Dies
  • Unit - A unit Enters a region
  • Unit - A unit Loses an item
  • Unit - A unit Issues an order targeting an object
A unit = The unit that triggered the Event = (Triggering unit)

Edit: Actually, I forget how the Event is worded, the shop might be the triggering unit in this case.
 
Last edited:
Top