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

Problems with my hero choose system!

Status
Not open for further replies.
Level 2
Joined
May 21, 2010
Messages
10
Guys, I am doing a Hero choose system, that you just need to write, for example, -adventurer1 or -adventurer2...
And well, I tried some stuff, to disable the other trigger, like this, if I type -adventurer1, the -adventurer2 trigger is disabled...
I did 5 different triggers, because the map I am making is for 2 players (me and my brother, lol)
Well, I did like this:

First Trigger:
Name: Hashtable
Events:
Map Initialization
Actions:
Hashtable - Create Hashtable
---------------------------------
Second Trigger:
Name: Player 1 Trigger 1
Events:
Player - Player 1 (Red) types a chat message containing -adventurer1 as An exact match
Actions:
Hashtable - Save Handle Of(This Trigger) as 1 of 4 in (Last created hashtable)
Unit - Create 1 Adventurer1 for Player 1 (Red) at (Center of Start Point <gen>) facing Default buildings facing degrees
Trigger - Turn off (Load 1 of 4 in (Last created hashtable))
Trigger - Turn off (Load 2 of 4 in (Last created hashtable))
-------------------------------------------------------------
Third Trigger:
Name: Player 1 Trigger 2
Events:
Player - Player 1 (Red) types a chat message containing -adventurer2 as An exact match
Actions:
Hashtable - Save Handle Of(This Trigger) as 2 of 4 in (Last created hashtable)
Unit - Create 1 Adventurer2 for Player 1 (Red) at (Center of Start Point <gen>) facing Default buildings facing degrees
Trigger - Turn off (Load 1 of 4 in (Last created hashtable))
Trigger - Turn off (Load 2 of 4 in (Last created hashtable))
-------------------------------------------------------------
Fourth Trigger:
Name: Player 2 Trigger 1
Events:
Player - Player 2 (Blue) types a chat message containing -adventurer1 as An exact match
Actions:
Hashtable - Save Handle Of(This Trigger) as 3 of 4 in (Last created hashtable)
Unit - Create 1 Adventurer1 for Player 2 (Blue) at (Center of Start Point <gen>) facing Default buildings facing degrees
Trigger - Turn off (Load 3 of 4 in (Last created hashtable))
Trigger - Turn off (Load 4 of 4 in (Last created hashtable))
---------------------------------------------------------------------
Fifth Trigger:
Name: Player 2 Trigger 2
Events:
Player - Player 2 (Blue) types a chat message containing -adventurer2 as An exact match
Actions:
Hashtable - Save Handle Of(This Trigger) as 4 of 4 in (Last created hashtable)
Unit - Create 1 Adventurer2 for Player 2 (Blue) at (Center of Start Point <gen>) facing Default buildings facing degrees
Trigger - Turn off (Load 3 of 4 in (Last created hashtable))
Trigger - Turn off (Load 4 of 4 in (Last created hashtable))
------------------------------------------------------------

If I type it the other type, I still get the other hero, but then, I can't get it anymore, and I wish to pick up only one of them...
Well, the problem is a little bit obvious...
The trigger is only saved in the hashtable after it is used, is there any way to save all of these 4 triggers before I use them?
Answer it quickly please!
 
Level 8
Joined
Jan 8, 2010
Messages
493
i don't really understand hashtables so i'm not sure if there's something wrong with what you did, but you can try

  • Events
    • Player - Player 1 (Red) types a chat message containing -adventurer1 as An exact match
    • Player - Player 2 (Blue) types a chat message containing -adventurer1 as An exact match
    • Player - Player 1 (Red) types a chat message containing -adventurer2 as An exact match
    • Player - Player 2 (Blue) types a chat message containing -adventurer2 as An exact match
  • Conditions
  • Actions
    • Set StartPoint = ((Triggering player) start location)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • HeroOk[(Player number of (Triggering player))] Equal to True
      • Then - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Entered chat string) Equal to -adventurer1
          • Then - Actions
            • Unit - Create 1 Adventurer1 for (Triggering player) at StartPoint facing Default building facing degrees
          • Else - Actions
            • Unit - Create 1 Adventurer2 for (Triggering player) at StartPoint facing Default building facing degrees
        • Set HeroOk[(Player number of (Triggering player))] = True
      • Else - Actions
    • Custom script: call RemoveLocation(udg_StartLocation)
HeroOk[array] is a Boolean array with False default value. it will check if the player already owns a hero, if false it will create a hero for him. if true then it will simply ignore the chat string.

just tell if this works for you or not. :]
 
Status
Not open for further replies.
Top