• 🏆 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!

[Trigger] Why doesn't my trigger work?

Status
Not open for further replies.
Level 18
Joined
Aug 23, 2008
Messages
2,319
I've made this trigger:
  • Unit facing
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Less than or equal to 50
        • Then - Actions
          • Unit - Make UNIT face 180.00 over 1.00 seconds
          • Wait (Random real number between 0.50 and 3.00) seconds
          • Unit - Make UNIT face 00.00 over 1.00 seconds
        • Else - Actions
          • Do nothing
If I'm not mistaken, this trigger would cause the unit to have a chance of 50% every second to turn around 180 degrees for 0.50-3.00 seconds, and then turn back.

For some reason the unit doesn't do anything. Can anyone figure out how come?
 
Level 10
Joined
Dec 11, 2006
Messages
359
have you set a variable to witch unit to face that angle?

You could create another tirgger with the event: Unit learns a skill
And the set a variable that says like YourUnit = triggering unit

Then instead if Make Unit face 180.00 over 1 seonds

Do Make YourUnit face 180.00 over 1 seonds

If thats the case
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
No, I've just selected the unit in the map, because it was pre-placed. I thought such variables were only used to destroy them at the end of the trigger to prevent leaks.


EDIT: Ok, I've made a variable of the unit and inserted it in the trigger, but still nothing changed. should I make variables that if the random number is equal to variable 1, i get those 3 actions? that would make it a huge trigger! :eek:
 
Level 10
Joined
Aug 15, 2008
Messages
448
Try this one:
  • Unit facing
    • Events
      • Time - every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set RANDOM = random integer number between 1 and 100
      • If (all conditions are true) then (then actions) else (else actions)
        • If - conditions
          • RANDOM is less or equal to 50
        • Then - actions
          • Unit - make UNIT face ((facing of UNIT)-180) over 1.00 seconds
          • Wait (random real number between 0.50 and 3.00) seconds
          • Unit - make UNIT face ((facing of UNIT)+180) over 1.00 seconds
        • Else - actions
          • Do nothing
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
The variable isn't actually needed anyway. I don't see how your trigger isn't working, unless you've made a stupid mistake such as using a "Unit" variable which isn't initialized at all.

Do you have following action (or similar to it) in one of your triggers?
  • Set UNIT = (Preset unit on the map)
You should also add some debugmessages, such as:

  • Unit facing
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Less than or equal to 50
        • Then - Actions
          • Game - display text message to player: "The unit should change its angle now"
          • Game - ping minimap at position of UNIT
          • Unit - Make UNIT face 180.00 over 1.00 seconds
          • Wait (Random real number between 0.50 and 3.00) seconds
          • Unit - Make UNIT face 00.00 over 1.00 seconds
        • Else - Actions
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
That's the point of the trigger, Crusad3r91.

And yes, I have inserted a Unit Variable referring to the pre-placed unit on the map, and double-checked if that variable refers to the right unit.

my trigger now is
  • Unit facing 2
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set Unit1 = Unit 0012 <gen>
      • Set RANDOM = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RANDOM Less than or equal to 50
        • Then - Actions
          • Game - Display to (All players) the text: Works so far!
          • Unit - Make Unit1 face ((Facing of Unit1) - 180.00) over 1.00 seconds
          • Wait (Random real number between 0.50 and 3.00) seconds
          • Unit - Make Unit1 face ((Facing of Unit1) + 180.00) over 1.00 seconds
        • Else - Actions
          • Do nothing
That was a good suggestion, Eleandor! The text message does display, so the Event and Condition are good, but there´s something wrong with the Actions.

And no, my unit stays put the entire game. He only turns around randomly by use of this trigger.
 
Level 10
Joined
Aug 15, 2008
Messages
448
Well, anyway, here's my testmap. I set the timer to 5.00 secs so the footman has actually all the time for turning once, waiting and then turning a second time.
Check it in the World Editor: I see that my trigger is actually equal to yours...

NOTE: I've used another trigger for setting the UNIT variable...
 

Attachments

  • TESTMAP.w3x
    12.7 KB · Views: 25
Level 21
Joined
Aug 21, 2005
Messages
3,699
If the unit doesn't move at all, then try adding the "ping minimap" action. If the center of the minimap is pinged, Unit1 hasn't been set correctly.

But judging by your post, the unit is turning, it only seems random? If the unit IS turning, but it seems random, the problem is probably that:

Every 1 second the trigger runs, which makes the unit face -180 over 1 second. By the time he's turned, the trigger already runs again, making the unit face -180 again, while at the same time (after waiting 0.5 to 3 seconds), it's turning 180 ° AGAIN. This might make it look totally random.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Works with me too, but when I change the time of my Event, the game message shows up like it should but the unit still doesn't do anything!

I've also deleted the unit, placed it again, set variable to the new unit, and made the triggers containing the variable again. No result.

Also, I've added that ping minimap Action, and it pings at the unit (who is far from the center of the map).
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Crusad3r91, your a genius! You just solved the problem xD

I wanted to make sure the unit wouldn't go off somewhere, so I put his base speed to 0 '^^
I've set it to 1 now, and he turn around! :thumbs_up:

Thanks everyone for doing so much trouble for me. You guys rock :wink:
 
Status
Not open for further replies.
Top