• 🏆 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] Spell similar to Drow Ranger ultimate

Status
Not open for further replies.
Level 5
Joined
Dec 25, 2018
Messages
110
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:
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.
 
Level 5
Joined
Dec 25, 2018
Messages
110
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
 
Level 8
Joined
Mar 30, 2013
Messages
180
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
 
Level 5
Joined
Dec 25, 2018
Messages
110
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)
 
Level 8
Joined
Mar 30, 2013
Messages
180
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)


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
 
Level 5
Joined
Dec 25, 2018
Messages
110
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!
 
Status
Not open for further replies.
Top