1. Are you planning to upload your awesome map to Hive? Please review the rules here.
    Dismiss Notice
  2. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  4. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Trigger Viewer

Pong v1.1.w3x
Variables
Initialization
Init
Reset
Leaderboard
Constant Motion!
Initialization
Up
UpEnd
Down
DownEnd
LeftMoveDown
LeftMoveUp
RightMoveDown
RightMoveUp
Ball Movement
Scoring
ScoreLeft
ScoreRight
Abilities
NetCast
WrathCast
GazeCast
FlightCast
QueryCast
LeftAnswer
RightAnswer
ShivaCast
SpireCast
DeceptionCast
//TESH.scrollpos=0
//TESH.alwaysfold=0
function AngleCalc takes string side returns real
local integer r = GetRandomInt(1,2)
if side == "left" then
return GetRandomReal(45, 135) + 90
else
return GetRandomReal(225, 315) + 90
endif
endfunction
Name Type Is Array Initial Value
Angle real No
AnswerLeft string No
AnswerRight string No
Ball unit No
FlightCheck boolean No true
Leaderboard leaderboard No
LeftAccel real No 30.00
LeftAnscore integer No
LeftBlock unit No
LeftCenter unit No
LeftCopy unit No
LeftMod real No
LeftNet unit No
LeftScore integer No
Mark unit No
MotionObjects group No
RightAccel real No 30.00
RightAnscore integer No
RightBlock unit No
RightCenter unit No
RightCopy unit No
RightMod real No
RightNet unit No
RightScore integer No
Speed real No 30.00
SpellGain abilcode Yes
SPELL NAMES TO MAKE:
[S]pire Of Hades
Loki's [D]eception
//TESH.scrollpos=3
//TESH.alwaysfold=0
function Trig_Init_Actions takes nothing returns nothing
call DisableTrigger(gg_trg_Ball_Movement)
set udg_Ball = CreateUnit(Player(13), 'h002', 0,0, 270)
    call CreateFogModifierRectBJ( true, Player(0), FOG_OF_WAR_VISIBLE, GetPlayableMapRect() )
    call CreateFogModifierRectBJ( true, Player(1), FOG_OF_WAR_VISIBLE, GetPlayableMapRect() )
    call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_TARGET_DISTANCE, 3700.00, 0 )
    call SetCameraFieldForPlayer( Player(1), CAMERA_FIELD_TARGET_DISTANCE, 3700.00, 0 )
    call SetCameraFieldForPlayer( Player(1), CAMERA_FIELD_ANGLE_OF_ATTACK, -90.00, 0 )
    call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_ANGLE_OF_ATTACK, -90.00, 0 )
    call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_FIELD_OF_VIEW, 6000.00, 0 )
    call SetCameraFieldForPlayer( Player(1), CAMERA_FIELD_FIELD_OF_VIEW, 6000.00, 0 )
    call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_FARZ, 6000.00, 0 )
    call SetCameraFieldForPlayer( Player(1), CAMERA_FIELD_FARZ, 6000.00, 0 )
    call SetCameraTargetControllerNoZForPlayer( Player(0), gg_unit_h000_0001, 0, 0, false )
    call SetCameraTargetControllerNoZForPlayer( Player(1), gg_unit_h000_0001, 0, 0, false )
call CreateUnit(Player(0), 'h001', -2000, 200, 270)
call CreateUnit(Player(1), 'h001', 2000, 200, 270)
set udg_LeftCenter = CreateUnit(Player(0), 'h001', -2000, 0, 270)
set udg_RightCenter = CreateUnit(Player(1), 'h001', 2000, 0, 270)
call CreateUnit(Player(0), 'h001', -2000, -200, 270)
call CreateUnit(Player(1), 'h001', 2000, -200, 270)
endfunction

//===========================================================================
function InitTrig_Init takes nothing returns nothing
    set gg_trg_Init = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Init, function Trig_Init_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Reset_Actions takes nothing returns nothing
local player p = GetTriggerPlayer()
local boolean go = false
if p == Player(0) and udg_LeftAnscore == 0 then
set go = true
elseif p == Player(1) and udg_RightAnscore == 0 then
set go = true
endif
if go == true then
call SetCameraFieldForPlayer( p, CAMERA_FIELD_TARGET_DISTANCE, 3700.00, 0 )
call SetCameraFieldForPlayer( p, CAMERA_FIELD_ANGLE_OF_ATTACK, -90.00, 0 )
call SetCameraFieldForPlayer( p, CAMERA_FIELD_FIELD_OF_VIEW, 6000.00, 0 )
call SetCameraFieldForPlayer( p, CAMERA_FIELD_FARZ, 6000.00, 0 )
call SetCameraTargetControllerNoZForPlayer( p, gg_unit_h000_0001, 0, 0, false )
call SelectUnitForPlayerSingle( gg_unit_h003_0003, Player(0) )
call SelectUnitForPlayerSingle( gg_unit_h003_0005, Player(1) )
endif
set p = null
endfunction

//===========================================================================
function InitTrig_Reset takes nothing returns nothing
    set gg_trg_Reset = CreateTrigger(  )
    call TriggerRegisterPlayerEventEndCinematic( gg_trg_Reset, Player(0) )
    call TriggerRegisterPlayerEventEndCinematic( gg_trg_Reset, Player(1) )
    call TriggerAddAction( gg_trg_Reset, function Trig_Reset_Actions )
endfunction

 
Leaderboard
  Events
    Time - Elapsed game time is 1.00 seconds
  Conditions
  Actions
    Leaderboard - Create a leaderboard for (All players) titled Ultra Pong
    Leaderboard - Show (Last created leaderboard)
    Leaderboard - Add Player 1 (Red) to (Last created leaderboard) with label (Name of Player 1 (Red)) and value 0
    Leaderboard - Add Player 2 (Blue) to (Last created leaderboard) with label (Name of Player 2 (Blue)) and value 0
//TESH.scrollpos=12
//TESH.alwaysfold=0
function Trig_Initialization_Actions takes nothing returns nothing
    set udg_SpellGain[1] = 'A004'
    set udg_SpellGain[2] = 'A007'
    set udg_SpellGain[3] = 'A003'
    set udg_SpellGain[4] = 'A002'
    set udg_SpellGain[5] = 'A005'
    set udg_SpellGain[6] = 'A006'
    set udg_SpellGain[7] = 'A001'
    call DisableTrigger( GetTriggeringTrigger() )
    call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "TRIGSTR_052" )
    call TriggerSleepAction( 5.00 )
    call DisplayTimedTextToForce( GetPlayersAll(), 1.50, "TRIGSTR_053" )
    call TriggerSleepAction( 1.00 )
    call DisplayTimedTextToForce( GetPlayersAll(), 1.50, "TRIGSTR_054" )
    call TriggerSleepAction( 1.00 )
    call DisplayTimedTextToForce( GetPlayersAll(), 1.50, "TRIGSTR_055" )
    call TriggerSleepAction( 1.00 )
    set udg_Angle = GetRandomReal(1.00, 360.00)
    set udg_Angle = 150.00
    call EnableTrigger( gg_trg_Ball_Movement )
    call SelectUnitForPlayerSingle( gg_unit_h003_0003, Player(0) )
    call SelectUnitForPlayerSingle( gg_unit_h003_0005, Player(1) )
    set udg_Mark = CreateUnit(Player(13), 'h005', GetRandomReal(-1400,1400),GetRandomReal(-1350,1350),0)
endfunction

//===========================================================================
function InitTrig_Initialization takes nothing returns nothing
    set gg_trg_Initialization = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Initialization, function Trig_Initialization_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Up_Actions takes nothing returns nothing
    if GetTriggerPlayer() == Player(0) then
        call DisableTrigger(gg_trg_LeftMoveDown)
        call EnableTrigger(gg_trg_LeftMoveUp)
    else
        call EnableTrigger(gg_trg_RightMoveUp)
        call DisableTrigger(gg_trg_RightMoveDown)
    endif
endfunction

//===========================================================================
function InitTrig_Up takes nothing returns nothing
    set gg_trg_Up = CreateTrigger(  )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_Up, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_Up, Player(1), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
    call TriggerAddAction( gg_trg_Up, function Trig_Up_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_UpEnd_Actions takes nothing returns nothing
if GetTriggerPlayer() == Player(0)  then
call DisableTrigger(gg_trg_LeftMoveUp)
else
call DisableTrigger(gg_trg_RightMoveUp)
endif
endfunction

//===========================================================================
function InitTrig_UpEnd takes nothing returns nothing
    set gg_trg_UpEnd = CreateTrigger(  )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_UpEnd, Player(0), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_UP )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_UpEnd, Player(1), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_UP )
    call TriggerAddAction( gg_trg_UpEnd, function Trig_UpEnd_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Down_Actions takes nothing returns nothing
    if GetTriggerPlayer() == Player(0) then
        call DisableTrigger(gg_trg_LeftMoveUp)
        call EnableTrigger(gg_trg_LeftMoveDown)
    else
        call EnableTrigger(gg_trg_RightMoveDown)
        call DisableTrigger(gg_trg_RightMoveUp)
    endif
endfunction

//===========================================================================
function InitTrig_Down takes nothing returns nothing
    set gg_trg_Down = CreateTrigger(  )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_Down, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_Down, Player(1), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
    call TriggerAddAction( gg_trg_Down, function Trig_Down_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_DownEnd_Actions takes nothing returns nothing
if GetTriggerPlayer() == Player(0)  then
call DisableTrigger(gg_trg_LeftMoveDown)
else
call DisableTrigger(gg_trg_RightMoveDown)
endif
endfunction


//===========================================================================
function InitTrig_DownEnd takes nothing returns nothing
    set gg_trg_DownEnd = CreateTrigger(  )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_DownEnd, Player(0), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_DOWN )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_DownEnd, Player(1), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_DOWN )
    call TriggerAddAction( gg_trg_DownEnd, function Trig_DownEnd_Actions )
endfunction

 
//TESH.scrollpos=23
//TESH.alwaysfold=0
function Check1 takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == 'h001'
endfunction
function Trig_LeftMoveDown_Actions takes nothing returns nothing
local group left = CreateGroup()
local unit u
local real y
local boolean spire = true
if udg_LeftBlock != null then
set y = GetUnitY(udg_LeftBlock)
set spire = y+130 < udg_LeftMod - 300 or y-99 > udg_LeftMod + 300
endif
if udg_LeftMod > -1550 and spire == true then
call GroupEnumUnitsOfPlayer(left, Player(0), Condition(function Check1))

loop
        set u = FirstOfGroup(left)
        exitwhen u == null
        call SetUnitPosition(u, -2000, GetUnitY(u) - udg_LeftAccel)
        call GroupRemoveUnit(left, u)
    endloop
    set udg_LeftMod = GetUnitY(udg_LeftCenter)
call DestroyGroup(left)
set u = null
set left = null
endif
endfunction

//===========================================================================
function InitTrig_LeftMoveDown takes nothing returns nothing
    set gg_trg_LeftMoveDown = CreateTrigger(  )
    call DisableTrigger( gg_trg_LeftMoveDown )
    call TriggerRegisterTimerEventPeriodic( gg_trg_LeftMoveDown, 0.02 )
    call TriggerAddAction( gg_trg_LeftMoveDown, function Trig_LeftMoveDown_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Check2 takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == 'h001'
endfunction
function Trig_LeftMoveUp_Actions takes nothing returns nothing
local group left = CreateGroup()
local unit u
local real y
local boolean spire = true
if udg_LeftBlock != null then
set y = GetUnitY(udg_LeftBlock)
set spire = y-130 > udg_LeftMod + 300 or y+99 < udg_LeftMod - 300
endif
if udg_LeftMod < 1550 and spire == true then
call GroupEnumUnitsOfPlayer(left, Player(0), Condition(function Check2))
loop
        set u = FirstOfGroup(left)
        exitwhen u == null
        call SetUnitPosition(u, -2000, GetUnitY(u) + udg_LeftAccel)
        call GroupRemoveUnit(left, u)
endloop
    set udg_LeftMod = GetUnitY(udg_LeftCenter)
call DestroyGroup(left)
set u = null
set left = null
endif
endfunction

//===========================================================================
function InitTrig_LeftMoveUp takes nothing returns nothing
    set gg_trg_LeftMoveUp = CreateTrigger(  )
    call DisableTrigger( gg_trg_LeftMoveUp )
    call TriggerRegisterTimerEventPeriodic( gg_trg_LeftMoveUp, 0.02 )
    call TriggerAddAction( gg_trg_LeftMoveUp, function Trig_LeftMoveUp_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Check3 takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == 'h001'
endfunction
function Trig_RightMoveDown_Actions takes nothing returns nothing
local group right = CreateGroup()
local unit u
local real y
local boolean spire = true
if udg_RightBlock != null then
set y = GetUnitY(udg_RightBlock)
set spire = y+130 < udg_RightMod - 300 or y-99 > udg_RightMod + 300
endif
if udg_RightMod > -1550 and spire == true then
call GroupEnumUnitsOfPlayer(right, Player(1), Condition(function Check3))
    loop
        set u= FirstOfGroup(right)
        exitwhen u == null
        call SetUnitPosition(u, 2000, GetUnitY(u) - udg_RightAccel)
        call GroupRemoveUnit(right, u)
    endloop
    set udg_RightMod = GetUnitY(udg_RightCenter)
call DestroyGroup(right)
set u = null
set right = null
endif
endfunction

//===========================================================================
function InitTrig_RightMoveDown takes nothing returns nothing
    set gg_trg_RightMoveDown = CreateTrigger(  )
    call DisableTrigger( gg_trg_RightMoveDown )
    call TriggerRegisterTimerEventPeriodic( gg_trg_RightMoveDown, 0.02 )
    call TriggerAddAction( gg_trg_RightMoveDown, function Trig_RightMoveDown_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Check4 takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == 'h001'
endfunction
function Trig_RightMoveUp_Actions takes nothing returns nothing
local group right = CreateGroup()
local unit u
local real y
local boolean spire = true
if udg_RightBlock != null then
set y = GetUnitY(udg_RightBlock)
set spire = y-130 > udg_RightMod + 300 or y+99 < udg_RightMod - 300
endif
if udg_RightMod < 1550 and spire == true then
call GroupEnumUnitsOfPlayer(right, Player(1), Condition(function Check4))
loop
        set u = FirstOfGroup(right)
        exitwhen u == null
        call SetUnitPosition(u, 2000, GetUnitY(u) + udg_RightAccel)
        call GroupRemoveUnit(right, u)
    endloop
    set udg_RightMod = GetUnitY(udg_RightCenter)
call DestroyGroup(right)
set u = null
set right = null  
endif  
endfunction

//===========================================================================
function InitTrig_RightMoveUp takes nothing returns nothing
    set gg_trg_RightMoveUp = CreateTrigger(  )
    call DisableTrigger( gg_trg_RightMoveUp )
    call TriggerRegisterTimerEventPeriodic( gg_trg_RightMoveUp, 0.02 )
    call TriggerAddAction( gg_trg_RightMoveUp, function Trig_RightMoveUp_Actions )
endfunction

 
//TESH.scrollpos=39
//TESH.alwaysfold=0
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local unit u = udg_Ball //PONG BALL VARS
local real angle = udg_Angle
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real x2 = x+ udg_Speed* Cos(angle*(3.14/180))
local real y2 = y+ udg_Speed* Sin(angle*(3.14/180))
local real dif
local boolean left = x2 > -2000 and x2 < -1950 and y2 < GetUnitY(udg_LeftCenter)+300 and y2 > GetUnitY(udg_LeftCenter)-300
local boolean right = x2 < 2000 and x2 > 1950 and y2 < GetUnitY(udg_RightCenter)+300 and y2 > GetUnitY(udg_RightCenter)-300
local real level = GetLocationZ(Location(x2,y2))
local integer abil = udg_SpellGain[GetRandomInt(1, 7)]
// =====================PONG BALL MOVEMENT========================//
if level == 0 and left == false and right == false then
call SetUnitPosition(u,x2,y2)

            elseif level != 0 then
                    set udg_Angle = 360-angle
            elseif udg_FlightCheck == false then
            call SetUnitPosition(u,x2,y2)
            elseif left == true or right == true then
                      if angle <= 180 then
                            set udg_Angle = 180 - angle
                                else
                            set udg_Angle = 540 - angle
                    endif
endif
            //=========AngleDistortion==========//
            if left == true then
            set dif = y2 - udg_LeftMod
                if dif > 100 then
                    set udg_Angle = udg_Angle + ((dif/200)*25)
                    elseif dif < -100 then
                    set udg_Angle = udg_Angle + ((dif/200)*25)
                endif
            elseif right == true then
            set dif = y2 - udg_RightMod
                if dif > 100 then
                    set udg_Angle = udg_Angle - ((dif/200)*25)
                    elseif dif < -100 then
                    set udg_Angle = udg_Angle - ((dif/200)*25)
                endif
            endif
//===========NET MOVEMENT
call SetUnitPosition(udg_LeftNet, GetUnitX(udg_LeftNet) + 40, GetUnitY(udg_LeftNet))
set x = GetUnitX(udg_LeftNet) - GetUnitX(udg_Mark)
set y = GetUnitY(udg_LeftNet) - GetUnitY(udg_Mark)
if SquareRoot(x * x + y * y) < 200 and udg_LeftNet != null then
    call RemoveUnit(udg_LeftNet)
    set udg_LeftNet = null
    call SetUnitPosition(udg_Mark,GetRandomReal(-1400,1400),GetRandomReal(-1350,1350))
        loop
        exitwhen GetUnitAbilityLevel(gg_unit_h003_0003,abil) == 0
        set abil = udg_SpellGain[GetRandomInt(1, 7)]
        endloop
    call UnitAddAbility(gg_unit_h003_0003,abil)
endif
call SetUnitPosition(udg_RightNet, GetUnitX(udg_RightNet) - 40, GetUnitY(udg_RightNet))
set x = GetUnitX(udg_RightNet) - GetUnitX(udg_Mark)
set y = GetUnitY(udg_RightNet) - GetUnitY(udg_Mark)
if SquareRoot(x * x + y * y) < 200 and udg_RightNet != null then
    call RemoveUnit(udg_RightNet)
    set udg_RightNet = null
    call SetUnitPosition(udg_Mark,GetRandomReal(-1400,1400),GetRandomReal(-1350,1350))
        loop
        exitwhen GetUnitAbilityLevel(gg_unit_h003_0005,abil) == 0
        set abil = udg_SpellGain[GetRandomInt(1, 7)]
        endloop
    call UnitAddAbility(gg_unit_h003_0005,abil)
endif
//===========COPY MOVEMENT
if udg_LeftCopy != null then
set u = udg_LeftCopy
set angle = I2R(GetUnitUserData(u))
set x = GetUnitX(u)+ udg_Speed* Cos(angle*(3.14/180))
set y = GetUnitY(u)+ udg_Speed* Sin(angle*(3.14/180))
    if GetLocationZ(Location(x,y)) > 0 then
    call RemoveUnit(u)
    set udg_LeftCopy = null
    else
    call SetUnitPosition(u,x,y)
    endif
endif
if udg_RightCopy != null then
set u = udg_RightCopy
set angle = I2R(GetUnitUserData(u))
set x = GetUnitX(u)+ udg_Speed* Cos(angle*(3.14/180))
set y = GetUnitY(u)+ udg_Speed* Sin(angle*(3.14/180))
    if GetLocationZ(Location(x,y)) > 0 then
    call RemoveUnit(u)
    set udg_RightCopy = null
    else
    call SetUnitPosition(u,x,y)
    endif
endif
set u = null
endfunction

//===========================================================================
function InitTrig_Ball_Movement takes nothing returns nothing
    set gg_trg_Ball_Movement = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Ball_Movement, 0.02 )
    call TriggerAddAction( gg_trg_Ball_Movement, function Trig_Untitled_Trigger_001_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_ScoreLeft_Actions takes nothing returns nothing
if GetTriggerUnit() == udg_Ball then
    set udg_RightScore = ( udg_RightScore + 1 )
    call LeaderboardSetPlayerItemValueBJ( Player(1), GetLastCreatedLeaderboard(), udg_RightScore )
    call SetUnitPositionLoc( GetTriggerUnit(), GetRectCenter(GetPlayableMapRect()) )
    set udg_Angle = AngleCalc("right")
elseif GetUnitTypeId(GetTriggerUnit()) == 'h004' then
call RemoveUnit(GetTriggerUnit())
endif
if GetTriggerUnit() == udg_RightNet then
set udg_RightNet = null
endif
set udg_Speed = 30
endfunction

//===========================================================================
function InitTrig_ScoreLeft takes nothing returns nothing
    set gg_trg_ScoreLeft = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_ScoreLeft, gg_rct_LeftGoal )
    call TriggerAddAction( gg_trg_ScoreLeft, function Trig_ScoreLeft_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_ScoreRight_Actions takes nothing returns nothing
if GetTriggerUnit() == udg_Ball then
    set udg_LeftScore = ( udg_LeftScore + 1 )
    call LeaderboardSetPlayerItemValueBJ( Player(0), GetLastCreatedLeaderboard(), udg_LeftScore )
    call SetUnitPositionLoc( GetTriggerUnit(), GetRectCenter(GetPlayableMapRect()) )
    set udg_Angle = AngleCalc("left")
elseif GetUnitTypeId(GetTriggerUnit()) == 'h004' then
call RemoveUnit(GetTriggerUnit())
endif
if GetTriggerUnit() == udg_LeftNet then
set udg_LeftNet = null
endif
set udg_Speed = 30
endfunction

//===========================================================================
function InitTrig_ScoreRight takes nothing returns nothing
    set gg_trg_ScoreRight = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_ScoreRight, gg_rct_RightGoal )
    call TriggerAddAction( gg_trg_ScoreRight, function Trig_ScoreRight_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_NetCast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function Trig_NetCast_Actions takes nothing returns nothing
local player p = GetOwningPlayer(GetTriggerUnit())
if p == Player(0) then
set udg_LeftNet = CreateUnit(p, 'h004', -2000,udg_LeftMod,90)
else
set udg_RightNet = CreateUnit(p, 'h004', 2000,udg_RightMod,90)
endif
endfunction

//===========================================================================
function InitTrig_NetCast takes nothing returns nothing
    set gg_trg_NetCast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_NetCast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_NetCast, Condition( function Trig_NetCast_Conditions ) )
    call TriggerAddAction( gg_trg_NetCast, function Trig_NetCast_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_WrathCast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A001'
endfunction

function SlowSpeed takes nothing returns nothing
local timer t = GetExpiredTimer()
if udg_Speed > 30 then
set udg_Speed = udg_Speed - 3
else
call PauseTimer(t)
call DestroyTimer(t)
set t = null
endif
endfunction

function Trig_WrathCast_Actions takes nothing returns nothing
local timer t = CreateTimer()
local real x = GetUnitX(udg_Ball)
local real y = GetUnitY(udg_Ball)
call UnitRemoveAbility(GetTriggerUnit(), GetSpellAbilityId())
set udg_Angle = GetRandomReal(1, 359)
set udg_Speed = 90
call TimerStart(t, .05, true, function SlowSpeed)
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Avatar\\AvatarCaster.mdl",x,y))
endfunction

//===========================================================================
function InitTrig_WrathCast takes nothing returns nothing
    set gg_trg_WrathCast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_WrathCast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_WrathCast, Condition( function Trig_WrathCast_Conditions ) )
    call TriggerAddAction( gg_trg_WrathCast, function Trig_WrathCast_Actions )
endfunction

 
//TESH.scrollpos=2
//TESH.alwaysfold=0
function Trig_GazeCast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A002'
endfunction

function Trig_GazeCast_Actions takes nothing returns nothing
local integer counter = 0
local effect array s
call UnitRemoveAbility(GetTriggerUnit(), GetSpellAbilityId())
call SetUnitVertexColor(udg_Ball,0,0,255,50)
loop
exitwhen counter == 50
set counter = counter + 1
set s[counter] = AddSpecialEffect("Abilities\\Spells\\Human\\CloudOfFog\\CloudOfFog.mdl", GetRandomReal(-2000.,2000.), GetRandomReal(-1700.,1700.))
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveDamage.mdl", GetRandomReal(-2000.,2000.), GetRandomReal(-1700.,1700.)))
endloop
call TriggerSleepAction(3.)
set counter = 0
loop
exitwhen counter == 50
set counter = counter + 1
call DestroyEffect(s[counter])
set s[counter] = null
endloop
call TriggerSleepAction(2.)
call SetUnitVertexColor(udg_Ball,255,255,255,255)
endfunction

//===========================================================================
function InitTrig_GazeCast takes nothing returns nothing
    set gg_trg_GazeCast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_GazeCast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_GazeCast, Condition( function Trig_GazeCast_Conditions ) )
    call TriggerAddAction( gg_trg_GazeCast, function Trig_GazeCast_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_FlightCast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A004'
endfunction

function Trig_FlightCast_Actions takes nothing returns nothing
local effect s = AddSpecialEffectTarget("Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl",udg_Ball,"overhead")
call UnitRemoveAbility(GetTriggerUnit(), GetSpellAbilityId())
set udg_FlightCheck = false
call TriggerSleepAction(1.5)
set udg_FlightCheck = true
call DestroyEffect(s)
set s = null
endfunction

//===========================================================================
function InitTrig_FlightCast takes nothing returns nothing
    set gg_trg_FlightCast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_FlightCast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_FlightCast, Condition( function Trig_FlightCast_Conditions ) )
    call TriggerAddAction( gg_trg_FlightCast, function Trig_FlightCast_Actions )
endfunction

 
//TESH.scrollpos=3
//TESH.alwaysfold=0
function Trig_QueryCast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A003'
endfunction

function Trig_QueryCast_Actions takes nothing returns nothing
local integer n1 = GetRandomInt(1,10)
local integer n2 = GetRandomInt(1,10)
local integer n3 = GetRandomInt(1,10)
local integer ans = (n1*n2)+n3
local player p
call UnitRemoveAbility(GetTriggerUnit(), GetSpellAbilityId())
if GetTriggerPlayer() == Player(0) then
set p = Player(1)
set udg_RightAnscore = 1
call EnableTrigger(gg_trg_RightAnswer)
set udg_AnswerRight = I2S(ans)
else
set p = Player(0)
set udg_LeftAnscore = 1
call EnableTrigger(gg_trg_LeftAnswer)
set udg_AnswerLeft = I2S(ans)
endif
call SetCameraFieldForPlayer( p, CAMERA_FIELD_TARGET_DISTANCE, -1000, 2 )
call SetCameraFieldForPlayer( p, CAMERA_FIELD_ANGLE_OF_ATTACK, 90.00, 2 )
call DisplayTimedTextToPlayer(p,0,0,8,"|CFFECDC89What is |CFFFFAA00"+I2S(n1)+"|CFFECDC89 times |CFFFFAA00"+I2S(n2)+"|CFFECDC89 plus |CFFFFAA00"+I2S(n3)+"|CFFECDC89?")
set p = null
endfunction

//===========================================================================
function InitTrig_QueryCast takes nothing returns nothing
    set gg_trg_QueryCast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_QueryCast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_QueryCast, Condition( function Trig_QueryCast_Conditions ) )
    call TriggerAddAction( gg_trg_QueryCast, function Trig_QueryCast_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_LeftAnswer_Actions takes nothing returns nothing
local string s = GetEventPlayerChatString()
local player p = Player(0)
if s == udg_AnswerLeft then
set udg_LeftAnscore = 0
call SetCameraFieldForPlayer( p, CAMERA_FIELD_TARGET_DISTANCE, 3700, 0 )
call SetCameraFieldForPlayer( p, CAMERA_FIELD_ANGLE_OF_ATTACK, -90.00, 0 )
call DisplayTimedTextToPlayer(p,0,0,5,"|CFFFFF200C|CFFFFE400o|CFFFFD500r|CFFFFC600r|CFFFFB700e|CFFFFA800c|CFFFF9900t|CFFFF8B00!")
call DisableTrigger(GetTriggeringTrigger())
else
set udg_LeftAnscore = udg_LeftAnscore + 1
    if udg_LeftAnscore >= 4 then
    call DisableTrigger(GetTriggeringTrigger())
    call DisplayTimedTextToPlayer(p,0,0,5,"|CFFE2E3E3T|CFFDDDEDEh|CFFD7D8D8o|CFFD1D2D2u |CFFC5C6C6a|CFFC0C0C0r|CFFBABABAt |CFFAEAEAEn|CFFA8A8A8o|CFFADADADt |CFFB9B9B9w|CFFBFBFBFo|CFFC5C5C5r|CFFCACBCBt|CFFD0D1D1h|CFFD6D7D7y|CFFDCDDDD!")
    set udg_LeftAnscore = 0
    call SetCameraFieldForPlayer( p, CAMERA_FIELD_TARGET_DISTANCE, 3700, 3 )
    call SetCameraFieldForPlayer( p, CAMERA_FIELD_ANGLE_OF_ATTACK, -90.00, 3 )
    else
    call DisplayTimedTextToPlayer(p,0,0,4,"|CFFED1C24I|CFFD71F1Dn|CFFC02316c|CFFA9260Fo|CFF922A08r|CFF7B2E00r|CFF912B07e|CFFA8270Ec|CFFBF2415t|CFFD6201C.")
    endif
endif
set s = null
set p = null
endfunction

//===========================================================================
function InitTrig_LeftAnswer takes nothing returns nothing
    set gg_trg_LeftAnswer = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_LeftAnswer, Player(0), "", true )
    call TriggerAddAction( gg_trg_LeftAnswer, function Trig_LeftAnswer_Actions )
endfunction

 
//TESH.scrollpos=2
//TESH.alwaysfold=0
function Trig_RightAnswer_Actions takes nothing returns nothing
local string s = GetEventPlayerChatString()
local player p = Player(1)
if s == udg_AnswerRight then
set udg_RightAnscore = 0
call SetCameraFieldForPlayer( p, CAMERA_FIELD_TARGET_DISTANCE, 3700, 0 )
call SetCameraFieldForPlayer( p, CAMERA_FIELD_ANGLE_OF_ATTACK, -90.00, 0 )
call DisplayTimedTextToPlayer(p,0,0,5,"|CFFFFF200C|CFFFFE400o|CFFFFD500r|CFFFFC600r|CFFFFB700e|CFFFFA800c|CFFFF9900t|CFFFF8B00!")
call DisableTrigger(GetTriggeringTrigger())
else
set udg_RightAnscore = udg_RightAnscore + 1
    if udg_RightAnscore >= 4 then
    call DisableTrigger(GetTriggeringTrigger())
    call DisplayTimedTextToPlayer(p,0,0,5,"|CFFE2E3E3T|CFFDDDEDEh|CFFD7D8D8o|CFFD1D2D2u |CFFC5C6C6a|CFFC0C0C0r|CFFBABABAt |CFFAEAEAEn|CFFA8A8A8o|CFFADADADt |CFFB9B9B9w|CFFBFBFBFo|CFFC5C5C5r|CFFCACBCBt|CFFD0D1D1h|CFFD6D7D7y|CFFDCDDDD!")
    set udg_RightAnscore = 0
    call SetCameraFieldForPlayer( p, CAMERA_FIELD_TARGET_DISTANCE, 3700, 3 )
    call SetCameraFieldForPlayer( p, CAMERA_FIELD_ANGLE_OF_ATTACK, -90.00, 3 )
    else
    call DisplayTimedTextToPlayer(p,0,0,4,"|CFFED1C24I|CFFD71F1Dn|CFFC02316c|CFFA9260Fo|CFF922A08r|CFF7B2E00r|CFF912B07e|CFFA8270Ec|CFFBF2415t|CFFD6201C.")
    endif
endif
set s = null
set p = null
endfunction

//===========================================================================
function InitTrig_RightAnswer takes nothing returns nothing
    set gg_trg_RightAnswer = CreateTrigger(  )
    call DisableTrigger( gg_trg_RightAnswer )
    call TriggerRegisterPlayerChatEvent( gg_trg_RightAnswer, Player(1), "", true )
    call TriggerAddAction( gg_trg_RightAnswer, function Trig_RightAnswer_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_ShivaCast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A005'
endfunction
function Trig_ShivaCast_Actions takes nothing returns nothing
local unit u
local real x
local real y
local real x2
local real y2
local real angle = 0
call UnitRemoveAbility(GetTriggerUnit(), GetSpellAbilityId())
if GetTriggerPlayer() == Player(0) then
    set u = udg_RightCenter
    set udg_RightAccel = 15
    else
    set u = udg_LeftCenter
    set udg_LeftAccel = 15
endif
set x = GetUnitX(u)
set y = GetUnitY(u)
loop
exitwhen angle == 360
set angle = angle + 36
set x2 = x+ 100*Cos(angle*(3.14/180))
set y2 = y+ 100*Sin(angle*(3.14/180))
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl",x2,y2))
set x2 = x+ 200*Cos(angle*(3.14/180))
set y2 = y+ 200*Sin(angle*(3.14/180))
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl",x2,y2))
endloop
call TriggerSleepAction(5.)
if u == udg_RightCenter then
set udg_RightAccel = 30
else
set udg_LeftAccel = 30
endif
set u = null
endfunction

//===========================================================================
function InitTrig_ShivaCast takes nothing returns nothing
    set gg_trg_ShivaCast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ShivaCast, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_ShivaCast, Condition( function Trig_ShivaCast_Conditions ) )
    call TriggerAddAction( gg_trg_ShivaCast, function Trig_ShivaCast_Actions )
endfunction

 
//TESH.scrollpos=1
//TESH.alwaysfold=0
function Trig_SpireCast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A006'
endfunction

function Trig_SpireCast_Actions takes nothing returns nothing
local player p
local real y = GetRandomReal(-1600,1600)
local unit u
call UnitRemoveAbility(GetTriggerUnit(), GetSpellAbilityId())
if GetTriggerPlayer() == Player(1) then
set p = Player(0)
loop
exitwhen y > udg_LeftMod+360 or y < udg_LeftMod-360
set y = GetRandomReal(-1600,1600)
endloop
set udg_LeftBlock = CreateUnit(Player(13), 'h006', -2000, y, 0)
set u = udg_LeftBlock
else
set p = Player(1)
loop
exitwhen y > udg_RightMod+360 or y < udg_RightMod-360
set y = GetRandomReal(-1600,1600)
endloop
set udg_RightBlock = CreateUnit(Player(13), 'h006', 2000, y, 180)
set u = udg_RightBlock
endif
call TriggerSleepAction(5.)
call RemoveUnit(u)
if p == Player(0) then
set udg_LeftBlock = null
else
set udg_RightBlock = null
endif
set p = null
set u = null
endfunction

//===========================================================================
function InitTrig_SpireCast takes nothing returns nothing
    set gg_trg_SpireCast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_SpireCast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_SpireCast, Condition( function Trig_SpireCast_Conditions ) )
    call TriggerAddAction( gg_trg_SpireCast, function Trig_SpireCast_Actions )
endfunction

 
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_DeceptionCast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A007'
endfunction
function Trig_DeceptionCast_Actions takes nothing returns nothing
local player p = GetTriggerPlayer()
local real x = GetUnitX(udg_Ball)
local real y = GetUnitY(udg_Ball)
local unit u
call UnitRemoveAbility(GetTriggerUnit(), GetSpellAbilityId())
if p == Player(0) then
    if udg_LeftCopy == null then
        set udg_LeftCopy = CreateUnit(Player(13), 'h002', x, y, 0)
        set u = udg_LeftCopy
    endif
else
    if udg_RightCopy == null then
        set udg_RightCopy = CreateUnit(Player(13), 'h002', x, y, 0)
        set u = udg_RightCopy
    endif
endif
if GetRandomInt(1,20) >= 10 then
    call SetUnitUserData(u, R2I(udg_Angle -23))
    set udg_Angle = udg_Angle + 23
    else
    call SetUnitUserData(u, R2I(udg_Angle +23))
    set udg_Angle = udg_Angle - 23
endif
set p = null
set u = null
endfunction

//===========================================================================
function InitTrig_DeceptionCast takes nothing returns nothing
    set gg_trg_DeceptionCast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_DeceptionCast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_DeceptionCast, Condition( function Trig_DeceptionCast_Conditions ) )
    call TriggerAddAction( gg_trg_DeceptionCast, function Trig_DeceptionCast_Actions )
endfunction