• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Group Problem _ JASS

Status
Not open for further replies.
JASS:
scope Sc1 initializer Init

    globals
        private player PID
    endglobals   
    

    private function Conditions takes nothing returns boolean
        return  IsUnitEnemy(GetFilterUnit(),PID) == true
    endfunction

    private function f1 takes nothing returns nothin
    local unit target = GetSpellTargetUnit()
    local real x = GetUnitX(target)
    local real y = GetUnitY(target)
    local group g

    set PID = GetOwningPlayer(caster)
    set g = GroupEnumUnitsInRange  (g, x, y,  256.00, Condition(function Conditions))
   
    call DestroyGroup(g)

    set g = null
    set target = null
    endfunction

endscope
Everytime I save it says: Cannot convert nothing to group, line
JASS:
    set g = GroupEnumUnitsInRange  (g, x, y,  256.00, Condition(function Conditions))
 
Level 14
Joined
Nov 23, 2008
Messages
187
JASS:
native GroupEnumUnitsInRange takes group whichGroup, real x, real y, real radius, boolexpr filter returns nothing

Function returns nothing, not group. So the correct call would be:

JASS:
call GroupEnumUnitsInRange(g, x, y, 256.00, Condition(function Conditions))

And you have mistake in function declaration - "nothin" instead of "nothing".

Also, I recommend you to use global "temporary" group for this, instead of creating and destroying it every time f1 runs, and store boolean expression in variable (to avoid multiple calls of Condition(code)). It would be more efficient.

JASS:
scope Sc1 initializer Init

    globals
      private player PID
      private group temp_gr = CreateGroup()
      private boolexpr bx = null
    endglobals

    private function Conditions takes nothing returns boolean
      return IsUnitEnemy(GetFilterUnit(),PID)
    endfunction

    private function f1 takes nothing returns nothing
      local unit target = GetSpellTargetUnit()
      local real x = GetUnitX(target)
      local real y = GetUnitY(target)

      set PID = GetOwningPlayer(caster)
      call GroupEnumUnitsInRange(temp_gr, x, y, 256.00, bx)

      // . . .
      set target = null
    endfunction
    // . . .
    private function Init takes nothing returns nothing
      set bx = Condition(function Conditions)
      // . . .
    endfunction
endscope
 
Status
Not open for further replies.
Top