• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Trigger problem

Status
Not open for further replies.
Level 4
Joined
May 1, 2013
Messages
68
I need help fixing this trigger. The problem is, that if the unit using the item isn't a paladin, it should play a sound and give 1 item charge of the item used, which it doesn't. It should also work with different units like, instead of a paladin a barbarian in 1 trigger. It will need to work with 5 different heroes.

If you don't understand just ask.

  • Town Portal Scroll Paladin
    • Events
      • Unit - A unit owned by Player 1 (Red) Uses an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Town Portal Scroll
          • (Rogues Camp <gen> contains (Hero manipulating item)) Equal to False
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Hero manipulating item)) Equal to Paladin
            • Then - Actions
              • Destructible - Create a Town Portal at (Position of (Hero manipulating item)) facing (Random angle) with scale 1.00 and variation 0
              • Set Town_portal = (Last created destructible)
              • Sound - Play portalcast <gen>
              • Wait 1.00 seconds
              • Sound - Play portalenter <gen>
              • Wait 0.05 seconds
              • Unit - Move (Hero manipulating item) instantly to (Center of gg_rct_Inicio <gen>)
              • Destructible - Remove Town_portal
              • Camera - Pan camera for Player 1 (Red) to (Center of gg_rct_Inicio <gen>) over 0.00 seconds
            • Else - Actions
              • Sound - Play Pal_notintown <gen>
              • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
        • Else - Actions
Edit: I would preferable like all done in 1 trigger if possible, but not a must.
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,378
Here is explanation why "waits" are inaccurate and not recommended for multiplayer maps: http://www.hiveworkshop.com/forums/2346365-post5.html (note: "TriggerSleepAction" is the script name for "Wait")

As for the trigger you want to fix: If that hero isn't Paladin and uses that item, does it play the "Sound - Play Pal_notintown <gen>" sound?


How to use and find it?
You make 2 triggers and use an "integer" variable - let's call it "Count_var" because it counts how many times the second trigger runs. In the first trigger you have same actions as in your original trigger until the 1st "Wait" action. Instead of "wait" and all successive actions, you instead turn on the second trigger. In the first trigger you also set "Count_var" to 0.

The second trigger's even is this:
  • Events
    • Time - Every 0.05 seconds of game time
Why 0,05? Because the shortest wait you want to use is 0,05 second. You have to make math how many times this second trigger will run. The sum of both waits is 1,05 second and this trigger runs every 0,05 second. That means 1,05 / 0,05 = 21. So the trigger will run 21 times.
Each time this trigger runs you increase "Count_var" by 1 and then through If/then/else you check what number is Count_var equal to.
If equal to 20, you know 1 second has passed so you can use the "Sound - Play portalcast <gen>" action. If 21, you know 1,05 second has passed so you move the hero, remove the destructible and pan camera; and switch this looping trigger off.

The second trigger could look like this
  • Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set Count_var = (Count_var + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Count_var Equal to 20 /// This is equivalent to 1 second
        • Then - Actions
          • Sound - Play <Your sound>
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Count_var Equal to 21 /// This is equivalent to 1,05 second
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • -------- do the other things you want to do --------
        • Else - Actions
 
Level 4
Joined
May 1, 2013
Messages
68
1: Thanks, i will definitely try this.

You make 2 triggers and use an "integer" variable - let's call it "Count_var" because it counts how many times the second trigger runs. In the first trigger you have same actions as in your original trigger until the 1st "Wait" action. Instead of "wait" and all successive actions, you instead turn on the second trigger. In the first trigger you also set "Count_var" to 0.

The second trigger's even is this:
Events
Time - Every 0.05 seconds of game time
Why 0,05? Because the shortest wait you want to use is 0,05 second. You have to make math how many times this second trigger will run. The sum of both waits is 1,05 second and this trigger runs every 0,05 second. That means 1,05 / 0,05 = 21. So the trigger will run 21 times.
Each time this trigger runs you increase "Count_var" by 1 and then through If/then/else you check what number is Count_var equal to.
If equal to 20, you know 1 second has passed so you can use the "Sound - Play portalcast <gen>" action. If 21, you know 1,05 second has passed so you move the hero, remove the destructible and pan camera; and switch this looping trigger off.

The second trigger could look like this
Click

  • Loop
  • Events
  • Time - Every 0.05 seconds of game time
  • Conditions
  • Actions
  • Set Count_var = (Count_var + 1)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • Count_var Equal to 20 /// This is equivalent to 1 second
  • Then - Actions
  • Sound - Play <Your sound>
  • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • Count_var Equal to 21 /// This is equivalent to 1,05 second
  • Then - Actions
  • Trigger - Turn off (This trigger)
  • -------- do the other things you want to do --------
  • Else - Action
2:

  • As for the trigger you want to fix: If that hero isn't Paladin and uses that item, does it play the "Sound - Play Pal_notintown <gen>" sound?
No, it's supposed to play the sound if the hero is a paladin and isn't in a certain region (town region)
  • Sound - Play Pal_notintown <gen>" sound
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
No, it's supposed to play the sound if the hero is a paladin and isn't in a certain region (town region)
  • Sound - Play Pal_notintown <gen>" sound
I see. Then you have incorrectly set conditions.

In the hidden tab is exact copy of the trigger you posted in your first post
  • Town Portal Scroll Paladin
    • Events
      • Unit - A unit owned by Player 1 (Red) Uses an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Town Portal Scroll
          • (Rogues Camp <gen> contains (Hero manipulating item)) Equal to False
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Hero manipulating item)) Equal to Paladin
            • Then - Actions
              • Destructible - Create a Town Portal at (Position of (Hero manipulating item)) facing (Random angle) with scale 1.00 and variation 0
              • Set Town_portal = (Last created destructible)
              • Sound - Play portalcast <gen>
              • Wait 1.00 seconds
              • Sound - Play portalenter <gen>
              • Wait 0.05 seconds
              • Unit - Move (Hero manipulating item) instantly to (Center of gg_rct_Inicio <gen>)
              • Destructible - Remove Town_portal
              • Camera - Pan camera for Player 1 (Red) to (Center of gg_rct_Inicio <gen>) over 0.00 seconds
            • Else - Actions
              • Sound - Play Pal_notintown <gen>
              • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
        • Else - Actions
You want to play sound "Sound - Play Pal_notintown <gen>" when the hero is paladin but is not in region - but you have conditions in your trigger messed up.
I divided both If/Then/Else and I'll post each individually
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of (Item being manipulated)) Equal to Town Portal Scroll
        • (Rogues Camp <gen> contains (Hero manipulating item)) Equal to False
      • Then - Actions
        • *here you start your second If/Then/Else*
      • Else - Actions
As you can see, in this ITE you check if that unit is using your specific item and is in specific region. If it is, it will continue and do the other ITE action. If conditions are not true, it will do nothing.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Unit-type of (Hero manipulating item)) Equal to Paladin
    • Then - Actions
      • Destructible - Create a Town Portal at (Position of (Hero manipulating item)) facing (Random angle) with scale 1.00 and variation 0
      • Set Town_portal = (Last created destructible)
      • Sound - Play portalcast <gen>
      • Wait 1.00 seconds
      • Sound - Play portalenter <gen>
      • Wait 0.05 seconds
      • Unit - Move (Hero manipulating item) instantly to (Center of gg_rct_Inicio <gen>)
      • Destructible - Remove Town_portal
      • Camera - Pan camera for Player 1 (Red) to (Center of gg_rct_Inicio <gen>) over 0.00 seconds
    • Else - Actions
      • Sound - Play Pal_notintown <gen>
      • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
In this trigger you check if the unit that uses item is paladin; if yes, you teleport him; if no, you play sound.


You could do it this way:
  • Untitled Trigger 001
    • Events
      • Unit - A unit owned by Player 1 (Red) Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Tome of Experience
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Hero manipulating item)) Equal to Footman
          • (Unit-type of (Hero manipulating item)) Equal to Knight
          • (Unit-type of (Hero manipulating item)) Equal to Rifleman
          • (Unit-type of (Hero manipulating item)) Equal to Mortar Team
          • (Unit-type of (Hero manipulating item)) Equal to Flying Machine
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Your_region <gen> contains (Hero manipulating item)) Equal to True
        • Then - Actions
          • -------- teleports to town --------
        • Else - Actions
          • -------- plays Pal_notintown sound --------
 
Status
Not open for further replies.
Top