Trigger Loop or repeat ?

guitar89

New Member
Reaction score
0
For trigger, it should make into 'loops', 'repeat typing' or 'periodic event' makes it better in anyway ? Example :-
Loops:
Code:
        Actions
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                Set SV_DamageGroup = (Units within 400.00 of SV_Position matching (((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is dead) Not equal to True)) and ((((Matching unit) belongs to an ally of (Owner of SV_Caster)) Not equal to True) and (((Matching unit) 
                Unit Group - Pick every unit in SV_DamageGroup and do (Actions)
                    Loop - Actions
                        Unit - Cause SV_Caster to damage (Picked unit), dealing 40.00 damage of attack type Spells and damage type Magic
                        Special Effect - Create a special effect attached to the origin of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\HeroBloodElfBlood.mdl
                        Special Effect - Destroy (Last created special effect)
                Custom script:   call DestroyGroup (udg_SV_DamageGroup)
                Set SV_DamageGroup1 = (Units within 200.00 of SV_Position matching (((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is dead) Not equal to True)) and ((((Matching unit) belongs to an ally of (Owner of SV_Caster)) Not equal to True) and (((Matching unit) 
                Unit Group - Pick every unit in SV_DamageGroup1 and do (Actions)
                    Loop - Actions
                        Unit - Cause SV_Caster to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Magic
                Custom script:   call DestroyGroup (udg_SV_DamageGroup1)

Repeating Typing:
Code:
        Actions
        Set SV_DamageGroup = (Units within 400.00 of SV_Position matching (((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is dead) Not equal to True)) and ((((Matching unit) belongs to an ally of (Owner of SV_Caster)) Not equal to True) and (((Matching unit) 
        Unit Group - Pick every unit in SV_DamageGroup and do (Actions)
            Loop - Actions
                Unit - Cause SV_Caster to damage (Picked unit), dealing 40.00 damage of attack type Spells and damage type Magic
                Special Effect - Create a special effect attached to the origin of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\HeroBloodElfBlood.mdl
                Special Effect - Destroy (Last created special effect)
        Custom script:   call DestroyGroup (udg_SV_DamageGroup)
        Set SV_DamageGroup1 = (Units within 200.00 of SV_Position matching (((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is dead) Not equal to True)) and ((((Matching unit) belongs to an ally of (Owner of SV_Caster)) Not equal to True) and (((Matching unit) 
        Unit Group - Pick every unit in SV_DamageGroup1 and do (Actions)
            Loop - Actions
                Unit - Cause SV_Caster to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Magic
        Custom script:   call DestroyGroup (udg_SV_DamageGroup1)
Set SV_DamageGroup = (Units within 400.00 of SV_Position matching (((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is dead) Not equal to True)) and ((((Matching unit) belongs to an ally of (Owner of SV_Caster)) Not equal to True) and (((Matching unit) 
        Unit Group - Pick every unit in SV_DamageGroup and do (Actions)
            Loop - Actions
                Unit - Cause SV_Caster to damage (Picked unit), dealing 40.00 damage of attack type Spells and damage type Magic
                Special Effect - Create a special effect attached to the origin of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\HeroBloodElfBlood.mdl
                Special Effect - Destroy (Last created special effect)
        Custom script:   call DestroyGroup (udg_SV_DamageGroup)
        Set SV_DamageGroup1 = (Units within 200.00 of SV_Position matching (((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is dead) Not equal to True)) and ((((Matching unit) belongs to an ally of (Owner of SV_Caster)) Not equal to True) and (((Matching unit) 
        Unit Group - Pick every unit in SV_DamageGroup1 and do (Actions)
            Loop - Actions
                Unit - Cause SV_Caster to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Magic
        Custom script:   call DestroyGroup (udg_SV_DamageGroup1)
Set SV_DamageGroup = (Units within 400.00 of SV_Position matching (((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is dead) Not equal to True)) and ((((Matching unit) belongs to an ally of (Owner of SV_Caster)) Not equal to True) and (((Matching unit) 
        Unit Group - Pick every unit in SV_DamageGroup and do (Actions)
            Loop - Actions
                Unit - Cause SV_Caster to damage (Picked unit), dealing 40.00 damage of attack type Spells and damage type Magic
                Special Effect - Create a special effect attached to the origin of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\HeroBloodElfBlood.mdl
                Special Effect - Destroy (Last created special effect)
        Custom script:   call DestroyGroup (udg_SV_DamageGroup)
        Set SV_DamageGroup1 = (Units within 200.00 of SV_Position matching (((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is dead) Not equal to True)) and ((((Matching unit) belongs to an ally of (Owner of SV_Caster)) Not equal to True) and (((Matching unit) 
        Unit Group - Pick every unit in SV_DamageGroup1 and do (Actions)
            Loop - Actions
                Unit - Cause SV_Caster to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Magic
        Custom script:   call DestroyGroup (udg_SV_DamageGroup1)

Or Periodic Event :
Code:
    Events
        Time - Every 0.90 seconds of game time
    Conditions
    Actions
        Set SV_DamageGroup = (Units within 400.00 of SV_Position matching (((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is dead) Not equal to True)) and ((((Matching unit) belongs to an ally of (Owner of SV_Caster)) Not equal to True) and (((Matching unit) 
        Unit Group - Pick every unit in SV_DamageGroup and do (Actions)
            Loop - Actions
                Unit - Cause SV_Caster to damage (Picked unit), dealing 40.00 damage of attack type Spells and damage type Magic
                Special Effect - Create a special effect attached to the origin of (Picked unit) using Objects\Spawnmodels\Human\HumanBlood\HeroBloodElfBlood.mdl
                Special Effect - Destroy (Last created special effect)
        Custom script:   call DestroyGroup (udg_SV_DamageGroup)
        Set SV_DamageGroup1 = (Units within 200.00 of SV_Position matching (((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is dead) Not equal to True)) and ((((Matching unit) belongs to an ally of (Owner of SV_Caster)) Not equal to True) and (((Matching unit) 
        Unit Group - Pick every unit in SV_DamageGroup1 and do (Actions)
            Loop - Actions
                Unit - Cause SV_Caster to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Magic
        Custom script:   call DestroyGroup (udg_SV_DamageGroup1)
Will add a control timer for Periodic Trigger.

The above is only example, kinda messy. What are the pros and cons of those above method, which is better for saving space, easy modification and easy making ? Hope you all will give your oppinions, please and thank you.
 

vypur85

Hibernate
Reaction score
803
Errr... It depends on situation? If everything is not possible, then you would have to type out everything. Whenever possible, use loops. As for the periodic event, I'm not sure what you're doing.

And... Wtf... You need a real pro to really read the code o_O". Use code tags. Press this
code.gif
...
 

guitar89

New Member
Reaction score
0
wat i mean is that instead of using loops, i use periodic event will be better ?

Loops :
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
*blah blah blah*
Wait 1.00 game-time seconds

Means that so *blah blah blah* action every seconds for 10 times

Periodic Event :
Events
Time - Every 1 seconds of game time
Conditions
Actions
*blah blah blah*
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Execution count of (This trigger)) Equal to 10
Then - Actions
Trigger - Turn off (This trigger)
Else - Actions


This means it also do *blah blah blah* action in every seconds for 10 times.

This should be easy to look it. Understand my description this time ?
 

Baltazhar

Active Member
Reaction score
55
I'm sorry, but I don't really understand the problem. I tried reading the code through, but I was afraid my head would explode.
I would suggest code-tags as well.

And make a more thorough description of your problem, to make it easier for us to help you :)

EDIT: Didn't see you last post there.

Yes, both trigger will repeat ur actions 10 times, then stop. Not sure what you are going to use them for, but both will work fine.
 

guitar89

New Member
Reaction score
0
my question is that i want to know which method is better for prevent lag(or lag reduction) and space(bytes) consume. I want to find a method that not lagging and save spaces.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Repeating Typing

This is a clear "No". If you ever need to change something... Or even without, it's just unreadable.


Of the two examples in post #3, there's nothing inherently wrong with either one.
Use whatever makes sense to you.


Also, triggers add next to nothing to map size...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top