- Joined
- Jul 26, 2008
- Messages
- 1,009
Alright, I have a spell that's pretty simple. The unit Wind Walks, and the units he passes through take damage (but only once per cast).
Problem is when they're added to the group, they don't get added. This causes the ForGroup to have nothing to remove from the group.
I've tried this with just a CreateGroup type of group. Same results.
I've tested to see if the group was over-written or wiped some how; it's not because if I set the bottom return to true it returns some units (No detectable pattern for which units).
The problem seems to be in this block:
If someone knows a better way to do this let me know and I can just do that.
Full Code:
Problem is when they're added to the group, they don't get added. This causes the ForGroup to have nothing to remove from the group.
I've tried this with just a CreateGroup type of group. Same results.
I've tested to see if the group was over-written or wiped some how; it's not because if I set the bottom return to true it returns some units (No detectable pattern for which units).
The problem seems to be in this block:
JASS:
if IsUnitEnemy(target, GetOwningPlayer(.caster)) and not(hit[GetUnitId(target)])and not(IsUnitType(target, UNIT_TYPE_DEAD) and IsUnitType(target, UNIT_TYPE_STRUCTURE))then
call BJDebugMsg(GetUnitName(GetFilterUnit()))
set d = xedamage.create()
set d.dtype = DAMAGE_TYPE_NORMAL
set d.atype = ATTACK_TYPE_PIERCE
call d.useSpecialEffect(GetAbilityEffectById(SPELLID, EFFECT_TYPE_TARGET, 0), "origin")
call d.damageTarget(.caster, target, 40+10*lvl)
set hit[GetUnitId(target)] = true
call d.destroy()
return true
endif
If someone knows a better way to do this let me know and I can just do that.
Full Code:
JASS:
struct RushOfTerror
private static integer SPELLID = 'RuoT'
private static integer BUFFID = 'BOwk'
private static real tick = 0.05
static boolean array hit
static unit caster
group grp
real dur = 0
private static method RemHit takes nothing returns nothing
call BJDebugMsg(GetUnitName(GetEnumUnit()))
set hit[GetUnitId(GetEnumUnit())] = false
endmethod
private static method GroupEm takes nothing returns boolean
local unit target = GetFilterUnit()
local integer lvl = GetUnitAbilityLevel(.caster, SPELLID)
local xedamage d
if IsUnitEnemy(target, GetOwningPlayer(.caster)) and not(hit[GetUnitId(target)])and not(IsUnitType(target, UNIT_TYPE_DEAD) and IsUnitType(target, UNIT_TYPE_STRUCTURE))then
call BJDebugMsg(GetUnitName(GetFilterUnit()))
set d = xedamage.create()
set d.dtype = DAMAGE_TYPE_NORMAL
set d.atype = ATTACK_TYPE_PIERCE
call d.useSpecialEffect(GetAbilityEffectById(SPELLID, EFFECT_TYPE_TARGET, 0), "origin")
call d.damageTarget(.caster, target, 40+10*lvl)
set hit[GetUnitId(target)] = true
call d.destroy()
return true
endif
return false
endmethod
private static method Timer takes nothing returns nothing
local thistype this = GetTimerData(GetExpiredTimer())
call GroupEnumUnitsInArea(.grp, GetUnitX(.caster), GetUnitY(.caster), 110, Filter(function thistype.GroupEm))
if GetUnitAbilityLevel(.caster, BUFFID) == 0 then
call ForGroup(.grp, function thistype.RemHit)
call ReleaseGroup(.grp)
call ReleaseTimer(GetExpiredTimer())
call .destroy()
endif
set .dur = .dur + tick
endmethod
private static method create takes unit caster returns thistype
local thistype this = thistype.allocate()
set .caster = caster
set .grp = NewGroup()
call TimerStart(NewTimerEx(this), tick, true, function thistype.Timer)
return this
endmethod
private static method Actions takes nothing returns nothing
if GetSpellAbilityId() == SPELLID then
call thistype.create(GetTriggerUnit())
endif
endmethod
//===========================================================================
private static method onInit takes nothing returns nothing
set gg_trg_RushOfTerror = CreateTrigger( )
call TriggerRegisterPlayerUnitEvent(gg_trg_RushOfTerror, GetLocalPlayer(), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
call TriggerAddAction( gg_trg_RushOfTerror, function thistype.Actions )
endmethod
endstruct