• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] I need help at this spell script.

Status
Not open for further replies.
Level 21
Joined
Aug 9, 2006
Messages
2,384
This is a Script which should shoot a lightning on the target, set it on fire for 10 seconds. But i dunno how to use Handle Vars correctly :( sry, can someone please help me? :cry:

JASS:
scope FireChain

globals 
    constant integer FRCH_AbillID = 'A000'
    constant string FRCH_lightningModel = "AFOD" // The model path of the lightning
    real FRCH_damageUnCalculated = 25 // The Damage done, gets multiplied with the level
    integer FRCH_BurnDur = 10 // Duration of the Burn
endglobals


function Trig_Fire_Chain_Conditions takes nothing returns boolean
    if ( GetSpellAbilityId() == FRCH_AbillID ) then
        return true
    endif
    return false
endfunction

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

function DamageUnitFire takes nothing returns nothing
     local unit target 
     local unit caster 
     call GetHandleUnit(target, "target")
     call GetHandleUnit(caster, "caster")
     call UnitDamageTarget (caster, target, FRCH_damageUnCalculated*GetUnitAbilityLevel(caster, FRCH_AbillID), false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
     call DisplayTextToForce( GetPlayersAll(), "2" )
     set target = null
     set caster = null
endfunction

function ChainDamage takes unit target, unit caster returns nothing
     local effect FireBurn = AddSpecialEffectTarget("Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage", target, "head")
     local timer FireDamage = CreateTimer()
     call DisplayTextToForce( GetPlayersAll(), "1" )
     
     call TimerStart(FireDamage, 1.00, true, function DamageUnitFire )
     call PolledWait(10.00)
     call PauseTimer(FireDamage)
     call DestroyEffect(FireBurn)
endfunction

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

function Trig_Fire_Chain_Actions takes nothing returns nothing
    local unit caster
    local unit target
    local unit target2
    local real X1
    local real Y1
    local real X2
    local real Y2
    local player Cowner
    local integer arcs = 3 //number of arcs after the first jump
    local location locationFC
    local group DamagedUnits
    
    
    call SetHandleHandle(GetSpellTargetUnit(), "target", null)
    call SetHandleHandle(GetSpellAbilityUnit(), "caster", null)
    call GetHandleUnit(caster, "caster")
    call GetHandleUnit(target, "target")
    set Cowner = GetOwningPlayer(caster)
    set X1 = GetUnitX(caster)
    set Y1 = GetUnitY(caster)
    set X2 = GetUnitX(target)
    set Y2 = GetUnitY(target)
    set locationFC = Location(X2,Y2)
    call Chain(X1, Y1, X2, Y2)
    call ChainDamage(target, caster)
    call PolledWait(0.25)
    call RemoveLocation(locationFC)
    call GroupClear(DamagedUnits)
    set caster = null
    set target = null
    set target2 = null
    call DestroyGroup(DamagedUnits)
    call PolledWait(10.00)
    call FlushHandleLocals(target)
    call FlushHandleLocals(caster)
    
endfunction

//===========================================================================
function InitTrig_FireChain takes nothing returns nothing
    set gg_trg_FireChain = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_FireChain, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_FireChain, Condition( function Trig_Fire_Chain_Conditions ) )
    call TriggerAddAction( gg_trg_FireChain, function Trig_Fire_Chain_Actions )
endfunction

endscope


By the way, the 3,1,2 textmessage where to test what runs correctly and what not.
 
Level 17
Joined
Jun 17, 2007
Messages
1,433
This may not help, but this is the right way to do conditions instead of blizzard's terrible GUI methom.
JASS:
function Trig_Fire_Chain_Conditions takes nothing returns boolean
  return GetSpellAbilityId() == FRCH_AbillID 
endfunction
Now to remove the BJ
JASS:
function InitTrig_FireChain takes nothing returns nothing
    local integer i = /your minimum player slot that can use this spell
    set gg_trg_FireChain = CreateTrigger( )
    loop
        exitwhen i>/your greatest player slot that can use this spell
        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
Also, consider preloading the special effect with
JASS:
call Preload('Effect Name')
 
Level 21
Joined
Aug 9, 2006
Messages
2,384
I fixed now these things, works even not :(, no lightning is shown up, nothing. I think i use the handle vars wrong, can someone help me to fix that?

JASS:
scope FireChain

globals 
    constant integer FRCH_AbillID = 'A000'
    constant string FRCH_lightningModel = "AFOD" // The model path of the lightning
    real FRCH_damageUnCalculated = 25 // The Damage done, gets multiplied with the level
    integer FRCH_BurnDur = 10 // Duration of the Burn
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 nothing
     local lightning lightning1 = AddLightning(FRCH_lightningModel, true, X1, Y1, X2, Y2)
     call DisplayTextToForce( GetPlayersAll(), "3" )
     call PolledWait(1.00)
     call DestroyLightning(lightning1)
endfunction

function DamageUnitFire takes nothing returns nothing
     local unit target = GetHandleUnit(GetSpellTargetUnit(), "target")
     local unit caster = GetHandleUnit(GetSpellAbilityUnit(), "caster")
     call UnitDamageTarget (caster, target, FRCH_damageUnCalculated*GetUnitAbilityLevel(caster, FRCH_AbillID), false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
     call DisplayTextToForce( GetPlayersAll(), "2" )
     set target = null
     set caster = null
endfunction

function ChainDamage takes unit target, unit caster returns nothing
     local effect FireBurn = AddSpecialEffectTarget("Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage", target, "head")
     local timer FireDamage = CreateTimer()
     call DisplayTextToForce( GetPlayersAll(), "1" )
     
     call TimerStart(FireDamage, 1.00, true, function DamageUnitFire )
     call PolledWait(10.00)
     call PauseTimer(FireDamage)
     call DestroyEffect(FireBurn)
endfunction

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

function Trig_Fire_Chain_Actions takes nothing returns nothing
    local unit caster
    local unit target
    local unit target2
    local real X1
    local real Y1
    local real X2
    local real Y2
    local player Cowner
    local integer arcs = 3 //number of arcs after the first jump
    local location locationFC
    local group DamagedUnits
    call Preload("Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage")
    
    
    call SetHandleHandle(GetSpellTargetUnit(), "target", null)
    call SetHandleHandle(GetSpellAbilityUnit(), "caster", null)
    call GetHandleUnit(caster, "caster")
    call GetHandleUnit(target, "target")
    set Cowner = GetOwningPlayer(caster)
    set X1 = GetUnitX(caster)
    set Y1 = GetUnitY(caster)
    set X2 = GetUnitX(target)
    set Y2 = GetUnitY(target)
    set locationFC = Location(X2,Y2)
    call Chain(X1, Y1, X2, Y2)
    call ChainDamage(target, caster)
    call PolledWait(0.25)
    call RemoveLocation(locationFC)
    call GroupClear(DamagedUnits)
    set caster = null
    set target = null
    set target2 = null
    call DestroyGroup(DamagedUnits)
    call PolledWait(10.00)
    call FlushHandleLocals(target)
    call FlushHandleLocals(caster)
    
endfunction

//===========================================================================
function InitTrig_FireChain takes nothing returns nothing
    local integer i = 0
    set gg_trg_FireChain = CreateTrigger( )
    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
 
Last edited:
Level 21
Joined
Aug 9, 2006
Messages
2,384
fixed. but works not altough.... nothing appears, i am sure that it is the handle vars.^^

EDIT: it where the handle vars, i finally got how to use them right, but the fire effect shows not up for some reason -.-. But the damage works now, and the lightning.

JASS:
scope FireChain

globals 
    constant integer FRCH_AbillID = 'A000'
    constant string FRCH_lightningModel = "AFOD" // The model path of the lightning
    real FRCH_damageUnCalculated = 25 // The Damage done, gets multiplied with the level
    integer FRCH_BurnDur = 10 // Duration of the Burn
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 nothing
     local lightning lightning1 = AddLightning(FRCH_lightningModel, true, X1, Y1, X2, Y2)
     call DisplayTextToForce( GetPlayersAll(), "3" )
     call PolledWait(1.00)
     call DestroyLightning(lightning1)
endfunction

function DamageUnitFire takes nothing returns nothing
     local timer FireDamage = GetExpiredTimer()
     local unit target = GetHandleUnit(FireDamage, "target")
     local unit caster = GetHandleUnit(FireDamage, "caster")
     call UnitDamageTarget (caster, target, FRCH_damageUnCalculated*GetUnitAbilityLevel(caster, FRCH_AbillID), false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
     call DisplayTextToForce( GetPlayersAll(), "2" )
     set target = null
     set caster = null
endfunction

function ChainDamage takes nothing returns nothing
     local timer T = GetExpiredTimer()
     local unit target = GetHandleUnit(T, "target") 
     local unit caster = GetHandleUnit(T, "caster") 
     local effect FireBurn
     local timer FireDamage = CreateTimer()
     
     set FireBurn = AddSpecialEffectTarget("Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage", target, "head")
     call DisplayTextToForce( GetPlayersAll(), "1" )
     call SetHandleHandle(FireDamage, "caster", caster)
     call SetHandleHandle(FireDamage, "target", target)
     call TimerStart(FireDamage, 1.00, true, function DamageUnitFire )
     call PolledWait(10.00)
     call PauseTimer(FireDamage)
     call FlushHandleLocals(FireDamage)
     call DestroyEffect(FireBurn)
     set target = null 
     set caster = null 
endfunction

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

function Trig_Fire_Chain_Actions takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local unit target = GetSpellTargetUnit()
    local unit target2
    local timer T = CreateTimer()
    local real X1
    local real Y1
    local real X2
    local real Y2
    local player Cowner
    local integer arcs = 3 //number of arcs after the first jump
    local location locationFC
    local group DamagedUnits
    call SetHandleHandle(T, "caster", caster)
    call SetHandleHandle(T, "target", target)
    set Cowner = GetOwningPlayer(caster)
    set X1 = GetUnitX(caster)
    set Y1 = GetUnitY(caster)
    set X2 = GetUnitX(target)
    set Y2 = GetUnitY(target)
    set locationFC = Location(X2,Y2)
    call Chain(X1, Y1, X2, Y2)
    call TimerStart(T, 1.00, false, function ChainDamage )
    call PolledWait(0.25)
    call RemoveLocation(locationFC)
    call GroupClear(DamagedUnits)
    set caster = null
    set target = null
    set target2 = null
    call DestroyGroup(DamagedUnits)
    call PolledWait(10.00)
    call FlushHandleLocals(T)
    
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
 
Last edited:
Level 11
Joined
Aug 25, 2006
Messages
971
?! Did you update it? Some serious mistakes I saw before seem to have magically cleaned themselves up....
I'm looking at the code, be back soon.

Only found one problem. You did great but all your GetHandleHandle should be GetHandleUnit
There is no SetHandleUnit, you just use SetHandleHandle (Which you did)
 
Level 21
Joined
Aug 9, 2006
Messages
2,384
:wthumbsup: again updated.

Now the script works on the halfway, looks like this:

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)
 
Last edited:
Status
Not open for further replies.
Top