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

A trigger that won't work =/

Status
Not open for further replies.

Deleted member 177737

D

Deleted member 177737

Hey, I'm creating an ability that when cast on a point will create a dummy unit, then all units not friendly to player 1 will have their location and facing saved then ordered to move towards the dummy unit. After that a countdown timer is started.

After that I have two triggers;

The first sends the units back after the countdown from the main trigger finished and then starts another countdown timer.

The second orders the units to face their original facing.


When I go in-game and cast the spell on a point near an enemy nothing happens.


  • Throw Rock
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Throw Rock
    • Actions
      • Set Temporary_Points[1] = (Target point of ability being cast)
      • Unit - Create 1 Dummy (Throw Rock) for Neutral Passive at Temporary_Points[1] facing Default building facing degrees
      • Set Temporary_Units[1] = (Last created unit)
      • Unit Group - Pick every unit in (Units within 400.00 of Temporary_Points[1] matching (((Picked unit) belongs to an enemy of Player 1 (Red)) Equal to True)) and do (Actions)
        • Loop - Actions
          • -------- Increases the temp interger. --------
          • Set Temporary_Interger = (Temporary_Interger + 1)
          • -------- Saves the picked unit. --------
          • Set Temporary_Units2[Temporary_Interger] = (Picked unit)
          • -------- Saves the picked unit's original position. --------
          • Set Temporary_Points2[Temporary_Interger] = (Position of Temporary_Units[Temporary_Interger])
          • -------- Saves the facing of the unit. --------
          • Set Temporary_UnitFacing[Temporary_Interger] = (Facing of Temporary_Units[Temporary_Interger])
          • -------- Tells the picked unit to move towards the point that the spell was cast to. --------
          • Unit - Order Temporary_Units2[Temporary_Interger] to Move To Temporary_Points[1]
      • Countdown Timer - Start Timer_ThrowRockAbility[1] as a One-shot timer that will expire in 35.00 seconds
      • Unit - Remove Temporary_Units[1] from the game
      • Set Temporary_Interger2 = Temporary_Interger


  • Throw Rock Unit Reset
    • Events
      • Time - Timer_ThrowRockAbility[1] expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Temporary_UnitGroup[1] and do (Actions)
        • Loop - Actions
          • Unit - Order Temporary_Units2[Temporary_Interger] to Move To Temporary_Points[Temporary_Interger]
          • Set Temporary_Interger = (Temporary_Interger - 1)
      • Countdown Timer - Start Timer_ThrowRockAbility[2] as a One-shot timer that will expire in 15.00 seconds


  • Throw Rock Unit Facing Reset
    • Events
      • Time - Timer_ThrowRockAbility[2] expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Temporary_UnitGroup[1] and do (Actions)
        • Loop - Actions
          • Unit - Make Temporary_Units2[Temporary_Interger2] face Temporary_Points2[Temporary_Interger2] over 0.00 seconds
          • Set Temporary_Interger2 = (Temporary_Interger2 - 1)



As far as I can think there is some problem with the unit group in the first trigger. (Yes, I know that this has many leaks. I'll clean it up when I get it working)

+rep
 

Deleted member 177737

D

Deleted member 177737

Hmm... Is there another event that means kind of the same thing as "Unit finishes casting an ability event"? but that includes "Target Point of Ability Being Cast"?
 

Deleted member 177737

D

Deleted member 177737

I've gotten the first trigger to work but not the second and third are bugging out...

Here is what the triggers look like now:


  • one
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Throw Rock
    • Actions
      • Set Temporary_Interger = 0
      • Set Temporary_Points[1] = (Target point of ability being cast)
      • Set Temporary_UnitGroup[1] = (Units within 400.00 of Temporary_Points[1] matching (((Picked unit) belongs to an enemy of Player 1 (Red)) Equal to True))
      • Unit Group - Pick every unit in Temporary_UnitGroup[1] and do (Actions)
        • Loop - Actions
          • -------- Increases the temp interger. --------
          • Set Temporary_Interger = (Temporary_Interger + 1)
          • Game - Display to (All players) the text: (String(Temporary_Interger))
          • -------- Saves the picked unit. --------
          • Set Temporary_Units2[Temporary_Interger] = (Picked unit)
          • -------- Saves the picked unit's original position. --------
          • Set Temporary_Points2[Temporary_Interger] = (Position of Temporary_Units[Temporary_Interger])
          • -------- Saves the facing of the unit. --------
          • Set Temporary_UnitFacing[Temporary_Interger] = (Facing of Temporary_Units[Temporary_Interger])
          • -------- Tells the picked unit to move towards the point that the spell was cast to. --------
          • Unit - Order Temporary_Units2[Temporary_Interger] to Move To Temporary_Points[1]
      • Set Temporary_Interger2 = Temporary_Interger
      • Countdown Timer - Start Timer_ThrowRockAbility[1] as a One-shot timer that will expire in 35.00 seconds
      • Trigger - Turn off (This trigger)



  • two
    • Events
      • Time - Timer_ThrowRockAbility[1] expires
    • Conditions
    • Actions
      • Game - Display to (All players) the text: BLARGH
      • Unit Group - Pick every unit in Temporary_UnitGroup[1] and do (Actions)
        • Loop - Actions
          • Unit - Order Temporary_Units2[Temporary_Interger] to Move To Temporary_Points2[Temporary_Interger]
          • Set Temporary_Interger = (Temporary_Interger - 1)
      • Countdown Timer - Start Timer_ThrowRockAbility[2] as a One-shot timer that will expire in 15.00 seconds
      • Set Temporary_Interger = 0



  • three
    • Events
      • Time - Timer_ThrowRockAbility[2] expires
    • Conditions
    • Actions
      • Game - Display to (All players) the text: BLARGH TWO
      • Unit Group - Pick every unit in Temporary_UnitGroup[1] and do (Actions)
        • Loop - Actions
          • Unit - Make Temporary_Units2[Temporary_Interger2] face Temporary_Points2[Temporary_Interger2] over 0.00 seconds
          • Set Temporary_Interger2 = (Temporary_Interger2 - 1)
      • Set Temporary_Interger2 = 0
      • Trigger - Turn on one <gen>



There should be no reason for any of this not to work as far as I know, I've looked over each trigger multiple times and theres just nothing I can see to change anymore. =/

BTW Thanks for the help atleast getting part 1 to work, that was a big step.
 

Deleted member 177737

D

Deleted member 177737

The text shows up for both triggers 2 and 3 (the text is there to make sure the triggers being turned on) but the units don't move anywhere and in trigger 3 the units all face the same direction.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
The text shows up for both triggers 2 and 3 (the text is there to make sure the triggers being turned on) but the units don't move anywhere and in trigger 3 the units all face the same direction.

Could you check if the variables are empty in the 2nd and 3rd trigger?
Display a text when the group variable and unit variables are not empty.
Also check the tempinteger values, I can't see why this won't work.
The actions should be performed for each unit in the group so there is probably something wrong with the variables here..
 

Deleted member 177737

D

Deleted member 177737

Looks like you are right, the X Y points aren't being saved properly.



Edit: Thanks to your idea of how to debug this I may have just found the error, one of the triggers was set to be Temporary_Unit instead of Temporary_Unit2. Going to change some things around and see if this works.

Edit2: I managed to fix it up so that the units now move towards the selected point and then back after the timer expires. Now there are still 2 bugs left; The first is that the units don't change their facing in the second trigger, and the second is that the trigger is affecting all units regardless of the player.

Edit3: Well I got one unit to face an angle but it was for the other unit. The two bugs are still the same as above. Trying some more stuff now.





Edit4: The trigger 2 and 3 are now fixed but I've spotted yet another bug in trigger 1. As far as I can tell when the Temporary Unit Group is created it isn't following the condition set within itself, because the system keeps picking up and using player 1's character.
The Temporary Unit Group should only work on units not allied to player 1, but that didn't work when I set that as a condition within the action either.

Anyone know a way to get thhis working?


  • one
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Throw Rock
    • Actions
      • Set Temporary_Interger = 0
      • Set Temporary_Points[1] = (Target point of ability being cast)
      • Set Temporary_UnitGroup[1] = (Units within 400.00 of Temporary_Points[1] matching (((Picked unit) belongs to an enemy of Player 1 (Red)) Equal to True))
      • Unit Group - Pick every unit in Temporary_UnitGroup[1] and do (Actions)
        • Loop - Actions
          • -------- Increases the temp interger. --------
          • Set Temporary_Interger = (Temporary_Interger + 1)
          • Game - Display to (All players) the text: (String(Temporary_Interger))
          • -------- Saves the picked unit. --------
          • Set Temporary_Units2[Temporary_Interger] = (Picked unit)
          • Game - Display to (All players) the text: ((Name of Temporary_Units2[Temporary_Interger]) + (String(Temporary_Interger)))
          • -------- Saves the picked unit's original position. --------
          • Set Temporary_Points2[Temporary_Interger] = (Position of Temporary_Units2[Temporary_Interger])
          • Game - Display to (All players) the text: ((String((Center X of (Region centered at Temporary_Points2[Temporary_Interger] with size (1.00, 1.00))))) + (................ + (String((Center Y of (Region centered at Temporary_Points2[Temporary_Interger] with size (1.00, 1.00)))))))
          • -------- Saves the facing of the unit. --------
          • Set Temporary_UnitFacing[Temporary_Interger] = (Facing of Temporary_Units2[Temporary_Interger])
          • Game - Display to (All players) the text: ((String((Facing of Temporary_Units2[Temporary_Interger]))) + (................ + (String(Temporary_Interger))))
          • -------- Tells the picked unit to move towards the point that the spell was cast to. --------
          • Unit - Order Temporary_Units2[Temporary_Interger] to Move To Temporary_Points[1]
      • Set Temporary_Interger2 = Temporary_Interger
      • Countdown Timer - Start Timer_ThrowRockAbility[1] as a One-shot timer that will expire in 35.00 seconds
      • Trigger - Turn off (This trigger)
 

Attachments

  • 1.jpg
    1.jpg
    237.1 KB · Views: 62
Last edited by a moderator:
Level 14
Joined
Apr 20, 2009
Messages
1,543
Game - Display to (All players) the text: ((String((Center X of (Region centered at Temporary_Points2[Temporary_Interger] with size (1.00, 1.00))))) + (................ + (String((Center Y of (Region centered at Temporary_Points2[Temporary_Interger] with size (1.00, 1.00)))))))

Just to be sure, can you change this to:
  • Custom script - call DisplayTextToPlayer(Player(0), 0, 0, "X: " + R2S(GetUnitX(udg_Temporary_Units2[udg_Temporary_Interger])) + " Y: " + R2S(GetUnitY(udg_Temporary_Units2[udg_Temporary_Interger])))
This is just to make sure that you get the actual X and Y coordinates of unit Temporary_Units2[Temporary_Interger]
It might be that your not setting the variables correctly. This gets the coordinates of the units directly.


Also, try displaying all the unit ID's inside the unit groups.
  • Custom script - call DisplayTextToPlayer(Player(0), 0, 0, R2S(GetHandleId(GetEnumUnit())))
Put that inside the pick every unit action, this way it displays what unit ID the units have that are picked. Do this in every Pick unit action to see if they are different from each other. Add some string inside like:

  • Custom script - call DisplayTextToPlayer(Player(0), 0, 0, "First trigger: " + R2S(GetHandleId(GetEnumUnit())))
  • Custom script - call DisplayTextToPlayer(Player(0), 0, 0, "Second trigger: " + R2S(GetHandleId(GetEnumUnit())))
  • Custom script - call DisplayTextToPlayer(Player(0), 0, 0, "Third trigger: " + R2S(GetHandleId(GetEnumUnit())))
If the unit ID's are different from each other then Temporary_UnitGroup[1] get's altered inbetween the triggers.
Then all you'd have to do is debug and check where it get's altered and why. If this is the case you should be abled to fix it.

EDIT: Nevermind the above, check this:

Set Temporary_UnitGroup[1] = (Units within 400.00 of Temporary_Points[1] matching (((Picked unit) belongs to an enemy of Player 1 (Red)) Equal to True))

Change Picked unit to Matching unit...
 
Last edited:

Deleted member 177737

D

Deleted member 177737

Its funny how one little thing can make or break the trigger, everything works as intended now. Thanks for all the help.
 
Status
Not open for further replies.
Top