Name | Type | is_array | initial_value |
Area | rect | Yes | |
Dialog | dialog | No | |
DialogButton | button | Yes | |
DialogClicked | boolean | No | |
DialogPlayer | player | No | |
I | integer | No | |
II | integer | No | |
Item | itemcode | Yes | |
Middle | location | No | |
Player | player | No | |
Player_Position | location | Yes | |
PlayerArea | rect | Yes | |
Team | force | Yes | |
Up_Point | location | Yes |
library Variables initializer VariablesInit
globals
leaderboard LB
string s
real x
real y
integer l
constant real Vel_S = 110*0.071/128
constant real Vel_X = Vel_S * Cos(90 * bj_DEGTORAD)
constant real Vel_Y = Vel_S * Sin(90 * bj_DEGTORAD)
constant real piHalf = 0.5*3.14159
integer array count
integer array kills
unit array Barracks
unit array ControlCenter
boolean array BarracksDestroyed
string array Colour
group array UnitGroup
integer playerCount = 0
real array xB
real array yB
boolean array inGame
boolean array autoTrain
endglobals
function VariablesInit takes nothing returns nothing
set Colour[0] = "|cffffffcc"
set Colour[1] = "|CFFFF0303"
set Colour[2] = "|CFF0042FF"
set Colour[3] = "|c001CE6B9"
set Colour[4] = "|CFF540081"
set Colour[5] = "|CFFFFFF01"
set Colour[6] = "|CFFFE8A0E"
set Colour[7] = "|CFF20C000"
set Colour[8] = "|CFFE55BB0"
set Colour[9] = "|c00959697"
set Colour[10] = "|CFF7EBFF1"
set Colour[11] = "|CFF106246"
set Colour[12] = "|CFF4E2A04"
set Colour[13] = "|c00ffcc00"
set udg_Up_Point[0] = GetRectCenter(gg_rct_Up_1)
set udg_Up_Point[1] = GetRectCenter(gg_rct_Up_2)
set udg_Up_Point[2] = GetRectCenter(gg_rct_Up_3)
set udg_Up_Point[3] = GetRectCenter(gg_rct_Up_4)
set udg_Up_Point[4] = GetRectCenter(gg_rct_Up_5)
set udg_Up_Point[5] = GetRectCenter(gg_rct_Up_6)
// ----------------
set udg_Player_Position[0] = GetRectCenter(gg_rct_Rect_1)
set udg_Player_Position[1] = GetRectCenter(gg_rct_Rect_2)
set udg_Player_Position[2] = GetRectCenter(gg_rct_Rect_3)
set udg_Player_Position[3] = GetRectCenter(gg_rct_Rect_4)
set udg_Player_Position[4] = GetRectCenter(gg_rct_Rect_5)
set udg_Player_Position[5] = GetRectCenter(gg_rct_Rect_6)
// ----------------
set udg_Area[0] = gg_rct_Area_1
set udg_Area[1] = gg_rct_Area_2
set udg_Area[2] = gg_rct_Area_3
set udg_Area[3] = gg_rct_Area_4
set udg_Area[4] = gg_rct_Area_5
set udg_Area[5] = gg_rct_Area_6
// ----------------
set udg_Middle = GetRectCenter(gg_rct_Middle)
endfunction
endlibrary
library lol
function Start takes nothing returns nothing
local integer i = 0
local integer j
local player p
local real a
call StopMusic(false)
call PlayMusic( gg_snd_PH1 )
loop
exitwhen i > 5
set p = Player(i)
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING then
set inGame[i] = true
set autoTrain[i] = false
call TriggerRegisterPlayerEventLeave( leave, p )
call CreateFogModifierRect(p, FOG_OF_WAR_VISIBLE, gg_rct_Middle, TRUE, TRUE)
set BarracksDestroyed[i] = FALSE
set ControlCenter[i] = CreateUnit(p, 'h00D', GetLocationX(udg_Up_Point[i]), GetLocationY(udg_Up_Point[i]), bj_UNIT_FACING)
call TriggerRegisterUnitEvent( gg_trg_Control_Center, ControlCenter[i], EVENT_UNIT_SPELL_CAST )
set Barracks[i] = CreateUnit(p, 'h005', GetLocationX(udg_Player_Position[i]), GetLocationY(udg_Player_Position[i]), bj_UNIT_FACING)
call IssueImmediateOrderById(Barracks[i], 'h009')
call IssueImmediateOrderById(Barracks[i], 'h009')
set xB[i] = GetLocationX(udg_Player_Position[i])
set yB[i] = GetLocationY(udg_Player_Position[i])
set a = Atan2(yB[i] - GetLocationY(udg_Middle), xB[i] - GetLocationX(udg_Middle))
set UnitGroup[i] = CreateGroup()
set j = 0
loop
set a = a + piHalf
call CreateUnit(p, 'h004', xB[i] + 220*Cos(a), yB[i] + 220*Sin(a), bj_UNIT_FACING )
call GroupAddUnit(UnitGroup[i], CreateUnit(p, 'h009', xB[i], yB[i], bj_UNIT_FACING))
set j = j + 1
exitwhen j > 3
endloop
if GetLocalPlayer() == p then
call PanCameraToTimed(xB[i], yB[i], 1)
endif
call LeaderboardAddItemBJ( p, LB, GetPlayerName(p), 0 )
call TriggerRegisterUnitEvent( gg_trg_Barrack_dies, Barracks[i], EVENT_UNIT_DEATH )
else
set BarracksDestroyed[i] = TRUE
endif
set i = i + 1
endloop
call LeaderboardDisplay(LB, TRUE)
endfunction
endlibrary
scope DeathUnit initializer DeathUnitInit
function Death takes nothing returns boolean
local string s = " "
local unit u = GetTriggerUnit()
local unit k = GetKillingUnit()
local player p = GetOwningPlayer(k)
local integer i = GetPlayerId(p)
local player p2 = GetTriggerPlayer()
local integer j = GetPlayerId(p2)
local texttag t
// **** Get Gold ****
if IsPlayerEnemy(p2,p) then
if count[i] == 9 then
set count[i] = 0
set income[i] = income[i] + 2
else
set count[i] = count[i] + 1
endif
set kills[i] = kills[i] + 1
call LeaderboardSetPlayerItemValueBJ( p, LB, kills[i] )
if p2 != UNIT_PLAYER then
if IsUnitType(u, UNIT_TYPE_STRUCTURE) == true then
set i = 75
else
set j = GetUnitLevel(u)
if RectContainsCoords(udg_Area[i], GetUnitX(k), GetUnitY(k)) then
set i = j
else
set i = j + 1
endif
endif
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, (GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + i))
if GetLocalPlayer() == p then
set s = ("|c00ffcc00+" + I2S(i))
endif
set t = CreateTextTag()
call SetTextTagText(t, s, 0.023)
call SetTextTagPosUnit(t, u, 0)
call SetTextTagColor(t, 255, 255, 255, 255)
call SetTextTagVelocity(t,Vel_X, Vel_Y)
call SetTextTagPermanent(t, FALSE)
call SetTextTagFadepoint(t, 1.75)
call SetTextTagLifespan(t, 2.75)
call RemoveUnit( u )
set t = null
endif
endif
// **** Train-Debug ****
set j = GetPlayerId(p2)
if CountTrains(Barracks[j]) < 2 then
call IssueImmediateOrderById(Barracks[j], GetLastTrainedUnitId(Barracks[j]))
endif
set u = null
set k = null
return false
endfunction
function DeathUnitInit takes nothing returns nothing
local trigger t = CreateTrigger( )
local integer i = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_DEATH, null)
set i = i + 1
exitwhen i > 5
endloop
call TriggerRegisterPlayerUnitEvent(t, UNIT_PLAYER, EVENT_PLAYER_UNIT_DEATH, null)
call TriggerAddCondition( t, Filter(function Death ))
endfunction
endscope
function GroupOrder takes nothing returns nothing
call IssuePointOrder(GetEnumUnit(), s, x, y)
endfunction
function Control takes nothing returns boolean
set x = GetSpellTargetX()
set y = GetSpellTargetY()
if GetSpellAbilityId() == 'A001' then
set s = "attack"
call ForGroup(UnitGroup[GetPlayerId(GetTriggerPlayer())], function GroupOrder)
elseif GetSpellAbilityId() == 'A000' then
set s = "Move"
call ForGroup(UnitGroup[GetPlayerId(GetTriggerPlayer())], function GroupOrder)
endif
return false
endfunction
function InitTrig_Control_Center takes nothing returns nothing
set gg_trg_Control_Center = CreateTrigger()
call TriggerAddCondition( gg_trg_Control_Center, Filter(function Control ))
endfunction
function Repair takes nothing returns nothing
local unit u = GetTriggerUnit()
local string s
local texttag t
local player p = GetTriggerPlayer()
local integer i
local real life
if GetSpellAbilityId() == 1093677107 then //RepairId
set i = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
if i < 40 then
call DisplayTimedTextToPlayer(p, 0, 0, 6., "You need |c00ffcc0040 gold.|r")
call TriggerSleepAction(0.00)
call UnitResetCooldown(u)
else
set life = GetWidgetLife(u)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, (i-40))
call SetWidgetLife(u, life + GetUnitState(u, UNIT_STATE_MAX_LIFE)*.333333)
set i = R2I(GetWidgetLife(u) - life) //wesh
set s = "|CFF20C000" + I2S(i) + "HP"
set t = CreateTextTag()
call SetTextTagText(t, s, .023)
call SetTextTagPosUnit(t, u, 0)
call SetTextTagColor(t, 255, 255, 255, 255)
call SetTextTagVelocity(t, Vel_X, Vel_Y)
call SetTextTagPermanent(t, FALSE)
call SetTextTagFadepoint(t, 1.75)
call SetTextTagLifespan(t, 2.75)
set t = null
endif
set u = null
endif
endfunction
function InitTrig_Repair takes nothing returns nothing
local trigger t = CreateTrigger( )
local integer i = 0
call TriggerAddAction( t, function Repair )
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
set i = i + 1
exitwhen i > 5
endloop
endfunction
function KillUnits takes nothing returns nothing
call KillUnit(GetEnumUnit())
endfunction
function Trig_Barrack_dies_Actions takes nothing returns nothing
local player pd = GetOwningPlayer(GetTriggerUnit())
local player pk = GetOwningPlayer(GetKillingUnit())
local integer i = 0
local integer j = GetPlayerId(pd)
set BarracksDestroyed[j] = true
set inGame[j] = false
if unitsCreation then
call ForGroup(atkG[j], function KillUnits)
endif
call printAll(( GetPlayerName(pk) + " has destroyed " ) + ( GetPlayerName(pd) + "'s Barracks." ), 12)
call FogModifierStart(CreateFogModifierRect(pd, FOG_OF_WAR_VISIBLE, GetPlayableMapRect(), true, false))
loop
if IsPlayerEnemy(Player(i), pk) and not BarracksDestroyed[i] then
set i = 7
else
set i = i + 1
endif
exitwhen i > 5
endloop
if i < 7 then
call TriggerSleepAction(5.0)
set i = 0
loop
set pk = Player(i)
if IsPlayerAlly(pk, pd) then
call CustomDefeatBJ( pk, "Lose" )
else
call CustomDefeatBJ( pk, "Win" )
endif
set i = i + 1
exitwhen i > 5
endloop
endif
endfunction
function InitTrig_Barrack_dies takes nothing returns nothing
set gg_trg_Barrack_dies = CreateTrigger( )
call TriggerAddAction( gg_trg_Barrack_dies, function Trig_Barrack_dies_Actions )
endfunction
library TrainDetection initializer TrainInit uses optional Table
/***********************************************************************
** TrainDetection v0.7 by IcemanBo **
** **
** Optional Table (thanks to Bribe) **
** **
** API **
** **
** **
** DisplayTrains(player, whichunit) **
** **
** CountTrains(whichunit) **
** **
** GetLastTrainedUnitId (whichunit) **
** GetLastTrainedUnitName (whichunit) **
** **
** GetCurrentTrainedUnitId (whichunit) **
** GetCurrentTrainedUnitName (whichunit) **
** **
***********************************************************************/
private struct TD extends array
static if LIBRARY_Table then
static TableArray table
else
static hashtable hash = InitHashtable()
endif
endstruct
globals
private constant integer COUNTKEY = 8
private constant integer CURRENTKEY = 9
private constant integer LASTKEY = 10
private constant string EMPTY_STRING = "Default string"
endglobals
// The order of displayed objects may differ from the real train order of unit!
function DisplayTrains takes player p, unit building returns nothing
local integer unitId = GetHandleId(building)
local integer i = 0
static if LIBRARY_Table then
local integer j = TD.table[COUNTKEY][unitId]
loop
set i = i + 1
exitwhen i > j
call DisplayTimedTextToPlayer(p, 0, 0, 8, "|c00ffcc00" + TD.table[i].string[unitId] + "|r ObjectId: " + I2S(TD.table[i][unitId]))
endloop
else
local integer j = LoadInteger(TD.hash, unitId, COUNTKEY)
loop
set i = i + 1
exitwhen i > j
call DisplayTimedTextToPlayer(p, 0, 0, 8, "|c00ffcc00" + LoadStr(TD.hash, unitId, i) + "|r ObjectId: " + I2S(LoadInteger(TD.hash, unitId, i)))
endloop
endif
endfunction
function CountTrains takes unit building returns integer
static if LIBRARY_Table then
return TD.table[COUNTKEY][GetHandleId(building)]
else
return LoadInteger(TD.hash, GetHandleId(building), COUNTKEY)
endif
endfunction
function GetLastTrainedUnitId takes unit building returns integer
static if LIBRARY_Table then
return TD.table[LASTKEY][GetHandleId(building)]
else
return LoadInteger(TD.hash, GetHandleId(building), LASTKEY)
endif
endfunction
function GetLastTrainedUnitName takes unit building returns string
static if LIBRARY_Table then
return TD.table[LASTKEY].string[GetHandleId(building)]
else
return LoadStr(TD.hash, GetHandleId(building), LASTKEY)
endif
endfunction
function GetCurrentTrainedUnitId takes unit building returns integer
static if LIBRARY_Table then
return TD.table[CURRENTKEY][GetHandleId(building)]
else
return LoadInteger(TD.hash, GetHandleId(building), CURRENTKEY)
endif
endfunction
function GetCurrentTrainedUnitName takes unit building returns string
static if LIBRARY_Table then
return TD.table[CURRENTKEY].string[GetHandleId(building)]
else
return LoadStr(TD.hash, GetHandleId(building), CURRENTKEY)
endif
endfunction
//This fires if an object finishes training or get canceled
//It moves up all trains which would be trained After
private function ObjectsMoveUp takes unit building, integer trainId returns nothing
local integer unitId = GetHandleId(building)
local integer i = 0
local integer j = 0
local integer k
static if LIBRARY_Table then
local integer trainCounter = TD.table[COUNTKEY][unitId] - 1
set TD.table[COUNTKEY][unitId] = trainCounter
if trainCounter == 0 then //no loop needed + fix train 1 and CurrentTrainedUnit
set TD.table[CURRENTKEY][unitId] = 0
set TD.table[CURRENTKEY].string[unitId] = null
set TD.table[1][unitId] = 0
set TD.table[1].string[unitId] = null
else
loop // loop through trained objects
set i = i + 1
if TD.table[i][unitId] == trainId then // found matching objectId
set j = i
set i = 0
loop //loop from found ObjectId to 7 (max of trained objects)
exitwhen j > 7
if j == 7 then // just set to 0 it it's last trained object
set TD.table[j][unitId] = 0
set TD.table[j].string[unitId] = null
else //Move up by 1
set TD.table[j][unitId] = TD.table[j + 1][unitId]
set TD.table[j].string[unitId] = TD.table[j + 1].string[unitId]
set TD.table[j+1][unitId] = 0
set TD.table[j+1].string[unitId] = null
endif
set j = j + 1
endloop
endif
exitwhen i == 0 or i == 7
endloop
endif
else
local integer trainCounter = LoadInteger(TD.hash, unitId, COUNTKEY) - 1
call SaveInteger(TD.hash, unitId, COUNTKEY, trainCounter)
if trainCounter == 0 then //no loop needed + fix train 1 and CurrentTrainedUnit
call SaveInteger(TD.hash, unitId, CURRENTKEY, 0)
call SaveStr(TD.hash, unitId, CURRENTKEY, null)
call SaveInteger(TD.hash, unitId, 1, 0)
call SaveStr(TD.hash, unitId, 1, null)
else
loop // loop through trained objects
set i = i + 1
if LoadInteger(TD.hash, unitId, i) == trainId then // found matching objectId
set j = i
set i = 0
loop //loop from found ObjectId to 7 (max of trained objects)
exitwhen j > 7
if j == 7 then // just set to 0 it it's last trained object
call SaveInteger(TD.hash, unitId, j, 0)
call SaveStr(TD.hash, unitId, j, null)
else //Move up by 1
call SaveInteger(TD.hash, unitId, j, LoadInteger(TD.hash, unitId, j + 1))
call SaveStr(TD.hash, unitId, j, LoadStr(TD.hash, unitId, j + 1))
call SaveInteger(TD.hash, unitId, j + 1, 0)
call SaveStr(TD.hash, unitId, j + 1, null)
endif
set j = j + 1
endloop
endif
exitwhen i == 0 or i == 7
endloop
endif
endif
endfunction
private function TrainOrder takes nothing returns boolean
local integer trainId = GetIssuedOrderId()
local string trainName = GetObjectName(trainId)
local integer unitId
local integer trainCounter
if trainName != EMPTY_STRING then
set unitId = GetHandleId(GetTriggerUnit())
static if LIBRARY_Table then
set trainCounter = TD.table[COUNTKEY][unitId] + 1
set TD.table[COUNTKEY][unitId] = trainCounter
set TD.table[trainCounter][unitId] = trainId
set TD.table[trainCounter].string[unitId] = trainName
else
set trainCounter = LoadInteger(TD.hash, unitId, COUNTKEY) + 1
call SaveInteger(TD.hash, unitId, COUNTKEY, trainCounter)
call SaveInteger(TD.hash, unitId, trainCounter, trainId)
call SaveStr(TD.hash, unitId, trainCounter, trainName)
endif
endif
return false
endfunction
private function TrainStart takes nothing returns boolean
local integer unitId = GetHandleId(GetTriggerUnit())
local integer trainId = GetTrainedUnitType()
local string trainName
if trainId == 0 then // check if train is no unit
set trainId = GetResearched()
if trainId == 0 then // check if train is no research
set trainId = GetUnitTypeId(GetTriggerUnit()) // --> train is an upgrade
endif
endif
set trainName = GetObjectName(trainId)
static if LIBRARY_Table then
set TD.table[CURRENTKEY][unitId] = trainId
set TD.table[CURRENTKEY].string[unitId] = trainName
else
call SaveInteger(TD.hash, unitId, CURRENTKEY, trainId)
call SaveStr(TD.hash, unitId, CURRENTKEY, trainName)
endif
return false
endfunction
private function TrainCancel takes nothing returns boolean
local integer i = GetTrainedUnitType()
if i == 0 then // check if canceled object is an unit or an research, no need to check for upgrade in here
call ObjectsMoveUp(GetTriggerUnit(), GetResearched())
else
call ObjectsMoveUp(GetTriggerUnit(), i)
endif
return false
endfunction
private function TrainFinish takes nothing returns boolean
local unit building = GetTriggerUnit()
local integer unitId = GetHandleId(building)
local integer trainId = GetTrainedUnitType()
local string trainName
if trainId == 0 then // check if train was no unit
set trainId = GetResearched()
if trainId == 0 then // check if train was no research
set trainId = GetUnitTypeId(building) // --> train was an upgrade
endif
endif
set trainName = GetObjectName(trainId)
static if LIBRARY_Table then
set TD.table[LASTKEY][unitId] = trainId
set TD.table[LASTKEY].string[unitId] = trainName
set TD.table[CURRENTKEY][unitId] = 0
set TD.table[CURRENTKEY].string[unitId] = null
else
call SaveInteger(TD.hash, unitId, LASTKEY, trainId)
call SaveStr(TD.hash, unitId, LASTKEY, trainName)
call SaveInteger(TD.hash, unitId, CURRENTKEY, 0)
call SaveStr(TD.hash, unitId, CURRENTKEY, null)
endif
call ObjectsMoveUp(building, trainId)
set building = null
return false
endfunction
private function TrainInit takes nothing returns nothing
local trigger trainOrder = CreateTrigger()
local trigger trainStart = CreateTrigger()
local trigger trainFinish = CreateTrigger()
local trigger trainCancel = CreateTrigger()
local player p
local integer i = 0
static if LIBRARY_Table then
set TD.table = TableArray[11]
endif
loop
set p = Player(i)
call TriggerRegisterPlayerUnitEvent(trainOrder, p, EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
call TriggerRegisterPlayerUnitEvent(trainStart, p, EVENT_PLAYER_UNIT_RESEARCH_START, null)
call TriggerRegisterPlayerUnitEvent(trainStart, p, EVENT_PLAYER_UNIT_TRAIN_START, null)
call TriggerRegisterPlayerUnitEvent(trainStart, p, EVENT_PLAYER_UNIT_UPGRADE_START, null)
call TriggerRegisterPlayerUnitEvent(trainCancel, p, EVENT_PLAYER_UNIT_TRAIN_CANCEL, null)
call TriggerRegisterPlayerUnitEvent(trainCancel, p, EVENT_PLAYER_UNIT_RESEARCH_CANCEL, null)
call TriggerRegisterPlayerUnitEvent(trainCancel, p, EVENT_PLAYER_UNIT_UPGRADE_CANCEL, null)
call TriggerRegisterPlayerUnitEvent(trainFinish, p, EVENT_PLAYER_UNIT_TRAIN_FINISH, null)
call TriggerRegisterPlayerUnitEvent(trainFinish, p, EVENT_PLAYER_UNIT_RESEARCH_FINISH, null)
call TriggerRegisterPlayerUnitEvent(trainFinish, p, EVENT_PLAYER_UNIT_UPGRADE_FINISH, null)
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddCondition(trainOrder, Filter(function TrainOrder))
call TriggerAddCondition(trainStart, Filter(function TrainStart))
call TriggerAddCondition(trainFinish, Filter(function TrainFinish))
call TriggerAddCondition(trainCancel, Filter(function TrainCancel))
endfunction
endlibrary
library Leave initializer LeaveInit uses TextDisplay
globals
trigger leave = CreateTrigger()
endglobals
function RemoveUnits takes nothing returns nothing
call RemoveUnit( GetEnumUnit() )
endfunction
function Leave takes nothing returns boolean
local player p = GetTriggerPlayer()
local integer i = 0
local integer j = 0
local group g = GetUnitsOfPlayerAll(p)
local integer k = GetPlayerId(p)
set inGame[k] = false
set playerCount = playerCount - 1
set BarracksDestroyed[k] = true
call printAll(( GetPlayerName(p) + " has left the game" ), 12)
call ForGroup(g, function RemoveUnits)
loop
if not BarracksDestroyed[i] then
set p = Player(i)
loop
if IsPlayerEnemy(Player(j), p) and not BarracksDestroyed[j] then
set j = 7
else
set j = j + 1
endif
exitwhen j > 5
endloop
if j < 7 then
call TriggerSleepAction(3.50)
set i = 0
loop
set p = Player(i)
if not IsPlayerEnemy(Player(j), p) then
call CustomDefeatBJ( Player(i), "Lose" )
else
call CustomDefeatBJ( Player(i), "Win" )
endif
set i = i + 1
exitwhen i > 5
endloop
endif
endif
set i = i + 1
exitwhen i > 5
endloop
call DestroyGroup(g)
set g = null
return false
endfunction
function LeaveInit takes nothing returns nothing
call TriggerAddCondition( leave, Filter(function Leave))
endfunction
endlibrary
library IncomeLib uses TextDisplay
globals
constant real incomeTimeout = 15
integer array income
endglobals
function Income takes nothing returns nothing
local integer i = 0
local player p
loop
set p = Player(i)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + income[i])
call print(p, "|c00ffcc00Income: |r" + I2S(income[i]), 6)
set i = i + 1
exitwhen i > 5
endloop
endfunction
function IncomeInit takes nothing returns nothing
local timer incomeTimer = CreateTimer()
local timerdialog iDialog = CreateTimerDialog(incomeTimer)
local integer i = 0
loop
set income[i] = 1
exitwhen i > 5
set i = i + 1
endloop
call TimerStart(incomeTimer, incomeTimeout, true, function Income)
call TimerDialogSetTitle(iDialog, "Next Income")
call TimerDialogDisplay(iDialog, true)
set incomeTimer = null
endfunction
endlibrary
library Cam initializer CamInit uses TextDisplay
globals
constant real ZOOM_START = 2250.
constant real ZOOM_MIN = 500.
constant real ZOOM_MAX = 3500.
constant real ZOOM_TIMEOUT = 1.
constant real ZOOM_TIME = 1.
real array zoom
endglobals
function SetDistance takes nothing returns nothing
local integer i = 0
local player p
loop
set p = Player(i)
if GetLocalPlayer() == p then
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, zoom[i], ZOOM_TIME)
endif
set i = i + 1
exitwhen i > 5
endloop
endfunction
function Zoom takes nothing returns boolean
local string chat = GetEventPlayerChatString()
local player p = GetTriggerPlayer()
local real r = 0
local string s = null
if SubString(chat, 0, 2) == "-z " then
set r = S2R(SubString(chat, 3, StringLength(chat)))
else
set r = S2R(SubString(chat, 6, StringLength(chat)))
endif
if r == 0 then
call print(p, "|c00ffcc00Current Zoom: |r" + R2S(zoom[GetPlayerId(p)]), 8)
else
if r < ZOOM_MIN then
set r = ZOOM_MIN
set s = "|c00ffcc00Min-"
elseif r > ZOOM_MAX then
set r = ZOOM_MAX
set s = "|c00ffcc00Max-"
endif
set zoom[GetPlayerId(p)] = r
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, r, ZOOM_TIME)
set s = s + "|c00ffcc00Zoom: |r" + R2S(r)
call print(p, s, 8)
endif
return false
endfunction
function CamInit takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
call TimerStart(CreateTimer(), ZOOM_TIMEOUT, true, function SetDistance)
call TriggerAddCondition( t, Filter(function Zoom ))
loop
set zoom[i] = ZOOM_START
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, zoom[i], 0.00)
call TriggerRegisterPlayerChatEvent( t, Player(i), "-zoom", false )
set i = i + 1
exitwhen i > 5
endloop
endfunction
endlibrary
library Barracks initializer BarracksInit uses TrainDetection
function Upgrade takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer id = GetUnitTypeId(u)
local integer order = 0
if id == 'h008' then //Barracks level 2
set order = 'h001' //Footman
elseif id == 'h006' then //Barracks level 3
set order = 'h002' //Sniper
elseif id == 'h007' then //Barracks level 4
set order = 'h00A' //Knight
endif
if order != 0 then
call IssueImmediateOrderById(u, order)
call IssueImmediateOrderById(u, order)
endif
set u = null
return false
endfunction
function Train takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
call GroupAddUnit(UnitGroup[i], GetTrainedUnit())
call TriggerSleepAction( 0.00 )
call IssueImmediateOrderById(Barracks[i], GetLastTrainedUnitId(Barracks[i]))
endfunction
function BarracksInit takes nothing returns nothing
local integer i = 0
local trigger finishTrain = CreateTrigger( )
local trigger finishUpgrade = CreateTrigger( )
local player p
loop
set p = Player(i)
call TriggerRegisterPlayerUnitEvent(finishTrain, p, EVENT_PLAYER_UNIT_TRAIN_FINISH, null)
call TriggerRegisterPlayerUnitEvent(finishUpgrade, p, EVENT_PLAYER_UNIT_UPGRADE_FINISH, null)
set i = i + 1
exitwhen i > 5
endloop
call TriggerAddAction( finishTrain, function Train )
call TriggerAddCondition(finishUpgrade, Filter(function Upgrade))
endfunction
endlibrary
library Items
globals
integer array Item
rect itemRect
real xMinI
real xMaxI
real yMinI
real yMaxI
constant real itemTimeout = 25.
constant integer maxItems = 5
constant integer minItems = 0
endglobals
function ItemCreation takes nothing returns nothing
call CreateItem(Item[GetRandomInt(minItems, maxItems)], GetRandomReal(xMinI, xMaxI), GetRandomReal(yMinI, yMaxI))
endfunction
function ItemsInit takes nothing returns nothing
set xMinI = GetRectMinX(itemRect)
set xMaxI = GetRectMaxX(itemRect)
set yMinI = GetRectMinY(itemRect)
set yMaxI = GetRectMaxY(itemRect)
set Item[0] = 'gomn'
set Item[1] = 'rhe2'
set Item[2] = 'rspd'
set Item[3] = 'I001'
set Item[4] = 'I002'
set Item[5] = 'I000'
call TimerStart(CreateTimer(), itemTimeout, true, function ItemCreation)
endfunction
endlibrary
library Units uses TextDisplay
globals
constant integer EASY_UNITS = 2
constant integer MEDIUM_UNITS = 8
constant integer HARD_UNITS = 14
constant integer EXTREME_UNITS = 18
timer unitsTimer
timerdialog unitsTimerDialog
string unitsTimerTitle = " (|CFF20C000Easy|r)"
group array atkG
integer unitLevelMin = 0
integer unitLevelMax = 0
integer unitAmount = 6
integer array unitId
real xMinU
real xMaxU
real yMinU
real yMaxU
boolean increase = true
boolean lastLevel = false
boolean unitsCreation = false
constant integer WAVE_COUNT_LIMIT = 3
integer waveCount = 0
constant string ATTACK = "attack"
constant real ATTACK_TIMEOUT = 5.
real unitsTimeout = 45.
constant real UNIT_FACING = 270.
constant player UNIT_PLAYER = Player(11)
endglobals
function Survived takes nothing returns nothing
local integer i = 0
call printAll("Victory", 0.)
loop
call CustomDefeatBJ( Player(i), "Win" )
set i = i + 1
exitwhen i > 5
endloop
endfunction
function UnitAttack takes nothing returns nothing
call IssuePointOrder(GetEnumUnit(), ATTACK, xB[l], yB[l])
endfunction
function UnitsAttack takes nothing returns nothing
set l = 0
loop
if GetPlayerSlotState(Player(l)) == PLAYER_SLOT_STATE_PLAYING then
call ForGroup(atkG[l], function UnitAttack)
endif
set l = l + 1
exitwhen l > 5
endloop
endfunction
function UnitCreation takes nothing returns nothing
local integer i
local integer j = 0
local integer k = 1
local unit u
loop
if inGame[j] then
set k = k + 1
set i = 0
loop
exitwhen i == unitAmount
set u = CreateUnit(UNIT_PLAYER, unitId[GetRandomInt(unitLevelMin, unitLevelMax)], GetRandomReal(xMinU, xMaxU), GetRandomReal(yMinU, yMaxU), UNIT_FACING)
call IssuePointOrder( u, ATTACK, xB[j], yB[j])
call GroupAddUnit(atkG[j], u)
set i = i + 1
endloop
endif
exitwhen k > playerCount or j > 5
set j = j + 1
endloop
set waveCount = waveCount + 1
if waveCount == HARD_UNITS then
set unitsTimerTitle = " (|c00640000Extreme|r)"
set unitLevelMin = HARD_UNITS
set unitLevelMax = EXTREME_UNITS
set unitAmount = 3
elseif waveCount == MEDIUM_UNITS then
set unitsTimerTitle = " (|CFFFF0303Hard|r)"
set unitLevelMin = MEDIUM_UNITS
set unitLevelMax = HARD_UNITS
set unitAmount = 3
elseif waveCount == EASY_UNITS then
set unitsTimerTitle = " (|CFFFFFF01Medium|r)"
set unitLevelMin = EASY_UNITS
set unitLevelMax = MEDIUM_UNITS
set unitAmount = 3
endif
set unitAmount = unitAmount + 1
call TimerDialogSetTitle(unitsTimerDialog, "Wave " + I2S(waveCount + 1) + unitsTimerTitle)
if waveCount == EXTREME_UNITS then
call PauseTimer(unitsTimer)
call DestroyTimer(unitsTimer)
set unitsTimer = null
call DestroyTimerDialog(unitsTimerDialog)
set unitsTimerDialog = null
set unitsTimer = CreateTimer()
set unitsTimerDialog = CreateTimerDialog(unitsTimer)
call TimerDialogSetTitle(unitsTimerDialog, "Victory")
call TimerDialogDisplay(unitsTimerDialog, true)
call TimerStart(unitsTimer, 80., false, function Survived)
call printAll("|c00ffcc00SURVIVE FOR 80 SECONDS!", 15)
set j = 0
set k = 1
loop
if inGame[j] then
set k = k + 1
set u = CreateUnit(UNIT_PLAYER, unitId[19], GetRandomReal(xMinU, xMaxU), GetRandomReal(yMinU, yMaxU), UNIT_FACING)
call IssuePointOrder( u, ATTACK, xB[j], yB[j])
call GroupAddUnit(atkG[j], u)
endif
exitwhen k > playerCount or j > 5
set j = j + 1
endloop
endif
set u = null
endfunction
function UnitsInit takes nothing returns nothing
local rect unitRect = gg_rct_Units
local integer i = 0
set unitsCreation = true
set unitsTimer = CreateTimer()
set unitsTimerDialog = CreateTimerDialog(unitsTimer)
call TimerDialogSetTitle(unitsTimerDialog, "Next Wave " + I2S(waveCount + 1) + unitsTimerTitle)
call TimerDialogDisplay(unitsTimerDialog, true)
call TimerStart(unitsTimer, unitsTimeout, true, function UnitCreation)
loop
set atkG[i] = CreateGroup()
set i = i + 1
exitwhen i > 5
endloop
call TimerStart(CreateTimer(), ATTACK_TIMEOUT, true, function UnitsAttack)
call SetPlayerState(UNIT_PLAYER, PLAYER_STATE_NO_CREEP_SLEEP, 1)
call SetPlayerState(UNIT_PLAYER, PLAYER_STATE_GIVES_BOUNTY, 1)
set xMinU = GetRectMinX(unitRect)
set xMaxU = GetRectMaxX(unitRect)
set yMinU = GetRectMinY(unitRect)
set yMaxU = GetRectMaxY(unitRect)
//Easy
set unitId[0] = 'n00F'
set unitId[1] = 'n00C'
set unitId[2] = 'n009'
//Medium
set unitId[3] = 'n00D'
set unitId[4] = 'n001'
set unitId[5] = 'n004'
set unitId[6] = 'n006'
set unitId[7] = 'n00A'
set unitId[8] = 'n00G'
//Hard
set unitId[9] = 'n00E'
set unitId[10] = 'n002'
set unitId[11] = 'n005'
set unitId[12] = 'n007'
set unitId[13] = 'n00B'
set unitId[14] = 'n00H'
//Extreme
set unitId[15] = 'n003'
set unitId[16] = 'n008'
set unitId[17] = 'n00I'
set unitId[18] = 'n00J'
set unitId[19] = 'n00K'
set unitLevelMin = 0
set unitLevelMax = EASY_UNITS
call RemoveRect(unitRect)
set unitRect = null
endfunction
endlibrary
library TextDisplay
function printAll takes string text, real duration returns nothing
local integer i = 0
loop
call DisplayTimedTextToPlayer(Player(i), 0, 0, duration, text)
set i = i + 1
exitwhen i > 11
endloop
endfunction
function print takes player p, string text, real duration returns nothing
call DisplayTimedTextToPlayer(p, 0, 0, duration, text)
endfunction
endlibrary