• 🏆 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!

Jass Spell Problem

Status
Not open for further replies.
Level 4
Joined
Jan 4, 2007
Messages
67
Hey all, i got a little problem with Jass enhanced spells (i heard this is common)
I imported a Jass Spell with Triggers Units Buffs etc.
I changed the Spell ID in the script and created a Variable named 'Cache'

But now if i activate the Trigger and save the map i get like 50 errors saying 'Function Name expected' and 'endloop expected' (my translation XD,sry)

(I also copied and pasted the custom script)
 
Level 4
Joined
Jan 4, 2007
Messages
67
The whole script? oo"
Alright

JASS:
//***************************************************************************************************
//* ===================   
//* Lightning Fury   
//* ===================  
//* Made by emjlr3. 
//* 
//*
//* How to implement:
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* 1. Copy the spells Lightning Fury and Lightning Fury (Dummy) to your map. 
//*
//* 2. Copy the dummy unit Cast Dummy (Enemy) to your map, and give it the spell Lightning Fury
//*    (Dummy).
//*
//* 3. Copy this trigger to your map and the code in the custom script section of this map, and
//*    change the dummy unit raw codes in it to those in your map.
//*
//* 
//* Targets/Effects:
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯   
//*    This is set to all non magic immune enemies, but can be changed in the two unit spells
//*    fields. The rest of the options not available to be changed here can also be changed in
//*    the two abilities Lightning Fury and Lightning Fury (Dummy). 
//*  
//*
//*************************************************************************************************

//Variable Configuration:
constant function Lightning_Fury_SpellId takes nothing returns integer
    return 'A02Q' 
endfunction

constant function Lightning_Fury_DummyId takes nothing returns integer
    return 'A02R'
endfunction

constant function Lightning_Fury_Jumps takes integer Level returns integer    
    return 6 + Level * 2 //Number of jumps
endfunction

constant function Lightning_Fury_Explosion takes integer Level returns integer    
    return 0 + Level * 5 //Chance for random lightning explosion
endfunction

constant function Lightning_Fury_Radius takes real Level returns real
    return 50 + Level * 100 //Radius of damage for random explosions
endfunction

constant function Lightning_Fury_Damage takes real Level returns real
    return 15 + Level * 10 //Damage done by random explosions
endfunction

constant function Lightning_Fury_Effects takes nothing returns string
    return "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" //Effect of random lightning explosion
endfunction



//Spell:
function Lightning_Fury_1 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false and IsUnitAliveBJ(GetFilterUnit()) == true  )
endfunction

function Lightning_Fury_2 takes nothing returns boolean
    return ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == false and Lightning_Fury_1()  )
endfunction

function Lightning_Fury_3 takes nothing returns boolean
    return ( GetFilterUnit() != GetSpellTargetUnit() and Lightning_Fury_2()  )
endfunction

function Lightning_Fury_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit v
    local unit w
    local unit x 
    local unit y     
    local integer i = GetUnitAbilityLevel(u, Lightning_Fury_SpellId())
    local integer j = GetDummyIdEnemy()
    local integer k = Lightning_Fury_DummyId()
    local integer l = Lightning_Fury_Jumps(i)
    local integer m = 0
    local integer n = Lightning_Fury_Explosion(i)
    local location L = GetUnitLoc(u)
    local location M = GetUnitLoc(GetSpellTargetUnit())
    local location N
    local real r = Lightning_Fury_Radius(i)
    local real s = Lightning_Fury_Damage(i)
    local group g    
    local player p = GetOwningPlayer(u)    
    call TriggerSleepAction( ( DistanceBetweenPoints(L, M) / 1500.00 ) )
    set g = GetUnitsInRangeOfLocMatching(600.00, M, Condition(function Lightning_Fury_3))
    if ( IsUnitGroupEmptyBJ(g) == false ) then
        set v = GroupPickRandomUnit(g)
        call GroupRemoveUnit( g, v )
        set x = CreateUnit(p,j,GetUnitX(GetSpellTargetUnit()),GetUnitY(GetSpellTargetUnit()),bj_UNIT_FACING)
        call SetUnitAbilityLevelSwapped( k, x, GetUnitAbilityLevelSwapped(i, u) )
        call IssueTargetOrder( x, "chainlightning", v )
        call UnitApplyTimedLife( x, 'BTLF', 1.00 )
            if (GetRandomInt(1, 100) <= n) then
                call DestroyEffect(AddSpecialEffect( Lightning_Fury_Effects(), GetUnitX(v), GetUnitY(v) ))
                call DamageEnemiesArea(u, r, GetUnitX(v), GetUnitY(v), s, false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
            else
            endif
        if ( IsUnitGroupEmptyBJ(g) == false ) then
            set w = GroupPickRandomUnit(g)
            set x = CreateUnit(p,j,GetUnitX(GetSpellTargetUnit()),GetUnitY(GetSpellTargetUnit()),bj_UNIT_FACING)
            call SetUnitAbilityLevelSwapped( k, x, GetUnitAbilityLevelSwapped(i, u) )
            call IssueTargetOrder( x, "chainlightning", w )
            call UnitApplyTimedLife( x, 'BTLF', 1.00 )
            if (GetRandomInt(1, 100) <= n) then
                call DestroyEffect(AddSpecialEffect( Lightning_Fury_Effects(), GetUnitX(w), GetUnitY(w) ))
                call DamageEnemiesArea(u, r, GetUnitX(w), GetUnitY(w), s, false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
            else
            endif
        else
        endif
    else
    endif
    call DestroyGroup(g)
    call TriggerSleepAction( 0.02 )    
    loop
        set m = m + 1
        exitwhen m > l
        set N = GetUnitLoc(v)
        set g = GetUnitsInRangeOfLocMatching(600.00, N, Condition(function Lightning_Fury_2))
        call RemoveLocation(N)
        if ( IsUnitGroupEmptyBJ(g) == false ) then
            if ( GetFilterUnit() != v ) then
                set y = v
                call GroupRemoveUnit( g, y )
                set v = GroupPickRandomUnit(g)
                call GroupRemoveUnit( g, v )
                call GroupAddUnit(g,y)
                set x = CreateUnit(p,j,GetUnitX(v),GetUnitY(v),bj_UNIT_FACING)
                call SetUnitAbilityLevelSwapped( k, x, GetUnitAbilityLevelSwapped(i, u) )
                set v = GroupPickRandomUnit(g)
                call IssueTargetOrder( x, "chainlightning", v )
                call UnitApplyTimedLife( x, 'BTLF', 1.00 )
                if (GetRandomInt(1, 100) <= n) then
                    call DestroyEffect(AddSpecialEffect( Lightning_Fury_Effects(), GetUnitX(v), GetUnitY(v) ))
                    call DamageEnemiesArea(u, r, GetUnitX(v), GetUnitY(v), s, false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
                else
                endif
            else                
                set x = CreateUnit(p,j,GetUnitX(v),GetUnitY(v),bj_UNIT_FACING)
                call SetUnitAbilityLevelSwapped( k, x, GetUnitAbilityLevelSwapped(i, u) )
                call GroupRemoveUnit(g,v)
                set v = GroupPickRandomUnit(g)
                call IssueTargetOrder( x, "chainlightning", v )
                call UnitApplyTimedLife( x, 'BTLF', 1.00 )
                if (GetRandomInt(1, 100) <= n) then
                    call DestroyEffect(AddSpecialEffect( Lightning_Fury_Effects(), GetUnitX(v), GetUnitY(v) ))
                    call DamageEnemiesArea(u, r, GetUnitX(v), GetUnitY(v), s, false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
                else
                endif
            endif
        else
        endif
        call DestroyGroup(g)
        set N = GetUnitLoc(w)
        set g = GetUnitsInRangeOfLocMatching(600.00, N, Condition(function Lightning_Fury_2))
        call RemoveLocation(N)
        if ( IsUnitGroupEmptyBJ(g) == false ) then
            if ( GetFilterUnit() != w ) then
                set y = w
                call GroupRemoveUnit( g, y )
                set w = GroupPickRandomUnit(g)
                call GroupRemoveUnit( g, w )
                call GroupAddUnit(g,y)
                set x = CreateUnit(p,j,GetUnitX(w),GetUnitY(w),bj_UNIT_FACING)
                call SetUnitAbilityLevelSwapped( k, x, GetUnitAbilityLevelSwapped(i, u) )
                set w = GroupPickRandomUnit(g)
                call IssueTargetOrder( x, "chainlightning", w )
                call UnitApplyTimedLife( x, 'BTLF', 1.00 )
                if (GetRandomInt(1, 100) <= n) then
                    call DestroyEffect(AddSpecialEffect( Lightning_Fury_Effects(), GetUnitX(w), GetUnitY(w) ))
                    call DamageEnemiesArea(u, r, GetUnitX(w), GetUnitY(w), s, false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
                else
                endif
            else                
                set x = CreateUnit(p,j,GetUnitX(w),GetUnitY(w),bj_UNIT_FACING)
                call SetUnitAbilityLevelSwapped( k, x, GetUnitAbilityLevelSwapped(i, u) )
                call GroupRemoveUnit(g,w)
                set w = GroupPickRandomUnit(g)
                call IssueTargetOrder( x, "chainlightning", w )
                call UnitApplyTimedLife( x, 'BTLF', 1.00 )
                if (GetRandomInt(1, 100) <= n) then
                    call DestroyEffect(AddSpecialEffect( Lightning_Fury_Effects(), GetUnitX(w), GetUnitY(w) ))
                    call DamageEnemiesArea(u, r, GetUnitX(w), GetUnitY(w), s, false, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_AXE_MEDIUM_CHOP)
                else
                endif
            endif
        else
        endif
        call DestroyGroup(g)
        call TriggerSleepAction( 0.02 )        
    endloop
    set u = null
    set v = null
    set w = null
    set x = null 
    set y = null    
    set g = null    
    set p = null
    call RemoveLocation(L)
    call RemoveLocation(M)
    set L = null
    set M = null
    set N = null
endfunction

//===========================================================================
function Lightning_Fury_Conditions takes nothing returns boolean  
    return GetSpellAbilityId() == Lightning_Fury_SpellId()
endfunction

function InitTrig_Lightning_Fury takes nothing returns nothing
    set gg_trg_Lightning_Fury = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Fury, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Lightning_Fury, Condition( function Lightning_Fury_Conditions ) )
    call TriggerAddAction( gg_trg_Lightning_Fury, function Lightning_Fury_Actions )
endfunction

hope its right how i posted this XD
 
Level 4
Joined
Jan 4, 2007
Messages
67
No, I didnt press Strg+f and search for it.
And i think i wouldnt get lik 50 errors just because of that
 
Level 11
Joined
Jul 12, 2005
Messages
764
I think that spell uses Vex's Caster System, and you didn't copy it's function into the custom script section of your map..
Follow the instructions that emjlr3 (the spell creator) listed where you downloaded the spell from! I'm sure he mentions the Caster System.

Offtopic: Guys, do you use the Caster System? I personally do not, cause i like to make spells by myself, from scratch.
 
Level 4
Joined
Jan 4, 2007
Messages
67
So DummyIDEnemy should also be a dummy unit in the spell map if have to fill in?
 
Level 9
Joined
Jul 27, 2006
Messages
652
Offtopic : Caster System

Offtopic : i dont use the Caster System, at all, or the Cache System or Local Handle Vars.
All of which are pretty good but once you've looked at them, you can do most of the cache stuff yourself.
I havnt looked at the code for the Caster System, i should though...
Also i get over any spell that says "requires the caster system" or "uses struts".
I stick to good old JASS... :smile:
 
Status
Not open for further replies.
Top