• 🏆 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] Replicating Locust Swarm Ability With Triggers

Status
Not open for further replies.
Level 10
Joined
Apr 4, 2010
Messages
509
It's doing what I want it to do, but it's causing so much lag. This should be easy to fix. I can't think of alternative.

Main:
  • Test
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit - Create 1 Peasant for Neutral Passive at ((Position of Paladin 0000 <gen>) offset by 100.00 towards (Random angle) degrees) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Peasant_Group
      • Set Peasant_Counts = (Peasant_Counts + 1)
      • Set Peasants[Peasant_Counts] = (Last created unit)
      • Unit - Create 1 Peasant for Neutral Passive at ((Position of Paladin 0000 <gen>) offset by 100.00 towards (Random angle) degrees) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Peasant_Group
      • Set Peasant_Counts = (Peasant_Counts + 1)
      • Set Peasants[Peasant_Counts] = (Last created unit)
      • Unit - Create 1 Peasant for Neutral Passive at ((Position of Paladin 0000 <gen>) offset by 100.00 towards (Random angle) degrees) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Peasant_Group
      • Set Peasant_Counts = (Peasant_Counts + 1)
      • Set Peasants[Peasant_Counts] = (Last created unit)
      • Unit - Create 1 Peasant for Neutral Passive at ((Position of Paladin 0000 <gen>) offset by 100.00 towards (Random angle) degrees) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Peasant_Group
      • Set Peasant_Counts = (Peasant_Counts + 1)
      • Set Peasants[Peasant_Counts] = (Last created unit)
      • Unit - Create 1 Peasant for Neutral Passive at ((Position of Paladin 0000 <gen>) offset by 100.00 towards (Random angle) degrees) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Peasant_Group
      • Set Peasant_Counts = (Peasant_Counts + 1)
      • Set Peasants[Peasant_Counts] = (Last created unit)
      • Unit - Create 1 Peasant for Neutral Passive at ((Position of Paladin 0000 <gen>) offset by 100.00 towards (Random angle) degrees) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Peasant_Group
      • Set Peasant_Counts = (Peasant_Counts + 1)
      • Set Peasants[Peasant_Counts] = (Last created unit)
      • Unit - Create 1 Peasant for Neutral Passive at ((Position of Paladin 0000 <gen>) offset by 100.00 towards (Random angle) degrees) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Peasant_Group
      • Set Peasant_Counts = (Peasant_Counts + 1)
      • Set Peasants[Peasant_Counts] = (Last created unit)
      • Unit - Create 1 Peasant for Neutral Passive at ((Position of Paladin 0000 <gen>) offset by 100.00 towards (Random angle) degrees) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Peasant_Group
      • Set Peasant_Counts = (Peasant_Counts + 1)
      • Set Peasants[Peasant_Counts] = (Last created unit)
      • Unit - Create 1 Peasant for Neutral Passive at ((Position of Paladin 0000 <gen>) offset by 100.00 towards (Random angle) degrees) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Peasant_Group
      • Set Peasant_Counts = (Peasant_Counts + 1)
      • Set Peasants[Peasant_Counts] = (Last created unit)
      • Unit - Create 1 Peasant for Neutral Passive at ((Position of Paladin 0000 <gen>) offset by 100.00 towards (Random angle) degrees) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Peasant_Group
      • Set Peasant_Counts = (Peasant_Counts + 1)
      • Set Peasants[Peasant_Counts] = (Last created unit)
Move: Test2
  • Test2
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Peasant_Counts) from 1 to Peasant_Counts, do (Actions)
        • Loop - Actions
          • Set Peasant_Random_Move = ((Position of Paladin 0000 <gen>) offset by (Random real number between 50.00 and 150.00) towards (Random angle) degrees)
          • Unit - Order Peasants[Peasant_Counts] to Move To Peasant_Random_Move
          • Custom script: call RemoveLocation (udg_Peasant_Random_Move)
 

Attachments

  • Locust Swarm Test.w3x
    17.5 KB · Views: 48
Level 7
Joined
Oct 11, 2008
Messages
304
Every (Position of Paladin 0000 <gen>) leak in your trigger.
Also the Test trigger could be a lot less work, just loop as the Test2 trigger.

Your Test has: 20 leaks.
Your Test2 has: 50 leaks per second.

EDIT: Also your Test2 is wrong, you're modifying the Peasant_Counts in the loop, you shouldn't, use another integer variable instead.


For each (Integer Peasant_Counts) from 1 to Peasant_Counts, do (Actions)
Unit - Order Peasants[Peasant_Counts] to Move To Peasant_Random_Move
>
For each (Integer <another variable>) from 1 to Peasant_Counts, do (Actions)
Unit - Order Peasants[<another variable>] to Move To Peasant_Random_Move
 
Level 10
Joined
Apr 4, 2010
Messages
509
Thanks, I think it fixed it.

  • Test
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Caster = Paladin 0000 <gen>
      • Set Peasant_Loop = 10
      • Unit - Create 1 Peasant for Neutral Passive at ((Position of Caster) offset by 100.00 towards (Random angle) degrees) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Peasant_Group
      • Set Peasant_Counts = (Peasant_Counts + 1)
      • Set Peasants[Peasant_Counts] = (Last created unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Peasant_Counts Equal to Peasant_Loop
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Trigger - Run (This trigger) (ignoring conditions)
  • Test2
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Peasant_Loop) from 1 to Peasant_Counts, do (Actions)
        • Loop - Actions
          • Set Peasant_Random_Move = ((Position of Caster) offset by (Random real number between 50.00 and 150.00) towards (Random angle) degrees)
          • Unit - Order Peasants[Peasant_Loop] to Move To Peasant_Random_Move
          • Custom script: call RemoveLocation (udg_Peasant_Random_Move)
 
Level 7
Joined
Oct 11, 2008
Messages
304
You still leak position :p in both triggers.

They should look something like this:

  • Test
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Peasant_CasterLoc = (Position of Paladin 0000 <gen>)
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set Peasant_Random_Move = (Peasant_CasterLoc offset by (Random real number between 50.00 and 150.00) towards (Random angle) degrees)
          • Unit - Create 1 Peasant for Neutral Passive at Peasant_Random_Move facing Default building facing degrees
          • Unit Group - Add (Last created unit) to Peasant_Group
          • Set Peasant_Counts = (Peasant_Counts + (Integer A))
          • Set Peasants[Peasant_Counts] = (Last created unit)
          • Custom script: call RemoveLocation (udg_Peasant_Random_Move)
      • Custom script: call RemoveLocation (udg_Peasant_CasterLoc)
  • Test2
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Set Peasant_CasterLoc = (Position of Paladin 0000 <gen>)
      • For each (Integer Peasant_TempInteger) from 1 to Peasant_Counts, do (Actions)
        • Loop - Actions
          • Set Peasant_Random_Move = (Peasant_CasterLoc offset by (Random real number between 50.00 and 150.00) towards (Random angle) degrees)
          • Unit - Order Peasants[Peasant_TempInteger] to Move To Peasant_Random_Move
          • Custom script: call RemoveLocation (udg_Peasant_Random_Move)
      • Custom script: call RemoveLocation (udg_Peasant_CasterLoc)
But take a note, both is not MUI and is far from how a spell should be coded.

I suggest take a look here, here and here (this one in special will help you a lot).
 
Level 10
Joined
Apr 4, 2010
Messages
509
Turns out converting it to MUI is pretty hard for me. :vw_wtf: Please help, I'm going to bed :goblin_cry:
:vw_death: :vw_sleep:

  • Chunks
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Chicken
    • Actions
      • Set Chunks_Index = (Chunks_Index + 1)
      • Set Chunk_Follow_Index = (Chunk_Follow_Index + 1)
      • Set Chunks_Unit_DeathTrigger[Chunks_Index] = (Dying unit)
      • Set Chunks_Summon_Point[Chunks_Index] = (Position of (Dying unit))
      • Unit - Create 1 Peasant for (Owner of Chunks_Unit_DeathTrigger[Chunks_Index]) at Chunks_Summon_Point[Chunks_Index] facing Default building facing degrees
      • Set Chunks_Core[Chunks_Index] = (Last created unit)
      • For each (Integer Chunks_Spawn_Loop_Integer) from 1 to 15, do (Actions)
        • Loop - Actions
          • Set Chunks_Random_Spawn = ((Position of Chunks_Core[Chunks_Index]) offset by 100.00 towards (Random angle) degrees)
          • Unit - Create 1 Peasant for (Owner of Chunks_Core[Chunks_Index]) at Chunks_Random_Spawn facing Default building facing degrees
          • Set Chunk_Follow_Index = (Chunk_Follow_Index + 1)
          • Set Chunk_Followers[Chunk_Follow_Index] = (Last created unit)
          • Unit Group - Add (Last created unit) to Chunks_TempGroup
          • Custom script: call RemoveLocation (udg_Chunks_Random_Spawn)
      • Set Chunks_Particle_Group[Chunks_Index] = Chunks_TempGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Chunks_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on Chunks Move <gen>
        • Else - Actions
      • Custom script: call DestroyGroup (udg_Chunks_TempGroup)
  • Chunks Move
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Chunks_Core[Chunks_Index] is dead) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in Chunks_Particle_Group[Chunks_Index] and do (Unit - Kill (Picked unit))
          • Set Chunks_Core[Chunks_Loop_Integer] = Chunks_Core[Chunks_Index]
          • Set Chunks_Counter[Chunks_Loop_Integer] = Chunks_Counter[Chunks_Index]
          • Set Chunks_Index = (Chunks_Index - 1)
          • Set Chunks_Loop_Integer = (Chunks_Loop_Integer - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Chunks_Index Equal to 0
            • Then - Actions
              • Trigger - Turn on (This trigger)
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Chunks_Particle_Group[Chunks_Index]) Less than or equal to (Chunk_Follow_Index - 7)
        • Then - Actions
          • Unit Group - Pick every unit in Chunks_Particle_Group[Chunks_Index] and do (Unit - Kill (Picked unit))
          • Set Chunks_Core[Chunks_Loop_Integer] = Chunks_Core[Chunks_Index]
          • Set Chunks_Counter[Chunks_Loop_Integer] = Chunks_Counter[Chunks_Index]
          • Set Chunks_Index = (Chunks_Index - 1)
          • Set Chunks_Loop_Integer = (Chunks_Loop_Integer - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Chunks_Index Equal to 0
            • Then - Actions
              • Trigger - Turn on (This trigger)
            • Else - Actions
        • Else - Actions
      • For each (Integer Chunks_Loop_Integer) from 1 to Chunk_Follow_Index, do (Actions)
        • Loop - Actions
          • Set Chunks_Random_Move = (((Position of Chunks_Core[Chunks_Index]) offset by 75.00 towards (Facing of Chunks_Core[Chunks_Index]) degrees) offset by (Random real number between 20.00 and 100.00) towards (Random angle) degrees)
          • Unit - Order Chunk_Followers[Chunk_Follow_Index] to Attack-Move To Chunks_Random_Move
          • Custom script: call RemoveLocation (udg_Chunks_Random_Move)
 

Attachments

  • Locust Swarm Test v1.w3x
    21.8 KB · Views: 92
Last edited:
Level 7
Joined
Oct 11, 2008
Messages
304
Unfortunately I can't help you with this part, since I hate GUI in Warcraft (was using vJass in my old times) and also I'm not part anymore of Warcraft :p now Starcraft <3


Some advice to you, here (Pet System) you can find a example how it's supposed to work, also you can find more example here :)
 
Status
Not open for further replies.
Top