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