• 🏆 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!

[Jass] Pick ever unit + matching

Status
Not open for further replies.
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

I have another question. I want to pick units in range that matching some conditions.

In GUI it's like that:
  • Unit Group - Pick every unit in (Units within 1850.00 of (Position of Diablos Mother 0001 <gen>) matching ((((Matching unit) is dead) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of Diablos Mother 0001 <gen>)) Equal to True))) and do (Actions)
    • Loop - Actions
      • Unit Group - Add (Picked unit) to FrozenLoveGrp
But now I want get it in Jass. If I convert this part from GUI to Jass it looks like:
JASS:
function Trig_Frozen_Love_2_Func001001003001 takes nothing returns boolean
    return ( IsUnitDeadBJ(GetFilterUnit()) == false )
endfunction

function Trig_Frozen_Love_2_Func001001003002 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(gg_unit_E000_0001)) == true )
endfunction

function Trig_Frozen_Love_2_Func001001003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Frozen_Love_2_Func001001003001(), Trig_Frozen_Love_2_Func001001003002() )
endfunction

function Trig_Frozen_Love_2_Func001A takes nothing returns nothing
    call GroupAddUnitSimple( GetEnumUnit(), udg_FrozenLoveGrp )
endfunction

function Trig_Frozen_Love_2_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsInRangeOfLocMatching(1850.00, GetUnitLoc(gg_unit_E000_0001), Condition(function Trig_Frozen_Love_2_Func001001003)), function Trig_Frozen_Love_2_Func001A )
endfunction

1) I don't think that this picking + matching stuff looks like this, if I write from the beginning each line in Jass or??

2) If it does, how should I keep it in my mind, that I always can type it without using hours of hours.

3) If not can someone (PLZ!) create the true Jass trigger with the matching stuff? So I can use it as an example, if I need more of them with different matching stuff or something like that.
 
Level 13
Joined
Mar 16, 2008
Messages
941
JASS:
function TriggerFrozenCondition takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(gg_unit_E000_0001) and GetUnitState(UNIT_STATE_LIFE) > 0.405
endfunction

function TriggerFrozenAction takes nothing returns nothing
    local unit u
    local location l = GetUnitLoc(gg_unit_E000_0001)
    local group g = CreateGroup()
    
    call GroupEnumUnitsInRangeLoc(g, l, 1800, Condition(function TriggerFrozenCondition))
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        call GroupAddUnit(udg_FrozenLoveGrp, u)
        call GroupRemoveUnit(g, u)
    endloop
    call RemoveLocation(l)
    call DestroyGroup(g)
    set l = null
    set g = null
    set u = null
Should be something like this.
 
Level 13
Joined
Mar 16, 2008
Messages
941
GetFilterUnit() is MatchingUnit in GUI. The "picking" stuff is from "loop" to "endloop". I didn't use a new function. If you use another function with "ForGroup" picked unit is GetEnumUnit (if I remember correctly). 0.405 is the point when a unit dies. A unit will never directly reach 0 hitpoints. In the moment it dies, its hitpoints are 0.405. Don't ask me why. You could also ask for 0 hitpoints, but then you would pick dying units too. (but not dead ones)
 
Level 11
Joined
Apr 29, 2007
Messages
826
Seas =)

Ok somehow this sounds not difficult but I got 2 questions:

"GetFilterUnit ()" <-- what is this? Is that just the unit that is picked if all matching stuff is correct?
GetFilterUnit() indeed returns what you call Matching Unit in GUI, while GetEnumUnit() returns the unit when you use a ForGroup loop.

"0.405" what's the number at the end of your 2nd line? =O

A unit's life cant go below 0.406, whenever a unit reaches 0.405 it will die. Thus, that number is for checking if a unit is alive. (Although this is really unreliable, a unit's life can still be changed after death)

e/ meh, too late :/
 
Status
Not open for further replies.
Top