• 🏆 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 is not working =/

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi!

This trigger isn't working, and I can't figure why. It's supposed to spawn a creep around the unit from "Wood-Group" unit-group.

This is the trigger that Adds a unit to "Wood_Group"
  • Unit enters Wood
    • Events
      • Unit - A unit enters Woods1 <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Unit Group - Add (Triggering unit) to Wood_Group
This is the trigger that's supposed to spawn a creep if less than 3 Hostile Creeps are detected in the area. Chances are set to 99% just for testing purposes.
  • Creep Spawn
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Number of units in Wood_Group) Greater than 0
    • Actions
      • Unit Group - Pick every unit in Wood_Group and do (Actions)
        • Loop - Actions
          • Set Temp_Group = (Units within 800.00 of (Position of (Picked unit)) matching (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True))
          • Set Temp_Point = (Random point in (Region centered at (Position of (Picked unit)) with size (1000.00, 1000.00)))
          • Set Temp_Point2 = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in Temp_Group) Greater than or equal to 3
            • Then - Actions
              • Unit Group - Remove (Picked unit) from Wood_Group
            • Else - 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 99
                • Then - Actions
                  • Unit - Create 1 (Random level (Random integer number between 1 and 5) creep unit-type) for Neutral Hostile at Temp_Point facing Temp_Point2
                  • Unit - Order (Last created unit) to Attack-Move To Temp_Point2
                  • Unit Group - Add (Last created unit) to Creep_Group
                • Else - 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 99
                • Then - Actions
                  • Unit - Create 1 Floating Energy for Neutral Passive at Temp_Point facing Temp_Point2
                  • Unit - Order (Last created unit) to Attack-Move To Temp_Point2
                • Else - Actions
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Custom script: call RemoveLocation(udg_Temp_Point2)
      • Custom script: set bj_wantDestroyGroup = true
 
  • (Number of units in Temp_Group) Greater than or equal to 3
You are checking the number of units in Temp_Group, yet you add them in the Creep_Group
  • Unit Group - Add (Last created unit) to Creep_Group
Why don't you move these:
  • Unit - Create 1 Floating Energy for Neutral Passive at Temp_Point facing Temp_Point2
  • Unit - Order (Last created unit) to Attack-Move To Temp_Point2
to the previous if then else? They share the same condition.

The triggers needs to be reworked: loads of leaks, unnecessary creation of a region (use point with polar offset instead), a local group should be attached on the wood_group hero, otherwise it's not "MUI".
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
1) I changed "Add to Creep_Group" for "Add to Temp_Group"

2) For testing purposes I set the same chance for both, but in reality, Hostile creeps has 20%, and Floating Energy has 10%, besides, I want them to be able to spawn simultaneously.

3) Removed the creation of region, and used Polar Offset, as you said, with Random Distance (100 - 800), and random degrees (0 - 359)

4) I don't understand what you said about:
A local group should be attached on the wood_group hero
Its a common Unit-Group variable. Would you please, explain me this? Sounds like that "GetLocalPlayer()" I've never know how to use xD

This is the trigger so far (Changes already made, only that "Local-Group" thing left)

  • Creep Spawn
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Number of units in Wood_Group) Greater than 0
    • Actions
      • Unit Group - Pick every unit in Wood_Group and do (Actions)
        • Loop - Actions
          • Set Temp_Group = (Units within 800.00 of (Position of (Picked unit)) matching (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True))
          • Set Temp_Point = ((Position of (Picked unit)) offset by (Random real number between 100.00 and 800.00) towards (Random real number between 0.00 and 359.00) degrees)
          • Set Temp_Point2 = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in Temp_Group) Greater than or equal to 3
            • Then - Actions
              • Unit Group - Remove (Picked unit) from Wood_Group
            • Else - 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 99
                • Then - Actions
                  • Unit - Create 1 (Random level (Random integer number between 1 and 5) creep unit-type) for Neutral Hostile at Temp_Point facing Temp_Point2
                  • Unit - Order (Last created unit) to Attack-Move To Temp_Point2
                  • Unit Group - Add (Last created unit) to Temp_Group
                • Else - 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 99
                • Then - Actions
                  • Unit - Create 1 Floating Energy for Neutral Passive at Temp_Point facing Temp_Point2
                  • Unit - Order (Last created unit) to Attack-Move To Temp_Point2
                • Else - Actions
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Custom script: call RemoveLocation(udg_Temp_Point2)
      • Custom script: set bj_wantDestroyGroup = true
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Remove the "Custom script: set bj_wantDestroyGroup = true" part, since you don't want to remove the unit group.

Also, why do you have "Or - Any conditions are true" and you only have one condition under it?

You also need to remove the unit group leak (Temp_Group). Add this at the end:

  • Custom script: call DestroyGroup(udg_Temp_Group)
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
1) Lol... I'm a beginner thinkin that "leak" is everything what involves a Group xD. Thanks, I was just wondering why only 1 creep was spawning xD

2) The map's a RPG. I'm having more than one Combat region in the map... about... I don't know, 34... Should I make 34 triggers (One for each region...) or Insert all the combat regions inside the same timer event with 34 "If/Then/Else"?

3)DestroyGroup(udg_Temp_Group) This is the group I was trying to destroy with the bj_wantDestroyGroup script :p. EDIT: The script exactly as you told me to do, crashes the game. Shouldn't it be "call Destroy..." ?
 
Status
Not open for further replies.
Top