• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Need sum Jass Help!

Status
Not open for further replies.
Level 5
Joined
Jun 25, 2008
Messages
118
Ok so im making an auto cast spell that causes attacks to burn the target dealing a percentage of the original attacks damage over 3 seconds. I really have no clue what I've done wrong here, was hoping getting a 3rd persons perspective would help!

JASS:
globals
    group Stickyplas
endglobals

function Sticky_Plasma_Damage takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit cast = GetHandleUnit(t, "cast")
    local unit targ = GetHandleUnit(t, "targ")
    local real dmg = GetHandleReal(t, "dmg")
    local integer lvl = GetHandleInt(t, "lvl")
    
    call UnitDamageTarget(cast, targ, dmg*0.021*lvl, true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
    
    set cast = null
    set targ = null
 endfunction
 
function Sticky_Plasma_Detect takes nothing returns boolean
    if GetTriggerEventId()==EVENT_PLAYER_UNIT_ATTACKED and GetUnitAbilityLevel(GetAttacker(),'A008')>0 then 
        return true 
    elseif GetTriggerEventId()==EVENT_UNIT_SPELL_EFFECT and GetSpellAbilityId()=='A008' then 
        return true 
    endif 
    
    return false 
endfunction 

function Sticky_Plasma_Effects takes nothing returns nothing 
    local timer t = CreateTimer()
    local unit cast = GetEventDamageSource() 
    local unit targ = GetTriggerUnit()
    local real dmg = GetEventDamage() 
    local integer lvl = GetUnitAbilityLevel(cast, 'A008')
    local effect plas
    
    if not IsUnitInGroup(targ, Stickyplas) then
        if GetUnitAbilityLevel(targ,'B002')>0 and lvl>0 then 
            call DisableTrigger(GetTriggeringTrigger())
            call GroupAddUnit(Stickyplas, targ)
            set plas = AddSpecialEffectTarget("war3mapImported\\PlasmaGrenade.mdl", targ, "chest")
            call SetHandleHandle(t, "cast", cast)
            call SetHandleHandle(t, "targ", targ)
            call SetHandleReal(t, "dmg", dmg)
            call SetHandleInt(t, "lvl", lvl)
            call TimerStart(t, 0.25, true, function Sticky_Plasma_Damage)
            call PolledWait(3)
            call PauseTimer(t)
            call DestroyEffect(plas)
            call GroupRemoveUnit(Stickyplas, targ)
        endif 
    endif
    
    call FlushHandleLocals(t)
    call DestroyTimer(t)
    set t = null
    set targ = null 
    set cast = null 
    set plas = null
endfunction 

function Sticky_Plasma_Detect_Actions takes nothing returns nothing 
    local trigger trig = CreateTrigger() 
    local triggeraction ta 
    local unit u 
    
    if GetTriggerEventId()==EVENT_UNIT_SPELL_EFFECT then 
        set u = GetSpellTargetUnit() 
    else 
        set u = GetTriggerUnit() 
    endif 
    
    call TriggerRegisterUnitEvent(trig,u, EVENT_UNIT_DAMAGED) 
    set ta = TriggerAddAction(trig, function Sticky_Plasma_Effects) 
    call PolledWait(5) 
    call DisableTrigger(trig) 
    call TriggerRemoveAction(trig,ta) 
    call DestroyTrigger(trig) 
    set ta = null 
    set u = null 
    set trig = null 
endfunction 

function InitTrig_Sticky_Plasma takes nothing returns nothing 
    set gg_trg_Sticky_Plasma = CreateTrigger( ) 
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Sticky_Plasma, EVENT_PLAYER_UNIT_ATTACKED) 
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Sticky_Plasma, EVENT_PLAYER_UNIT_SPELL_EFFECT) 
    call TriggerAddCondition(gg_trg_Sticky_Plasma, Condition(function Sticky_Plasma_Detect)) 
    call TriggerAddAction(gg_trg_Sticky_Plasma, function Sticky_Plasma_Detect_Actions) 
endfunction

Uses Handle Vars if you hadnt guessed :p

A008 is ofc my auto cast ability (based on Frost Arrows), and B002 is the Non-Stacking Buff for it (and yea ive tried setting it as the Stacking Buff)

I have found out so far that Sticky_Plasma_Effects IS working, but the "IsUnitInGroup(targ, Stickyplas)" always returns false, whether i put a "not" before it or not, so im rather bewildered. Any help will be greatly appreciated!
 
Status
Not open for further replies.
Top