• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] How to disable trigger for one player?

Status
Not open for further replies.

Seijy99

S

Seijy99

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.)
 
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
 
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.
 
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
 
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?
 
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)
 
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.
 
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 =(
 
  • 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)
 
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.
Back
Top