1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Yet another question by me

Discussion in 'Triggers & Scripts' started by RollinDoubles, Aug 11, 2013.

  1. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    182
    Resources:
    0
    Resources:
    0
    Ok, so i deleted my original post, i am now editing because i was really tired when i made it. I fixed the problems now and cleaned it up, it now works but causes extreme delay after around 10 minutes.

    What this trigger does is check every .15 seconds to make sure that each base (a base is a county and a CoP, with a tower) has a defender in its CoP. It loops through by baseDefender Unit group and if it is the only available defender owned by the owner of the base then the current defender will be moved to the center of the circle. If there is other units within range of the circle owned by the owner of the base it will change the defender to one of those units.

    TLDR version: this trigger keeps a bases defender in its CoP.

    New Trig
    • Change Defender Range
      • Events
        • Time - Every 0.15 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in baseDefenders and do (Actions)
          • Loop - Actions
            • Set tempUnit1 = (Picked unit)
            • Set tempPoint1 = (Position of tempUnit1)
            • Set tempGroup1 = (Units within 300.00 of tempPoint1 matching ((Unit-type of (Matching unit)) Equal to Tower))
            • Set tempUnit2 = (Random unit from tempGroup1)
            • Set tempPoint2 = (Position of tempUnit2)
            • Set tempPlayer1 = (Owner of tempUnit1)
            • Set tempGroup2 = (Units within 175.00 of tempPoint2 matching ((((Matching unit) is A structure) Equal to False) and (((Owner of (Matching unit)) Equal to tempPlayer1) and ((Matching unit) Not equal to tempUnit1))))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Distance between tempPoint1 and tempPoint2) Greater than or equal to 175.00
                • (Number of units in tempGroup2) Equal to 0
              • Then - Actions
                • -------- Move the defender back to the center of the CoP for his base, if he is the only unit around. --------
                • Unit - Move tempUnit1 instantly to tempPoint2
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Distance between tempPoint1 and tempPoint2) Greater than or equal to 175.00
                    • (Number of units in tempGroup2) Greater than or equal to 1
                  • Then - Actions
                    • -------- This will switch the defender is there is another in the range. --------
                    • Unit Group - Remove tempUnit1 from baseDefenders
                    • Set tempUnit3 = (Random unit from tempGroup2)
                    • Unit Group - Add tempUnit3 to baseDefenders
                  • Else - Actions
            • Custom script: set udg_tempUnit1 = null
            • Custom script: set udg_tempUnit2 = null
            • Custom script: set udg_tempUnit3 = null
            • Custom script: set udg_tempPlayer1 = null
            • Custom script: call DestroyGroup( udg_tempGroup1 )
            • Custom script: set udg_tempGroup1 = null
            • Custom script: call DestroyGroup( udg_tempGroup2 )
            • Custom script: set udg_tempGroup2 = null
            • Custom script: call RemoveLocation( udg_tempPoint1 )
            • Custom script: set udg_tempPoint1 = null
            • Custom script: call RemoveLocation( udg_tempPoint2 )
            • Custom script: set udg_tempPoint2 = null



    Why does this trigger cause huge delay after about 10 minutes?





    edited to fix the trigger.
     
    Last edited: Aug 14, 2013
  2. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,530
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    this should be stored before you make the unit group. (Owner of tempUnit1)

    Neither of your triggers really make sense. Why do you create a group inside either the group or the loop only to remove one unit then destroy the group ?

    It would help if you explain what this is supposed to do.
     
  3. Arhowk

    Arhowk

    Joined:
    Aug 8, 2007
    Messages:
    2,753
    Resources:
    0
    Resources:
    0
    you dont have to null the variables.

    what exactly are you trying to do with this trigger?
     
  4. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    182
    Resources:
    0
    Resources:
    0
    Im sorry i was really tired when i made that, i fixed it now. I also updated the first post because i have a new question, why does this trigger make the game have delay after about 10 minutes? Do i have leaks?
     
  5. Arhowk

    Arhowk

    Joined:
    Aug 8, 2007
    Messages:
    2,753
    Resources:
    0
    Resources:
    0

    use a UnitIndexer and set it to a variable
    based on the custom value of the defender

    move the second if into the first if's else.

    add a check to make sure that tempgroup1 isnt null, else you would
    threadcrash

    set the timer to something much higher, like 1 second. (this goes with the first suggestion, linking every defender to the tower physically. you could
    just loop through every tower and check it that way, rather than checking
    for base defender and linking the last defender.
     
  6. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,530
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    Store owner of tempUnit1 into a variable. Then use it in the group check.
    Always store anything used twice or more into a variable.
     
  7. Arhowk

    Arhowk

    Joined:
    Aug 8, 2007
    Messages:
    2,753
    Resources:
    0
    Resources:
    0
    ?!?!? its used once. also, thrice or more because a global write takes longer than a function lookup
     
  8. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,530
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    It's in a group condition which means it runs once per unit it checks. So if 1 unit it runs once if 10 units it runs 10 times.

    I use twice or more because that was what I was told when I started.
     
  9. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    182
    Resources:
    0
    Resources:
    0
    Alright i been away for a few days, i was actually told you use an Unit Indexer before and i tried and well failed. I just give my self a big headache when trying to use it. But i did move the the second if.

    so besides trying to use a unit indexer. How else would it be possible to do this without making the game lag.

    Or

    Why does this generate lag after a little while

    Oh and just a side note, there is 146 Units in the base defender group at all times

    Last thing, when i make the event timer higher, units are able to get out of the circle they are in.

    to death: i did what you said to.


    If you guys want to see the newest v, just look at top post. i edited it in
     
  10. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,530
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    using unit indexer is very easy.

    All you do is have arrays for the info you want to store.
    damage / time / abi lvl / whatever you want.
    you then give it a global group ( only use for this spell never destroy the group)

    then when casting you store everything in the arrays using custom value of unit as the key value.

    for a loop trigger you use a group loop and load data from arrays using custom value of picked unit.
     
  11. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    182
    Resources:
    0
    Resources:
    0
    I get the basics of it (i think), but i just cant get it to work. I just attempted to make a spell called roar that is susposed to damage units for 25 health per second for 30 seconds. it doesnt work

    here is the triggers, lmk what i did wrong. maybe it will help me use it(the indexer) in my map

    spell
    • Custom Roar Cast
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Custom Roar
      • Actions
        • Set Key = (Custom value of (Target unit of ability being cast))
        • Set RoarTime[Key] = 35
        • Set RoarDmg[Key] = 25.00
        • Unit Group - Add (Target unit of ability being cast) to RoarUnits


    spell p2
    • Custom Roar Loop
      • Events
        • Time - Every 0.10 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in RoarUnits and do (Actions)
          • Loop - Actions
            • Set Key = (Custom value of (Picked unit))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • RoarTime[Key] Greater than or equal to 1
              • Then - Actions
                • Set RoarTime[Key] = (RoarTime[Key] - 1)
                • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - RoarDmg[Key])
              • Else - Actions
                • Unit Group - Remove (Picked unit) from RoarUnits
     
  12. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,530
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    if you mean that you want to damage a unit 25 damage every second for 30 seconds then your problem is in your counter.
    You need another integer array called counter
    and a temp unit variable to store picked unit
    after you store key in the second trigger you then need to reduce the counter and damage the unit. Also you should use 0.03 not 0.10
    remember that at 0.03 your counter needs to be at integer 34 that will be for one second.

    Right now your spell is only lasting about 3.5 seconds because of the counters.
     
  13. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    182
    Resources:
    0
    Resources:
    0
    Yes that is what i meant sorry.
    How come i cant use my RoarTime as my timer? thats what i intended it for.
    So what do i even do with Roartime if im going to add another integer array called counter?
    I stored the unit to tempunit (although this isnt necessary right, just for optimizing?)
    how come i should use .03 instead of .10, i thought that .10 was the lowest you could go and anything lower is read as .10?

    Right now it doesnt seem to be lasting for any time, as no units are being damaged?

    eh fuck it wanna give me an example of the counter variable using my triggers posted above
     
  14. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,530
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    its easier if you label questions as 1 / 2 and so on.

    1) you can't use it as your timer because you actually need 2 timers one for interval time ( every second) and one for timeout time ( when spell ends)

    2) this is just for speed and efficiency

    3) 0.03 should be used because it gives the best visual time. Not sure were you heard that as you can actually use times all the way down to somewere in this area 0.00001
    0.03 is the time were efficiency and visual effects become close 0.03125 is actually better but you can't use that in GUI.

    4) It's not lasting because the timer period is disappearing is going fast.
    0.10 means that the trigger runs 10 times every second so your spell will only last 3.5 seconds.
     
  15. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    182
    Resources:
    0
    Resources:
    0
    cast trig
    • Custom Roar Cast
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Custom Roar
      • Actions
        • Set Key = (Custom value of (Target unit of ability being cast))
        • Set RoarTime[Key] = 30
        • Set RoarDmg[Key] = 25.00
        • Unit Group - Add (Target unit of ability being cast) to RoarUnits


    loop trig
    • Custom Roar Loop
      • Events
        • Time - Every 0.03 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in RoarUnits and do (Actions)
          • Loop - Actions
            • Set tu = (Picked unit)
            • Set Key = (Custom value of tu)
            • Set Counter[Key] = 0.00
            • Set Counter[Key] = (Counter[Key] + 0.03)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Counter[Key] Less than 30.00
              • Then - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • RoarTime[Key] Greater than 0
                  • Then - Actions
                    • Set RoarTime[Key] = (RoarTime[Key] - 1)
                    • Unit - Set life of tu to ((Life of tu) - RoarDmg[Key])
                  • Else - Actions
                    • Unit Group - Remove tu from RoarUnits
              • Else - Actions



    well this is what i did, it still doesnt work. but im guessing im doing the counter var wrong?
     
  16. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,530
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    Here is the right way.

    cast trig
    • Custom Roar Cast
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Custom Roar
      • Actions
        • Set Key = (Custom value of (Target unit of ability being cast))
        • Set Counter[Key] = 0.00
        • Set RoarTime[Key] = 30
        • Set RoarDmg[Key] = 25.00
        • Unit Group - Add (Target unit of ability being cast) to RoarUnits


    loop trig
    • Custom Roar Loop
      • Events
        • Time - Every 0.03 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in RoarUnits and do (Actions)
          • Loop - Actions
            • Set tu = (Picked unit)
            • Set Key = (Custom value of tu)
            • Set Counter[Key] = (Counter[Key] + 0.03)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Counter[Key] Greater than or equal to 1.00
              • Then - Actions
                • Set Counter[Key] = 0.00
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • RoarTime[Key] Greater than 0
                  • Then - Actions
                    • Set RoarTime[Key] = (RoarTime[Key] - 1)
                    • Unit - Set life of tu to ((Life of tu) - RoarDmg[Key])
                  • Else - Actions
                    • Unit Group - Remove tu from RoarUnits
              • Else - Actions
     
  17. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    182
    Resources:
    0
    Resources:
    0
    alright so i wasnt to far off. it makes a little more sense now and i just an idea on how to keep units within a certain range of there circle.

    But on the other hand, the spell still doesnt work lol.

    any idea why? did i do something else wrong?
     
  18. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,530
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    do you use bribes unit indexer ?

    if you do then post the map or send it to me by pm and ill check it out tomorrow.
     
  19. RollinDoubles

    RollinDoubles

    Joined:
    Feb 10, 2011
    Messages:
    182
    Resources:
    0
    Resources:
    0
    ya i am, im actually literally using his example map

    i pm'd u

    by the way, why do you have to use an indexer for things like this?

    dont units already have a set custom value?
     
  20. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,842
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Nope they are not.
    Unit has 0 values because of the word "custom", meaning it is intended to be customized and used by the map maker.

    If you are asking to their Handle Id then yes they have, though this count all of the child handles, includes units, buffs, events, destructables, effects, and more.