HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Little Problem..

11-21-2007, 04:35 AM#1
Tiku
I have two spells that use lightning.... and im using Handle Variables.... but for some reason, when i use one spell with lightning and another while that one is running, the lightnings like take turns to be visible, as in when one lightning isnt visible the other is....

i dont know what the problem is, and i did change the timer "name" and the lightning name, but the same problem comes up, if i need to post the spells up, i will

but everything else works fine besides that....

is it the handle vars?
thanks in advanced :D
11-21-2007, 07:56 AM#2
Pyrogasm
Yes, you should post the code.
11-21-2007, 01:33 PM#3
Tiku
Okay here is the first code:
Collapse JASS:
constant function Inner_Bind_AbilityId takes nothing returns integer
    return 'A001'
endfunction

constant function Inner_Bind_LinkId takes nothing returns string
    return "SPLK"
endfunction

constant function Inner_Bind_UnitId takes nothing returns integer
    return 'h001'
endfunction

function Trig_Inner_Bind_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function Inner_Bind_ChainActions takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = GetHandleUnit(t, "u")
    local unit im = GetHandleUnit(t, "im") 
    local unit dmg = GetHandleUnit(t, "dmg")
    local real ux = GetUnitX(im)
    local real uy = GetUnitY(im)
    local player up = GetOwningPlayer(u)
    local real dmgx = GetUnitX(dmg)
    local real dmgy = GetUnitY(dmg)
    local real dist = SquareRoot((dmgx-ux)*(dmgx-ux)+(dmgy-uy)*(dmgy-uy))
    local lightning light = GetHandleLightning(t, "tlight")
    local unit caster
    
    call SetUnitAnimation(im, "Spell")
    call DestroyLightning(light)
    set light = null
    if dist <= 800.0 then
     set light = AddLightning(Inner_Bind_LinkId(), true,ux, uy, dmgx, dmgy)
     call SetHandleHandle(t, "tlight", light)
    endif
    if dist > 800.0 or IsUnitAliveBJ(dmg) != true then
     set caster = CreateUnit(up, 'h001', ux, uy, 0.0)
     call UnitApplyTimedLife(caster, 'B000', 1.0)
     call UnitAddAbility(caster, Inner_Bind_AbilityId())
     call IssueTargetOrder(caster, "thunderbolt", dmg)
     call PauseTimer(t)
     call DestroyTimer(t)
     set t = null
     call FlushHandleLocals(t)
     call RemoveUnit(im)
     call DestroyLightning(light)
     set light = null
    endif 
    
    set u = null
    set dmg = null
    set caster = null
    set light = null
    set im = null 
endfunction

function Trig_Inner_Bind_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit dmg = GetSpellTargetUnit()
    local real ux = GetUnitX(u)
    local real uy = GetUnitY(u)
    local player up = GetOwningPlayer(u)
    local timer t = CreateTimer()
    local real face = GetUnitFacing(u)
    local unit im = CreateUnit(up, Inner_Bind_UnitId(), ux, uy, face)
    local real dmgx = GetUnitX(dmg)
    local real dmgy = GetUnitY(dmg)
    local lightning light
                        
    set light = AddLightning(Inner_Bind_LinkId(), true,ux, uy, dmgx, dmgy)
    call SetHandleHandle(t, "tlight", light)
    call SetHandleHandle(t, "u", u)
    call SetHandleHandle(t, "im", im)
    call SetHandleHandle(t, "dmg", dmg)
    call TimerStart(t, 0.02, true, function Inner_Bind_ChainActions)
    
    set u = null
    set dmg = null
    set up = null
    set im = null
endfunction

//===========================================================================
function InitTrig_Inner_Bind takes nothing returns nothing
    local unit u = CreateUnit(Player(13), 'h002', 0.0, 0.0, 0.0)
    call UnitAddAbility(u, Inner_Bind_AbilityId())
    call RemoveUnit(u)
    set u = null
    set gg_trg_Inner_Bind = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Inner_Bind, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Inner_Bind, Condition( function Trig_Inner_Bind_Conditions ) )
    call TriggerAddAction( gg_trg_Inner_Bind, function Trig_Inner_Bind_Actions )
endfunction

and the other one:

Collapse JASS:
constant function Vampiric_Orb_LightningId takes nothing returns string
    return "LEAS"
endfunction

constant function Vampiric_Orb_MaxAmm takes nothing returns integer
    return 500
endfunction

constant function Vampiric_Orb_OrbId takes nothing returns integer
    return 'h003'
endfunction

function Vampiric_Orb_Check takes nothing returns boolean
    return IsUnitAliveBJ(GetFilterUnit()) == true
endfunction

function Trig_Vampiric_Orb_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A002'
endfunction

function Vampiric_Orb_Effect takes nothing returns nothing
    local timer k = GetExpiredTimer()
    local unit u = GetHandleUnit(k, "u")
    local unit orb = GetHandleUnit(k, "orb")
    local real orbx = GetUnitX(orb)
    local real orby = GetUnitY(orb)
    local unit dmg = GetHandleUnit(k, "dmg")
    local real dmgx = GetUnitX(dmg)
    local real dmgy = GetUnitY(dmg)
    local group g = CreateGroup()
    local lightning light = GetHandleLightning(k, "klight")
    local integer abs = GetUnitUserData(orb)
    local boolexpr check = Condition(function Vampiric_Orb_Check)
    local real unitlife = GetUnitState(u, UNIT_STATE_LIFE)
    
    call DestroyLightning(light)
    if dmg != null and abs < Vampiric_Orb_MaxAmm() then
     call SetUnitUserData(orb, abs+1)
     call UnitDamageTarget(u, dmg, 1.0, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
     call SetUnitScale(orb, 1.0+(0.02*I2R(abs)), 1.0+(0.02*I2R(abs)), 1.0+(0.02*I2R(abs)))
     set dmgx = GetUnitX(dmg)
     set dmgy = GetUnitY(dmg)
     set light = AddLightning(Vampiric_Orb_LightningId(), true, orbx, orby, dmgx, dmgy)
     call SetHandleHandle(k, "klight", light)
    endif
    if IsUnitAliveBJ(dmg) == false or IsUnitInRange(dmg, orb, 500.0) == false then
     call GroupEnumUnitsInRange(g, orbx, orby, 500.0, check)
     set dmg = FirstOfGroup(g)
     call SetHandleHandle(k, "dmg", dmg)  
    endif
    if abs >= Vampiric_Orb_MaxAmm() then 
     call ExplodeUnitBJ(orb)
     call SetUnitLifeBJ(u, unitlife+I2R(Vampiric_Orb_MaxAmm()))
     call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl", u, "chest"))
     call DestroyLightning(light)
     call PauseTimer(k)
     call DestroyTimer(k)
     set k = null
     call DestroyGroup(g)
     set g = null
     call FlushHandleLocals(k)
    endif 
    
    set u = null
    set dmg = null
    set orb = null
    set light = null      
endfunction

function Trig_Vampiric_Orb_Actions takes nothing returns nothing   
    local unit u = GetTriggerUnit()
    local player up = GetOwningPlayer(u)
    local real locx = GetLocationX(GetSpellTargetLoc())
    local real locy = GetLocationY(GetSpellTargetLoc())
    local unit orb = CreateUnit(up, Vampiric_Orb_OrbId(), locx, locy, 0.0)
    local timer k = CreateTimer()
    local boolexpr check = Condition(function Vampiric_Orb_Check)
    local group g = CreateGroup()
    local unit dmg
    local real dmgx
    local real dmgy
    local lightning light
    
    call GroupEnumUnitsInRange(g, locx, locy, 500.0, check)
    call GroupRemoveUnit(g, u)
    set dmg = FirstOfGroup(g)
    set dmgx = GetUnitX(dmg)
    set dmgy = GetUnitY(dmg)
    set light = AddLightning(Vampiric_Orb_LightningId(), true, locx, locy, dmgx, dmgy)
    call SetHandleHandle(k, "klight", light)
    call SetHandleHandle(k, "u", u)
    call SetHandleHandle(k, "orb", orb)
    call SetHandleHandle(k, "dmg", dmg)    
    call TimerStart(k, 0.02, true, function Vampiric_Orb_Effect)
    
    set u = null
    set orb = null
endfunction

//===========================================================================
function InitTrig_Vampiric_Orb takes nothing returns nothing
    set gg_trg_Vampiric_Orb = CreateTrigger(  )
    call Preload("Objects\\Spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl")
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Vampiric_Orb, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Vampiric_Orb, Condition( function Trig_Vampiric_Orb_Conditions ) )
    call TriggerAddAction( gg_trg_Vampiric_Orb, function Trig_Vampiric_Orb_Actions )
endfunction




They work except the lightning effect takes turns when both abilities are at effect
11-21-2007, 04:35 PM#4
midiway
AddLightning( Inner_Bind_LinkId(), true, ux, uy, dmgx, dmgy )

try this:

AddLightning( Inner_Bind_LinkId(), false, ux, uy, dmgx, dmgy )