| 04-01-2006, 07:10 AM | #1 |
Well, I suspect it's something painfully obvious but we'll see. I can't get this trigger to work, and I've narrowed it down to the Condition (unless something else is somehow messing with the conditions..). After looking at code from other spells/triggers it seems exactly the same..so I dunno what's wrong. What the spell is supposed to do is first cast the Justice buff on all units in the target area, then when a unit with the Justice buff dies, the unit that killed him dies as well, after showing a sfx. Trigger that runs when spell is cast to apply buffs to units (This one doesn't have any problems that I know of, but just so you can see everything.): JASS:function Trig_Justice_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A03X' ) ) then return false endif return true endfunction function Trig_Justice_Actions takes nothing returns nothing local unit u local group g = CreateGroup() local unit c = GetSpellAbilityUnit() local player p = GetOwningPlayer(c) local player o local location l = GetSpellTargetLoc() local unit d call GroupEnumUnitsInRange(g,GetLocationX(l),GetLocationY(l),600,null) loop set u = FirstOfGroup(g) exitwhen u == null set o = GetOwningPlayer(u) if(o==p) then set d = CreateUnit(p,'h000',GetLocationX(l),GetLocationY(l),0) call UnitApplyTimedLife(d,'BTLF',2) call UnitAddAbility(d,'A03Y') call IssueTargetOrder(d,"innerfire",u) endif call GroupRemoveUnit(g,u) endloop set u = null call DestroyGroup(g) set g = null set c = null set p = null set o = null call RemoveLocation(l) set l = null set d = null endfunction function InitTrig_Justice takes nothing returns nothing local player p local integer index = 0 set gg_trg_Justice = CreateTrigger( ) loop set p = Player(index) call TriggerRegisterPlayerUnitEvent(gg_trg_Justice,p,EVENT_PLAYER_UNIT_SPELL_EFFECT,null) set index = index + 1 exitwhen index == bj_MAX_PLAYER_SLOTS endloop set p = null call TriggerAddCondition( gg_trg_Justice, Condition( function Trig_Justice_Conditions ) ) call TriggerAddAction( gg_trg_Justice, function Trig_Justice_Actions ) endfunction Here's trigger 2, which runs when a unit with the buff is killed. Every time it runs I'm getting my debug message, "Returning false..", and nothing happens. JASS:function JusticeKill takes nothing returns nothing local timer t = GetExpiredTimer() local unit u = GetHandleUnit(t,"JusticeUnit") local effect e = GetHandleEffect(u,"JusticeEffect") call DestroyEffect(e) call FlushHandleLocals(u) call KillUnit(u) call FlushHandleLocals(t) call DestroyTimer(t) set t = null set u = null set e = null endfunction function Trig_Justice_Killed_Conditions takes nothing returns boolean if ( not ( GetUnitAbilityLevel(GetTriggerUnit(), 'B00H') > 0 ) ) then call DisplayTextToPlayer(Player(0),0,0,"Returning false..") return FALSE endif call DisplayTextToPlayer(Player(0),0,0,"Returning TRUE!!") return true endfunction function Trig_Justice_Killed_Actions takes nothing returns nothing local timer t = CreateTimer() local unit u = GetKillingUnit() local effect e set e = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Resurrect\\ResurrectCaster.mdl",u,"overhead") call SetHandleHandle(u,"JusticeEffect",e) call SetHandleHandle(t,"JusticeUnit",u) call TimerStart(t,1,FALSE,function JusticeKill) set u = null set e = null set t = null endfunction function InitTrig_Justice_Killed takes nothing returns nothing local player p local integer index = 0 set gg_trg_Justice_Killed = CreateTrigger( ) loop set p = Player(index) call TriggerRegisterPlayerUnitEvent(gg_trg_Justice_Killed,p,EVENT_PLAYER_UNIT_DEATH,null) set index = index + 1 exitwhen index == 6 endloop set p = null call TriggerAddCondition( gg_trg_Justice_Killed, Condition( function Trig_Justice_Killed_Conditions ) ) call TriggerAddAction( gg_trg_Justice_Killed, function Trig_Justice_Killed_Actions ) endfunction |
| 04-01-2006, 07:18 AM | #2 |
A unit no longer has any buffs on it when it triggers the 'A unit dies' event. You'll have to use custom value or game cache to attach a value to every unit in the AoE and check that when they die. |
| 04-01-2006, 07:21 AM | #3 |
Oh..I thought I had used a spell doing almost the same exact thing before when I was using GUI but I guess I must not have =P. Thanks. |
