UnitApplyTimedLife

Sessional

New Member
Reaction score
5
I'm trying to get the dummy units of a spell I'm creating, but I'm having to problems. First, what is the Jass function to choose a group and apply an action to it? Second, what is the 'integer buffId' field for?
 
1. ForGroup(whichGroup, code callback)

2. The BuffId determines which kind of timed life will display. 'BTLF' is the default Timed Life, but I don't know the others. I just know their names:

Water elemental
Doom Guard
Sentry Ward

and the such.
 
I actually made a list just for the types of things like that...
It has the integer codes for all the timed lives (first list). They are called expiration timers.
 
1. You must use ForGroup():
JASS:
native ForGroup                 takes group whichGroup, code callback returns nothing


This means that you use for group like this:
JASS:
function GroupFor takes nothing returns nothing
 //Actions//
    //Example//
    call KillUnit(GetEnumUnit()) //Kills the picked unit//
endfunction

function Forgroup takes nothing returns nothing
    local group g = CreateGroup()
    call ForGroup(g,function GroupFor)
    call DestroyGroup(g)
    set g = null
endfunction


You also might want to set the settings of it by using something such as "call GroupEnumUnitsInRangeOfLoc" or something like that.

Groups are more complex but more flexible in JASS than GUI. :)

2. Just view elmst's thread

Generic ('BTLF') is what I use in GUI, it is like a "null" to the area I think. :D
 
Alright, thanks everyone.
One other question though, does the ForGroup have to call a function to add the expiration timer, or can I just add it within the current function I'm in.
 
If you want all the units in the group to expire, then you would put the UnitApplyTimedLife function inside the forgroup function, picked units are GetEnumUnit().

Or did I misunderstand you?
 
Yes, that is what I want. But the group is initially empty and it is spitting out an error. Do I have to have the empty group equal a CreateGroup() function?
 
Do you mean how you add units to a group. Well it depends what you want to do.

JASS:
native GroupEnumUnitsInRange takes group whichGroup, real x, real y, real radius, boolexpr filter returns nothing


All units in range with coords.

JASS:
native GroupEnumUnitsInRangeOfLoc takes group whichGroup, location whichLocation, real radius, boolexpr filter returns nothing


All units in range with Loc.

JASS:
native GroupEnumUnitsInRect takes group whichGroup, rect r, boolexpr filter returns nothing


All units in a rect (or Region in GUI language).

JASS:
native GroupEnumUnitsOfPlayer takes group whichGroup, player whichPlayer, boolexpr filter returns nothing


All units owned by a player.

JASS:
native GroupEnumUnitsOfType takes group whichGroup, string unitname, boolexpr filter returns nothing


All units of a certain type (shouldn't the string be an integer?)

And finally:

JASS:
ive GroupEnumUnitsSelected takes group whichGroup, player whichPlayer, boolexpr filter returns nothing


All units selected by a player.
 
Oh, I'll explain a bit better. This is my current Jass script.
JASS:
function XFrostNova takes nothing returns nothing
//===== @Variable Declaration @ =====
    local unit Caster
    local location CastingPoint
    local group Dummies
    local group Damaged
    local real Damage
    local real Angle
    local real MaxAoE
    local real CurrentAoE
    local player OwningPlayer
    
//===== @SetUp @ =====    
    set Caster = GetTriggerUnit()
    set CastingPoint = GetUnitLoc(Caster)
    set Damage =  GetUnitAbilityLevel(Caster, 'A000') * 50 + GetUnitLevel(Caster)
    set MaxAoE = GetUnitAbilityLevel(Caster, 'A000') * 400 + GetUnitLevel(Caster)
    set CurrentAoE = 100
    set Angle = 45
    set OwningPlayer = GetOwningPlayer(Caster)

//===== @UnitScript Actions@ =====    
    loop
        exitwhen CurrentAoE - 100 >= MaxAoE
        call CreateNUnitsAtLocFacingLocBJ(1, 'h000', OwningPlayer, PolarProjectionBJ(CastingPoint, CurrentAoE, Angle), null)
        call GroupAddUnit(Dummies, GetLastCreatedUnit())
        set CurrentAoE = CurrentAoE + 80
        if Angle > 315 then
            set Angle = 45
        else
            call DoNothing()
        endif
    endloop
    
    call ForGroup(Dummies, UnitApplyTimedLife(GetEnumUnit(), 'BTLF', 10.00))
     
endfunction


This line is my problem: 'call ForGroup(Dummies, UnitApplyTimedLife(GetEnumUnit(), 'BTLF', 10.00))'. It is spitting out this error: Cannot convert nothing to code.
 
Ah, well you need to put that inside a function so the script could read it.

Example:

JASS:

function Timed_For_Group takes nothing returns nothing
    call UnitApplyTimedLife(GetEnumUnit(), 'BTLF', 10.00)
endfunction

function Your_Function takes nothing returns nothing

// ... Blah, blah, blah...

    call ForGroup(Some_Group, function Timed_For_Group)

// ... Blah, blah, blah...

endfunction
 
Code is a not-so-well known variable. Basically, it can take nothing but a function reference. Some functions such as ForGroup() take code as a parameter, which means that you must but a function reference as Rheias showed above. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      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