Komaqtion
You can change this now in User CP.
- Reaction score
- 469
Hi!
I was just making a small spell for some1, and he only wanted 1 - 2 - 3 units to be affected, so I thought I'd use the "GroupEnumUnitsInRangeCounted" native...
I haven't actually used this native before (XD) but I though it'd do exactly what it says, only add a max amount of units to the group, but that doesn't seem to work
Here's the code atm, and now it's only supposed to add 1 unit to the group, right ? :S
Well, the debug msg is showing 8 !?
How can that happen ? :S
Here's the code:
Any ideas, or have I done something wrong ? :S
I was just making a small spell for some1, and he only wanted 1 - 2 - 3 units to be affected, so I thought I'd use the "GroupEnumUnitsInRangeCounted" native...
I haven't actually used this native before (XD) but I though it'd do exactly what it says, only add a max amount of units to the group, but that doesn't seem to work
Here's the code atm, and now it's only supposed to add 1 unit to the group, right ? :S
Well, the debug msg is showing 8 !?
How can that happen ? :S
Here's the code:
JASS:
scope Spell initializer Init
globals
private constant integer SPELL_ID = 039;A00H039;
private constant integer BUFF_ID = 039;B000039;
private constant integer THUNDER_ID = 039;A00I039;
private constant integer DUMMY_ID = 039;dmmy039;
private group enum = CreateGroup()
private unit cast
endglobals
private function Filters takes nothing returns boolean
return IsUnitType( GetFilterUnit(), UNIT_TYPE_STRUCTURE ) != true and IsUnitAlly( GetFilterUnit(), GetOwningPlayer( cast ) ) != true and GetWidgetLife( GetFilterUnit() ) >= 0.405
endfunction
private function Spell_Check takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID and GetUnitAbilityLevel( GetTriggerUnit(), BUFF_ID ) > 0
endfunction
private function ForGroup_Actions takes nothing returns nothing
local unit u = GetEnumUnit()
local player p = GetOwningPlayer ( u )
local real x = GetUnitX( u )
local real y = GetUnitY( u )
local unit d = CreateUnit( p, DUMMY_ID, x, y, bj_UNIT_FACING )
local real dur = 1.0
local integer lvl = GetUnitAbilityLevel( cast, SPELL_ID )
call UnitApplyTimedLife( d, 039;BTLF039;, dur )
call UnitAddAbility( d, THUNDER_ID )
call SetUnitAbilityLevel( d, THUNDER_ID, lvl )
call IssueImmediateOrder( d, "thunderclap" )
set u = null
set d = null
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer lvl = GetUnitAbilityLevel( u, SPELL_ID )
local real x = GetUnitX( u )
local real y = GetUnitY( u )
local real radius = I2R( ( 100 * lvl ) + 500 )
set cast = u
call GroupEnumUnitsInRangeCounted( enum, x, y, radius, Filter( function Filters ), 1 )
call BJDebugMsg( I2S( CountUnitsInGroup( enum ) ) )
call ForGroup( enum, function ForGroup_Actions )
set u = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i >= 11
call TriggerRegisterPlayerUnitEvent( t, Player( i ), EVENT_PLAYER_UNIT_SPELL_EFFECT, null )
set i = i + 1
endloop
call TriggerAddCondition( t, Condition( function Spell_Check ) )
call TriggerAddAction( t, function Actions )
endfunction
endscope
Any ideas, or have I done something wrong ? :S