| 05-11-2008, 01:18 AM | #1 |
I've been trying to figure out the problem for a while. A friend has helped help me occasionally, but I think it's unfair to have him take me step-by-step through every little problem I have while learning JASS (which has been a lot). So I'm finally going to post here, asking for help. It works if I just call the function instead of using a timer with callback; but once I add the timer, it stops working. And, yes, I know that I have nothing to stop the trigger early if the channeling is interrupted. I figured I should probably get it working through the whole duration before I bother with that. Drain Blood:globals unit Caster location Loc integer d endglobals function Trig_Drain_Blood_Conditions takes nothing returns boolean return GetSpellAbilityId( ) == 'A003' endfunction function Drain_Blood_Filter takes nothing returns boolean return IsPlayerEnemy (GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405 and not IsUnitType( GetFilterUnit(), UNIT_TYPE_FLYING) endfunction function Drain_Blood_CopyGroup takes group g returns group set bj_groupAddGroupDest = CreateGroup() call ForGroup(g, function GroupAddGroupEnum) return bj_groupAddGroupDest endfunction function Drain_Blood_Callback takes nothing returns nothing local timer t = GetExpiredTimer() local unit c = Caster local real x = GetLocationX(Loc) local real y = GetLocationY(Loc) local boolexpr b = Condition(function Drain_Blood_Filter) local group g = CreateGroup() local group n local unit f call GroupEnumUnitsInRange(g, x, y, 400., b) set n = Drain_Blood_CopyGroup(g) loop set f = FirstOfGroup(n) exitwhen f == null call UnitDamageTarget(c, f, 10, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null) call GroupRemoveUnit(n, f) endloop set d = d - 1 set c = null set g = null set n = null if d == 0 then call DestroyTimer(t) set Caster = null set Loc = null endif set t = null endfunction function Trig_Drain_Blood_Actions takes nothing returns nothing local timer t = CreateTimer() set Caster = GetSpellAbilityUnit() set Loc = GetSpellTargetLoc() set d = 10 call TimerStart(t, 1, true, function Drain_Blood_Callback) set t = null endfunction //=========================================================================== function InitTrig_Drain_Blood takes nothing returns nothing set gg_trg_Drain_Blood = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Drain_Blood, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Drain_Blood, Condition( function Trig_Drain_Blood_Conditions ) ) call TriggerAddAction( gg_trg_Drain_Blood, function Trig_Drain_Blood_Actions ) endfunction |
| 05-11-2008, 01:43 AM | #2 |
First of all, this thing isn't MUI, so verify that you are not using those global variables in another function. * Your problem is that you got GetTriggerUnit() in the filter, you are probably intended to use "Caster" there. There are a lot of issues in your spell's , so once you verify that changing TriggerUnit() with caster there, tell us so we can correct you. (A lot of issues) |
| 05-11-2008, 02:06 AM | #3 |
Haha, wow. I can't believe I skipped over that! It works now. |
