Hero Selection via clicking twice

icond3maker

New Member
Reaction score
6
Hello, I have a question about hero selection via clicking the unit twice.
When I click the unit and click it again, I will have a new hero.
Can someone put the wc3 code here? I really need help thank you!
+REP the first one to give the right answer.

- Thx in advance
 

jig7c

Stop reading me...-statement
Reaction score
123
something like:

Trigger:
  • Event
    • A player Selects a Unit
    • Conditions
      • -any conditions you wish-
    • Actions
      • Set TempInteger[Player number of (Owner of (Triggering Unit))] = TempInteger[Player number of (Owner of (Triggering Unit))] + 1
      • If/Then/Else
        • If
          • TempInteger[Player number of (Owner of (Triggering Unit))] = 2
        • Then
          • Change ownership of (triggering unit) to (Triggering Player)
          • TempInteger[Player number of (Owner of (Triggering Unit))] = 0
        • Else
 

tommerbob

Minecraft. :D
Reaction score
110
Is selecting a unit a unit event or player event? I was thinking its a player event, but I could be wrong.
 

icond3maker

New Member
Reaction score
6
something like:

Trigger:
  • Event
    • A player Selects a Unit
    • Conditions
      • -any conditions you wish-
    • Actions
      • Set TempInteger[Player number of (Owner of (Triggering Unit))] = TempInteger[Player number of (Owner of (Triggering Unit))] + 1
      • If/Then/Else
        • If
          • TempInteger[Player number of (Owner of (Triggering Unit))] = 2
        • Then
          • Change ownership of (triggering unit) to (Triggering Player)
          • TempInteger[Player number of (Owner of (Triggering Unit))] = 0
        • Else

A neutral named "Knight" have no movement speed and is invulnerable. Once I double click him, or 2 consecutive clicks. There will be an action :
Create 1 Knight for (Selecting player) at the (center of playable map)
is your code working? I can't understand :/
Can you explain much further..
btw : you are +rep
 

tooltiperror

Super Moderator
Reaction score
231
See, if you wanted to, you could create a double click event, so when a player selects units, add them to a force, start a 3 second timer, and if they select the force again before that timer turns on, register that as the double click.

Or, if you know JASS, just use DoubleClick.
 

icond3maker

New Member
Reaction score
6
See, if you wanted to, you could create a double click event, so when a player selects units, add them to a force, start a 3 second timer, and if they select the force again before that timer turns on, register that as the double click.

Or, if you know JASS, just use DoubleClick.

I have it running! +rep for you :]
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
take a look at the demo map (attached below)
here are two main triggers: (out of 4)
Trigger:
  • HeroSelect Init
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set TempInt = (Integer A)
          • Set CurrentSelectedUnit[TempInt] = No unit
          • Set HasSelectedHero[TempInt] = False
          • Trigger - Add to HeroSelect Click <gen> the event (Player - (Player(TempInt)) Selects a unit)
          • Trigger - Add to HeroSelect Repick <gen> the event (Player - (Player(TempInt)) types a chat message containing -repick as An exact match)
      • Wait 60.00 seconds
      • -------- turn off repick --------
      • Trigger - Turn off HeroSelect Repick <gen>


Trigger:
  • HeroSelect Click
    • Events
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Passive
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set TempPlayer = (Triggering player)
      • Set TempUnit = (Triggering unit)
      • Set TempInt = (Player number of TempPlayer)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HasSelectedHero[TempInt] Equal to True
        • Then - Actions
          • -------- this player has already selected a hero, no need to run the trigger any further --------
          • Skip remaining actions
        • Else - Actions
      • -------- --------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CurrentSelectedUnit[TempInt] Equal to TempUnit
        • Then - Actions
          • Set CurrentSelectedUnit[TempInt] = No unit
          • -------- second click --------
          • Set HasSelectedHero[TempInt] = True
          • -------- unit type of TempUnit is the unit that the player has chosen, now create hero for him/her --------
          • Set TempPoint = (Center of HeroSpawnPlace <gen>)
          • Unit - Create 1 (Unit-type of TempUnit) for TempPlayer at TempPoint facing Default building facing degrees
          • Set TempUnit = (Last created unit)
          • Selection - Select TempUnit for TempPlayer
          • Camera - Pan camera for TempPlayer to TempPoint over 0.10 seconds
          • Set TempForce = (Player group(TempPlayer))
          • Cinematic - Clear the screen of text messages for TempForce
          • Custom script: call DestroyForce( udg_TempForce )
          • Game - Display to (All players) the text: ((Name of TempPlayer) + ( has picked + (Name of TempUnit)))
          • Custom script: call RemoveLocation( udg_TempPoint )
          • -------- a little special effect won't hurt --------
          • Special Effect - Create a special effect attached to the origin of TempUnit using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
          • -------- first click --------
          • Animation - Play TempUnit's Attack animation
          • Animation - Queue TempUnit's stand animation
          • Trigger - Run HeroSelect Description <gen> (ignoring conditions)
          • Set CurrentSelectedUnit[TempInt] = TempUnit


I hope this would help :)
 

Attachments

  • [Demo] Select Hero by Double Click.w3x
    13.5 KB · Views: 98

icond3maker

New Member
Reaction score
6
take a look at the demo map (attached below)
here are two main triggers: (out of 4)
Trigger:
  • HeroSelect Init
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set TempInt = (Integer A)
          • Set CurrentSelectedUnit[TempInt] = No unit
          • Set HasSelectedHero[TempInt] = False
          • Trigger - Add to HeroSelect Click <gen> the event (Player - (Player(TempInt)) Selects a unit)
          • Trigger - Add to HeroSelect Repick <gen> the event (Player - (Player(TempInt)) types a chat message containing -repick as An exact match)
      • Wait 60.00 seconds
      • -------- turn off repick --------
      • Trigger - Turn off HeroSelect Repick <gen>


Trigger:
  • HeroSelect Click
    • Events
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Passive
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set TempPlayer = (Triggering player)
      • Set TempUnit = (Triggering unit)
      • Set TempInt = (Player number of TempPlayer)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HasSelectedHero[TempInt] Equal to True
        • Then - Actions
          • -------- this player has already selected a hero, no need to run the trigger any further --------
          • Skip remaining actions
        • Else - Actions
      • -------- --------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CurrentSelectedUnit[TempInt] Equal to TempUnit
        • Then - Actions
          • Set CurrentSelectedUnit[TempInt] = No unit
          • -------- second click --------
          • Set HasSelectedHero[TempInt] = True
          • -------- unit type of TempUnit is the unit that the player has chosen, now create hero for him/her --------
          • Set TempPoint = (Center of HeroSpawnPlace <gen>)
          • Unit - Create 1 (Unit-type of TempUnit) for TempPlayer at TempPoint facing Default building facing degrees
          • Set TempUnit = (Last created unit)
          • Selection - Select TempUnit for TempPlayer
          • Camera - Pan camera for TempPlayer to TempPoint over 0.10 seconds
          • Set TempForce = (Player group(TempPlayer))
          • Cinematic - Clear the screen of text messages for TempForce
          • Custom script: call DestroyForce( udg_TempForce )
          • Game - Display to (All players) the text: ((Name of TempPlayer) + ( has picked + (Name of TempUnit)))
          • Custom script: call RemoveLocation( udg_TempPoint )
          • -------- a little special effect won't hurt --------
          • Special Effect - Create a special effect attached to the origin of TempUnit using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
          • -------- first click --------
          • Animation - Play TempUnit's Attack animation
          • Animation - Queue TempUnit's stand animation
          • Trigger - Run HeroSelect Description <gen> (ignoring conditions)
          • Set CurrentSelectedUnit[TempInt] = TempUnit


I hope this would help :)

That's a nice! GUI-friendly triggers, but I have the jass version. +rep for effort and thanks for the GUI
 

jig7c

Stop reading me...-statement
Reaction score
123
just out of curiosity, may i see the jass triggers?
i'm scripting/learning jass and i could use some knowledge from your triggers...
i won't use your trigger, i don't even have a map i'm making, this is just for learning purposes!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top