//TESH.scrollpos=0
//TESH.alwaysfold=0
native UnitAlive takes unit u returns boolean
Name | Type | is_array | initial_value |
Banner_Boolean | boolean | Yes | |
Banner_Caster | unit | Yes | |
Banner_Dummy | unit | Yes | |
Banner_MaxIndex | integer | No | |
colorEnd | string | No | |
DoNotAllowAFKTimer | boolean | No | |
LeaderBoard | leaderboard | No | |
playerColors | string | Yes | |
RGBColors1 | integer | Yes | |
RGBColors2 | integer | Yes | |
RGBColors3 | integer | Yes | |
subStr | string | No | |
TempBoolean | boolean | No | |
TempFloat | texttag | No | |
TempForce | force | No | |
TempGroup | group | No | |
TempInteger | integer | No | |
TempInteger2 | integer | No | |
TempInteger3 | integer | No | |
TempLoc | location | No | |
TempPlayer | player | No | |
TempPoint | location | No | |
TempPoint2 | location | No | |
TempReal | real | No | |
TempReal2 | real | No | |
TempReal3 | real | No | |
TempReal4 | real | No | |
tempString | string | No | |
TempString | string | No | |
TempUnit | unit | Yes | |
TempUnit2 | unit | No |
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_RGB_Colors_Setup_Actions takes nothing returns nothing
set udg_RGBColors1[0] = 255 // red
set udg_RGBColors2[0] = 3
set udg_RGBColors3[0] = 3
set udg_RGBColors1[1] = 0 // blue
set udg_RGBColors2[1] = 66
set udg_RGBColors3[1] = 255
set udg_RGBColors1[2] = 28 // teal
set udg_RGBColors2[2] = 230
set udg_RGBColors3[2] = 185
set udg_RGBColors1[3] = 84 // purp
set udg_RGBColors2[3] = 0
set udg_RGBColors3[3] = 129
set udg_RGBColors1[4] = 255 // yellow
set udg_RGBColors2[4] = 252
set udg_RGBColors3[4] = 1
set udg_RGBColors1[5] = 254 // orange
set udg_RGBColors2[5] = 186
set udg_RGBColors3[5] = 14
set udg_RGBColors1[6] = 32 // green
set udg_RGBColors2[6] = 192
set udg_RGBColors3[6] = 0
set udg_RGBColors1[7] = 229 // pink
set udg_RGBColors2[7] = 91
set udg_RGBColors3[7] = 176
set udg_RGBColors1[8] = 75 // gray
set udg_RGBColors2[8] = 90
set udg_RGBColors3[8] = 75
set udg_RGBColors1[9] = 75 // light blue
set udg_RGBColors2[9] = 175
set udg_RGBColors3[9] = 255
set udg_RGBColors1[10] = 0 // dark green
set udg_RGBColors2[10] = 40
set udg_RGBColors3[10] = 0
set udg_RGBColors1[11] = 139 // brown
set udg_RGBColors2[11] = 69
set udg_RGBColors3[11] = 19
endfunction
//===========================================================================
function InitTrig_RGB_Colors_Setup takes nothing returns nothing
set gg_trg_RGB_Colors_Setup = CreateTrigger( )
call TriggerAddAction( gg_trg_RGB_Colors_Setup, function Trig_RGB_Colors_Setup_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
integer array wins
leaderboard leaderBoard
endglobals
function LeaderBoardSetUp takes nothing returns nothing
local player p
local integer i = 0
set leaderBoard = CreateLeaderboard()
call LeaderboardSetLabel(leaderBoard, "Wins")
loop
exitwhen i > 11
set p = Player(i)
if IsPlaying(p) == true then
set wins[i] = 0
call PlayerSetLeaderboard(Player(i), leaderBoard)
call LeaderboardAddItem(leaderBoard, GetPlayerName(Player(i)), wins[i], Player(i))
call LeaderboardSetSizeByItemCount(leaderBoard, LeaderboardGetItemCount(leaderBoard))
endif
set i = i + 1
endloop
call LeaderboardDisplay(leaderBoard, true)
endfunction
//===========================================================================
function InitTrig_LeaderBoard_Setup takes nothing returns nothing
set gg_trg_LeaderBoard_Setup = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_LeaderBoard_Setup, .01 )
call TriggerAddAction( gg_trg_LeaderBoard_Setup, function LeaderBoardSetUp )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Claim_Conditions takes nothing returns boolean
if GetSpellAbilityId() == 'A000' then
return true
else
return false
endif
endfunction
function Claim_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local player p = Player(playerNumberOfWhoseTurn)
local integer i = unitIdForMarkers[playerNumberOfWhoseTurn]
local integer i2 = 0
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local unit u2 = CreateUnit(p, i, GetUnitX(u), GetUnitY(u), 270)
call UnitRemoveAbility(u2, 'Amov')
call UnitAddType(u2, UNIT_TYPE_PEON)
call GroupAddUnit(lastMove, u2)
call SetUnitX(u2, x)
call SetUnitY(u2, y)
call PauseUnit(u, true)
if GetLocalPlayer() == p then
call ClearSelection()
call SelectUnit(builders[GetPlayerId(p)], true)
endif
set extraTurn = 1
call Winner(p, u, u2, x, y)
call SetUnitAnimationByIndex(u, 1)
set p = null
set u = null
set u2 = null
endfunction
function InitTrig_Claim takes nothing returns nothing
local trigger myTrigger = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( myTrigger, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(myTrigger, Condition(function Claim_Conditions))
call TriggerAddAction( myTrigger, function Claim_Actions )
endfunction
//TESH.scrollpos=4
//TESH.alwaysfold=0
//Checks every 90 degrees if there is a structure to allow building, otherwise aborts building.
// Not sure exactly why it works even when the lines are not perfect i.e building one on the line of 2 others [][]
// See Pic.
globals
boolean isEncaps = false
endglobals
function BuildNewSquare_Conditions takes nothing returns boolean
local unit u = GetConstructingStructure()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local player p = GetOwningPlayer(u)
if AllowBuilding(x,y) == true then
call UnitRemoveAbility(u, 'Amov')
call SetUnitOwner(u, Player(PLAYER_NEUTRAL_PASSIVE), true)
call GroupAddUnit(lastMove, u)
call TurnClaimOn()
call TurnBuildOff(p)
set extraTurn = -1
set isEncaps = true
call DetectEncapsulation(p, x, y)
set isEncaps = false
call NextTurn()
else
call SimError(p, "Unable to build there, select a spot that connects along a side")
call KillUnit(u)
endif
set u = null
set p = null
return true
endfunction
function InitTrig_Build_New_Square takes nothing returns nothing
set gg_trg_Build_New_Square = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Build_New_Square, EVENT_PLAYER_UNIT_CONSTRUCT_START )
call TriggerAddCondition(gg_trg_Build_New_Square, Condition(function BuildNewSquare_Conditions))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Detection
function BuildingsOnly takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE)
endfunction
function IsSpotFilled takes real x, real y returns boolean
local boolean result = false
local group g = CreateGroup()
call GroupEnumUnitsInRange(g, x, y, 10., Condition(function BuildingsOnly))
set result = FirstOfGroup(g) != null
call DestroyGroup(g)
set g = null
return result
endfunction
function IsSpotSurrounded takes real x, real y returns boolean
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 4
if i == 0 then
set x2 = x
set y2 = y + grid
elseif i == 1 then
set x2 = x
set y2 = y - grid
elseif i == 2 then
set x2 = x + grid
set y2 = y
elseif i == 3 then
set x2 = x - grid
set y2 = y
endif
if not IsSpotFilled(x2, y2) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function AllowBuilding takes real x, real y returns boolean
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 4
if i == 0 then
set x2 = x
set y2 = y + grid
elseif i == 1 then
set x2 = x
set y2 = y - grid
elseif i == 2 then
set x2 = x + grid
set y2 = y
elseif i == 3 then
set x2 = x - grid
set y2 = y
endif
if IsSpotFilled(x2, y2) then
return true
endif
set i = i + 1
endloop
return false
endfunction
function DetectEncapsulation takes player pl, real x, real y returns nothing
local unit u
local integer i = 0
local real x2
local real y2
local real grid = 128.
loop
exitwhen i >= 4
if i == 0 then
set x2 = x
set y2 = y + grid
elseif i == 1 then
set x2 = x
set y2 = y - grid
elseif i == 2 then
set x2 = x + grid
set y2 = y
elseif i == 3 then
set x2 = x - grid
set y2 = y
endif
if IsSpotSurrounded(x2, y2) == true and IsSpotFilled(x2, y2)== false then
set u = CreateUnit(pl, 'h002', x2, y2, 270)
call SetUnitOwner(u, Player(PLAYER_NEUTRAL_PASSIVE), true)
call SetUnitAnimationByIndex(u, 1)
call SetUnitX(u, x2)
call SetUnitY(u, y2)
call IssueImmediateOrder(u, "channel")
endif
set i = i + 1
endloop
set u = null
endfunction
function DetectAllowBuilding takes real x, real y returns unit u
local real x2
local real y2
local unit u
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 4
if i == 0 then
set x2 = x
set y2 = y + grid
elseif i == 1 then
set x2 = x
set y2 = y - grid
elseif i == 2 then
set x2 = x + grid
set y2 = y
elseif i == 3 then
set x2 = x - grid
set y2 = y
endif
if IsSpotFilled(x2, y2) == false then
set u = CreateUnit(Player(playerNumberOfWhoseTurn), 'h00H', x2, y2, 270)
return u
endif
set i = i + 1
endloop
set u = null
return u
endfunction
endlibrary
//TESH.scrollpos=590
//TESH.alwaysfold=0
library WinDetection requires Turns, GF
function ClaimMarkersOnly takes nothing returns boolean // Outdated, was checking if own unit was ally lol.
return IsUnitType(GetFilterUnit(), UNIT_TYPE_SAPPER) and IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetFilterUnit() ))
endfunction
function IsSpotMarked takes player p, real x, real y, integer i returns boolean
local boolean result = false
local group g = CreateGroup()
local group g2 = CreateGroup()
local unit u
call GroupEnumUnitsInRange(g, x, y, 10., null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if IsUnitType(u, UNIT_TYPE_SAPPER) and IsUnitAlly(u, p) == true then
call GroupAddUnit(g2, u)
else
endif
call GroupRemoveUnit(g, u)
endloop
set result = FirstOfGroup(g2) != null
if i == 0 then
//
elseif i == 1 then
call SetUnitVertexColor( FirstOfGroup(g2), 0, 0, 0, 255 )
call SetAnimation(FirstOfGroup(g2))
endif
call DestroyGroup(g)
call DestroyGroup(g2)
set u = null
set g = null
set g2 = null
return result
endfunction
function IsMarkInChain takes player p, real x, real y, integer j returns boolean // Checks 3 above
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x
set y2 = y + grid
elseif i == 1 then
set x2 = x
set y2 = y + (grid*2)
elseif i == 2 then
set x2 = x
set y2 = y + (grid*3)
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain2 takes player p, real x, real y, integer j returns boolean // checks 2 above 1 below
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x
set y2 = y + grid
elseif i == 1 then
set x2 = x
set y2 = y + (grid*2)
elseif i == 2 then
set x2 = x
set y2 = y - grid
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain3 takes player p, real x, real y, integer j returns boolean // Checks 1 above 2 below
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x
set y2 = y + grid
elseif i == 1 then
set x2 = x
set y2 = y - grid
elseif i == 2 then
set x2 = x
set y2 = y - (grid*2)
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain4 takes player p, real x, real y, integer j returns boolean // Checks 3 below
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x
set y2 = y - grid
elseif i == 1 then
set x2 = x
set y2 = y - (grid*2)
elseif i == 2 then
set x2 = x
set y2 = y - (grid*3)
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain5 takes player p, real x, real y, integer j returns boolean // Checks 3 to the right
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x + (grid*1)
set y2 = y
elseif i == 1 then
set x2 = x + (grid*2)
set y2 = y
elseif i == 2 then
set x2 = x + (grid*3)
set y2 = y
endif
if not IsSpotMarked (p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain6 takes player p, real x, real y, integer j returns boolean // Checks 2 to the right 1 left
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x + grid
set y2 = y
elseif i == 1 then
set x2 = x + grid*2
set y2 = y
elseif i == 2 then
set x2 = x - grid
set y2 = y
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain7 takes player p, real x, real y, integer j returns boolean // Checks 1 to the right 2 left
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x + grid
set y2 = y
elseif i == 1 then
set x2 = x - grid
set y2 = y
elseif i == 2 then
set x2 = x - (grid*2)
set y2 = y
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain8 takes player p, real x, real y, integer j returns boolean // Checks 3 left
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x - grid
set y2 = y
elseif i == 1 then
set x2 = x - (grid*2)
set y2 = y
elseif i == 2 then
set x2 = x - (grid*3)
set y2 = y
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain9 takes player p, real x, real y, integer j returns boolean // Checks 3 to the Right Diagonal (/)
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x + grid
set y2 = y + grid
elseif i == 1 then
set x2 = x + (grid*2)
set y2 = y + (grid*2)
elseif i == 2 then
set x2 = x + (grid*3)
set y2 = y + (grid*3)
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain10 takes player p, real x, real y, integer j returns boolean // Checks 2 to the Right diagonal (/) 1 left
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x + grid
set y2 = y + grid
elseif i == 1 then
set x2 = x + (grid*2)
set y2 = y + (grid*2)
elseif i == 2 then
set x2 = x - grid
set y2 = y - grid
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain11 takes player p, real x, real y, integer j returns boolean // Checks 1 to the Right Diagonal (/) 2 left
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x + grid
set y2 = y + grid
elseif i == 1 then
set x2 = x - grid
set y2 = y - grid
elseif i == 2 then
set x2 = x - (grid*2)
set y2 = y - (grid*2)
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain12 takes player p, real x, real y, integer j returns boolean // Checks 3 to the left diagonal (/)
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x - grid
set y2 = y - grid
elseif i == 1 then
set x2 = x - (grid*2)
set y2 = y - (grid*2)
elseif i == 2 then
set x2 = x - (grid*3)
set y2 = y - (grid*3)
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain13 takes player p, real x, real y, integer j returns boolean // Checks 3 to the Left diagonal (\)
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x - grid
set y2 = y + grid
elseif i == 1 then
set x2 = x - (grid*2)
set y2 = y + (grid*2)
elseif i == 2 then
set x2 = x - (grid*3)
set y2 = y + (grid*3)
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain14 takes player p, real x, real y, integer j returns boolean // Checks 2 to the left diagonal 1 right (\)
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x - grid
set y2 = y + grid
elseif i == 1 then
set x2 = x - (grid*2)
set y2 = y + (grid*2)
elseif i == 2 then
set x2 = x + grid
set y2 = y - grid
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain15 takes player p, real x, real y, integer j returns boolean // Checks 1 to the left diagonal 2 right (\)
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x - grid
set y2 = y + grid
elseif i == 1 then
set x2 = x + grid
set y2 = y - grid
elseif i == 2 then
set x2 = x + (grid*2)
set y2 = y - (grid*2)
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function IsMarkInChain16 takes player p, real x, real y, integer j returns boolean // Checks 3 Right diagonal (\)
local real x2
local real y2
local real grid = 128.
local integer i = 0
loop
exitwhen i >= 3
if i == 0 then
set x2 = x + grid
set y2 = y - grid
elseif i == 1 then
set x2 = x + (grid*2)
set y2 = y - (grid*2)
elseif i == 2 then
set x2 = x + (grid*3)
set y2 = y - (grid*3)
endif
if not IsSpotMarked(p, x2, y2, j) then
return false
endif
set i = i + 1
endloop
return true
endfunction
function WinningChain takes player p, real x, real y, integer j returns integer
if IsMarkInChain(p, x, y, j) then
return 1
elseif IsMarkInChain2(p, x, y, j) then
return 2
elseif IsMarkInChain3(p, x, y, j) then
return 3
elseif IsMarkInChain4(p, x, y, j) then
return 4
elseif IsMarkInChain5(p, x, y, j) then
return 5
elseif IsMarkInChain6(p, x, y, j) then
return 6
elseif IsMarkInChain7(p, x, y, j) then
return 7
elseif IsMarkInChain8(p, x, y, j) then
return 8
elseif IsMarkInChain9(p, x, y, j) then
return 9
elseif IsMarkInChain10(p, x, y, j) then
return 10
elseif IsMarkInChain11(p, x, y, j) then
return 11
elseif IsMarkInChain12(p, x, y, j) then
return 12
elseif IsMarkInChain13(p, x, y, j) then
return 13
elseif IsMarkInChain14(p, x, y, j) then
return 14
elseif IsMarkInChain15(p, x, y, j) then
return 15
elseif IsMarkInChain16(p, x, y, j) then
return 16
endif
return 0
endfunction
function Winner takes player p, unit u, unit u2, real x, real y returns nothing
local integer j
local integer i2 = 0
local integer pId = GetPlayerId(p)
//local string s
set j = WinningChain(p, x, y, 0)
if j != 0 then
if j == 1 then
call IsMarkInChain(p, x, y, 1)
elseif j == 2 then
call IsMarkInChain2(p, x, y, 1)
elseif j == 3 then
call IsMarkInChain3(p, x, y, 1)
elseif j == 4 then
call IsMarkInChain4(p, x, y, 1)
elseif j == 5 then
call IsMarkInChain5(p, x, y, 1)
elseif j == 6 then
call IsMarkInChain6(p, x, y, 1)
elseif j == 7 then
call IsMarkInChain7(p, x, y, 1)
elseif j == 8 then
call IsMarkInChain8(p, x, y, 1)
elseif j == 9 then
call IsMarkInChain9(p, x, y, 1)
elseif j == 10 then
call IsMarkInChain10(p, x, y, 1)
elseif j == 11 then
call IsMarkInChain11(p, x, y, 1)
elseif j == 12 then
call IsMarkInChain12(p, x, y, 1)
elseif j == 13 then
call IsMarkInChain13(p, x, y, 1)
elseif j == 14 then
call IsMarkInChain14(p, x, y, 1)
elseif j == 15 then
call IsMarkInChain15(p, x, y, 1)
elseif j == 16 then
call IsMarkInChain16(p, x, y, 1)
endif
call TurnClaimOff()
call SetUnitVertexColor( u2, 0, 0, 0, 255 )
call SetAnimation(u2)
call SetUnitAnimationByIndex(u, 1)
set hideMsg = true
set preGame = true
call TimerEnd2()
call ClearTextMessages()
set turns = turns + extraTurn
call SetGoldToTurns(true)
call WinSound(u2)
call PanCameraToTimed(x, y, 0.)
loop
exitwhen i2 > 11
call DisplayTimedTextToPlayer(Player(i2), 1, 1, 20., udg_playerColors[pId] + GetPlayerName(p) + udg_colorEnd + " has won the game!")
call DisplayTimedTextToPlayer(Player(i2), 1, 1, 20., "That game lasted " + udg_playerColors[5] + I2S(turns) + udg_colorEnd + " turns.")
call DisplayTimedTextToPlayer(Player(i2), 1, 1, 20., udg_playerColors[12] + "The game will restart in 20 seconds" + udg_colorEnd)
set i2 = i2 + 1
endloop
set wins[pId] = wins[pId] + 1
call LeaderboardSetItemValue(leaderBoard, LeaderboardGetPlayerIndex(leaderBoard, p), wins[pId])
call TriggerSleepAction(15.)
call TriggerExecute(gg_trg_Restart)
return
else
if isEncaps == true then
else
call TurnClaimOff()
endif
endif
call TurnBuildOn(p)
endfunction
endlibrary
//TESH.scrollpos=64
//TESH.alwaysfold=0
library Turns requires AFKTimers
globals
integer turns = 0
integer extraTurn
group lastMove = CreateGroup()
group lastMove2 = CreateGroup()
boolean hideMsg = false
endglobals
function PreventPlay takes nothing returns nothing
local integer i = playerNumberOfWhoseTurn
local integer i2 = 0
local force f = CreateForce()
local player p
loop
exitwhen i2 > 11
set p = Player(i2)
if i2 == i then
call ForceAddPlayer(f, p)
else
endif
set i2 = i2 + 1
endloop
if (IsPlayerInForce(GetLocalPlayer(), f)) then
call EnableSelect(true, true)
else
call EnableSelect(false, true)
endif
set i2 = 0
loop
exitwhen i2 > 11
set p = Player(i2)
if GetLocalPlayer() == p then
call ClearSelection()
call SelectUnit(builders[GetPlayerId(p)], true)
endif
set i2 = i2 + 1
endloop
call DestroyForce(f)
set f = null
set p = null
endfunction
function TurnBuildOn takes player p returns nothing
call ReviveHero(toggleBuilding[GetPlayerId(p)], 0, 0, false)
endfunction
function TurnBuildOff takes player p returns nothing
call KillUnit(toggleBuilding[GetPlayerId(p)])
endfunction
function TurnClaimOff takes nothing returns nothing
call SetPlayerAbilityAvailable(Player(PLAYER_NEUTRAL_PASSIVE), 'A000', false)
endfunction
function TurnClaimOn takes nothing returns nothing
call SetPlayerAbilityAvailable(Player(PLAYER_NEUTRAL_PASSIVE), 'A000', true)
endfunction
function ClearMsg takes nothing returns nothing
local integer i = 0
if afkMsg == false then
call ClearTextMessages()
else
set afkMsg = false
endif
loop
exitwhen i > 11
call DisplayTimedTextToPlayer(Player(i), 0,0, 100., "It is now " + udg_playerColors[playerNumberOfWhoseTurn] + GetPlayerName(Player(playerNumberOfWhoseTurn)) + udg_colorEnd + "'s turn.")
set i = i + 1
endloop
endfunction
function SetPlayerTurn takes nothing returns nothing
local integer i = playerNumberOfWhoseTurn + 1
if i == 12 then
set i = 0
endif
loop
if IsPlaying(Player(i)) == true and spectating[i] == 1 then
set playerNumberOfWhoseTurn = i
call TurnClaimOn()
call TurnBuildOff(Player(i))
call ClearMsg()
if shouldSound[playerNumberOfWhoseTurn] == true then
if shotClockDuration == 60. then
if GetLocalPlayer() == Player(i) then
call StartSound(gg_snd_TurnStart2)
call SetSoundVolume(gg_snd_TurnStart2, 200)
endif
endif
endif
return
else
set i = i + 1
if i == 12 then
set i = 0
endif
endif
endloop
endfunction
function SetGoldToTurns takes boolean b returns nothing
local player p
local integer i = 0
local integer i2 = -1000000
loop
exitwhen i > 11
set p = Player(i)
if b == true then
// Sets Gold to the number of turns
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, turns)
else
// Sets Gold to 0 for a restart
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, i2)
set turns = 0
endif
set i = i + 1
endloop
set p = null
endfunction
function LastMove takes nothing returns nothing
local unit u
loop
set u = FirstOfGroup(lastMove)
exitwhen u == null
call SetUnitVertexColor(u, udg_RGBColors1[playerNumberOfWhoseTurn], udg_RGBColors2[playerNumberOfWhoseTurn], udg_RGBColors3[playerNumberOfWhoseTurn], 255)
call GroupRemoveUnit(lastMove, u)
call GroupAddUnit(lastMove2, u)
endloop
endfunction
function LastMove2 takes nothing returns nothing
local unit u
loop
set u = FirstOfGroup(lastMove2)
exitwhen u == null
call SetUnitVertexColor(u, 255, 255, 255, 255)
call GroupRemoveUnit(lastMove2, u)
endloop
set u = null
endfunction
function NextTurn takes nothing returns nothing
call TimerEnd()
set turns = turns + 1
call SetGoldToTurns(true)
call TurnBuildOff(Player(playerNumberOfWhoseTurn))
call TurnClaimOn()
call LastMove2()
if hideMsg == false then
call LastMove()
call SetPlayerTurn()
if shotClockDuration != 60. then
call ShotClock()
endif
endif
call PreventPlay()
// if shotClockDuration != 60. then
// call ShotClock()
// endif
endfunction
endlibrary
//TESH.scrollpos=72
//TESH.alwaysfold=0
library AFKTimers initializer init requires AFKTimeOut
globals
timer shotClock
timerdialog shotClockTD
private integer count = 0
boolean afkTimerAlreadyOn = false
real shotClockDuration = 60.
boolean afkMsg = false
boolean array shouldSound
endglobals
function ShotClockCleanUp takes nothing returns nothing
local integer i = 0
local integer i2 = 0
local real x = 0
call PauseTimer(shotClock)
call DestroyTimer(shotClock)
call DestroyTimerDialog(shotClockTD)
if UnitAlive(toggleBuilding[playerNumberOfWhoseTurn]) == false then
call ClaimRandomMark()
set i2 = 1
endif
call BuildRandomMark()
if hideMsg == false then
call ClearTextMessages()
else
set x = 1
endif
loop
exitwhen i > 11
if i2 == 1 then
call DisplayTimedTextToPlayer(Player(i), x, x, 100., udg_playerColors[playerNumberOfWhoseTurn] + GetPlayerName(Player(playerNumberOfWhoseTurn)) + udg_colorEnd + " did not move in time, a marker was claimed and another built randomly.")
else
call DisplayTimedTextToPlayer(Player(i), x, x, 100., udg_playerColors[playerNumberOfWhoseTurn] + GetPlayerName(Player(playerNumberOfWhoseTurn)) + udg_colorEnd + " did not move in time, a random marker was built randomly.")
endif
set i = i + 1
endloop
set afkMsg = true
set afkTimerAlreadyOn = false
set shotClock = null
set shotClockTD = null
endfunction
function ShotClock takes nothing returns nothing
set afkTimerAlreadyOn = true
set shotClock = CreateTimer()
set shotClockTD = CreateTimerDialog(shotClock)
call TimerStart(shotClock, shotClockDuration, true, function ShotClockCleanUp)
call TimerDialogDisplay(shotClockTD, true)
call TimerDialogSetTitle(shotClockTD, udg_playerColors[playerNumberOfWhoseTurn] +"Turn randomized in..." + udg_colorEnd)
if shouldSound[playerNumberOfWhoseTurn] == true then
if GetLocalPlayer() == Player(playerNumberOfWhoseTurn) then
call StartSound( gg_snd_TurnEnd)
call SetSoundVolume( gg_snd_TurnEnd, 1000)
endif
endif
endfunction
function AllowAFKTimer takes nothing returns boolean
if preGame == true then
call DisplayTextToPlayer(GetTriggerPlayer(), 0 ,0, udg_playerColors[0] + "Error" + udg_colorEnd + " The game has not yet started, you cannot start an afk timer")
return false
else
if afkTimerAlreadyOn == false then
return true
else
call DisplayTextToPlayer(GetTriggerPlayer(), 0 ,0, udg_playerColors[0] + "Error" + udg_colorEnd + " The shot clock is already running")
return false
endif
endif
endfunction
function TimerEnd takes nothing returns nothing
if afkTimerAlreadyOn == true then
if TimerGetRemaining(shotClock) != 0. then
call PauseTimer(shotClock)
call DestroyTimer(shotClock)
call DestroyTimerDialog(shotClockTD)
set afkTimerAlreadyOn = false
set shotClock = null
set shotClockTD = null
else
call ShotClockCleanUp()
endif
endif
endfunction
function TimerEnd2 takes nothing returns nothing
if afkTimerAlreadyOn == true then
call PauseTimer(shotClock)
call DestroyTimer(shotClock)
call DestroyTimerDialog(shotClockTD)
set afkTimerAlreadyOn = false
set shotClock = null
set shotClockTD = null
endif
endfunction
function init takes nothing returns nothing
local integer i = 0
loop
exitwhen i > 11
set shouldSound[i] = true
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_AFK_Enable takes nothing returns nothing
set gg_trg_AFK_Enable = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Enable, Player(0), "-afk", true )
call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Enable, Player(1), "-afk", true )
call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Enable, Player(2), "-afk", true )
call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Enable, Player(3), "-afk", true )
call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Enable, Player(4), "-afk", true )
call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Enable, Player(5), "-afk", true )
call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Enable, Player(6), "-afk", true )
call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Enable, Player(7), "-afk", true )
call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Enable, Player(8), "-afk", true )
call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Enable, Player(9), "-afk", true )
call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Enable, Player(10), "-afk", true )
call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Enable, Player(11), "-afk", true )
call TriggerAddCondition(gg_trg_AFK_Enable, Condition(function AllowAFKTimer))
call TriggerAddAction( gg_trg_AFK_Enable, function ShotClock )
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library AFKTimeOut requires Detection
function BuildRandomMark takes nothing returns nothing
local boolean b = false
local real x
local real y
local real x2
local real y2
local unit u
local unit u2
local group g = CreateGroup()
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Condition(function BuildingsOnly))
loop
exitwhen b == true
set u = FirstOfGroup(g)
call GroupRemoveUnit(g, u)
set x = GetUnitX(u)
set y = GetUnitY(u)
set u2 = DetectAllowBuilding(x, y)
if u2 != null then
call UnitAddAbility(u2, 'AIbl')
call UnitApplyTimedLife(u2, 'BTLF', 1.)
set x2 = GetUnitX(u2)
set y2 = GetUnitY(u2)
call IssueBuildOrderById(u2, 852619, x2, y2)
set b = true
endif
endloop
call DestroyGroup(g)
set u = null
set u2 = null
set g = null
endfunction
function ClaimRandomMark takes nothing returns nothing
local boolean b = false
local unit u
local group g = CreateGroup()
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Condition(function BuildingsOnly))
loop
exitwhen b == true
set u = FirstOfGroup(g)
call GroupRemoveUnit(g, u)
if not IsUnitPaused(u) then
call IssueImmediateOrder(u, "channel")
set b = true
endif
endloop
call DestroyGroup(g)
set g = null
set u = null
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Reset takes nothing returns nothing
call RemoveUnit( GetEnumUnit() )
endfunction
function ResetMarkers takes nothing returns nothing
// the unit id is what is set when unitmarker chosen // 0 is null
local integer i = 0
loop
exitwhen i > 11
set unitIdForMarkers[i] = 0
set i = i + 1
endloop
endfunction
function SetFalse takes nothing returns nothing
// false is no // true is yes
local integer i = 0
loop
exitwhen i > 11
set startEarly[i] = false
set i = i + 1
endloop
endfunction
function ResetSpectate takes nothing returns nothing
// 0 = yes // 1 = no
local integer i = 0
loop
exitwhen i > 11
set spectating[i] = 0
set i = i + 1
endloop
endfunction
function RemoveAll takes nothing returns nothing
local integer i = 0
local group g = CreateGroup()
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
call ForGroup(g, function Reset )
call DestroyGroup(g)
set g = null
loop
exitwhen i > 11
call KillUnit(toggleBuilding[i])
set toggleBuilding[i] = null
set i = i + 1
endloop
call SetGoldToTurns(false)
set hideMsg = false
set preGame = true
call DestroyGroup(lastMove)
call DestroyGroup(lastMove2)
set lastMove = null
set lastMove2 = null
set lastMove = CreateGroup()
set lastMove2 = CreateGroup()
call TurnClaimOn()
call ResetSpectate()
call ResetMarkers()
call SetFalse()
call CreateDialog2()
endfunction
function InitTrig_Restart takes nothing returns nothing
set gg_trg_Restart = CreateTrigger( )
call TriggerAddAction( gg_trg_Restart, function RemoveAll )
endfunction
//TESH.scrollpos=40
//TESH.alwaysfold=0
library SetUp requires Turns
globals
timerdialog startDelayTD
private group selectors = null
private unit Tavern = null
timer startDelay
boolean preGame = true
integer playerNumberOfWhoseTurn
integer gBoardDimensions = 1
integer array unitIdForMarkers
boolean array startEarly
unit array builders
unit array toggleBuilding
endglobals
function TurnSelect takes nothing returns nothing
local integer i = GetRandomInt(0, 11)
local boolean b = false
loop
exitwhen b == true
if IsPlaying(Player(i)) and spectating[i] == 1 then
set playerNumberOfWhoseTurn = i
call BJDebugMsg(udg_playerColors[playerNumberOfWhoseTurn] + GetPlayerName(Player(playerNumberOfWhoseTurn)) + udg_colorEnd + " was randomly selected to go first")
if shouldSound[playerNumberOfWhoseTurn] == true then
if shotClockDuration == 60. then
if GetLocalPlayer() == Player(playerNumberOfWhoseTurn) then
call StartSound(gg_snd_TurnStart2)
call SetSoundVolume( gg_snd_TurnStart2, 200)
endif
endif
endif
set b = true
endif
set i = GetRandomInt(0, 11)
endloop
endfunction
/*function TurnSelect takes nothing returns nothing // Wasn't giving everyone a 1 and 11 chance of being picked.
local integer i = GetRandomInt(0, 11)
set playerNumberOfWhoseTurn = i
loop
if IsPlaying(Player(i)) == true and spectating[i] == 1 then
set playerNumberOfWhoseTurn = i
call BJDebugMsg(udg_playerColors[playerNumberOfWhoseTurn] + GetPlayerName(Player(playerNumberOfWhoseTurn)) + udg_colorEnd + " was randomly selected to go first")
if shouldSound[playerNumberOfWhoseTurn] == true then
if shotClockDuration == 60. then
if GetLocalPlayer() == Player(playerNumberOfWhoseTurn) then
call StartSound(gg_snd_TurnStart2)
call SetSoundVolume( gg_snd_TurnStart2, 200)
endif
endif
endif
return
else
if i == 11 then
set i = GetRandomInt(0, 10)
else
set i = i + 1
endif
endif
endloop
endfunction*/
function AtleastX takes group g , integer j returns boolean
local integer i = 0
local unit u
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
set i = i + 1
endloop
if i >= j then
set u = null
return true
else
set u = null
return false
endif
endfunction
function Solo2 takes nothing returns boolean
local integer i = 0
local integer i2 = 0
loop
exitwhen i > 11
if IsPlaying(Player(i)) then
set i2 = i2 + 1
endif
set i = i + 1
endloop
if i2 == 1 then
return true
endif
return false
endfunction
function Solo takes nothing returns boolean
local integer i = 0
local integer i2 = 0
loop
exitwhen i > 11
if IsPlaying(Player(i)) then
set i2 = i2 + 1
endif
set i = i + 1
endloop
if i2 == 1 then
call BJDebugMsg(udg_playerColors[0] + "Error" + udg_colorEnd + "This game is not meant to be played solo, but you can \"play\" alone.")
return true
endif
return false
endfunction
function CreateBuilders2 takes nothing returns group
local integer i = 0
local unit u2
local player p
local group g = CreateGroup()
loop
exitwhen i > 11
set p = Player(i)
if IsPlaying(p) and spectating[i] == 1 then
set u2 = CreateUnit(p, 'h004', 0, 0, 270)
set builders[i] = u2
call GroupAddUnit(g, u2)
if GetLocalPlayer() == p then
call ClearSelection()
call SelectUnit(u2, true)
endif
set toggleBuilding[i] = CreateUnit(p, 'H008', 0, 0 , 270)
call KillUnit(toggleBuilding[i])
endif
set i = i + 1
endloop
set u2 = null
return g
endfunction
function AutoSelect2 takes nothing returns nothing
local integer i = 0
local integer i2
local integer Garithos = 'h003'
local integer PitLord = 'h007'
local integer Rexxar = 'h005'
local integer Tinker = 'h006'
local integer BladeMaster = 'h00B'
local integer Balnazzar = 'h00A'
local integer Maiev = 'h001'
local integer Sylvanas = 'h009'
local integer Jaina = 'h00F'
local integer Tyrande = 'h00E'
local integer Alchemist = 'h00C'
local integer Antonidas = 'h00D'
local integer whichMarker
loop
exitwhen i > 11
set i2 = GetRandomInt(1, 12)
if unitIdForMarkers[i] == 0 then
if i2 == 1 then
set whichMarker = Garithos
elseif i2 == 2 then
set whichMarker = PitLord
elseif i2 == 3 then
set whichMarker = Rexxar
elseif i2 == 4 then
set whichMarker = Tinker
elseif i2 == 5 then
set whichMarker = BladeMaster
elseif i2 == 6 then
set whichMarker = Balnazzar
elseif i2 == 7 then
set whichMarker = Maiev
elseif i2 == 8 then
set whichMarker = Sylvanas
elseif i2 == 9 then
set whichMarker = Jaina
elseif i2 == 10 then
set whichMarker = Tyrande
elseif i2 == 11 then
set whichMarker = Alchemist
elseif i2 == 12 then
set whichMarker = Antonidas
endif
set unitIdForMarkers[i] = whichMarker
if spectating[i] == 1 then
call DisplayTextToPlayer(Player(i), 0,0, "You randomed " + udg_playerColors[6] + GetObjectName(whichMarker) + udg_colorEnd + " as your marker.")
endif
endif
set i = i + 1
endloop
endfunction
function RemoveSelectors2 takes nothing returns nothing
local unit u
loop
set u = FirstOfGroup(selectors)
exitwhen u == null
call RemoveUnit(u)
call GroupRemoveUnit(selectors, u)
endloop
call DestroyGroup(selectors)
set u = null
set selectors = null
endfunction
function BoardSetUpRM takes nothing returns nothing // Square Boards
local unit u
local integer currentBoardSize = 0
local integer boardDimensions = gBoardDimensions // Default is 1, this is a 3x3 board.
local integer lengthOfSide = 3 + ((boardDimensions-1)*2)
local integer boardSize = lengthOfSide * lengthOfSide
local integer ChainLength = lengthOfSide - 1
local integer currentChainLength = 0
local integer whichDirection = 1
local integer direction = 1 // 1 is down, 2 is is up, 3 is right
local real start = 128 * boardDimensions
local real x = -start
local real y = start
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h002', x, y, 270)
call SetUnitAnimationByIndex(u, 1)
call UnitRemoveAbility(u, 'Amov')
loop
exitwhen currentBoardSize == boardSize - 1
if direction == 1 then
set y = y - 128
elseif direction == 2 then
set y = y + 128
elseif direction == 3 then
set x = x + 128
set currentChainLength = currentChainLength - 1
if whichDirection == 1 then
set direction = 2
set whichDirection = 2
else
set direction = 1
set whichDirection = 1
endif
endif
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h002', x, y, 270)
call SetUnitAnimationByIndex(u, 1)
call UnitRemoveAbility(u, 'Amov')
set currentChainLength = currentChainLength + 1
if currentChainLength == ChainLength then
set currentChainLength = 0
set direction = 3
endif
set currentBoardSize = currentBoardSize + 1
endloop
set u = null
endfunction
function CreateDummies takes nothing returns nothing
local unit u
local integer i = 0
set selectors = CreateGroup()
loop
exitwhen i > 11
if IsPlaying(Player(i)) and spectating[i] == 1 then
set startEarly[i] = false
set u = CreateUnit(Player(i), 'h000', 0, 0, 270)
call GroupAddUnit(selectors, u)
if GetLocalPlayer() == Player(i) then
call ClearSelection()
call SelectUnit(Tavern, true)
endif
else
set startEarly[i] = true
endif
set i = i + 1
endloop
set u = null
endfunction
function GameStartCleanUp takes nothing returns nothing
local group g
local boolean check
local string s
call PauseTimer(startDelay)
call DestroyTimer(startDelay)
call DestroyTimerDialog(startDelayTD)
call RemoveUnit(Tavern)
call RemoveSelectors2()
call AutoSelect2()
if whichShape == STANDARD then
call BoardSetUpRM()
elseif whichShape == RECTANGLE then
call CreateRectangle(whichSize, whichSize)
elseif whichShape == DIAMOND then
call CreateAngledSquare(whichSize, whichSize)
elseif whichShape == PLUS then
call CreatePlus(whichSize)
elseif whichShape == X then
call CreateX(whichSize)
elseif whichShape == Z then
call CreateZ(whichSize)
endif
call SetGoldToTurns(false)
set g = CreateBuilders2()
if Solo() then
set check = AtleastX(g, 1)
set s = udg_playerColors[0] + "Error" + udg_colorEnd +"You may not observe a solo game. Restarting."
else
set check = AtleastX(g, 2)
set s = udg_playerColors[0] + "Error" + udg_colorEnd + " Not enough people are playing, must be at least" + udg_playerColors[4] + " 2." + udg_colorEnd + " Restarting."
endif
if check == true then
set preGame = false
call TurnSelect()
call PreventPlay()
call DestroyGroup(g)
set g = null
set startDelay = null
set startDelayTD = null
if shotClockDuration != 60. then
call ShotClock()
endif
else
call BJDebugMsg(s)
call DestroyGroup(g)
set g = null
set startDelay = null
set startDelayTD = null
call TriggerExecute(gg_trg_Restart)
endif
endfunction
function GameStart2 takes nothing returns nothing
local integer i = 0
set Tavern = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'n000', 0, 0, 270)
set startDelay = CreateTimer()
set startDelayTD = CreateTimerDialog(startDelay)
call TimerStart(startDelay, 30., true, function GameStartCleanUp)
call TimerDialogDisplay(startDelayTD, true)
call TimerDialogSetTitle(startDelayTD, "Time to select marker...")
call CreateDummies()
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
function SetMarkers takes nothing returns nothing
local integer i = GetPlayerId(GetOwningPlayer(GetBuyingUnit()))
local integer i2 = 0
local integer j = 0
local integer j2 = 0
set unitIdForMarkers[i] = GetUnitTypeId(GetSoldUnit())
call DisplayTimedTextToPlayer(Player(i), 0,0, 5., "You've selected " + udg_playerColors[6] + GetUnitName(GetSoldUnit()) + udg_colorEnd + " as your marker")
call RemoveUnit(GetSoldUnit())
set startEarly[i] = true
loop
exitwhen j > 11
if startEarly[j] == false then
set j2 = j2 + 1
else
endif
set j = j + 1
endloop
if j2 > 0 then
else
call PauseTimer(startDelay)
call DestroyTimer(startDelay)
set startDelay = CreateTimer()
call TimerStart(startDelay, 0., false, function GameStartCleanUp)
endif
endfunction
//===========================================================================
function InitTrig_Set_Markers takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SELL )
call TriggerAddAction( t, function SetMarkers )
endfunction
//TESH.scrollpos=478
//TESH.alwaysfold=0
library DialogSetUp requires SetUp
globals
private button array buttons
private Dialog whichDialog = 0
private timer t
private timerdialog td
private integer numberOfPlayers = 0
private integer voteCount = 0
private boolean standardShape = true
private integer array votes
private boolean array didVote
constant integer STANDARD = 1
constant integer RECTANGLE = 2
constant integer DIAMOND = 3
constant integer PLUS = 4
constant integer X = 5
constant integer Z = 6
integer whichShape = 0
integer whichSize = 0
integer array spectating
endglobals
private function AppendHotkey takes string source, string hotkey returns string
return "|cffffcc00[" + hotkey + "]|r " + source
endfunction
private function ResetNumberOfPlayers takes nothing returns nothing
local integer i = 0
set numberOfPlayers = 0
loop
exitwhen i > 11
if IsPlaying(Player(i)) then
set numberOfPlayers = numberOfPlayers + 1
set didVote[i] = false
endif
set i = i + 1
endloop
endfunction
private function ResetVote takes integer choices returns nothing
local integer j = 0
loop
exitwhen j > choices
set votes[j] = 0
set j = j + 1
endloop
endfunction
private function VotedShotClock takes nothing returns nothing
local integer i = 1
local integer i2 = 0
local integer j = 0
local string s
local string s2
loop
exitwhen i > 3
if votes[i2] < votes[i] then
set i2 = i
endif
set i = i + 1
endloop
if i2 == 0 then
set s = "no"
set s2 = ""
set shotClockDuration = 60.
elseif i2 == 1 then
set s = " 30 second"
set s2 = "a"
set shotClockDuration = 30.
elseif i2 == 2 then
set s = " 15 second"
set s2 = "a"
set shotClockDuration = 15.
endif
call BJDebugMsg("There will be " + s2 + udg_playerColors[4] + s + udg_colorEnd + " shot clock.")
call ResetVote(2)
endfunction
private function VotedBoardSize takes nothing returns nothing
local integer i = 1
local integer i2 = 0
local integer j = 0
local string s
loop
exitwhen i > 3
if votes[i2] < votes[i] then
set i2 = i
endif
set i = i + 1
endloop
if i2 == 0 then
set s = "3 by 3."
elseif i2 == 1 then
set s = "5 by 5."
elseif i2 == 2 then
set s = "7 by 7."
elseif i2 == 3 then
set s = "9 by 9."
endif
call BJDebugMsg("The board will be " + udg_playerColors[4] + s + udg_colorEnd)
set gBoardDimensions = i2 + 1
call ResetVote(3)
endfunction
private function VotedWildBoardSize takes nothing returns nothing
local integer i = 1
local integer i2 = 0
local integer j = 0
local string s
loop
exitwhen i > 1
if votes[i2] < votes[i] then
set i2 = i
endif
set i = i + 1
endloop
if i2 == 0 then
set s = "Small."
set whichSize = 5
elseif i2 == 1 then
set s = "Large."
if whichShape == Z then // Z Doesn't look good with Even numbers
set whichSize = 11
else
set whichSize = 10
endif
endif
call BJDebugMsg("The board will be " + udg_playerColors[4] + s + udg_colorEnd)
call ResetVote(1)
endfunction
private function VotedBoardShape takes nothing returns nothing
local integer i = 1
local integer i2 = 0
local integer j = 0
local string s
local string s2
loop
exitwhen i > 5
if votes[i2] < votes[i] then
set i2 = i
endif
set i = i + 1
endloop
if i2 == 0 then
set s = "Standard"
set s2 = ""
set whichShape = STANDARD
elseif i2 == 1 then
set s = " Rectangle"
set s2 = "a"
set whichShape = RECTANGLE
elseif i2 == 2 then
set s = " Diamond"
set s2 = "a"
set whichShape = DIAMOND
elseif i2 == 3 then
set s = " Plus Sign"
set s2 = "a"
set whichShape = PLUS
elseif i2 == 4 then
set s = " X"
set s2 = "an"
set whichShape = X
elseif i2 == 5 then
set s = " Z"
set s2 = "a"
set whichShape = Z
endif
call BJDebugMsg("The board's shape will be " + s2 + udg_playerColors[4] + s + udg_colorEnd)
call ResetVote(5)
endfunction
private function DidVoteAndReset takes nothing returns nothing
local integer i = 0
set voteCount = 0
loop
exitwhen i > 11
if didVote[i] == false and IsPlaying(Player(i)) == true then
call BJDebugMsg(udg_playerColors[i] + GetPlayerName(Player(i)) + udg_colorEnd + " did not choose in time and will observe this game.")
set spectating[i] = 0
else
set didVote[i] = false
endif
set i = i + 1
endloop
endfunction
private function DidVoteAndReset2 takes nothing returns nothing
local integer i = 0
set voteCount = 0
loop
exitwhen i > 11
if didVote[i] == false and spectating[i] == 1 then
call BJDebugMsg(udg_playerColors[i] + GetPlayerName(Player(i)) + udg_colorEnd + " did not choose in time.")
else
set didVote[i] = false
endif
set i = i + 1
endloop
endfunction
private function ShotClockDialogExpired takes nothing returns nothing
call whichDialog.destroy()
call DidVoteAndReset2()
call PauseTimer(t)
call DestroyTimer(t)
call DestroyTimerDialog(td)
set t = null
set td = null
call VotedShotClock()
call GameStart2()
endfunction
private function ShotClockButton takes nothing returns boolean
local Dialog log = Dialog.getClickedDialog()
local button b = Dialog.getClickedButton()
local player p = Dialog.getPlayer()
local string s
if b == buttons[0] then
set s = " no"
set votes[0] = votes[0] + 1
elseif b == buttons[1] then
set s = " a 30 second"
set votes[1] = votes[1] + 1
elseif b == buttons[2] then
set s = " a 15 second"
set votes[2] = votes[2] + 1
endif
call BJDebugMsg(udg_playerColors[GetPlayerId(p)] + GetPlayerName(p) + udg_colorEnd + " voted for" + s + " shot clock.")
set voteCount = voteCount + 1
set didVote[GetPlayerId(p)] = true
if voteCount == numberOfPlayers then
call PauseTimer(t)
call DestroyTimer(t)
set t = null
set t = CreateTimer()
call TimerStart(t, 0, false, function ShotClockDialogExpired)
endif
set b = null
set p = null
return false
endfunction
private function ShotClockDialog takes nothing returns nothing
local integer i = 0
local Dialog log = Dialog.create()
set log.title = "Speed up gameplay with a shot clock?"
set buttons[0] = log.addButton(AppendHotkey("No (recommended)", "A"), 'A')
set buttons[1] = log.addButton(AppendHotkey("Yes: 30 seconds per turn", "B"), 'B')
set buttons[2] = log.addButton(AppendHotkey("Yes: 15 seconds per turn", "C"), 'C')
set numberOfPlayers = 0
loop
exitwhen i > 11
if spectating[i] == 1 then
call log.display(Player(i), true)
set numberOfPlayers = numberOfPlayers + 1
endif
set i = i + 1
endloop
call log.registerClickEvent(Condition(function ShotClockButton))
set whichDialog = log
set t = CreateTimer()
set td = CreateTimerDialog(t)
call TimerDialogDisplay(td, true)
call TimerDialogSetTitle(td, "Shot Clock?")
call TimerStart(t, 30., false, function ShotClockDialogExpired)
endfunction
private function BoardSizeDialogExpired takes nothing returns nothing
call whichDialog.destroy()
call DidVoteAndReset2()
call PauseTimer(t)
call DestroyTimer(t)
call DestroyTimerDialog(td)
set t = null
set td = null
call VotedBoardSize()
call ShotClockDialog()
endfunction
private function BoardSizeButton takes nothing returns boolean
local Dialog log = Dialog.getClickedDialog()
local button b = Dialog.getClickedButton()
local player p = Dialog.getPlayer()
local string s
if b == buttons[0] then
set s = " 3 by 3."
set votes[0] = votes[0] + 1
elseif b == buttons[1] then
set s = " 5 by 5."
set votes[1] = votes[1] + 1
elseif b == buttons[2] then
set s = " 7 by 7."
set votes[2] = votes[2] + 1
elseif b == buttons[3] then
set s = " 9 by 9."
set votes[3] = votes[3] + 1
endif
call BJDebugMsg(udg_playerColors[GetPlayerId(p)] + GetPlayerName(p) + udg_colorEnd + " voted for" + s)
set voteCount = voteCount + 1
set didVote[GetPlayerId(p)] = true
if voteCount == numberOfPlayers then
call PauseTimer(t)
call DestroyTimer(t)
set t = null
set t = CreateTimer()
call TimerStart(t, 0, false, function BoardSizeDialogExpired)
endif
set b = null
set p = null
return false
endfunction
private function BoardSizeDialog takes nothing returns nothing
local integer i = 0
local Dialog log = Dialog.create()
set log.title = "How large should the inital board be?"
set buttons[0] = log.addButton(AppendHotkey("3 by 3 (recommended for 2)", "A"), 'A')
set buttons[1] = log.addButton(AppendHotkey("5 by 5 (3+)", "B"), 'B')
set buttons[2] = log.addButton(AppendHotkey("7 by 7 (3+)", "C"), 'C')
set buttons[3] = log.addButton(AppendHotkey("9 by 9 (3+)", "D"), 'D')
set numberOfPlayers = 0
loop
exitwhen i > 11
if spectating[i] == 1 then
call log.display(Player(i), true)
set numberOfPlayers = numberOfPlayers + 1
endif
set i = i + 1
endloop
call log.registerClickEvent(Condition(function BoardSizeButton))
set whichDialog = log
set t = CreateTimer()
set td = CreateTimerDialog(t)
call TimerDialogDisplay(td, true)
call TimerDialogSetTitle(td, "Board Size?")
call TimerStart(t, 30., false, function BoardSizeDialogExpired)
endfunction
private function WildBoardSizeDialogExpired takes nothing returns nothing
call whichDialog.destroy()
call DidVoteAndReset2()
call PauseTimer(t)
call DestroyTimer(t)
call DestroyTimerDialog(td)
set t = null
set td = null
call VotedWildBoardSize()
call ShotClockDialog()
endfunction
private function WildBoardSizeButton takes nothing returns boolean
local Dialog log = Dialog.getClickedDialog()
local button b = Dialog.getClickedButton()
local player p = Dialog.getPlayer()
local string s
if b == buttons[0] then
set s = " Small"
set votes[0] = votes[0] + 1
elseif b == buttons[1] then
set s = " Large"
set votes[1] = votes[1] + 1
endif
call BJDebugMsg(udg_playerColors[GetPlayerId(p)] + GetPlayerName(p) + udg_colorEnd + " voted for" + s)
set voteCount = voteCount + 1
set didVote[GetPlayerId(p)] = true
if voteCount == numberOfPlayers then
call PauseTimer(t)
call DestroyTimer(t)
set t = null
set t = CreateTimer()
call TimerStart(t, 0, false, function WildBoardSizeDialogExpired)
endif
set b = null
set p = null
return false
endfunction
private function WildBoardSizeDialog takes nothing returns nothing
local integer i = 0
local Dialog log = Dialog.create()
set log.title = "How large should the inital board be?"
set buttons[0] = log.addButton(AppendHotkey("Small (recommended for 2)", "A"), 'A')
set buttons[1] = log.addButton(AppendHotkey("Large (3+)", "B"), 'B')
set numberOfPlayers = 0
loop
exitwhen i > 11
if spectating[i] == 1 then
call log.display(Player(i), true)
set numberOfPlayers = numberOfPlayers + 1
endif
set i = i + 1
endloop
call log.registerClickEvent(Condition(function WildBoardSizeButton))
set whichDialog = log
set t = CreateTimer()
set td = CreateTimerDialog(t)
call TimerDialogDisplay(td, true)
call TimerDialogSetTitle(td, "Board Size?")
call TimerStart(t, 30., false, function WildBoardSizeDialogExpired)
endfunction
private function BoardShapeDialogExpired takes nothing returns nothing
call whichDialog.destroy()
call DidVoteAndReset2()
call PauseTimer(t)
call DestroyTimer(t)
call DestroyTimerDialog(td)
set t = null
set td = null
call VotedBoardShape()
if whichShape == STANDARD then
call BoardSizeDialog()
else
call WildBoardSizeDialog()
endif
endfunction
private function BoardShapeButton takes nothing returns boolean
local Dialog log = Dialog.getClickedDialog()
local button b = Dialog.getClickedButton()
local player p = Dialog.getPlayer()
local string s
if b == buttons[0] then
set s = " Standard."
set votes[0] = votes[0] + 1
elseif b == buttons[1] then
set s = " Rectangle."
set votes[1] = votes[1] + 1
elseif b == buttons[2] then
set s = " Diamond."
set votes[2] = votes[2] + 1
elseif b == buttons[3] then
set s = " Plus Sign."
set votes[3] = votes[3] + 1
elseif b == buttons[4] then
set s = " \"X\""
set votes[4] = votes[4] + 1
elseif b == buttons[5] then
set s = " \"Z\""
set votes[5] = votes[5] + 1
endif
call BJDebugMsg(udg_playerColors[GetPlayerId(p)] + GetPlayerName(p) + udg_colorEnd + " voted for" + s)
set voteCount = voteCount + 1
set didVote[GetPlayerId(p)] = true
if voteCount == numberOfPlayers then
call PauseTimer(t)
call DestroyTimer(t)
set t = null
set t = CreateTimer()
call TimerStart(t, 0, false, function BoardShapeDialogExpired)
endif
set b = null
set p = null
return false
endfunction
private function BoardShapeDialog takes nothing returns nothing
local integer i = 0
local Dialog log = Dialog.create()
set log.title = "What board shape?"
set buttons[0] = log.addButton(AppendHotkey("Standard (recommended)", "A"), 'A')
set buttons[1] = log.addButton(AppendHotkey("Rectangle", "B"), 'B')
set buttons[2] = log.addButton(AppendHotkey("Diamond", "C"), 'C')
set buttons[3] = log.addButton(AppendHotkey("Plus Sign", "D"), 'D')
set buttons[4] = log.addButton(AppendHotkey("\"X\"", "E"), 'E')
set buttons[5] = log.addButton(AppendHotkey("\"Z\"", "F"), 'F')
set numberOfPlayers = 0
loop
exitwhen i > 11
if spectating[i] == 1 then
call log.display(Player(i), true)
set numberOfPlayers = numberOfPlayers + 1
endif
set i = i + 1
endloop
call log.registerClickEvent(Condition(function BoardShapeButton))
set whichDialog = log
set t = CreateTimer()
set td = CreateTimerDialog(t)
call TimerDialogDisplay(td, true)
call TimerDialogSetTitle(td, "Board Shape?")
call TimerStart(t, 30., false, function BoardShapeDialogExpired)
endfunction
private function PlayingDialogExpired takes nothing returns nothing
local integer i = 0
local integer i2 = 0
call whichDialog.destroy()
call DidVoteAndReset()
call PauseTimer(t)
call DestroyTimer(t)
call DestroyTimerDialog(td)
set t = null
set td = null
loop
exitwhen i > 11
if spectating[i] == 1 then
set i2 = i2 + 1
endif
set i = i + 1
endloop
if i2 >= 1 then
call BoardShapeDialog()
else
set voteCount = 0
call ResetNumberOfPlayers()
set startDelay = CreateTimer()
set startDelayTD = CreateTimerDialog(startDelay)
call TimerStart(startDelay, 0., false, function GameStartCleanUp)
endif
endfunction
private function PlayingButton takes nothing returns boolean
local Dialog log = Dialog.getClickedDialog()
local button b = Dialog.getClickedButton()
local player p = Dialog.getPlayer()
local string s
if b == buttons[0] then
set s = " wants to play."
set spectating[GetPlayerId(p)] = 1
elseif b == buttons[1] then
set s = " wants to observe."
set spectating[GetPlayerId(p)] = 0
endif
call BJDebugMsg(udg_playerColors[GetPlayerId(p)] + GetPlayerName(p) + udg_colorEnd + s)
set voteCount = voteCount + 1
set didVote[GetPlayerId(p)] = true
if voteCount == numberOfPlayers then
call PauseTimer(t)
call DestroyTimer(t)
set t = CreateTimer()
call TimerStart(t, 0, false, function PlayingDialogExpired)
endif
set b = null
set p = null
return false
endfunction
private function PlayingDialog takes nothing returns nothing
local Dialog log = Dialog.create()
set log.title = "Welcome to Advanced Tic-Tac-Toe\n Would you like to play?"
set buttons[0] = log.addButton(AppendHotkey("Yes", "Y"), 'Y')
set buttons[1] = log.addButton(AppendHotkey("No, I'll Observe (Lasts 1 Game)", "N"), 'N')
call log.displayAll(true)
call log.registerClickEvent(Condition(function PlayingButton))
set whichDialog = log
set t = CreateTimer()
set td = CreateTimerDialog(t)
call TimerDialogDisplay(td, true)
call TimerDialogSetTitle(td, "Play or Observe?")
call TimerStart(t, 30, false, function PlayingDialogExpired)
endfunction
function CreateDialog2 takes nothing returns nothing
call ResetNumberOfPlayers()
call PlayingDialog()
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
function PlayerLeaves takes nothing returns nothing
local player p = GetTriggerPlayer()
local integer i = GetPlayerId(p)
local unit u = builders[i]
call RemoveUnit(u)
set startEarly[i] = true
set spectating[i] = 0
call BJDebugMsg(udg_playerColors[GetPlayerId(p)] + GetPlayerName(p) + udg_colorEnd + " has left the game")
if playerNumberOfWhoseTurn == i then
if afkTimerAlreadyOn == true then
call PauseTimer(shotClock)
call DestroyTimer(shotClock)
call DestroyTimerDialog(shotClockTD)
set shotClock = null
set shotClockTD = null
set afkTimerAlreadyOn = false
endif
set shotClock = CreateTimer()
set shotClockTD = CreateTimerDialog(shotClock)
call TimerStart(shotClock, 0., false, function ShotClockCleanUp)
endif
set p = null
endfunction
//===========================================================================
function InitTrig_Player_Leaves takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterPlayerEventLeave( t, Player(0) )
call TriggerRegisterPlayerEventLeave( t, Player(1) )
call TriggerRegisterPlayerEventLeave( t, Player(2) )
call TriggerRegisterPlayerEventLeave( t, Player(3) )
call TriggerRegisterPlayerEventLeave( t, Player(4) )
call TriggerRegisterPlayerEventLeave( t, Player(5) )
call TriggerRegisterPlayerEventLeave( t, Player(6) )
call TriggerRegisterPlayerEventLeave( t, Player(7) )
call TriggerRegisterPlayerEventLeave( t, Player(8) )
call TriggerRegisterPlayerEventLeave( t, Player(9) )
call TriggerRegisterPlayerEventLeave( t, Player(10) )
call TriggerRegisterPlayerEventLeave( t, Player(11) )
call TriggerAddAction( t, function PlayerLeaves)
endfunction
//TESH.scrollpos=149
//TESH.alwaysfold=0
library Shapes
globals
private integer MARKER = 'h002'
endglobals
function SetBuilding takes real x, real y returns nothing
local unit u
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), MARKER, x, y, 270)
call SetUnitAnimationByIndex(u, 1)
call UnitRemoveAbility(u, 'Amov')
set u = null
endfunction
function CreateAngledSquare takes integer tilesNE, integer tilesSE returns nothing // someCondition
local integer i = 0
local real GRID = 128
local real posX = 0 - ((tilesNE + tilesSE)/2) * GRID + GRID
local real posY = (0 - (tilesNE/2)*GRID) + ((tilesSE/2)* GRID)
local real markerX
local real markerY
loop
exitwhen i >= tilesNE
set markerX = posX + GRID * i
set markerY = posY + GRID * i
call SetBuilding(markerX, markerY)
set markerX = posX + (GRID * i) + (GRID * (tilesSE-1))
set markerY = posY + (GRID * i) - (GRID * (tilesSE-1))
call SetBuilding(markerX, markerY)
set i = i + 1
endloop
set i = 1
loop
exitwhen i >= tilesSE - 1
set markerX = posX + GRID * i
set markerY = posY - GRID * i
call SetBuilding(markerX, markerY)
set markerX = posX + GRID * i + GRID * (tilesNE-1)
set markerY = posY - GRID * i + GRID * (tilesNE-1)
call SetBuilding(markerX, markerY)
set i = i + 1
endloop
endfunction
function CreateTriangle takes integer side returns nothing // Can't use?
local integer i = 1
local integer offset
local integer halfTop = (side / 2)
local integer halfBot
if halfTop*2 != side then
set halfBot = -halfTop
else
set halfBot = (-side+1) / 2
endif
set halfBot = halfBot * 128
set halfTop = halfTop * 128
call SetBuilding(0, halfTop) // top
call SetBuilding(0, halfBot) // bottom
loop
exitwhen i >= side - 1
set offset = i * 128
call SetBuilding(-offset, halfTop-offset) // Left top
call SetBuilding(offset, halfTop - offset) // Right top
call SetBuilding(-offset, halfBot) // Left bottom
call SetBuilding(offset, halfBot) // Right bottom
set i = i + 1
endloop
call SetBuilding((-side+1)*128, halfBot) // Left corner
call SetBuilding((side-1)*128, halfBot) // Right corner
endfunction
function CreateX takes integer side returns nothing
local integer i = 1
local integer offset
local integer halfTop = (side / 2)
local integer halfBot
if halfTop*2 != side then
set halfBot = -halfTop
else
set halfBot = (-side+1) / 2
endif
set halfBot = halfBot * 128
set halfTop = halfTop * 128
call SetBuilding(0, halfTop) // middle
loop
exitwhen i >= side
set offset = i * 128
call SetBuilding(-offset, halfTop+offset) // top left
call SetBuilding(offset, halfTop+offset) // top right
call SetBuilding(-offset, halfTop-offset) // bot left
call SetBuilding(offset, halfTop - offset) // bot right
set i = i + 1
endloop
endfunction
function CreatePlus takes integer side returns nothing
local integer i = 1
local integer offset
call SetBuilding(0, 0) // middle
loop
exitwhen i >= side
set offset = i * 128
call SetBuilding(-offset, 0) // left
call SetBuilding(offset, 0) // right
call SetBuilding(0, offset) // up
call SetBuilding(0, -offset) // down
set i = i + 1
endloop
endfunction
function CreateRectangle takes integer width, integer height returns nothing // must be at least 3 in both dimensions
local integer boardSize = (width*2 + height*2 )-4
local integer currentBoardSize = 0
local integer whichDirection = 0
local integer direction
local real offsetX = 128 * (width/2)
local real offsetY = 128 * (height/2)
local real x = -offsetX
local real y = offsetY
loop
exitwhen currentBoardSize == boardSize
call SetBuilding(x,y)
if whichDirection == 0 then
set direction = 1 // right
elseif whichDirection == width -1 then
set direction = 2 // down
elseif whichDirection == width + height -2 then
set direction = 3 // left
elseif whichDirection == width + height + width-3 then
set direction = 4 // up
endif
if direction == 1 then
set x = x + 128
elseif direction == 2 then
set y = y - 128
elseif direction == 3 then
set x = x - 128
elseif direction == 4 then
set y = y + 128
endif
set currentBoardSize = currentBoardSize + 1
set whichDirection = whichDirection + 1
endloop
endfunction
function CreateZ takes integer size returns nothing // Probably shouldn't take an EVEN
local integer boardSize = (size *3)+2
local integer currentBoardSize = 0
local integer whichDirection = 0
local integer direction
local real x = 0
local real y = 0
call SetBuilding(x,y) // middle
loop
exitwhen currentBoardSize == boardSize/2
if whichDirection == 0 then
set direction = 1 // NE and SE
elseif whichDirection == size/2 then
set direction = 2 // up and down
elseif whichDirection == (size/2) + 2 then
set direction = 3 // left and right
endif
if direction == 1 then
set x = x + 128
set y = y + 128
elseif direction == 2 then
set y = y + 128
elseif direction == 3 then
set x = x - 128
endif
call SetBuilding(x,y)
call SetBuilding(-x,-y)
set currentBoardSize = currentBoardSize + 1
set whichDirection = whichDirection + 1
endloop
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library GF
function IsPlaying takes player p returns boolean
if ( GetPlayerController(p) == MAP_CONTROL_USER ) and ( GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING ) then
return true
endif
return false
endfunction
function WinSound takes unit u returns nothing
local integer i = GetUnitTypeId(u)
local integer Garithos = 'h003'
local integer PitLord = 'h007'
local integer Rexxar = 'h005'
local integer Tinker = 'h006'
local integer BladeMaster = 'h00B'
local integer Balnazzar = 'h00A'
local integer Maiev = 'h001'
local integer Sylvanas = 'h009'
local integer Jaina = 'h00F'
local integer Tyrande = 'h00E'
local integer Alchemist = 'h00C'
local integer Antonidas = 'h00D'
local sound line
if i == Garithos then
set line = gg_snd_GarithosWin
elseif i == PitLord then
set line = gg_snd_PitLordWin
elseif i == Rexxar then
set line = gg_snd_RexxarWin
elseif i == Tinker then
set line = gg_snd_TinkerWin
elseif i == BladeMaster then
set line =gg_snd_BladeMasterWin
elseif i == Balnazzar then
set line = gg_snd_DreadLordWin
elseif i == Maiev then
set line = gg_snd_MaievWin
elseif i == Sylvanas then
set line = gg_snd_SylvanasWin
elseif i == Jaina then
set line = gg_snd_JainaWin
elseif i == Tyrande then
set line = gg_snd_TyrandeWin
elseif i == Alchemist then
set line = gg_snd_AlchemistWin
elseif i == Antonidas then
set line = gg_snd_ArchMageWin
endif
call StartSound(line)
call SetSoundVolume(line, 200)
set line = null
endfunction
function SetAnimation takes unit u returns nothing
local integer i = GetUnitTypeId(u)
local integer index = 0
local integer Garithos = 'h003'
local integer PitLord = 'h007'
local integer Rexxar = 'h005'
local integer Tinker = 'h006'
local integer BladeMaster = 'h00B'
local integer Balnazzar = 'h00A'
local integer Maiev = 'h001'
local integer Sylvanas = 'h009'
local integer Jaina = 'h00F'
local integer Tyrande = 'h00E'
local integer Alchemist = 'h00C'
local integer Antonidas = 'h00D'
if i == Garithos then
set index = 0
elseif i == PitLord then
set index = 12
elseif i == Rexxar then
set index = 0
elseif i == Tinker then
set index = 0
elseif i == BladeMaster then
set index = 10
elseif i == Balnazzar then
set index = 2
elseif i == Maiev then
set index = 11
elseif i == Sylvanas then
set index = 8
elseif i == Jaina then
set index = 2
elseif i == Tyrande then
set index = 6
elseif i == Alchemist then
set index = 6
elseif i == Antonidas then
set index = 3
endif
call PauseUnit(u, true)
call SetUnitAnimationByIndex(u, index)
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Clear_Msg_Actions takes nothing returns nothing
local player p = GetTriggerPlayer()
if GetLocalPlayer() == p then
call ClearTextMessages()
endif
set p = null
endfunction
//===========================================================================
function InitTrig_Clear_Msg takes nothing returns nothing
set gg_trg_Clear_Msg = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Clear_Msg, Player(0), "-clear", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Clear_Msg, Player(1), "-clear", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Clear_Msg, Player(2), "-clear", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Clear_Msg, Player(3), "-clear", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Clear_Msg, Player(4), "-clear", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Clear_Msg, Player(5), "-clear", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Clear_Msg, Player(6), "-clear", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Clear_Msg, Player(7), "-clear", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Clear_Msg, Player(8), "-clear", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Clear_Msg, Player(9), "-clear", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Clear_Msg, Player(10), "-clear", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Clear_Msg, Player(11), "-clear", false )
call TriggerAddAction( gg_trg_Clear_Msg, function Trig_Clear_Msg_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function ChangeCamera takes nothing returns nothing
local player p = GetTriggerPlayer()
local string s = GetEventPlayerChatString()
local string s2 = SubString(s, 5, StringLength(s))
local real zoom = S2R(s2)
local real zoom2 = 0.
if zoom < 1000.00 or zoom > 8000.00 then
set zoom = 1650
call DisplayTextToPlayer(p, 0, 0, udg_playerColors[0] + ( "Error" + ( udg_colorEnd + "Your entered value was too small or large please choose something between 1000 and 8000. Resetting to Default (1650).")))
endif
if zoom > 3000. then
set zoom2 = 10000.
else
set zoom2 = 5000.
endif
if GetLocalPlayer() == p then
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, zoom, 0)
call SetCameraField(CAMERA_FIELD_FARZ, zoom2, 0)
endif
set p = null
endfunction
//===========================================================================
function InitTrig_Camera_Change takes nothing returns nothing
set gg_trg_Camera_Change = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Camera_Change, Player(0), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Camera_Change, Player(1), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Camera_Change, Player(2), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Camera_Change, Player(3), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Camera_Change, Player(4), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Camera_Change, Player(5), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Camera_Change, Player(6), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Camera_Change, Player(7), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Camera_Change, Player(8), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Camera_Change, Player(9), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Camera_Change, Player(10), "-cam", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Camera_Change, Player(11), "-cam", false )
call TriggerAddAction( gg_trg_Camera_Change, function ChangeCamera )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function ToggleSound takes nothing returns nothing
local player p = GetTriggerPlayer()
local string s = GetEventPlayerChatString()
local string s2 = SubString(s, 13, StringLength(s))
if s2 == "on" then
set shouldSound[GetPlayerId(p)] = true
call DisplayTextToPlayer(p, 0, 0, "You have toggled Turn Sounds " + udg_playerColors[4] + "on" + udg_colorEnd)
elseif s2 == "off" then
set shouldSound[GetPlayerId(p)] = false
call DisplayTextToPlayer(p, 0, 0, "You have toggled Turn Sounds " + udg_playerColors[4] + "off" + udg_colorEnd)
else
call DisplayTextToPlayer(p, 0, 0, udg_playerColors[0] + ( "Error" + ( udg_colorEnd + "You have entered an unacceptable command. Try either on or off.")))
endif
set p = null
endfunction
//===========================================================================
function InitTrig_ToggleSound takes nothing returns nothing
set gg_trg_ToggleSound = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_ToggleSound, Player(0), "-togglesound", false )
call TriggerRegisterPlayerChatEvent( gg_trg_ToggleSound, Player(1), "-togglesound", false )
call TriggerRegisterPlayerChatEvent( gg_trg_ToggleSound, Player(2), "-togglesound", false )
call TriggerRegisterPlayerChatEvent( gg_trg_ToggleSound, Player(3), "-togglesound", false )
call TriggerRegisterPlayerChatEvent( gg_trg_ToggleSound, Player(4), "-togglesound", false )
call TriggerRegisterPlayerChatEvent( gg_trg_ToggleSound, Player(5), "-togglesound", false )
call TriggerRegisterPlayerChatEvent( gg_trg_ToggleSound, Player(6), "-togglesound", false )
call TriggerRegisterPlayerChatEvent( gg_trg_ToggleSound, Player(7), "-togglesound", false )
call TriggerRegisterPlayerChatEvent( gg_trg_ToggleSound, Player(8), "-togglesound", false )
call TriggerRegisterPlayerChatEvent( gg_trg_ToggleSound, Player(9), "-togglesound", false )
call TriggerRegisterPlayerChatEvent( gg_trg_ToggleSound, Player(10), "-togglesound", false )
call TriggerRegisterPlayerChatEvent( gg_trg_ToggleSound, Player(11), "-togglesound", false )
call TriggerAddAction( gg_trg_ToggleSound, function ToggleSound )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function StopAttack takes nothing returns nothing
local unit u = GetAttacker()
call PauseUnit(u, true)
call IssueImmediateOrder(u, "stop")
call PauseUnit(u, false)
set u = null
endfunction
function InitTrig_Allow_Attack_Sound takes nothing returns nothing
local trigger myTrigger = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( myTrigger, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddAction( myTrigger, function StopAttack)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Dialog /* v.1.1.0.0
**************************************************
*
* A struct wrapper for easy dialog creation.
*
**************************************************
*
*/ requires Table /* [url]http://www.hiveworkshop.com/forums/jass-resources-412/snippet-new-table-188084/[/url]
*
**************************************************
*
* struct Dialog
*
* static method create() returns thistype
*
* Creates a new dialog and returns its instance.
*
* method operator title= takes string s
*
* Sets the title message for the dialog.
*
* method addButton( string text, integer hotkey ) returns button
*
* Adds a button to the dialog that reads <text>.
* The hotkey serves as a shortcut to press a dialog
* button. Example input: 'a', 'b', 512 (esc).
*
* method display( player p, boolean flag )
*
* Shows/hides a dialog for a particular player.
*
* method displayAll( boolean flag )
*
* Shows/hides a dialog for all players.
*
* method clear()
*
* Clears a dialog of its message and buttons.
*
* method destroy()
*
* Destroys a dialog and its instance.
*
* -- Event API --
*
* method registerClickEvent( boolexpr b )
*
* Registers when a dialog button is clicked.
*
* static method getClickedDialog() returns Dialog
* static method getClickedButton() returns button
* static method getPlayer() returns player
*
* Event responses.
*
**************************************************
*
* Constants - Credits to DysfunctionaI for the list!
*/
globals
constant integer KEY_SPACEBAR = 32
/* Number Pad */
constant integer KEY_NUMPAD_0 = 257
constant integer KEY_NUMPAD_1 = 258
constant integer KEY_NUMPAD_2 = 259
constant integer KEY_NUMPAD_3 = 260
constant integer KEY_NUMPAD_4 = 261
constant integer KEY_NUMPAD_5 = 262
constant integer KEY_NUMPAD_6 = 263
constant integer KEY_NUMPAD_7 = 264
constant integer KEY_NUMPAD_8 = 265
constant integer KEY_NUMPAD_9 = 266
constant integer KEY_NUMPAD_PLUS = 267
constant integer KEY_NUMPAD_MINUS = 268
constant integer KEY_NUMPAD_ASTERISK = 269
constant integer KEY_NUMPAD_SLASH = 270
constant integer KEY_NUMPAD_PERIOD = 271
constant integer KEY_EQUALS = 272
constant integer KEY_MINUS = 273
constant integer KEY_LEFT_BRACKET = 274
constant integer KEY_RIGHT_BRACKET = 275
constant integer KEY_BACKSLASH = 276
constant integer KEY_SEMICOLON = 277
constant integer KEY_APOSTROPHE = 278
constant integer KEY_COMMA = 279
constant integer KEY_PERIOD = 280
constant integer KEY_SLASH = 281
constant integer KEY_ESCAPE = 512
constant integer KEY_BACKSPACE = 514
/* Arrows */
constant integer KEY_LEFT_ARROW = 516
constant integer KEY_UP_ARROW = 517
constant integer KEY_RIGHT_ARROW = 518
constant integer KEY_DOWN_ARROW = 519
constant integer KEY_INSERT = 520
constant integer KEY_DELETE = 521
constant integer KEY_HOME = 522
constant integer KEY_END = 523
constant integer KEY_PAGE_UP = 524
constant integer KEY_PAGE_DOWN = 525
constant integer KEY_CAPS_LOCK = 526
constant integer KEY_NUM_LOCK = 527
constant integer KEY_SCROLL_LOCK = 528
constant integer KEY_PAUSE = 529
/* Function Buttons */
constant integer KEY_F1 = 768
constant integer KEY_F2 = 769
constant integer KEY_F3 = 770
constant integer KEY_F4 = 771
constant integer KEY_F5 = 772
constant integer KEY_F6 = 773
constant integer KEY_F7 = 774
constant integer KEY_F8 = 775
constant integer KEY_F9 = 776
constant integer KEY_F10 = 777
constant integer KEY_F11 = 778
constant integer KEY_F12 = 779
endglobals
/*
**************************************************/
globals
private Table instance = 0
endglobals
private module DialogInit
private static method onInit takes nothing returns nothing
set instance = Table.create()
endmethod
endmodule
struct Dialog
private dialog dg
private trigger click
private string msg
static method getClickedDialog takes nothing returns thistype
return instance[GetHandleId(GetClickedDialog())]
endmethod
static method getClickedButton takes nothing returns button
return GetClickedButton()
endmethod
static method getPlayer takes nothing returns player
return GetTriggerPlayer()
endmethod
method operator title= takes string text returns nothing
call DialogSetMessage(this.dg, text)
set this.msg = text
endmethod
method addButton takes string text, integer hotkey returns button
return DialogAddButton(this.dg, text, hotkey)
endmethod
method display takes player p, boolean flag returns nothing
call DialogDisplay(p, this.dg, flag)
call DialogSetMessage(this.dg, this.msg)
endmethod
method displayAll takes boolean flag returns nothing
call DialogDisplay(GetLocalPlayer(), this.dg, flag)
call DialogSetMessage(this.dg, this.msg)
endmethod
method clear takes nothing returns nothing
call DialogClear(this.dg)
set this.msg = ""
endmethod
method registerClickEvent takes boolexpr b returns nothing
if this.click == null then
set instance[GetHandleId(this.dg)] = this
set this.click = CreateTrigger()
call TriggerRegisterDialogEvent(this.click, this.dg)
endif
call TriggerAddCondition(this.click, b)
endmethod
method destroy takes nothing returns nothing
debug if this.dg == null then
debug call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "[Dialog] Attempted to destroy null dialog.")
debug endif
if this.click != null then
call DestroyTrigger(this.click)
call instance.remove(GetHandleId(this.dg))
set this.click = null
endif
call DialogClear(this.dg)
call DialogDestroy(this.dg)
set this.dg = null
call this.deallocate()
endmethod
static method create takes nothing returns thistype
local thistype this = thistype.allocate()
set this.dg = DialogCreate()
return this
endmethod
implement DialogInit
endstruct
endlibrary
//TESH.scrollpos=11
//TESH.alwaysfold=0
library SimError initializer init
//**************************************************************************************************
//*
//* SimError
//*
//* Mimic an interface error message
//* call SimError(ForPlayer, msg)
//* ForPlayer : The player to show the error
//* msg : The error
//*
//* To implement this function, copy this trigger and paste it in your map.
//* Unless of course you are actually reading the library from wc3c's scripts section, then just
//* paste the contents into some custom text trigger in your map.
//*
//**************************************************************************************************
//==================================================================================================
globals
private sound error
endglobals
//====================================================================================================
function SimError takes player ForPlayer, string msg returns nothing
set msg="\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+msg+"|r"
if (GetLocalPlayer() == ForPlayer) then
call ClearTextMessages()
call DisplayTimedTextToPlayer( ForPlayer, 0.52, 0.96, 2.00, msg )
call StartSound( error )
endif
endfunction
private function init takes nothing returns nothing
set error=CreateSoundFromLabel("InterfaceError",false,false,false,10,10)
//call StartSound( error ) //apparently the bug in which you play a sound for the first time
//and it doesn't work is not there anymore in patch 1.22
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Table /* made by Bribe, special thanks to Vexorian & Nestharus, version 4.1.0.1.
One map, one hashtable. Welcome to NewTable 4.1.0.1
This newest iteration of Table introduces the new HashTable struct.
You can now instantiate HashTables which enables the use of large
parent and large child keys, just like a standard hashtable. Previously,
the user would have to instantiate a Table to do this on their own which -
while doable - is something the user should not have to do if I can add it
to this resource myself (especially if they are inexperienced).
This library was originally called NewTable so it didn't conflict with
the API of Table by Vexorian. However, the damage is done and it's too
late to change the library name now. To help with damage control, I
have provided an extension library called TableBC, which bridges all
the functionality of Vexorian's Table except for 2-D string arrays &
the ".flush(integer)" method. I use ".flush()" to flush a child hash-
table, because I wanted the API in NewTable to reflect the API of real
hashtables (I thought this would be more intuitive).
API
------------
struct Table
| static method create takes nothing returns Table
| create a new Table
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush all stored values inside of it
|
| method remove takes integer key returns nothing
| remove the value at index "key"
|
| method operator []= takes integer key, $TYPE$ value returns nothing
| assign "value" to index "key"
|
| method operator [] takes integer key returns $TYPE$
| load the value at index "key"
|
| method has takes integer key returns boolean
| whether or not the key was assigned
|
----------------
struct TableArray
| static method operator [] takes integer array_size returns TableArray
| create a new array of Tables of size "array_size"
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush and destroy it
|
| method operator size takes nothing returns integer
| returns the size of the TableArray
|
| method operator [] takes integer key returns Table
| returns a Table accessible exclusively to index "key"
*/
globals
private integer less = 0 //Index generation for TableArrays (below 0).
private integer more = 8190 //Index generation for Tables.
//Configure it if you use more than 8190 "key" variables in your map (this will never happen though).
private hashtable ht = InitHashtable()
private key sizeK
private key listK
endglobals
private struct dex extends array
static method operator size takes nothing returns Table
return sizeK
endmethod
static method operator list takes nothing returns Table
return listK
endmethod
endstruct
private struct handles extends array
method has takes integer key returns boolean
return HaveSavedHandle(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSavedHandle(ht, this, key)
endmethod
endstruct
private struct agents extends array
method operator []= takes integer key, agent value returns nothing
call SaveAgentHandle(ht, this, key, value)
endmethod
endstruct
//! textmacro NEW_ARRAY_BASIC takes SUPER, FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$(ht, this, key, value)
endmethod
method has takes integer key returns boolean
return HaveSaved$SUPER$(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSaved$SUPER$(ht, this, key)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//! textmacro NEW_ARRAY takes FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$Handle(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$Handle(ht, this, key, value)
endmethod
method has takes integer key returns boolean
return HaveSavedHandle(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSavedHandle(ht, this, key)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//Run these textmacros to include the entire hashtable API as wrappers.
//Don't be intimidated by the number of macros - Vexorian's map optimizer is
//supposed to kill functions which inline (all of these functions inline).
//! runtextmacro NEW_ARRAY_BASIC("Real", "Real", "real")
//! runtextmacro NEW_ARRAY_BASIC("Boolean", "Boolean", "boolean")
//! runtextmacro NEW_ARRAY_BASIC("String", "Str", "string")
//New textmacro to allow table.integer[] syntax for compatibility with textmacros that might desire it.
//! runtextmacro NEW_ARRAY_BASIC("Integer", "Integer", "integer")
//! runtextmacro NEW_ARRAY("Player", "player")
//! runtextmacro NEW_ARRAY("Widget", "widget")
//! runtextmacro NEW_ARRAY("Destructable", "destructable")
//! runtextmacro NEW_ARRAY("Item", "item")
//! runtextmacro NEW_ARRAY("Unit", "unit")
//! runtextmacro NEW_ARRAY("Ability", "ability")
//! runtextmacro NEW_ARRAY("Timer", "timer")
//! runtextmacro NEW_ARRAY("Trigger", "trigger")
//! runtextmacro NEW_ARRAY("TriggerCondition", "triggercondition")
//! runtextmacro NEW_ARRAY("TriggerAction", "triggeraction")
//! runtextmacro NEW_ARRAY("TriggerEvent", "event")
//! runtextmacro NEW_ARRAY("Force", "force")
//! runtextmacro NEW_ARRAY("Group", "group")
//! runtextmacro NEW_ARRAY("Location", "location")
//! runtextmacro NEW_ARRAY("Rect", "rect")
//! runtextmacro NEW_ARRAY("BooleanExpr", "boolexpr")
//! runtextmacro NEW_ARRAY("Sound", "sound")
//! runtextmacro NEW_ARRAY("Effect", "effect")
//! runtextmacro NEW_ARRAY("UnitPool", "unitpool")
//! runtextmacro NEW_ARRAY("ItemPool", "itempool")
//! runtextmacro NEW_ARRAY("Quest", "quest")
//! runtextmacro NEW_ARRAY("QuestItem", "questitem")
//! runtextmacro NEW_ARRAY("DefeatCondition", "defeatcondition")
//! runtextmacro NEW_ARRAY("TimerDialog", "timerdialog")
//! runtextmacro NEW_ARRAY("Leaderboard", "leaderboard")
//! runtextmacro NEW_ARRAY("Multiboard", "multiboard")
//! runtextmacro NEW_ARRAY("MultiboardItem", "multiboarditem")
//! runtextmacro NEW_ARRAY("Trackable", "trackable")
//! runtextmacro NEW_ARRAY("Dialog", "dialog")
//! runtextmacro NEW_ARRAY("Button", "button")
//! runtextmacro NEW_ARRAY("TextTag", "texttag")
//! runtextmacro NEW_ARRAY("Lightning", "lightning")
//! runtextmacro NEW_ARRAY("Image", "image")
//! runtextmacro NEW_ARRAY("Ubersplat", "ubersplat")
//! runtextmacro NEW_ARRAY("Region", "region")
//! runtextmacro NEW_ARRAY("FogState", "fogstate")
//! runtextmacro NEW_ARRAY("FogModifier", "fogmodifier")
//! runtextmacro NEW_ARRAY("Hashtable", "hashtable")
struct Table extends array
// Implement modules for intuitive syntax (tb.handle; tb.unit; etc.)
implement realm
implement integerm
implement booleanm
implement stringm
implement playerm
implement widgetm
implement destructablem
implement itemm
implement unitm
implement abilitym
implement timerm
implement triggerm
implement triggerconditionm
implement triggeractionm
implement eventm
implement forcem
implement groupm
implement locationm
implement rectm
implement boolexprm
implement soundm
implement effectm
implement unitpoolm
implement itempoolm
implement questm
implement questitemm
implement defeatconditionm
implement timerdialogm
implement leaderboardm
implement multiboardm
implement multiboarditemm
implement trackablem
implement dialogm
implement buttonm
implement texttagm
implement lightningm
implement imagem
implement ubersplatm
implement regionm
implement fogstatem
implement fogmodifierm
implement hashtablem
method operator handle takes nothing returns handles
return this
endmethod
method operator agent takes nothing returns agents
return this
endmethod
//set this = tb[GetSpellAbilityId()]
method operator [] takes integer key returns Table
return LoadInteger(ht, this, key) //return this.integer[key]
endmethod
//set tb[389034] = 8192
method operator []= takes integer key, Table tb returns nothing
call SaveInteger(ht, this, key, tb) //set this.integer[key] = tb
endmethod
//set b = tb.has(2493223)
method has takes integer key returns boolean
return HaveSavedInteger(ht, this, key) //return this.integer.has(key)
endmethod
//call tb.remove(294080)
method remove takes integer key returns nothing
call RemoveSavedInteger(ht, this, key) //call this.integer.remove(key)
endmethod
//Remove all data from a Table instance
method flush takes nothing returns nothing
call FlushChildHashtable(ht, this)
endmethod
//local Table tb = Table.create()
static method create takes nothing returns Table
local Table this = dex.list[0]
if this == 0 then
set this = more + 1
set more = this
else
set dex.list[0] = dex.list[this]
call dex.list.remove(this) //Clear hashed memory
endif
debug set dex.list[this] = -1
return this
endmethod
// Removes all data from a Table instance and recycles its index.
//
// call tb.destroy()
//
method destroy takes nothing returns nothing
debug if dex.list[this] != -1 then
debug call BJDebugMsg("Table Error: Tried to double-free instance: " + I2S(this))
debug return
debug endif
call this.flush()
set dex.list[this] = dex.list[0]
set dex.list[0] = this
endmethod
//! runtextmacro optional TABLE_BC_METHODS()
endstruct
//! runtextmacro optional TABLE_BC_STRUCTS()
struct TableArray extends array
//Returns a new TableArray to do your bidding. Simply use:
//
// local TableArray ta = TableArray[array_size]
//
static method operator [] takes integer array_size returns TableArray
local Table tb = dex.size[array_size] //Get the unique recycle list for this array size
local TableArray this = tb[0] //The last-destroyed TableArray that had this array size
debug if array_size <= 0 then
debug call BJDebugMsg("TypeError: Invalid specified TableArray size: " + I2S(array_size))
debug return 0
debug endif
if this == 0 then
set this = less - array_size
set less = this
else
set tb[0] = tb[this] //Set the last destroyed to the last-last destroyed
call tb.remove(this) //Clear hashed memory
endif
set dex.size[this] = array_size //This remembers the array size
return this
endmethod
//Returns the size of the TableArray
method operator size takes nothing returns integer
return dex.size[this]
endmethod
//This magic method enables two-dimensional[array][syntax] for Tables,
//similar to the two-dimensional utility provided by hashtables them-
//selves.
//
//ta[integer a].unit[integer b] = unit u
//ta[integer a][integer c] = integer d
//
//Inline-friendly when not running in debug mode
//
method operator [] takes integer key returns Table
static if DEBUG_MODE then
local integer i = this.size
if i == 0 then
call BJDebugMsg("IndexError: Tried to get key from invalid TableArray instance: " + I2S(this))
return 0
elseif key < 0 or key >= i then
call BJDebugMsg("IndexError: Tried to get key [" + I2S(key) + "] from outside TableArray bounds: " + I2S(i))
return 0
endif
endif
return this + key
endmethod
//Destroys a TableArray without flushing it; I assume you call .flush()
//if you want it flushed too. This is a public method so that you don't
//have to loop through all TableArray indices to flush them if you don't
//need to (ie. if you were flushing all child-keys as you used them).
//
method destroy takes nothing returns nothing
local Table tb = dex.size[this.size]
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to destroy an invalid TableArray: " + I2S(this))
debug return
debug endif
if tb == 0 then
//Create a Table to index recycled instances with their array size
set tb = Table.create()
set dex.size[this.size] = tb
endif
call dex.size.remove(this) //Clear the array size from hash memory
set tb[this] = tb[0]
set tb[0] = this
endmethod
private static Table tempTable
private static integer tempEnd
//Avoids hitting the op limit
private static method clean takes nothing returns nothing
local Table tb = .tempTable
local integer end = tb + 0x1000
if end < .tempEnd then
set .tempTable = end
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
else
set end = .tempEnd
endif
loop
call tb.flush()
set tb = tb + 1
exitwhen tb == end
endloop
endmethod
//Flushes the TableArray and also destroys it. Doesn't get any more
//similar to the FlushParentHashtable native than this.
//
method flush takes nothing returns nothing
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to flush an invalid TableArray instance: " + I2S(this))
debug return
debug endif
set .tempTable = this
set .tempEnd = this + this.size
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
call this.destroy()
endmethod
endstruct
//NEW: Added in Table 4.0. A fairly simple struct but allows you to do more
//than that which was previously possible.
struct HashTable extends array
//Enables myHash[parentKey][childKey] syntax.
//Basically, it creates a Table in the place of the parent key if
//it didn't already get created earlier.
method operator [] takes integer index returns Table
local Table t = Table(this)[index]
if t == 0 then
set t = Table.create()
set Table(this)[index] = t //whoops! Forgot that line. I'm out of practice!
endif
return t
endmethod
//You need to call this on each parent key that you used if you
//intend to destroy the HashTable or simply no longer need that key.
method remove takes integer index returns nothing
local Table t = Table(this)[index]
if t != 0 then
call t.destroy()
call Table(this).remove(index)
endif
endmethod
//Added in version 4.1
method has takes integer index returns boolean
return Table(this).has(index)
endmethod
//HashTables are just fancy Table indices.
method destroy takes nothing returns nothing
call Table(this).destroy()
endmethod
//Like I said above...
static method create takes nothing returns thistype
return Table.create()
endmethod
endstruct
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Hello_Actions takes nothing returns nothing
local group g = CreateGroup()
local unit u
local string s = GetEventPlayerChatString()
local integer i = S2I(s)
call GroupEnumUnitsOfPlayer(g, Player(0), null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
call SetUnitAnimationByIndex(u, i)
endloop
endfunction
//===========================================================================
function InitTrig_Animation_Check takes nothing returns nothing
set gg_trg_Animation_Check = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Animation_Check, Player(0), "", false )
call TriggerAddAction( gg_trg_Animation_Check, function Trig_Hello_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Debug
function Debug takes string s returns nothing
//call BJDebugMsg("fired")
if udg_DebugMode == true then
call DisplayTimedTextToForce(udg_DebugForce, 300., s)
endif
endfunction
endlibrary
//TESH.scrollpos=2
//TESH.alwaysfold=0
function Trig_Debug_Enable_Actions takes nothing returns nothing
if udg_DebugForce == null then
set udg_DebugForce = CreateForce()
set udg_DebugMode = true
endif
if IsPlayerInForce(GetTriggerPlayer(), udg_DebugForce) == false then
call ForceAddPlayer(udg_DebugForce, GetTriggerPlayer())
call DisplayTextToPlayer(GetTriggerPlayer(), 0 , 0, "You will now get debug messages")
else
call ForceRemovePlayer(udg_DebugForce, GetTriggerPlayer())
call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, "You will no longer get debug messages")
if CountPlayersInForceBJ(udg_DebugForce) <= 0 then
call DestroyForce(udg_DebugForce)
set udg_DebugForce = null
set udg_DebugMode = false
endif
endif
endfunction
//===========================================================================
function InitTrig_Debug_Enable takes nothing returns nothing
set gg_trg_Debug_Enable = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Enable, Player(0), "-debug", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Enable, Player(1), "-debug", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Enable, Player(2), "-debug", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Enable, Player(3), "-debug", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Enable, Player(4), "-debug", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Enable, Player(5), "-debug", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Enable, Player(6), "-debug", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Enable, Player(7), "-debug", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Enable, Player(8), "-debug", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Enable, Player(9), "-debug", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Enable, Player(10), "-debug", true )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Enable, Player(11), "-debug", true )
call TriggerAddAction( gg_trg_Debug_Enable, function Trig_Debug_Enable_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Dialog222 //initializer CreateDialog
globals
private button array buttons
endglobals
function IsPlaying takes player p returns boolean
if ( GetPlayerController(p) == MAP_CONTROL_USER ) and ( GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING ) then
return true
endif
return false
endfunction
function WhichButton takes nothing returns boolean
local dialog d = GetClickedDialog()
local button b = GetClickedButton()
local group g = CreateGroup()
local unit u
local player p = GetTriggerPlayer()
local integer i = GetPlayerId(p)
if b == buttons[0] then
if udg_TooLate == true then
set udg_Spectating[i] = 0
call DisplayTextToPlayer(p, 0, 0, "You were too late, you will be able to play next game")
else
set udg_Spectating[i] = 1
endif
elseif b == buttons[1] then
set udg_StartEarly[i] = true
set udg_Spectating[i] = 0
set g = GetUnitsOfPlayerMatching(p, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
call RemoveUnit(u)
endloop
endif
call DialogDisplay(p, d, false)
call DestroyGroup(g)
set b = null
set u = null
set g = null
return false
endfunction
function ShowDialog takes nothing returns nothing
local dialog d = DialogCreate()
local integer i = 0
local trigger t = CreateTrigger()
local player p
call DialogSetMessage(d, "Welcome to Advanced Tic-Tac-Toe\n Would you like to play?")
set buttons[0] = DialogAddButton(d,"Yes " + "[Y]", 'Y')
set buttons[1] = DialogAddButton(d,"No, I'll Observe (Lasts 1 Game) " + "[N]", 'N')
loop
exitwhen i > 11
set p = Player(i)
if IsPlaying(p) == true then
call DialogDisplay(p, d, true)
else
endif
set i = i + 1
endloop
call TriggerRegisterDialogEvent(t, d)
call TriggerAddCondition(t, Condition(function WhichButton))
set d = null
set t = null
set p = null
endfunction
function CreateDialog takes nothing returns nothing
call TimerStart(CreateTimer(), 0, false, function ShowDialog)
endfunction
endlibrary
//TESH.scrollpos=162
//TESH.alwaysfold=0
library GameStart requires Turns
globals
private timer t
private timer t2
private timerdialog b
private unit Tavern
private group selectors
private integer count = 0
endglobals
function TurnSelect takes nothing returns nothing
local integer i = GetRandomInt(0, 11)
set udg_PlayerNumberOfWhoseTurn = i
loop
if IsPlaying(Player(i)) == true and udg_Spectating[i] == 1 then
set udg_PlayerNumberOfWhoseTurn = i
call BJDebugMsg(udg_playerColors[udg_PlayerNumberOfWhoseTurn] + GetPlayerName(Player(udg_PlayerNumberOfWhoseTurn)) + udg_colorEnd + " was randomly selected to go first")
return
else
if i == 11 then
set i = GetRandomInt(0, 10)
else
set i = i + 1
endif
endif
endloop
endfunction
function AtleastTwo takes group g returns boolean
local integer i = 0
local unit u
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
set i = i + 1
endloop
if i >= 2 then
set u = null
return true
else
set u = null
return false
endif
endfunction
function BoardSetUp takes nothing returns nothing
local unit u
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h002', 0, 0, 270)
call SetUnitAnimationByIndex(u, 1)
call UnitRemoveAbility(u, 'Amov')
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h002', 0, 128, 270)
call SetUnitAnimationByIndex(u, 1)
call UnitRemoveAbility(u, 'Amov')
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h002', -128, 128, 270)
call SetUnitAnimationByIndex(u, 1)
call UnitRemoveAbility(u, 'Amov')
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h002', 128, 128, 270)
call SetUnitAnimationByIndex(u, 1)
call UnitRemoveAbility(u, 'Amov')
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h002', -128, 0, 270)
call SetUnitAnimationByIndex(u, 1)
call UnitRemoveAbility(u, 'Amov')
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h002', 128, 0, 270)
call SetUnitAnimationByIndex(u, 1)
call UnitRemoveAbility(u, 'Amov')
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h002', -128, -128, 270)
call SetUnitAnimationByIndex(u, 1)
call UnitRemoveAbility(u, 'Amov')
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h002', 128, -128, 270)
call SetUnitAnimationByIndex(u, 1)
call UnitRemoveAbility(u, 'Amov')
set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h002', 0, -128, 270)
call SetUnitAnimationByIndex(u, 1)
call UnitRemoveAbility(u, 'Amov')
set u = null
endfunction
function AutoSelect takes nothing returns nothing
local integer i = 0
local integer i2 = GetRandomInt(1, 12)
local integer Garithos = 'h003'
local integer PitLord = 'h007'
local integer Rexxar = 'h005'
local integer Tinker = 'h006'
local integer BladeMaster = 'h00B'
local integer Balnazzar = 'h00A'
local integer Maiev = 'h001'
local integer Sylvanas = 'h009'
local integer Jaina = 'h00F'
local integer Tyrande = 'h00E'
local integer Alchemist = 'h00C'
local integer Antonidas = 'h00D'
local integer whichMarker
loop
exitwhen i > 11
if udg_UnitIdForMarkers[i] == 0 then
if i2 == 1 then
set whichMarker = Garithos
elseif i2 == 2 then
set whichMarker = PitLord
elseif i2 == 3 then
set whichMarker = Rexxar
elseif i2 == 4 then
set whichMarker = Tinker
elseif i2 == 5 then
set whichMarker = BladeMaster
elseif i2 == 6 then
set whichMarker = Balnazzar
elseif i2 == 7 then
set whichMarker = Maiev
elseif i2 == 8 then
set whichMarker = Sylvanas
elseif i2 == 9 then
set whichMarker = Jaina
elseif i2 == 10 then
set whichMarker = Tyrande
elseif i2 == 11 then
set whichMarker = Alchemist
elseif i2 == 12 then
set whichMarker = Antonidas
endif
set udg_UnitIdForMarkers[i] = whichMarker
call DisplayTextToPlayer(Player(i), 0,0, "You randomed " + udg_playerColors[6] + GetObjectName(whichMarker) + udg_colorEnd + " as your marker.")
endif
set i = i + 1
endloop
endfunction
function StartEarly takes nothing returns boolean
local integer i = 0
local integer i2 = 0
loop
exitwhen i > 11
if udg_StartEarly[i] == true then
set i2 = i2 + 1
else
endif
if i2 == 12 then
//call BJDebugMsg("Everyone picked, going early")
return true
endif
set i = i + 1
endloop
return false
endfunction
function RemoveSelectors takes nothing returns nothing
local unit u
loop
set u = FirstOfGroup(selectors)
exitwhen u == null
call RemoveUnit(u)
call GroupRemoveUnit(selectors, u)
endloop
call DestroyGroup(selectors)
set u = null
set selectors = null
endfunction
function CreateBuilders takes nothing returns group
local integer i = 0
local unit u2
local group g = CreateGroup()
loop
exitwhen i > 11
if IsPlaying(Player(i)) and udg_Spectating[i] == 1 then
set u2 = CreateUnit(Player(i), 'h004', 0, 0, 270)
set udg_Builders[GetPlayerId(Player(i))] = u2
call GroupAddUnit(g, u2)
call SelectUnitForPlayerSingle(u2, Player(i))
set udg_ToggleBuilding[GetPlayerId(Player(i))] = CreateUnit(Player(i), 'H008', 0, 0 , 270)
call KillUnit(udg_ToggleBuilding[GetPlayerId(Player(i))])
endif
set i = i + 1
endloop
set u2 = null
return g
endfunction
function CleanUpStart takes nothing returns nothing
local integer i = 0
local group g
local boolean check
set count = count + 1
call EnableSelect(true, true) // I think this is necessary, although I haven't needed it. How? If a new game starts players ought to be prevented, haven't had the problem though? Why.
if StartEarly() == true or count == 30 then
set udg_TooLate = true
call RemoveUnit(Tavern)
call PauseTimer(t)
call DestroyTimer(t)
call PauseTimer(t2)
call DestroyTimer(t2)
call DestroyTimerDialog(b)
call RemoveSelectors()
call AutoSelect()
call BoardSetUp()
call SetGoldToTurns(false)
set g = CreateBuilders()
set check = AtleastTwo(g)
set udg_PreGame = false
set count = 0
set check = true
if check == true then
call TurnSelect()
call PreventPlay()
set t = null
set t2 = null
set b = null
call DestroyGroup(g)
set g = null
else
call BJDebugMsg(udg_playerColors[0] + "Error" + udg_colorEnd + " Not enough people are playing, must be at least" + udg_playerColors[4] + " 2")
//Rerun starting functions
set t = null
set t2 = null
set b = null
call DestroyGroup(g)
set g = null
call TriggerExecute(gg_trg_Restart)
endif
endif
endfunction
function GameStart takes nothing returns nothing
local unit u
local integer i = 0
set selectors = CreateGroup()
set Tavern = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'n000', 0, 0, 270)
set t = CreateTimer()
set t2 = CreateTimer()
set b = CreateTimerDialog(t2)
call TimerStart(t, 1., true, function CleanUpStart)
call TimerStart(t2, 30., false, null)
call TimerDialogDisplay(b, true)
call TimerDialogSetTitle(b, "Time To Pick")
loop
exitwhen i > 11
if IsPlaying(Player(i)) then
set u = CreateUnit(Player(i), 'h000', 0, 0, 270)
call GroupAddUnit(selectors, u)
call SelectUnitForPlayerSingle(Tavern, Player(i))
else
set udg_StartEarly[i] = true
endif
set i = i + 1
endloop
set u = null
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
//scope Testing initializer Init
library Dialog2 initializer Init
globals
private button array buttons
endglobals
private function DialogEvent takes nothing returns boolean
local Dialog log = Dialog.getClickedDialog()
local button b = Dialog.getClickedButton()
local group g = CreateGroup()
local unit u
if b == buttons[0] then
if udg_TooLate == true then
set udg_Spectating[GetPlayerId(GetTriggerPlayer())] = 0
call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, "You were too late, you will be able to play next game")
else
set udg_Spectating[GetPlayerId(GetTriggerPlayer())] = 1
endif
elseif b == buttons[1] then
set udg_Spectating[GetPlayerId(GetTriggerPlayer())] = 0
set g = GetUnitsOfPlayerMatching(GetTriggerPlayer(), null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
call RemoveUnit(u)
endloop
endif
call DestroyGroup(g)
set u = null
set g = null
call log.destroy()
set b = null
return false
endfunction
private function AppendHotkey takes string source, string hotkey returns string
return "|cffffcc00[" + hotkey + "]|r " + source
endfunction
private function DialogTest takes nothing returns nothing
local Dialog log = Dialog.create()
set log.title = "someTitle"
set buttons[0] = log.addButton(AppendHotkey("Play", "A"), 'A')
set buttons[1] = log.addButton(AppendHotkey("Observe (Not Permanent)", "B"), 'B')
call log.displayAll(true)
call log.registerClickEvent(Condition(function DialogEvent))
endfunction
function Init takes nothing returns nothing
call TimerStart(CreateTimer(), 0, false, function DialogTest)
endfunction
//endscope
endlibrary
//TESH.scrollpos=45
//TESH.alwaysfold=0
//Checks every 90 degrees if there is a structure to allow building, otherwise aborts building.
// Not sure exactly why it works even when the lines are not perfect i.e building one on the line of 2 others [][]
// See Pic. []
function BuildNewSquare_Conditions takes nothing returns boolean
local unit u = GetConstructingStructure()
local unit u2
local group g
local group g2
// local group g3
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local player p = GetOwningPlayer(u)
local integer i = 0
local integer i2 = 0
local real offset
local real offset2
local boolean b = false
loop
exitwhen b == true or i == 5
set g = CreateGroup()
set g2 = CreateGroup()
set i = i+1
set i2 = 0
if i == 5 then
call SimError(p, "Unable to build there, select a spot that connects along a side")
call KillUnit(u)
else
if i == 1 then
set offset = 0.
set offset2 = 128.
elseif i == 2 then
set offset = 128.
set offset2 = 0.
elseif i == 3 then
set offset = 0.
set offset2 = -128.
elseif i == 4 then
set offset = -128.
set offset2 = 0.
endif
call GroupEnumUnitsInRange(g, x+offset, y+offset2, 10., Condition(function BuildingsOnly))
set g2 = g
loop
set u2 = FirstOfGroup(g2)
exitwhen u2 == null
call GroupRemoveUnit(g, u2)
set i2 = i2 + 1
endloop
endif
// Decides whether to keep searching or exit
if i2 < 1 then
else
// If exiting, it was a legal move, check to see if player encapsulated a spot
set b = true
// call GroupEnumUnitsInRange(g3, x, y, 10., Condition(function BuildingsOnly))
if IsSpotSurrounded(x, y) == false then
call Detect(p, x, y)
else
call BJDebugMsg("Skipped creating/claiming because it was already occupied")
endif
endif
call DestroyGroup(g)
call DestroyGroup(g2)
// call DestroyGroup(g3)
endloop
call UnitRemoveAbility(u, 'Amov')
call SetUnitOwner(u, Player(PLAYER_NEUTRAL_PASSIVE), true)
set u = null
set u2 = null
set g = null
set g2 = null
set p = null
return true
endfunction
function BuildNewSquare_Actions takes nothing returns nothing
endfunction
function InitTrig_Build_New_Square_Old takes nothing returns nothing
local trigger myTrigger = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( myTrigger, EVENT_PLAYER_UNIT_CONSTRUCT_START )
call TriggerAddCondition(myTrigger, Condition(function BuildNewSquare_Conditions))
call TriggerAddAction( myTrigger, function BuildNewSquare_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Untitled_Trigger_006_Actions takes nothing returns nothing
call BJDebugMsg("Order ID: " + I2S(GetIssuedOrderId()))
endfunction
//===========================================================================
function InitTrig_Order_Id_Detector takes nothing returns nothing
set gg_trg_Order_Id_Detector = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Order_Id_Detector, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Order_Id_Detector, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Order_Id_Detector, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerAddAction( gg_trg_Order_Id_Detector, function Trig_Untitled_Trigger_006_Actions )
endfunction
//TESH.scrollpos=84
//TESH.alwaysfold=0
library Detection initializer init
// Checks to make sure that the units being searched for are buildings only.
//function Filter_Condition takes nothing returns boolean
//return (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == true)
//endfunction
function Detection takes player pl, real x1, real y1 returns nothing
local group g
local unit u
local unit u2
local integer i = 0 // spots to check
local integer i2 = 0 // spots around the spot to check
local integer i3 = 0 // counter of buildings that surround a spot if == 4 then do
local real offset
local real offset2
local boolean b = false
loop
exitwhen b == true or i == 5
set i = i+1
set i3 = 0
if i == 5 then
// We've checked all spots and all sides. No enclosed spot found
else
call BJDebugMsg("main loop " + I2S(i))
if i == 1 then
set x1 = x1 + 0.
set y1 = y1 + 128.
// call CreateUnit(Player(0), 'hgry', x1, y1, 270)
//call BJDebugMsg("x: " + R2S(x1) + "y: " + R2S(y1))
elseif i == 2 then
set x1 = x1 + 128.
set y1 = y1 - 128.
// call CreateUnit(Player(0), 'hgry', x1, y1, 270)
elseif i == 3 then
set x1 = x1 - 128.
set y1 = y1 - 128.
// call CreateUnit(Player(0), 'hgry', x1, y1, 270)
elseif i == 4 then
set x1 = x1 - 128.
set y1 = y1 + 128.
// call CreateUnit(Player(0), 'hgry', x1, y1, 270)
endif
loop
exitwhen i2 == 4
set g = CreateGroup()
set i2 = i2 + 1
if i2 == 5 then
// exit it doesn't enclose
else
if i2 == 1 then
set offset = 0.
set offset2 = 128.
elseif i2 == 2 then
set offset = 128.
set offset2 = 0.
elseif i2 == 3 then
set offset = 0.
set offset2 = -128.
elseif i2 == 4 then
set offset = -128.
set offset2 = 0.
endif
endif
call BJDebugMsg("x: " + R2S(x1+offset) + " y: " + R2S(y1+offset2))
// call CreateUnit(Player(0), 'hgry', x1+offset, y1+offset2, 270)
call GroupEnumUnitsInRange(g, x1+offset, y1+offset2, 10., Condition(function Filter_Condition))
set u = FirstOfGroup(g)
//call SetUnitVertexColor(u, 10, 100, 100, 100)
if u == null then // if u is null then it's an empty spot, do nothing, if there is a building then incrememnt.
call BJDebugMsg("U was null")
else
set i3 = i3 + 1
if i3 == 4 then // If i3 is 4 then that means there is something around each side meaning its been enclosed!
set b = true
else
endif
endif
call BJDebugMsg("4 to close" + I2S(i3))
//call BJDebugMsg(GetUnitName(u))
call DestroyGroup(g)
endloop
endif
endloop
if b == true then
set u2 = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h002', x1, y1, 270)
//call IssueNeutralTargetOrderById(
call SelectUnitForPlayerSingle(u2, pl)
call ForceUIKeyBJ(pl, "C")
// claim the spot for the player.
else
endif
set g = null
set u = null
set u2 = null
call BJDebugMsg("Exited")
endfunction
private function init takes nothing returns nothing
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Remove takes nothing returns nothing
call RemoveItem(GetSoldItem())
endfunction
function InitTrig_Remove_Item takes nothing returns nothing
local trigger myTrigger = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( myTrigger, EVENT_PLAYER_UNIT_SELL_ITEM )
call TriggerAddAction( myTrigger, function Remove )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function WrongTurnConditions takes nothing returns boolean
if udg_PlayerNumberOfWhoseTurn == GetPlayerId(GetOwningPlayer(GetBuyingUnit())) then
return false
else
return true
endif
endfunction
function WrongTurnActions takes nothing returns nothing
local player p = GetOwningPlayer(GetBuyingUnit())
call DisplayTextToPlayer(p, 0, 0, (udg_playerColors[1]+ "It is not your turn."))
set p = null
endfunction
function InitTrig_Wrong_Turn takes nothing returns nothing
local trigger myTrigger = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( myTrigger, EVENT_PLAYER_UNIT_SELL_ITEM )
call TriggerAddCondition(myTrigger, Condition(function WrongTurnConditions))
call TriggerAddAction( myTrigger, function WrongTurnActions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Dialogs initializer DialogClick
globals
dialog Dialog
button array Button
endglobals
function DialogClickActions2 takes nothing returns nothing
local player p = GetTriggerPlayer()
call BJDebugMsg("Anything")
if GetClickedDialog() == udg_DialogButtons[0] then
// setup play
call BJDebugMsg("I want to play")
elseif GetClickedButtonBJ() == udg_DialogButtons[1] then
set udg_Spectating[GetPlayerId(p)] = 0
call DisplayTextToPlayer(p, 0 , 0, udg_playerColors[2] + "You've chosen to spectate this round, you will be able to play to play next game")
endif
endfunction
function D takes nothing returns nothing
call BJDebugMsg("FIREDDDD")
endfunction
function IsPlaying takes player p returns boolean
if ( GetPlayerController(p) == MAP_CONTROL_USER ) and ( GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING ) then
return true
endif
return false
endfunction
private function DialogClick takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterDialogEvent(t, Dialog)
call TriggerAddAction(t, function D)
endfunction
function DialogSetUp takes nothing returns nothing
local integer i = 0
local player p
set Dialog = DialogCreate()
call DialogClear(Dialog)
call DialogSetMessage(Dialog, "Welcome to TicTacWC4")
set Button[0] = DialogAddButton(Dialog, "Play", 257)
set Button[1] = DialogAddButton(Dialog, "Observe (not permanent)", 258)
loop
exitwhen i > 12
set p = Player(i)
if IsPlaying(p) == true then
call DialogDisplay(p, udg_Dialog1, true)
else
endif
set i = i + 1
endloop
// call TriggerRegisterDialogEvent(DialogClick, Dialog)
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
function DialogClickActions takes nothing returns nothing
local player p = GetTriggerPlayer()
call BJDebugMsg("Anything")
if GetClickedDialog() == udg_DialogButtons[0] then
// setup play
call BJDebugMsg("I want to play")
elseif GetClickedButtonBJ() == udg_DialogButtons[1] then
set udg_Spectating[GetPlayerId(p)] = 0
call DisplayTextToPlayer(p, 0 , 0, udg_playerColors[2] + "You've chosen to spectate this round, you will be able to play to play next game")
endif
endfunction
function D takes nothing returns nothing
call BJDebugMsg("FIREDDDD")
endfunction
//===========================================================================
function InitTrig_Dialog_Click takes nothing returns nothing
trigger gg_trg_Dialog_Click = CreateTrigger( )
call TriggerRegisterDialog(gg_trg_Dialog_Click, )
//call TriggerAddAction( t, function DialogClickActions )
call TriggerAddAction(t, function D)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local group g = CreateGroup()
if GetLocalPlayer() == Player(0) then
call EnableSelect(false, true)
set g = GetUnitsOfPlayerMatching(Player(0), null)
call SelectUnit(GroupPickRandomUnit(g), true)
else
call BJDebugMsg("Failed")
endif
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
set gg_trg_Untitled_Trigger_001 = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Untitled_Trigger_001, Player(0), "333", true )
call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Untitled_Trigger_001_Copy_Actions takes nothing returns nothing
if GetLocalPlayer() == Player(0) and i == 10 then
call EnableSelect(true, true)
call BJDebugMsg("Allowed playing for " )
else
call EnableSelect(false, true)
call ClearSelection()
call SelectUnit(udg_Builders[GetPlayerId(p2)], true)
call BJDebugMsg("Blocked for " + GetPlayerName(p2))
endif
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_001_Copy takes nothing returns nothing
set gg_trg_Untitled_Trigger_001_Copy = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Untitled_Trigger_001_Copy, Player(0), "", false )
call TriggerAddAction( gg_trg_Untitled_Trigger_001_Copy, function Trig_Untitled_Trigger_001_Copy_Actions )
endfunction
function Trig_Untitled_Trigger_004_Func001A takes nothing returns nothing
call LeaderboardAddItemBJ( Player(0), GetLastCreatedLeaderboard(), "TRIGSTR_275", 0 )
endfunction
function Trig_Untitled_Trigger_004_Actions takes nothing returns nothing
call ForForce( GetPlayersAll(), function Trig_Untitled_Trigger_004_Func001A )
call CreateLeaderboardBJ( GetPlayersAll(), "TRIGSTR_274" )
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_004 takes nothing returns nothing
set gg_trg_Untitled_Trigger_004 = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Untitled_Trigger_004, 5 )
call TriggerAddAction( gg_trg_Untitled_Trigger_004, function Trig_Untitled_Trigger_004_Actions )
endfunction