• 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.

Hero Select Once Problem

Status
Not open for further replies.
Level 8
Joined
Feb 17, 2007
Messages
368
I'm trying to make it so players cant pick 2 of the same hero, but not sure how to do it. I realize this method is wrong but it's what I'm working with right now. Anyone have any idea how to fix this?

  • Actions
    • Set DbzHeroes = (Units in Region 001 <gen>)
    • Unit Group - Pick every unit in DbzHeroes and do (Actions)
      • Loop - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Region 078 <gen> contains (Picked unit)) Equal to True
      • Then - Actions
        • Set FloatTxtGroup = (Player group((Triggering player)))
        • Game - Display to FloatTxtGroup for 5.00 seconds the text: This hero has alrea...
        • Custom script: call DestroyForce(udg_FloatTxtGroup)
      • Else - Actions
        • Cinematic - Clear the screen of text messages for (All players matching (Picking_Hero[(Player number of (Triggering player))] Equal to True))
        • Set DBZStartSpot = (Center of Region 095 <gen>)
        • Set Picking_Hero[(Player number of (Triggering player))] = False
        • Set Hero_Selected[(Player number of (Triggering player))] = True
        • Visibility - Create an initially Enabled visibility modifier for (Triggering player) emitting Visibility across Region 078 <gen>
        • Set VisibleArray[(Player number of (Triggering player))] = (Last created visibility modifier)
        • Unit - Create 1 Current_Hero[(Player number of (Triggering player))] for (Triggering player) at DBZStartSpot facing Default building facing degrees
        • Custom script: call RemoveLocation (udg_DBZStartSpot)
        • Game - Display to (All players) for 5.00 seconds the text: (CounterColor[(Player number of (Triggering player))] + ((Name of (Triggering player)) + (|cff4169e1 has selected a|r + (Proper name of (Last created unit)))))
        • Player - Set name of (Triggering player) to (player_name_raw[(Player number of (Triggering player))] + (( ( + (Proper name of (Last created unit))) + (CounterColor[(Player number of (Triggering player))] + ))))
        • Unit Group - Add (Last created unit) to Hero_Selected_Unit_Group
        • Set Players_Heroes[(Player number of (Triggering player))] = (Last created unit)
        • Selection - Select (Last created unit) for (Triggering player)
        • Camera - Reset camera for (Triggering player) to standard game-view over 0.00 seconds
        • Camera - Set (Triggering player)'s camera Height Offset to 400.00 over 0.00 seconds
        • Player Group - Remove (Triggering player) from Hero_Selecting_Group
        • Player Group - Remove (Triggering player) from RepickHeroSelecting
        • Player Group - Add (Triggering player) to Hero_Selected_Group
 
Last edited:
Level 3
Joined
Apr 29, 2009
Messages
32
Hey, been a while since I last WC3'd. Haven't had it installed for a while and I checked the forums and think I've might found a solution nonetheless. <-- Former Triggerer

Try to do a little different approach.

Like:

Event:
Player X picks unit

Action:
If - Then - Else, multiple action.
If: Picked unit is in group PlayerHeroGroup [X] (Unit Group Variable)
Then: Display text to player; You can't pick this hero, it's already been picked.
Else: Add picked unit to PlayerHeroGroup [X]

That's how to sum it up. Now I can't show you an exact trigger since I don't have the game installed mentioned, hope it helps. :D

Edit: Ok, so this thing has been bugging me a while: Sure it isn't just the condition? Instead of doing the "all units in region" do a "Unit is in Unit-Group Hero_Selected_Unit_Group"
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
Use unit pools:


  • Untitled Trigger 080
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: local unitpool up = CreateUnitPool()
      • Custom script: call UnitPoolAddUnitType(up, 'Hpal', 1)
      • Custom script: call UnitPoolAddUnitType(up, 'Hmkg', 1)
      • Custom script: call UnitPoolAddUnitType(up, 'Hamg', 1)
      • Custom script: call UnitPoolAddUnitType(up, 'Hblm', 1)
      • Custom script: call SaveUnitPoolHandle(udg_hash, 0, StringHash("unitpool"), up)
  • Untitled Trigger 082
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: local unitpool up = LoadUnitPoolHandle(udg_hash, 0, StringHash("unitpool"))
      • Custom script: set bj_lastCreatedUnit = PlaceRandomUnit(up, GetTriggerPlayer(), 0, 0, 0)
      • Custom script: call UnitPoolRemoveUnitType(up, GetUnitTypeId(bj_lastCreatedUnit))
      • Custom script: set up = null


Create a hashtable variable called hash. You could give it a better name, remember to change the "hash" in those custom scripts.

For example if you name the hashtable UnitpoolStorage then change those udg_hash thingies to udg_UnitpoolStorage.

In the first trigger you can add unit types into the pool of pickable unit types. You can see the raw codes of units in object editor, click Ctrl + D. Paladin is Hpal for example.

This line determines the player for who the unit is created and where it is spawned. The first 0 is the x coordinate. The second 0 is the y coordinate. The last 0 is the facing of the spawned unit.
  • Custom script: set bj_lastCreatedUnit = PlaceRandomUnit(up, GetTriggerPlayer(), 0, 0, 0)
You can use GUI function <last created unit> to manipulate the created unit, like movve it to desired location.
 
Status
Not open for further replies.
Top