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

[Trigger] How to disable trigger for one player?

Status
Not open for further replies.
Level 1
Joined
Apr 24, 2010
Messages
6
Hello, this is my first thread and i want to know how to disable a trigger for one player only.
So that i can give an item for a Hero when i train it but only when i train, because if i dont disable the trigger, everytime i revive him he will get the item again, but when i disable the trigger it disables for every player also, and this causes only the first player who pick the hero to get the item. (To be exact, i am creating heroes with diferent starting itens for each one of they.)
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
There is surely a more efficient way to solve this problem but this way will work just fine.
  • Test
    • Events
      • Unit - A unit owned by Player 1 (Red) Finishes training a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Trained unit)) Equal to someUnit
        • Then - Actions
          • Hero - Create someItem and give it to (Trained unit)
          • Trigger - Turn off (This trigger)
        • Else - Actions
 
Level 10
Joined
Dec 15, 2012
Messages
650
If Boolean[number of (triggering player)] equal to True then
actions

Set Boolean[?] equal to false when you want to disable the trigger for player[?]
(Boolean is a boolean variable, array size:13 and has True default value).

EDIT :
I knew your problem was solved and I don't want the rep, I just want to tell you there is an easier way and it's work for all players. It will be very usful for you if you understood it.
 
Level 1
Joined
Apr 24, 2010
Messages
6
If Boolean[number of (triggering player)] equal to True then
actions

Set Boolean[?] equal to false when you want to disable the trigger for player[?]
(Boolean is a boolean variable, array size:13 and has True default value).

EDIT :
I knew your problem was solved and I don't want the rep, I just want to tell you there is an easier way and it's work for all players. It will be very usful for you if you understood it.

No problem about Rep, but i didn't understood so well what is this solution of yours...

There is surely a more efficient way to solve this problem but this way will work just fine.
  • Test
    • Events
      • Unit - A unit owned by Player 1 (Red) Finishes training a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Trained unit)) Equal to someUnit
        • Then - Actions
          • Hero - Create someItem and give it to (Trained unit)
          • Trigger - Turn off (This trigger)
        • Else - Actions

This was really easy to do, thanks for the help! =D
 
Level 10
Joined
Dec 15, 2012
Messages
650
No problem, bro. I will explain it for you :D
  • Give Item
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • Boolean[(Player number of (Triggering player))] Equal to True
    • Actions
      • Set tempPoint = (Position of (Trained unit))
      • Set Boolean[(Player number of (Triggering player))] = False
      • Item - Create Tome of Experience at tempPoint
      • Hero - Give (Last created item) to (Trained unit)
      • Custom script: call RemoveLocation(udg_tempPoint)
      • Custom script: set udg_tempPoint = null
Default value of Boolean[array] = TRUE
Array size of Boolean = 17(for all players' use, include neutrals)

EDIT : added two triggers
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Trained unit) is in Unit_Group_ItemGiven) Equal to False
    • Then - Actions
      • Unit Group - Add (Trained unit) to Unit_Group_ItemGiven
    • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Trained unit) is in Unit_Group_ItemGiven) Equal to False
    • Then - Actions
      • -------- For units (not for players so your players can have more than 1 heroes) --------
      • Set tempPoint = (Position of (Trained unit))
      • Item - Create Tome of Experience at tempPoint
      • Hero - Give (Last created item) to (Trained unit)
      • Custom script: call RemoveLocation(udg_tempPoint)
      • Custom script: set udg_tempPoint = null
    • Else - Actions
 
Of course the simplest way is to copy and paste the trigger and make it player specific with a condition (owner of (triggering unit) equal to (player one(red)). I know its not flashy but it will do what you want.

For example:
  • Event -
  • Unit - enters a region (entire map)
  • Conditions -
    • (triggering unit) equal to a Hero
    • (owner of (triggering unit) equal to Player 1
  • Actions -
    • Unit - give (triggering unit) item
    • Trigger - turn off (this trigger).
 
Boolean is the 'simplest' way lol. You don't even have to Copy Paste. :cgrin:
Oh ya, this is true. You can create a Boolean Action that does all of this inside a single trigger. That is in fact the simplest way.

But the problem with that is the turn off trigger action. You want to turn it off so that the hero does not get a new item every time it revives. Unless thats what you want, which maybe it is, I am a little confused about how he wants it to work. Either way, how's it coming? Is it working for you?
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Event
-Some event
Conditions
-Unit has item of type equal to false
Actions
-Give item to unit

Most likely you can use a single, simple trigger like this to cover all players.
imo this may not be the best idea, as the same player could create another hero (if possible to have more than 1) or the triggering unit may have sold the item, getting new one again.


But the problem with that is the turn off trigger action. You want to turn it off so that the hero does not get a new item every time it revives. Unless thats what you want, which maybe it is, I am a little confused about how he wants it to work. Either way, how's it coming? Is it working for you?
He wants to give item to newly trained heroes, not revived ones.
If he has 1 hero per player, he could use boolean using player's number as index for the boolean.
If he has more heroes per player, he could use hashtables I guess (unless heroe's handle id changes when that hero gets revived)
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
imo this may not be the best idea, as the same player could create another hero (if possible to have more than 1) or the triggering unit may have sold the item, getting new one again.

It was an example on how you can use conditions to solve the issue easily and with only one trigger. As the exact situation was not known, it was impossible to give the correct event and conditions.
 
Level 1
Joined
Apr 24, 2010
Messages
6
Ok, thanks for all the help, the first solution worked, but when i use a custom hero it doesn't work, i tested with the Paladin hero and it went fine, then with my Naga hero it didn't worked...strange, anyone know about it?
And sorry for answering too late =(
 
Level 1
Joined
Apr 24, 2010
Messages
6
  • Test
    • Events
      • Unit - A unit owned by Player 1 (Red) Finishes training a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Trained unit)) Equal to someUnit
        • Then - Actions
          • Hero - Create someItem and give it to (Trained unit)
          • Trigger - Turn off (This trigger)
        • Else - Actions

I used this trigger, tested in a new map with a paladin worked just fine, but then when i used with my custom hero it didn't worked...(the item is also custom)
 
Level 1
Joined
Apr 24, 2010
Messages
6
Ok, i tried doing this one
  • Give Item
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • Boolean[(Player number of (Triggering player))] Equal to True
    • Actions
      • Set tempPoint = (Position of (Trained unit))
      • Set Boolean[(Player number of (Triggering player))] = False
      • Item - Create Tome of Experience at tempPoint
      • Hero - Give (Last created item) to (Trained unit)
      • Custom script: call RemoveLocation(udg_tempPoint)
      • Custom script: set udg_tempPoint = null
Default value of Boolean[array] = TRUE
Array size of Boolean = 17(for all players' use, include neutrals)
But i goT stuck at "Set tempPoint", what is tempPoint?
 
Status
Not open for further replies.
Top