Problems with my slow trigger!

Quakern

New Member
Reaction score
1
Hey there!
I am trying to make a trigger, that everyone in 100 range of the attacked unit (attacking unit=my slow tower), is running 20% slower for 2 seconds.

My trigger now looks like this:
Trigger:
  • Slow
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Frost Tower
    • Actions
      • Custom script: local group udg_slow
      • Custom script: set udg_slow = GetUnitsInRangeOfLocAll(100.00, GetUnitLoc(GetAttackedUnitBJ()))
      • Custom script: call ForGroupBJ( udg_slow,( GetUnitDefaultMoveSpeed(GetEnumUnit()) * ( 80.00 / 100.00 ) ) )
      • Custom script: call TriggerSleepAction( 2 )
      • Custom script: call ForGroupBJ( udg_slow,( GetUnitDefaultMoveSpeed(GetEnumUnit()) ) )
      • Custom script: call DestroyGroup(udg_slow)


I get for some reason error on the wait command and destroy the local variable :S
Anyone knows how to fix this? Or something like this would work? I'm kindy new on this, so im not 100% sure ^^
 

Lehona

New Member
Reaction score
12
Don't name the variable udg_<name>. The prefix udg_ is for global variables which are created with gui.

But I'm not sure whether this is the error.
 

HydraRancher

Truth begins in lies
Reaction score
197
The sleep trigger action (I'm not sure if this is right) I think it has to be 2.00


Remove all the udg's. udg = universal defined global variable. But you're using locals right?
 

Quakern

New Member
Reaction score
1
The sleep trigger action (I'm not sure if this is right) I think it has to be 2.00


Remove all the udg's. udg = universal defined global variable. But you're using locals right?

Yes im using local variables :) I still get error on the wait command, and the destroy command. It says: "Invalid argument type(real)".
My trigger now looks like this:
Trigger:
  • Slow
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Frost Tower
    • Actions
      • Custom script: local group slow
      • Custom script: set slow = GetUnitsInRangeOfLocAll(100.00, GetUnitLoc(GetAttackedUnitBJ()))
      • Custom script: call ForGroupBJ( slow,( GetUnitDefaultMoveSpeed(GetEnumUnit()) * ( 80.00 / 100.00 ) ) )
      • Wait 2.00 seconds
      • Custom script: call ForGroupBJ( slow,( GetUnitDefaultMoveSpeed(GetEnumUnit()) ) )
      • Custom script: call DestroyGroup(slow)
 

cleeezzz

The Undead Ranger.
Reaction score
268
Custom script: call ForGroupBJ( slow,( GetUnitDefaultMoveSpeed(GetEnumUnit()) * ( 80.00 / 100.00 ) ) )
Custom script: call ForGroupBJ( slow,( GetUnitDefaultMoveSpeed(GetEnumUnit()) ) )

you cant use ForGroupBJ like that.. why are you using GUI, your trigger is pretty much JASS
 

Quakern

New Member
Reaction score
1
Custom script: call ForGroupBJ( slow,( GetUnitDefaultMoveSpeed(GetEnumUnit()) * ( 80.00 / 100.00 ) ) )
Custom script: call ForGroupBJ( slow,( GetUnitDefaultMoveSpeed(GetEnumUnit()) ) )

you cant use ForGroupBJ like that.. why are you using GUI, your trigger is pretty much JASS

Like I said, I'm new on this. So im kinda a noob on JASS :p
How should I do it then?:)
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
There are several approaches you could take. If you prefer to stay with more GUI than JASS, and because groups are "agent" type, you can pass the local group off to a global variable so you can access it with a GUI group loop:
Trigger:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Footman
    • Actions
      • Custom script: local group slow
      • Set TempPoint = (Position of (Triggering unit))
      • Set TempGroup = (Units within 100.00 of TempPoint)
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • -------- Stuff --------
      • Custom script: set slow = udg_TempGroup
      • Wait 2.00 seconds
      • Custom script: set udg_TempGroup = slow
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • -------- Stuff --------
      • Custom script: call DestroyGroup(slow)
      • Custom script: set slow = null

This won't leak the group even though it destroys "slow" instead of "TempGroup" because we made "slow" point to the same actual group in memory. There's still only one unit group being used.

To actually use the ForGroup JASS command, you need to make a separate function for your actions; you can't just specify it in the ForGroup command itself. You'll pretty much need to convert the whole trigger to JASS to accomplish this:

JASS:
function Slow_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetAttacker()) == &#039;hfoo&#039; //&#039;hfoo&#039; is the rawcode for a Footman.  Substitute for your frost tower.
endfunction

function RestoreUnit_Callback takes nothing returns nothing
    call SetUnitMoveSpeed(GetEnumUnit(), GetUnitDefaultMoveSpeed(GetEnumUnit()))
endfunction

function SlowUnit_Callback takes nothing returns nothing
    call SetUnitMoveSpeed(GetEnumUnit(), GetUnitDefaultMoveSpeed(GetEnumUnit())*0.8)
endfunction

function Slow_Actions takes nothing returns nothing
    local group slow = CreateGroup()
    call GroupEnumUnitsInRange(slow, 100.00, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), null)
    call ForGroup(slow, function SlowUnit_Callback)
    call TriggerSleepAction(2.)
    call ForGroup(slow, function RestoreUnit_Callback)
    call DestroyGroup(slow)
    set slow = null
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Untitled_Trigger_001, Condition( function Slow_Conditions ) )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Slow_Actions )
endfunction

FYI, I've de-GUI'd that a bit, using [ljass]GroupEnumUnitsInRange[/ljass] instead of [ljass]GetUnitsInRangeOfLocAll[/ljass].

There are yet other ways to approach this, but it should get you started.

------------------

Also FYI, this method isn't very safe. If a unit is slowed, and then hit again before the first slow has ended, the first slow period will restore the unit's movement speed before the second slow should wear off. I'll leave it as an exercise for you to think about how to account for that...
 

Quakern

New Member
Reaction score
1
Thanks Weep! :) That worked :D
My trigger now looks like this:
Trigger:
  • Slow
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Frost Tower
    • Actions
      • Custom script: local group slow
      • Set TempPointSlow = (Position of (Attacked unit))
      • Set TempGroup = (Units within 200.00 of TempPointSlow)
      • Custom script: call RemoveLocation(udg_TempPointSlow)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Set (Picked unit) movement speed to ((Default movement speed of (Picked unit)) x (80.00 / 100.00))
      • Custom script: set slow = udg_TempGroup
      • Wait 2.00 seconds
      • Custom script: set udg_TempGroup = slow
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Set (Picked unit) movement speed to (Default movement speed of (Picked unit))
      • Custom script: call DestroyGroup(slow)
      • Custom script: set slow = null
 

Laiev

Hey Listen!!
Reaction score
188
Trigger:
  • Slow
    • Set TempGroup = (Units within 200.00 of TempPointSlow)


TempGroup = group = leak

Trigger:
  • Slow
    • Set TempGroup = (Units within 200.00 of TempPointSlow)
    • Custom script: set udg_TempGroup = slow


set group which you don't destroy before set AGAIN = leak
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
TempGroup = group = leak
set group which you don't destroy before set AGAIN = leak
Incorrect. In fact, destroying TempGroup would prevent the trigger from working after the wait.
This won't leak the group even though it destroys "slow" instead of "TempGroup" because we made "slow" point to the same actual group in memory. There's still only one unit group being used.
 

Laiev

Hey Listen!!
Reaction score
188
Incorrect. In fact, destroying TempGroup would prevent the trigger from working after the wait.

You don't destroy the group, you just set other group to value of that group, then you just destroy the newest group, leaving one alive. So you leak.
 
General chit-chat
Help Users
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top