• 🏆 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] Compile error

Status
Not open for further replies.
Level 3
Joined
Mar 1, 2015
Messages
53
Basicly the idea is to edit the map with already exsiting seperate jass triggers. I made a custom spell using GUI which later I converted into a custom text and saved it as a jass file in a folder where the map's orginal jass custom triggers are located. After running the script in GIT I get the following error:


JASS:
JASS Exception, please wait...

logs\output_war3map.j: Compile error.
Line 23575: [] Unexpected: (  )

 23572 |
 23573 | //=====================================================================
======
 23574 | function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
 23575 |     local gg_trg_Untitled_Trigger_002 = CreateTrigger(  )
 23576 |     call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_002, EV
ENT_PLAYER_UNIT_SPELL_CAST )
 23577 |     call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_U
ntitled_Trigger_002_Actions )
 23578 | endfunction
jasshelper error: pid 3616 exit 1


Here's the spell:

JASS:
function Trig_Untitled_Trigger_002_Func001C takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A0DC' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
    if ( Trig_Untitled_Trigger_002_Func001C() ) then
        call AddSpecialEffectTargetUnitBJ( "overhead", GetTriggerUnit(), "Abilities\\Spells\\Orc\\AncestralSpirit\\AncestralSpiritCaster.mdl" )
        call PauseUnitBJ( true, GetTriggerUnit() )
        call SetUnitAnimation( GetTriggerUnit(), "Spell Slam" )
        call SetPlayerStateBJ( GetOwningPlayer(GetTriggerUnit()), PLAYER_STATE_RESOURCE_GOLD, 120 )
        call TriggerSleepAction( 1.67 )
        call PauseUnitBJ( false, GetTriggerUnit() )
        call IssuePointOrderLocBJ( GetTriggerUnit(), "move", GetUnitLoc(GetSpellAbilityUnit()) )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
    local gg_trg_Untitled_Trigger_002 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_002, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions )
endfunction
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Should probably be set gg_trg_Untitled_Trigger_002 = CreateTrigger( ).
But if you want to define a local variable it would look like this:
local trigger your_name_here = CreateTrigger()
 
Level 3
Joined
Mar 1, 2015
Messages
53
1.Changed it to:
JASS:
    local trigger gg_trg_Untitled_Trigger_002 = CreateTrigger(  )
the error is gone but the spell doesn't work ingame :/


2.I want to try it with diffrent spell but I have a problem, how to create local variable inside jass code?
JASS:
function Trig_Untitled_Trigger_004_Actions takes nothing returns nothing
    local location = udg_Temp_Point
endfunction
Something like this?

3.Author told me the spell doesnt work because I have to call initialization function, how to do it?
 
Last edited:
About the initialization issue:

When you create a trigger in GUI, it adds a line in the war3map.j (within the function InitCustomTriggers) to call the "InitTrig_" function. Since you are directly editing the war3map.j (I assume), you have to add that call yourself. Navigate to the InitCustomTriggers function. Let's say it looks like this:
JASS:
function InitCustomTriggers takes nothing returns nothing
    call InitTrig_Init(  )
    call InitTrig_Init_Waves_01_10(  )
    call InitTrig_Init_Waves_11_20(  )
    call InitTrig_Init_Waves_21_30(  )
    call InitTrig_Init_Waves_31_40(  )
    call InitTrig_Init_Waves_41_50(  )
endfunction
If you wanted to add your "Untitled Trigger 2" to this list, you would simply add a line to call it:
JASS:
function InitCustomTriggers takes nothing returns nothing
    call InitTrig_Init(  )
    call InitTrig_Init_Waves_01_10(  )
    call InitTrig_Init_Waves_11_20(  )
    call InitTrig_Init_Waves_21_30(  )
    call InitTrig_Init_Waves_31_40(  )
    call InitTrig_Init_Waves_41_50(  )
    call InitTrig_Untitled_Trigger_002() // add this line
endfunction

After that, your spell should at least run. Your code has issues with it, but let's try to get it to run first. :)
 
Level 3
Joined
Mar 1, 2015
Messages
53
Sorry for double post but I have a problem with other variables.
I tried doing it on my own, I am just getting errors everytime.
Can someone show me and example how to do it on this file:

JASS:
function Trig_Rupture_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A0D8' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Rupture_Func001C takes nothing returns boolean
    if ( not ( udg_RuptureTurnoApagado == 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Rupture_Actions takes nothing returns nothing
    if ( Trig_Rupture_Func001C() ) then
        call EnableTrigger( gg_trg_Rupture_Loop )
    else
    endif
    set udg_Rupture_Integer = ( udg_Rupture_Integer + 1 )
    set udg_RuptureTurnoApagado = ( udg_RuptureTurnoApagado + 1 )
    set udg_Rupture_Apagado[udg_Rupture_Integer] = true
    set udg_RuptureCaster_2[udg_Rupture_Integer] = GetTriggerUnit()
    set udg_RuptureCaster_1[udg_Rupture_Integer] = GetSpellTargetUnit()
    set udg_RupturePunto_1[udg_Rupture_Integer] = GetUnitLoc(GetSpellTargetUnit())
    call UnitDamageTargetBJ( GetTriggerUnit(), GetSpellTargetUnit(), ( 30.00 + ( 1.00 * I2R(GetUnitAbilityLevelSwapped('A0D8', GetTriggerUnit())) ) ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNKNOWN )
    call AddSpecialEffectTargetUnitBJ( "chest", udg_RuptureCaster_1[udg_Rupture_Integer], "Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
endfunction

//===========================================================================
function InitTrig_Rupture takes nothing returns nothing
    local trigger gg_trg_Rupture = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Rupture, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Rupture, Condition( function Trig_Rupture_Conditions ) )
    call TriggerAddAction( gg_trg_Rupture, function Trig_Rupture_Actions )
endfunction



the variables are:
Rupture_Apagado = Boolean Array (1)
Rupture_Integer = Integer
Rupture_Loop = Integer
RuptureCaster_1 and 2 = Unit Array (1)
RupturePunto_1 = Point Array (1)
RupturePunto_2 = Point
Rupture Tiempo = Integer Array (1) = initial value = 0
RuptureTurnoApagado = Integer = initial value = 0

heres my try:
JASS:
function Trig_Rupture_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A0D8' ) ) then
        return false
    endif
    return true
endfunction


function Trig_Rupture_Func001C takes nothing returns boolean
        local integer = udg_RuptureTurnoApagado
if ( not ( udg_RuptureTurnoApagado == 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Rupture_Actions takes nothing returns nothing
    if ( Trig_Rupture_Func001C() ) then
        call EnableTrigger( gg_trg_Rupture_Loop )
    else
    endif
    local integer = udg_RuptureInteger
    set udg_Rupture_Integer = ( udg_Rupture_Integer + 1 )
   local integer = udg_RuptureTurnoApagado
    set udg_RuptureTurnoApagado = ( udg_RuptureTurnoApagado + 1 )
    local boolean = udg_RuptureApagado
    set udg_Rupture_Apagado[udg_Rupture_Integer] = true
    local unit = udg_RuptureCaster_2
    set udg_RuptureCaster_2[udg_Rupture_Integer] = GetTriggerUnit()
   local unit = udg_RuptureCaster_1
    set udg_RuptureCaster_1[udg_Rupture_Integer] = GetSpellTargetUnit()
   local location = udg_RupturePunto_1
    set udg_RupturePunto_1[udg_Rupture_Integer] = GetUnitLoc(GetSpellTargetUnit())
    call UnitDamageTargetBJ( GetTriggerUnit(), GetSpellTargetUnit(), ( 30.00 + ( 1.00 * I2R(GetUnitAbilityLevelSwapped('A0D8', GetTriggerUnit())) ) ), ATTACK_TYPE_CHAOS, 

DAMAGE_TYPE_UNKNOWN )
    call AddSpecialEffectTargetUnitBJ( "chest", udg_RuptureCaster_1[udg_Rupture_Integer], "Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
endfunction

//===========================================================================
function InitTrig_Rupture takes nothing returns nothing
    local trigger gg_trg_Rupture = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Rupture, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Rupture, Condition( function Trig_Rupture_Conditions ) )
    call TriggerAddAction( gg_trg_Rupture, function Trig_Rupture_Actions )
endfunction

MAYBE MORE IMPORTANT QUESTION:
Can I somehow use variables from GUI in my jass file without adding all this local etc.?
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Can I somehow use variables from GUI in my jass file without adding all this local etc.?
You just enter their name? You should not be trying to name-space overload them anyway.

You might want to read up about the difference between a global and a local variable. They have completely different use cases.

When you save the map all GUI globals are added to the global section at the top of the main map script. Here they are given a name which is used to refer to them in GUI and that name can also be used to refer to them in JASS (although it might not change if you change the variable name in GUI).

If you want more help please post the map or your global variable declaration. I am guessing you have a different name for the global in GUI than you are using in JASS.
 
Level 3
Joined
Mar 1, 2015
Messages
53
I know how to fix previous spell, I got problem with another one:

Variable type:
BT_Closed, Boolean, Array, size 1, initial value- false (default

Error:
Line 23601: [maa???] Undeclared variable udg_BT_Closed


code
JASS:
                            function Trig_Bear_Trap_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A0D3' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Func003C takes nothing returns boolean
    local integer = udg_BT_Skip
    if ( not ( udg_BT_Skip == 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Actions takes nothing returns nothing
local integer = udg_BT
local boolean array udg_BT_closed
local real array = udg_BT_damage
local real array = udg_BT_Duration
local group = udg_BT_Group
local unit array udg_BT_Hero
local real array udg_BT_Interval
local real array udg_BT_IntervalCheck
local integer array udg_BT_Level
local boolean array udg_BT_On
local location array udg_BT_Point
local integer = udg_BT_Skip
local group array udg_BT_Target
local location array udg_BT_TargetPoint
local integer = udg_BT_Times
local unit array udg_BT_Trap
    
    if ( Trig_Bear_Trap_Func003C() ) then
        call EnableTrigger( gg_trg_Bear_Trap_Loop )
    else
    endif
    set udg_BT_Skip = ( udg_BT_Skip + 1 )
    set udg_BT_Times = ( udg_BT_Times + 1 )
    set udg_BT_Point[0] = GetSpellTargetLoc()
    set udg_BT_Hero[udg_BT_Times] = GetTriggerUnit()
    set udg_BT_Level[udg_BT_Times] = GetUnitAbilityLevelSwapped('A0D3', GetTriggerUnit())
    set udg_BT_Duration[udg_BT_Times] = ( 2.00 + ( 1 * I2R(udg_BT_Level[udg_BT_Times]) ) )
    set udg_BT_Closed[udg_BT_Times] = false
    call CreateNUnitsAtLoc( 1, 'o01S', GetOwningPlayer(GetTriggerUnit()), udg_BT_Point[0], GetUnitFacing(GetTriggerUnit()) )
    call SetUnitAnimation( GetLastCreatedUnit(), "birth" )
    call SetUnitPathing( GetLastCreatedUnit(), false )
    call UnitApplyTimedLifeBJ( 16.00, 'BTLF', GetLastCreatedUnit() )
    set udg_BT_Trap[udg_BT_Times] = GetLastCreatedUnit()
    set udg_BT_IntervalCheck[udg_BT_Times] = 0.50
    set udg_BT_Interval[udg_BT_Times] = 0.50
    call RemoveLocation(udg_BT_Point[0])
endfunction

//===========================================================================
function InitTrig_Bear_Trap takes nothing returns nothing
    local trigger gg_trg_Bear_Trap = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Bear_Trap, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Bear_Trap, Condition( function Trig_Bear_Trap_Conditions ) )
    call TriggerAddAction( gg_trg_Bear_Trap, function Trig_Bear_Trap_Actions )
endfunction

So how is this wrong?
JASS:
local boolean array udg_BT_closed
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
So how is this wrong?
How could it be not wrong?

Please look up the difference between a global and a local variable. They are not the same thing and have different use cases. I do not understand why you are declaring so many local variables with the name style of global variables. You should not declare a local variable with the same name as a global variable as it can cause conflict errors.

I will give you a small summary on the differences. Global variables are saved to the program heap so share values between all threads. Once a global is declared it will persist until the session ends. Local variables are saved on the thread stack as part of the function frame so are only available to that thread within that function. Once a local is declared it will persist until the function returns or thread crashes.

If you want to use locals then give them unique names that are not the same as global variables. If you want to use globals delete all the local declarations.
 
Level 3
Joined
Mar 1, 2015
Messages
53
OK I set up global variables:
JASS:
  globals
integer = udg_BT
boolean array udg_BT_Closed
real array udg_BT_Damage 
real array udg_BT_Duration
group = udg_BT_Group
unit array udg_BT_Hero
real array udg_BT_Interval
real array udg_BT_IntervalCheck
integer array udg_BT_Level
boolean array udg_BT_On
location array udg_BT_Point
integer = udg_BT_Skip
unit array udg_BT_Target
location array udg_BT_TargetPoint
integer = udg_BT_Times
unit array udg_BT_Trap
endglobals


function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006001 takes nothing returns boolean
    return ( GetLocationX(udg_BT_Point[1]) == GetLocationX(udg_BT_Point[2]) )
endfunction


function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006002 takes nothing returns boolean
    return ( GetLocationY(udg_BT_Point[1]) == GetLocationY(udg_BT_Point[2]) )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008C takes nothing returns boolean
    if ( not GetBooleanOr( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006002() ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005C takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(udg_BT_Target[udg_BT]) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011C takes nothing returns boolean
    if ( not ( udg_BT_IntervalCheck[udg_BT] >= udg_BT_Interval[udg_BT] ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001001 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) == true )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001002 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001 takes nothing returns boolean
    return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001002() )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002001 takes nothing returns boolean
    return ( IsUnitDeadBJ(GetFilterUnit()) == false )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002002 takes nothing returns boolean
    return ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(udg_BT_Hero[udg_BT])) == false )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002 takes nothing returns boolean
    return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002002() )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002() )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023Func001A takes nothing returns nothing
    set udg_BT_Target[udg_BT] = GetEnumUnit()
    set udg_BT_Closed[udg_BT] = true
    call SetUnitAnimation( udg_BT_Trap[udg_BT], "death spell" )
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // Trap being visible if you stack in it. You can remove lower line if you want enemy to do not know what damaging it.
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023C takes nothing returns boolean
    if ( not ( CountUnitsInGroup(udg_BT_Group) > 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005C takes nothing returns boolean
    if ( not ( udg_BT_Closed[udg_BT] == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func007C takes nothing returns boolean
    if ( ( udg_BT_Duration[udg_BT] <= 0.00 ) ) then
        return true
    endif
    if ( ( udg_BT_Trap[udg_BT] == null ) ) then
        return true
    endif
    if ( ( IsUnitDeadBJ(udg_BT_Trap[udg_BT]) == true ) ) then
        return true
    endif
    return false
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func008Func005C takes nothing returns boolean
    if ( ( udg_BT_Trap[udg_BT] == null ) ) then
        return true
    endif
    if ( ( IsUnitDeadBJ(udg_BT_Trap[udg_BT]) == true ) ) then
        return true
    endif
    return false
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func008C takes nothing returns boolean
    if ( not Trig_Bear_Trap_Loop_Func001Func001Func001Func008Func005C() ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func010C takes nothing returns boolean
    if ( not ( udg_BT < udg_BT_Times ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func014C takes nothing returns boolean
    if ( not ( udg_BT_Skip == 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001C takes nothing returns boolean
    if ( not Trig_Bear_Trap_Loop_Func001Func001Func001Func007C() ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001C takes nothing returns boolean
    if ( not ( udg_BT_On[udg_BT] == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Actions takes nothing returns nothing
    set udg_BT = 1
    loop
        exitwhen udg_BT > udg_BT_Times
        if ( Trig_Bear_Trap_Loop_Func001Func001C() ) then
            if ( Trig_Bear_Trap_Loop_Func001Func001Func001C() ) then
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func008C() ) then
                else
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Killing trap because if it is exist and it is alive but duration elapsed it must to die.
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    call KillUnit( udg_BT_Trap[udg_BT] )
                endif
                set udg_BT_On[udg_BT] = false
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func010C() ) then
                    set udg_BT_On[udg_BT] = udg_BT_On[udg_BT_Times]
                    set udg_BT_Closed[udg_BT] = udg_BT_Closed[udg_BT_Times]
                    set udg_BT_Damage[udg_BT] = udg_BT_Damage[udg_BT_Times]
                    set udg_BT_Duration[udg_BT] = udg_BT_Duration[udg_BT_Times]
                    set udg_BT_Hero[udg_BT] = udg_BT_Hero[udg_BT_Times]
                    set udg_BT_Interval[udg_BT] = udg_BT_Interval[udg_BT_Times]
                    set udg_BT_IntervalCheck[udg_BT] = udg_BT_IntervalCheck[udg_BT_Times]
                    set udg_BT_Level[udg_BT] = udg_BT_Level[udg_BT_Times]
                    set udg_BT_Target[udg_BT] = udg_BT_Target[udg_BT_Times]
                    set udg_BT_Trap[udg_BT] = udg_BT_Trap[udg_BT_Times]
                else
                endif
                set udg_BT = ( udg_BT - 1 )
                set udg_BT_Skip = ( udg_BT_Skip - 1 )
                set udg_BT_Times = ( udg_BT_Times - 1 )
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func014C() ) then
                    set udg_BT_Times = 0
                    call DisableTrigger( GetTriggeringTrigger() )
                else
                endif
            else
                set udg_BT_Point[1] = GetUnitLoc(udg_BT_Trap[udg_BT])
                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                // If trap is not closed actions below are runing
                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005C() ) then
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Picking units around to catch one
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    set udg_BT_Group = GetUnitsInRangeOfLocMatching(75.00, udg_BT_Point[1], Condition(function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003))
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // If that is some unit around, it catch him and close
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023C() ) then
                        call ForGroupBJ( GetRandomSubGroup(1, udg_BT_Group), function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023Func001A )
                    else
                    endif
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Clearing group to destroy leaks
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    call DestroyGroup(udg_BT_Group)
                else
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Lower action is seting point where victum must return. like that victum cant walk.
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    set udg_BT_Point[2] = GetUnitLoc(udg_BT_Target[udg_BT])
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Interval check must increase with 0.02 second like loop speed. Interval show per how much time unit recive damage.
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011C() ) then
                        set udg_BT_IntervalCheck[udg_BT] = 0.00
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Trap destroys when victum dies.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005C() ) then
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // If victum is exacly at position of trap, it means what it is not mooving and will recive less damage
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008C() ) then
                                call UnitDamageTargetBJ( udg_BT_Hero[udg_BT], udg_BT_Target[udg_BT], udg_BT_Damage[udg_BT], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
                            else
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // But if victum trying to move, coardinates victum point will be diferent and it recive 150% damage more. You can change it by changing multiplayer number (1.50 at spell)
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                call UnitDamageTargetBJ( udg_BT_Hero[udg_BT], udg_BT_Target[udg_BT], ( udg_BT_Damage[udg_BT] * 1.65 ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
                            endif
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Removing point to avoid leaks.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Special effect creates to enemy origin, because damage recived at legs.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            call AddSpecialEffectTargetUnitBJ( "origin", udg_BT_Target[udg_BT], "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" )
                            call DestroyEffectBJ( GetLastCreatedEffectBJ() )
                        else
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Victum dies and trap must be destroyed, so duration must be zero too.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            set udg_BT_Duration[udg_BT] = 0.00
                        endif
                    else
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Interval check variable increased by loop speed to become greater or equal to interval and cause damage.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        set udg_BT_IntervalCheck[udg_BT] = ( udg_BT_IntervalCheck[udg_BT] + 0.02 )
                    endif
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Here victim moving to position of trap with function and not action. Diferent with Instant move of unit is: unit can walk while mooving :P unit can attack and cast spells. while mooving, also creeps will return to their camp place.
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    call SetUnitX(udg_BT_Target[udg_BT], GetLocationX(udg_BT_Point[1]))
                    call SetUnitY(udg_BT_Target[udg_BT], GetLocationY(udg_BT_Point[1]))
                    call RemoveLocation(udg_BT_Point[2])
                    set udg_BT_Duration[udg_BT] = ( udg_BT_Duration[udg_BT] - 0.02 )
                endif
                call RemoveLocation(udg_BT_Point[1])
            endif
        else
        endif
        set udg_BT = udg_BT + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Bear_Trap_Loop takes nothing returns nothing
    local trigger gg_trg_Bear_Trap_Loop = CreateTrigger(  )
    call DisableTrigger( gg_trg_Bear_Trap_Loop )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Bear_Trap_Loop, 0.02 )
    call TriggerAddAction( gg_trg_Bear_Trap_Loop, function Trig_Bear_Trap_Loop_Actions )
endfunction
But now I am getting this:
Line 23567: [] Function redeclared: Trig_Bear_Trap_Loop_Func001Func001Func001Fun
c005Func011Func005Func008Func006001
Line 23179: [] ---- Previous declaration.


I know I am supposed to do something with scopes/private librarys, just not sure how to do it right.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Multiple globals blocks are only supported with JassHelper doing the compiling (it merges them into one on save).

If they are already declared in GUI trigger editor then re-declaring them will not work and is totally unnecessary as they are already inside the main globals block.
 
Level 3
Joined
Mar 1, 2015
Messages
53
I fixed redeclarated error
JASS:
library BearTrapLoop initializer onInit
  globals
integer = udg_BT
boolean array udg_BT_Closed
real array udg_BT_Damage 
real array udg_BT_Duration
group = udg_BT_Group
unit array udg_BT_Hero
real array udg_BT_Interval
real array udg_BT_IntervalCheck
integer array udg_BT_Level
boolean array udg_BT_On
location array udg_BT_Point
integer = udg_BT_Skip
unit array udg_BT_Target
location array udg_BT_TargetPoint
integer = udg_BT_Times
unit array udg_BT_Trap
endglobals
    
function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006001 takes nothing returns boolean
    return ( GetLocationX(udg_BT_Point[1]) == GetLocationX(udg_BT_Point[2]) )
endfunction


function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006002 takes nothing returns boolean
    return ( GetLocationY(udg_BT_Point[1]) == GetLocationY(udg_BT_Point[2]) )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008C takes nothing returns boolean
    if ( not GetBooleanOr( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006002() ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005C takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(udg_BT_Target[udg_BT]) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011C takes nothing returns boolean
    if ( not ( udg_BT_IntervalCheck[udg_BT] >= udg_BT_Interval[udg_BT] ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001001 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) == true )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001002 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001 takes nothing returns boolean
    return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001002() )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002001 takes nothing returns boolean
    return ( IsUnitDeadBJ(GetFilterUnit()) == false )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002002 takes nothing returns boolean
    return ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(udg_BT_Hero[udg_BT])) == false )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002 takes nothing returns boolean
    return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002002() )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002() )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023Func001A takes nothing returns nothing
    set udg_BT_Target[udg_BT] = GetEnumUnit()
    set udg_BT_Closed[udg_BT] = true
    call SetUnitAnimation( udg_BT_Trap[udg_BT], "death spell" )
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // Trap being visible if you stack in it. You can remove lower line if you want enemy to do not know what damaging it.
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023C takes nothing returns boolean
    if ( not ( CountUnitsInGroup(udg_BT_Group) > 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005C takes nothing returns boolean
    if ( not ( udg_BT_Closed[udg_BT] == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func007C takes nothing returns boolean
    if ( ( udg_BT_Duration[udg_BT] <= 0.00 ) ) then
        return true
    endif
    if ( ( udg_BT_Trap[udg_BT] == null ) ) then
        return true
    endif
    if ( ( IsUnitDeadBJ(udg_BT_Trap[udg_BT]) == true ) ) then
        return true
    endif
    return false
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func008Func005C takes nothing returns boolean
    if ( ( udg_BT_Trap[udg_BT] == null ) ) then
        return true
    endif
    if ( ( IsUnitDeadBJ(udg_BT_Trap[udg_BT]) == true ) ) then
        return true
    endif
    return false
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func008C takes nothing returns boolean
    if ( not Trig_Bear_Trap_Loop_Func001Func001Func001Func008Func005C() ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func010C takes nothing returns boolean
    if ( not ( udg_BT < udg_BT_Times ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func014C takes nothing returns boolean
    if ( not ( udg_BT_Skip == 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001C takes nothing returns boolean
    if ( not Trig_Bear_Trap_Loop_Func001Func001Func001Func007C() ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001C takes nothing returns boolean
    if ( not ( udg_BT_On[udg_BT] == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Loop_Actions takes nothing returns nothing
    set udg_BT = 1
    loop
        exitwhen udg_BT > udg_BT_Times
        if ( Trig_Bear_Trap_Loop_Func001Func001C() ) then
            if ( Trig_Bear_Trap_Loop_Func001Func001Func001C() ) then
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func008C() ) then
                else
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Killing trap because if it is exist and it is alive but duration elapsed it must to die.
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    call KillUnit( udg_BT_Trap[udg_BT] )
                endif
                set udg_BT_On[udg_BT] = false
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func010C() ) then
                    set udg_BT_On[udg_BT] = udg_BT_On[udg_BT_Times]
                    set udg_BT_Closed[udg_BT] = udg_BT_Closed[udg_BT_Times]
                    set udg_BT_Damage[udg_BT] = udg_BT_Damage[udg_BT_Times]
                    set udg_BT_Duration[udg_BT] = udg_BT_Duration[udg_BT_Times]
                    set udg_BT_Hero[udg_BT] = udg_BT_Hero[udg_BT_Times]
                    set udg_BT_Interval[udg_BT] = udg_BT_Interval[udg_BT_Times]
                    set udg_BT_IntervalCheck[udg_BT] = udg_BT_IntervalCheck[udg_BT_Times]
                    set udg_BT_Level[udg_BT] = udg_BT_Level[udg_BT_Times]
                    set udg_BT_Target[udg_BT] = udg_BT_Target[udg_BT_Times]
                    set udg_BT_Trap[udg_BT] = udg_BT_Trap[udg_BT_Times]
                else
                endif
                set udg_BT = ( udg_BT - 1 )
                set udg_BT_Skip = ( udg_BT_Skip - 1 )
                set udg_BT_Times = ( udg_BT_Times - 1 )
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func014C() ) then
                    set udg_BT_Times = 0
                    call DisableTrigger( GetTriggeringTrigger() )
                else
                endif
            else
                set udg_BT_Point[1] = GetUnitLoc(udg_BT_Trap[udg_BT])
                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                // If trap is not closed actions below are runing
                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005C() ) then
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Picking units around to catch one
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    set udg_BT_Group = GetUnitsInRangeOfLocMatching(75.00, udg_BT_Point[1], Condition(function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003))
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // If that is some unit around, it catch him and close
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023C() ) then
                        call ForGroupBJ( GetRandomSubGroup(1, udg_BT_Group), function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023Func001A )
                    else
                    endif
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Clearing group to destroy leaks
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    call DestroyGroup(udg_BT_Group)
                else
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Lower action is seting point where victum must return. like that victum cant walk.
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    set udg_BT_Point[2] = GetUnitLoc(udg_BT_Target[udg_BT])
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Interval check must increase with 0.02 second like loop speed. Interval show per how much time unit recive damage.
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011C() ) then
                        set udg_BT_IntervalCheck[udg_BT] = 0.00
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Trap destroys when victum dies.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005C() ) then
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // If victum is exacly at position of trap, it means what it is not mooving and will recive less damage
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008C() ) then
                                call UnitDamageTargetBJ( udg_BT_Hero[udg_BT], udg_BT_Target[udg_BT], udg_BT_Damage[udg_BT], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
                            else
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // But if victum trying to move, coardinates victum point will be diferent and it recive 150% damage more. You can change it by changing multiplayer number (1.50 at spell)
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                call UnitDamageTargetBJ( udg_BT_Hero[udg_BT], udg_BT_Target[udg_BT], ( udg_BT_Damage[udg_BT] * 1.65 ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
                            endif
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Removing point to avoid leaks.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Special effect creates to enemy origin, because damage recived at legs.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            call AddSpecialEffectTargetUnitBJ( "origin", udg_BT_Target[udg_BT], "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" )
                            call DestroyEffectBJ( GetLastCreatedEffectBJ() )
                        else
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Victum dies and trap must be destroyed, so duration must be zero too.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            set udg_BT_Duration[udg_BT] = 0.00
                        endif
                    else
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Interval check variable increased by loop speed to become greater or equal to interval and cause damage.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        set udg_BT_IntervalCheck[udg_BT] = ( udg_BT_IntervalCheck[udg_BT] + 0.02 )
                    endif
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Here victim moving to position of trap with function and not action. Diferent with Instant move of unit is: unit can walk while mooving :P unit can attack and cast spells. while mooving, also creeps will return to their camp place.
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    call SetUnitX(udg_BT_Target[udg_BT], GetLocationX(udg_BT_Point[1]))
                    call SetUnitY(udg_BT_Target[udg_BT], GetLocationY(udg_BT_Point[1]))
                    call RemoveLocation(udg_BT_Point[2])
                    set udg_BT_Duration[udg_BT] = ( udg_BT_Duration[udg_BT] - 0.02 )
                endif
                call RemoveLocation(udg_BT_Point[1])
            endif
        else
        endif
        set udg_BT = udg_BT + 1
    endloop
endfunction

//===========================================================================
function onInit takes nothing returns nothing
    local trigger gg_trg_Bear_Trap_Loop = CreateTrigger(  )
    call DisableTrigger( gg_trg_Bear_Trap_Loop )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Bear_Trap_Loop, 0.02 )
    call TriggerAddAction( gg_trg_Bear_Trap_Loop, function Trig_Bear_Trap_Loop_Actions )
endfunction

NEW ERROR:
Line 6663: [] Nested scopes cannot have initializers
 
Level 19
Joined
Jul 14, 2011
Messages
875
Why convert GUI spells to jass if you arent gonna change anything? You gain nothing.
Anyways, you were missing an endlibrary. Use scope instead of library. I also suggest to make the functions private, mainly onInit. Judging by the name you gave the library, the variables are used in other places so you shouldn't make them private.

E: Here:
JASS:
scope BearTrapLoop initializer onInit
    globals
        integer     array   udg_BT_Level
        real        array   udg_BT_Interval
        real        array   udg_BT_IntervalCheck
        real        array   udg_BT_Damage
        real        array   udg_BT_Duration
        unit        array   udg_BT_Hero
        unit        array   udg_BT_Target
        unit        array   udg_BT_Trap
        boolean     array   udg_BT_On
        boolean     array   udg_BT_Closed
        location    array   udg_BT_TargetPoint
        location    array   udg_BT_Point
        integer             udg_BT_Times
        integer             udg_BT_Skip
        integer             udg_BT
        group               udg_BT_Group
    endglobals
    
    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006001 takes nothing returns boolean
        return ( GetLocationX(udg_BT_Point[1]) == GetLocationX(udg_BT_Point[2]) )
    endfunction


    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006002 takes nothing returns boolean
        return ( GetLocationY(udg_BT_Point[1]) == GetLocationY(udg_BT_Point[2]) )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008C takes nothing returns boolean
        if ( not GetBooleanOr( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006002() ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005C takes nothing returns boolean
        if ( not ( IsUnitAliveBJ(udg_BT_Target[udg_BT]) == true ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011C takes nothing returns boolean
        if ( not ( udg_BT_IntervalCheck[udg_BT] >= udg_BT_Interval[udg_BT] ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001001 takes nothing returns boolean
        return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) == true )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001002 takes nothing returns boolean
        return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001 takes nothing returns boolean
        return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001002() )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002001 takes nothing returns boolean
        return ( IsUnitDeadBJ(GetFilterUnit()) == false )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002002 takes nothing returns boolean
        return ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(udg_BT_Hero[udg_BT])) == false )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002 takes nothing returns boolean
        return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002002() )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003 takes nothing returns boolean
        return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002() )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023Func001A takes nothing returns nothing
        set udg_BT_Target[udg_BT] = GetEnumUnit()
        set udg_BT_Closed[udg_BT] = true
        call SetUnitAnimation( udg_BT_Trap[udg_BT], "death spell" )
        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
        // Trap being visible if you stack in it. You can remove lower line if you want enemy to do not know what damaging it.
        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023C takes nothing returns boolean
        if ( not ( CountUnitsInGroup(udg_BT_Group) > 0 ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005C takes nothing returns boolean
        if ( not ( udg_BT_Closed[udg_BT] == false ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func007C takes nothing returns boolean
        if ( ( udg_BT_Duration[udg_BT] <= 0.00 ) ) then
            return true
        endif
        if ( ( udg_BT_Trap[udg_BT] == null ) ) then
            return true
        endif
        if ( ( IsUnitDeadBJ(udg_BT_Trap[udg_BT]) == true ) ) then
            return true
        endif
        return false
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func008Func005C takes nothing returns boolean
        if ( ( udg_BT_Trap[udg_BT] == null ) ) then
            return true
        endif
        if ( ( IsUnitDeadBJ(udg_BT_Trap[udg_BT]) == true ) ) then
            return true
        endif
        return false
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func008C takes nothing returns boolean
        if ( not Trig_Bear_Trap_Loop_Func001Func001Func001Func008Func005C() ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func010C takes nothing returns boolean
        if ( not ( udg_BT < udg_BT_Times ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func014C takes nothing returns boolean
        if ( not ( udg_BT_Skip == 0 ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001C takes nothing returns boolean
        if ( not Trig_Bear_Trap_Loop_Func001Func001Func001Func007C() ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001C takes nothing returns boolean
        if ( not ( udg_BT_On[udg_BT] == true ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Actions takes nothing returns nothing
        set udg_BT = 1
        loop
            exitwhen udg_BT > udg_BT_Times
            if ( Trig_Bear_Trap_Loop_Func001Func001C() ) then
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001C() ) then
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func008C() ) then
                    else
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Killing trap because if it is exist and it is alive but duration elapsed it must to die.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        call KillUnit( udg_BT_Trap[udg_BT] )
                    endif
                    set udg_BT_On[udg_BT] = false
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func010C() ) then
                        set udg_BT_On[udg_BT] = udg_BT_On[udg_BT_Times]
                        set udg_BT_Closed[udg_BT] = udg_BT_Closed[udg_BT_Times]
                        set udg_BT_Damage[udg_BT] = udg_BT_Damage[udg_BT_Times]
                        set udg_BT_Duration[udg_BT] = udg_BT_Duration[udg_BT_Times]
                        set udg_BT_Hero[udg_BT] = udg_BT_Hero[udg_BT_Times]
                        set udg_BT_Interval[udg_BT] = udg_BT_Interval[udg_BT_Times]
                        set udg_BT_IntervalCheck[udg_BT] = udg_BT_IntervalCheck[udg_BT_Times]
                        set udg_BT_Level[udg_BT] = udg_BT_Level[udg_BT_Times]
                        set udg_BT_Target[udg_BT] = udg_BT_Target[udg_BT_Times]
                        set udg_BT_Trap[udg_BT] = udg_BT_Trap[udg_BT_Times]
                    else
                    endif
                    set udg_BT = ( udg_BT - 1 )
                    set udg_BT_Skip = ( udg_BT_Skip - 1 )
                    set udg_BT_Times = ( udg_BT_Times - 1 )
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func014C() ) then
                        set udg_BT_Times = 0
                        call DisableTrigger( GetTriggeringTrigger() )
                    else
                    endif
                else
                    set udg_BT_Point[1] = GetUnitLoc(udg_BT_Trap[udg_BT])
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // If trap is not closed actions below are runing
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005C() ) then
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Picking units around to catch one
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        set udg_BT_Group = GetUnitsInRangeOfLocMatching(75.00, udg_BT_Point[1], Condition(function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003))
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // If that is some unit around, it catch him and close
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023C() ) then
                            call ForGroupBJ( GetRandomSubGroup(1, udg_BT_Group), function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023Func001A )
                        else
                        endif
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Clearing group to destroy leaks
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        call DestroyGroup(udg_BT_Group)
                    else
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Lower action is seting point where victum must return. like that victum cant walk.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        set udg_BT_Point[2] = GetUnitLoc(udg_BT_Target[udg_BT])
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Interval check must increase with 0.02 second like loop speed. Interval show per how much time unit recive damage.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011C() ) then
                            set udg_BT_IntervalCheck[udg_BT] = 0.00
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Trap destroys when victum dies.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005C() ) then
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // If victum is exacly at position of trap, it means what it is not mooving and will recive less damage
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008C() ) then
                                    call UnitDamageTargetBJ( udg_BT_Hero[udg_BT], udg_BT_Target[udg_BT], udg_BT_Damage[udg_BT], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
                                else
                                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                    // But if victum trying to move, coardinates victum point will be diferent and it recive 150% damage more. You can change it by changing multiplayer number (1.50 at spell)
                                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                    call UnitDamageTargetBJ( udg_BT_Hero[udg_BT], udg_BT_Target[udg_BT], ( udg_BT_Damage[udg_BT] * 1.65 ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
                                endif
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // Removing point to avoid leaks.
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // Special effect creates to enemy origin, because damage recived at legs.
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                call AddSpecialEffectTargetUnitBJ( "origin", udg_BT_Target[udg_BT], "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" )
                                call DestroyEffectBJ( GetLastCreatedEffectBJ() )
                            else
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // Victum dies and trap must be destroyed, so duration must be zero too.
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                set udg_BT_Duration[udg_BT] = 0.00
                            endif
                        else
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Interval check variable increased by loop speed to become greater or equal to interval and cause damage.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            set udg_BT_IntervalCheck[udg_BT] = ( udg_BT_IntervalCheck[udg_BT] + 0.02 )
                        endif
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Here victim moving to position of trap with function and not action. Diferent with Instant move of unit is: unit can walk while mooving :P unit can attack and cast spells. while mooving, also creeps will return to their camp place.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        call SetUnitX(udg_BT_Target[udg_BT], GetLocationX(udg_BT_Point[1]))
                        call SetUnitY(udg_BT_Target[udg_BT], GetLocationY(udg_BT_Point[1]))
                        call RemoveLocation(udg_BT_Point[2])
                        set udg_BT_Duration[udg_BT] = ( udg_BT_Duration[udg_BT] - 0.02 )
                    endif
                    call RemoveLocation(udg_BT_Point[1])
                endif
            else
            endif
            set udg_BT = udg_BT + 1
        endloop
    endfunction

    private function onInit takes nothing returns nothing
        local trigger gg_trg_Bear_Trap_Loop = CreateTrigger( )
        call DisableTrigger( gg_trg_Bear_Trap_Loop )
        call TriggerRegisterTimerEventPeriodic( gg_trg_Bear_Trap_Loop, 0.02 )
        call TriggerAddAction( gg_trg_Bear_Trap_Loop, function Trig_Bear_Trap_Loop_Actions )
    endfunction
endscope
 
Level 3
Joined
Mar 1, 2015
Messages
53
I have to use jass because its the only way to add spells to a existing map without bugging it.

So Bear_Trap_Loop works fine now, next problem is diffrent jass file- Bear_Trap which is supposed to enable the Bear_Trap_Loop

Error:

logs\output_war3map.j: Compile error.
Line 23542: [maa???] Undeclared variable gg_trg_Bear_Trap_Loop

23541 | if ( Trig_Bear_Trap_Func003C() ) then
23542 | call EnableTrigger(gg_trg_Bear_Trap_Loop)
23543 | else
23544 | endif
23545 | set udg_BT_Skip=( udg_BT_Skip + 1 )
jasshelper error: pid 8548 exit 1
 
Level 19
Joined
Jul 14, 2011
Messages
875
Make sure the trigger name is "Bear Trap Loop"

JASS:
globals
	integer     array   udg_BT_Level
	real        array   udg_BT_Interval
	real        array   udg_BT_IntervalCheck
	real        array   udg_BT_Damage
	real        array   udg_BT_Duration
	unit        array   udg_BT_Hero
	unit        array   udg_BT_Target
	unit        array   udg_BT_Trap
	boolean     array   udg_BT_On
	boolean     array   udg_BT_Closed
	location    array   udg_BT_TargetPoint
	location    array   udg_BT_Point
	integer             udg_BT_Times
	integer             udg_BT_Skip
	integer             udg_BT
	group               udg_BT_Group
endglobals
	
function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006001 takes nothing returns boolean
	return ( GetLocationX(udg_BT_Point[1]) == GetLocationX(udg_BT_Point[2]) )
endfunction


function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006002 takes nothing returns boolean
	return ( GetLocationY(udg_BT_Point[1]) == GetLocationY(udg_BT_Point[2]) )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008C takes nothing returns boolean
	if ( not GetBooleanOr( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006002() ) ) then
		return false
	endif
	return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005C takes nothing returns boolean
	if ( not ( IsUnitAliveBJ(udg_BT_Target[udg_BT]) == true ) ) then
		return false
	endif
	return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011C takes nothing returns boolean
	if ( not ( udg_BT_IntervalCheck[udg_BT] >= udg_BT_Interval[udg_BT] ) ) then
		return false
	endif
	return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001001 takes nothing returns boolean
	return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) == true )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001002 takes nothing returns boolean
	return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001 takes nothing returns boolean
	return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001002() )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002001 takes nothing returns boolean
	return ( IsUnitDeadBJ(GetFilterUnit()) == false )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002002 takes nothing returns boolean
	return ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(udg_BT_Hero[udg_BT])) == false )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002 takes nothing returns boolean
	return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002002() )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003 takes nothing returns boolean
	return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002() )
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023Func001A takes nothing returns nothing
	set udg_BT_Target[udg_BT] = GetEnumUnit()
	set udg_BT_Closed[udg_BT] = true
	call SetUnitAnimation( udg_BT_Trap[udg_BT], "death spell" )
	// ----------------------------------------------------------------------------------------------------------------------------------------------------------
	// Trap being visible if you stack in it. You can remove lower line if you want enemy to do not know what damaging it.
	// ----------------------------------------------------------------------------------------------------------------------------------------------------------
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023C takes nothing returns boolean
	if ( not ( CountUnitsInGroup(udg_BT_Group) > 0 ) ) then
		return false
	endif
	return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func005C takes nothing returns boolean
	if ( not ( udg_BT_Closed[udg_BT] == false ) ) then
		return false
	endif
	return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func007C takes nothing returns boolean
	if ( ( udg_BT_Duration[udg_BT] <= 0.00 ) ) then
		return true
	endif
	if ( ( udg_BT_Trap[udg_BT] == null ) ) then
		return true
	endif
	if ( ( IsUnitDeadBJ(udg_BT_Trap[udg_BT]) == true ) ) then
		return true
	endif
	return false
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func008Func005C takes nothing returns boolean
	if ( ( udg_BT_Trap[udg_BT] == null ) ) then
		return true
	endif
	if ( ( IsUnitDeadBJ(udg_BT_Trap[udg_BT]) == true ) ) then
		return true
	endif
	return false
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func008C takes nothing returns boolean
	if ( not Trig_Bear_Trap_Loop_Func001Func001Func001Func008Func005C() ) then
		return false
	endif
	return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func010C takes nothing returns boolean
	if ( not ( udg_BT < udg_BT_Times ) ) then
		return false
	endif
	return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001Func014C takes nothing returns boolean
	if ( not ( udg_BT_Skip == 0 ) ) then
		return false
	endif
	return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001Func001C takes nothing returns boolean
	if ( not Trig_Bear_Trap_Loop_Func001Func001Func001Func007C() ) then
		return false
	endif
	return true
endfunction

function Trig_Bear_Trap_Loop_Func001Func001C takes nothing returns boolean
	if ( not ( udg_BT_On[udg_BT] == true ) ) then
		return false
	endif
	return true
endfunction

function Trig_Bear_Trap_Loop_Actions takes nothing returns nothing
	set udg_BT = 1
	loop
		exitwhen udg_BT > udg_BT_Times
		if ( Trig_Bear_Trap_Loop_Func001Func001C() ) then
			if ( Trig_Bear_Trap_Loop_Func001Func001Func001C() ) then
				if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func008C() ) then
				else
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					// Killing trap because if it is exist and it is alive but duration elapsed it must to die.
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					call KillUnit( udg_BT_Trap[udg_BT] )
				endif
				set udg_BT_On[udg_BT] = false
				if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func010C() ) then
					set udg_BT_On[udg_BT] = udg_BT_On[udg_BT_Times]
					set udg_BT_Closed[udg_BT] = udg_BT_Closed[udg_BT_Times]
					set udg_BT_Damage[udg_BT] = udg_BT_Damage[udg_BT_Times]
					set udg_BT_Duration[udg_BT] = udg_BT_Duration[udg_BT_Times]
					set udg_BT_Hero[udg_BT] = udg_BT_Hero[udg_BT_Times]
					set udg_BT_Interval[udg_BT] = udg_BT_Interval[udg_BT_Times]
					set udg_BT_IntervalCheck[udg_BT] = udg_BT_IntervalCheck[udg_BT_Times]
					set udg_BT_Level[udg_BT] = udg_BT_Level[udg_BT_Times]
					set udg_BT_Target[udg_BT] = udg_BT_Target[udg_BT_Times]
					set udg_BT_Trap[udg_BT] = udg_BT_Trap[udg_BT_Times]
				else
				endif
				set udg_BT = ( udg_BT - 1 )
				set udg_BT_Skip = ( udg_BT_Skip - 1 )
				set udg_BT_Times = ( udg_BT_Times - 1 )
				if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func014C() ) then
					set udg_BT_Times = 0
					call DisableTrigger( GetTriggeringTrigger() )
				else
				endif
			else
				set udg_BT_Point[1] = GetUnitLoc(udg_BT_Trap[udg_BT])
				// ----------------------------------------------------------------------------------------------------------------------------------------------------------
				// If trap is not closed actions below are runing
				// ----------------------------------------------------------------------------------------------------------------------------------------------------------
				if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005C() ) then
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					// Picking units around to catch one
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					set udg_BT_Group = GetUnitsInRangeOfLocMatching(75.00, udg_BT_Point[1], Condition(function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003))
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					// If that is some unit around, it catch him and close
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023C() ) then
						call ForGroupBJ( GetRandomSubGroup(1, udg_BT_Group), function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023Func001A )
					else
					endif
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					// Clearing group to destroy leaks
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					call DestroyGroup(udg_BT_Group)
				else
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					// Lower action is seting point where victum must return. like that victum cant walk.
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					set udg_BT_Point[2] = GetUnitLoc(udg_BT_Target[udg_BT])
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					// Interval check must increase with 0.02 second like loop speed. Interval show per how much time unit recive damage.
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011C() ) then
						set udg_BT_IntervalCheck[udg_BT] = 0.00
						// ----------------------------------------------------------------------------------------------------------------------------------------------------------
						// Trap destroys when victum dies.
						// ----------------------------------------------------------------------------------------------------------------------------------------------------------
						if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005C() ) then
							// ----------------------------------------------------------------------------------------------------------------------------------------------------------
							// If victum is exacly at position of trap, it means what it is not mooving and will recive less damage
							// ----------------------------------------------------------------------------------------------------------------------------------------------------------
							if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008C() ) then
								call UnitDamageTargetBJ( udg_BT_Hero[udg_BT], udg_BT_Target[udg_BT], udg_BT_Damage[udg_BT], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
							else
								// ----------------------------------------------------------------------------------------------------------------------------------------------------------
								// But if victum trying to move, coardinates victum point will be diferent and it recive 150% damage more. You can change it by changing multiplayer number (1.50 at spell)
								// ----------------------------------------------------------------------------------------------------------------------------------------------------------
								call UnitDamageTargetBJ( udg_BT_Hero[udg_BT], udg_BT_Target[udg_BT], ( udg_BT_Damage[udg_BT] * 1.65 ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
							endif
							// ----------------------------------------------------------------------------------------------------------------------------------------------------------
							// Removing point to avoid leaks.
							// ----------------------------------------------------------------------------------------------------------------------------------------------------------
							// ----------------------------------------------------------------------------------------------------------------------------------------------------------
							// Special effect creates to enemy origin, because damage recived at legs.
							// ----------------------------------------------------------------------------------------------------------------------------------------------------------
							call AddSpecialEffectTargetUnitBJ( "origin", udg_BT_Target[udg_BT], "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" )
							call DestroyEffectBJ( GetLastCreatedEffectBJ() )
						else
							// ----------------------------------------------------------------------------------------------------------------------------------------------------------
							// Victum dies and trap must be destroyed, so duration must be zero too.
							// ----------------------------------------------------------------------------------------------------------------------------------------------------------
							set udg_BT_Duration[udg_BT] = 0.00
						endif
					else
						// ----------------------------------------------------------------------------------------------------------------------------------------------------------
						// Interval check variable increased by loop speed to become greater or equal to interval and cause damage.
						// ----------------------------------------------------------------------------------------------------------------------------------------------------------
						set udg_BT_IntervalCheck[udg_BT] = ( udg_BT_IntervalCheck[udg_BT] + 0.02 )
					endif
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					// Here victim moving to position of trap with function and not action. Diferent with Instant move of unit is: unit can walk while mooving :P unit can attack and cast spells. while mooving, also creeps will return to their camp place.
					// ----------------------------------------------------------------------------------------------------------------------------------------------------------
					call SetUnitX(udg_BT_Target[udg_BT], GetLocationX(udg_BT_Point[1]))
					call SetUnitY(udg_BT_Target[udg_BT], GetLocationY(udg_BT_Point[1]))
					call RemoveLocation(udg_BT_Point[2])
					set udg_BT_Duration[udg_BT] = ( udg_BT_Duration[udg_BT] - 0.02 )
				endif
				call RemoveLocation(udg_BT_Point[1])
			endif
		else
		endif
		set udg_BT = udg_BT + 1
	endloop
endfunction

function InitTrig_Bear_Trap_Loop takes nothing returns nothing
	local trigger gg_trg_Bear_Trap_Loop = CreateTrigger( )
	call DisableTrigger( gg_trg_Bear_Trap_Loop )
	call TriggerRegisterTimerEventPeriodic( gg_trg_Bear_Trap_Loop, 0.02 )
	call TriggerAddAction( gg_trg_Bear_Trap_Loop, function Trig_Bear_Trap_Loop_Actions )
endfunction

Also, see this.
 
Last edited:
Level 3
Joined
Mar 1, 2015
Messages
53
Guy's author of the map told me to set gg_trg_Bear_Trap_Loop as a global, is it ok:
JASS:
    globals
        integer     array   udg_BT_Level
        real        array   udg_BT_Interval
        real        array   udg_BT_IntervalCheck
        real        array   udg_BT_Damage
        real        array   udg_BT_Duration
        unit        array   udg_BT_Hero
        unit        array   udg_BT_Target
        unit        array   udg_BT_Trap
        boolean     array   udg_BT_On
        boolean     array   udg_BT_Closed
        location    array   udg_BT_TargetPoint
        location    array   udg_BT_Point
        integer             udg_BT_Times
        integer             udg_BT_Skip
        integer             udg_BT
        group               udg_BT_Group
        trigger gg_trg_Bear_Trap_Loop
    endglobals

I don't get any errors in Git Bash anymore, but nothing happens when I use spell ingame... Let me note that I already added 2 simpler custom spells to the map before and they works.

Some more explenation:
The jass code of spells is not located in the world editor, it is saved as a separate .j file in the triggers folder of the map contants. By typing in comand in GIT bash, scripts takes base_map and loads the jass files from the folder in it.
Maybe this will clear some things.

NOT WORKING SPELLS:

BearTrap
JASS:
function Trig_Bear_Trap_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A0D3' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Func003C takes nothing returns boolean
    if ( not ( udg_BT_Skip == 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Bear_Trap_Actions takes nothing returns nothing
    // If no spells are runing, loop will turn on to run spell that just have been casted.
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    if ( Trig_Bear_Trap_Func003C() ) then
        call EnableTrigger( gg_trg_Bear_Trap_Loop )
    else
    endif
    set udg_BT_Skip = ( udg_BT_Skip + 1 )
    set udg_BT_Times = ( udg_BT_Times + 1 )
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // Boolean below controll whole spell. It show if spell must run or not (if it is on orr off).
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    set udg_BT_On[udg_BT_Times] = true
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // This spell use specific point variable that will be cleared at loop trigger
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    set udg_BT_Point[0] = GetSpellTargetLoc()
    set udg_BT_Hero[udg_BT_Times] = GetTriggerUnit()
    set udg_BT_Level[udg_BT_Times] = GetUnitAbilityLevelSwapped('A0D3', GetTriggerUnit())
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // Duration variable show how much unit will remain at trap after it closed.
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    set udg_BT_Duration[udg_BT_Times] = ( 2.00 + ( 1 * I2R(udg_BT_Level[udg_BT_Times]) ) )
    set udg_BT_Damage[udg_BT_Times] = ( 5.00 + ( 5.00 * I2R(udg_BT_Level[udg_BT_Times]) ) )
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // Variable closed is boolead that check if trap close and hold unit.
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    set udg_BT_Closed[udg_BT_Times] = false
    call CreateNUnitsAtLoc( 1, 'o01S', GetOwningPlayer(GetTriggerUnit()), udg_BT_Point[0], GetUnitFacing(GetTriggerUnit()) )
    call SetUnitAnimation( GetLastCreatedUnit(), "birth" )
    call SetUnitPathing( GetLastCreatedUnit(), false )
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // Lower code line show how much trap remain at ground. I dont recomend to put very big time and low cppldown of spell. It must be balabced somehow to do not cause game to lag.
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    call UnitApplyTimedLifeBJ( 16.00, 'BTLF', GetLastCreatedUnit() )
    set udg_BT_Trap[udg_BT_Times] = GetLastCreatedUnit()
    set udg_BT_IntervalCheck[udg_BT_Times] = 0.50
    set udg_BT_Interval[udg_BT_Times] = 0.50
    call RemoveLocation(udg_BT_Point[0])
endfunction

//===========================================================================
function InitTrig_Bear_Trap takes nothing returns nothing
    local trigger gg_trg_Bear_Trap = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Bear_Trap, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Bear_Trap, Condition( function Trig_Bear_Trap_Conditions ) )
    call TriggerAddAction( gg_trg_Bear_Trap, function Trig_Bear_Trap_Actions )
endfunction




BearTrapLoop
JASS:
scope BearTrapLoop initializer onInit
    globals
        integer     array   udg_BT_Level
        real        array   udg_BT_Interval
        real        array   udg_BT_IntervalCheck
        real        array   udg_BT_Damage
        real        array   udg_BT_Duration
        unit        array   udg_BT_Hero
        unit        array   udg_BT_Target
        unit        array   udg_BT_Trap
        boolean     array   udg_BT_On
        boolean     array   udg_BT_Closed
        location    array   udg_BT_TargetPoint
        location    array   udg_BT_Point
        integer             udg_BT_Times
        integer             udg_BT_Skip
        integer             udg_BT
        group               udg_BT_Group
        trigger gg_trg_Bear_Trap_Loop
    endglobals
    
    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006001 takes nothing returns boolean
        return ( GetLocationX(udg_BT_Point[1]) == GetLocationX(udg_BT_Point[2]) )
    endfunction


    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006002 takes nothing returns boolean
        return ( GetLocationY(udg_BT_Point[1]) == GetLocationY(udg_BT_Point[2]) )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008C takes nothing returns boolean
        if ( not GetBooleanOr( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006002() ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005C takes nothing returns boolean
        if ( not ( IsUnitAliveBJ(udg_BT_Target[udg_BT]) == true ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011C takes nothing returns boolean
        if ( not ( udg_BT_IntervalCheck[udg_BT] >= udg_BT_Interval[udg_BT] ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001001 takes nothing returns boolean
        return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) == true )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001002 takes nothing returns boolean
        return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001 takes nothing returns boolean
        return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001002() )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002001 takes nothing returns boolean
        return ( IsUnitDeadBJ(GetFilterUnit()) == false )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002002 takes nothing returns boolean
        return ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(udg_BT_Hero[udg_BT])) == false )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002 takes nothing returns boolean
        return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002002() )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003 takes nothing returns boolean
        return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002() )
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023Func001A takes nothing returns nothing
        set udg_BT_Target[udg_BT] = GetEnumUnit()
        set udg_BT_Closed[udg_BT] = true
        call SetUnitAnimation( udg_BT_Trap[udg_BT], "death spell" )
        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
        // Trap being visible if you stack in it. You can remove lower line if you want enemy to do not know what damaging it.
        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023C takes nothing returns boolean
        if ( not ( CountUnitsInGroup(udg_BT_Group) > 0 ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005C takes nothing returns boolean
        if ( not ( udg_BT_Closed[udg_BT] == false ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func007C takes nothing returns boolean
        if ( ( udg_BT_Duration[udg_BT] <= 0.00 ) ) then
            return true
        endif
        if ( ( udg_BT_Trap[udg_BT] == null ) ) then
            return true
        endif
        if ( ( IsUnitDeadBJ(udg_BT_Trap[udg_BT]) == true ) ) then
            return true
        endif
        return false
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func008Func005C takes nothing returns boolean
        if ( ( udg_BT_Trap[udg_BT] == null ) ) then
            return true
        endif
        if ( ( IsUnitDeadBJ(udg_BT_Trap[udg_BT]) == true ) ) then
            return true
        endif
        return false
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func008C takes nothing returns boolean
        if ( not Trig_Bear_Trap_Loop_Func001Func001Func001Func008Func005C() ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func010C takes nothing returns boolean
        if ( not ( udg_BT < udg_BT_Times ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001Func014C takes nothing returns boolean
        if ( not ( udg_BT_Skip == 0 ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001Func001C takes nothing returns boolean
        if ( not Trig_Bear_Trap_Loop_Func001Func001Func001Func007C() ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Func001Func001C takes nothing returns boolean
        if ( not ( udg_BT_On[udg_BT] == true ) ) then
            return false
        endif
        return true
    endfunction

    private function Trig_Bear_Trap_Loop_Actions takes nothing returns nothing
        set udg_BT = 1
        loop
            exitwhen udg_BT > udg_BT_Times
            if ( Trig_Bear_Trap_Loop_Func001Func001C() ) then
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001C() ) then
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func008C() ) then
                    else
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Killing trap because if it is exist and it is alive but duration elapsed it must to die.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        call KillUnit( udg_BT_Trap[udg_BT] )
                    endif
                    set udg_BT_On[udg_BT] = false
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func010C() ) then
                        set udg_BT_On[udg_BT] = udg_BT_On[udg_BT_Times]
                        set udg_BT_Closed[udg_BT] = udg_BT_Closed[udg_BT_Times]
                        set udg_BT_Damage[udg_BT] = udg_BT_Damage[udg_BT_Times]
                        set udg_BT_Duration[udg_BT] = udg_BT_Duration[udg_BT_Times]
                        set udg_BT_Hero[udg_BT] = udg_BT_Hero[udg_BT_Times]
                        set udg_BT_Interval[udg_BT] = udg_BT_Interval[udg_BT_Times]
                        set udg_BT_IntervalCheck[udg_BT] = udg_BT_IntervalCheck[udg_BT_Times]
                        set udg_BT_Level[udg_BT] = udg_BT_Level[udg_BT_Times]
                        set udg_BT_Target[udg_BT] = udg_BT_Target[udg_BT_Times]
                        set udg_BT_Trap[udg_BT] = udg_BT_Trap[udg_BT_Times]
                    else
                    endif
                    set udg_BT = ( udg_BT - 1 )
                    set udg_BT_Skip = ( udg_BT_Skip - 1 )
                    set udg_BT_Times = ( udg_BT_Times - 1 )
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func014C() ) then
                        set udg_BT_Times = 0
                        call DisableTrigger( GetTriggeringTrigger() )
                    else
                    endif
                else
                    set udg_BT_Point[1] = GetUnitLoc(udg_BT_Trap[udg_BT])
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // If trap is not closed actions below are runing
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005C() ) then
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Picking units around to catch one
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        set udg_BT_Group = GetUnitsInRangeOfLocMatching(75.00, udg_BT_Point[1], Condition(function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003))
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // If that is some unit around, it catch him and close
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023C() ) then
                            call ForGroupBJ( GetRandomSubGroup(1, udg_BT_Group), function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023Func001A )
                        else
                        endif
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Clearing group to destroy leaks
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        call DestroyGroup(udg_BT_Group)
                    else
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Lower action is seting point where victum must return. like that victum cant walk.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        set udg_BT_Point[2] = GetUnitLoc(udg_BT_Target[udg_BT])
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Interval check must increase with 0.02 second like loop speed. Interval show per how much time unit recive damage.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011C() ) then
                            set udg_BT_IntervalCheck[udg_BT] = 0.00
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Trap destroys when victum dies.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005C() ) then
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // If victum is exacly at position of trap, it means what it is not mooving and will recive less damage
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008C() ) then
                                    call UnitDamageTargetBJ( udg_BT_Hero[udg_BT], udg_BT_Target[udg_BT], udg_BT_Damage[udg_BT], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
                                else
                                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                    // But if victum trying to move, coardinates victum point will be diferent and it recive 150% damage more. You can change it by changing multiplayer number (1.50 at spell)
                                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                    call UnitDamageTargetBJ( udg_BT_Hero[udg_BT], udg_BT_Target[udg_BT], ( udg_BT_Damage[udg_BT] * 1.65 ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
                                endif
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // Removing point to avoid leaks.
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // Special effect creates to enemy origin, because damage recived at legs.
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                call AddSpecialEffectTargetUnitBJ( "origin", udg_BT_Target[udg_BT], "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" )
                                call DestroyEffectBJ( GetLastCreatedEffectBJ() )
                            else
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // Victum dies and trap must be destroyed, so duration must be zero too.
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                set udg_BT_Duration[udg_BT] = 0.00
                            endif
                        else
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Interval check variable increased by loop speed to become greater or equal to interval and cause damage.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            set udg_BT_IntervalCheck[udg_BT] = ( udg_BT_IntervalCheck[udg_BT] + 0.02 )
                        endif
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Here victim moving to position of trap with function and not action. Diferent with Instant move of unit is: unit can walk while mooving :P unit can attack and cast spells. while mooving, also creeps will return to their camp place.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        call SetUnitX(udg_BT_Target[udg_BT], GetLocationX(udg_BT_Point[1]))
                        call SetUnitY(udg_BT_Target[udg_BT], GetLocationY(udg_BT_Point[1]))
                        call RemoveLocation(udg_BT_Point[2])
                        set udg_BT_Duration[udg_BT] = ( udg_BT_Duration[udg_BT] - 0.02 )
                    endif
                    call RemoveLocation(udg_BT_Point[1])
                endif
            else
            endif
            set udg_BT = udg_BT + 1
        endloop
    endfunction

    private function onInit takes nothing returns nothing
        local trigger gg_trg_Bear_Trap_Loop = CreateTrigger( )
        call DisableTrigger( gg_trg_Bear_Trap_Loop )
        call TriggerRegisterTimerEventPeriodic( gg_trg_Bear_Trap_Loop, 0.02 )
        call TriggerAddAction( gg_trg_Bear_Trap_Loop, function Trig_Bear_Trap_Loop_Actions )
    endfunction
endscope

EXAMPLE OF WORKING SPELL:
JASS:
function Trig_heal_Copy_Copy_Copy_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A0D5' ) ) then
        return false
    endif
    return true
endfunction

function Trig_heal_Copy_Copy_Copy_Actions takes nothing returns nothing
    local location = udg_Temp_Point
    set udg_Temp_Point = GetUnitLoc(GetTriggerUnit())
    call CreateNUnitsAtLoc( 1, 'H03M', GetOwningPlayer(GetTriggerUnit()), udg_Temp_Point, bj_UNIT_FACING )
    call UnitAddAbilityBJ( 'Arej', GetLastCreatedUnit() )
    call IssueTargetOrderBJ( GetLastCreatedUnit(), "rejuvination", GetSpellTargetUnit() )
    call UnitApplyTimedLifeBJ( 2.00, 'BTLF', GetLastCreatedUnit() )
    call RemoveLocation(udg_Temp_Point)
endfunction

//===========================================================================
function InitTrig_heal_Copy_Copy_Copy takes nothing returns nothing
    local trigger gg_trg_heal_Copy_Copy_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_heal_Copy_Copy_Copy, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_heal_Copy_Copy_Copy, Condition( function Trig_heal_Copy_Copy_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_heal_Copy_Copy_Copy, function Trig_heal_Copy_Copy_Copy_Actions )
endfunction
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
I have to use jass because its the only way to add spells to a existing map without bugging
News to me... It is common place that people import GUI spells.

Elaborate what "errors" it causes.
What ever the error the compiler decides to throw. The standard compiler might do anything from throw an error on the wrong line to crash the editor process. JassHelper might throw an error that is more useful. Without the map I cannot tell.
 
Level 3
Joined
Mar 1, 2015
Messages
53
Made some spells today, and they all work after being converted to JASS, all of them don't have any enabling trigger inside them so I think that's the problem in Bear Trap Spell...

Current codes:

BEAR TRAP SPELL:

Globals
JASS:
    location                udg_Temp_Point 
    integer array           udg_BT_Level             
    real array              udg_BT_Interval           
    real array              udg_BT_IntervalCheck      
    real array              udg_BT_Damage              
    real array              udg_BT_Duration           
    unit array              udg_BT_Hero
    unit array              udg_BT_Target
    unit array              udg_BT_Trap               
    boolean array           udg_BT_On                        
    boolean array           udg_BT_Closed              
    location array          udg_BT_TargetPoint         
    location array          udg_BT_Point
    integer                 udg_BT_Times               
    integer                 udg_BT_Skip                
    integer                 udg_BT                   
    group                   udg_BT_Group            
      trigger                 gg_trg_Bear_Trap_Loop      
   trigger                  gg_trg_Bear_Trap

CustomTriggers.j
JASS:
    call InitTrig_Bear_Trap(  )
    call InitTrig_Bear_Trap_Loop(  )

Bear Trap
JASS:
      scope BearTrap initializer onInit 

private function Trig_Bear_Trap_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A0D3' ) ) then
        return false
    endif
    return true
endfunction

private function Trig_Bear_Trap_Func003C takes nothing returns boolean
    if ( not ( udg_BT_Skip == 0 ) ) then
        return false
    endif
    return true
endfunction

private function Trig_Bear_Trap_Actions takes nothing returns nothing
    // If no spells are runing, loop will turn on to run spell that just have been casted.
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    if ( Trig_Bear_Trap_Func003C() ) then
        call EnableTrigger( gg_trg_Bear_Trap_Loop )
    else
    endif
    set udg_BT_Skip = ( udg_BT_Skip + 1 )
    set udg_BT_Times = ( udg_BT_Times + 1 )
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // Boolean below controll whole spell. It show if spell must run or not (if it is on orr off).
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    set udg_BT_On[udg_BT_Times] = true
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // This spell use specific point variable that will be cleared at loop trigger
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    set udg_BT_Point[0] = GetSpellTargetLoc()
    set udg_BT_Hero[udg_BT_Times] = GetTriggerUnit()
    set udg_BT_Level[udg_BT_Times] = GetUnitAbilityLevelSwapped('A0D3', GetTriggerUnit())
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // Duration variable show how much unit will remain at trap after it closed.
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    set udg_BT_Duration[udg_BT_Times] = ( 2.00 + ( 1 * I2R(udg_BT_Level[udg_BT_Times]) ) )
    set udg_BT_Damage[udg_BT_Times] = ( 5.00 + ( 5.00 * I2R(udg_BT_Level[udg_BT_Times]) ) )
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // Variable closed is boolead that check if trap close and hold unit.
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    set udg_BT_Closed[udg_BT_Times] = false
    call CreateNUnitsAtLoc( 1, 'o01S', GetOwningPlayer(GetTriggerUnit()), udg_BT_Point[0], GetUnitFacing(GetTriggerUnit()) )
    call SetUnitAnimation( GetLastCreatedUnit(), "birth" )
    call SetUnitPathing( GetLastCreatedUnit(), false )
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // Lower code line show how much trap remain at ground. I dont recomend to put very big time and low cppldown of spell. It must be balabced somehow to do not cause game to lag.
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    call UnitApplyTimedLifeBJ( 16.00, 'BTLF', GetLastCreatedUnit() )
    set udg_BT_Trap[udg_BT_Times] = GetLastCreatedUnit()
    set udg_BT_IntervalCheck[udg_BT_Times] = 0.50
    set udg_BT_Interval[udg_BT_Times] = 0.50
    call RemoveLocation(udg_BT_Point[0])
endfunction

//===========================================================================
private function onInit takes nothing returns nothing
    set gg_trg_Bear_Trap = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Bear_Trap, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Bear_Trap, Condition( function Trig_Bear_Trap_Conditions ) )
    call TriggerAddAction( gg_trg_Bear_Trap, function Trig_Bear_Trap_Actions )
endfunction

endscope

Bear_Trap_Loop THIS TRIGGER IS NOT INITIALY ON
JASS:
       scope BearTrapLoop initializer onInit 



private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006001 takes nothing returns boolean
    return ( GetLocationX(udg_BT_Point[1]) == GetLocationX(udg_BT_Point[2]) )
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006002 takes nothing returns boolean
    return ( GetLocationY(udg_BT_Point[1]) == GetLocationY(udg_BT_Point[2]) )
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008C takes nothing returns boolean
    if ( not GetBooleanOr( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008Func006002() ) ) then
        return false
    endif
    return true
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005C takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(udg_BT_Target[udg_BT]) == true ) ) then
        return false
    endif
    return true
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011C takes nothing returns boolean
    if ( not ( udg_BT_IntervalCheck[udg_BT] >= udg_BT_Interval[udg_BT] ) ) then
        return false
    endif
    return true
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001001 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) == true )
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001002 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false )
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001 takes nothing returns boolean
    return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001002() )
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002001 takes nothing returns boolean
    return ( IsUnitDeadBJ(GetFilterUnit()) == false )
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002002 takes nothing returns boolean
    return ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(udg_BT_Hero[udg_BT])) == false )
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002 takes nothing returns boolean
    return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002002() )
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003001(), Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003002() )
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023Func001A takes nothing returns nothing
    set udg_BT_Target[udg_BT] = GetEnumUnit()
    set udg_BT_Closed[udg_BT] = true
    call SetUnitAnimation( udg_BT_Trap[udg_BT], "death spell" )
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
    // Trap being visible if you stack in it. You can remove lower line if you want enemy to do not know what damaging it.
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023C takes nothing returns boolean
    if ( not ( CountUnitsInGroup(udg_BT_Group) > 0 ) ) then
        return false
    endif
    return true
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func005C takes nothing returns boolean
    if ( not ( udg_BT_Closed[udg_BT] == false ) ) then
        return false
    endif
    return true
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func007C takes nothing returns boolean
    if ( ( udg_BT_Duration[udg_BT] <= 0.00 ) ) then
        return true
    endif
    if ( ( udg_BT_Trap[udg_BT] == null ) ) then
        return true
    endif
    if ( ( IsUnitDeadBJ(udg_BT_Trap[udg_BT]) == true ) ) then
        return true
    endif
    return false
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func008Func005C takes nothing returns boolean
    if ( ( udg_BT_Trap[udg_BT] == null ) ) then
        return true
    endif
    if ( ( IsUnitDeadBJ(udg_BT_Trap[udg_BT]) == true ) ) then
        return true
    endif
    return false
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func008C takes nothing returns boolean
    if ( not Trig_Bear_Trap_Loop_Func001Func001Func001Func008Func005C() ) then
        return false
    endif
    return true
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func010C takes nothing returns boolean
    if ( not ( udg_BT < udg_BT_Times ) ) then
        return false
    endif
    return true
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001Func014C takes nothing returns boolean
    if ( not ( udg_BT_Skip == 0 ) ) then
        return false
    endif
    return true
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001Func001C takes nothing returns boolean
    if ( not Trig_Bear_Trap_Loop_Func001Func001Func001Func007C() ) then
        return false
    endif
    return true
endfunction

private function Trig_Bear_Trap_Loop_Func001Func001C takes nothing returns boolean
    if ( not ( udg_BT_On[udg_BT] == true ) ) then
        return false
    endif
    return true
endfunction

private function Trig_Bear_Trap_Loop_Actions takes nothing returns nothing
    set udg_BT = 1
    loop
        exitwhen udg_BT > udg_BT_Times
        if ( Trig_Bear_Trap_Loop_Func001Func001C() ) then
            if ( Trig_Bear_Trap_Loop_Func001Func001Func001C() ) then
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func008C() ) then
                else
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Killing trap because if it is exist and it is alive but duration elapsed it must to die.
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    call KillUnit( udg_BT_Trap[udg_BT] )
                endif
                set udg_BT_On[udg_BT] = false
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func010C() ) then
                    set udg_BT_On[udg_BT] = udg_BT_On[udg_BT_Times]
                    set udg_BT_Closed[udg_BT] = udg_BT_Closed[udg_BT_Times]
                    set udg_BT_Damage[udg_BT] = udg_BT_Damage[udg_BT_Times]
                    set udg_BT_Duration[udg_BT] = udg_BT_Duration[udg_BT_Times]
                    set udg_BT_Hero[udg_BT] = udg_BT_Hero[udg_BT_Times]
                    set udg_BT_Interval[udg_BT] = udg_BT_Interval[udg_BT_Times]
                    set udg_BT_IntervalCheck[udg_BT] = udg_BT_IntervalCheck[udg_BT_Times]
                    set udg_BT_Level[udg_BT] = udg_BT_Level[udg_BT_Times]
                    set udg_BT_Target[udg_BT] = udg_BT_Target[udg_BT_Times]
                    set udg_BT_Trap[udg_BT] = udg_BT_Trap[udg_BT_Times]
                else
                endif
                set udg_BT = ( udg_BT - 1 )
                set udg_BT_Skip = ( udg_BT_Skip - 1 )
                set udg_BT_Times = ( udg_BT_Times - 1 )
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func014C() ) then
                    set udg_BT_Times = 0
                    call DisableTrigger( GetTriggeringTrigger() )
                else
                endif
            else
                set udg_BT_Point[1] = GetUnitLoc(udg_BT_Trap[udg_BT])
                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                // If trap is not closed actions below are runing
                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005C() ) then
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Picking units around to catch one
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    set udg_BT_Group = GetUnitsInRangeOfLocMatching(75.00, udg_BT_Point[1], Condition(function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func019002003))
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // If that is some unit around, it catch him and close
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023C() ) then
                        call ForGroupBJ( GetRandomSubGroup(1, udg_BT_Group), function Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func023Func001A )
                    else
                    endif
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Clearing group to destroy leaks
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    call DestroyGroup(udg_BT_Group)
                else
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Lower action is seting point where victum must return. like that victum cant walk.
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    set udg_BT_Point[2] = GetUnitLoc(udg_BT_Target[udg_BT])
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Interval check must increase with 0.02 second like loop speed. Interval show per how much time unit recive damage.
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011C() ) then
                        set udg_BT_IntervalCheck[udg_BT] = 0.00
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Trap destroys when victum dies.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005C() ) then
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // If victum is exacly at position of trap, it means what it is not mooving and will recive less damage
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            if ( Trig_Bear_Trap_Loop_Func001Func001Func001Func005Func011Func005Func008C() ) then
                                call UnitDamageTargetBJ( udg_BT_Hero[udg_BT], udg_BT_Target[udg_BT], udg_BT_Damage[udg_BT], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
                            else
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                // But if victum trying to move, coardinates victum point will be diferent and it recive 150% damage more. You can change it by changing multiplayer number (1.50 at spell)
                                // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                                call UnitDamageTargetBJ( udg_BT_Hero[udg_BT], udg_BT_Target[udg_BT], ( udg_BT_Damage[udg_BT] * 1.65 ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
                            endif
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Removing point to avoid leaks.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Special effect creates to enemy origin, because damage recived at legs.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            call AddSpecialEffectTargetUnitBJ( "origin", udg_BT_Target[udg_BT], "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" )
                            call DestroyEffectBJ( GetLastCreatedEffectBJ() )
                        else
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            // Victum dies and trap must be destroyed, so duration must be zero too.
                            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                            set udg_BT_Duration[udg_BT] = 0.00
                        endif
                    else
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        // Interval check variable increased by loop speed to become greater or equal to interval and cause damage.
                        // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                        set udg_BT_IntervalCheck[udg_BT] = ( udg_BT_IntervalCheck[udg_BT] + 0.02 )
                    endif
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    // Here victim moving to position of trap with function and not action. Diferent with Instant move of unit is: unit can walk while mooving :P unit can attack and cast spells. while mooving, also creeps will return to their camp place.
                    // ----------------------------------------------------------------------------------------------------------------------------------------------------------
                    call SetUnitX(udg_BT_Target[udg_BT], GetLocationX(udg_BT_Point[1]))
                    call SetUnitY(udg_BT_Target[udg_BT], GetLocationY(udg_BT_Point[1]))
                    call RemoveLocation(udg_BT_Point[2])
                    set udg_BT_Duration[udg_BT] = ( udg_BT_Duration[udg_BT] - 0.02 )
                endif
                call RemoveLocation(udg_BT_Point[1])
            endif
        else
        endif
        set udg_BT = udg_BT + 1
    endloop
endfunction

//===========================================================================
private function onInit takes nothing returns nothing
    set gg_trg_Bear_Trap_Loop = CreateTrigger(  )
    call DisableTrigger( gg_trg_Bear_Trap_Loop )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Bear_Trap_Loop, 0.02 )
    call TriggerAddAction( gg_trg_Bear_Trap_Loop, function Trig_Bear_Trap_Loop_Actions )
endfunction

endscope

TRIED CHANGING
JASS:
 local trigger
to
JASS:
 set
didn't work


EXAMPLE OF A WORKING SPELL:



Globals:
JASS:
    location                udg_Temp_Point

CustomTrigger.j
JASS:
    call InitTrig_gg_trg_heal_Copy_Copy(  )

UnknownFire
JASS:
     scope UnknownFire initializer onInit 
     
private function Trig_heal_Copy_Copy_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A0CN' ) ) then
        return false
    endif
    return true
endfunction

private function Trig_heal_Copy_Copy_Actions takes nothing returns nothing
    set udg_Temp_Point = GetUnitLoc(GetTriggerUnit())
    call CreateNUnitsAtLoc( 1, 'H03M', GetOwningPlayer(GetTriggerUnit()), udg_Temp_Point, bj_UNIT_FACING )
    call UnitAddAbilityBJ( 'AHfs', GetLastCreatedUnit() )
    call IssuePointOrderLocBJ( GetLastCreatedUnit(), "flamestrike", GetUnitLoc(GetSpellTargetUnit()) )
    call UnitApplyTimedLifeBJ( 2.00, 'BTLF', GetLastCreatedUnit() )
    call RemoveLocation(udg_Temp_Point)
endfunction

//===========================================================================
private function onInit takes nothing returns nothing
    local trigger gg_trg_heal_Copy_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_heal_Copy_Copy, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_heal_Copy_Copy, Condition( function Trig_heal_Copy_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_heal_Copy_Copy, function Trig_heal_Copy_Copy_Actions )
endfunction

endscope


I think I posted pretty much everything that could clear some things for you guys.....

How can I make this spell work/Enabling other trigger
 
Level 3
Joined
Mar 1, 2015
Messages
53
Tried doing librarys instead of scopes, setting globals inside spell, private into public.
I am out of ideas, just stuck... I need someone to guide me in the right direction.
 
What is the your concrete question? I have problems to understand your problem. It just does not compile?
The code is very unreadable at it's current state because it still has all this typical signs of a just converted GUI trigger.

For now it might help if you prepare a short demo map which includes only your bugged spell,
so we can easier can understand what's going on, because as said it's a bit confusing at the moment.
 
Level 3
Joined
Mar 1, 2015
Messages
53
I want BearTrap trigger to enable BearTrapLoop trigger.
Spell works fine in GUI, jass gives no errors but the spell doesn't work.
 
Level 3
Joined
Mar 1, 2015
Messages
53
there's the spell in GUI http://www.speedyshare.com/K8zfh/test-hive.w3x
Can you show me how to make them a working jass spell with scopes etc?

globals:
integer array udg_BT_Level
real array udg_BT_Interval
real array udg_BT_IntervalCheck
real array udg_BT_Damage
real array udg_BT_Duration
unit array udg_BT_Hero
unit array udg_BT_Target
unit array udg_BT_Trap
boolean array udg_BT_On
boolean array udg_BT_Closed
location array udg_BT_TargetPoint
location array udg_BT_Point
integer udg_BT_Times
integer udg_BT_Skip
integer udg_BT
group udg_BT_Group
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
I would recommend you take JASS tutorials before trying this. Once you understand the language and how it works it should be easy to do what you are after. The problem I see currently is that you are not sure how the language works so are trying illogical things which cause syntax errors.

Instead of starting with something already done and porting it with no clue how, try working from the ground up and learning as you go along. This is how I learnt JASS and it ended up invaluable when I went on to study Computer Science later on. Asking how to do every little thing all the time is not productive both with respect to what you want done and with regard to those who have to help you.

JASSHelper comes with a reasonably well written user manual in English (in fact the manual is likely better written that the program itself, kind of amazing). I would advise reading that to learn about all the language features that are not part of native JASS.
 
Status
Not open for further replies.
Top