• 🏆 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] Unit group only affecting one unit

Status
Not open for further replies.
Level 2
Joined
Jan 22, 2012
Messages
13
Hello, I have a very simple trigger which is much like an aoe Bloodlust. Using the items gives the buff within a 900 aoe. But, everytime I cast it, only 1 unit gets affected. The dummy has 0 cast point, backswing and ms, so ideally it should work.

  • Warsong Drums Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Speed dummy (item) (item)
    • Actions
      • Set temporaryunit = (Casting unit)
      • Set CastPoint = (Position of temporaryunit)
      • Unit - Create 1 Dummy Caster for (Owner of temporaryunit) at CastPoint facing Default building facing degrees
      • Set tempdummy = (Last created unit)
      • Unit - Add Warsong Drums dummy spel to (Last created unit)
      • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
      • Set CastGroup = (Units within 900.00 of CastPoint matching (((Matching unit) belongs to an ally of (Owner of temporaryunit)) Equal to True))
      • Unit Group - Pick every unit in CastGroup and do (Actions)
        • Loop - Actions
          • Unit - Order tempdummy to Orc Shaman - Bloodlust (Picked unit)
      • Set temporaryunit = No unit
      • Custom script: call RemoveLocation(udg_CastPoint)
      • Custom script: call DestroyGroup(udg_CastGroup)
I tried adding a display/debug message inside the group. Apparently, after the first run of the loop, it says that the number of units in the group is 0. However, it still runs x amount of times as if there are units in the group.

Any solutions/suggestions? :(

Edit: trigger tags
 
Hello frend, I cannot view picture because I am on mobie, but I gess to this is problemm:
U use for excample create one dummy at casters point and order it to cast bloodlust on picked unist, that will afect only one unit. U should create 1 dummy at point of picked units and then order it. Ofc that was mistake what I was making and I gess to that is ur mistake.

EDIT: just saw to that is mistake, also ur coding is bad because of leaks, and u dont need set tempdummy = no unit.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
For certain spells (such as bloodlust), this isn't necessary.
The values you mentioned in your initial post are the only values needed for a dummy to work that way (cast point, backswing and MS must all equal zero).
So it should actually work with a single dummy (also with 1 dummy per target of course, but that creates unnecessary dummies).

Might the problem perhaps be with the Bloodlust-ability?

Edit: this is the (leaking :D) test. All units on the map received the Bloodlust buff.
  • Actions
    • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
    • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
      • Loop - Actions
        • Unit - Order (Last created unit) to Orc Shaman - Bloodlust (Picked unit)
    • Unit - Kill (Last created unit)
    • Unit - Remove (Last created unit) from the game
(Doesn't use an expiration timer for the dummy either)
 
Level 2
Joined
Jan 22, 2012
Messages
13
For certain spells (such as bloodlust), this isn't necessary.
The values you mentioned in your initial post are the only values needed for a dummy to work that way (cast point, backswing and MS must all equal zero).
So it should actually work with a single dummy (also with 1 dummy per target of course, but that creates unnecessary dummies).

Might the problem perhaps be with the Bloodlust-ability?

Edit: this is the (leaking :D) test. All units on the map received the Bloodlust buff.
  • Actions
    • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
    • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
      • Loop - Actions
        • Unit - Order (Last created unit) to Orc Shaman - Bloodlust (Picked unit)
    • Unit - Kill (Last created unit)
    • Unit - Remove (Last created unit) from the game
(Doesn't use an expiration timer for the dummy either)

I am loading my map with the changes now. You are right. I made the careless mistake of not setting the cooldown of the bloodlust to 0. *facepalm lol

But I did learn that I should just kill it instead of adding a timer. Probably it is more efficient. My triggering skills are like 5 years old already lol
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Indeed: Triggering Unit will always be faster, but "much faster" is an overstatement.
Still, you should only use "Triggering Unit" (as a replacement for Attacked-/Casting-/Entered-/Dying-/Decaying-/Leveling-/... unit).

Basically: the subject of the event is the Triggering Unit, and since it is local (still available after a wait) and usually somewhat faster, it should be used instead of the specific form.
E.g.: "Unit - A unit Loses an item". The subject is the unit that loses the item, so "Triggering Unit" will be the same as "Hero Manipulating Item".
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
I tested like this:
JASS:
library leakTest1 initializer onInit
    globals
        private timer t = CreateTimer()
        private constant integer dummies = 1
        private constant integer events = 2000
        private integer c = 0
        private trigger acquire = CreateTrigger()
    endglobals
    
    private function acquireItem takes nothing returns boolean
        local unit u
        local integer i = events
        loop
            /*
            set u = GetDyingUnit()
            set u = GetDyingUnit()
            set u = GetDyingUnit()
            set u = GetDyingUnit()
            set u = GetDyingUnit()
            set u = GetDyingUnit()
            set u = GetDyingUnit()
            set u = GetDyingUnit()
            set u = GetDyingUnit()
            set u = GetDyingUnit()
            */
            
            set u = GetTriggerUnit()
            set u = GetTriggerUnit()
            set u = GetTriggerUnit()
            set u = GetTriggerUnit()
            set u = GetTriggerUnit()
            set u = GetTriggerUnit()
            set u = GetTriggerUnit()
            set u = GetTriggerUnit()
            set u = GetTriggerUnit()
            set u = GetTriggerUnit()
            
            
            exitwhen i == 0
            set i = i - 1
        endloop
        set u = null
        return false
    endfunction

    private function leaks takes nothing returns nothing
        local integer i = dummies
        
        loop
            exitwhen i == 0
            call KillUnit(CreateUnit(Player(0), 'hfoo', 0, 0, 0))
            set c = c + 1
            set i = i - 1
        endloop
    endfunction
    
    private function pauseResume takes nothing returns nothing
        if ModuloInteger(GetTriggerExecCount(GetTriggeringTrigger()) , 2) == 1 then
            call BJDebugMsg("started")
            call TimerStart(t, 0.01, true, function leaks)
        else
            call BJDebugMsg("paused, " + "dummies created: " + I2S(c))
            call PauseTimer(t)
        endif
    endfunction

    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterPlayerEvent(t, Player(0), EVENT_PLAYER_END_CINEMATIC)
        call TriggerAddAction(t, function pauseResume)
        call TriggerRegisterAnyUnitEventBJ(acquire, EVENT_PLAYER_UNIT_DEATH)
        call TriggerAddCondition(acquire, function acquireItem)
    endfunction
endlibrary

It creates 100 footmen dummy units per second and kills the right away. The death event is registered, and for each death it does 2000 loops, and each loops uses the event response 10 times.

I was setting u = GetDyingUnit() 100*2000*10 = 2 000 000 times per second and didn't notice any difference compared to u = GetTriggerUnit()

I don't care if one uses GetTriggerUnit or some other event response.
 
Status
Not open for further replies.
Top