//TESH.scrollpos=0
//TESH.alwaysfold=0
function CreateSoundForPlayer takes string file, player p returns nothing
local sound S = CreateSound(file, false, false, false, 10, 10, "DefaultEAXON")
call SetSoundVolume(S, 127)
call SetSoundPitch(S, 1.)
if GetLocalPlayer() == p then
call StartSound(S)
endif
call KillSoundWhenDone(S)
endfunction
function CreateSoundEx takes string file returns nothing
local sound S = CreateSound(file, false, false, false, 10, 10, "DefaultEAXON")
call SetSoundVolume(S, 127)
call SetSoundPitch(S, 1.)
call StartSound(S)
call KillSoundWhenDone(S)
endfunction
function CreateSoundAtPoint takes string file, real x, real y returns nothing
local sound S = CreateSound(file, false, true, false, 12700, 12700, "DefaultEAXON") //12700
call SetSoundPosition(S, x, y, 10.)
call SetSoundVolume(S, 127)
call SetSoundPitch(S, 1.)
call StartSound(S)
call KillSoundWhenDone(S)
endfunction
function IsPointInBase takes real x, real y returns boolean
return (x <= GetRectMaxX(gg_rct_RedBase) and x >= GetRectMinX(gg_rct_RedBase) and y <= GetRectMaxY(gg_rct_RedBase) and y >= GetRectMinY(gg_rct_RedBase)) or (x <= GetRectMaxX(gg_rct_BlueBase) and x >= GetRectMinX(gg_rct_BlueBase) and y <= GetRectMaxY(gg_rct_BlueBase) and y >= GetRectMinY(gg_rct_BlueBase))
endfunction
function CreateEffectZ takes string path, real x, real y, real z returns effect
local destructable d = CreateDestructableZ('OTip', x, y, z, 0., 1, 0)
local effect e = AddSpecialEffect(path, x, y)
call RemoveDestructable(d)
set d = null
return e
endfunction
function CinematicFilterForPlayer takes player whichPlayer, real duration, blendmode bmode, string tex, real red0, real green0, real blue0, real trans0, real red1, real green1, real blue1, real trans1 returns nothing
if GetLocalPlayer() == whichPlayer then
call SetCineFilterTexture(tex)
call SetCineFilterBlendMode(bmode)
call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
call SetCineFilterStartUV(0, 0, 1, 1)
call SetCineFilterEndUV(0, 0, 1, 1)
call SetCineFilterStartColor(PercentTo255(red0), PercentTo255(green0), PercentTo255(blue0), PercentTo255(100-trans0))
call SetCineFilterEndColor(PercentTo255(red1), PercentTo255(green1), PercentTo255(blue1), PercentTo255(100-trans1))
call SetCineFilterDuration(duration)
call DisplayCineFilter(true)
endif
endfunction
function ConvertI2S takes integer i returns string
return i
return ""
endfunction
Name | Type | is_array | initial_value |
//TESH.scrollpos=0
//TESH.alwaysfold=0
CREDITS:
* Illidan(evil)x:
M1A2 Abrams Battle Tank (model, texture, icon)
M2 Bradley Infantry Fighting Vehicle (model, texture, icon, projectile)
Scout Jeep (model, texture, icon)
AH-1 Cobra Attack Helicopter (model, texture, icon)
Artillery Explosion Effect (model)
Triggering/Scripting
Doodad models/Textures
Custom User Interface
* WILLTHEALMIGHTY:
NewGroundEX (Explosion, ground)
NewAirEX (Explosion, air)
NewDirtEX (Explosion, dirt)
NewMassiveEX (Explosion, massive)
* Punisher_X
Road tile texture
* Music: Polaris9 - Show No Mercy
//TESH.scrollpos=0
//TESH.alwaysfold=0
//The leak test I've created. Creates a location every 0.0005 second.
//The game became unplayable at 450,000 - 500,000 leaks, dropping down from 64 FPS to 8-20 FPS.
//Enable this trigger to enable the Location Leak Test.
globals
integer Intd = 0
string stf
trigger TeSt = CreateTrigger()
endglobals
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
call DestroyEffect(AddSpecialEffectLoc("none.mdl", GetRectCenter(GetWorldBounds())))
set Intd = Intd + 1
endfunction
function Trig_Untitled_Trigger_003_Actions takes nothing returns nothing
call ClearTextMessages()
set stf = "Location Leaks: " +I2S(Intd)
call DisplayTextToPlayer(Player(0), 0.5,0.5,stf)
endfunction
//===========================================================================
function InitTrig_LocationLeakTest takes nothing returns nothing
set gg_trg_LocationLeakTest = CreateTrigger( )
call TriggerRegisterTimerEvent( gg_trg_LocationLeakTest, 0.0005,true )
call TriggerRegisterTimerEvent( TeSt, 0.25,true )
call TriggerAddAction( gg_trg_LocationLeakTest, function Trig_Untitled_Trigger_002_Actions )
call TriggerAddAction( TeSt, function Trig_Untitled_Trigger_003_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
integer StartingCredits = 5000 //Player starting credits
endglobals
function Trig_Initialization_Actions takes nothing returns nothing
local integer i = 0
call SetMusicVolume(0)
call EndThematicMusic()
call StopMusic(false)
call CinematicFadeBJ(bj_CINEFADETYPE_FADEOUT, 0., "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 100., 100., 100., 0)
call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 12.00)
if GetLocalPlayer() == GetLocalPlayer() then
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 4000., 0)
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, 270., 0)
endif
call TriggerSleepAction(0.01)
call EnableMinimapFilterButtons(false, false)
call CinematicFadeBJ(bj_CINEFADETYPE_FADEIN, 5., "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 100., 100., 100., 0)
if GetLocalPlayer() == GetLocalPlayer() then
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, bj_CAMERA_DEFAULT_DISTANCE, 5.)
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, bj_CAMERA_DEFAULT_AOA, 5.)
endif
call PlayMusic(gg_snd_ShowNoMercy)
call SetMusicVolume(127)
call SetSkyModel("Environment\\Sky\\BlizzardSky\\BlizzardSky.mdl")
call SetTerrainType(GetRectCenterX(gg_rct_UnitPreviewRect), GetRectCenterY(gg_rct_UnitPreviewRect), 'Oaby', -1, 10, 0)
loop
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD, StartingCredits)
set i = i + 1
exitwhen i > 12
endloop
set i = 0
loop
call SetPlayerAllianceStateBJ(Player(i), Player(5), bj_ALLIANCE_ALLIED_ADVUNITS)
call SetPlayerAllianceStateBJ(Player(5), Player(i), bj_ALLIANCE_ALLIED_ADVUNITS)
call CreateFogModifierRectBJ(true, Player(i), FOG_OF_WAR_VISIBLE, gg_rct_RedBase)
set i = i + 1
exitwhen i > 4
endloop
set i = 6
loop
call SetPlayerAllianceStateBJ(Player(i), Player(11), bj_ALLIANCE_ALLIED_ADVUNITS)
call SetPlayerAllianceStateBJ(Player(11), Player(i), bj_ALLIANCE_ALLIED_ADVUNITS)
call CreateFogModifierRectBJ(true, Player(i), FOG_OF_WAR_VISIBLE, gg_rct_BlueBase)
set i = i + 1
exitwhen i > 11
endloop
call TriggerSleepAction(5.)
set i = 0
loop
set EnableMenu[i] = true
set i = i + 1
exitwhen i > 10
endloop
endfunction
//===========================================================================
function InitTrig_Initialization takes nothing returns nothing
set gg_trg_Initialization = CreateTrigger()
call TriggerAddAction(gg_trg_Initialization, function Trig_Initialization_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
quest Credits_Quest = null
endglobals
function Trig_Quests_Actions takes nothing returns nothing
set Credits_Quest = CreateQuest()
call QuestSetTitle(Credits_Quest, "Credits")
call QuestSetRequired(Credits_Quest, false)
call QuestSetIconPath(Credits_Quest, "ReplaceableTextures\\CommandButtons\\BTNNecromancerMaster.blp")
call QuestSetDescription(Credits_Quest, " |cff00ff00CREDITS:
=============================================|r
|cffff0000Illidan(evil)x|r: (Author)
- M1A2 Abrams Battle Tank
- M2 Bradley Infantry Fighting Vehicle
- Scout Jeep
- AH-1 Cobra Attack Helicopter
- Triggering/Scripting
- Custom User Interface
- Doodad models/Textures
|cff00ff00=============================================|r
|cffff0000WILLTHEALMIGHTY|r:
- NewGroundEX (Explosion, ground)
- NewAirEX (Explosion, air)
- NewDirtEX (Explosion, dirt)
- NewMassiveEX (Explosion, massive)
|cff00ff00=============================================|r
|cffff0000Punisher_X|r:
- Road tile texture
|cff00ff00=============================================|r
Music: Polaris9 - Show No Mercy")
call QuestSetEnabled(Credits_Quest, true)
call QuestSetCompleted(Credits_Quest, false)
//==//===============
endfunction
//===========================================================================
function InitTrig_Quests takes nothing returns nothing
set gg_trg_Quests = CreateTrigger()
call TriggerRegisterTimerEvent(gg_trg_Quests, 0., false)
call TriggerAddAction(gg_trg_Quests, function Trig_Quests_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_RecognizeAuthor_Actions takes nothing returns nothing
local integer i = 0
loop
if StringCase(GetPlayerName(Player(i)), false) == "illidan(evil)x" then
call DisplayTextToPlayer(GetLocalPlayer(), 0.,0.,"The map author, Illidan(evil)x, is playing in the game, and will have enabled debugging options!")
endif
set i = i + 1
exitwhen i > 10
endloop
endfunction
//===========================================================================
function InitTrig_RecognizeAuthor takes nothing returns nothing
set gg_trg_RecognizeAuthor = CreateTrigger()
call TriggerRegisterTimerEvent(gg_trg_RecognizeAuthor, 20., false)
call TriggerAddAction(gg_trg_RecognizeAuthor, function Trig_RecognizeAuthor_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//Preload sounds/models/units to avoid first-time-lag
function PreloadSound takes string file returns nothing
local sound s = CreateSound(file, false, false, false, 0, 0, "DefaultEAXON")
call SetSoundVolume(s, 0)
call StartSound(s)
call StopSound(s,true,false)
set s = null
endfunction
function PreloadUnit takes integer unitId returns nothing
local unit u = CreateUnit(Player(14), unitId, GetRectMinX(GetWorldBounds()), GetRectMinY(GetWorldBounds()), 270.)
call RemoveUnit(u)
set u = null
endfunction
function Trig_Preload_Actions takes nothing returns nothing
call PreloadSound("Sounds\\Cash.MP3")
call PreloadSound("Sounds\\Flyby2.wav")
call PreloadSound("Sounds\\restricted.MP3")
call PreloadSound("Sound\\Ambient\\DoodadEffects\\RollingThunder1.wav")
call Preloader("Models\\Effects\\")
call PreloadUnit('h003')
endfunction
//===========================================================================
function InitTrig_Preload takes nothing returns nothing
set gg_trg_Preload = CreateTrigger()
call TriggerAddAction(gg_trg_Preload, function Trig_Preload_Actions)
call TriggerRegisterTimerEvent(gg_trg_Preload, 0., false)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_TeamIncome_Actions takes nothing returns nothing
local integer i = 0
loop
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD) + 1500)
set i = i + 1
exitwhen i > 11
endloop
call SetPlayerState(Player(5), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(1), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(2), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(3), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(4), PLAYER_STATE_RESOURCE_GOLD))
call SetPlayerState(Player(11), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(6), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(7), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(8), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(9), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(10), PLAYER_STATE_RESOURCE_GOLD))
endfunction
//===========================================================================
function InitTrig_TeamIncome takes nothing returns nothing
set gg_trg_TeamIncome = CreateTrigger()
call TriggerRegisterTimerEventPeriodic(gg_trg_TeamIncome, 60.)
call TriggerAddAction(gg_trg_TeamIncome, function Trig_TeamIncome_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
real FogColorRed = 1.00
real FogColorGreen = 1.00
real FogColorBlue = 1.00
real FogDensity = 1.00
real FogZStart = 1500.00
real FogZEnd = 3500.00
real tmp_R
real tmp_G
real tmp_B
real tmp_density
real tmp_zstart
real tmp_zend
real FogRate
boolean array FogFinish
trigger LoopFogFade = CreateTrigger()
endglobals
function ChangeFogSmooth takes real density, real ZStart, real ZEnd, real red, real green, real blue, real rate returns nothing
//CALL THIS FUNCTION TO GET A SMOOTH FOG CHANGE
local integer i = 0
set tmp_R = red
set tmp_G = green
set tmp_B = blue
set tmp_density = density
set tmp_zstart = ZStart
set tmp_zend = ZEnd
set FogRate = rate
loop
set FogFinish[i] = false
set i = i + 1
exitwhen i > 5
endloop
call EnableTrigger(LoopFogFade)
endfunction
function FadeFogColor takes nothing returns nothing
if FogColorRed < tmp_R - (FogRate * 5.) then
set FogColorRed = FogColorRed + FogRate
elseif FogColorRed > tmp_R + (FogRate * 5.) then
set FogColorRed = FogColorRed - FogRate
else
set FogColorRed = tmp_R
set FogFinish[0] = true
endif
if FogColorGreen < tmp_G - (FogRate * 5.) then
set FogColorGreen = FogColorGreen + FogRate
elseif FogColorGreen > tmp_G + (FogRate * 5.) then
set FogColorGreen = FogColorGreen - FogRate
else
set FogColorGreen = tmp_G
set FogFinish[1] = true
endif
if FogColorBlue < tmp_B - (FogRate * 5.) then
set FogColorBlue = FogColorBlue + FogRate
elseif FogColorBlue > tmp_B + (FogRate * 5.) then
set FogColorBlue = FogColorBlue - FogRate
else
set FogColorBlue = tmp_B
set FogFinish[2] = true
endif
if FogDensity < tmp_density - (FogRate * 5.) then
set FogDensity = FogDensity + FogRate
elseif FogDensity > tmp_density + (FogRate * 5.) then
set FogDensity = FogDensity - FogRate
else
set FogDensity = tmp_density
set FogFinish[3] = true
endif
if FogZStart < tmp_zstart - (FogRate * 1000.) then
set FogZStart = FogZStart + (FogRate * 1000.)
elseif FogZStart > tmp_zstart + (FogRate * 1000.) then
set FogZStart = FogZStart - (FogRate * 1000.)
else
set FogZStart = tmp_zstart
set FogFinish[4] = true
endif
if FogZEnd < tmp_zend - (FogRate * 1000.) then
set FogZEnd = FogZEnd + (FogRate * 1000.)
elseif FogZEnd > tmp_zend + (FogRate * 1000.) then
set FogZEnd = FogZEnd - (FogRate * 1000.)
else
set FogZEnd = tmp_zend
set FogFinish[5] = true
endif
call SetTerrainFogEx(0, FogZStart, FogZEnd, FogDensity, FogColorRed, FogColorGreen, FogColorBlue)
if FogFinish[0] and FogFinish[1] and FogFinish[2] and FogFinish[3] and FogFinish[4] and FogFinish[5] then
call DisableTrigger(LoopFogFade)
endif
endfunction
//===========================================================================
function InitTrig_InitFog takes nothing returns nothing
call TriggerRegisterTimerEvent(LoopFogFade, 0.03, true)
call TriggerAddAction(LoopFogFade, function FadeFogColor)
call DisableTrigger(LoopFogFade)
call SetTerrainFogEx(0, FogZStart, FogZEnd, FogDensity, FogColorRed, FogColorGreen, FogColorBlue)
endfunction
//TESH.scrollpos=35
//TESH.alwaysfold=0
globals
trigger FogNoon = CreateTrigger()
trigger Thunder = CreateTrigger()
integer CurrentWeather = 2
weathereffect WeatherEffect1 = null
weathereffect WeatherEffect2 = null
endglobals
function FogNoonActions takes nothing returns nothing
local integer i = GetRandomInt(0,3)
// 0 = clear
// 1 = rainy
// 2 = foggy
// 3 = thunder
if CurrentWeather != i then
set CurrentWeather = i
if i == 0 then
call RemoveWeatherEffect(WeatherEffect1)
call RemoveWeatherEffect(WeatherEffect2)
call ChangeFogSmooth(0.5, 3500., 5500., 1., 1., 1., 0.005)
call DisableTrigger(Thunder)
elseif i == 1 then
call RemoveWeatherEffect(WeatherEffect1)
call RemoveWeatherEffect(WeatherEffect2)
set WeatherEffect1 = AddWeatherEffect(gg_rct_Weather1, 'RAlr')
set WeatherEffect2 = AddWeatherEffect(gg_rct_Weather2, 'RAlr')
call EnableWeatherEffect(WeatherEffect1, true)
call EnableWeatherEffect(WeatherEffect2, true)
call ChangeFogSmooth(1., 1500., 3500., .5, .5, .5, 0.005)
call DisableTrigger(Thunder)
elseif i == 2 then
call RemoveWeatherEffect(WeatherEffect1)
call RemoveWeatherEffect(WeatherEffect2)
call ChangeFogSmooth(2., 1000., 3500., 1., 1., 1., 0.005)
call DisableTrigger(Thunder)
else
call RemoveWeatherEffect(WeatherEffect1)
call RemoveWeatherEffect(WeatherEffect2)
set WeatherEffect1 = AddWeatherEffect(gg_rct_Weather1, 'RAhr')
set WeatherEffect2 = AddWeatherEffect(gg_rct_Weather2, 'RAhr')
call EnableWeatherEffect(WeatherEffect1, true)
call EnableWeatherEffect(WeatherEffect2, true)
call ChangeFogSmooth(2., 500., 3500., .4, .4, .4, 0.005)
call EnableTrigger(Thunder)
endif
endif
endfunction
function ThunderLightning takes nothing returns nothing
set FogColorRed = 1.00
set FogColorGreen = 1.00
set FogColorBlue = 1.00
set FogDensity = 1.00
set FogZStart = 500.00
set FogZEnd = 3500.00
call SetTerrainFogEx(0, 0., 1000., 1., 1., 1., 1.)
call TriggerSleepAction(0)
call ChangeFogSmooth(2., 500., 3500., .4, .4, .4, 0.05)
call TriggerSleepAction(GetRandomReal(0.25, 1.))
call CreateSoundEx("Sound\\Ambient\\DoodadEffects\\RollingThunder1.wav")
endfunction
function ThunderActions takes nothing returns nothing
call ExecuteFunc("ThunderLightning")
endfunction
//===========================================================================
function InitTrig_FogController takes nothing returns nothing
call TriggerRegisterGameStateEvent(FogNoon, GAME_STATE_TIME_OF_DAY, EQUAL, 11.00)
call TriggerRegisterGameStateEvent(FogNoon, GAME_STATE_TIME_OF_DAY, EQUAL, 23.00)
call TriggerRegisterGameStateEvent(FogNoon, GAME_STATE_TIME_OF_DAY, EQUAL, 5.00)
call TriggerRegisterGameStateEvent(FogNoon, GAME_STATE_TIME_OF_DAY, EQUAL, 17.00)
call TriggerRegisterTimerEvent(Thunder, 15., true)
call TriggerAddAction(FogNoon, function FogNoonActions)
call TriggerAddAction(Thunder, function ThunderActions)
call DisableTrigger(Thunder)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
integer array UIS_Order
boolean array UIS_Target
widget array UIS_Widget
boolean array UIS_Pos
real array UIS_X
real array UIS_Y
boolean array UIS_NoTarget
endglobals
function Trig_GiveOrder_Actions takes nothing returns nothing
set UIS_Order[GetUnitUserData(GetTriggerUnit())] = GetIssuedOrderId()
set UIS_Target[GetUnitUserData(GetTriggerUnit())] = true
set UIS_Widget[GetUnitUserData(GetTriggerUnit())] = GetOrderTarget()
set UIS_Pos[GetUnitUserData(GetTriggerUnit())] = false
set UIS_NoTarget[GetUnitUserData(GetTriggerUnit())] = false
endfunction
//===========================================================================
function InitTrig_GiveOrderTarget takes nothing returns nothing
set gg_trg_GiveOrderTarget = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_GiveOrderTarget, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
call TriggerAddAction(gg_trg_GiveOrderTarget, function Trig_GiveOrder_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_GiveOrderPos_Actions takes nothing returns nothing
set UIS_Order[GetUnitUserData(GetTriggerUnit())] = GetIssuedOrderId()
set UIS_Pos[GetUnitUserData(GetTriggerUnit())] = true
set UIS_X[GetUnitUserData(GetTriggerUnit())] = GetOrderPointX()
set UIS_Y[GetUnitUserData(GetTriggerUnit())] = GetOrderPointY()
set UIS_Target[GetUnitUserData(GetTriggerUnit())] = false
set UIS_NoTarget[GetUnitUserData(GetTriggerUnit())] = false
endfunction
//===========================================================================
function InitTrig_GiveOrderPos takes nothing returns nothing
set gg_trg_GiveOrderPos = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_GiveOrderPos, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
call TriggerAddAction(gg_trg_GiveOrderPos, function Trig_GiveOrderPos_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//THIS FUNCTION FAILED BADLY!!
function Trig_GiveOrderNoTarget_Actions takes nothing returns nothing
set UIS_Order[GetUnitUserData(GetTriggerUnit())] = GetIssuedOrderId()
set UIS_NoTarget[GetUnitUserData(GetTriggerUnit())] = true
set UIS_Pos[GetUnitUserData(GetTriggerUnit())] = false
set UIS_Target[GetUnitUserData(GetTriggerUnit())] = false
endfunction
//===========================================================================
function InitTrig_GiveOrderNoTarget takes nothing returns nothing
set gg_trg_GiveOrderNoTarget = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_GiveOrderNoTarget, EVENT_PLAYER_UNIT_ISSUED_ORDER)
call TriggerAddAction(gg_trg_GiveOrderNoTarget, function Trig_GiveOrderNoTarget_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
group array SelectedUnits
boolean SelectedInitialized = false
unit SelectedUnitEffect
endglobals
function Trig_SelectionSelect_Conditions takes nothing returns boolean
return (GetOwningPlayer(GetTriggerUnit()) == Player(5) or GetOwningPlayer(GetTriggerUnit()) == Player(11)) and IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), GetTriggerPlayer())
endfunction
function Trig_SelectionSelect_Actions takes nothing returns nothing
call SetUnitOwner(GetTriggerUnit(), GetTriggerPlayer(), true)
set SelectedUnitEffect = CreateUnit(GetOwningPlayer(GetTriggerUnit()), 'h008', GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 270.)
if IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetLocalPlayer()) then
call SetUnitVertexColor(SelectedUnitEffect, 0, 0, 0, 0)
endif
// call GroupAddUnit(SelectedUnits[GetPlayerId(GetTriggerPlayer())], GetTriggerUnit())
if UIS_Target[GetUnitUserData(GetTriggerUnit())] == true then
call IssueTargetOrderById(GetTriggerUnit(), UIS_Order[GetUnitUserData(GetTriggerUnit())], UIS_Widget[GetUnitUserData(GetTriggerUnit())])
elseif UIS_Pos[GetUnitUserData(GetTriggerUnit())] == true then
call IssuePointOrderById(GetTriggerUnit(), UIS_Order[GetUnitUserData(GetTriggerUnit())], UIS_X[GetUnitUserData(GetTriggerUnit())], UIS_Y[GetUnitUserData(GetTriggerUnit())])
elseif UIS_NoTarget[GetUnitUserData(GetTriggerUnit())] == true then
call IssueImmediateOrderById(GetTriggerUnit(), UIS_Order[GetUnitUserData(GetTriggerUnit())])
endif
endfunction
//===========================================================================
function InitTrig_SelectionSelect takes nothing returns nothing
local integer i = 0
if SelectedInitialized == false then
loop
set SelectedUnits[i] = CreateGroup()
set i = i + 1
exitwhen i > 10
endloop
set SelectedInitialized = true
set i = 0
endif
set gg_trg_SelectionSelect = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_SelectionSelect, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
set i = i + 1
exitwhen i > 10
endloop
call TriggerAddCondition(gg_trg_SelectionSelect, Condition(function Trig_SelectionSelect_Conditions))
call TriggerAddAction(gg_trg_SelectionSelect, function Trig_SelectionSelect_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_SelectionSelectX_Actions takes nothing returns nothing
call GroupAddUnit(SelectedUnits[GetPlayerId(GetTriggerPlayer())], GetTriggerUnit())
endfunction
//===========================================================================
function InitTrig_SelectionSelectX takes nothing returns nothing
local integer i = 0
set gg_trg_SelectionSelectX = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_SelectionSelectX, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
set i = i + 1
exitwhen i > 10
endloop
call TriggerAddAction(gg_trg_SelectionSelectX, function Trig_SelectionSelectX_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_SelectionDeselect_Conditions takes nothing returns boolean
return GetOwningPlayer(GetTriggerUnit()) == GetTriggerPlayer()
endfunction
function Trig_SelectionDeselect_Actions takes nothing returns nothing
if not(SquadSelected[SquadNumber[GetUnitUserData(GetTriggerUnit())]]) then
if GetPlayerId(GetTriggerPlayer()) < 5 then
call SetUnitOwner(GetTriggerUnit(), Player(5), true)
else
call SetUnitOwner(GetTriggerUnit(), Player(11), true)
endif
endif
//call GroupRemoveUnit(SelectedUnits[GetPlayerId(GetTriggerPlayer())], GetTriggerUnit())
call RemoveGuardPosition(GetTriggerUnit())
if UIS_Target[GetUnitUserData(GetTriggerUnit())] == true then
call IssueTargetOrderById(GetTriggerUnit(), UIS_Order[GetUnitUserData(GetTriggerUnit())], UIS_Widget[GetUnitUserData(GetTriggerUnit())])
elseif UIS_Pos[GetUnitUserData(GetTriggerUnit())] == true then
call IssuePointOrderById(GetTriggerUnit(), UIS_Order[GetUnitUserData(GetTriggerUnit())], UIS_X[GetUnitUserData(GetTriggerUnit())], UIS_Y[GetUnitUserData(GetTriggerUnit())])
elseif UIS_NoTarget[GetUnitUserData(GetTriggerUnit())] == true then
call IssueImmediateOrderById(GetTriggerUnit(), UIS_Order[GetUnitUserData(GetTriggerUnit())])
endif
endfunction
//===========================================================================
function InitTrig_SelectionDeselect takes nothing returns nothing
local integer i = 0
set gg_trg_SelectionDeselect = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_SelectionDeselect, Player(i), EVENT_PLAYER_UNIT_DESELECTED, null)
set i = i + 1
exitwhen i > 10
endloop
call TriggerAddCondition(gg_trg_SelectionDeselect, Condition(function Trig_SelectionDeselect_Conditions))
call TriggerAddAction(gg_trg_SelectionDeselect, function Trig_SelectionDeselect_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_SelectionDeselectX_Actions takes nothing returns nothing
call GroupRemoveUnit(SelectedUnits[GetPlayerId(GetTriggerPlayer())], GetTriggerUnit())
endfunction
//===========================================================================
function InitTrig_SelectionDeselectX takes nothing returns nothing
local integer i = 0
set gg_trg_SelectionDeselectX = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_SelectionDeselectX, Player(i), EVENT_PLAYER_UNIT_DESELECTED, null)
set i = i + 1
exitwhen i > 10
endloop
call TriggerAddAction(gg_trg_SelectionDeselectX, function Trig_SelectionDeselectX_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_SelectionDisconnected_Actions takes nothing returns nothing
//Just to free the currently selected unit from the leaving player
if GetLocalPlayer() == GetTriggerPlayer() then
call ClearSelection()
endif
endfunction
//===========================================================================
function InitTrig_SelectionDisconnected takes nothing returns nothing
local integer i = 0
set gg_trg_SelectionDisconnected = CreateTrigger()
loop
call TriggerRegisterPlayerEvent(gg_trg_SelectionDisconnected, Player(i), EVENT_PLAYER_LEAVE)
set i = i + 1
exitwhen i > 10
endloop
call TriggerAddAction(gg_trg_SelectionDisconnected, function Trig_SelectionDisconnected_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//====================================================================
// UNIT INDEXING SYSTEM - by Illidan(evil)x
globals
unit array UVA_Units
endglobals
function FindNextUnusedUnitValue takes nothing returns integer
local integer i = 0
loop
exitwhen UVA_Units[i] == null or i == 8190
set i = i + 1
endloop
if i == 8190 then
call DisplayTextToPlayer(GetLocalPlayer(), 0., 0., "|cffff0000SCRIPT ERROR: Too many units in the game!!|r")
set i = 0
endif
return i
endfunction
function UnitAssignNewValue takes nothing returns nothing
call SetUnitUserData(GetEnumUnit(), FindNextUnusedUnitValue())
set UVA_Units[GetUnitUserData(GetEnumUnit())] = GetEnumUnit()
endfunction
function UnitValueAssignConditions takes nothing returns boolean
return GetPlayerId(GetOwningPlayer(GetTriggerUnit())) <= 11 and GetUnitAbilityLevel(GetTriggerUnit(), 'Aloc') == 0
endfunction
function InitializeExistingUnits takes nothing returns nothing
local group g = CreateGroup()
local integer i = 0
loop
call GroupEnumUnitsOfPlayer(g, Player(i), null)
call ForGroup(g, function UnitAssignNewValue)
call GroupClear(g)
set i = i + 1
exitwhen i > 11
endloop
call DestroyGroup(g)
set g = null
endfunction
function AddNewUnitValue takes nothing returns nothing
call SetUnitUserData(GetTriggerUnit(), FindNextUnusedUnitValue())
set UVA_Units[GetUnitUserData(GetTriggerUnit())] = GetTriggerUnit()
endfunction
function RemoveUnitValue takes nothing returns nothing
set UVA_Units[GetUnitUserData(GetTriggerUnit())] = null
endfunction
//===========================================================================
function InitTrig_UnitIndexing takes nothing returns nothing
local trigger t = CreateTrigger()
local region r = CreateRegion()
//ADD PREPLACED UNITS
set gg_trg_UnitIndexing = CreateTrigger()
call TriggerAddAction(gg_trg_UnitIndexing, function InitializeExistingUnits)
//ADD CREATED UNITS
call RegionAddRect(r, GetWorldBounds())
call TriggerRegisterEnterRegion(t, r, null)
call TriggerAddCondition(t, Condition(function UnitValueAssignConditions))
call TriggerAddAction(t, function AddNewUnitValue)
//REMOVE UNITS TRIGGER
set t = CreateTrigger()
call TriggerRegisterLeaveRegion(t, r, null)
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(t, Condition(function UnitValueAssignConditions))
call TriggerAddAction(t, function RemoveUnitValue)
set t = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
group TankGroup = CreateGroup()
trigger RegisterNewTank = CreateTrigger()
trigger TankKilled = CreateTrigger()
trigger TankLoop = CreateTrigger()
trigger WaitAddTankGroup = CreateTrigger()
rect TankRect = Rect(-400., -400., 400., 400.)
endglobals
function FindUnitNumber takes integer unitId returns integer
//Used to find unit number, based on a units RAW code
local integer i = 0
loop
exitwhen i > TotalVehicles or unitId == Stat_Type[i]
set i = i + 1
endloop
if i <= TotalVehicles then
//Found unit. Return value
return i
endif
//Unregistered unit. Return -1
return -1
endfunction
function FilterTanks takes nothing returns boolean
return Stat_KillDoodad[FindUnitNumber(GetUnitTypeId(GetFilterUnit()))]
endfunction
function TankKilledCond takes nothing returns boolean
return IsUnitInGroup(GetTriggerUnit(), TankGroup)
endfunction
function TankKilledAction takes nothing returns nothing
call GroupRemoveUnit(TankGroup, GetTriggerUnit())
endfunction
function TankRegister takes nothing returns nothing
call GroupAddUnit(TankGroup, GetTriggerUnit())
endfunction
function GetSmallDest takes nothing returns boolean
return GetDestructableMaxLife(GetFilterDestructable()) < 50. and GetDestructableLife(GetFilterDestructable()) > 0.
endfunction
function TankKillDest takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
function LoopTankEnum takes nothing returns nothing
call SetRect(TankRect, GetUnitX(GetEnumUnit())-150., GetUnitY(GetEnumUnit())-150., GetUnitX(GetEnumUnit())+150., GetUnitY(GetEnumUnit())+150.)
call EnumDestructablesInRect(TankRect, Filter(function GetSmallDest), function TankKillDest)
endfunction
function LoopTanks takes nothing returns nothing
call ForGroup(TankGroup, function LoopTankEnum)
endfunction
function AddTankDelay takes nothing returns nothing
call GroupEnumUnitsInRect(TankGroup, GetWorldBounds(), Filter(function FilterTanks))
call DestroyTrigger(WaitAddTankGroup)
set WaitAddTankGroup = null
endfunction
//===========================================================================
function InitTrig_InitUnitsKillDoodads takes nothing returns nothing
local region r = CreateRegion()
call RegionAddRect(r, GetWorldBounds())
call TriggerRegisterAnyUnitEventBJ(TankKilled, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(TankKilled, Condition(function TankKilledCond))
call TriggerAddAction(TankKilled, function TankKilledAction)
call TriggerRegisterEnterRegion(RegisterNewTank, r, Filter(function FilterTanks))
call TriggerAddAction(RegisterNewTank, function TankRegister)
call TriggerRegisterTimerEvent(TankLoop, 0.25, true)
call TriggerAddAction(TankLoop, function LoopTanks)
call TriggerRegisterTimerEvent(WaitAddTankGroup, 0.1, false)
call TriggerAddAction(WaitAddTankGroup, function AddTankDelay)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
unit DamageSource = null
trigger KillDestBuilding = CreateTrigger()
endglobals
function DestructableFilterLife takes nothing returns boolean
return GetDestructableLife(GetFilterDestructable()) > 0.
endfunction
function DestructableEnum takes nothing returns nothing
call SetDestructableLife(GetEnumDestructable(), GetDestructableLife(GetEnumDestructable()) - 100)
endfunction
function BarrelExplosion takes nothing returns nothing
local rect r = Rect(GetWidgetX(GetTriggerWidget())-250., GetWidgetY(GetTriggerWidget())-250., GetWidgetX(GetTriggerWidget())+250., GetWidgetY(GetTriggerWidget())+250.)
local effect e = AddSpecialEffect("Models\\Effects\\ArtilleryExplosion.mdx", GetWidgetX(GetTriggerWidget()), GetWidgetY(GetTriggerWidget()))
call TriggerSleepAction(0.1)
call UnitDamagePoint(DamageSource, 0., 250., GetWidgetX(GetTriggerWidget()), GetWidgetY(GetTriggerWidget()), 300., false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call EnumDestructablesInRect(r, Filter(function DestructableFilterLife), function DestructableEnum)
call TriggerSleepAction(12)
call DestroyEffect(e)
call RemoveRect(r)
set e = null
set r = null
endfunction
function BuldingExplosion takes nothing returns nothing
local effect e1 = CreateEffectZ("Models\\Effects\\NewMassiveEX.mdx", GetRandomReal(GetWidgetX(GetTriggerWidget())-150., GetWidgetX(GetTriggerWidget())+150.), GetRandomReal(GetWidgetY(GetTriggerWidget())-150., GetWidgetY(GetTriggerWidget())+150.), GetRandomReal(100., 500.))
local effect e2 = null
local effect e3 = null
call TriggerSleepAction(0.5)
set e2 = CreateEffectZ("Models\\Effects\\ArtilleryExplosion.mdx", GetRandomReal(GetWidgetX(GetTriggerWidget())-150., GetWidgetX(GetTriggerWidget())+150.), GetRandomReal(GetWidgetY(GetTriggerWidget())-150., GetWidgetY(GetTriggerWidget())+150.), GetRandomReal(100., 500.))
call TriggerSleepAction(0.5)
set e3 = CreateEffectZ("Models\\Effects\\NewMassiveEX.mdx", GetRandomReal(GetWidgetX(GetTriggerWidget())-150., GetWidgetX(GetTriggerWidget())+150.), GetRandomReal(GetWidgetY(GetTriggerWidget())-150., GetWidgetY(GetTriggerWidget())+150.), GetRandomReal(100., 500.))
call TriggerSleepAction(10.)
call DestroyEffect(e1)
call DestroyEffect(e2)
call DestroyEffect(e3)
set e1 = null
set e2 = null
set e3 = null
endfunction
function SortDestructables takes nothing returns nothing
if GetDestructableTypeId(GetDyingDestructable()) == 'B006' then //BARREL
call BarrelExplosion()
elseif GetDestructableTypeId(GetDyingDestructable()) == 'B005' then //CITY BUILDINGS
call BuldingExplosion()
endif
endfunction
function AddDestExp takes nothing returns nothing
call TriggerRegisterDeathEvent(gg_trg_DestrouctableDeath, GetEnumDestructable())
endfunction
//===========================================================================
function InitTrig_DestrouctableDeath takes nothing returns nothing
set gg_trg_DestrouctableDeath = CreateTrigger()
call TriggerAddAction(gg_trg_DestrouctableDeath, function SortDestructables)
call EnumDestructablesInRect(GetWorldBounds(), null, function AddDestExp)
//Add Destructable Damage Source
set DamageSource = CreateUnit(Player(14), 'ushd', GetRectMaxX(GetWorldBounds()), GetRectMinY(GetWorldBounds()), 270.)
call UnitAddAbility(DamageSource, 'Aloc')
endfunction
//TESH.scrollpos=67
//TESH.alwaysfold=0
// UNIT LIST
// 1 : M1A2 Abrams Battle Tank
// 2 : M2 Bradley Infantry Fighting Vehicle
// 3 : Scout Jeep
// 4 : AH-1 Cobra Attack Helicopter
// END UNIT LIST
globals
integer TotalVehicles = 0 //Total amount of purchaseable unit-types
real array Stat_Cost //The cost of the unit
string array Stat_Name //The name of the unit
integer array Stat_Bounty //The credits given to the killing player
integer array Stat_Type //The units RAW code. i.e. 'h000'
real array Stat_Scale //The units model scaling. Default is 1.00
string array Stat_Model //The file path to the units model
string array Stat_Damage //The damage of the unit, dmglow - dmghigh
integer array Stat_HP //The max hit points of the unit
integer array Stat_Speed //The speed of the unit
string array Stat_Ability //Abilities of the unit
integer array Stat_DeliverType //Unit deliver type. 1 = Crate ;; 2 = Flying in ;; 3 = Chinook Helicopter
boolean array Stat_KillDoodad //Is the unit able to run down small doodads?
endglobals
function Trig_InitUnitStats_Actions takes nothing returns nothing
local integer i = 0
//M1A2 Abrams
set Stat_Cost[i] = 1500.00
set Stat_Name[i] = "M1A2 Abrams Battle Tank"
set Stat_Bounty[i] = 250
set Stat_Type[i] = 'h000'
set Stat_Scale[i] = 0.80
set Stat_Model[i] = "Models\\M1_Abrams.mdx"
set Stat_Damage[i] = I2S(61)+"-"+I2S(71)
set Stat_HP[i] = 1000
set Stat_Speed[i] = 190
set Stat_Ability[i] = "N/A"
set Stat_DeliverType[i] = 1
set Stat_KillDoodad[i] = true
set i=i+1
//M2 Bradley
set Stat_Cost[i] = 750.00
set Stat_Name[i] = "M2 Bradley"
set Stat_Bounty[i] = 100
set Stat_Type[i] = 'h001'
set Stat_Scale[i] = 0.80
set Stat_Model[i] = "Models\\M2Bradley.mdx"
set Stat_Damage[i] = I2S(11)+"-"+I2S(21)
set Stat_HP[i] = 600
set Stat_Speed[i] = 250
set Stat_Ability[i] = "N/A"
set Stat_DeliverType[i] = 1
set Stat_KillDoodad[i] = true
set i=i+1
//Scout Jeep
set Stat_Cost[i] = 250.00
set Stat_Name[i] = "Scout Jeep"
set Stat_Bounty[i] = 50
set Stat_Type[i] = 'h002'
set Stat_Scale[i] = 0.75
set Stat_Model[i] = "Models\\Jeep.mdx"
set Stat_Damage[i] = "N/A"
set Stat_HP[i] = 200
set Stat_Speed[i] = 350
set Stat_Ability[i] = "N/A"
set Stat_DeliverType[i] = 1
set Stat_KillDoodad[i] = false
set i=i+1
//AH-1 Cobra
set Stat_Cost[i] = 1000.00
set Stat_Name[i] = "AH-1 Cobra"
set Stat_Bounty[i] = 200
set Stat_Type[i] = 'h003'
set Stat_Scale[i] = 0.80
set Stat_Model[i] = "Models\\CobraHelicopter.mdx"
set Stat_Damage[i] = I2S(11)+"-"+I2S(21)
set Stat_HP[i] = 500
set Stat_Speed[i] = 400
set Stat_Ability[i] = "Hellfire Missile"
set Stat_DeliverType[i] = 2
set Stat_KillDoodad[i] = false
set TotalVehicles=i
endfunction
function ShowUnitState takes integer unitId, player toPlayer returns nothing
if GetLocalPlayer() == toPlayer then
call ClearTextMessages()
endif
call DisplayTimedTextToPlayer(toPlayer, 0., 0., 480., "|cffff0000" + Stat_Name[unitId] + "|r\n Cost: |cff00ff00" + I2S(R2I(Stat_Cost[unitId])) + "$|r\n\n Damage: |cffffcc00" + Stat_Damage[unitId] + "|r\n Hit Points: |cffffcc00" + I2S(Stat_HP[unitId]) + "|r\n Speed: |cffffcc00" + I2S(Stat_Speed[unitId]) + "|r\n Abilities: |cffffcc00" + Stat_Ability[unitId] + "|r")
endfunction
//===========================================================================
function InitTrig_InitUnitStats takes nothing returns nothing
set gg_trg_InitUnitStats = CreateTrigger()
call TriggerAddAction(gg_trg_InitUnitStats, function Trig_InitUnitStats_Actions)
// set Stat_KillDoodad[-1] = false //OOPS. This created a crash.. :P
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
playercolor ColorCorrection_Color
integer ColorCorrectionId
endglobals
function NullLeak takes nothing returns boolean
return true
endfunction
function ColorCorrectionEnum takes nothing returns nothing
if GetLocalPlayer() == Player(ColorCorrectionId) then
call SetUnitColor(GetEnumUnit(), ColorCorrection_Color)
endif
endfunction
function Trig_PlayerColorCorrection_Actions takes nothing returns nothing
local group g = CreateGroup()
local unit u = null
local integer i = 0
local integer i2 = 6
//TEAM 1
loop
call GroupEnumUnitsOfPlayer(g, Player(5), Filter(function NullLeak))
set ColorCorrection_Color = ConvertPlayerColor(12)
set ColorCorrectionId = i
if GetLocalPlayer() == Player(i) then
call SetPlayerColor(Player(5), ConvertPlayerColor(12))
endif
call ForGroup(g, function ColorCorrectionEnum)
call GroupClear(g)
loop
call GroupEnumUnitsOfPlayer(g, Player(i2), Filter(function NullLeak))
set ColorCorrection_Color = PLAYER_COLOR_GREEN
set ColorCorrectionId = i
if GetLocalPlayer() == Player(i) then
call SetPlayerColor(Player(i2), PLAYER_COLOR_GREEN)
endif
call ForGroup(g, function ColorCorrectionEnum)
call GroupClear(g)
set i2 = i2 + 1
exitwhen i2 > 11
endloop
set i = i + 1
exitwhen i > 5
set i2 = 6
endloop
set i = 6
set i2 = 0
//TEAM 2
loop
call GroupEnumUnitsOfPlayer(g, Player(11), Filter(function NullLeak))
set ColorCorrection_Color = ConvertPlayerColor(12)
set ColorCorrectionId = i
if GetLocalPlayer() == Player(i) then
call SetPlayerColor(Player(11), ConvertPlayerColor(12))
endif
call ForGroup(g, function ColorCorrectionEnum)
call GroupClear(g)
loop
call GroupEnumUnitsOfPlayer(g, Player(i2), Filter(function NullLeak))
set ColorCorrection_Color = PLAYER_COLOR_RED
set ColorCorrectionId = i
if GetLocalPlayer() == Player(i) then
call SetPlayerColor(Player(i2), PLAYER_COLOR_RED)
endif
call ForGroup(g, function ColorCorrectionEnum)
call GroupClear(g)
set i2 = i2 + 1
exitwhen i2 > 5
endloop
set i = i + 1
exitwhen i > 11
set i2 = 0
endloop
call DestroyGroup(g)
set g = null
endfunction
//===========================================================================
function InitTrig_PlayerColorCorrection takes nothing returns nothing
set gg_trg_PlayerColorCorrection = CreateTrigger()
call TriggerAddAction(gg_trg_PlayerColorCorrection, function Trig_PlayerColorCorrection_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
integer GameStats_KillsTeam1 = 0
integer GameStats_KillsTeam2 = 0
integer GameStats_LostTeam1 = 0
integer GameStats_LostTeam2 = 0
real GameStats_BountyTeam1 = 0.0
real GameStats_BountyTeam2 = 0.0
real GameStats_UsedResourcesTeam1 = 0.0
real GameStats_UsedResourcesTeam2 = 0.0
dialog array gameStatDialog
button array gameStatBtn
boolean BInitStatDialog = false
endglobals
function InitStatDialog takes nothing returns nothing
local integer i = 0
loop
set gameStatDialog[i] = DialogCreate()
set i = i + 1
exitwhen i > 11
endloop
endfunction
function UpdateStatDialog takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
local string s = "Elapsed Game Time: "
//START CLOCK STRING (hour:min:sec)
if Clock_Hour < 10 then
set s = s + I2S(0)
endif
set s = s + I2S(Clock_Hour) + ":"
if Clock_Min < 10 then
set s = s + I2S(0)
endif
set s = s + I2S(Clock_Min) + ":"
if Clock_Sec < 10 then
set s = s + I2S(0)
endif
set s = s + I2S(Clock_Sec)
//END CLOCK STRING
call DialogClear(gameStatDialog[i])
call DialogSetMessage(gameStatDialog[i], "Game Stastistics")
call DialogAddButton(gameStatDialog[i], s, 0)
call DialogAddButton(gameStatDialog[i], "Total Kills [Team "+I2S(1)+"]: "+I2S(GameStats_KillsTeam1), 0)
call DialogAddButton(gameStatDialog[i], "Total Kills [Team "+I2S(2)+"]: "+I2S(GameStats_KillsTeam2), 0)
call DialogAddButton(gameStatDialog[i], "Units Lost [Team "+I2S(1)+"]: "+I2S(GameStats_LostTeam1), 0)
call DialogAddButton(gameStatDialog[i], "Units Lost [Team "+I2S(2)+"]: "+I2S(GameStats_LostTeam2), 0)
call DialogDisplay(Player(i), gameStatDialog[i], true)
set s = ""
endfunction
function Trig_GameStats_Actions takes nothing returns nothing
if BInitStatDialog == false then
set BInitStatDialog = true
call InitStatDialog()
else
call UpdateStatDialog()
endif
endfunction
//===========================================================================
function InitTrig_GameStats takes nothing returns nothing
set gg_trg_GameStats = CreateTrigger()
call TriggerAddAction(gg_trg_GameStats, function Trig_GameStats_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
integer Clock_Sec = 0
integer Clock_Min = 0
integer Clock_Hour = 0
endglobals
function Trig_GameTimer_Actions takes nothing returns nothing
set Clock_Sec = Clock_Sec + 1
if Clock_Sec >= 60 then
set Clock_Sec = 0
set Clock_Min = Clock_Min + 1
if Clock_Min >= 60 then
set Clock_Min = 0
set Clock_Hour = Clock_Hour + 1
endif
endif
endfunction
//===========================================================================
function InitTrig_GameTimer takes nothing returns nothing
set gg_trg_GameTimer = CreateTrigger()
call TriggerRegisterTimerEvent(gg_trg_GameTimer, 1., true)
call TriggerAddAction(gg_trg_GameTimer, function Trig_GameTimer_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function AddPlayerStatePoint takes integer team returns nothing
local integer i = 6*team
local integer max = i+5
loop
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_LUMBER) + 1)
set i = i + 1
exitwhen i > max
endloop
endfunction
function Trig_StatAddKill_Cond takes nothing returns boolean
return GetUnitAbilityLevel(GetTriggerUnit(), 'Aloc') == 0
endfunction
function Trig_StatAddKill_Actions takes nothing returns nothing
if IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetKillingUnit())) then
if GetPlayerId(GetOwningPlayer(GetTriggerUnit())) <= 5 then
set GameStats_KillsTeam2 = GameStats_KillsTeam2 + 1
call AddPlayerStatePoint(1)
else
set GameStats_KillsTeam1 = GameStats_KillsTeam1 + 1
call AddPlayerStatePoint(0)
endif
endif
if GetPlayerId(GetOwningPlayer(GetTriggerUnit())) <= 5 then
set GameStats_LostTeam1 = GameStats_LostTeam1 + 1
else
set GameStats_LostTeam2 = GameStats_LostTeam2 + 1
endif
endfunction
//===========================================================================
function InitTrig_StatAddKill takes nothing returns nothing
set gg_trg_StatAddKill = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_StatAddKill, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(gg_trg_StatAddKill, Condition(function Trig_StatAddKill_Cond))
call TriggerAddAction(gg_trg_StatAddKill, function Trig_StatAddKill_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
boolean array EnableMenu
boolean Menu_InitMenu = false
dialog Menu_MainMenu = null
button Menu_Resume = null
button Menu_GameStat = null
button Menu_BuyUnits = null
button Menu_Abilities = null
button Menu_Camera = null
//
endglobals
function InitMenu takes nothing returns nothing
set Menu_MainMenu = DialogCreate()
call DialogSetMessage(Menu_MainMenu, "Menu")
set Menu_Resume = DialogAddButton(Menu_MainMenu, "|cFFFF0000[«]|r Resume Game", 0)
set Menu_GameStat = DialogAddButton(Menu_MainMenu, "|cFF0000FF[?]|r Game Statistics", 0)
set Menu_BuyUnits = DialogAddButton(Menu_MainMenu, "|cFF00FF00[$]|r Order Units", 0)
set Menu_Abilities = DialogAddButton(Menu_MainMenu, "|cFFFFFFFF[!]|r Special Weapons", 0)
set Menu_Camera = DialogAddButton(Menu_MainMenu, "|cFF909090[¤]|r Camera", 0)
call TriggerRegisterDialogButtonEvent(gg_trg_GameStats, Menu_GameStat)
call TriggerRegisterDialogButtonEvent(gg_trg_ButtonOrderVehicle, Menu_BuyUnits)
call TriggerRegisterDialogButtonEvent(gg_trg_SpecialWeaponsPanel, Menu_Abilities)
call TriggerRegisterDialogButtonEvent(gg_trg_StartCameraConfig, Menu_Camera)
endfunction
function Trig_EnterMenu_Conditions takes nothing returns boolean
return EnableMenu[GetPlayerId(GetTriggerPlayer())]
endfunction
function Trig_EnterMenu_Actions takes nothing returns nothing
if Menu_InitMenu == false then
call InitMenu()
set Menu_InitMenu = true
endif
call DialogDisplay(GetTriggerPlayer(), Menu_MainMenu, true)
endfunction
//===========================================================================
function InitTrig_EnterMenu takes nothing returns nothing
local integer i = 0
set gg_trg_EnterMenu = CreateTrigger()
loop
call TriggerRegisterPlayerEvent(gg_trg_EnterMenu, Player(i), EVENT_PLAYER_END_CINEMATIC)
//DISABLE MENU FOR ALL PLAYERS
set EnableMenu[i] = false
set i = i + 1
exitwhen i > 10
endloop
call TriggerAddCondition(gg_trg_EnterMenu, Condition(function Trig_EnterMenu_Conditions))
call TriggerAddAction(gg_trg_EnterMenu, function Trig_EnterMenu_Actions)
endfunction
//TESH.scrollpos=20
//TESH.alwaysfold=0
globals
effect array UnitPreSFX
unit array PreviewUnit
unit array PreviewDummy
boolean array CameraLoop
texttag array RemCredits
integer array PreviewUnitId
endglobals
function Trig_ButtonOrderVehicle_Actions takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
local string s = ""
set PreviewUnitId[i] = 0
set PreviewUnit[i] = CreateUnit(GetTriggerPlayer(), 'h004', GetRectCenterX(gg_rct_UnitPreviewRect), GetRectCenterY(gg_rct_UnitPreviewRect), 90.)
set PreviewDummy[i] = CreateUnit(GetTriggerPlayer(), 'h005', GetRectCenterX(gg_rct_UnitPreviewRect), GetRectCenterY(gg_rct_UnitPreviewRect), 270.)
call SetUnitVertexColor(PreviewUnit[i], 255, 255, 255, 0)
set EnableMenu[i] = false
call ShowUnitState(0, GetTriggerPlayer())
//
set RemCredits[i] = CreateTextTag()
call SetTextTagColor(RemCredits[i], 0, 255, 0, 255)
call SetTextTagText(RemCredits[i], I2S(GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD)) + "$", TextTagSize2Height(20.))
call SetTextTagPos(RemCredits[i], GetRectCenterX(gg_rct_UnitPreview2), GetRectCenterY(gg_rct_UnitPreview2), 50.)
call SetTextTagVisibility(RemCredits[i], false)
//
if GetLocalPlayer() == GetTriggerPlayer() then
call SetTextTagVisibility(RemCredits[i], true)
call ClearSelection()
call SelectUnit(PreviewDummy[i], true)
call SetUnitVertexColor(PreviewUnit[i], 255, 255, 255, 255)
call SetCameraPosition(GetRectCenterX(gg_rct_UnitPreviewRect), GetRectCenterY(gg_rct_UnitPreviewRect))
call SetCameraField(CAMERA_FIELD_ROTATION, 225., 0.)
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 600., 0.)
call SetCameraField(CAMERA_FIELD_ZOFFSET, 50., 0.)
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, 340., 0.)
call SetCameraField(CAMERA_FIELD_FARZ, 850., 0.)
call PanCameraTo(GetRectCenterX(gg_rct_UnitPreviewRect), GetRectCenterY(gg_rct_UnitPreviewRect))
set s = Stat_Model[0]
endif
set UnitPreSFX[i] = AddSpecialEffectTarget(s, PreviewUnit[i], "sprite first")
set CameraLoop[i] = true
set s = null
endfunction
//===========================================================================
function InitTrig_ButtonOrderVehicle takes nothing returns nothing
local fogmodifier Fog
local integer i = 0
loop
set CameraLoop[i] = false
set Fog = CreateFogModifierRadius(Player(i), FOG_OF_WAR_VISIBLE, GetRectCenterX(gg_rct_UnitPreviewRect), GetRectCenterY(gg_rct_UnitPreviewRect), 500., false, false)
call FogModifierStart(Fog)
set i = i + 1
exitwhen i > 10
endloop
set gg_trg_ButtonOrderVehicle = CreateTrigger()
call TriggerAddAction(gg_trg_ButtonOrderVehicle, function Trig_ButtonOrderVehicle_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_PreviewAnimation_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A003' or GetSpellAbilityId() == 'A004' or GetSpellAbilityId() == 'A007'
endfunction
function Trig_PreviewAnimation_Actions takes nothing returns nothing
if GetSpellAbilityId() == 'A003' then
call SetUnitTimeScale(PreviewUnit[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))], 1.)
elseif GetSpellAbilityId() == 'A004' then
call SetUnitTimeScale(PreviewUnit[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))], 0.)
else
call SetUnitTimeScale(PreviewUnit[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))], -1.)
endif
endfunction
//===========================================================================
function InitTrig_PreviewAnimationStopPlay takes nothing returns nothing
set gg_trg_PreviewAnimationStopPlay = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_PreviewAnimationStopPlay, EVENT_PLAYER_UNIT_SPELL_CHANNEL)
call TriggerAddCondition(gg_trg_PreviewAnimationStopPlay, Condition(function Trig_PreviewAnimation_Conditions))
call TriggerAddAction(gg_trg_PreviewAnimationStopPlay, function Trig_PreviewAnimation_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_ReturnToMenu_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A006'
endfunction
function Trig_ReturnToMenu_Actions takes nothing returns nothing
local integer i = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
set CameraLoop[i] = false
call DestroyEffect(UnitPreSFX[i])
call RemoveUnit(PreviewUnit[i])
call KillUnit(PreviewDummy[i])
call DestroyTextTag(RemCredits[i])
set EnableMenu[i] = true
if i < 5 then
if GetLocalPlayer() == Player(i) then
call ClearTextMessages()
call ResetToGameCamera(0.)
call SetCameraPosition(GetRectCenterX(gg_rct_RedBase), GetRectCenterY(gg_rct_RedBase))
endif
else
if GetLocalPlayer() == Player(i) then
call ClearTextMessages()
call ResetToGameCamera(0.)
call SetCameraPosition(GetRectCenterX(gg_rct_BlueBase), GetRectCenterY(gg_rct_BlueBase))
endif
endif
call DialogDisplay(Player(i), Menu_MainMenu, true)
endfunction
//===========================================================================
function InitTrig_ReturnToMenu takes nothing returns nothing
set gg_trg_ReturnToMenu = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_ReturnToMenu, EVENT_PLAYER_UNIT_SPELL_CHANNEL)
call TriggerAddCondition(gg_trg_ReturnToMenu, Condition(function Trig_ReturnToMenu_Conditions))
call TriggerAddAction(gg_trg_ReturnToMenu, function Trig_ReturnToMenu_Actions)
endfunction
//TESH.scrollpos=5
//TESH.alwaysfold=0
function Trig_NextPreviousUnit_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A002' or GetSpellAbilityId() == 'A000'
endfunction
function Trig_NextPreviousUnit_Actions takes nothing returns nothing
local integer i = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
local string s = ""
if GetSpellAbilityId() == 'A002' then
if PreviewUnitId[i] == TotalVehicles then
set PreviewUnitId[i] = 0
else
set PreviewUnitId[i] = PreviewUnitId[i] + 1
endif
else
if PreviewUnitId[i] == 0 then
set PreviewUnitId[i] = TotalVehicles
else
set PreviewUnitId[i] = PreviewUnitId[i] - 1
endif
endif
call DestroyEffect(UnitPreSFX[i])
call RemoveUnit(PreviewUnit[i])
set PreviewUnit[i] = CreateUnit(Player(i), 'h004', GetRectCenterX(gg_rct_UnitPreviewRect), GetRectCenterY(gg_rct_UnitPreviewRect), 90.)
if GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) then
set s = Stat_Model[PreviewUnitId[i]]
endif
set UnitPreSFX[GetPlayerId(GetTriggerPlayer())] = AddSpecialEffectTarget(s, PreviewUnit[GetPlayerId(GetTriggerPlayer())], "sprite first")
call SetUnitScale(PreviewUnit[i], Stat_Scale[PreviewUnitId[i]], Stat_Scale[PreviewUnitId[i]], Stat_Scale[PreviewUnitId[i]])
call ShowUnitState(PreviewUnitId[i], Player(i))
set s = null
endfunction
//===========================================================================
function InitTrig_NextPreviousUnit takes nothing returns nothing
set gg_trg_NextPreviousUnit = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_NextPreviousUnit, EVENT_PLAYER_UNIT_SPELL_CHANNEL)
call TriggerAddCondition(gg_trg_NextPreviousUnit, Condition(function Trig_NextPreviousUnit_Conditions))
call TriggerAddAction(gg_trg_NextPreviousUnit, function Trig_NextPreviousUnit_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
texttag BuyTT
endglobals
function OrderUnitFuncCargo takes integer unitId, real x, real y, integer Owner returns nothing
local unit Plane
local unit Crate
local real Direction
set Direction = GetRandomReal(0., 360.)
//
call TriggerSleepAction(2)
call CreateSoundAtPoint("Sounds\\Flyby2.wav", x, y)
call TriggerSleepAction(3)
set Plane = CreateUnit(Player(14), 'h007', x, y, Direction)
call TriggerSleepAction(1.8)
set Crate = CreateUnit(Player(14), 'h006', x, y, Direction)
call SetUnitScale(Crate, Stat_Scale[unitId] - 0.2, Stat_Scale[unitId] - 0.2, Stat_Scale[unitId] - 0.2)
call SetUnitAnimation(Crate, "birth")
call TriggerSleepAction(7)
call CreateUnit(Player(Owner), Stat_Type[unitId], x, y, Direction)
call KillUnit(Crate)
call RemoveUnit(Plane)
endfunction
function OrderUnitFuncFlyIn takes integer unitId, real x, real y, integer Owner returns nothing
local unit Unit
local real X = GetRandomReal(GetCameraBoundMinX(), GetCameraBoundMaxX())
local real Y = GetRandomReal(GetCameraBoundMinY(), GetCameraBoundMaxY())
if Owner == 5 then
if GetRandomInt(0, 1) == 0 then
set X = GetCameraBoundMinX()
else
set Y = GetCameraBoundMaxY()
endif
else
if GetRandomInt(0, 1) == 0 then
set X = GetCameraBoundMaxX()
else
set Y = GetCameraBoundMinY()
endif
endif
set Unit = CreateUnit(Player(14), Stat_Type[unitId], X, Y, 270.)
call UnitAddAbility(Unit, 'Aloc')
call IssuePointOrder(Unit, "move", x, y)
loop
exitwhen SquareRoot((GetUnitX(Unit) - x) * (GetUnitX(Unit) - x) + (GetUnitY(Unit) - y) * (GetUnitY(Unit) - y)) <= 200.
call TriggerSleepAction(0.25)
call IssuePointOrder(Unit, "move", x, y)
endloop
if Owner == 5 then
call CreateUnit(Player(5), Stat_Type[unitId], GetUnitX(Unit), GetUnitY(Unit), GetUnitFacing(Unit))
else
call CreateUnit(Player(11), Stat_Type[unitId], GetUnitX(Unit), GetUnitY(Unit), GetUnitFacing(Unit))
endif
call RemoveUnit(Unit)
set Unit = null
endfunction
function OrderUnitFunc takes integer unitId, player p returns nothing
local real X
local real Y
local integer i
if GetPlayerId(p) < 5 then
set X = GetRandomReal(GetRectMinX(gg_rct_AirportTeamRed), GetRectMaxX(gg_rct_AirportTeamRed))
set Y = GetRandomReal(GetRectMinY(gg_rct_AirportTeamRed), GetRectMaxY(gg_rct_AirportTeamRed))
set i = 5
else
set X = GetRandomReal(GetRectMinX(gg_rct_AirportTeamBlue), GetRectMaxX(gg_rct_AirportTeamBlue))
set Y = GetRandomReal(GetRectMinY(gg_rct_AirportTeamBlue), GetRectMaxY(gg_rct_AirportTeamBlue))
set i = 11
endif
if Stat_DeliverType[unitId] == 1 then
//CARGO CRATE
call OrderUnitFuncCargo(unitId, X, Y, i)
elseif Stat_DeliverType[unitId] == 2 then
//FLYING IN
call OrderUnitFuncFlyIn(unitId, X, Y, i)
elseif Stat_DeliverType[unitId] == 3 then
//CHINOOK IN!!!
//call OrderUnitFuncFlyIn(unitId, X, Y, i)
//ADD NEW FUNCTION HERE!!!
//********************************************************************************************************************************'
endif
endfunction
//*******************************************************
function Trig_OrderUnit_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A005'
endfunction
function Trig_OrderUnit_Actions takes nothing returns nothing
if GetPlayerState(GetOwningPlayer(GetTriggerUnit()), PLAYER_STATE_RESOURCE_GOLD) >= Stat_Cost[PreviewUnitId[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))]] then
//if GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) then
// call ClearTextMessages()
//endif
//
set BuyTT = CreateTextTag()
call SetTextTagColor(BuyTT, 255, 0, 0, 255)
call SetTextTagText(BuyTT, "-" + I2S(R2I(Stat_Cost[PreviewUnitId[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))]])) + "$", TextTagSize2Height(20.))
call SetTextTagPos(BuyTT, GetRectCenterX(gg_rct_UnitPreview2), GetRectCenterY(gg_rct_UnitPreview2), 100.)
call SetTextTagVisibility(BuyTT, false)
if GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) then
call SetTextTagVisibility(BuyTT, true)
endif
call SetTextTagLifespan(BuyTT, 3.)
call SetTextTagFadepoint(BuyTT, 2.)
call SetTextTagPermanent(BuyTT, false)
//
set BuyTT = CreateTextTag()
call SetTextTagColor(BuyTT, 0, 255, 0, 255)
call SetTextTagText(BuyTT, "UNIT PURCHASED", TextTagSize2Height(20.))
call SetTextTagPos(BuyTT, GetRectCenterX(gg_rct_UnitPreview1), GetRectCenterY(gg_rct_UnitPreview1), 25.)
call SetTextTagVisibility(BuyTT, false)
if GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) then
call SetTextTagVisibility(BuyTT, true)
endif
call SetTextTagLifespan(BuyTT, 3.)
call SetTextTagFadepoint(BuyTT, 2.)
call SetTextTagPermanent(BuyTT, false)
//
call CreateSoundForPlayer("Sounds\\Cash.MP3", GetOwningPlayer(GetTriggerUnit()))
// call DisplayTextToPlayer(GetOwningPlayer(GetTriggerUnit()), 0.5, 0.5, "|cff00ff00UNIT PURCHASED|r")
call SetPlayerState(GetOwningPlayer(GetTriggerUnit()), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(GetOwningPlayer(GetTriggerUnit()), PLAYER_STATE_RESOURCE_GOLD) - R2I(Stat_Cost[PreviewUnitId[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))]]))
call SetPlayerState(Player(5), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(1), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(2), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(3), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(4), PLAYER_STATE_RESOURCE_GOLD))
call SetPlayerState(Player(11), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(6), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(7), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(8), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(9), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(10), PLAYER_STATE_RESOURCE_GOLD))
call SetTextTagText(RemCredits[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))], I2S(GetPlayerState(GetOwningPlayer(GetTriggerUnit()), PLAYER_STATE_RESOURCE_GOLD)) + "$", TextTagSize2Height(20.))
call OrderUnitFunc(PreviewUnitId[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))], GetOwningPlayer(GetTriggerUnit()))
//call TriggerSleepAction(1.)
//call ShowUnitState(PreviewUnitId[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))], GetOwningPlayer(GetTriggerUnit()))
else
//if GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) then
// call ClearTextMessages()
//endif
//
call CreateSoundForPlayer("Sounds\\restricted.MP3", GetOwningPlayer(GetTriggerUnit()))
set BuyTT = CreateTextTag()
call SetTextTagColor(BuyTT, 255, 0, 0, 255)
call SetTextTagText(BuyTT, "NOT ENOUGH CREDITS", TextTagSize2Height(20.))
call SetTextTagPos(BuyTT, GetRectCenterX(gg_rct_UnitPreview1), GetRectCenterY(gg_rct_UnitPreview1), 25.)
call SetTextTagVisibility(BuyTT, false)
if GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) then
call SetTextTagVisibility(BuyTT, true)
endif
call SetTextTagLifespan(BuyTT, 3.)
call SetTextTagFadepoint(BuyTT, 2.)
call SetTextTagPermanent(BuyTT, false)
//
//call DisplayTextToPlayer(GetOwningPlayer(GetTriggerUnit()), 0.5, 0.5, "|cffff0000NOT ENOUGH CREDITS|r")
//call TriggerSleepAction(1.)
//call ShowUnitState(PreviewUnitId[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))], GetOwningPlayer(GetTriggerUnit()))
endif
endfunction
//===========================================================================
function InitTrig_OrderUnit takes nothing returns nothing
set gg_trg_OrderUnit = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_OrderUnit, EVENT_PLAYER_UNIT_SPELL_CHANNEL)
call TriggerAddCondition(gg_trg_OrderUnit, Condition(function Trig_OrderUnit_Conditions))
call TriggerAddAction(gg_trg_OrderUnit, function Trig_OrderUnit_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_CameraAttachLoop_Actions takes nothing returns nothing
local integer i = 0
loop
if CameraLoop[i] and GetLocalPlayer() == Player(i) then
call SetCameraPosition(GetRectCenterX(gg_rct_UnitPreviewRect), GetRectCenterY(gg_rct_UnitPreviewRect))
call SetCameraField(CAMERA_FIELD_ROTATION, 225., 0.)
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 600., 0.)
call SetCameraField(CAMERA_FIELD_ZOFFSET, 50., 0.)
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, 340., 0.)
call SetCameraField(CAMERA_FIELD_FARZ, 850., 0.)
call SelectUnit(PreviewDummy[i], true)
endif
set i = i + 1
exitwhen i > 10
endloop
endfunction
//===========================================================================
function InitTrig_CameraAttachLoop takes nothing returns nothing
set gg_trg_CameraAttachLoop = CreateTrigger( )
call TriggerRegisterTimerEvent(gg_trg_CameraAttachLoop, .02, true)
call TriggerAddAction(gg_trg_CameraAttachLoop, function Trig_CameraAttachLoop_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
integer array SW_AbilityID //The Ability RAW code
integer array SW_BuyAbilityID //The unabled Ability RAW code
integer array SW_AbilityCost //The cost of the ability
boolean array SW_Bought //
real array SW_Cooldown //Cooldown of the ability (!make a cooldown trigger)
real array SW_CurrentCooldownP0
real array SW_CurrentCooldownP1
real array SW_CurrentCooldownP2
real array SW_CurrentCooldownP3
real array SW_CurrentCooldownP4
real array SW_CurrentCooldownP6
real array SW_CurrentCooldownP7
real array SW_CurrentCooldownP8
real array SW_CurrentCooldownP9
real array SW_CurrentCooldownP10
integer SWCount = 0
endglobals
function SpecialWeaponsInit takes nothing returns nothing
//Artillery
set SW_AbilityID[SWCount] = 'A008'
set SW_BuyAbilityID[SWCount] = 'A008'
set SW_AbilityCost[SWCount] = 500
set SW_Bought[SWCount] = false
set SW_Cooldown[SWCount] = 30.00
//**********************
set SWCount=SWCount+1
set SW_AbilityID[SWCount] = 'A009'
set SW_BuyAbilityID[SWCount] = 'A009'
set SW_AbilityCost[SWCount] = 500
set SW_Bought[SWCount] = false
set SW_Cooldown[SWCount] = 30.00
//**********************
//set SWCount=SWCount+1
//set SW_AbilityID[SWCount] = 'A000'
//set SW_BuyAbilityID[SWCount] = 'A001'
//set SW_AbilityCost[SWCount] = 500
//set SW_Bought[SWCount] = false
//set SW_Cooldown[SWCount] = 30.00
endfunction
function GetPlayerAbilityCooldown takes integer PlayerId, integer Ability returns real
if PlayerId == 0 then
return SW_CurrentCooldownP0[Ability]
elseif PlayerId == 1 then
return SW_CurrentCooldownP1[Ability]
elseif PlayerId == 2 then
return SW_CurrentCooldownP2[Ability]
elseif PlayerId == 3 then
return SW_CurrentCooldownP3[Ability]
elseif PlayerId == 4 then
return SW_CurrentCooldownP4[Ability]
elseif PlayerId == 6 then
return SW_CurrentCooldownP6[Ability]
elseif PlayerId == 7 then
return SW_CurrentCooldownP7[Ability]
elseif PlayerId == 8 then
return SW_CurrentCooldownP8[Ability]
elseif PlayerId == 9 then
return SW_CurrentCooldownP9[Ability]
elseif PlayerId == 10 then
return SW_CurrentCooldownP10[Ability]
endif
return 1.00
endfunction
function UnitAddAbilities takes unit u, integer PlayerId returns nothing
local integer i = 0
loop
if GetPlayerState(Player(PlayerId), PLAYER_STATE_RESOURCE_GOLD) >= SW_AbilityCost[i] and GetPlayerAbilityCooldown(PlayerId, i) <= 0. then
call UnitAddAbility(u, SW_AbilityID[i])
else
call UnitAddAbility(u, SW_BuyAbilityID[i])
endif
set i = i + 1
exitwhen i >SWCount
endloop
endfunction
function Trig_SpecialWeaponsPanel_Actions takes nothing returns nothing
local unit u = CreateUnit(GetTriggerPlayer(), 'h00B', GetRectMinX(GetWorldBounds()),GetRectMinY(GetWorldBounds()),270.)
local integer i = GetPlayerId(GetTriggerPlayer())
if GetLocalPlayer() == GetTriggerPlayer() then
call ClearSelection()
call SelectUnit(u, true)
endif
call UnitAddAbilities(u, i)
call TriggerSleepAction(0.5)
loop
call TriggerSleepAction(0.1)
set bj_groupCountUnits = 0
call ForGroup(SelectedUnits[i], function CountUnitsInGroupEnum)
exitwhen bj_groupCountUnits != 1 or IsUnitInGroup(u, SelectedUnits[i]) != true
endloop
call KillUnit(u)
call TriggerSleepAction(0.5)
call RemoveUnit(u)
set u = null
endfunction
//===========================================================================
function InitTrig_SpecialWeaponsPanel takes nothing returns nothing
local integer i = 0
call SpecialWeaponsInit()
loop
set SW_CurrentCooldownP0[i] = 0.00
set SW_CurrentCooldownP1[i] = 0.00
set SW_CurrentCooldownP2[i] = 0.00
set SW_CurrentCooldownP3[i] = 0.00
set SW_CurrentCooldownP4[i] = 0.00
set SW_CurrentCooldownP6[i] = 0.00
set SW_CurrentCooldownP7[i] = 0.00
set SW_CurrentCooldownP8[i] = 0.00
set SW_CurrentCooldownP9[i] = 0.00
set SW_CurrentCooldownP10[i] = 0.00
set i = i + 1
exitwhen i > SWCount
endloop
set gg_trg_SpecialWeaponsPanel = CreateTrigger()
call TriggerAddAction(gg_trg_SpecialWeaponsPanel, function Trig_SpecialWeaponsPanel_Actions)
endfunction
//TESH.scrollpos=10
//TESH.alwaysfold=0
globals
integer array UnitBountyValue
group AUB_Group = CreateGroup()
trigger AUB_trg
endglobals
function Trig_AddUnitBountyValue_Conditions takes nothing returns boolean
return GetPlayerId(GetOwningPlayer(GetTriggerUnit())) <= 11 and GetUnitAbilityLevel(GetTriggerUnit(), 'Aloc') == 0
endfunction
function Trig_AddUnitBountyValue_Filter takes nothing returns boolean
return GetPlayerId(GetOwningPlayer(GetFilterUnit())) <= 11 and GetUnitAbilityLevel(GetFilterUnit(), 'Aloc') == 0
endfunction
function Trig_AddUnitBountyValue_Group takes nothing returns nothing
local integer i = 0
loop
exitwhen i > TotalVehicles or GetUnitTypeId(GetEnumUnit()) == Stat_Type[i]
set i = i + 1
endloop
if i <= TotalVehicles then
set UnitBountyValue[GetUnitUserData(GetEnumUnit())] = Stat_Bounty[i]
endif
call GroupRemoveUnit(AUB_Group, GetEnumUnit())
endfunction
function Trig_AddUnitBountyValue_Actions takes nothing returns nothing
local integer i = 0
loop
exitwhen i > TotalVehicles or GetUnitTypeId(GetTriggerUnit()) == Stat_Type[i]
set i = i + 1
endloop
if i > TotalVehicles then
return
endif
call TriggerSleepAction(.5)
set UnitBountyValue[GetUnitUserData(GetTriggerUnit())] = Stat_Bounty[i]
endfunction
function AddUnitBountyInitAll takes nothing returns nothing
call GroupEnumUnitsInRect(AUB_Group, GetWorldBounds(), Filter(function Trig_AddUnitBountyValue_Filter))
call ForGroup(AUB_Group, function Trig_AddUnitBountyValue_Group)
call DestroyGroup(AUB_Group)
endfunction
//===========================================================================
function InitTrig_AddUnitBountyValue takes nothing returns nothing
set gg_trg_AddUnitBountyValue = CreateTrigger()
call TriggerRegisterEnterRectSimple(gg_trg_AddUnitBountyValue, GetWorldBounds())
call TriggerAddCondition(gg_trg_AddUnitBountyValue, Condition(function Trig_AddUnitBountyValue_Conditions))
call TriggerAddAction(gg_trg_AddUnitBountyValue, function Trig_AddUnitBountyValue_Actions)
set AUB_trg = CreateTrigger()
call TriggerRegisterTimerEvent(AUB_trg, 1., false)
call TriggerAddAction(AUB_trg, function AddUnitBountyInitAll)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_BountyAdd_Conditions takes nothing returns boolean
return GetPlayerId(GetOwningPlayer(GetTriggerUnit())) <= 11 and GetUnitAbilityLevel(GetTriggerUnit(), 'Aloc') == 0 and IsPlayerEnemy(GetOwningPlayer(GetKillingUnit()), GetOwningPlayer(GetTriggerUnit()))
endfunction
function Trig_BountyAdd_Actions takes nothing returns nothing
local integer i = 0
local texttag tt = CreateTextTag()
call SetTextTagText(tt, "+" + I2S(UnitBountyValue[GetUnitUserData(GetTriggerUnit())]), 0.03)
call SetTextTagColor(tt, 0, 255, 0, 255)
call SetTextTagPos(tt, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 100.)
call SetTextTagPermanent(tt, false)
call SetTextTagLifespan(tt, 4.)
call SetTextTagFadepoint(tt, 2.)
if IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), GetLocalPlayer()) then
call SetTextTagVisibility(tt, false)
endif
loop
if IsPlayerEnemy(Player(i), GetOwningPlayer(GetTriggerUnit())) then
call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD) + UnitBountyValue[GetUnitUserData(GetTriggerUnit())])
call SetPlayerState(Player(5), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(1), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(2), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(3), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(4), PLAYER_STATE_RESOURCE_GOLD))
call SetPlayerState(Player(11), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(6), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(7), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(8), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(9), PLAYER_STATE_RESOURCE_GOLD) + GetPlayerState(Player(10), PLAYER_STATE_RESOURCE_GOLD))
endif
set i = i + 1
exitwhen i > 11
endloop
call TriggerSleepAction(4.)
set tt = null
endfunction
//===========================================================================
function InitTrig_BountyAdd takes nothing returns nothing
set gg_trg_BountyAdd = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_BountyAdd, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(gg_trg_BountyAdd, Condition(function Trig_BountyAdd_Conditions))
call TriggerAddAction(gg_trg_BountyAdd, function Trig_BountyAdd_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//====================================================================
// ARROW KEY DETECTION SYSTEM - by Illidan(evil)x
//====================================================================
globals
trigger KeyPressUp = CreateTrigger()
trigger KeyPressDown = CreateTrigger()
trigger KeyPressLeft = CreateTrigger()
trigger KeyPressRight = CreateTrigger()
trigger KeyReleaseUp = CreateTrigger()
trigger KeyReleaseDown = CreateTrigger()
trigger KeyReleaseLeft = CreateTrigger()
trigger KeyReleaseRight = CreateTrigger()
boolean array KeyUp
boolean array KeyDown
boolean array KeyLeft
boolean array KeyRight
endglobals
//======================================================
function PressUp_Actions takes nothing returns nothing
set KeyUp[GetPlayerId(GetTriggerPlayer())] = true
endfunction
function PressDown_Actions takes nothing returns nothing
set KeyDown[GetPlayerId(GetTriggerPlayer())] = true
endfunction
function PressLeft_Actions takes nothing returns nothing
set KeyLeft[GetPlayerId(GetTriggerPlayer())] = true
endfunction
function PressRight_Actions takes nothing returns nothing
set KeyRight[GetPlayerId(GetTriggerPlayer())] = true
endfunction
function ReleaseUp_Actions takes nothing returns nothing
set KeyUp[GetPlayerId(GetTriggerPlayer())] = false
endfunction
function ReleaseDown_Actions takes nothing returns nothing
set KeyDown[GetPlayerId(GetTriggerPlayer())] = false
endfunction
function ReleaseLeft_Actions takes nothing returns nothing
set KeyLeft[GetPlayerId(GetTriggerPlayer())] = false
endfunction
function ReleaseRight_Actions takes nothing returns nothing
set KeyRight[GetPlayerId(GetTriggerPlayer())] = false
endfunction
//===========================================================================
function InitTrig_ArrowKeyDetection takes nothing returns nothing
local integer i = 0
loop
call TriggerRegisterPlayerEvent(KeyPressUp, Player(i), EVENT_PLAYER_ARROW_UP_DOWN)
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(KeyPressUp, function PressUp_Actions)
set i = 0
loop
call TriggerRegisterPlayerEvent(KeyPressDown, Player(i), EVENT_PLAYER_ARROW_DOWN_DOWN)
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(KeyPressDown, function PressDown_Actions)
set i = 0
loop
call TriggerRegisterPlayerEvent(KeyPressLeft, Player(i), EVENT_PLAYER_ARROW_LEFT_DOWN)
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(KeyPressLeft, function PressLeft_Actions)
set i = 0
loop
call TriggerRegisterPlayerEvent(KeyPressRight, Player(i), EVENT_PLAYER_ARROW_RIGHT_DOWN)
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(KeyPressRight, function PressRight_Actions)
set i = 0
loop
call TriggerRegisterPlayerEvent(KeyReleaseUp, Player(i), EVENT_PLAYER_ARROW_UP_UP)
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(KeyReleaseUp, function ReleaseUp_Actions)
set i = 0
loop
call TriggerRegisterPlayerEvent(KeyReleaseDown, Player(i), EVENT_PLAYER_ARROW_DOWN_UP)
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(KeyReleaseDown, function ReleaseDown_Actions)
set i = 0
loop
call TriggerRegisterPlayerEvent(KeyReleaseLeft, Player(i), EVENT_PLAYER_ARROW_LEFT_UP)
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(KeyReleaseLeft, function ReleaseLeft_Actions)
set i = 0
loop
call TriggerRegisterPlayerEvent(KeyReleaseRight, Player(i), EVENT_PLAYER_ARROW_RIGHT_UP)
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(KeyReleaseRight, function ReleaseRight_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
boolean array CameraConfig
endglobals
function Trig_StartCameraConfig_Actions takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
call SetCameraBounds(GetCameraTargetPositionX(), GetCameraTargetPositionY(), GetCameraTargetPositionX(), GetCameraTargetPositionY(), GetCameraTargetPositionX(), GetCameraTargetPositionY(), GetCameraTargetPositionX(), GetCameraTargetPositionY())
call ClearTextMessages()
endif
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0.5,0.5, 90., "
CAMERA MODE
Press the UP/DOWN arrow keys to adjust the camera Distance.
Press the LEFT/RIGHT arrow keys to adjust the camera Rotation. (CURRENTLY NOT WORKING!)
Press ESCAPE to leave the Camera Mode.")
call CinematicFilterForPlayer(GetTriggerPlayer(), 0.5, BLEND_MODE_BLEND, "UI\\Widgets\\Glues\\GlueScreen-CampaignButton-BackdropBackgroundCamera.blp", 0., 0., 0., 100., 100., 100., 100., 0.)
set CameraConfig[GetPlayerId(GetTriggerPlayer())] = true
set EnableMenu[GetPlayerId(GetTriggerPlayer())] = false
endfunction
//===========================================================================
function InitTrig_StartCameraConfig takes nothing returns nothing
local integer i = 0
loop
set CameraConfig[i] = false
set i = i + 1
exitwhen i > 11
endloop
set gg_trg_StartCameraConfig = CreateTrigger()
call TriggerAddAction(gg_trg_StartCameraConfig, function Trig_StartCameraConfig_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
real CameraMaxDist = 2800.00 //The maximum distance of the camera
real CameraMinDist = 700.00 //The minimum distance of the camera
real array CameraCurrentRot //The current rotation of the camera
endglobals
function Trig_CameraCustomization_Actions takes nothing returns nothing
local integer i = 0
loop
if CameraConfig[i] then
if KeyUp[i] then
//+UP
// !!! FOR LOCAL PLAYER ONLY !!!
if GetLocalPlayer() == Player(i) then
if GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) <= CameraMinDist+50. then
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, CameraMinDist, 0.05)
else
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) - 50., 0.05)
endif
endif
endif
if KeyDown[i] then
//+DOWN
//
if GetLocalPlayer() == Player(i) then
if GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) >= CameraMaxDist-50. then
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, CameraMaxDist, 0.05)
else
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) + 50., 0.05)
endif
endif
endif
if KeyLeft[i] then
//+LEFT
//set CameraCurrentRot[i] = CameraCurrentRot[i] - 2.5
//if CameraCurrentRot[i] < 0. then
// set CameraCurrentRot[i] = 360.
//endif
//if GetLocalPlayer() == Player(i) then
// call SetCameraField(CAMERA_FIELD_ROTATION, CameraCurrentRot[i], 0.05)
//endif
endif
if KeyRight[i] then
//+RIGHT
//set CameraCurrentRot[i] = CameraCurrentRot[i] + 2.5
//if CameraCurrentRot[i] > 360. then
// set CameraCurrentRot[i] = 0.
//endif
//if GetLocalPlayer() == Player(i) then
// call SetCameraField(CAMERA_FIELD_ROTATION, CameraCurrentRot[i], 0.05)
//call SetCameraField(CAMERA_FIELD_ROTATION, GetCameraField(CAMERA_FIELD_ROTATION) + 5., 0.05)
//endif
endif
endif
set i = i + 1
exitwhen i > 10
endloop
endfunction
//===========================================================================
function InitTrig_CameraCustomization takes nothing returns nothing
local integer i = 0
loop
set CameraCurrentRot[i] = 90.
set i = i + 1
exitwhen i > 10
endloop
set gg_trg_CameraCustomization = CreateTrigger()
call TriggerRegisterTimerEvent(gg_trg_CameraCustomization, 0.05, true)
call TriggerAddAction(gg_trg_CameraCustomization, function Trig_CameraCustomization_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function ExitCameraConfigCond takes nothing returns boolean
return CameraConfig[GetPlayerId(GetTriggerPlayer())]
endfunction
function Trig_ExitCameraConfig_Actions takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
call SetCameraBounds(GetRectMinX(bj_mapInitialCameraBounds), GetRectMinY(bj_mapInitialCameraBounds), GetRectMinX(bj_mapInitialCameraBounds), GetRectMaxY(bj_mapInitialCameraBounds), GetRectMaxX(bj_mapInitialCameraBounds), GetRectMaxY(bj_mapInitialCameraBounds), GetRectMaxX(bj_mapInitialCameraBounds), GetRectMinY(bj_mapInitialCameraBounds))
call ClearTextMessages()
endif
call CinematicFilterForPlayer(GetTriggerPlayer(), 0.5, BLEND_MODE_BLEND, "UI\\Widgets\\Glues\\GlueScreen-CampaignButton-BackdropBackgroundCamera.blp", 100., 100., 100., 0., 0., 0., 0., 100.)
set CameraConfig[GetPlayerId(GetTriggerPlayer())] = false
set EnableMenu[GetPlayerId(GetTriggerPlayer())] = true
endfunction
//===========================================================================
function InitTrig_ExitCameraConfig takes nothing returns nothing
local integer i = 0
set gg_trg_ExitCameraConfig = CreateTrigger()
loop
call TriggerRegisterPlayerEvent(gg_trg_ExitCameraConfig, Player(i), EVENT_PLAYER_END_CINEMATIC)
set i = i + 1
exitwhen i > 10
endloop
call TriggerAddCondition(gg_trg_ExitCameraConfig, Condition(function ExitCameraConfigCond))
call TriggerAddAction(gg_trg_ExitCameraConfig, function Trig_ExitCameraConfig_Actions)
endfunction
//TESH.scrollpos=91
//TESH.alwaysfold=0
//====================================================================
// UNIT SQUAD SYSTEM - by Illidan(evil)x
globals
integer SquadLeaderRaw = 'h00A' //The RAW code of the "squad leader" (The unit trained to create a squad. This is also the unit that appears when selecting a squad)
integer MaxSquadMembers = 5 //The max amount of squad members in each squad
integer array SquadTeam //The RAW code of the actual units in the squad team (Add/Delete/Modify Squad members in the InitSquad function below)
string SelectionCirclePath = "Models\\Effects\\selectioncircleModified.mdx" //The file path of the simulated selection circles
endglobals
function InitSquad takes nothing returns nothing
//This is the actual squad members (starts at 0)
set SquadTeam[0] = 'h009'
set SquadTeam[1] = 'h009'
set SquadTeam[2] = 'h009'
set SquadTeam[3] = 'hrif' //Rifleman
set SquadTeam[4] = 'hrif' //Rifleman
endfunction
//===========================================================
//===========================================================
//===========================================================
globals
integer SquadCurrent = 0
integer array SquadNumber
boolean array IsInSquad
unit array SquadLeader
boolean array IsSquadLeader
group array Squad
boolean array SquadSelected
trigger SquadSelect = CreateTrigger()
trigger SquadRemove = CreateTrigger()
trigger SquadOrderPoint = CreateTrigger()
trigger SquadOrderTarget = CreateTrigger()
trigger SquadOrderNoTarget = CreateTrigger()
trigger SquadDeselect = CreateTrigger()
effect array SquadEffect
endglobals
function SquadSystemCondition takes nothing returns boolean
return GetUnitTypeId(GetTrainedUnit()) == SquadLeaderRaw
endfunction
function InitAddSquad takes nothing returns nothing
local integer i = 0
loop
set SquadTeam[i] = 0
set i = i + 1
exitwhen i > MaxSquadMembers
endloop
call InitSquad()
endfunction
function Trig_SquadSystem_Actions takes nothing returns nothing
local location l = GetUnitRallyPoint(GetTriggerUnit())
local real x = GetUnitX(GetTrainedUnit())
local real y = GetUnitY(GetTrainedUnit())
local integer i = 0
local integer squad = SquadCurrent + 1
local unit u = null
local integer pid = GetPlayerId(GetOwningPlayer(GetTrainedUnit()))
set SquadLeader[squad] = GetTrainedUnit()
call SetUnitX(GetTrainedUnit(), GetRectMinX(GetWorldBounds()))
call SetUnitY(GetTrainedUnit(), GetRectMinY(GetWorldBounds()))
call SetUnitMoveSpeed(GetTrainedUnit(), 0.00)
call SetUnitScale(GetTrainedUnit(), 0., 0., 0.)
set SquadCurrent = SquadCurrent + 1
set Squad[squad] = CreateGroup()
loop
set u = CreateUnit(Player(pid), SquadTeam[i], x, y, 270.)
call IssuePointOrder(u, "move", GetLocationX(l), GetLocationY(l))
call TriggerSleepAction(0.25)
set SquadNumber[GetUnitUserData(u)] = squad
call GroupAddUnit(Squad[squad], u)
set IsInSquad[GetUnitUserData(u)] = true
set i = i + 1
exitwhen SquadTeam[i] == 0 or i > MaxSquadMembers
endloop
call TriggerSleepAction(0)
set IsSquadLeader[GetUnitUserData(SquadLeader[squad])] = true
set SquadNumber[GetUnitUserData(SquadLeader[squad])] = squad
call RemoveLocation(l)
set l = null
set u = null
endfunction
//============================SquadSelect
function Trig_SquadSystemSelect_Conditions takes nothing returns boolean
return IsInSquad[GetUnitUserData(GetTriggerUnit())] and GetOwningPlayer(GetTriggerUnit()) == GetTriggerPlayer()
endfunction
function SquadAddEffect takes nothing returns nothing
local string s = ""
if GetLocalPlayer() == GetTriggerPlayer() then
set s = SelectionCirclePath
endif
call DestroyEffect(SquadEffect[GetUnitUserData(GetEnumUnit())])
set SquadEffect[GetUnitUserData(GetEnumUnit())] = AddSpecialEffectTarget(s, GetEnumUnit(), "origin")
call SetUnitOwner(GetEnumUnit(), GetTriggerPlayer(), true)
endfunction
function Trig_SquadSystemSelect_Actions takes nothing returns nothing
if SquadSelected[SquadNumber[GetUnitUserData(GetTriggerUnit())]] == false then
call SetUnitOwner(SquadLeader[SquadNumber[GetUnitUserData(GetTriggerUnit())]], GetTriggerPlayer(), true)
if GetLocalPlayer() == GetTriggerPlayer() then
call SelectUnit(GetTriggerUnit(), false)
call SelectUnit(SquadLeader[SquadNumber[GetUnitUserData(GetTriggerUnit())]], true)
endif
call ForGroup(Squad[SquadNumber[GetUnitUserData(GetTriggerUnit())]], function SquadAddEffect)
set SquadSelected[SquadNumber[GetUnitUserData(GetTriggerUnit())]] = true
elseif GetLocalPlayer() == GetTriggerPlayer() then
call SelectUnit(GetTriggerUnit(), false)
endif
endfunction
//============================
function Trig_SquadOrders_Conditions takes nothing returns boolean
return IsSquadLeader[GetUnitUserData(GetTriggerUnit())]
endfunction
function Trig_SquadOrderTarget_Actions takes nothing returns nothing
local unit u = null
local integer order = GetIssuedOrderId()
local widget w = GetOrderTarget()
local group g = CreateGroup()
loop
set u = FirstOfGroup(Squad[SquadNumber[GetUnitUserData(GetTriggerUnit())]])
exitwhen u == null
call GroupRemoveUnit(Squad[SquadNumber[GetUnitUserData(GetTriggerUnit())]], u)
call IssueTargetOrderById(u, order, w)
call GroupAddUnit(g, u)
endloop
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
call GroupAddUnit(Squad[SquadNumber[GetUnitUserData(GetTriggerUnit())]], u)
endloop
call DestroyGroup(g)
set g = null
set w = null
endfunction
function Trig_SquadOrderPoint_Actions takes nothing returns nothing
local unit u = null
local integer order = GetIssuedOrderId()
local real x = GetOrderPointX()
local real y = GetOrderPointY()
local group g = CreateGroup()
loop
set u = FirstOfGroup(Squad[SquadNumber[GetUnitUserData(GetTriggerUnit())]])
exitwhen u == null
call GroupRemoveUnit(Squad[SquadNumber[GetUnitUserData(GetTriggerUnit())]], u)
call IssuePointOrderById(u, order, x, y)
call GroupAddUnit(g, u)
endloop
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
call GroupAddUnit(Squad[SquadNumber[GetUnitUserData(GetTriggerUnit())]], u)
endloop
call DestroyGroup(g)
set g = null
endfunction
function Trig_SquadOrderNoTarget_Actions takes nothing returns nothing
local unit u = null
local integer order = GetIssuedOrderId()
local group g = CreateGroup()
loop
set u = FirstOfGroup(Squad[SquadNumber[GetUnitUserData(GetTriggerUnit())]])
exitwhen u == null
call GroupRemoveUnit(Squad[SquadNumber[GetUnitUserData(GetTriggerUnit())]], u)
call IssueImmediateOrderById(u, order)
call GroupAddUnit(g, u)
endloop
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
call GroupAddUnit(Squad[SquadNumber[GetUnitUserData(GetTriggerUnit())]], u)
endloop
call DestroyGroup(g)
set g = null
endfunction
//============================
function Trig_SquadRemove_Conditions takes nothing returns boolean
return IsInSquad[GetUnitUserData(GetTriggerUnit())]
endfunction
function Trig_SquadRemove_Actions takes nothing returns nothing
local integer i = GetUnitUserData(GetTriggerUnit())
call DestroyEffect(SquadEffect[i])
call GroupRemoveUnit(Squad[SquadNumber[i]], GetTriggerUnit())
call TriggerSleepAction(0)
set bj_groupCountUnits = 0
call ForGroup(Squad[SquadNumber[i]], function CountUnitsInGroupEnum)
if bj_groupCountUnits <= 0 then
call RemoveUnit(SquadLeader[SquadNumber[i]])
call DestroyGroup(Squad[SquadNumber[i]])
endif
endfunction
//============================
function SquadRemoveEffect takes nothing returns nothing
call DestroyEffect(SquadEffect[GetUnitUserData(GetEnumUnit())])
if GetPlayerId(GetTriggerPlayer()) < 5 then
call SetUnitOwner(GetEnumUnit(), Player(5), true)
else
call SetUnitOwner(GetEnumUnit(), Player(11), true)
endif
call RemoveGuardPosition(GetEnumUnit())
if UIS_Target[GetUnitUserData(GetEnumUnit())] == true then
call IssueTargetOrderById(GetEnumUnit(), UIS_Order[GetUnitUserData(GetEnumUnit())], UIS_Widget[GetUnitUserData(GetEnumUnit())])
elseif UIS_Pos[GetUnitUserData(GetEnumUnit())] == true then
call IssuePointOrderById(GetEnumUnit(), UIS_Order[GetUnitUserData(GetEnumUnit())], UIS_X[GetUnitUserData(GetEnumUnit())], UIS_Y[GetUnitUserData(GetEnumUnit())])
elseif UIS_NoTarget[GetUnitUserData(GetEnumUnit())] == true then
call IssueImmediateOrderById(GetEnumUnit(), UIS_Order[GetUnitUserData(GetEnumUnit())])
endif
endfunction
function SquadDeselectAction takes nothing returns nothing
call ForGroup(Squad[SquadNumber[GetUnitUserData(GetTriggerUnit())]], function SquadRemoveEffect)
set SquadSelected[SquadNumber[GetUnitUserData(GetTriggerUnit())]] = false
endfunction
//===========================================================================
function InitTrig_SquadSystem takes nothing returns nothing
local integer i = 0
call InitAddSquad()
set gg_trg_SquadSystem = CreateTrigger()
//call TriggerRegisterEnterRectSimple(gg_trg_SquadSystem, GetWorldBounds())
call TriggerRegisterAnyUnitEventBJ(gg_trg_SquadSystem, EVENT_PLAYER_UNIT_TRAIN_FINISH)
call TriggerAddCondition(gg_trg_SquadSystem, Condition(function SquadSystemCondition))
call TriggerAddAction(gg_trg_SquadSystem, function Trig_SquadSystem_Actions)
loop
call TriggerRegisterPlayerUnitEvent(SquadSelect, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
call TriggerRegisterPlayerUnitEvent(SquadDeselect, Player(i), EVENT_PLAYER_UNIT_DESELECTED, null)
set i = i + 1
exitwhen i > 11
endloop
call TriggerAddCondition(SquadSelect, Condition(function Trig_SquadSystemSelect_Conditions))
call TriggerAddAction(SquadSelect, function Trig_SquadSystemSelect_Actions)
call TriggerAddCondition(SquadDeselect, Condition(function Trig_SquadOrders_Conditions))
call TriggerAddAction(SquadDeselect, function SquadDeselectAction)
call TriggerRegisterAnyUnitEventBJ(SquadOrderTarget, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
call TriggerRegisterAnyUnitEventBJ(SquadOrderPoint, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
call TriggerRegisterAnyUnitEventBJ(SquadOrderNoTarget, EVENT_PLAYER_UNIT_ISSUED_ORDER)
call TriggerAddCondition(SquadOrderTarget, Condition(function Trig_SquadOrders_Conditions))
call TriggerAddCondition(SquadOrderPoint, Condition(function Trig_SquadOrders_Conditions))
call TriggerAddCondition(SquadOrderNoTarget, Condition(function Trig_SquadOrders_Conditions))
call TriggerAddAction(SquadOrderTarget, function Trig_SquadOrderTarget_Actions)
call TriggerAddAction(SquadOrderPoint, function Trig_SquadOrderPoint_Actions)
call TriggerAddAction(SquadOrderNoTarget, function Trig_SquadOrderNoTarget_Actions)
call TriggerRegisterAnyUnitEventBJ(SquadRemove, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(SquadRemove, Condition(function Trig_SquadRemove_Conditions))
call TriggerAddAction(SquadRemove, function Trig_SquadRemove_Actions)
endfunction