- Joined
- Feb 22, 2013
- Messages
- 161
So I am having the worst time ever with my programming or something but I've been asking for help a lot more than I should.. But yet another problem has occured:
For some reason FirstOfGroup is returning a null unit, why is that?
JASS:
scope Taunt initializer TauntInit
globals
integer random
timer tauntTimer = CreateTimer()
unit caster
group tauntGroup = CreateGroup()
unit array unitIndex
integer unitCount
effect array sfx
endglobals
function TauntGroupFilter takes nothing returns boolean
return (GetFilterUnit() != caster) and (IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(caster)) == true) and (not (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == true) )
endfunction
function TauntExecute takes unit u returns nothing
set sfx[unitCount] = AddSpecialEffectTarget("Abilities\\Spells\\Other\\HowlOfTerror\\HowlTarget.mdl", u, "overhead")
call IssueTargetOrder(u, "attack", caster)
endfunction
function TauntCast takes nothing returns boolean
set caster = GetSpellAbilityUnit()
call DisplayTimedTextToPlayer(Player(0), 0, 0, 3.00, GetUnitName(caster))
if GetSpellAbilityId() == 'TA00' then
call GroupEnumUnitsInRange(tauntGroup, GetUnitX(caster), GetUnitY(caster), 256.00, Condition(function TauntGroupFilter))
call DestroyBoolExpr(Condition(function TauntGroupFilter))
call DisplayTimedTextToPlayer(Player(0), 0, 0, 3.00, "FirstOfGroup = " + GetUnitName(FirstOfGroup(tauntGroup)))
loop
set unitCount = unitCount + 1
set unitIndex[unitCount] = FirstOfGroup(tauntGroup)
exitwhen unitIndex[unitCount] == null
call TauntExecute(unitIndex[unitCount])
call GroupRemoveUnit(tauntGroup, unitIndex[unitCount])
endloop
endif
set caster = null
return false
endfunction
private function TauntInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function TauntCast))
set t = null
endfunction
endscope
For some reason FirstOfGroup is returning a null unit, why is that?