HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help with a Chain - Spell:

12-31-2007, 09:48 PM#1
redscores
This is Code i have done, i posted it before here, but i heavily reworked it, but it seems not to work, can someone please help me? I don't know whats wrong.

It is a :

-Single Target
-Bouncing
-Lightning-based
-Damage over Time

Spell.

Collapse JASS:
scope FireChain

globals 
    constant integer FRCH_AbillID = 'A000'
    constant string FRCH_lightningModel = "AFOD" // The model path of the lightning.
    constant real FRCH_damageUnCalculated = 25.00 //The Damage without level calculate
    constant integer FRCH_BurnDur = 10 // Duration of the Burn.
    constant string FRCH_BurnEffect = "Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage" //The Model used for the continous burn of the enemies.
    constant integer arcs = 3 //number of arcs after the first jump
    constant integer arcsExtraJumpWithEveryLevel = 1//Number of Jumps gained per level.
endglobals


function Trig_Fire_Chain_Conditions takes nothing returns boolean
  return GetSpellAbilityId() == FRCH_AbillID
endfunction

function Chain takes real X1, real Y1, real X2, real Y2 returns lightning
     local lightning lightning1 = AddLightning(FRCH_lightningModel, true, X1, Y1, X2, Y2)
     call DisplayTextToForce( GetPlayersAll(), "3" )
     return lightning1
endfunction

function KeepOrNoKeep takes unit target, player Cowner returns boolean
     if ( IsUnitType(target, UNIT_TYPE_STRUCTURE) == false ) and ( IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false ) and ( IsUnitAliveBJ(target) == true ) and ( IsUnitEnemy(target, Cowner) == true ) and target != null then
         return true
     endif
     return false
endfunction

function DamageUnitFire takes nothing returns nothing
     local timer T = GetExpiredTimer()
     local unit caster = GetHandleUnit(T, "caster")
     local unit target
     local player Cowner = GetHandlePlayer(T, "player")
     local group PickGroup = GetHandleGroup(T, "group")
     
     loop 
         exitwhen CountUnitsInGroup(PickGroup) == null
         set target = FirstOfGroup(PickGroup)
         call GroupRemoveUnit(PickGroup, target)
         call UnitDamageTarget (caster, target, FRCH_damageUnCalculated*GetUnitAbilityLevel(caster, FRCH_AbillID), false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
         set target = null
     endloop
     
     set caster = null
endfunction


function Trig_Fire_Chain_Actions takes nothing returns nothing
    local timer T = CreateTimer()
    local real X1
    local real Y1
    local real X2
    local real Y2
    local unit target2 = GetSpellTargetUnit()
    local unit caster = GetSpellAbilityUnit()
    local unit target = caster
    local player Cowner = GetOwningPlayer(caster)
    local lightning array lightning1
    local effect array FireBurn
    local integer TimesArced = 0
    local group DamagedUnits
    local group PickGroup
    local location location1
    set X1 = GetUnitX(target)
    set Y1 = GetUnitY(target)
    set X2 = GetUnitX(target2)
    set Y2 = GetUnitY(target2)
    set FireBurn[0] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head")
    call GroupAddUnit(PickGroup, target2)
    set lightning1[0] = Chain(X1, Y1, X2, Y2)
    set target = target2
    set target2 = null
    loop
        exitwhen TimesArced == arcs
        set TimesArced = TimesArced + 1
        set location1 = Location(X2, Y2)
        set DamagedUnits = GetUnitsInRangeOfLocAll(400, location1)
        call RemoveLocation(location1)
        set target2 = GroupPickRandomUnit(DamagedUnits)
        if KeepOrNoKeep(target2, Cowner) == false then
            set caster = null
            set target = null
            set Cowner = null
            call FlushHandleLocals(T)
            return
        endif

        call GroupClear(DamagedUnits)
        set FireBurn[TimesArced] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head")
        call GroupAddUnit(PickGroup, target2)
        set X1 = GetUnitX(target)
        set Y1 = GetUnitY(target)
        set X2 = GetUnitX(target2)
        set Y2 = GetUnitY(target2)
        set lightning1[TimesArced] = Chain(X1, Y1, X2, Y2)
        set target = target2
        set target2 = null
    endloop
    set TimesArced = 0
    call SetHandleHandle(T, "caster", caster)
    call SetHandleHandle(T, "player", Cowner)
    call SetHandleHandle(T, "group", PickGroup)
    call TimerStart(T, 1.00, true, function DamageUnitFire )
    call PolledWait(0.50)
    loop
        exitwhen TimesArced == arcs
        call DestroyEffect(FireBurn[TimesArced])
        set TimesArced = TimesArced + 1
    endloop
    set TimesArced = 0
    call PolledWait(FRCH_BurnDur - 0.50)
    loop
        exitwhen TimesArced == arcs
        call DestroyLightning(lightning1[TimesArced])
        set TimesArced = TimesArced + 1
    endloop
endfunction

//===========================================================================
function InitTrig_FireChain takes nothing returns nothing
    local integer i = 0
    set gg_trg_FireChain = CreateTrigger( )
    call Preload("Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage")
    loop
        exitwhen i>15
        call TriggerRegisterPlayerUnitEvent( gg_trg_FireChain, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null )
        set i = i+1
    endloop
    call TriggerAddCondition( gg_trg_FireChain, Condition( function Trig_Fire_Chain_Conditions ) )
    call TriggerAddAction( gg_trg_FireChain, function Trig_Fire_Chain_Actions )
endfunction

endscope
12-31-2007, 11:03 PM#2
Dil999
You could use my lightning system over on THW if you wanted to. It would be a lot faster than coding your own chain lightning. (Click Here)

About the code: Could you tell us exactly what doesn't work? If you don't know (dont see anything happen) put a bunch of BJDebugMsg in and see if anything doesn't show.
12-31-2007, 11:19 PM#3
redscores
Thats strange, I placed TextMessages to detect the problem, but no text message is shown at all....

Collapse JASS:
scope FireChain

globals 
    constant integer FRCH_AbillID = 'A000'
    constant string FRCH_lightningModel = "AFOD" // The model path of the lightning.
    constant real FRCH_damageUnCalculated = 25.00 //The Damage without level calculate
    constant integer FRCH_BurnDur = 10 // Duration of the Burn.
    constant string FRCH_BurnEffect = "Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage" //The Model used for the continous burn of the enemies.
    constant integer arcs = 3 //number of arcs after the first jump
    constant integer arcsExtraJumpWithEveryLevel = 1//Number of Jumps gained per level.
endglobals


function Trig_Fire_Chain_Conditions takes nothing returns boolean
  return GetSpellAbilityId() == FRCH_AbillID
endfunction

function Chain takes real X1, real Y1, real X2, real Y2 returns lightning
     local lightning lightning1 = AddLightning(FRCH_lightningModel, true, X1, Y1, X2, Y2)
     //call DisplayTextToForce( GetPlayersAll(), "3" )
     return lightning1
endfunction

function KeepOrNoKeep takes unit target, player Cowner returns boolean
     if ( IsUnitType(target, UNIT_TYPE_STRUCTURE) == false ) and ( IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false ) and ( IsUnitAliveBJ(target) == true ) and ( IsUnitEnemy(target, Cowner) == true ) and target != null then
         return true
     endif
     return false
endfunction

function DamageUnitFire takes nothing returns nothing
     local timer T = GetExpiredTimer()
     local unit caster = GetHandleUnit(T, "caster")
     local unit target
     local player Cowner = GetHandlePlayer(T, "player")
     local group PickGroup = GetHandleGroup(T, "group")
     //call DisplayTextToForce( GetPlayersAll(), "2" )[/b]
     loop 
         exitwhen CountUnitsInGroup(PickGroup) == null
         //call DisplayTextToForce( GetPlayersAll(), "Groups" )
         set target = FirstOfGroup(PickGroup)
         call GroupRemoveUnit(PickGroup, target)
         call UnitDamageTarget (caster, target, FRCH_damageUnCalculated*GetUnitAbilityLevel(caster, FRCH_AbillID), false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
         set target = null
     endloop
     set caster = null
endfunction


function Trig_Fire_Chain_Actions takes nothing returns nothing
    local timer T = CreateTimer()
    local real X1
    local real Y1
    local real X2
    local real Y2
    local unit target2 = GetSpellTargetUnit()
    local unit caster = GetSpellAbilityUnit()
    local unit target = caster
    local player Cowner = GetOwningPlayer(caster)
    local lightning array lightning1
    local effect array FireBurn
    local integer TimesArced = 0
    local group DamagedUnits
    local group PickGroup
    local location location1
    set X1 = GetUnitX(target)
    set Y1 = GetUnitY(target)
    set X2 = GetUnitX(target2)
    set Y2 = GetUnitY(target2)
    set FireBurn[0] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head")
    call GroupAddUnit(PickGroup, target2)
    set lightning1[0] = Chain(X1, Y1, X2, Y2)
    set target = target2
    set target2 = null
    //call DisplayTextToForce( GetPlayersAll(), "0" )
    loop
        exitwhen TimesArced == arcs
        set TimesArced = TimesArced + 1
        set location1 = Location(X2, Y2)
        set DamagedUnits = GetUnitsInRangeOfLocAll(400, location1)
        call RemoveLocation(location1)
        set target2 = GroupPickRandomUnit(DamagedUnits)
        //call DisplayTextToForce( GetPlayersAll(), "4" )
        if KeepOrNoKeep(target2, Cowner) == false then
            set caster = null
            set target = null
            set Cowner = null
            call FlushHandleLocals(T)
            return
        endif

        call GroupClear(DamagedUnits)
        set FireBurn[TimesArced] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head")
        call GroupAddUnit(PickGroup, target2)
        set X1 = GetUnitX(target)
        set Y1 = GetUnitY(target)
        set X2 = GetUnitX(target2)
        set Y2 = GetUnitY(target2)
        set lightning1[TimesArced] = Chain(X1, Y1, X2, Y2)
        set target = target2
        set target2 = null
    endloop
    set TimesArced = 0
    call SetHandleHandle(T, "caster", caster)
    call SetHandleHandle(T, "player", Cowner)
    call SetHandleHandle(T, "group", PickGroup)
    call TimerStart(T, 1.00, true, function DamageUnitFire )
    call PolledWait(0.50)
    loop
        exitwhen TimesArced == arcs
        call DestroyEffect(FireBurn[TimesArced])
        set TimesArced = TimesArced + 1
    endloop
    set TimesArced = 0
    call PolledWait(FRCH_BurnDur - 0.50)
    loop
        exitwhen TimesArced == arcs
        call DestroyLightning(lightning1[TimesArced])
        set TimesArced = TimesArced + 1
    endloop
endfunction

//===========================================================================
function InitTrig_FireChain takes nothing returns nothing
    local integer i = 0
    set gg_trg_FireChain = CreateTrigger( )
    call Preload("Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage")
    loop
        exitwhen i>15
        call TriggerRegisterPlayerUnitEvent( gg_trg_FireChain, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null )
        set i = i+1
    endloop
    call TriggerAddCondition( gg_trg_FireChain, Condition( function Trig_Fire_Chain_Conditions ) )
    call TriggerAddAction( gg_trg_FireChain, function Trig_Fire_Chain_Actions )
endfunction

endscope

I made every debug message as a comment.
12-31-2007, 11:22 PM#4
TaintedReality
Ah hah! There are probably other problems later down, but you're trying to add a unit to a null group.

Collapse JASS:
    local group PickGroup     <---Never created
    local location location1
    set X1 = GetUnitX(target)
    set Y1 = GetUnitY(target)
    set X2 = GetUnitX(target2)
    set Y2 = GetUnitY(target2)
    set FireBurn[0] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head")
    call GroupAddUnit(PickGroup, target2)     <---Here's your problem
12-31-2007, 11:36 PM#5
redscores
thanks alot, i will try it and say you how it works ^.^, by the way this is my first a bit more complicated jass spell.

So now the text messages are shown, but the lightnings do not arc(just the first is shown) and do not deal any damage.

Now the Jass script looks like this:

Collapse JASS:
scope FireChain

globals 
    constant integer FRCH_AbillID = 'A000'
    constant string FRCH_lightningModel = "AFOD" // The model path of the lightning.
    constant real FRCH_damageUnCalculated = 25.00 //The Damage without level calculate
    constant integer FRCH_BurnDur = 10// Duration of the Burn.
    constant string FRCH_BurnEffect = "Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage" //The Model used for the continous burn of the enemies.
    constant integer arcs = 3 //number of arcs after the first jump
    constant integer arcsExtraJumpWithEveryLevel = 1//Number of Jumps gained per level.
endglobals


function Trig_Fire_Chain_Conditions takes nothing returns boolean
  return GetSpellAbilityId() == FRCH_AbillID
endfunction

function Chain takes real X1, real Y1, real X2, real Y2 returns lightning
     local lightning lightning1 = AddLightning(FRCH_lightningModel, true, X1, Y1, X2, Y2)
     call DisplayTextToForce( GetPlayersAll(), "3" )
     return lightning1
endfunction

function KeepOrNoKeep takes unit target, player Cowner returns boolean
     if ( IsUnitType(target, UNIT_TYPE_STRUCTURE) == false ) and ( IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false ) and ( IsUnitAliveBJ(target) == true ) and ( IsUnitEnemy(target, Cowner) == true ) and target != null then
         return true
     endif
     return false
endfunction

function DamageUnitFire takes nothing returns nothing
     local timer T = GetExpiredTimer()
     local unit caster = GetHandleUnit(T, "caster")
     local unit target
     local player Cowner = GetHandlePlayer(T, "player")
     local group PickGroup = CreateGroup()
     set PickGroup = GetHandleGroup(T, "group")
     call DisplayTextToForce( GetPlayersAll(), "2" )
     loop 
        exitwhen CountUnitsInGroup(PickGroup) == null
        call DisplayTextToForce( GetPlayersAll(), "Groups" )
        set target = FirstOfGroup(PickGroup)
        call GroupRemoveUnit(PickGroup, target)
        call UnitDamageTarget (caster, target, FRCH_damageUnCalculated*GetUnitAbilityLevel(caster, FRCH_AbillID), false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        set target = null
     endloop
     set caster = null
endfunction


function Trig_Fire_Chain_Actions takes nothing returns nothing
    local timer T = CreateTimer()
    local real X1
    local real Y1
    local real X2
    local real Y2
    local unit target2 = GetSpellTargetUnit()
    local unit caster = GetSpellAbilityUnit()
    local unit target = caster
    local player Cowner = GetOwningPlayer(caster)
    local lightning array lightning1
    local effect array FireBurn
    local integer TimesArced = 0
    local group DamagedUnits = CreateGroup()
    local group PickGroup = CreateGroup()
    local location location1
    set X1 = GetUnitX(target)
    set Y1 = GetUnitY(target)
    set X2 = GetUnitX(target2)
    set Y2 = GetUnitY(target2)
    set FireBurn[0] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head")
    call GroupAddUnit(PickGroup, target2)
    set lightning1[0] = Chain(X1, Y1, X2, Y2)
    set target = target2
    set target2 = null
    call DisplayTextToForce( GetPlayersAll(), "0" )
    loop
        exitwhen TimesArced == arcs
        set location1 = Location(X2, Y2)
        set DamagedUnits = GetUnitsInRangeOfLocAll(400, location1)
        call RemoveLocation(location1)
        set target2 = FirstOfGroup(DamagedUnits)
        call GroupClear(DamagedUnits)
        if KeepOrNoKeep(target2, Cowner) == true then
            set TimesArced = TimesArced + 1
            call DisplayTextToForce( GetPlayersAll(), "4" )
            set FireBurn[TimesArced] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head")
            call GroupAddUnit(PickGroup, target2)
            set X1 = GetUnitX(target)
            set Y1 = GetUnitY(target)
            set X2 = GetUnitX(target2)
            set Y2 = GetUnitY(target2)
            set lightning1[TimesArced] = Chain(X1, Y1, X2, Y2)
            set target = target2
            set target2 = null
        endif
    endloop
    set TimesArced = 0
    call SetHandleHandle(T, "caster", caster)
    call SetHandleHandle(T, "player", Cowner)
    call SetHandleHandle(T, "group", PickGroup)
    call TimerStart(T, 1.00, true, function DamageUnitFire )
    call PolledWait(1.00)
    loop
        exitwhen TimesArced == arcs
        call DestroyLightning(lightning1[TimesArced])
        set TimesArced = TimesArced + 1
    endloop
    set TimesArced = 0
    call PolledWait(FRCH_BurnDur - 1)
    call PauseTimer(T)
    call FlushHandleLocals(T)
    call DestroyTimer(T)
    loop
        exitwhen TimesArced == arcs
        call DestroyEffect(FireBurn[TimesArced])
        set TimesArced = TimesArced + 1
    endloop
    set target2 = null
    set target = null
    set Cowner = null
endfunction

//===========================================================================
function InitTrig_FireChain takes nothing returns nothing
    local integer i = 0
    set gg_trg_FireChain = CreateTrigger( )
    call Preload("Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage")
    loop
        exitwhen i>15
        call TriggerRegisterPlayerUnitEvent( gg_trg_FireChain, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null )
        set i = i+1
    endloop
    call TriggerAddCondition( gg_trg_FireChain, Condition( function Trig_Fire_Chain_Conditions ) )
    call TriggerAddAction( gg_trg_FireChain, function Trig_Fire_Chain_Actions )
endfunction

endscope
01-01-2008, 01:11 PM#7
redscores
i am new at this, and i cannot figure out structs, I am still learning, so do not blame me for this, by the way fixed the if then else.

Now it looks like this (i made the extra jumps per level configurable).

Collapse JASS:
scope FireChain

globals 
    constant integer FRCH_AbillID = 'A000'
    constant string FRCH_lightningModel = "AFOD" // The model path of the lightning.
    constant real FRCH_damageUnCalculated = 25.00 //The Damage without level calculate
    constant integer FRCH_BurnDur = 10// Duration of the Burn.
    constant string FRCH_BurnEffect = "Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage" //The Model used for the continous burn of the enemies.
    constant integer arcs = 3 //number of arcs after the first jump
    constant integer arcsExtraJumpWithEveryLevel = 1//Number of Jumps gained per level.
endglobals


function Trig_Fire_Chain_Conditions takes nothing returns boolean
  return GetSpellAbilityId() == FRCH_AbillID
endfunction

function Chain takes real X1, real Y1, real X2, real Y2 returns lightning
     local lightning lightning1 = AddLightning(FRCH_lightningModel, true, X1, Y1, X2, Y2)
     call DisplayTextToForce( GetPlayersAll(), "3" )
     return lightning1
endfunction

function KeepOrNoKeep takes unit target, player Cowner returns boolean
     return ( IsUnitType(target, UNIT_TYPE_STRUCTURE) == false ) and ( IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false ) and ( IsUnitAliveBJ(target) == true ) and ( IsUnitEnemy(target, Cowner) == true ) and target != null
endfunction

function DamageUnitFire takes nothing returns nothing
     local timer T = GetExpiredTimer()
     local unit caster = GetHandleUnit(T, "caster")
     local unit target
     local player Cowner = GetHandlePlayer(T, "player")
     local group PickGroup = CreateGroup()
     set PickGroup = GetHandleGroup(T, "group")
     call DisplayTextToForce( GetPlayersAll(), "2" )
     loop 
        exitwhen CountUnitsInGroup(PickGroup) == null
        call DisplayTextToForce( GetPlayersAll(), "Groups" )
        set target = FirstOfGroup(PickGroup)
        call GroupRemoveUnit(PickGroup, target)
        call UnitDamageTarget (caster, target, FRCH_damageUnCalculated*GetUnitAbilityLevel(caster, FRCH_AbillID), false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        set target = null
     endloop
     call GroupClear(PickGroup)
     set caster = null
endfunction


function Trig_Fire_Chain_Actions takes nothing returns nothing
    local timer T = CreateTimer()
    local real X1
    local real Y1
    local real X2
    local real Y2
    local unit target2 = GetSpellTargetUnit()
    local unit caster = GetSpellAbilityUnit()
    local unit target = caster
    local player Cowner = GetOwningPlayer(caster)
    local lightning array lightning1
    local effect array FireBurn
    local integer TimesArced = 0
    local group DamagedUnits = CreateGroup()
    local group PickGroup = CreateGroup()
    local location location1
    set X1 = GetUnitX(target)
    set Y1 = GetUnitY(target)
    set X2 = GetUnitX(target2)
    set Y2 = GetUnitY(target2)
    set FireBurn[0] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head")
    call GroupAddUnit(PickGroup, target2)
    set lightning1[0] = Chain(X1, Y1, X2, Y2)
    set target = target2
    set target2 = null
    call DisplayTextToForce( GetPlayersAll(), "0" )
    loop
        exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)
        set location1 = Location(X2, Y2)
        set DamagedUnits = GetUnitsInRangeOfLocAll(400, location1)
        if CountUnitsInGroup(DamagedUnits) == 0 then
            set target2 = null
            set target = null
            set Cowner = null
            call RemoveLocation(location1)
            loop
                exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)
                call DestroyLightning(lightning1[TimesArced])
                set TimesArced = TimesArced + 1
            endloop
            set TimesArced = 0
            loop
                exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)
                call DestroyEffect(FireBurn[TimesArced])
                set TimesArced = TimesArced + 1
            endloop
            return
        endif
        call RemoveLocation(location1)
        set target2 = FirstOfGroup(DamagedUnits)
        if KeepOrNoKeep(target2, Cowner) == true then
            set TimesArced = TimesArced + 1
            call DisplayTextToForce( GetPlayersAll(), "4" )
            set FireBurn[TimesArced] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head")
            call GroupAddUnit(PickGroup, target2)
            set X1 = GetUnitX(target)
            set Y1 = GetUnitY(target)
            set X2 = GetUnitX(target2)
            set Y2 = GetUnitY(target2)
            set lightning1[TimesArced] = Chain(X1, Y1, X2, Y2)
            set target = target2
            set target2 = null
        endif
        call GroupClear(DamagedUnits)
    endloop
    set TimesArced = 0
    call SetHandleHandle(T, "caster", caster)
    call SetHandleHandle(T, "player", Cowner)
    call SetHandleHandle(T, "group", PickGroup)
    call TimerStart(T, 1.00, true, function DamageUnitFire )
    call PolledWait(1.00)
    loop
        exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)
        call DestroyLightning(lightning1[TimesArced])
        set TimesArced = TimesArced + 1
    endloop
    set TimesArced = 0
    call PolledWait(FRCH_BurnDur - 1)
    call PauseTimer(T)
    call FlushHandleLocals(T)
    call DestroyTimer(T)
    loop
        exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)
        call DestroyEffect(FireBurn[TimesArced])
        set TimesArced = TimesArced + 1
    endloop
    set target2 = null
    set target = null
    set Cowner = null
endfunction

//===========================================================================
function InitTrig_FireChain takes nothing returns nothing
    local integer i = 0
    set gg_trg_FireChain = CreateTrigger( )
    call Preload("Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage")
    loop
        exitwhen i>15
        call TriggerRegisterPlayerUnitEvent( gg_trg_FireChain, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null )
        set i = i+1
    endloop
    call TriggerAddCondition( gg_trg_FireChain, Condition( function Trig_Fire_Chain_Conditions ) )
    call TriggerAddAction( gg_trg_FireChain, function Trig_Fire_Chain_Actions )
endfunction

endscope

Fixed a bit with stopping when there are no enemys around^.^.
01-01-2008, 02:00 PM#9
Pyrogasm
Quote:
Originally Posted by Need_O2
To All: giving a THW link wont be a problem here right ?
And how can I change that User text bellow my name
Not really... but, uh, it's kind-of a weird thing to link to. And a title below your name comes when you get 30 (maybe it's 60) reputation points.

If you have more questions, please read the FAQ about reputation and/or look through the threads in the "site discussion" forum to find people who've asked similar questions.
01-01-2008, 03:23 PM#11
redscores
Now the script works on the halfway, looks like this:

Collapse JASS:
scope FireChain

globals 
    private constant integer FRCH_AbillID = 'A000'
    private constant string FRCH_lightningModel = "AFOD" // The model path of the lightning.
    private constant real FRCH_damageUnCalculated = 25.00 //The Damage without level calculate
    private constant integer FRCH_BurnDur = 10// Duration of the Burn.
    private constant string FRCH_BurnEffect = "Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage" //The Model used for the continous burn of the enemies.
    private constant integer arcs = 3 //number of arcs after the first jump
    private constant integer arcsExtraJumpWithEveryLevel = 1//Number of Jumps gained per level.
endglobals


function Trig_Fire_Chain_Conditions takes nothing returns boolean
  return GetSpellAbilityId() == FRCH_AbillID
endfunction

function Chain takes real X1, real Y1, real X2, real Y2 returns lightning
     local lightning lightning1 = AddLightning(FRCH_lightningModel, true, X1, Y1, X2, Y2)
     call DisplayTextToForce( GetPlayersAll(), "3" )
     return lightning1
endfunction

function KeepOrNoKeep takes unit target, player Cowner returns boolean
     return ( IsUnitType(target, UNIT_TYPE_STRUCTURE) == false ) and ( IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false ) and ( IsUnitAliveBJ(target) == true ) and ( IsUnitEnemy(target, Cowner) == true ) and target != null
endfunction

function DamageUnitFire takes nothing returns nothing
     local timer T = GetExpiredTimer()
     local unit caster = GetHandleUnit(T, "caster")
     local unit target
     local player Cowner = GetHandlePlayer(T, "player")
     local group PickGroup = CreateGroup()
     local integer PickCount = 0
     set PickGroup = GetHandleGroup(T, "group")
     loop 
        exitwhen PickCount == CountUnitsInGroup(PickGroup)
        set target = FirstOfGroup(PickGroup)
        call GroupRemoveUnit(PickGroup, target)
        call UnitDamageTarget (caster, target, FRCH_damageUnCalculated*GetUnitAbilityLevel(caster, FRCH_AbillID), false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        set target = null
     endloop
     call DisplayTextToForce( GetPlayersAll(), I2S(CountUnitsInGroup(PickGroup)))
     set caster = null
endfunction


function Trig_Fire_Chain_Actions takes nothing returns nothing
    local timer T = CreateTimer()
    local real X1
    local real Y1
    local real X2
    local real Y2
    local unit target2 = GetSpellTargetUnit()
    local unit caster = GetSpellAbilityUnit()
    local unit target = caster
    local player Cowner = GetOwningPlayer(caster)
    local lightning array lightning1
    local effect array FireBurn
    local integer TimesArced = 0
    local group DamagedUnits = CreateGroup()
    local group PickGroup = CreateGroup()
    local location location1
    set X1 = GetUnitX(target)
    set Y1 = GetUnitY(target)
    set X2 = GetUnitX(target2)
    set Y2 = GetUnitY(target2)
    set FireBurn[0] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head")
    call GroupAddUnit(PickGroup, target2)
    set lightning1[0] = Chain(X1, Y1, X2, Y2)
    set target = target2
    set target2 = null
    call DisplayTextToForce( GetPlayersAll(), "0" )
    loop
        exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)
        set location1 = Location(X2, Y2)
        set DamagedUnits = GetUnitsInRangeOfLocAll(400.00, location1)
        if CountUnitsInGroup(DamagedUnits) == 0 then
            set target2 = null
            set target = null
            set Cowner = null
            call RemoveLocation(location1)
            loop
                exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)
                call DestroyLightning(lightning1[TimesArced])
                set TimesArced = TimesArced + 1
            endloop
            set TimesArced = 0
            loop
                exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)
                call DestroyEffect(FireBurn[TimesArced])
                set TimesArced = TimesArced + 1
            endloop
            call PauseTimer(T)
            call FlushHandleLocals(T)
            call DestroyTimer(T)
            return
        endif
        call RemoveLocation(location1)
        set target2 = FirstOfGroup(DamagedUnits)
        if KeepOrNoKeep(target2, Cowner) == true then
            set TimesArced = TimesArced + 1
            call DisplayTextToForce( GetPlayersAll(), "4" )
            set FireBurn[TimesArced] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head")
            call GroupAddUnit(PickGroup, target2)
            set X1 = GetUnitX(target)
            set Y1 = GetUnitY(target)
            set X2 = GetUnitX(target2)
            set Y2 = GetUnitY(target2)
            set lightning1[TimesArced] = Chain(X1, Y1, X2, Y2)
            set target = target2
            set target2 = null
        endif
        call GroupClear(DamagedUnits)
    endloop
    set TimesArced = 0
    call SetHandleHandle(T, "caster", caster)
    call SetHandleHandle(T, "player", Cowner)
    call SetHandleHandle(T, "group", PickGroup)
    call TimerStart(T, 1.00, true, function DamageUnitFire )
    call PolledWait(1.00)
    loop
        exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)
        call DestroyLightning(lightning1[TimesArced])
        set TimesArced = TimesArced + 1
    endloop
    set TimesArced = 0
    call PolledWait(FRCH_BurnDur - 1)
    call PauseTimer(T)
    call FlushHandleLocals(T)
    call DestroyTimer(T)
    loop
        exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)
        call DestroyEffect(FireBurn[TimesArced])
        set TimesArced = TimesArced + 1
    endloop
    set target2 = null
    set target = null
    set Cowner = null
endfunction

//===========================================================================
function InitTrig_FireChain takes nothing returns nothing
    local integer i = 0
    set gg_trg_FireChain = CreateTrigger( )
    call Preload("Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage")
    loop
        exitwhen i>15
        call TriggerRegisterPlayerUnitEvent( gg_trg_FireChain, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null )
        set i = i+1
    endloop
    call TriggerAddCondition( gg_trg_FireChain, Condition( function Trig_Fire_Chain_Conditions ) )
    call TriggerAddAction( gg_trg_FireChain, function Trig_Fire_Chain_Actions )
endfunction

endscope

The Lightning jump works not, it bugs when there are more then 1 unit around, it shows then ever a zero as the number of units in that group and the lightning does not disappear, dunno why. And i have a different problem in the DamageUnitFire function, i want it as a dot, but i dunno how to do this without a group which keeps removing the first unit and deals damage to the removed unit (it is saved in a var when it gets removed and the var is cleared after) it deals only 1 time damage, i know why, but how can i override that, and whats the reason for the jump problem? i guess its something with the If then elses to detect a empty group (means no enemy is around)
01-04-2008, 04:20 PM#12
zen87
Quote:
Originally Posted by Need_O2
30 or 60 rep got it

LoL wc3c is better
I can use a longer signature

redscores: use private constant instead of constant
if you came form hive lets get a fact right, this place aint like hive so quit spamming around, today i log into few places and half of the page are all your names with some of expired topics being revived... what the...
01-05-2008, 03:06 PM#14
redscores
huh? sorry for that. The Problem is already solved, I just worked 2 weeks on this spell, I had some topics opened cause they were outdated and i don't want to double post, by the way, I am longer on wc3c as you, you just don't see me (I'm here since 2003)