1. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  2. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  3. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  4. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice

[Trigger] Spell similar to Drow Ranger ultimate

Discussion in 'Triggers & Scripts' started by Fakuspakus, Dec 26, 2018.

Tags:
  1. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    75
    Resources:
    0
    Resources:
    0
    Spell: Gain damage bonus if theres no enemy units nearby.

    This trigger activates another trigger if selected hero is X.
    • Picked
      • Events
        • Unit - A unit Sells a unit
      • Conditions
        • (Unit-type of (Sold unit)) Equal to Sharpshooter
      • Actions
        • Set SniperMax = (SniperMax + 1)
        • Set Sniper[SniperMax] = (Sold unit)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • SniperMax Equal to 1
          • Then - Actions
            • Trigger - Turn on Sniper <gen>
          • Else - Actions


    second trigger
    • Sniper
      • Events
        • Time - Every 1.00 seconds of game time
      • Conditions
      • Actions
        • For each (Integer SniperCur) from 1 to SniperMax, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Number of units in (Units within 100.00 of (Position of Sniper[SniperCur]) matching (((Triggering unit) belongs to an enemy of (Owner of Sniper[SniperCur])) Equal to True))) Greater than or equal to 1
              • Then - Actions
                • Unit - Remove Sniper buff from Sniper[SniperCur]


    Theres problem with enemy detection (Number of units[...]), bonus is lost right after buying X hero.
    Maybe 'triggering unit' is wrong there, what else should I pick?
     
    Last edited: Dec 26, 2018
  2. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,420
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Try using (Matching unit) instead of (Triggering unit).

    Also, just as a warning, "(Units within 100.0 of (Position of Sniper[SniperCur]))" has two leaks: one that creates a new group (Units within...) and one that creates a location for a unit (Position of...). Here is how I would clean it up:
    • Sniper
      • Events
        • Time - Every 1.00 seconds of game time
      • Conditions
      • Actions
        • For each (Integer SniperCur) from 1 to SniperMax, do (Actions)
          • Loop - Actions
            • Set SniperLocation = (Position of Sniper[SniperCur])
            • Set SniperGroup = (Units within 100.00 of SniperLocation)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Number of units in SniperGroup) matching (((Matching unit) belongs to an enemy of (Owner of Sniper[SniperCur])) Equal to True))) Greater than or equal to 1
              • Then - Actions
                • Unit - Remove Sniper buff from Sniper[SniperCur]
            • Custom script: call RemoveLocation(udg_SniperLocation)
            • Custom script: call DestroyGroup(udg_SniperGroup)


    Basically, assign them to variables and then remove/destroy them when you're done using them.
     
  3. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    75
    Resources:
    0
    Resources:
    0
    Ok so I got removing of the ability working, but now I have issue of adding ability back when theres no enemy units around.
    (Buff is added in first trigger)
    • Sniper Copy 2
      • Events
        • Time - Every 1.00 seconds of game time
      • Conditions
      • Actions
        • For each (Integer SniperCur) from 1 to SniperMax, do (Actions)
          • Loop - Actions
            • Set SniperLocation = (Position of Sniper[SniperCur])
            • Set SniperGroup = (Units within 800.00 of (Position of Sniper[SniperCur]) matching (((Matching unit) belongs to an enemy of (Owner of Sniper[SniperCur])) Equal to True))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Number of units in SniperGroup) Greater than or equal to 1
              • Then - Actions
                • Unit - Remove Sniper buff from Sniper[SniperCur]
                • Set Sniper[SniperCur] = Sniper[SniperMax]
                • Set SniperMax = (SniperMax - 1)
                • Set SniperCur = (SniperCur - 1)
              • Else - Actions
        • Custom script: call RemoveLocation(udg_SniperLocation)
        • Custom script: call DestroyGroup(udg_SniperGroup)



    Version with adding back:
    • Sniper Copy 2
      • Events
        • Time - Every 1.00 seconds of game time
      • Conditions
      • Actions
        • For each (Integer SniperCur) from 1 to SniperMax, do (Actions)
          • Loop - Actions
            • Set SniperLocation = (Position of Sniper[SniperCur])
            • Set SniperGroup = (Units within 800.00 of (Position of Sniper[SniperCur]) matching (((Matching unit) belongs to an enemy of (Owner of Sniper[SniperCur])) Equal to True))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Number of units in SniperGroup) Greater than or equal to 1
              • Then - Actions
                • Unit - Remove Sniper buff from Sniper[SniperCur]
                • Set Sniper[SniperCur] = Sniper[SniperMax]
                • Set SniperMax = (SniperMax - 1)
                • Set SniperCur = (SniperCur - 1)
              • Else - Actions
                • Unit - Add Sniper buff to Sniper[SniperCur]
                • Set Sniper[SniperCur] = Sniper[SniperMax]
                • Set SniperMax = (SniperMax - 1)
                • Set SniperCur = (SniperCur - 1)
        • Custom script: call RemoveLocation(udg_SniperLocation)
        • Custom script: call DestroyGroup(udg_SniperGroup)

    In above code even removal doesnt work if I add 'else actions' section
     
  4. The10th-X

    The10th-X

    Joined:
    Mar 30, 2013
    Messages:
    169
    Resources:
    3
    Models:
    1
    Maps:
    2
    Resources:
    3
    From what i see the problem is the MUI part, it doesn't really make sense?
    You shouldn't be changing the SniperCur integer at all, it's just a reference value to the current loop.
    The SniperMax shouldn't be changed either, because the moment it deactivates the ability it's also setting that to 0 (Assuming in this instance there's only 1 of that hero), so the loop would be going from 1 to 0 which just doesn't work, which is why your ability isn't getting added back

    You should just make it so it'll remove it if it's greater and the other way around, don't touch the integers

    If it's a unit that has only one instance, add a condition before everything in a loop that checks whether X Boolean is true, and if it isn't do nothing, when that unit dies set the X boolean to false so it doesn't act on that unit and set secondary integer to -1 and when that is =0, set SniperMax to 0 and turn of the trigger then

    Probably done a piss poor job at explaining this, if you need an example i'll make a quick mock up
     
  5. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    75
    Resources:
    0
    Resources:
    0
    Works fine now, but theres still minor issue: every few seconds bonus dissapears for like 0.5 seconds:
    • Sniper Copy 2
      • Events
        • Time - Every 1.00 seconds of game time
      • Conditions
      • Actions
        • For each (Integer SniperCur) from 1 to SniperMax, do (Actions)
          • Loop - Actions
            • Set SniperLocation = (Position of Sniper[SniperCur])
            • Set SniperGroup = (Units within 800.00 of (Position of Sniper[SniperCur]) matching (((Matching unit) belongs to an enemy of (Owner of Sniper[SniperCur])) Equal to True))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Number of units in SniperGroup) Greater than or equal to 1
              • Then - Actions
                • Unit - Remove Sharpshooter Book from Sniper[SniperCur]
                • Custom script: call UnitRemoveAbility(udg_Sniper[udg_SniperCur] ,'B008')
              • Else - Actions
                • Player - Disable Sharpshooter Book for (Owner of Sniper[SniperCur])
                • Unit - Add Sharpshooter Book to Sniper[SniperCur]
        • Custom script: call RemoveLocation(udg_SniperLocation)
        • Custom script: call DestroyGroup(udg_SniperGroup)
     
  6. The10th-X

    The10th-X

    Joined:
    Mar 30, 2013
    Messages:
    169
    Resources:
    3
    Models:
    1
    Maps:
    2
    Resources:
    3

    Is the bonus based on an aura spell? if it is it doesn't activate immediately because of how aura's work in wc3, so if so base it off an item bonus instead

    Otherwise, try adding extra conditions to the unit group, instead of one line just set the unit group as unit in range then select everyone in that unit group, add an if + or statement for thing like "If a unit is dead, remove pick unit from unit group"

    Dead units are still selected in the unit group stuff afaik, if their bodies are still there
     
  7. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    75
    Resources:
    0
    Resources:
    0
    Ok I added condition for unit to be alive, thats helpful to know for the future.
    Issue was somewhere else tho, disabling spellbook on Map initialization fixed it.
    Thanks for help!