• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Ownership change "on-click"/ on selection

Status
Not open for further replies.
Level 7
Joined
May 30, 2018
Messages
290
Is it possible to make a type of building change ownership to whoever clicks it, with say a few seconds "cooldown" so that not all players just spamclick it? Like somebody clicks it and has few seconds to chose what to produce.
Help would be appreciated since I haven't got any clue on how to trigger such a thing. The only thing I managed to trigger was the building changing ownership to one specific player, but I'd like it to change to whoever IS IN THE TEAM and clicks it (not enemies!)

thank you for your help
 
Level 30
Joined
Feb 18, 2014
Messages
3,623
You can store the selecting player inside a variable and then create a countdown timer to change the owner of the unit to the Selecting Player when it expires.
  • Decect Selecting Player
    • Events
      • Player - Player 1 (Red) Select a unit
      • Player - Player 2 (Blue) Select a unit
      • Player - Player 3 (Teal) Select a unit
      • Player - Player 4 (Purple) Select a unit
    • Conditions
      • (Triggering unit) Equal "YourUnit"
    • Actions
      • Set SelectingPlayer = (Triggering player)
      • Countdown Timer - Start SelectTimer as a One shot timer that will expire in 5.00 seconds
  • Change Ownership
    • Events
      • Time - SelectTimer expires
    • Conditions
    • Actions
      • Unit - Change ownership of "YourUnit" to SelectingPlayer and Change colour
 
Level 7
Joined
May 30, 2018
Messages
290
You can store the selecting player inside a variable and then create a countdown timer to change the owner of the unit to the Selecting Player when it expires.
  • Decect Selecting Player
    • Events
      • Player - Player 1 (Red) Select a unit
      • Player - Player 2 (Blue) Select a unit
      • Player - Player 3 (Teal) Select a unit
      • Player - Player 4 (Purple) Select a unit
    • Conditions
      • (Triggering unit) Equal "YourUnit"
    • Actions
      • Set SelectingPlayer = (Triggering player)
      • Countdown Timer - Start SelectTimer as a One shot timer that will expire in 5.00 seconds
  • Change Ownership
    • Events
      • Time - SelectTimer expires
    • Conditions
    • Actions
      • Unit - Change ownership of "YourUnit" to SelectingPlayer and Change colour

Thank you, kind sir :)
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
I don't think what Warseeker wrote is what you want, exactly. That changes the owner to the clicking player after 5 seconds, and it doesn't lock anyone out of changing it. This version of those trigger does do that properly:

  • Detect Selecting Player
    • Events
      • Player - Player 1 (Red) Select a unit
      • Player - Player 2 (Blue) Select a unit
      • Player - Player 3 (Teal) Select a unit
      • Player - Player 4 (Purple) Select a unit
    • Conditions
      • (Triggering unit) Equal "YourUnit"
      • LockoutActive equal to false
    • Actions
      • Set LockoutActive = True
      • Unit - Change ownership of "YourUnit" to (Triggering Player) and Change colour
      • Countdown Timer - Start SelectTimer as a One shot timer that will expire in 5.00 seconds
  • Change Ownership
    • Events
      • Time - SelectTimer expires
    • Conditions
    • Actions
      • Set LockoutActive = false
 
Level 30
Joined
Feb 18, 2014
Messages
3,623
I don't think what Warseeker wrote is what you want, exactly. That changes the owner to the clicking player after 5 seconds, and it doesn't lock anyone out of changing it. This version of those trigger does do that properly:

  • Detect Selecting Player
    • Events
      • Player - Player 1 (Red) Select a unit
      • Player - Player 2 (Blue) Select a unit
      • Player - Player 3 (Teal) Select a unit
      • Player - Player 4 (Purple) Select a unit
    • Conditions
      • (Triggering unit) Equal "YourUnit"
      • LockoutActive equal to false
    • Actions
      • Set LockoutActive = True
      • Unit - Change ownership of "YourUnit" to (Triggering Player) and Change colour
      • Countdown Timer - Start SelectTimer as a One shot timer that will expire in 5.00 seconds
  • Change Ownership
    • Events
      • Time - SelectTimer expires
    • Conditions
    • Actions
      • Set LockoutActive = false
Correct me if I'm wrong, but wouldn't that cause the players to spamclick on the unit since every time the unit is selected the timer reset? Plus, the OP said he wants a delay before choosing which player should the unit go.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
No. The owner is changed and timer run only if the lockout boolean is false; it gets set to true when someone clicks (while false) and is reset to false when the timer expires. The OP said they wanted a player to click it, gain ownership, and other players should be prevented from clicking it to gain ownership for some time (no delay involved).
 
Level 30
Joined
Feb 18, 2014
Messages
3,623
No. The owner is changed and timer run only if the lockout boolean is false; it gets set to true when someone clicks (while false) and is reset to false when the timer expires. The OP said they wanted a player to click it, gain ownership, and other players should be prevented from clicking it to gain ownership for some time (no delay involved).
Ah, yes, I was a little confused at the beginning, but after analyzing it, I realised that you're actually right! :p

I thought the OP wanted to have a few seconds delay before changing the ownership of the unit to the selecting player, not like instantly but depending on the last player who clicked it, like if another player clicks on that unit during that time, the player who previously clicked that unit will lose that advantage. At least that's what I understand.
 
Status
Not open for further replies.
Top