• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Why does this lag?

Status
Not open for further replies.
Due a request, I made a spell, where you can shoot.
Now, if I cast this spell 4/5 times, it begins to lag, and after the dummies were cleaned up, it stops lagging.
  • SS Cast shoot
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shoot
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • S_OnOff Equal to False
        • Then - Actions
          • Set S_OnOff = True
          • Trigger - Turn on SS Missile Move <gen>
        • Else - Actions
      • -------- This trigger runs, if you cast the ability 'Shoot' --------
      • -------- This saves the caster in a variable --------
      • Set S_Caster = (Casting unit)
      • -------- This is an Integer, so other triggers can query the bullets. --------
      • Set S_Integer = (S_Integer + 1)
      • -------- This is the radius of the dummy unit. --------
      • Set S_DummyRadius[S_Integer] = 45.00
      • -------- This sets the damage. --------
      • -------- For more hero levels, just copy the if/then/else, and paste it in the else, and change level + damage --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Shoot for S_Caster) Equal to 1
        • Then - Actions
          • Set S_Damage[S_Integer] = 50.00
          • Set S_DummySpeed[S_Integer] = 15.00
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Shoot for S_Caster) Equal to 2
            • Then - Actions
              • Set S_Damage[S_Integer] = 100.00
              • Set S_DummySpeed[S_Integer] = 25.00
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Shoot for S_Caster) Equal to 3
                • Then - Actions
                  • Set S_Damage[S_Integer] = 150.00
                  • Set S_DummySpeed[S_Integer] = 35.00
                • Else - Actions
      • -------- This sets the facing angle of the caster, so the bullet flies with that degrees. --------
      • Set S_Real = (Facing of S_Caster)
      • -------- This sets the point, where the bullet will be created. --------
      • Set S_Point = (Position of S_Caster)
      • -------- The offset. Only, that it doesn't look like the bullet comes out of his body. --------
      • Set S_Point_Offset = (S_Point offset by 50.00 towards S_Real degrees)
      • -------- This creates the bullet at the point. --------
      • Unit - Create 1 Dummy - Shoot for (Owner of S_Caster) at S_Point_Offset facing S_Real degrees
      • -------- This is the 'lifetimer' of the bullet. Now it's on 1.5, that means, the bullet 'dies', if this is equal to 0 (1,5 seconds) --------
      • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
      • -------- This sets the dummy in a variable. --------
      • Set S_Dummy[S_Integer] = (Last created unit)
      • -------- This increases the flying height of the bullet, so it doesn't fly on the ground. --------
      • Unit - Add Ravenform to S_Dummy[S_Integer]
      • Unit - Remove Ravenform from S_Dummy[S_Integer]
      • Animation - Change S_Dummy[S_Integer] flying height to 70.00 at 0.00
      • Custom script: call RemoveLocation(udg_S_Point)
      • Custom script: call RemoveLocation(udg_S_Point_Offset)
  • SS Missile Move
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer S_IntegerA) from 1 to S_Integer, do (Actions)
        • Loop - Actions
          • -------- This picks all enemy units in a range of 30. --------
          • Set S_Point = (Position of S_Dummy[S_IntegerA])
          • Set S_Group = (Units within S_DummyRadius[S_IntegerA] of S_Point matching ((((Matching unit) is Dead) Equal to False) and (((Owner of (Matching unit)) is an enemy of (Owner of S_Dummy[S_IntegerA])) Equal to True)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in S_Group) Greater than or equal to 1
            • Then - Actions
              • Unit Group - Pick every unit in S_Group and do (Actions)
                • Loop - Actions
                  • -------- This action deals the damage. --------
                  • Unit - Cause S_Dummy[S_IntegerA] to damage (Picked unit), dealing S_Damage[S_IntegerA] damage of attack type Pierce and damage type Universal
                  • -------- This removes the dummy bullet from the game --------
                  • Unit - Remove S_Dummy[S_IntegerA] from the game
            • Else - Actions
          • Custom script: call RemoveLocation(udg_S_Point)
          • Custom script: call DestroyGroup(udg_S_Group)
          • -------- For a faster and better movement --------
          • -------- This picks all bullets on the map. --------
          • -------- The facing, where the bullet has to fly. --------
          • Set S_Real = (Facing of S_Dummy[S_IntegerA])
          • Set S_Point = (Position of S_Dummy[S_IntegerA])
          • -------- The offset. This is the 'movement speed'. --------
          • Set S_Point_Offset = (S_Point offset by 35.00 towards S_Real degrees)
          • -------- Moves the bullet. --------
          • Unit - Move S_Dummy[S_IntegerA] instantly to S_Point_Offset, facing S_Real degrees
          • Custom script: call RemoveLocation(udg_S_Point)
          • Custom script: call RemoveLocation(udg_S_Point_Offset)
          • Set S_Group = (Units of type Dummy - Shoot)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in S_Group) Equal to 0
            • Then - Actions
              • Set S_OnOff = False
              • Trigger - Turn off (This trigger)
            • Else - Actions
          • Custom script: call DestroyGroup(udg_S_Group)
All leaks should be cleaned up.
(Dummy has locust ability, is visible)
I also made a trigger, where dead dummies were removed after they die.

Hope someone can find the problem source.
 
Level 8
Joined
Apr 7, 2008
Messages
176
Im not even sure how that runs.... Since you've activated the looping trigger BEFORE you set the variables. Yes of course the computer only runs one function at a time, I just wouldnt take the chance of it bouncing back and forth between the 2 triggers.
 
I really am not sure of why it has such lag, but maybe:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • (Number of units in S_Group) Greater than or equal to 1
    • Then - Actions
    • Unit Group - Pick every unit in S_Group and do (Actions)
    • Loop - Actions
    • -------- This action deals the damage. --------
    • Unit - Cause S_Dummy[S_IntegerA] to damage (Picked unit), dealing S_Damage[S_IntegerA] damage of attack type Pierce and damage type Universal
    • -------- This removes the dummy bullet from the game --------
    • Unit - Remove S_Dummy[S_IntegerA] from the game
In this part, you should firstly pick up every unit from the group and THEN add this If/ then/ else, to check how many units there are inside.
 
Level 8
Joined
Apr 7, 2008
Messages
176
You know what I do when i come across the thing not working right? I put in text messages in each action part to make sure they are working right. Put them outside the loops then move them inside the loops. It's surprising what stuff isnt happening like you thought it would because of a condition or something trivial that noone know why it happens.
 

Rmx

Rmx

Level 19
Joined
Aug 27, 2007
Messages
1,164
This trigger is like UH !@#$% ...

It's like a combination of MUI and Normal GUI but not MUI o_O..

Well make your trigger MUI really hard to explain but the problem is in the **S_OnOff**

well removing the units is BAD .. try Adding EXPIRATION Timer like 0.01 seconds... make it better ..

Well nothing to add LEAKLESS .. but maybe the dummy units are cozing the lag coz of their model i think .. don't know :S 0_o
 
@Pharaoh_: the unit group is created in a variable, so it doesn't matter

@Guishiu: I added text messages, the number of units in the unitgroup, and it works fine :)

@Rmx: lol. Why is there a problem with S_OnOff ? And the units get an expiration timer (look first trigger), and when they die, there is a trigger, that waits 1 second, and then remove it, because I thought, it would lagg, because of the dead dummies :p (the trigger has locals, so there is no problem with wait). About the model: I tried different models, the missile of the firelord, lich, ... I can try no model, but....meh
 
Level 8
Joined
Apr 7, 2008
Messages
176
  • SS Missile Move
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer S_IntegerA) from 1 to S_Integer, do (Actions)
        • Loop - Actions
          • -------- This picks all enemy units in a range of 30. --------
          • Set S_Point = (Position of S_Dummy[S_IntegerA])
          • Set S_Group = (Units within S_DummyRadius[S_IntegerA] of S_Point matching ((((Matching unit) is Unknown) Equal to False) and (((Owner of (Matching unit)) is an enemy of (Owner of S_Dummy[S_IntegerA])) Equal to True)))
          • Unit Group - Pick every unit in S_Group and do (Actions)
            • Loop - Actions
              • -------- This action deals the damage. --------
              • Unit - Cause S_Dummy[S_IntegerA] to damage (Picked unit), dealing S_Damage[S_IntegerA] damage of attack type Pierce and damage type Universal
              • -------- This removes the dummy bullet from the game --------
              • Unit - Remove S_Dummy[S_IntegerA] from the game
              • Set S_Dummy[S_IntegerA] = No unit
          • Custom script: call RemoveLocation(udg_S_Point)
          • Custom script: call DestroyGroup(udg_S_Group)
          • -------- For a faster and better movement --------
          • -------- This picks all bullets on the map. --------
          • -------- The facing, where the bullet has to fly. --------
          • Set S_Real = (Facing of S_Dummy[S_IntegerA])
          • Set S_Point = (Position of S_Dummy[S_IntegerA])
          • -------- The offset. This is the 'movement speed'. --------
          • Set S_Point_Offset = (S_Point offset by 35.00 towards S_Real degrees)
          • -------- Moves the bullet. --------
          • Unit - Move S_Dummy[S_IntegerA] instantly to S_Point_Offset, facing S_Real degrees
          • Custom script: call RemoveLocation(udg_S_Point)
          • Custom script: call RemoveLocation(udg_S_Point_Offset)
          • Set S_Group = (Units of type Dummy - Shoot)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in S_Group) Equal to 0
            • Then - Actions
              • Set S_OnOff = False
              • Trigger - Turn off (This trigger)
            • Else - Actions
          • Custom script: call DestroyGroup(udg_S_Group)
Doesnt it turn itself off before it destroys the group?

Causes a group leak wouldnt it?

Either reset the Integer_S back to zero so the group can be recycled since it's empty anyways. Or move the custom script above the trigger off action. I would try it but I use the Originall WE and it wont let me save it.
 
Status
Not open for further replies.
Top