HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spell Help 3

07-02-2006, 06:34 AM#1
emjlr3
rnt i the needy one

so yea, this trigger is giving me a friggin headache

what the ability does is

cast, creates effect on ur weapon, next target u attack gets poisoned, by me adding a disabled spell book and setting the level of ths slow abiltiy on it

for up to 15 seconds the target is slowed, it it dies, the poison will find a new target, or dissipate

as of right now the bugs are this

*effect and abiltiy are never taken off last targeted unit
*after the first target, the rest only have the ability at lvl 1, not the correct level
*if allies are around after the last enemy dies, they get targeted with it

any help would be appreciated

Collapse JASS:
function Trig_Living_Poison_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A053' 
endfunction

function LP_Filter2 takes nothing returns boolean    
    return IsUnitEnemy(GetFilterUnit(), bj_groupEnumOwningPlayer)==true and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)>0
endfunction

function LP_Effects2 takes nothing returns nothing
    local trigger trig2 = GetTriggeringTrigger()
    local string strig2 = GetAttTable(trig2)
    local trigger trig = GetTableTrigger(strig2,"trig")
    local string strig = GetAttTable(trig)
    local trigger trig3 = CreateTrigger()
    local triggeraction ta3
    local string strig3 = GetAttTable(trig3)    
    local group g = CreateGroup()
    local boolexpr b = Condition(function LP_Filter2)     
    local unit u = GetTableUnit(strig,"u")
    local unit targ = GetTriggerUnit()
    local unit dum
    local integer lvl = GetTableInt(strig,"lvl")  
    local effect e = GetTableEffect(strig,"e") 
    
    call UnitRemoveAbility(targ,'A054')
    call DestroyEffect(e)
    
    set bj_groupEnumOwningPlayer = GetOwningPlayer(u)
    call GroupEnumUnitsInRange(g,GetUnitX(targ),GetUnitY(targ),400,b)
    set dum = GroupPickRandomUnit(g)
    if dum!=null then
        call UnitAddAbility(dum,'A054')
        call SetUnitAbilityLevel(dum,'A055',lvl) 
        call SetTableObject(strig,"targ",dum)
        call TriggerRegisterUnitEvent( trig3,dum, EVENT_UNIT_DEATH )    
        set ta3 = TriggerAddAction( trig3, function LP_Effects2 )               
        call SetTableObject(strig3,"trig",trig)
        call SetTableObject(strig3,"ta2",ta3)
        call SetTableObject(strig,"trig2",trig2)
        set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\AcidBomb\\BottleImpact.mdl",dum,"chest")
        call SetTableObject(strig,"e",e)
        set dum = null
        set ta3 = null 
    else
        call DestroyTrigger(trig3)
    endif
    
    call TriggerRemoveAction(trig2,GetTableTriggerAction(strig2,"ta2"))
    call ClearTable(strig2)
    call DestroyTrigger(trig2)    
    
    set trig2 = null
    set trig = null
    set trig3 = null
    call DestroyGroup(g)
    set g = null
    call DestroyBoolExpr(b)
    set b = null
    set u = null
    set targ = null    
endfunction

function LP_Filter takes nothing returns boolean
    local string s = GetAttTable(GetTriggeringTrigger())
    return GetAttacker()==GetTableUnit(s,"u") 
endfunction

function LP_Effects takes nothing returns nothing
    local trigger trig = GetTriggeringTrigger()
    local string strig = GetAttTable(trig)   
    local unit targ = GetTriggerUnit() 
    local integer lvl = GetTableInt(strig,"lvl")
    local trigger trig2 = CreateTrigger()
    local string strig2 = GetAttTable(trig2)
    local triggeraction ta2
    local effect e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\AcidBomb\\BottleImpact.mdl",targ,"chest")
    
    call DisableTrigger(trig)
    call DestroyEffect(GetTableEffect(strig,"e"))
    call UnitAddAbility(targ,'A054')
    call SetUnitAbilityLevel(targ,'A055',lvl)    
    
    call TriggerRegisterUnitEvent( trig2,targ, EVENT_UNIT_DEATH )    
    set ta2 = TriggerAddAction( trig2, function LP_Effects2 )    
    call SetTableObject(strig2,"trig",trig)
    call SetTableObject(strig2,"ta2",ta2)       
    
    call SetTableObject(strig,"targ",targ)
    call SetTableObject(strig,"trig2",trig2)
    call SetTableObject(strig,"e",e)
    
    set trig = null
    set targ = null
    set trig2 = null
    set ta2 = null
endfunction

function Trig_Living_Poison_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer lvl = GetUnitAbilityLevel(u,'A053')
    local trigger trig = CreateTrigger()
    local triggeraction ta
    local trigger trig2
    local string strig = GetAttTable(trig)
    local string strig2
    local timer t = CreateTimer()
    local effect e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\AcidBomb\\BottleImpact.mdl",u,"weapon")    
    
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( trig, Condition( function LP_Filter ) )
    set ta = TriggerAddAction( trig, function LP_Effects )    
    call SetTableObject(strig,"e",e)    
    call SetTableObject(strig,"u",u)
    call SetTableInt(strig,"lvl",lvl)
    
    call TimerStart(t,15.,false,null)
    loop
        exitwhen TimerGetRemaining(t)<.1
        call TriggerSleepAction(.1)
    endloop
    
    call DestroyEffect(e)
    call DestroyEffect(GetTableEffect(strig,"e"))
    call UnitRemoveAbility(GetTableUnit(strig,"targ"),'A054')
    set trig2 = GetTableTrigger(strig,"trig2")
    set strig2 = GetAttTable(trig2)
    call TriggerRemoveAction(trig2,GetTableTriggerAction(strig2,"ta2"))
    call ClearTable(strig2)
    call DestroyTrigger(trig2)
    call TriggerRemoveAction(trig,ta)
    call ClearTable(strig)
    call DestroyTrigger(trig)
    
    set u = null
    set trig = null
    set ta = null
    set trig2 = null
    set e = null
    set t = null    
endfunction

//===========================================================================
function InitTrig_Living_Poison takes nothing returns nothing
    set gg_trg_Living_Poison = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Living_Poison, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Living_Poison, Condition( function Trig_Living_Poison_Conditions ) )
    call TriggerAddAction( gg_trg_Living_Poison, function Trig_Living_Poison_Actions )
endfunction
07-03-2006, 04:58 PM#2
emjlr3
hrmmm...bump...I'd really like some help with this, it is racking my brains

perhaps my method isnt the best way to go about it, or perhaps I just screwed something minor up...
07-05-2006, 05:09 PM#3
emjlr3
bump!!!
07-09-2006, 01:17 PM#4
emjlr3
blarg, bump :(
07-09-2006, 05:19 PM#5
iNfraNe
Try not posting the entire code, but only the thing that holds a bug, if you dont know where the code bugs try some debug msgs. Noone will read this big code, its just too much work.
07-09-2006, 07:41 PM#6
emjlr3
amybe some one will...

i figured it imparative to post the whole thing, since it is pretty complicated, and w/o it all, one might not be able to get the jist of how it is working