//TESH.scrollpos=-1
//TESH.alwaysfold=1
#include "cj_types.j"
// //! external FileExporter C:\MyMap
function GetHeightRate takes real h_old, real h_new, real time returns real
real rate = Abs(h_old - h_new) * time // or / time ?
return rate
endfunction
function GetCornerLoc takes nothing returns location
location loc_corner = null
if RectContainsBall(gg_rct_LineRT) || RectContainsBall(gg_rct_RightTop2) then
set loc_corner = GetRectCenter(gg_rct_CornerRightTop)
elseif RectContainsBall(gg_rct_LineRB) || RectContainsBall(gg_rct_RightBottom2) then
set loc_corner = GetRectCenter(gg_rct_CornerRightBottom)
elseif RectContainsBall(gg_rct_LineLT) || RectContainsBall(gg_rct_LeftTop2) then
set loc_corner = GetRectCenter(gg_rct_CornerLeftTop)
elseif RectContainsBall(gg_rct_LineLB) || RectContainsBall(gg_rct_LeftBottom2) then
set loc_corner = GetRectCenter(gg_rct_CornerLeftBottom)
endif
return loc_corner
endfunction
function Trig_Cant_Get_Ball_Conditions takes unit u returns boolean
//unit u = GetEnumUnit()
bool b11 = ( udg_ThrowinMode == 1 ) and ( IsUnitInTeamExt(u, 2) )
bool b12 = ( udg_ThrowinMode == 2 ) and ( IsUnitInTeamExt(u, 1) )
bool b1 = b11 || b12
bool b21 = GetOwningPlayer(u) != Player(PLAYER_NEUTRAL_PASSIVE)
bool b22 = IsKeeper(u)
bool b2 = b21 || b22
return b1 && b2
endfunction
function Trig_Cant_Get_Ball_Actions takes unit u returns nothing
real ball2unit = AngleBetweenUnits( udg_Ball, u )
location loc_ball = GetUnitLoc(udg_Ball)
real dist = CANT_GET_BALL_PUSHBACK_RADIUS
location loc_unit_new = PolarProjectionBJ( loc_ball, dist, ball2unit)
call SetUnitPositionLoc( u, loc_unit_new )
call CleanLocs(loc_unit_new, loc_ball)
endfunction
function PlaceBallInFrontOfBallOwner takes nothing returns nothing
location loc_owner = GetUnitLoc(udg_BallOwner)
real facing = GetUnitFacing(udg_BallOwner)
location loc_ball_new = PolarProjectionBJ( loc_owner, 50, facing)
call SetUnitPositionLoc( udg_Ball, loc_ball_new )
call SetUnitFacing( udg_Ball, facing )
call SetBallHeight( GetUnitFlyHeight(udg_BallOwner) + udg_BallDefaultHeight )
call CleanLocs( loc_owner, loc_ball_new )
endfunction
void RemoveEnemyUnitsFromRangeOfBall() {
call Ensure(not udg_MapReset)
call Ensure(ShallRemoveUnitsFromRange)
location loc_ball = Ball_GetLoc()
//group g = GetUnitsInRangeOfLocAll(CANT_GET_BALL_RADIUS, loc_ball)
//call ForGroup( g, function RemoveEnemyUnitsFromRangeOfBallEnum )
for (unit u; UnitsInRangeOfLoc(loc_ball, CANT_GET_BALL_RADIUS)) {
if Trig_Cant_Get_Ball_Conditions(u)
call Trig_Cant_Get_Ball_Actions(u)
endif
}
//call ForGroup( g, function () {ConditionalTriggerExecute( gg_trg_Cant_Get_Ball )} )
call CleanLoc(loc_ball)
//call RemoveGroup(g)
}
#define ResetTempDirection(void) = {
DoNothing()
if udg_TempDirection < 0
udg_TempDirection += 360
endif
}
struct color
real R,G,B
static method ColorizeString takes string s, color clr returns string
return null
endmethod
static method create takes int R, int G, int B returns color
color clr = color.allocate()
set clr.R = R
set clr.G = G
set clr.B = B
return clr
endmethod
static method CreateById takes int pid returns color
color clr = color.allocate()
set clr.R = udg_PlayerColorR[pid]
set clr.G = udg_PlayerColorG[pid]
set clr.B = udg_PlayerColorB[pid]
return clr
endmethod
endstruct
Name | Type | is_array | initial_value |
AI_AttackPoint_D | rect | Yes | |
AI_AttackPoint_M | rect | Yes | |
AI_AttackPoint_U | rect | Yes | |
Ball | unit | No | |
BallDefaultHeight | real | No | |
BallDirection | real | No | |
BallImmuneTimer | integer | No | |
BallInHandEffect | effect | No | |
BallInitialDirection | real | No | |
BallOwner | unit | No | UnitNull |
BallVZ | real | No | |
BTN_10min | button | No | |
BTN_5min | button | No | |
BTN_7min | button | No | |
CameraAutoZoom | boolean | Yes | |
CameraDistance | real | Yes | 1870.00 |
CameraLock | boolean | Yes | |
CantEnterOtherSide | boolean | No | |
CantHoldBall | integer | Yes | |
CanUseUnobs | boolean | Yes | |
CurrentBallSpeed | real | No | |
CurveBallFactor | real | Yes | |
DistOfEnumUnit | real | No | |
FitnessOfPlayerA | integer | No | |
Flag | unit | No | |
G | real | No | |
GoalArea | rect | Yes | |
GoldenGoal | boolean | No | |
HeadingTarget | location | No | |
HeadingTargetFitness | integer | No | |
Hero | unit | Yes | |
HeroHeight | real | No | |
HeroInAir | boolean | Yes | |
HeroSlidingWait | integer | Yes | |
HeroVX | real | Yes | |
HeroVY | real | Yes | |
IgnoreAItimer | integer | No | |
IndirectFreeKick | boolean | No | |
IsBallInAir | boolean | No | |
Keeper | unit | Yes | |
KeeperArea | rect | Yes | |
KeeperBallHoldTimer | integer | No | |
KeeperDefPosY | real | No | |
KeeperMoveArea | rect | Yes | |
KeeperMoveY | real | No | |
KeeperPassTarget | unit | No | |
KeeperThrowLoc | location | No | |
KeeperThrowsBall | boolean | No | |
KeeperVotes | boolean | Yes | false |
KeeperVotingPending | boolean | Yes | |
LastKeeperMoveLocation | location | Yes | |
LeftTeamName | string | No | |
Linesman | unit | Yes | |
MapReset | boolean | No | |
MaxBVYforHeading | real | No | |
MinSpeed | real | No | |
nAllPasses | integer | Yes | |
nAssists | integer | Yes | |
NextKeeperController | player | Yes | |
nFailedPasses | integer | Yes | |
nKeeperVotingAttempts | integer | Yes | |
nPlayersCanVote | integer | No | |
nSuccDribbles | integer | Yes | 0 |
nSuccPasses | integer | Yes | |
PassSuccess | real | Yes | |
PassTarget | unit | No | |
PassTargetDistance | real | No | |
PenaltyArea | rect | Yes | |
PlayArea | rect | Yes | |
PlayerColorB | real | Yes | |
PlayerColorG | real | Yes | |
PlayerColorR | real | Yes | |
PlayerNames | string | Yes | |
PlayerPossession | real | Yes | 0.00 |
PlayerScore | integer | Yes | |
Quests | quest | Yes | |
RealTimer | timer | No | |
ReduceSpeedTimer | integer | Yes | |
Referee | unit | No | |
RightGoal | rect | No | RectNull |
RightTeamName | string | No | |
Round | integer | No | |
RoundTime | real | No | |
RoundTimer | timer | No | |
Score | integer | Yes | |
SlidingDirection | real | Yes | |
SlidingEffect | effect | Yes | |
SlidingUnits | group | No | |
Team1Heroes | group | No | |
Team2Heroes | group | No | |
TeamPossession | real | Yes | |
TempDirection | real | No | |
TempInt | integer | No | |
TempPoint | location | No | |
TempReal | real | No | |
TempRealArray | real | Yes | |
TempUnit | unit | No | |
TempUnitGroup1 | group | No | |
TempUnitGroup2 | group | No | |
ThinkingTeamEnemyNumber | integer | No | |
ThinkingTeamNumber | integer | No | |
ThrowinLoc | location | No | |
ThrowinMode | integer | No | |
ThrowInWaitTimer | integer | No | |
TimerDialog | timerdialog | No | |
UnitHeadingTarget | unit | No | |
VoteResult | integer | Yes | |
WhichKeeperHasBall | integer | No |
//TESH.scrollpos=-1
//TESH.alwaysfold=0
constant bool InTesting = false
bool InTraining = false
constant bool PublicVersion = true
constant bool ShortHalves = true
constant real HalfDurationInTestMode = 0.1 // 5 min button
constant bool NationVotingAtStart = true
constant bool AddMorganToDbg = false
constant int WhichKeeperToHide = 0
constant bool CanGetBallAfterGoal = true
constant bool ShowTimeSinceLastShot = false
constant bool ShowCustomMaxHeights = false
constant real CustomHeightMinimum = 200
bool EasyMode = false
bool ManualZ = true
bool HighC = false
bool CGoalsBan = true
bool IsKeeperPlayable = false
bool SmoothBall = false
bool IsGoldenGoalEnabled = true
bool AlwaysPickNearestAllyForZ = true
bool HeadToKeeperOnlyInBox = true
bool xvFalseFixEnabled = true
bool BallHitGroundAfterX = false
bool CurvedBall = false
bool CurvedVZ = false
bool ContinuousBallUpdate = false
bool NoGoals = false
bool PartialSmooth = false
constant real CANT_GET_BALL_RADIUS = 290
constant real CANT_GET_BALL_PUSHBACK_RADIUS = CANT_GET_BALL_RADIUS + 30
real MINIMUM_BAR_HEIGHT = 185
real MAXIMUM_BAR_HEIGHT = 225
//real TEXTTAG_EXCLAMATION_MINIMUM_BALL_HEIGHT = 250
// slow factors
constant real GROUND_HIT_FACTOR = 50
constant real GROUND_FRICTION_FACTOR = 10
constant real CROSSBAR_HIT_FACTOR = 10
constant real POST_HIT_FACTOR = 10
unit KEEPER_ONE
unit KEEPER_TWO
unit KEEPER_FIRST
unit KEEPER_SECOND
define { /* Unit constants */
//KEEPER_ONE = gg_unit_/e001_0103
//KEEPER_TWO = gg_unit_/e000_0102
//KEEPER_FIRST = KEEPER_ONE
//KEEPER_SECOND = KEEPER_TWO
BALL = gg_unit_h000_0001
BALL_NEW = gg_unit_h00A_0022
}
define { /* Variable hooks */
Ball = udg_Ball
Hero = udg_Hero
Flag = udg_Flag
Keeper = udg_Keeper
BallOwner = udg_BallOwner
BallImmuneTimer = udg_BallImmuneTimer
BallVZ = udg_BallVZ
BallVX = udg_BallVX
BallDirection = udg_BallDirection
Score = udg_Score
ThrowinMode = udg_ThrowinMode
KeeperBallHoldTimer = udg_KeeperBallHoldTimer
CantHoldBall = udg_CantHoldBall
//Round = udg_Round
}
define { /* Ability constants */
SPELL_SHORT_PASS = 'A007'
SPELL_TARGETABLE_SHORT_PASS = 'A001'
SPELL_SHORT_PASS_Y = 'A00D'
SPELL_TARGETABLE_SHORT_PASS_Y = 'A006'
SPELL_ID_KEEPER_THROW = 'A00A'
ABILITY_SHORT_PASS = 'A007'
ABILITY_SHORT_PASS_Q = 'A00I'
ABILITY_SHORT_PASS_Y = 'A00D'
ABILITY_KICK_SLIDE = 'A00K'
ABILITY_KICK_SLIDE_W = 'A00O'
ABILITY_LONG_PASS = 'A008'
ABILITY_LONG_PASS_E = 'A00N'
ABILITY_LONG_PASS_REVEAL = 'A00E'
ABILITY_JUMP = 'A009'
ABILITY_JUMP_F = 'A004'
ABILITY_JUMP_R = 'A00J'
ABILITY_JUMP_SLOW = 'A005'
ABILITY_FETCH_BALL = 'A00B'
ABILITY_TELEPORT = 'A00C'
ABILITY_DROP_BALL = 'A000'
ABILITY_FAKIE = 'A00F'
ABILITY_LEFT_CURVE = 'A00M'
ABILITY_RIGHT_CURVE = 'A00L'
ABILITY_PASS_TO_ME = 'A002'
ABILITY_SINGLE_HKEY_CURVE = 'A00H'
ABILITY_LEFT_FOOT_RED = 'A00W'
ABILITY_RIGHT_FOOT_RED = 'A00X'
ABILITY_LEFT_FOOT_BLUE = 'A00Y'
ABILITY_RIGHT_FOOT_BLUE = 'A00Z'
ABILITY_LEFT_FOOT_PURPLE = 'A019'
ABILITY_RIGHT_FOOT_PURPLE = 'A01C'
ABILITY_LEFT_FOOT_YELLOW = 'A01A'
ABILITY_RIGHT_FOOT_YELLOW = 'A01D'
ABILITY_LEFT_FOOT_ORANGE = 'A01B'
ABILITY_RIGHT_FOOT_ORANGE = 'A01E'
ABILITY_LEFT_FOOT_GREEN = 'A00S'
ABILITY_RIGHT_FOOT_GREEN = 'A00T'
ABILITY_LEFT_FOOT_PINK = 'A012'
ABILITY_RIGHT_FOOT_PINK = 'A011'
ABILITY_LEFT_FOOT_LIGHT_BLUE = 'A013'
ABILITY_RIGHT_FOOT_LIGHT_BLUE = 'A014'
ABILITY_LEFT_FOOT_DARK_GREEN = 'A015'
ABILITY_RIGHT_FOOT_DARK_GREEN = 'A016'
ABILITY_LEFT_FOOT_BROWN = 'A017'
ABILITY_RIGHT_FOOT_BROWN = 'A018'
}
define { /* Action constants */
ACTION_GET_BALL = 0
ACTION_GAME_PAUSED = 0
ACTION_SHORT_PASS = 1
ACTION_KICK = 2
ACTION_LONG_PASS = 3
ACTION_HEADING_PASS = 4
ACTION_SLIDE = 5
ACTION_VZ = 6
ACTION_VX = 7
ACTION_HEADING_SHOT = 8
ACTION_KEEPER_THROW = 10
ACTION_KEEPER_LONG_PASS= 11
ACTION_DROP_BALL = 12
}
int LastActionMade = ACTION_GAME_PAUSED
int LastPassMade = ACTION_GAME_PAUSED
gamecache Cache = InitGameCache( "Cache.w3v" )
timer VotingTimer = null
player morganxl = null
//unit gg_unit_h008_0011 = null
int TempInt = 0
bool TempBool = false
real TempReal = 0.0
rect TempRect = null
location TempLoc = null
player TempPlayer = null
unit TempUnit = null
string TempString = null
texttag TempTT = null
dialog TempDialog = null
constant real INFINITY_REAL = 999999.9
constant real INFINITY_RANGE = 99999.9
constant real INFINITY_TIME = 99999.9
//TESH.scrollpos=-1
//TESH.alwaysfold=1
string array TeamName
string array TeamNameShort
group array TeamHeroes
void Trig_Assign_values_SetRegions () {
set udg_PlayArea[1] = gg_rct_LeftArea
set udg_PlayArea[2] = gg_rct_RightArea
set udg_GoalArea[1] = gg_rct_HeadingShootAreaLeft
set udg_GoalArea[2] = gg_rct_HeadingShootAreaRight
set udg_KeeperMoveArea[1] = gg_rct_KeeperMoveAreaLeft
set udg_KeeperMoveArea[2] = gg_rct_KeeperMoveAreaRight
set udg_KeeperArea[1] = gg_rct_LeftKeeperArea
set udg_KeeperArea[2] = gg_rct_RightKeeperArea
set udg_PenaltyArea[1] = gg_rct_PenaltyAreaLeft
set udg_PenaltyArea[2] = gg_rct_PenaltyAreaRight
set udg_LastKeeperMoveLocation[1] = GetRectCenter(udg_KeeperMoveArea[1])
set udg_LastKeeperMoveLocation[2] = GetRectCenter(udg_KeeperMoveArea[2])
set udg_AI_AttackPoint_U[2] = gg_rct_AItargetLEFTU
set udg_AI_AttackPoint_M[2] = gg_rct_AItargetLEFTM
set udg_AI_AttackPoint_D[2] = gg_rct_AItargetLEFTTD
set udg_AI_AttackPoint_U[1] = gg_rct_AItargetRIGHTU
set udg_AI_AttackPoint_M[1] = gg_rct_AItargetRIGHTM
set udg_AI_AttackPoint_D[1] = gg_rct_AItargetRIGHTD
}
void Trig_Assign_values_SetKeepers() {
//call Ensure(InTesting) // fix
int k = WhichKeeperToHide
if IsInSet(k,1,3) && InTesting then
call ShowUnitHide( KEEPER_FIRST )
else
//set udg_Keeper[1] = KEEPER_FIRST
endif
if IsInSet(k,2,3) && InTesting then
call ShowUnitHide( KEEPER_SECOND )
else
//set udg_Keeper[2] = KEEPER_SECOND
endif
}
void Trig_Assign_values_SetHandles() {
set udg_Linesman[1] = gg_unit_n001_0100
set udg_Linesman[2] = gg_unit_n002_0101
set udg_Referee = gg_unit_N000_0099
set udg_Flag = gg_unit_h004_0007
set udg_Ball = BALL
set udg_ThrowinLoc = GetPitchCenter()
set TeamHeroes[1] = udg_Team1Heroes
set TeamHeroes[2] = udg_Team2Heroes
call UnitSetUsesAltIcon( Ball, true )
call Ball_SetLoc( udg_ThrowinLoc )
call HideUnit( BALL_NEW )
call HideUnit( Flag )
}
void Trig_Assign_values_SetElementaryTypes() {
// integers, reals, booleans
set udg_IgnoreAItimer = 40
set udg_MaxBVYforHeading = 10
set udg_HeroHeight = 100
set udg_BallDefaultHeight = GetUnitDefaultFlyHeight(Ball)
set udg_BallVZ = 0
set udg_IsBallInAir = false
set udg_IndirectFreeKick = true
set udg_CantEnterOtherSide = true
set udg_G = 2.3
set udg_Score[1] = 0
set udg_Score[2] = 0
set udg_MinSpeed = 1
set udg_Round = -1
set udg_ThrowinMode = 1
}
void Trig_Assign_values_SetColors() {
set udg_PlayerNames[1] = "|cffFF0202" + GetPlayerNameById(0) + "|r"
set udg_PlayerNames[2] = "|cff0041FF" + GetPlayerNameById(1) + "|r"
set udg_PlayerNames[3] = "|cff1BE6B8" + GetPlayerNameById(2) + "|r"
set udg_PlayerNames[4] = "|cff530080" + GetPlayerNameById(3) + "|r"
set udg_PlayerNames[5] = "|cffFFFC00" + GetPlayerNameById(4) + "|r"
set udg_PlayerNames[6] = "|cffFE890D" + GetPlayerNameById(5) + "|r"
set udg_PlayerNames[7] = "|cff1FC000" + GetPlayerNameById(6) + "|r"
set udg_PlayerNames[8] = "|cffE55AAF" + GetPlayerNameById(7) + "|r"
set udg_PlayerNames[9] = "|cff949596" + GetPlayerNameById(8) + "|r"
set udg_PlayerNames[10] = "|cff7DBEF1" + GetPlayerNameById(9) + "|r"
set udg_PlayerNames[11] = "|cff0F6145" + GetPlayerNameById(10) + "|r"
set udg_PlayerNames[12] = "|cff4D2903" + GetPlayerNameById(11) + "|r"
integer pid = 0
whilenot (pid > 12) {
call PlayerStoreStr( pid, "name", udg_PlayerNames[pid] )
++pid
}
set udg_PlayerColorR[1] = 100
set udg_PlayerColorG[1] = 1
set udg_PlayerColorB[1] = 1
set udg_PlayerColorR[2] = 0
set udg_PlayerColorG[2] = 25
set udg_PlayerColorB[2] = 100
set udg_PlayerColorR[3] = 11
set udg_PlayerColorG[3] = 90
set udg_PlayerColorB[3] = 72
set udg_PlayerColorR[4] = 33
set udg_PlayerColorG[4] = 0
set udg_PlayerColorB[4] = 50
set udg_PlayerColorR[13] = 33
set udg_PlayerColorG[13] = 0
set udg_PlayerColorB[13] = 50
set udg_PlayerColorR[5] = 100
set udg_PlayerColorG[5] = 99
set udg_PlayerColorB[5] = 0
set udg_PlayerColorR[6] = 100
set udg_PlayerColorG[6] = 54
set udg_PlayerColorB[6] = 5
set udg_PlayerColorR[7] = 12
set udg_PlayerColorG[7] = 75
set udg_PlayerColorB[7] = 0
set udg_PlayerColorR[8] = 90
set udg_PlayerColorG[8] = 35
set udg_PlayerColorB[8] = 69
set udg_PlayerColorR[9] = 58
set udg_PlayerColorG[9] = 58
set udg_PlayerColorB[9] = 59
set udg_PlayerColorR[14] = 58
set udg_PlayerColorG[14] = 58
set udg_PlayerColorB[14] = 59
set udg_PlayerColorR[10] = 49
set udg_PlayerColorG[10] = 75
set udg_PlayerColorB[10] = 95
set udg_PlayerColorR[11] = 6
set udg_PlayerColorG[11] = 38
set udg_PlayerColorB[11] = 27
set udg_PlayerColorR[12] = 30
set udg_PlayerColorG[12] = 16
set udg_PlayerColorB[12] = 1
}
void Trig_Assign_values_SetPlayers() {
string p_name
player p
int i = 0
whilenot i > 11 {
set p = Player(i)
set p_name = GetPlayerName(p)
set p_name = StringCase( p_name, false )
if IsInSet( p_name, "morganxl", "morganxl-", "dafling" )
set morganxl = p
// 2x zoom outs for morganxl
/*int pid = cPid(morganxl)
set udg_CameraDistance[pid] += 200*/
endif
++i
}
}
void Init_AssignValues() {
call Trig_Assign_values_SetRegions()
call Trig_Assign_values_SetKeepers()
call Trig_Assign_values_SetHandles()
call Trig_Assign_values_SetElementaryTypes()
//call Trig_Assign_values_SetTeamNames() // moved to init lib
call Trig_Assign_values_SetColors()
call Trig_Assign_values_SetPlayers()
}
//===========================================================================
function InitTrig_Assign_values takes nothing returns nothing
set gg_trg_Assign_values = CreateTrigger( )
call TriggerAddAction( gg_trg_Assign_values, function Init_AssignValues )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib_init( Init, config, StdLib ), StatsLib
private timer VotingTimer = CreateTimer()
private dialog VotingDialog = DialogCreate()
private bool IsVotingTimerCreated = false
enum (nations) {
TEAM_ONE_NATIONS
GERMANY
ENGLAND
NETHERLANDS
ARGENTINA
RUSSIA
TEAM_TWO_NATIONS
BRAZIL
SPAIN
ITALY
FRANCE
PORTUGAL
END_NATIONS
AUSTRALIA
JAPAN
SOUTH_KOREA
USA
}
integer NationToUnitTypeId(int team) { //!
int nation = TeamGetInt(team,"nation_id")
if (team==1)
if (nation==NETHERLANDS)
return 'H001'
elseif (nation==GERMANY)
return 'H00H'
elseif (nation==RUSSIA)
return 'H00L'
elseif (nation==ENGLAND)
return 'H00O'
elseif (nation==ARGENTINA)
return 'H00Q'
else
return 'H00H'
endif
elseif (team==2)
if (nation==SPAIN)
return 'H003'
elseif (nation==BRAZIL)
return 'H00I'
elseif (nation==PORTUGAL)
return 'H00N'
elseif (nation==ITALY)
return 'H00P'
elseif (nation==FRANCE)
return 'H00R'
else
return 'H003'
endif
endif
return 0
}
function GetKeeperUnitIdByNation takes integer team returns integer //!
integer nation = TeamGetInt(team,"nation_id")
if (team==1)
if nation == NETHERLANDS
return 'e001'
elseif nation == GERMANY
return 'e002'
elseif (nation == RUSSIA)
return 'e004'
elseif (nation == ENGLAND)
return 'e006'
elseif (nation == ARGENTINA)
return 'e008'
else
return 'e002' // default keeper (eg. if there is no nation voting)
endif
elseif (team==2)
if nation == SPAIN
return 'e000'
elseif nation == BRAZIL
return 'e003'
elseif (nation == PORTUGAL)
return 'e005'
elseif (nation == ITALY)
return 'e007'
elseif (nation == FRANCE)
return 'e009'
else
return 'e000' // default keeper
endif
endif
return 0
endfunction
function CreateKeeper takes integer team returns unit
if (team<1)||(team>2)
return null
endif
rect r
if (team==1)
set r = gg_rct_LeftKeeperArea
else
set r = gg_rct_RightKeeperArea
endif
location loc_keeper = GetRectCenter(r)
real facing = AngleBetweenPoints(loc_keeper,GetPitchCenter())
integer unitid = GetKeeperUnitIdByNation(team)
unit u = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), unitid, loc_keeper, facing)
return u
endfunction
function CreateAndConfigKeepers takes nothing returns nothing
set Keeper[1] = CreateKeeper(1)
set Keeper[2] = CreateKeeper(2)
set KEEPER_ONE = Keeper[1]
set KEEPER_FIRST = Keeper[1]
set KEEPER_TWO = Keeper[2]
set KEEPER_SECOND = Keeper[2]
string keeper_one_name = White(GetUnitName(udg_Keeper[1])) //"|cff530080" + GetUnitName(udg_Keeper[1]) + "|r"
string keeper_two_name = White(GetUnitName(udg_Keeper[2])) //"|cff949596" + GetUnitName(udg_Keeper[2]) + "|r"
set udg_PlayerNames[13] = keeper_one_name
set udg_PlayerNames[14] = keeper_two_name
call PlayerStoreStr( 13, "name", udg_PlayerNames[13] )
call PlayerStoreStr( 14, "name", udg_PlayerNames[14] )
endfunction
private void IsUnitNameUniqueEnum() {
unit u = GetEnumUnit()
string s = GetHeroProperName(u)
bool uniqueName = (s != TempString)
if (not uniqueName)
set TempBool = false
endif
}
private bool IsUnitNameUnique(string s) {
set TempBool = true
set TempString = s
call ForGroup(TeamHeroes[1], function IsUnitNameUniqueEnum)
call ForGroup(TeamHeroes[2], function IsUnitNameUniqueEnum)
return TempBool
}
private unit CreateUnitAtLocWithUniqueName(player p, integer type_id, location loc, real facing) {
bool isNameUnique = false
unit u = null
whilenot (isNameUnique == true) {
set u = CreateUnitAtLoc( p, type_id, loc, facing )
string str_name = GetHeroProperName(u)
//echo(str_name)
if IsUnitNameUnique(str_name)
set isNameUnique = true
else
call RemoveUnit(u)
endif
}
return u
}
private void CreateHeroForPlayer(player p) {
integer pid = cPid(p)
unit u = Hero[pid]
location loc_player = GetPlayerStartLocationLoc(p)
real player2ball = AngleBetweenPoints(loc_player, Ball_GetLoc())
int team
if ( pid <= 6 ) then
set team = 1
set loc_player = GetRandomLocInRect(gg_rct_LeftTeamStay)
else
set team = 2
set loc_player = GetRandomLocInRect(gg_rct_RightTeamStay)
endif
int type_id = NationToUnitTypeId(team)
set u = CreateUnitAtLocWithUniqueName( p, type_id, loc_player, player2ball ) // WithUniqueName
call GroupAddUnit( TeamHeroes[team], u )
set Hero[pid] = u
call SetHeroLevel( u, 10, false )
call UnitAddItemToSlotById( u, ITEM_ID_ZOOM_IN, 0 )
call UnitAddItemToSlotById( u, ITEM_ID_ZOOM_OUT, 1 )
call UnitAddItemToSlotById( u, ITEM_ID_ANGLE_LOWER, 2 )
call UnitAddItemToSlotById( u, ITEM_ID_ANGLE_HIGHER,3 )
// call AddFeetToPlayer(p)
}
private void CreateHeroEnum() {
call CreateHeroForPlayer(GetEnumPlayer())
}
function CreateUnits takes nothing returns nothing
force f = GetPlayersMatching(Condition(function FilterPlayerStatePlaying))
call ForForce( f, function CreateHeroEnum )
endfunction
string ColorizeByNation(string s, integer nation) { //!
if nation == 0
return s
elseif nation == NETHERLANDS
return BrightOrange(s)
elseif nation == GERMANY
return White(s)
elseif nation == RUSSIA
return Red(s)
elseif nation == SPAIN
return Red(s)
elseif nation == BRAZIL
return Yellow(s)
elseif nation == PORTUGAL
return Maroon(s)
elseif nation == ENGLAND
return White(s)
elseif nation == ITALY
return Blue(s)
elseif nation == ARGENTINA
return LightBlue(s)
elseif nation == FRANCE
return DarkBlue(s)
endif
return s
}
string NationToStr(int nation) { //!
if (nation==NETHERLANDS)
return "Netherlands"
elseif (nation==GERMANY)
return "Germany"
elseif (nation==RUSSIA)
return "Russia"
elseif (nation==SPAIN)
return "Spain"
elseif (nation==BRAZIL)
return "Brazil"
elseif (nation==PORTUGAL)
return "Portugal"
elseif (nation==ENGLAND)
return "England"
elseif (nation==ITALY)
return "Italy"
elseif (nation==ARGENTINA)
return "Argentina"
elseif (nation==FRANCE)
return "France"
endif
return ""
}
function SetTeamName takes integer team returns nothing
call Ensure (team==1 || team==2)
integer nation = TeamGetInt(team,"nation_id")
string str_nation = TeamGetStr(team,"nation")
set str_nation = ColorizeByNation(str_nation,nation)
if nation==0
if (team==1)
set TeamName[team] = "|c00ffff00Team Peasants|r"
set TeamNameShort[team] = "|c00ffff00Peasants|r"
else
set TeamName[team] = "|c00ff0000Team Peons|r"
set TeamNameShort[team] = "|c00ff0000Peons|r"
endif
else
set TeamName[team] = str_nation
set TeamNameShort[team] = str_nation
endif
if team==1
set udg_LeftTeamName = TeamName[1]
else
set udg_RightTeamName = TeamName[2]
endif
TeamStoreStr(team, "name", TeamName[team])
TeamStoreStr(team, "name_short", TeamNameShort[team])
endfunction
function SetTeamNames takes nothing returns nothing
call SetTeamName(1)
call SetTeamName(2)
endfunction
private function DeclareNations takes nothing returns nothing
int nation_1 = TeamGetInt(1,"nation_id")
int nation_2 = TeamGetInt(2,"nation_id")
string str_nation_1 = TeamNameShort[1]//TeamGetStr(1,"nation")
string str_nation_2 = TeamNameShort[2]//TeamGetStr(2,"nation")
echo ("Left team is "+str_nation_1)
echo ("Right team is "+str_nation_2)
echo()
endfunction
void AddFeetToPlayer(player p) {
integer pid = cPid(p)
unit u = Hero[pid]
integer team = GetPlayerConvertedTeam(p)
integer nation = TeamGetInt(team,"nation_id")
if nation!=0 /*(nation==NETHERLANDS) || (nation==GERMANY) || (nation==RUSSIA) || \
//(nation==BRAZIL) || (nation==ITALY) || (nation==SPAIN) */
if GetPlayerColor(p) == PLAYER_COLOR_RED
call UnitAddAbility(u, ABILITY_LEFT_FOOT_RED)
call UnitAddAbility(u, ABILITY_RIGHT_FOOT_RED)
elseif GetPlayerColor(p) == PLAYER_COLOR_BLUE
call UnitAddAbility(u, ABILITY_LEFT_FOOT_BLUE)
call UnitAddAbility(u, ABILITY_RIGHT_FOOT_BLUE)
elseif GetPlayerColor(p) == PLAYER_COLOR_PURPLE
call UnitAddAbility(u, ABILITY_LEFT_FOOT_PURPLE)
call UnitAddAbility(u, ABILITY_RIGHT_FOOT_PURPLE)
elseif GetPlayerColor(p) == PLAYER_COLOR_YELLOW
call UnitAddAbility(u, ABILITY_LEFT_FOOT_YELLOW)
call UnitAddAbility(u, ABILITY_RIGHT_FOOT_YELLOW)
elseif GetPlayerColor(p) == PLAYER_COLOR_ORANGE
call UnitAddAbility(u, ABILITY_LEFT_FOOT_ORANGE)
call UnitAddAbility(u, ABILITY_RIGHT_FOOT_ORANGE)
elseif GetPlayerColor(p) == PLAYER_COLOR_GREEN
call UnitAddAbility(u, ABILITY_LEFT_FOOT_GREEN)
call UnitAddAbility(u, ABILITY_RIGHT_FOOT_GREEN)
elseif GetPlayerColor(p) == PLAYER_COLOR_PINK
call UnitAddAbility(u, ABILITY_LEFT_FOOT_PINK)
call UnitAddAbility(u, ABILITY_RIGHT_FOOT_PINK)
elseif GetPlayerColor(p) == PLAYER_COLOR_LIGHT_BLUE
call UnitAddAbility(u, ABILITY_LEFT_FOOT_LIGHT_BLUE)
call UnitAddAbility(u, ABILITY_RIGHT_FOOT_LIGHT_BLUE)
elseif GetPlayerColor(p) == PLAYER_COLOR_AQUA
call UnitAddAbility(u, ABILITY_LEFT_FOOT_DARK_GREEN)
call UnitAddAbility(u, ABILITY_RIGHT_FOOT_DARK_GREEN)
elseif GetPlayerColor(p) == PLAYER_COLOR_BROWN
call UnitAddAbility(u, ABILITY_LEFT_FOOT_BROWN)
call UnitAddAbility(u, ABILITY_RIGHT_FOOT_BROWN)
endif
endif
}
private void AddFeetToHeroes() {
Ensure(NationVotingAtStart)
integer pid = 1
player p
whilenot (pid > 12) {
set p = ConvertedPlayer(pid)
call AddFeetToPlayer(p)
pid++
}
}
function SetRoundTime takes nothing returns nothing
int maxVotes = 0
// players who didn't vote "choose" 5 min option
//set udg_VoteResult[0] += udg_nPlayersCanVote
set udg_RoundTime = 10
if ( udg_VoteResult[3] <= udg_VoteResult[2] ) then
udg_RoundTime = 8
maxVotes = udg_VoteResult[2]
else
maxVotes = udg_VoteResult[3]
endif
if ( maxVotes <= udg_VoteResult[1] ) then
set udg_RoundTime = 7.5
set maxVotes = udg_VoteResult[1]
endif
if ( maxVotes <= udg_VoteResult[0] ) then
udg_RoundTime = 5
if ( InTesting and ShortHalves ) then
udg_RoundTime = HalfDurationInTestMode
endif
endif
endfunction
void HalfStartsMsg(integer half) {
Ensure(half==1 || half==2)
string str_half, left_team, right_team
if half==1
str_half = "1st"
left_team = TeamName[1]
right_team = TeamName[2]
else
str_half = "2nd"
left_team = TeamName[2]
right_team = TeamName[1]
endif
real time = 15 // seconds
echotimed("|c00ffcc00"+str_half+" half|r |c00ff0000STARTS!|r", time)
echo()
echotimed(left_team+"'s Kick-off", time)
echo()
echotimed(left_team+" = Attack |cffffcc00Right|r", time)
echotimed(right_team+" = Attack |cffffcc00Left|r", time)
echo()
}
public function DisplayMessages takes nothing returns nothing
//echo( "TRIGSTR/_226" ) // Voting finished!
if ( udg_nPlayersCanVote > 0 ) then
echo( I2S(udg_nPlayersCanVote) + " player(s) didn't vote.")
echo( )
endif
//echo( "Welcome to Warcraft Soccer!" )
//echo( )
if NationVotingAtStart
//call DeclareNations()
endif
Sleep(1)
call HalfStartsMsg(1)
Sleep(2)
//echo("New to the game? Enable " + Hotkey("-easy") + " mode for more rewarding experience :)")
if not PublicVersion
echo("New to the game? Enable " + Hotkey("-hints") + " to learn the basics :)")
echo()
endif
//echoln( "TRIGSTR_189" )
Sleep(3)
//echo("If you like, you can change hotkeys to QWER by typing "+Orange("-qwer"))
//echo("Added single hotkey curve ability (-curve mode).")
//echo("To show dribble indicator, write -show. To hide it, write -hide.")
//echo("To enable xv fix from 7.44a2.2, write -xv")
//echo("Over 10 new sounds have been added. Enable your sound by pressing Ctrl+S.")
//echo( "New feature - Manual header aiming." )
//echo( "To aim a header, use X, just before you head the ball." )
//echo( Orange("WEBSITE") )
//echo( "www.clangol.tk" )
//echo( "Check " + Orange("F9") + " for Game Info." )
//echo("To learn more about gameplay, type "+Orange("-help.") )
//call sBJDebugMsg("To learn more about gameplay, type %s.", Orange("-help"))
//echo("For list of changes in this version, type "+Orange("-changes")+".")
//echo("For new modes type: "+Orange("-z cooldown")+" and "+Orange("-wild x"))
//echo("You can adjust camera distance/angle by using inventory items.")
//echo("Improve your skill by playing with "+Orange("Clan KICK")+" members in Battle.net, Europe.")
//echo( "Learn about exciting new features in F9, Changelog." )
//echo( "Good luck and have fun!" )
endfunction
function ExecuteGameStartActions takes nothing returns nothing
call FogEnable( false )
call FogMaskEnable( false )
//call SetRoundTime() // moved to VotingFinshedActions - 7.47a
// comment needed - why execs, not calls?
exec(Camera_Init)
exec(Audio_Init)
call SetTeamNames()
exec(Init_DisplayMessages)
exec(Round_Init)
call CreateAndConfigKeepers()
call CreateUnits()
call TriggerExecute(gg_trg_Reset_player_locations)
exec(Scoreboard_Create)
call ModesLib_Init()
exec(Test_Init)
call AddFeetToHeroes()
//call Banners() // delays the rest by a few seconds!
call TriggerExecute( gg_trg_Initialize_Keepers )
call EnableTrigger( gg_trg_Timer_Interval_01 )
call EnableTrigger( gg_trg_Timer_Interval_001 )
endfunction
private void VotingFinishedActions() {
call DialogHide( VotingDialog )
call DialogDestroy( VotingDialog )
call DestroyTimerDialog( udg_TimerDialog )
call DestroyTimer( VotingTimer ) // to prevent second execution if the timer expires
call SetRoundTime()
}
private void CreateVotingTimerDialog() {
call TimerStart( VotingTimer, 10, false, function VotingFinishedActions )
set udg_TimerDialog = CreateTimerDialogBJ(VotingTimer, "Voting time: ")
set IsVotingTimerCreated = true
//echo( "The game will start within "+I2S(10)+" seconds!" )
}
private void ClickCounter() {
if ( GetClickedButton() == udg_BTN_5min ) then
udg_VoteResult[0] += 1 // magical numbers ?!
elseif ( GetClickedButton() == udg_BTN_7min ) then
udg_VoteResult[1] += 1
elseif ( GetClickedButton() == udg_BTN_10min )
udg_VoteResult[3] += 1
endif
}
private void PressDialogButton() {
call DialogDisplay( GetTriggerPlayer(), VotingDialog, false )
set udg_nPlayersCanVote -= 1
call ClickCounter()
if ( udg_nPlayersCanVote <= 0 ) then
call VotingFinishedActions()
elseif (not IsVotingTimerCreated)
call CreateVotingTimerDialog()
endif
}
private void ShowDurationVotingDialog() {
call Sleep( 0.10 )
call DialogSetMessage( VotingDialog, "TRIGSTR_227" )
set udg_BTN_5min = DialogAddButton( VotingDialog, "TRIGSTR_228", 0 )
set udg_BTN_7min = DialogAddButton( VotingDialog, "7.5 minutes per half", 0 )
set udg_BTN_10min = DialogAddButton( VotingDialog, "TRIGSTR_231", 0 )
force f = GetPlayersMatching(Condition(function UserControlsFilterPlayer))
set udg_nPlayersCanVote = countf( f )
set TempDialog = VotingDialog
call ForForce( f, function ShowDialogEnum )
// comment needed - what is this condition for?
if ( udg_nPlayersCanVote == 0 )
call VotingFinishedActions()
endif
}
/*private void InitializeMMD() {
//call MMD_init()
call MMD_DefineEvent1("goal", "Team\\ {0}\\ scored!\\ ", "team")
//primary
call MMD_DefineValue("goals", MMD_TYPE_INT, MMD_GOAL_HIGH, MMD_SUGGEST_LEADERBOARD) // +
call MMD_DefineValue("assists", MMD_TYPE_INT, MMD_GOAL_HIGH, MMD_SUGGEST_LEADERBOARD) // +
call MMD_DefineValue("rating", MMD_TYPE_REAL, MMD_GOAL_HIGH, MMD_SUGGEST_TRACK) // +
//additional
call MMD_DefineValue("passes_all", MMD_TYPE_INT, MMD_GOAL_NONE, MMD_SUGGEST_TRACK) // +
call MMD_DefineValue("passes_succ", MMD_TYPE_INT, MMD_GOAL_HIGH, MMD_SUGGEST_TRACK) // +
call MMD_DefineValue("ball_possession", MMD_TYPE_REAL, MMD_GOAL_HIGH, MMD_SUGGEST_TRACK) // +
// 01.06.2013
call MMD_DefineValue("owngoals", MMD_TYPE_INT, MMD_GOAL_HIGH, MMD_SUGGEST_LEADERBOARD) // -
call MMD_DefineValue("dribbles", MMD_TYPE_INT, MMD_GOAL_NONE, MMD_SUGGEST_TRACK) // -
//call MMD_DefineValue("", MMD_TYPE_REAL, MMD_GOAL_HIGH, MMD_SUGGEST_LEADERBOARD)
//DefineEvent takes string name, integer num_args, string format, string arg_data
}*/
private dialog array NationVotingDialog[3]
private timer array NationVotingTimer[3]
private integer array nvoters[3]
private button array NationButtons[30]
private integer IdentifyNationWithMostVotes(int team) {
if (team<1) || (team>2)
return 0
endif
int begin,end
if (team==1)
set begin = TEAM_ONE_NATIONS+1
set end = TEAM_TWO_NATIONS-1
elseif (team==2)
set begin = TEAM_TWO_NATIONS+1
set end = END_NATIONS-1
endif
int nation = begin
int maxvotes = -1
int winner = 0
int nvotes = 0
string str_nation = ""
whilenot (nation > end) {
set str_nation = NationToStr(nation)
set nvotes = GameGetInt(str_nation)
if (nvotes > maxvotes)
set maxvotes = nvotes
set winner = nation
endif
nation++
}
return winner
}
private void clickCounter() {
int begin = TEAM_ONE_NATIONS+1
int end = END_NATIONS-1
int nation = begin
whilenot (nation > end) {
if true {//not (nation==TEAM_TWO_NATIONS) { // NationButtons[TEAM_TWO_NATIONS] is uninitialized!..
if GetClickedButton() == NationButtons[nation] {
string str_nation = NationToStr(nation)
call GameIncInt(str_nation)
}
}
nation++
}
}
private void finishVotingAbstracted(integer team) {
call DialogHide( NationVotingDialog[team] )
call DialogDestroy( NationVotingDialog[team] )
call DestroyTimer( NationVotingTimer[team] )
int nation = IdentifyNationWithMostVotes(team)
string str_nation = NationToStr(nation)
call TeamStoreStr(team, "nation", str_nation)
call TeamStoreInt(team, "nation_id", nation)
}
private void finishVoting1() {
call finishVotingAbstracted(1)
}
private void finishVoting2() {
call finishVotingAbstracted(2)
}
private void createTimer(integer team) {
set NationVotingTimer[team] = CreateTimer()
if team==1
call TimerStart( NationVotingTimer[team], 10, false, function finishVoting1 )
else
call TimerStart( NationVotingTimer[team], 10, false, function finishVoting2 )
endif
//set IsNationVotingTimerCreated = true
//set udg_TimerDialog = CreateTimerDialogBJ(VotingTimer, "Voting time: ")
//echo( "The game will start within "+I2S(10)+" seconds!" )
}
private void pressButton() {
player p = GetTriggerPlayer()
integer team = GetPlayerConvertedTeam(p)
call DialogDisplay( p, NationVotingDialog[team], false )
set nvoters[team] -= 1
call clickCounter()
if ( nvoters[team] <= 0 ) then
call finishVotingAbstracted(team)
elseif (NationVotingTimer[team] == null)
call createTimer(team)
endif
}
private button DialogAddNation(dialog d, integer nation) {
string s = ColorizeByNation(NationToStr(nation),nation)
return DialogAddButton(d,s,0)
}
private void CreateNationVotingDialog(integer team) {
call Sleep()
call Ensure( team==1 || team==2 )
dialog d = NationVotingDialog[team]
call DialogSetMessage( d, "Choose the country you wish to play for" )
int begin,end
if (team==1)
set begin = TEAM_ONE_NATIONS+1
set end = TEAM_TWO_NATIONS-1
elseif (team==2)
set begin = TEAM_TWO_NATIONS+1
set end = END_NATIONS-1
endif
int picked_nation
int nation = begin
whilenot (nation > end) {
if false//(nation==TEAM_ONE_NATIONS+3) || (nation==TEAM_TWO_NATIONS+3)
set picked_nation = GetRandomInt(nation,nation+1)
nation+=2
else
set picked_nation = nation
nation++
endif
set NationButtons[picked_nation] = DialogAddNation( d, picked_nation )
}
trigger t = CreateTrigger( )
call TriggerRegisterDialogEvent( t, d )
call TriggerAddAction( t, function pressButton )
force f = GetPlayersByTeamNumber(team)
set nvoters[team] = countf( f )
set TempDialog = d
call ForForce( f, function ShowDialogEnum )
if ( nvoters[team] == 0 )
call finishVotingAbstracted(team)
endif
}
private void mapInit() {
//call StopMusic( false )
call ClearMapMusic() // disables default music?
call SetTimeOfDayScale( 0.0 ) // stopping day-night timer
call SetTimeOfDay( 12.0 )
call SetAllyColorFilterState( 0 )
call SetMapFlag(MAP_LOCK_RESOURCE_TRADING, true)
//call InitializeMMD()
call DisableTrigger( gg_trg_Timer_Interval_01 )
call DisableTrigger( gg_trg_Timer_Interval_001 )
call TriggerExecute( gg_trg_Assign_values )
if NationVotingAtStart
if PublicVersion
set udg_RoundTime = 7.5
else
set udg_RoundTime = 10
endif
call CreateNationVotingDialog(1)
call CreateNationVotingDialog(2)
whilenot (TeamGetInt(1,"nation_id")>0 && TeamGetInt(2,"nation_id")>0)
call Sleep()
endwhile
else
call ShowDurationVotingDialog()
endif
// comm.needed - purpose of this sleep()
// otherwise game starts before voting dialog is shown
call Sleep(0.5)
call ExecuteGameStartActions()
}
private void config() {
trigger t
Sleep() // to avoid bug when globals are not yet "created" (VotingDialog with DialogCreate())
set t = CreateTrigger( )
call TriggerRegisterDialogEvent( t, VotingDialog )
call TriggerAddAction( t, function PressDialogButton )
set NationVotingDialog[1] = DialogCreate()
set NationVotingDialog[2] = DialogCreate()
set NationVotingTimer[1] = null
set NationVotingTimer[2] = null
/*
set t = CreateTrigger()
call TriggerRegisterTimerExpireEvent( t, VotingTimer )
call TriggerAddAction( t, function VotingFinishedActions )
*/
}
void InitTrig_Initialization() {
set gg_trg_Initialization = CreateTrigger( )
call TriggerAddAction( gg_trg_Initialization, function mapInit )
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
define
/*CODE PATTERNS*/
IsInSet(value, v1) = {
(value == v1)
}
IsInSet(value, v1, v2) = {
( IsInSet(value, v1) || IsInSet(value, v2) )
}
IsInSet(value, v1, v2, v3) = {
( IsInSet(value, v1, v2) || IsInSet(value, v3) )
}
IsInSet(value, v1, v2, v3, v4) = {
( IsInSet(value, v1, v2) || IsInSet(value, v3, v4) )
}
IsInSet(value, v1, v2, v3, v4, v5) = {
( IsInSet(value, v1, v2, v3) || IsInSet(value, v4, v5) )
}
IsInSet(value, v1, v2, v3, v4, v5, v6) = {
( IsInSet(value, v1, v2, v3) || IsInSet(value, v4, v5, v6) )
}
IsInSet(value, v1, v2, v3, v4, v5, v6, v7) = {
( IsInSet(value, v1, v2, v3) || IsInSet(value, v4, v5, v6, v7) )
}
IsNull(h) = {
(h == null)
}
ConditionalAction(cond, todo) = {
if (cond) {todo}
}
DecUntil(n, lowerLimit) = {
DoNothing()
if (n > lowerLimit) then
Dec(n)
endif
// different implementation
// set n = IMaxBJ(lowerLimit, n-1)
}
DecIfPositive(n) = {
DecUntil(n,0)
}
Inc(n) = {
DoNothing()
n = n + 1
}
Dec(n) = {
DoNothing()
n = n - 1
}
Ensure(b) = {
DoNothing()
if not (b) then
return
endif
}
Ensure(b,void) = {
DoNothing()
if not (b) then
return false
endif
}
exec(func_name) = {
ExecuteFunc(`func_name`)
//StartThread(func_name)
}
/*doif(todo,cond) = {
if (cond) {todo}
}*/
/*FUNC ALIASES*/
cPid(p) = {
GetConvertedPlayerId(p)
}
Sid(void) = {
GetSpellAbilityId()
}
TrgUnit(void) = {
GetTriggerUnit()
}
HideUnit(u) = {
ShowUnitHide(u)
}
ShowUnit(u) = {
ShowUnitShow(u)
}
Sleep(t) = {
TriggerSleepAction(t)
}
Sleep() = {
Sleep(0)
}
sleep(t) = {
Sleep(t)
}
wait(t) = {
PolledWait(t)
}
/*MEMORY LEAKS REMOVAL NOTATION*/
CleanLoc(loc_1) = {
RemoveLocation(loc_1)
loc_1 = null
}
CleanLocs(loc_1, loc_2) = {
CleanLoc(loc_1)
CleanLoc(loc_2)
}
CleanLocs(loc_1, loc_2, loc_3) = {
CleanLoc(loc_1)
CleanLoc(loc_2)
CleanLoc(loc_3)
}
RemoveForce(f_1) = {
DestroyForce(f_1)
f_1 = null
}
RemoveCond(cond_1) = {
DestroyCondition(cond_1)
cond_1 = null
}
RemoveGroup(g_1) = {
DestroyGroup(g_1)
g_1 = null
}
/*LIBS*/
endlib = endlibrary
lib_keyword = library
const = constant
lib_init(lib_name, init_func, lib_req) = {
lib_keyword lib_name initializer init_func requires lib_req
}
lib_init(lib_name, init_func) = {
lib_keyword lib_name initializer init_func
}
lib(lib_name) = {
lib_keyword lib_name
}
lib(lib_name, lib_req) = {
lib_keyword lib_name requires lib_req
}
enddefine
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib( TextLib )
define
echo(s) = {
DisplayTextToForce(GetPlayersAll(),s)
}
echo() = {
echo(" ")
}
echo(p, s) = {
DisplayTextToPlayer(p,0,0,s)
}
echoln() = {
echo( )
}
echoln(s) = {
echo( )
echo(s)
}
echoln(p, s) = {
echo( )
echo(p,s)
}
msgtimed(s) = {
MsgTimed(`s`)
}
testmsg(text) = {
if InTesting { echo(`text`) }
}
write(text) = {
echo(`text`)
}
<declare string> = {
string input = GetEventPlayerChatString()
string pattern = GetEventPlayerChatStringMatched()
int strlen = StringLength(input)
int patlen = StringLength(pattern)
bool isExactMatch = strlen == patlen
}
enddefine
string SubChar(string s, int n) {
return SubStringBJ(s,n,n)
}
bool IsSpace(string s) {
//Ensure(StringLength(s) == 1,)
return SubChar(s,1) == " "
}
// returns position of first non-space symbol
int IgnoreSpaces(string input,int c) {
while ( IsSpace( SubChar(input,c) ) )
{
c++
}
return c
}
// returns positiong of first space or null symbol
int IgnoreSymbols(string input,int c) {
string s = SubChar(input,c)
whilenot IsSpace(s) || s == null || s == ""
{
c++
s = SubChar(input,c)
}
return c
}
void echotimed(string s, real duration) {
call DisplayTimedTextToForce(GetPlayersAll(), duration, s)
}
function MsgTimed takes string s returns nothing
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 20, s)
endfunction
function DebugMsg takes string s returns nothing
call DisplayTextToForce( Debuggers, s )
endfunction
function TestMsg takes string s returns nothing
if InTesting
echo(s)
endif
endfunction
function EventStringExactMatch takes nothing returns boolean
string input = GetEventPlayerChatString()
string pattern = GetEventPlayerChatStringMatched()
int len_input = StringLength(input)
int len_pattern = StringLength(pattern)
bool b1 = len_input == len_pattern
bool b2 = len_input != 0
return b1 and b2
endfunction
define endl(p) = {
echo(p, " ")
}
define endl() = {
echo( )
}
constant string GetTriggerString() {
return GetEventPlayerChatString()
}
function R2IS takes real r returns string
return I2S(R2I(r))
endfunction
// colors manipulation
define Orange(s) = {
"|cffffcc00"+s+"|r"
}
define orange(s) = {
Orange(`s`)
}
define White(s) = {
"|cffffffff"+s+"|r"
}
define white(s) = {
White(`s`)
}
function Hotkey takes string s returns string
return "|cffffcc00"+s+"|r"
endfunction
function BrightOrange takes string s returns string
return "|cffff8000"+s+"|r"
endfunction
function Black takes string s returns string
return "|cff000000"+s+"|r"
endfunction
function Cyan takes string s returns string
return "|cff00ffff" + s + "|r"
endfunction
function Yellow takes string s returns string
return "|cffffff00"+ s + "|r"
endfunction
function Blue takes string s returns string
return "|cff0000ff"+ s + "|r"
endfunction
function Red takes string s returns string
return "|cffff0000"+ s + "|r"
endfunction
function Green takes string s returns string
return "|cff00ff00"+ s + "|r"
endfunction
function Grey takes string s returns string
return "|cff444444"+ s + "|r"
endfunction
function Maroon takes string s returns string
return "|cff800000"+ s + "|r"
endfunction
function LightBlue takes string s returns string
return "|cff0080ff"+s+"|r"
endfunction
function DarkBlue takes string s returns string
return "|cff004080"+s+"|r"
endfunction
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib (AuxiliaryFuncs)
int count(group g) {
return CountUnitsInGroup(g)
}
int countg(group g) {
return CountUnitsInGroup(g)
}
int countf(force f) {
return CountPlayersInForceBJ(f)
}
function AngleBetweenUnits takes unit u1, unit u2 returns real
real u1_x = GetUnitX(u1)
real u2_x = GetUnitX(u2)
real u1_y = GetUnitY(u1)
real u2_y = GetUnitY(u2)
return bj_RADTODEG * Atan2(u2_y - u1_y, u2_x - u1_x)
endfunction
function DistanceBetweenUnits takes unit u1, unit u2 returns real
real x1 = GetUnitX(u1), y1 = GetUnitY(u1)
real x2 = GetUnitX(u2), y2 = GetUnitY(u2)
real dx = x1-x2, dy = y1-y2
real dist = SquareRoot(dx*dx + dy*dy)
return dist
endfunction
unit ClosestUnit = null
function GroupPickClosestUnitEnum takes nothing returns nothing
unit u = GetEnumUnit()
real dist = DistanceBetweenUnits(u, TempUnit)
if TempReal == 0.0 || TempReal > dist then
set TempReal = dist
set ClosestUnit = u
endif
endfunction
function GroupPickClosestUnit takes group g, unit u returns unit
set TempReal = 0.0
set TempUnit = u
set ClosestUnit = null
call ForGroup(g, function GroupPickClosestUnitEnum)
return ClosestUnit
endfunction
unit GroupPickNearestUnitToLoc(group g, location loc) {
real dist_min = 0
unit nearest_unit = null
///*
for(unit u; UnitsInGroup(g))
{
location loc_unit = GetUnitLoc(u)
real dist = DistanceBetweenPoints(loc_unit, loc)
if dist_min == 0 || dist_min > dist
dist_min = dist
nearest_unit = u
endif
}
//*/
return nearest_unit
}
bool ShallAddExclamationMark = true
texttag CreateExclamatoryTextTagMain (string s, location loc, real zOffset, real R, real G, real B) {
if ShallAddExclamationMark then
s += "!"
endif
set ShallAddExclamationMark = true
texttag t = CreateTextTagLocBJ( s, loc, zOffset, 10, R, G, B, 0 )
call SetTextTagVelocityBJ( t, 64, 90 )
call SetTextTagPermanentBJ( t, false )
call SetTextTagLifespanBJ( t, 4 )
call SetTextTagFadepointBJ( t, 3 )
return t
}
define CreateExclamatoryTextTag(s,loc,zOffset,R,G,B) = {
CreateExclamatoryTextTagMain(s,loc,zOffset,R,G,B)
}
define CreateExclamatoryTextTag(s,loc,zOffset,color) = {
CreateExclamatoryTextTag(s,loc,zOffset,color.R,color.G,color.B)
}
define CreateExclamatoryTextTag(s,loc,color) = {
CreateExclamatoryTextTag(s,loc,100,color)
}
void SetUnitLoc (unit u, location loc) {
call SetUnitPositionLoc(u, loc)
}
function AddLeadingZeroes takes int n returns string
string retval = I2S(n)
if n < 10
retval = "0" + retval
endif
return retval
endfunction
// trigger event utility func
function TriggerRegisterAnyPlayerEvent takes trigger trg, playerevent whichEvent returns nothing
int pcount = 0
while (pcount < 12) {
call TriggerRegisterPlayerEvent( trg, Player(pcount), whichEvent )
pcount ++
}
endfunction
function TriggerRegisterAnyPlayerUnitEvent takes trigger trg, playerunitevent whichEvent returns nothing
int pcount = 0
while (pcount <= 11) {
call TriggerRegisterPlayerUnitEventSimple( trg, Player(pcount), whichEvent )
pcount += 1
}
endfunction
function TriggerExecuteIfEnabled takes trigger t returns void
if IsTriggerEnabled(t) then
call TriggerExecute(t)
endif
endfunction
function UnitMove takes unit u, location loc returns nothing
if loc == null
return
endif
call IssuePointOrderLoc( u, "move", loc )
endfunction
function BallMove takes location loc returns void
//call Ensure(loc != null)
call UnitMove(udg_Ball, loc)
endfunction
function TriggerRegisterAnyPlayerChatEventMain takes trigger trg, string str, bool exactMatch returns nothing
int pcount = 0
whilenot pcount > 11 {
call TriggerRegisterPlayerChatEvent( trg, Player(pcount), str, exactMatch )
pcount++
}
endfunction
#define TriggerRegisterAnyPlayerChatEvent(trg, str, exactMatch) = {
TriggerRegisterAnyPlayerChatEventMain(trg, str, exactMatch)
}
#define TriggerRegisterAnyPlayerChatEvent(trg, str1, str2, exactMatch) = {
TriggerRegisterAnyPlayerChatEvent(trg, str1, exactMatch)
TriggerRegisterAnyPlayerChatEvent(trg, str2, exactMatch)
}
#define TriggerRegisterAnyPlayerChatEvent(trg, str1, str2, str3, exactMatch) = {
TriggerRegisterAnyPlayerChatEvent(trg, str1, str2, exactMatch)
TriggerRegisterAnyPlayerChatEvent(trg, str3, exactMatch)
}
#define TriggerRegisterAnyPlayerChatEvent(trg, str1, str2, str3, str4, exactMatch) = {
TriggerRegisterAnyPlayerChatEvent(trg, str1, str2, exactMatch)
TriggerRegisterAnyPlayerChatEvent(trg, str3, str4, exactMatch)
}
function TriggerAddConditionSimple takes trigger t, code cond_func returns nothing
DoNothing()
call Ensure(cond_func != null)
call Ensure(t != null)
call TriggerAddCondition(t, Condition(cond_func))
endfunction
#define TrgAddCond(t, cond_func) = {
TriggerAddConditionSimple(t, cond_func)
}
//
function MaskFadeOut takes real duration returns nothing
call CinematicFadeBJ(bj_CINEFADETYPE_FADEOUT,duration,"ReplaceableTextures\\CameraMasks\\Black_mask.blp",100,100,100,0)
endfunction
function MaskFadeIn takes real duration returns nothing
int fadetype = bj_CINEFADETYPE_FADEIN
string path = "ReplaceableTextures\\CameraMasks\\Black_mask.blp"
int R=100, G=100, B=100
call CinematicFadeBJ(fadetype,duration,path,R,G,B,0)
endfunction
function CountUnitsInRangeOfLocMatching takes real range, location loc, conditionfunc cond returns int
group g = GetUnitsInRangeOfLocMatching(range, loc, cond)
int n = CountUnitsInGroup(g)
call RemoveGroup(g)
return n
endfunction
function GetPitchCenter takes nothing returns location
return GetRectCenter(gg_rct_Center)
endfunction
function IsUnitInRect takes unit u, rect r returns boolean
return RectContainsUnit(r, u)
endfunction
function RevealUnit takes unit u returns nothing
call ShowUnitShow(u)
endfunction
function Round takes real r returns int
local string s = R2SW(r, 1, 0)
local int retVal = R2I(S2R(s))
// local int retVal = S2I(s) // may be simpler
return retVal
endfunction
function Abs takes real r returns real
return RAbsBJ(r)
endfunction
real abs(real r) {
return RAbsBJ(r)
}
int mod(int dividend, int divisor) {
return ModuloInteger(dividend, divisor)
}
function SetUnitHeight takes unit u, real h returns nothing
call SetUnitFlyHeight( u, h, 0.0 )
endfunction
function SetUnitH takes unit u, real h returns nothing
call SetUnitHeight(u, h)
endfunction
function OverHeadFlashEffect takes unit u returns nothing
string path = "Abilities\\Spells\\Other\\Levelup\\LevelupCaster.mdl"
call DestroyEffect(AddSpecialEffectTarget(path, u, "overhead"))
endfunction
void FlashEffect(unit u, string point) {
string path = "Abilities\\Spells\\Other\\Levelup\\LevelupCaster.mdl"
call DestroyEffect(AddSpecialEffectTarget(path, u, point))
}
function GetChance takes real r returns boolean
if r >= 1
return true
elseif r <= 0
return false
else
real r2 = GetRandomReal(0, 1)
return r2 <= r
endif
endfunction
// PLAYER SLOT STATE & PLAYER CONTROLLER FUNCS
function IsControllerUser takes player p returns boolean
return GetPlayerController(p) == MAP_CONTROL_USER
endfunction
function IsPlayerStatePlaying takes player p returns boolean
return GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING
endfunction
function IsPlayerStateLeft takes player p returns boolean
return GetPlayerSlotState(p) == PLAYER_SLOT_STATE_LEFT
endfunction
function IsPlayerStatePlayingOrLeft takes player p returns boolean
local boolean b1 = IsPlayerStatePlaying(p)
local boolean b2 = IsPlayerStateLeft(p)
return b1 or b2
endfunction
function FilterPlayerStatePlaying takes nothing returns boolean
return IsPlayerStatePlaying(GetFilterPlayer())
endfunction
function FilterPlayerStateLeft takes nothing returns boolean
return IsPlayerStateLeft(GetFilterPlayer())
endfunction
function FilterPlayerStatePlayingOrLeft takes nothing returns boolean
return IsPlayerStatePlayingOrLeft(GetFilterPlayer())
endfunction
function IsPlayerBot takes player p returns bool
return GetPlayerController(p) == MAP_CONTROL_COMPUTER
endfunction
function IsPlayerPlaying takes player p returns bool
bool b1 = IsPlayerStatePlaying(p)
int pid = GetConvertedPlayerId(p)
bool b2 = udg_Hero[pid] != null
bool b3 = not IsUnitHidden(udg_Hero[pid])
bool b4 = not IsPlayerInForce(p, Observers)
bool b5 = true
// IsPlayerBot()
// IsPlayerAway()
// IsPlayerInPitch()
return b1 and b2 and b3 and b4 and b5
endfunction
function IsPlayerPlayingObs takes player p returns bool
bool b1 = IsPlayerStatePlaying(p)
int pid = GetConvertedPlayerId(p)
bool b2 = udg_Hero[pid] != null
bool b3 = true
bool b4 = true
bool b5 = true
// IsPlayerBot()
// IsPlayerAway()
// IsPlayerInPitch()
return b1 and b2 and b3 and b4 and b5
endfunction
force GetPlayingPlayers() {
conditionfunc cond = Condition(function FilterPlayerStatePlaying)
return GetPlayersMatching(cond)
}
function UserControlsFilterPlayer takes nothing returns boolean
local boolean b1 = GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER
local boolean b2 = FilterPlayerStatePlaying()
return b1 and b2
endfunction
function ShowDialogEnum takes nothing returns nothing
call DialogDisplay( GetEnumPlayer(), TempDialog, true )
endfunction
void DialogHide(dialog d) {
call DialogDisplay(GetLocalPlayer(), d, false)
}
// TODO - IsPlayerPassable - identical to IsPlayerPlaying
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib( UnitPlayerTeam )
function GetPlayerNameById takes int id returns string
return GetPlayerName(Player(id))
endfunction
string LowerCase(string s) {
return StringCase(s, false)
}
player GetPlayerByName(string s) {
int pid = 0
player p
string pname
s = LowerCase(s)
whilenot (pid >= 12)
{
set p = Player(pid)
set pname = LowerCase(GetPlayerName(p))
if ( pname == s ) then
return p
endif
++pid
}
return null
}
player GetPlayerByShortName(string s) {
int strlen = StringLength(s)
if strlen < 2
return null
endif
player p = null
int nplayers = 0
for (int i = 1; i<=12; i++)
{
player indexPlayer = ConvertedPlayer(i)
string pname = GetPlayerName(indexPlayer)
set pname = LowerCase(pname)
int strlen_pname = StringLength(pname)
bool found = false
int j=1
while((j<=strlen_pname)&&(!found)) {
if (SubStringBJ(pname,j,j+strlen-1) == s)
found = true
p = indexPlayer
nplayers++
endif
j++
}
// this nested for-loop caused a syntax error
/*for (int j=1; (j<=strlen_pname)&&(!found); j++) //j<=strlen_pname-strlen+1
{
if (SubStringBJ(pname,j,j+strlen-1) == s)
found = true
p = indexPlayer
nplayers++
endif
}*/
}
if nplayers == 1
return p
else
return null
endif
}
player GetPlayerById(string s) {
/*int strlen = StringLength(s)
// make sure s is a string representation of a number between 1 and 12
call Ensure(strlen == 1 || IsInSet(s, "10","11","12"))
*/
int cpid = S2I(s) // better mechanism?
if cpid >= 1 && cpid <= 12 then
return ConvertedPlayer(cpid)
endif
return null
}
player GetPlayerByColor(string s) {
/*elseif s == "" then
return Player(12)*/
// IsInSet(s, "", "")
if s == "red" then
return Player(0)
elseif s == "blue" then
return Player(1)
elseif IsInSet(s, "teal", "cyan") then
return Player(2)
elseif s == "purple" then
return Player(3)
elseif s == "yellow" then
return Player(4)
elseif s == "orange" then
return Player(5)
elseif s == "green" then
return Player(6)
elseif s == "pink" then
return Player(7)
elseif IsInSet(s, "grey", "gray") then
return Player(8)
elseif IsInSet(s, "white", "lightblue") then
return Player(9)
elseif IsInSet(s, "darkgreen", "aqua") then
return Player(10)
elseif s == "brown" then
return Player(11)
endif
return null
}
private player GetPlayerBySpecifierMain(string s, bool byName, bool byColor, bool byId) {
player p = null
if byName && (p == null)
set p = GetPlayerByName(s)
endif
if byColor && (p == null)
set p = GetPlayerByColor(s)
endif
if byId && (p == null)
set p = GetPlayerById(s)
endif
return p
}
#define GetPlayerBySpecifier(s) = {
GetPlayerBySpecifierMain(s, true, true, false)
}
#define GetPlayerBySpecifier(s, name, color) = {
GetPlayerBySpecifierMain(s, name, color, false)
}
#define GetPlayerBySpecifier(s, name, color, id) = {
GetPlayerBySpecifierMain(s, name, color, id)
}
bool IsMorgan(player p) {
return (p == morganxl) && (morganxl != null)
}
bool IsUserMorgan(void) {
return IsMorgan(GetTriggerPlayer())
}
constant function IsKeeper takes unit u returns bool
local bool b1 = u == KEEPER_FIRST
local bool b2 = u == KEEPER_SECOND
return b1 or b2
endfunction
constant function IsPlayerObs takes player p returns bool
return IsPlayerInForce(p, Observers)
endfunction
function GetSquadById takes int id returns group
group g = CreateGroup()
if id == 1 then
call GroupAddGroup(udg_Team1Heroes, g)
elseif id == 2 then
call GroupAddGroup(udg_Team2Heroes, g)
else
g = null
endif
return g
endfunction
function GetFullSquad takes int id returns group
group g = GetSquadById(id)
call GroupAddUnit(g, udg_Keeper[id])
return g
endfunction
function GetUnitTeamNew takes unit u returns int
player p = GetOwningPlayer(u)
return GetPlayerTeam(p)
endfunction
function GetOwnerId takes unit u returns int
return GetConvertedPlayerId(GetOwningPlayer(u))
endfunction
function GetHeroByPlayer takes player p returns unit
int pid = GetConvertedPlayerId(p)
if (pid > 12) || (pid < 1)
return null
endif
return udg_Hero[pid]
endfunction
function GetHero takes player p returns unit
return GetHeroByPlayer(p)
endfunction
// Filter, player, unit utility funcs
function IsFilterUnitHero takes nothing returns bool
local integer pid = GetConvertedPlayerId(GetOwningPlayer(GetFilterUnit()))
bool b1 = GetFilterUnit() == udg_Hero[pid]
return b1
endfunction
function IsFilterUnitHeroOrKeeper takes nothing returns bool
int pid = GetConvertedPlayerId(GetOwningPlayer(GetFilterUnit()))
bool b1 = GetFilterUnit() == udg_Hero[pid]
bool b2 = IsKeeper(GetFilterUnit())
return b1 || b2
endfunction
function IsHeroNotObs takes nothing returns bool
local integer pid = GetConvertedPlayerId(GetOwningPlayer(GetFilterUnit()))
local bool b1 = udg_Hero[pid] == GetFilterUnit()
local bool b2 = not IsPlayerInForce( GetOwningPlayer(GetFilterUnit()), Observers )
return b1 and b2
endfunction
function IsUnitHero takes unit hero returns bool
integer pid = GetConvertedPlayerId(GetOwningPlayer(hero))
return (udg_Hero[pid] == hero)
endfunction
function IsUnitInTeam takes unit u, integer team returns bool
if team == 1
return IsUnitInGroup(u, TeamHeroes[1])
elseif team == 2
return IsUnitInGroup(u, TeamHeroes[2])
endif
return false
endfunction
bool IsPlayerInTeam(player p, int team) {
int pid = GetConvertedPlayerId(p)
if pid < 1 || pid > 12
return false
endif
unit u = udg_Hero[pid]
return ( IsUnitInTeam(u, team) )
// version 2
return ( GetPlayerTeam(p) == team )
// version 3
if team == 1
return IsPlayerAlly(p,Player(0))
elseif team == 2
return IsPlayerEnemy(p,Player(0))
endif
return false
//
}
function IsLeftPlayer takes player p returns bool
local bool b1 = udg_Round == FIRST_HALF && IsPlayerInTeam(p,1)
local bool b2 = udg_Round == SECOND_HALF && IsPlayerInTeam(p,2)
return b1 || b2
endfunction
integer GetPlayerConvertedTeam(player p) {
if p==null
return 0
endif
return (GetPlayerTeam(p)+1)
}
force GetPlayersByTeamNumber(int team) {
if team < 1 || team > 2
return null
endif
force f = CreateForce()
force users = GetPlayersMatching(Condition(function UserControlsFilterPlayer))
int pid = 1
player p = null
whilenot (pid > 12) {
set p = ConvertedPlayer(pid)
if (GetPlayerTeam(p)==team-1) && IsPlayerInForce(p,users)
call ForceAddPlayer(f,p)
endif
pid++
}
return f
}
force GetPlayersByTeam(int team) {
if not IsInSet(team,1,2)
return null
endif
force f = CreateForce()
for (unit u; UnitsInGroup(TeamHeroes[team]))
{
player p = GetOwningPlayer(u)
call ForceAddPlayer(f,p)
}
return f
}
function IsKeeperAlly takes unit keeper, unit u returns bool
if not IsUnitHero(u) then
return false
endif
bool b11 = keeper == udg_Keeper[1]
bool b12 = IsUnitInTeam(u, 1)
bool b1 = b11 and b12
bool b21 = keeper == udg_Keeper[2]
bool b22 = IsUnitInTeam(u, 2)
bool b2 = b21 and b22
return b1 or b2
endfunction
function GetKeeperId takes unit u returns integer
if not IsKeeper(u)
return 0
endif
if u == udg_Keeper[1]
return 1
else
return 2
endif
endfunction
function IsUnitPlaying takes unit u returns bool
return IsUnitHero(u) or IsKeeper(u)
endfunction
function IsUnitInTeamExt takes unit u, integer team returns bool
if IsUnitInTeam(u, team)
return true
elseif IsKeeper(u)
return udg_Keeper[team] == u
endif
return false
endfunction
function IsUnitFromLeftTeam takes unit u returns bool
if not IsUnitPlaying(u)
return false
endif
bool b1 = IsUnitInTeamExt(u,1) && udg_Round == 0
bool b2 = IsUnitInTeamExt(u,2) && udg_Round == 2
return b1 or b2
endfunction
bool IsUnitFromRightTeam (unit u) {
if not IsUnitPlaying(u)
return false
endif
bool b1 = IsUnitInTeamExt(u,2) && udg_Round == 0
bool b2 = IsUnitInTeamExt(u,1) && udg_Round == 2
return b1 || b2
}
function IsFilterUnitPeon takes nothing returns boolean
//return IsUnitEnemy(GetFilterUnit(), Player(0))
return IsUnitInTeam(GetFilterUnit(), 2)
endfunction
function IsEnumUnitPeasant takes nothing returns bool
//return IsUnitAlly(GetEnumUnit(), Player(0))
return IsUnitInTeam(GetEnumUnit(), 1)
endfunction
function IsFilterUnitPeasant takes nothing returns boolean
return IsUnitInTeam(GetFilterUnit(), 1)
//return IsUnitEnemy(GetFilterUnit(), Player(11))
endfunction
function IsUnitEnemyExt takes unit u1, unit u2 returns bool
if IsUnitInTeamExt(u1, 1) && IsUnitInTeamExt(u2, 2)
return true
elseif IsUnitInTeamExt(u1, 2) && IsUnitInTeamExt(u2, 1)
return true
endif
return false
endfunction
function IsUnitAllyExt takes unit u1, unit u2 returns bool
if IsUnitInTeamExt(u1, 1) && IsUnitInTeamExt(u2, 1)
return true
elseif IsUnitInTeamExt(u1, 2) && IsUnitInTeamExt(u2, 2)
return true
endif
return false
endfunction
function GetExtendedId takes unit u returns integer
if IsKeeper(u)
return 12+ GetKeeperId(u)
elseif IsUnitHero(u)
return GetConvertedPlayerId(GetOwningPlayer(u))
endif
return 0
endfunction
private function GetTeamOfUnit takes unit u returns group
if IsUnitInGroup(u, udg_Team1Heroes)
return udg_Team1Heroes
elseif IsUnitInGroup(u, udg_Team2Heroes)
return udg_Team2Heroes
endif
return null
endfunction
function GetTeamNumberOfUnit takes unit u returns integer
if IsUnitInGroup(u, udg_Team1Heroes)
return 1
elseif IsUnitInGroup(u, udg_Team2Heroes)
return 2
else
return 0
endif
endfunction
function GetEnemyTeamNumber takes integer team returns integer
if team == 1
return 2
elseif team == 2
return 1
endif
return 0
endfunction
function GetUnitTeam takes unit u, bool CheckKeepers returns int
if IsUnitInGroup(u, TeamHeroes[1])
return 1
elseif IsUnitInGroup(u, TeamHeroes[2])
return 2
elseif CheckKeepers && IsKeeper(u)
return GetKeeperId(u)
endif
return 0
endfunction
function GetUnitTeamSimple takes unit u returns int
return GetUnitTeam(u, false)
endfunction
function GetUnitTeamExt takes unit u returns int
return GetUnitTeam(u, true)
endfunction
function GetTeamNumberByPid takes integer pid returns integer
/*if pid >= 1 && pid <= 6
return 1
elseif pid >= 7 && pid <= 12
return 2
endif*/
unit u = Hero[pid]
return ( GetUnitTeamSimple(u) )
endfunction
function GetUnitSquad takes unit u returns group
group g = CreateGroup()
group squad = GetTeamOfUnit(u)
if squad == null
return null
endif
call GroupAddGroup(squad ,g)
return g
endfunction
void ShowTextTagGroupEnum() {
unit u = GetEnumUnit()
player p = GetOwningPlayer(u)
force f = GetForceOfPlayer(p)
call ShowTextTagForceBJ(TempBool,TempTT,f)
}
void ShowTextTagGroup(bool show, texttag tt, group g) {
set TempBool = show
set TempTT = tt
call ForGroup(g, function ShowTextTagGroupEnum)
}
group GetAllies(unit u) {
return GetUnitSquad(u)
}
bool IsPlayerEligibleForVoting(player p) {
unit u = GetHero(p)
int pid = cPid(p)
bool b1 = p!=null
bool b2 = GetPlayerController(p) == MAP_CONTROL_USER
bool b3 = IsPlayerStatePlaying(p)
bool b4 = not IsPlayerObserver(p)
bool b5 = not IsPlayerObs(p)
bool b6 = not IsUnitHidden(u)
bool b7 = pid >= 1 && pid <= 12
//bool b8 = not IsPlayerAaway(p)
return b1 && b2 && b3 && b4
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
#undef Ball
constant real CLASSIC_BALL_ANIM_SCALE_STILL = 0
constant real CLASSIC_BALL_ANIM_SCALE_OWNER = 350
constant real CLASSIC_BALL_ANIM_SCALE_COEF_MOVING = 1.5
constant integer BALL_CLASSIC = 1
constant integer BALL_BRAZUCA = 2
integer BALL_TYPE = BALL_CLASSIC
lib( Ball )
#setdef Ball = udg_Ball
function RunBallGeneralAnimations takes nothing returns nothing
call Ensure( udg_BallOwner == null )
call TriggerExecute( gg_trg_General_Animations )
endfunction
function SetAcquiredBallScale takes nothing returns nothing
// ball scale when obtained
real scale_owner = CLASSIC_BALL_ANIM_SCALE_OWNER
call SetUnitTimeScalePercent( udg_Ball, scale_owner )
endfunction
public unit GetHandle() {
return BALL
}
public void SetFacing(real direction) {
call SetUnitFacing(Ball, direction)
}
public real GetFacing() {
return GetUnitFacing(Ball)
}
public constant location GetLoc() {
return GetUnitLoc(udg_Ball)
}
constant function GetBallLoc takes nothing returns location
return GetUnitLoc(udg_Ball)
endfunction
public void SetLoc (location loc) {
call SetUnitPositionLoc( Ball, loc )
}
group GetUnitsInRangeOfBallMatching(real radius, conditionfunc cond) {
return GetUnitsInRangeOfLocMatching(radius, Ball_GetLoc(), cond)
}
public location GetOwnerLoc() {
if udg_BallOwner != null
return GetUnitLoc(udg_BallOwner)
endif
return null
}
function GetBallHeight takes nothing returns real
return GetUnitFlyHeight(udg_Ball)
endfunction
public real GetHeight() {
return GetUnitFlyHeight(udg_Ball)
}
public void SetHeight(real h) {
call SetUnitHeight(Ball, h)
}
public void SetHeightToDefault() {
call Ball_SetHeight(udg_BallDefaultHeight)
}
public void ResetHeight() {
call Ball_SetHeight(udg_BallDefaultHeight)
}
function SetBallHeight takes real h returns nothing
call SetUnitHeight(udg_Ball, h)
endfunction
function RectContainsBall takes rect r returns boolean
return RectContainsUnit(r, udg_Ball)
endfunction
function IsBallInRect takes rect r returns boolean
return IsUnitInRect(udg_Ball, r)
endfunction
function BallInRect takes rect r returns boolean
return IsUnitInRect(udg_Ball, r)
endfunction
public bool IsInRect(rect r) {
return RectContainsUnit(r, udg_Ball)
}
constant function GetBallY takes nothing returns real
return GetUnitY(udg_Ball)
endfunction
constant function GetBallX takes nothing returns real
return GetUnitX(udg_Ball)
endfunction
public constant real GetX() {
return GetUnitX(Ball)
}
public constant real GetY() {
return GetUnitY(Ball)
}
function GetBallH takes nothing returns real
return GetUnitFlyHeight(udg_Ball)
endfunction
public constant real GetSpeed() {
return GetUnitMoveSpeed(udg_Ball)
}
public void SetSpeed(real speed) {
call SetUnitMoveSpeed(Ball, speed)
set udg_CurrentBallSpeed = speed
}
constant function GetBallSpeed takes nothing returns real
return GetUnitMoveSpeed(udg_Ball)
endfunction
public string GetSpeedString() {
return R2S(Ball_GetSpeed())
}
function BallSpeedDown takes real factor returns nothing
set udg_CurrentBallSpeed = RMaxBJ( udg_MinSpeed, udg_CurrentBallSpeed - factor )
call SetUnitMoveSpeed( udg_Ball, udg_CurrentBallSpeed )
endfunction
public void SlowDown(real factor) {
set udg_CurrentBallSpeed = RMaxBJ( udg_MinSpeed, udg_CurrentBallSpeed - factor )
call Ball_SetSpeed( udg_CurrentBallSpeed )
}
function StopBall takes nothing returns nothing
call IssueImmediateOrder( udg_Ball, "stop" )
call BallSpeedDown( INFINITY_REAL )
real coef_stop = CLASSIC_BALL_ANIM_SCALE_STILL
call SetUnitTimeScalePercent( udg_Ball, coef_stop )
set udg_CurrentBallSpeed = 0.0 //
endfunction
public void Stop () {
call StopBall()
}
public void Land() {
call Ball_ResetHeight( )
set udg_BallVZ = 0
set udg_IsBallInAir = false
}
public void Show() {
call ShowUnit(Ball)
}
public void Hide() {
call HideUnit(Ball)
}
public void SwitchModel() {
player p = GetTriggerPlayer()
/*call Ensure( IsAdmin(p) || IsShine(p) )*/
// TODO - turn into mode or can be used by only vlad/morgan
location loc_ball = Ball_GetLoc()
real h_ball = Ball_GetHeight()
real speed_ball = Ball_GetSpeed()
real direction = Ball_GetFacing()
call Ball_Hide()
if Ball == BALL
set Ball = BALL_NEW
set BALL_TYPE = BALL_BRAZUCA
elseif Ball == BALL_NEW
set Ball = BALL
set BALL_TYPE = BALL_CLASSIC
endif
call Ball_Show()
call Ball_SetFacing(direction)
call Ball_SetLoc(loc_ball)
call Ball_SetHeight(h_ball)
call Ball_SetSpeed(speed_ball)
call UnitSetUsesAltIcon( Ball, true )
call RunBallGeneralAnimations()
}
public void SwitchModelTo(integer ball_type) {
if ball_type == BALL_BRAZUCA && BALL_TYPE == BALL_CLASSIC
call Ball_SwitchModel()
elseif ball_type == BALL_CLASSIC && BALL_TYPE == BALL_BRAZUCA
call Ball_SwitchModel()
endif
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=0
#undef Ball
int dummyInt // for compilation
library StdLib requires TextLib, AuxiliaryFuncs, UnitPlayerTeam, Ball
endlibrary
#setdef Ball = udg_Ball
//TESH.scrollpos=-1
//TESH.alwaysfold=0
///////////////////////////////////////////////////////////////
/// The Map Meta Data Library
/// Version: v1.00
/// Last Modified: April 24, 2009
/// Author Chain: Strilanc, [insert next ...]
///////////////////////////////////////////////////////////////
/// This library is used to emit standardized meta data which replay parsers and bot hosts can use to record relevant
/// game statistics like "hero kills" which would otherwise be impossible to record automatically.
///
/// In particular, the flag function can be used to indicate if a leaver should be awarded a win or not. Replays
/// don't contain enough information to easily tell winners who leave from losers who leave. (for example: people
/// who leave while end-game stats are being shown)
///////////////////////////////////////////////////////////////
/// Interface:
/// void FlagPlayer(player, flag_constant)
/// void DefineValue(name, type_constant, goal_constant, suggest_constant)
/// void UpdateValueInt(name, player, operation_constant, value)
/// void UpdateValueReal(name, player, operation_constant, value)
/// void UpdateValueString(name, player, value)
/// void DefineEvent0(name, format)
/// void DefineEvent1(name, format, argName1)
/// void DefineEvent2(name, format, argName1, argName2)
/// void DefineEvent3(name, format, argName1, argName2, argName3)
/// void LogEvent0(name)
/// void LogEvent1(name, arg0)
/// void LogEvent2(name, arg0, arg1)
/// void LogEvent3(name, arg0, arg1, arg2)
/// void LogCustom(unique_identifier, data)
/// void RaiseGuard(reason)
///////////////////////////////////////////////////////////////
/// Notes:
/// - Errors are displayed using BJDebugMsg
/// - Don't try to update a value before defining it
/// - Parsers expect a very specific format, don't screw with the library's output.
/// - If you emit a bunch of data per second, you will cause bandwidth problems for dial-up users. Try to avoid
/// emitting lots of data all at once except at the start and end of games or rounds.
/// - An event's format string uses {#} to represent arguments
/// - Calling RaiseGuard will increase the number of senders for each message from 1 to 3. This increases
/// security but uses more network bandwidth. It is done automatically if tampering is detected.
///////////////////////////////////////////////////////////////
lib_init (MMD, init)
//library MMD initializer init
globals
public constant integer GOAL_NONE = 101
public constant integer GOAL_HIGH = 102
public constant integer GOAL_LOW = 103
public constant integer TYPE_STRING = 101
public constant integer TYPE_REAL = 102
public constant integer TYPE_INT = 103
public constant integer OP_ADD = 101
public constant integer OP_SUB = 102
public constant integer OP_SET = 103
public constant integer SUGGEST_NONE = 101
public constant integer SUGGEST_TRACK = 102
public constant integer SUGGEST_LEADERBOARD = 103
public constant integer FLAG_DRAWER = 101
public constant integer FLAG_LOSER = 102
public constant integer FLAG_WINNER = 103
public constant integer FLAG_LEAVER = 104
public constant integer FLAG_PRACTICING = 105
endglobals
///////////////////////////////////////////////////////////////
/// Private variables and constants
///////////////////////////////////////////////////////////////
globals
private constant boolean SHOW_DEBUG_MESSAGES = true
private constant string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-+= \\!@#$%^&*()/?>.<,;:'\"{}[]|`~"
private constant integer num_chars = StringLength(chars)
private string array flags
private string array goals
private string array ops
private string array types
private string array suggestions
private boolean initialized = false
private gamecache gc = null
private constant string ESCAPED_CHARS = " \\"
private constant integer CURRENT_VERSION = 1
private constant integer MINIMUM_PARSER_VERSION = 1
private constant string FILENAME = "MMD.Dat"
private constant string M_KEY_VAL = "val:"
private constant string M_KEY_CHK = "chk:"
private constant integer NUM_SENDERS_NAIVE = 1
private constant integer NUM_SENDERS_SAFE = 3
private integer num_senders = NUM_SENDERS_NAIVE
private integer num_msg = 0
private timer clock = CreateTimer()
private string array q_msg
private real array q_time
private integer array q_index
private keyword QueueNode
private QueueNode q_head = 0
private QueueNode q_tail = 0
endglobals
///////////////////////////////////////////////////////////////
/// Private functions
///////////////////////////////////////////////////////////////
///Triggered when tampering is detected. Increases the number of safeguards against tampering.
public function RaiseGuard takes string reason returns nothing
debug if SHOW_DEBUG_MESSAGES then
debug call BJDebugMsg("MMD: Guard Raised! (" + reason + ")")
debug endif
set num_senders = NUM_SENDERS_SAFE //increase number of players voting on each message
endfunction
///Returns seconds elapsed in game time
private function time takes nothing returns real
return TimerGetElapsed(clock)
endfunction
///Initializes the char-to-int conversion
private function prepC2I takes nothing returns nothing
local integer i = 0
local string id
loop
exitwhen i >= num_chars
set id = SubString(chars, i, i+1)
if id == StringCase(id, true) then
set id = id + "U"
endif
call StoreInteger(gc, "c2i", id, i)
set i = i + 1
endloop
endfunction
///Converts a character to an integer
private function C2I takes string c returns integer
local integer i
local string id = c
if id == StringCase(id, true) then
set id = id + "U"
endif
set i = GetStoredInteger(gc, "c2i", id)
if (i < 0 or i >= num_chars or SubString(chars, i, i+1) != c) and HaveStoredInteger(gc, "c2i", id) then
//A cheater sent a fake sync to screw with the cached values
set i = 0
loop
exitwhen i >= num_chars //just a weird character
if c == SubString(chars, i, i+1) then //cheating!
call RaiseGuard("c2i poisoned")
call StoreInteger(gc, "c2i", id, i)
exitwhen true
endif
set i = i + 1
endloop
endif
return i
endfunction
///Computes a weak hash value, hopefully secure enough for our purposes
private function poor_hash takes string s, integer seed returns integer
local integer n = StringLength(s)
local integer m = n + seed
local integer i = 0
loop
exitwhen i >= n
set m = m * 41 + C2I(SubString(s, i, i+1))
set i = i + 1
endloop
return m
endfunction
///Stores previously sent messages for tamper detection purposes
private struct QueueNode
readonly real timeout
readonly string msg
readonly integer checksum
readonly string key
public QueueNode next = 0
public static method create takes integer id, string msg returns QueueNode
local QueueNode this = QueueNode.allocate()
set .timeout = time() + 7.0 + GetRandomReal(0, 2+0.1*GetPlayerId(GetLocalPlayer()))
set .msg = msg
set .checksum = poor_hash(.msg, id)
set .key = I2S(id)
return this
endmethod
private method onDestroy takes nothing returns nothing
call FlushStoredInteger(gc, M_KEY_VAL+.key, .msg)
call FlushStoredInteger(gc, M_KEY_CHK+.key, .key)
set .msg = null
set .key = null
set .next = 0
endmethod
public method send takes nothing returns nothing
call StoreInteger(gc, M_KEY_VAL+.key, .msg, .checksum)
call StoreInteger(gc, M_KEY_CHK+.key, .key, .checksum)
call SyncStoredInteger(gc, M_KEY_VAL+.key, .msg)
call SyncStoredInteger(gc, M_KEY_CHK+.key, .key)
endmethod
endstruct
///Returns true for a fixed size uniform random subset of players in the game
private function isEmitter takes nothing returns boolean
local integer i = 0
local integer n = 0
local integer r
local integer array picks
local boolean array pick_flags
loop
exitwhen i >= 12
if GetPlayerController(Player(i)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
if n < num_senders then //initializing picks
set picks[n] = i
set pick_flags[i] = true
else //maintain the invariant 'P(being picked) = c/n'
set r = GetRandomInt(0, n)
if r < num_senders then
set pick_flags[picks[r]] = false
set picks[r] = i
set pick_flags[i] = true
endif
endif
set n = n + 1
endif
set i = i + 1
endloop
return pick_flags[GetPlayerId(GetLocalPlayer())]
endfunction
///Places meta-data in the replay and in network traffic
private function emit takes string message returns nothing
local QueueNode q
if not initialized then
call BJDebugMsg("MMD Emit Error: Library not initialized yet.")
return
endif
//remember sent messages for tamper check
set q = QueueNode.create(num_msg, message)
if q_head == 0 then
set q_head = q
else
set q_tail.next = q
endif
set q_tail = q
//send new message
set num_msg = num_msg + 1
if isEmitter() then
call q.send()
endif
endfunction
///Performs tamper checks
private function tick takes nothing returns nothing
local QueueNode q
local integer i
//check previously sent messages for tampering
set q = q_head
loop
exitwhen q == 0 or q.timeout >= time()
if not HaveStoredInteger(gc, M_KEY_VAL+q.key, q.msg) then
call RaiseGuard("message skipping")
call q.send()
elseif not HaveStoredInteger(gc, M_KEY_CHK+q.key, q.key) then
call RaiseGuard("checksum skipping")
call q.send()
elseif GetStoredInteger(gc, M_KEY_VAL+q.key, q.msg) != q.checksum then
call RaiseGuard("message tampering")
call q.send()
elseif GetStoredInteger(gc, M_KEY_CHK+q.key, q.key) != q.checksum then
call RaiseGuard("checksum tampering")
call q.send()
endif
set q_head = q.next
call q.destroy()
set q = q_head
endloop
if q_head == 0 then
set q_tail = 0
endif
//check for future message tampering
set i = 0
loop
exitwhen not HaveStoredInteger(gc, M_KEY_CHK+I2S(num_msg), I2S(num_msg))
call RaiseGuard("message insertion")
call emit("Blank")
set i = i + 1
exitwhen i >= 10
endloop
endfunction
///Replaces control characters with escape sequences
private function pack takes string value returns string
local integer j
local integer i = 0
local string result = ""
local string c
loop //for each character in argument string
exitwhen i >= StringLength(value)
set c = SubString(value, i, i+1)
set j = 0
loop //for each character in escaped chars string
exitwhen j >= StringLength(ESCAPED_CHARS)
//escape control characters
if c == SubString(ESCAPED_CHARS, j, j+1) then
set c = "\\" + c
exitwhen true
endif
set j = j + 1
endloop
set result = result + c
set i = i + 1
endloop
return result
endfunction
///Updates the value of a defined variable for a given player
private function update_value takes string name, player p, string op, string value, integer val_type returns nothing
local integer id = GetPlayerId(p)
if p == null or id < 0 or id >= 12 then
call BJDebugMsg("MMD Set Error: Invalid player. Must be P1 to P12.")
elseif val_type != GetStoredInteger(gc, "types", name) then
call BJDebugMsg("MMD Set Error: Updated value of undefined variable or used value of incorrect type.")
elseif StringLength(op) == 0 then
call BJDebugMsg("MMD Set Error: Unrecognized operation type.")
elseif StringLength(name) > 50 then
call BJDebugMsg("MMD Set Error: Variable name is too long.")
elseif StringLength(name) == 0 then
call BJDebugMsg("MMD Set Error: Variable name is empty.")
else
call emit("VarP " + I2S(id) + " " + pack(name) + " " + op + " " + value)
endif
endfunction
///Defines an event's arguments and format
private function DefineEvent takes string name, integer num_args, string format, string arg_data returns nothing
if GetStoredInteger(gc, "events", name) != 0 then
call BJDebugMsg("MMD DefEvent Error: Event redefined.")
else
call StoreInteger(gc, "events", name, num_args+1)
call emit("DefEvent " + pack(name) + " " + I2S(num_args) + " " + arg_data + pack(format))
endif
endfunction
///Places an event in the meta-data
private function LogEvent takes string name, integer num_args, string data returns nothing
if GetStoredInteger(gc, "events", name) != num_args+1 then
call BJDebugMsg("MMD LogEvent Error: Event not defined or defined with different # of args.")
else
call emit("Event " + pack(name) + data)
endif
endfunction
///////////////////////////////////////////////////////////////
/// Public functions
///////////////////////////////////////////////////////////////
///Sets a player flag like "win_on_leave"
public function FlagPlayer takes player p, integer flag_type returns nothing
local string flag = flags[flag_type]
local integer id = GetPlayerId(p)
if p == null or id < 0 or id >= 12 then
call BJDebugMsg("MMD Flag Error: Invalid player. Must be P1 to P12.")
elseif StringLength(flag) == 0 then
call BJDebugMsg("MMD Flag Error: Unrecognized flag type.")
elseif GetPlayerController(Player(id)) == MAP_CONTROL_USER then
call emit("FlagP " + I2S(id) + " " + flag)
endif
endfunction
///Defines a variable to store things in
public function DefineValue takes string name, integer value_type, integer goal_type, integer suggestion_type returns nothing
local string goal = goals[goal_type]
local string vtype = types[value_type]
local string stype = suggestions[suggestion_type]
if goal == null then
call BJDebugMsg("MMD Def Error: Unrecognized goal type.")
elseif vtype == null then
call BJDebugMsg("MMD Def Error: Unrecognized value type.")
elseif stype == null then
call BJDebugMsg("Stats Def Error: Unrecognized suggestion type.")
elseif StringLength(name) > 32 then
call BJDebugMsg("MMD Def Error: Variable name is too long.")
elseif StringLength(name) == 0 then
call BJDebugMsg("MMD Def Error: Variable name is empty.")
elseif value_type == TYPE_STRING and goal_type != GOAL_NONE then
call BJDebugMsg("MMD Def Error: Strings must have goal type of none.")
elseif GetStoredInteger(gc, "types", name) != 0 then
call BJDebugMsg("MMD Def Error: Value redefined.")
else
call StoreInteger(gc, "types", name, value_type)
call emit("DefVarP " + pack(name) + " " + vtype + " " + goal + " " + stype)
endif
endfunction
///Updates the value of an integer variable
public function UpdateValueInt takes string name, player p, integer op, integer value returns nothing
call update_value(name, p, ops[op], I2S(value), TYPE_INT)
endfunction
///Updates the value of a real variable
public function UpdateValueReal takes string name, player p, integer op, real value returns nothing
call update_value(name, p, ops[op], R2S(value), TYPE_REAL)
endfunction
///Updates the value of a string variable
public function UpdateValueString takes string name, player p, string value returns nothing
local string q = "\"" // "
call update_value(name, p, ops[OP_SET], q + pack(value) + q, TYPE_STRING)
endfunction
public function DefineEvent0 takes string name, string format returns nothing
call DefineEvent(name, 0, format, "")
endfunction
public function DefineEvent1 takes string name, string format, string argName0 returns nothing
call DefineEvent(name, 1, format, pack(argName0) + " ")
endfunction
public function DefineEvent2 takes string name, string format, string argName0, string argName1 returns nothing
call DefineEvent(name, 2, format, pack(argName0) + " " + pack(argName1) + " ")
endfunction
public function DefineEvent3 takes string name, string format, string argName0, string argName1, string argName2 returns nothing
call DefineEvent(name, 3, format, pack(argName0) + " " + pack(argName1) + " " + pack(argName2) + " ")
endfunction
public function LogEvent0 takes string name returns nothing
call LogEvent(name, 0, "")
endfunction
public function LogEvent1 takes string name, string arg0 returns nothing
call LogEvent(name, 1, " " + pack(arg0))
endfunction
public function LogEvent2 takes string name, string arg0, string arg1 returns nothing
call LogEvent(name, 2, " " + pack(arg0) + " " + pack(arg1))
endfunction
public function LogEvent3 takes string name, string arg0, string arg1, string arg2 returns nothing
call LogEvent(name, 3, " " + pack(arg0) + " " + pack(arg1) + " " + pack(arg2))
endfunction
///Emits meta-data which parsers will ignore unless they are customized to understand it
public function LogCustom takes string unique_identifier, string data returns nothing
call emit("custom " + pack(unique_identifier) + " " + pack(data))
endfunction
///////////////////////////////////////////////////////////////
/// Initialization
///////////////////////////////////////////////////////////////
///Emits initialization data
private function init2 takes nothing returns nothing
local integer i
local trigger t
set initialized = true
call emit("init version " + I2S(MINIMUM_PARSER_VERSION) + " " + I2S(CURRENT_VERSION))
set i = 0
loop
exitwhen i >= 12
if GetPlayerController(Player(i)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call emit("init pid " + I2S(i) + " " + pack(GetPlayerName(Player(i))))
endif
set i = i + 1
endloop
set t = CreateTrigger()
call TriggerAddAction(t, function tick)
call TriggerRegisterTimerEvent(t, 0.37, true)
endfunction
///Places init2 on a timer, initializes game cache, and translates constants
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0, false)
call TriggerAddAction(t, function init2)
set goals[GOAL_NONE] = "none"
set goals[GOAL_HIGH] = "high"
set goals[GOAL_LOW] = "low"
set types[TYPE_INT] = "int"
set types[TYPE_REAL] = "real"
set types[TYPE_STRING] = "string"
set suggestions[SUGGEST_NONE] = "none"
set suggestions[SUGGEST_TRACK] = "track"
set suggestions[SUGGEST_LEADERBOARD] = "leaderboard"
set ops[OP_ADD] = "+="
set ops[OP_SUB] = "-="
set ops[OP_SET] = "="
set flags[FLAG_DRAWER] = "drawer"
set flags[FLAG_LOSER] = "loser"
set flags[FLAG_WINNER] = "winner"
set flags[FLAG_LEAVER] = "leaver"
set flags[FLAG_PRACTICING] = "practicing"
call FlushGameCache(InitGameCache(FILENAME))
set gc = InitGameCache(FILENAME)
call TimerStart(clock, 999999999, false, null)
call prepC2I()
endfunction
endlib
//endlibrary
//TESH.scrollpos=-1
//TESH.alwaysfold=0
lib( NewLib, StdLib )
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib( Test, StdLib )
globals
timer Timer01 = CreateTimer()
endglobals
void AnimationTestingStuff() {
/*
string CurrentAnimation = null
string GetNextAnim() {
string curAnim = CurrentAnimation
if IsInSet(curAnim, null, "three")
set curAnim = "one"
elseif curAnim == "one"
set curAnim = "two"
elseif curAnim == "two"
set curAnim = "three"
endif
set CurrentAnimation = curAnim
return curAnim
}
void SetNextAnim() {
string nextAnim = GetNextAnim()
//call SetUnitAnimation(gg_unit_/h002_0008, nextAnim)
//call SetUnitAnimation(gg_unit_h002_0022, nextAnim)
//call SetDoodadAnimationRectBJ( "three", 'D00D', GetPlayableMapRect() )
//string anim = GetRandomAnim() // "three"
}
*/
}
public void Init() {
if (morganxl != null ) && InTesting // && (not IsReleaseVersion)
{
unit u = udg_Hero[cPid(morganxl)]
call UnitAddAbility(u, ABILITY_TELEPORT)
call UnitAddAbility(u, ABILITY_FETCH_BALL)
}
//for (int i = 0; i < 16; i++) { echo(I2S(i))}
//forp (int i = 0; i < 16; i++) {echo(I2S(i))}
//for (unit u1; GetUnitsInRangeOfLocAll(1000, some_loc)){ echo("hi") }
call Ensure( InTesting )
//call ChangePlayersTeam(morganxl,2)
//printf("%i %i", CECH, CASILLAS)
// call SetUnitAnimation(null,null) // works
//tstmsg(here)
if AddMorganToDbg then
ForceAddPlayer( Debuggers, morganxl )
endif
/*call AddAbilityToAll(ABILITY_FETCH_BALL)
call AddAbilityToAll(ABILITY_TELEPORT)*/
call TriggerExecute(gg_trg_Various_testing)
/*call PlayerExchangeAbils(morganxl, ABILITY_LONG_PASS, 'A00E')
wait(5)
call PlayerExchangeAbils(morganxl, 'A00E', ABILITY_LONG_PASS)*/
}
define { /*memory leaks stress testing*/
LocsMillion = {
LocsThousand
LocsThousand
LocsThousand
LocsThousand
LocsThousand
}
LocsThousand = {
HundredLocs
HundredLocs
HundredLocs
HundredLocs
HundredLocs
HundredLocs
HundredLocs
}
HundredLocs = {
TenLocs
TenLocs
TenLocs
TenLocs
TenLocs
TenLocs
}
TenLocs = {
Ball_GetLoc()
Ball_GetLoc()
Ball_GetLoc()
Ball_GetLoc()
Ball_GetLoc()
Ball_GetLoc()
}
}
// testing
void Timer_05_Testing() {
call Ensure(InTesting)
//call SetNextAnim()
}
void Timer_01_Testing() {
call Ensure(InTesting)
// Testing code
/*
if KeeperTimer != null
call UnitMove(TempUnit, GetPitchCenter())
endif
*/
/*
if RectContainsUnit(TestRect, udg_Ball) && false
TestMsg("Inside the rect! x="+R2S(GetUnitX(udg_Ball))+", y="+R2S(GetUnitY(udg_Ball)))
endif
*/
/*
real time_elapsed = TimerGetElapsed(LastShotTimer)
if LastShotLoc != null && time_elapsed < 0.120 // && time_elapsed != 0
//call TestMsg(R2S(time_elapsed))
endif
time_elapsed = TimerGetElapsed(Timer01)
if time_elapsed < 0.099 or time_elapsed > 0.101
//call TestMsg(R2S(time_elapsed))
endif
call DestroyTimer(Timer01)
set Timer01 = CreateTimerBJ(false, 1)
*/
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function TestingStuff takes nothing returns nothing
call Ensure(InTesting)
call PolledWait(1)
call Banners()
//string s = "EXTRA TIME: 00:40"
//call echo(morganxl,5,5,s)
/*
texttag t = CreateTextTagUnitBJ( "hi!!!", udg_Ball, 0, 10, 0, 100, 0, 0 )
call SetTextTagVelocityBJ(t, 50, 90)
call SetTextTagLifespanBJ(t, 5)
*/
//call FlashEffect(udg_Ball, "origin")
/*
// peas = 0; peons = 1
if morganxl != null
echo("team = "+I2S(GetPlayerTeam(morganxl)))
endif
*/
/*
string input = "hi"
echo(input)
string topic = SubStringBJ(input, 7, 9)
echo( )
echo(topic)
echo( )
echo("check")
*/
/*
// 1 2 3
string str
set str = ""
echo(str)
echo("1")
set str = null
echo("2")
echo(str)
echo("3")
string str2
echo(str2)
echo("4")
*/
/*
// 1 3 4 5 6
if "" == ""
echo("1")
endif
if "" == null
echo("2")
endif
if null == null
echo("3")
endif
echo(" ")
echo("4")
echo("")
echo("5")
echo(null)
echo("6")
*/
//call echo(R2S(GetUnitFlyHeight(udg_Keeper[1])))
//int pid = GetConvertedPlayerId(morganxl)
//call SetUnitTimeScale(udg_Hero[pid], 0.50)
//questitem qi = QuestCreateItem(GetLastCreatedQuestBJ())
//QuestItemSetDescription(qi, "Description for quest item.")
//integer pid = GetConvertedPlayerId(morganxl)
//location loc_ball = GetUnitLoc(udg_Ball)
//PlayerLongPass(morganxl, GetUnitLoc(udg_Flag))
//call IssuePointOrderLoc( udg_Hero[1], "impale", GetUnitLoc(udg_Ball) )
//call PlayerKick(morganxl, GetUnitLoc(udg_Ball))
call Sleep(3)
//call TriggerExecute(gg_trg_Draw)
//call PlayerJump(morganxl)
//call BJDebugMsg("Round Timer: "+R2S(TimerGetRemaining(udg_RoundTimer)))
//BJDebugMsg(R2S(GetUnitDefaultMoveSpeed(udg_Hero[1])))
//BJDebugMsg(R2S(GetUnitDefaultFlyHeight(udg_Ball)))
//TestMsg ("neutral name = "+GetPlayerName(GetOwningPlayer(udg_Keeper[1])))
//if "" != "hi"
// BJDebugMsg("no string makes sense")
//endif
//string str_test = ""
//str_test += "hi"
//BJDebugMsg(str_test)
//call BJDebugMsg(R2SW(123.456, 4, 1) + " 4,1")
//call BJDebugMsg(R2SW(123.456, 5, 1) + " 5,1")
//call BJDebugMsg(R2SW(123.456, 6, 1) + " 6,1")
//call BJDebugMsg(R2SW(123.456, 7, 4) + " 7,4")
//call BJDebugMsg(R2SW(123.456, 6, 4) + " 6,4")
//call BJDebugMsg(R2SW(123.456, 6, 0) + " 6,0")
//call BJDebugMsg(R2SW(123.456, 5, 0) + " 5,0")
//call BJDebugMsg(R2SW(123.678, 4, 0) + " 4,0")
//call BJDebugMsg(R2SW(123.678, 3, 0) + " 3,0")
//call BJDebugMsg(R2SW(123.678, 2, 0) + " 2,0")
//call BJDebugMsg("null id = "+I2S(GetConvertedPlayerId(GetOwningPlayer(udg_LastOwner))))
//call DebugMsg(R2S(DistanceBetweenPoints(GetRectCenter(gg_rct_Center), GetRectCenter(gg_rct_LeftKeeperArea))))
//call DisplayTextToAll("|c00ffff00Default ball height|r = "+R2S(udg_BallDefaultHeight))
endfunction
//===========================================================================
function InitTrig_Various_testing takes nothing returns nothing
set gg_trg_Various_testing = CreateTrigger( )
call TriggerAddAction( gg_trg_Various_testing, function TestingStuff )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Get_Teleport_and_FB_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
if (morganxl != null) && (p == morganxl)
unit u = GetHero(p)
call UnitAddAbility(u, ABILITY_TELEPORT)
call UnitAddAbility(u, ABILITY_FETCH_BALL)
endif
endfunction
//===========================================================================
function InitTrig_Get_Teleport_and_FB takes nothing returns nothing
set gg_trg_Get_Teleport_and_FB = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Get_Teleport_and_FB, "-hax", true )
call TriggerAddAction( gg_trg_Get_Teleport_and_FB, function Trig_Get_Teleport_and_FB_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
force Debuggers = CreateForce()
force Testers = CreateForce()
function Trig_Debug_Mode_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
if IsPlayerInForce( p, Debuggers ) then
call ForceRemovePlayer( Debuggers, p )
call DisplayTextToPlayer( p, 0, 0, "Debug mode off.")
else
call ForceAddPlayer( Debuggers, p )
call DisplayTextToPlayer( p, 0, 0, "Debug mode on.")
endif
endfunction
//===========================================================================
function InitTrig_Debug_Mode takes nothing returns nothing
set gg_trg_Debug_Mode = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Debug_Mode, "-debug", true )
call TriggerAddAction( gg_trg_Debug_Mode, function Trig_Debug_Mode_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_hide_keeper_Actions takes nothing returns nothing
call Ensure(InTesting || InTraining || IsUserMorgan())
declare string
string specifier = SubStringBJ(input, strlen, strlen)
int whichKeeper = S2I(specifier)
//unit keeper = udg_keeper[whichKeeper]
DebugMsg(specifier)
DebugMsg("Mode = "+I2S(whichKeeper))
player p = GetTriggerPlayer()
bool correctSyntax = IsInSet(whichKeeper, 0,1,2,3) && strlen >= patlen + 2// && isNumber(specifier)
if not correctSyntax
echo(p, "Usage: -hide 1 to disable first keeper, -hide 3 to disable both keepers, -hide 0 to enable both keepers.")
return
endif
if IsInSet(whichKeeper, 1,2)
if udg_Keeper[whichKeeper] == null
if whichKeeper == 1
echo(p, "Enabling peasants' keeper.")
set udg_Keeper[whichKeeper] = KEEPER_ONE
else
echo(p, "Enabling peons' keeper.")
set udg_Keeper[whichKeeper] = KEEPER_TWO
endif
else
echo(p, "Disabling keeper "+I2S(whichKeeper)+".")
set udg_Keeper[whichKeeper] = null
endif
elseif whichKeeper == 3
echo(p, "Disabling both keepers.")
set udg_Keeper[1] = null
set udg_Keeper[2] = null
elseif whichKeeper == 0
echo(p, "Enabling both keepers.")
set udg_Keeper[1] = KEEPER_ONE
set udg_Keeper[2] = KEEPER_TWO
endif
endfunction
//===========================================================================
function InitTrig_hide_keeper takes nothing returns nothing
set gg_trg_hide_keeper = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_hide_keeper, "-hide", false )
call TriggerAddAction( gg_trg_hide_keeper, function Trig_hide_keeper_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Throwin_Mode_Actions takes nothing returns nothing
call Ensure(InTesting || InTraining || IsUserMorgan())
string input = GetEventPlayerChatString()
string pattern = GetEventPlayerChatStringMatched()
integer strlen = StringLength(input)
integer patlen = StringLength(pattern)
string modestr = SubStringBJ(input, strlen, strlen)
integer mode = S2I(modestr)
bool correctSyntax = (strlen >= patlen + 2) && (mode >= 0 && mode <= 2)
if not correctSyntax
player p = GetTriggerPlayer()
echo(p, "Usage: -tm 1 to give team 1 exclusive ball control, -tm 0 for default control.")
return
endif
set udg_ThrowinMode = mode
if mode == 0
set udg_CantEnterOtherSide = false
else
set udg_ThrowinLoc = Ball_GetLoc()
endif
endfunction
//===========================================================================
function InitTrig_Throwin_Mode takes nothing returns nothing
set gg_trg_Throwin_Mode = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent(gg_trg_Throwin_Mode, "-tm" ,false)
call TriggerAddAction( gg_trg_Throwin_Mode, function Trig_Throwin_Mode_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Show_MI_Actions takes nothing returns nothing
call Ensure(InTesting || InTraining || IsUserMorgan())
string str_mode = ""
integer mode = 0
string chat_str = GetEventPlayerChatString()
integer str_len = StringLength(chat_str)
if str_len > 4
str_mode = SubStringBJ(chat_str, str_len, str_len)
mode = S2I(str_mode)
StepByStepDisplay = mode
endif
if IsMultiboardDisplayed(StatsMB)
call MultiboardClear(StatsMB)
call DestroyMultiboard(StatsMB)
call MaskFadeIn(1)
call Scoreboard_Create()
call Scoreboard_Refresh()
else
call TriggerExecute(gg_trg_Display_Stats)
endif
endfunction
//===========================================================================
function InitTrig_Show_Stats takes nothing returns nothing
set gg_trg_Show_Stats = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Show_Stats,"-ms", false )
call TriggerAddAction( gg_trg_Show_Stats, function Trig_Show_MI_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Stop_ball_Actions takes nothing returns nothing
call Ensure(InTesting || InTraining || IsUserMorgan())
call Ball_Stop()
endfunction
//===========================================================================
function InitTrig_Stop_ball takes nothing returns nothing
set gg_trg_Stop_ball = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Stop_ball, "-stop", true )
call TriggerAddAction( gg_trg_Stop_ball, function Trig_Stop_ball_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
force fShowMeTestMsgs = CreateForce()
function Trig_show_hide_test_msg_SHOW takes nothing returns nothing
player p = GetTriggerPlayer()
call ForceAddPlayer(fShowMeTestMsgs, p)
echo(p,"Enabled testing messages.")
endfunction
function Trig_show_hide_test_msg_HIDE takes nothing returns nothing
player p = GetTriggerPlayer()
call ForceRemovePlayer(fShowMeTestMsgs, p)
echo(p,"Disabled testing messages.")
endfunction
//===========================================================================
function InitTrig_show_hide_test_msg takes nothing returns nothing
set gg_trg_show_hide_test_msg = CreateTrigger( )
trigger trg1 = CreateTrigger()
trigger trg2 = CreateTrigger()
call TriggerRegisterAnyPlayerChatEvent( trg1, "-show", true )
call TriggerRegisterAnyPlayerChatEvent( trg2, "-noshow", true )
call TriggerRegisterAnyPlayerChatEvent( trg2, "-hide", true )
call TriggerAddAction( trg1, function Trig_show_hide_test_msg_SHOW )
call TriggerAddAction( trg2, function Trig_show_hide_test_msg_HIDE )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_keeper_reached_loc_Actions takes nothing returns nothing
call Ensure(GetEnteringUnit() == TempUnit)
call Ensure (InTesting)
call sBJDebugMsg("Time elapsed: %r", TimerGetElapsed(KeeperTimer))
endfunction
//===========================================================================
function InitTrig_keeper_reached_loc takes nothing returns nothing
set gg_trg_keeper_reached_loc = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_keeper_reached_loc, gg_rct_Center )
call TriggerAddAction( gg_trg_keeper_reached_loc, function Trig_keeper_reached_loc_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
timer KeeperTimer = null
function Trig_go_keepers_Actions takes nothing returns nothing
call Ensure(InTesting)
set TempUnit = udg_Keeper[1]
set udg_Keeper[1] = null
call SetUnitPositionLoc(TempUnit, GetRectCenter(udg_KeeperArea[1]))
location loc_final = GetPitchCenter()
call UnitMove(TempUnit, loc_final)
set KeeperTimer = CreateTimerBJ(false, 100)
endfunction
//===========================================================================
function InitTrig_go_keepers takes nothing returns nothing
set gg_trg_go_keepers = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_go_keepers, "-go", true )
call TriggerAddAction( gg_trg_go_keepers, function Trig_go_keepers_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
rect TestRect = null
function Trig_ball2_testing_Actions takes nothing returns nothing
call Ensure (GetEnteringUnit() == udg_Ball)
location loc_ball = GetUnitLoc(udg_Ball)
string x_max = I2S(R2I(GetRectMaxX(TestRect)))
string y_max = I2S(R2I(GetRectMaxY(TestRect)))
string x_min = I2S(R2I(GetRectMinX(TestRect)))
string y_min = I2S(R2I(GetRectMinY(TestRect)))
call TestMsg("ball entered, X: "+x_min+" < "+x_max+", Y: "+y_min+" < "+y_max)
call TestMsg("x = "+R2S(GetUnitX(udg_Ball))+"Y = "+R2S(GetUnitY(udg_Ball)))
if RectContainsUnit(TestRect, udg_Ball)
TestMsg("And the rect contains the unit!")
endif
endfunction
//===========================================================================
function InitTrig_ball_move_in_rect takes nothing returns nothing
set gg_trg_ball_move_in_rect = CreateTrigger( )
call TriggerAddAction( gg_trg_ball_move_in_rect, function Trig_ball2_testing_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
bool Interval_001_Execution = false
bool BallHeight005Update = false
function Trig_Timer_Interval_001_Actions takes nothing returns nothing
call ConditionalTriggerExecute(gg_trg_Check_Linecross)
call ConditionalTriggerExecute(gg_trg_Smooth_Ball)
//call Curve_DisplayOwnCurveAngleToPlayersIfAny()
if ContinuousBallUpdate && (TimerGetElapsed(BallOwnerTimer) > 0.12) && (udg_BallOwner != null)
call PlaceBallInFrontOfBallOwner()
endif
real time01 = TimerGetElapsed(Timer_01)
real shot_time = TimerGetElapsed(LastShotTimer)
real h_ball = Ball_GetHeight()
// if 0.05 seconds passed since timer interval 01 execution
if PartialSmooth && (time01 > 0.045) && (time01 < 0.055) && (shot_time > 1.0) && (h_ball > 100)
// update ball height
call Ball_SetHeight( h_ball + 0.5*udg_BallVZ )
set BallHeight005Update = true
endif
set Interval_001_Execution = true
call TriggerExecute(gg_trg_Set_Ball_Owner)
set Interval_001_Execution = false
endfunction
//===========================================================================
function InitTrig_Timer_Interval_001 takes nothing returns nothing
set gg_trg_Timer_Interval_001 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Timer_Interval_001, 0.01 )
call TriggerAddAction( gg_trg_Timer_Interval_001, function Trig_Timer_Interval_001_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Timer_Interval_003_Actions takes nothing returns nothing
//call Curve_DisplayOwnCurveAngleToPlayersIfAny()
//call Curve_AdjustTextTagLocations()
endfunction
//===========================================================================
function InitTrig_Timer_Interval_003 takes nothing returns nothing
set gg_trg_Timer_Interval_003 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Timer_Interval_003, 0.03 )
call TriggerAddAction( gg_trg_Timer_Interval_003, function Trig_Timer_Interval_003_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Timer_Interval_005_Actions takes nothing returns nothing
//call Curve_DisplayOwnCurveAngleToPlayersIfAny()
call Timer_Interval_SmartCameraActions()
endfunction
//===========================================================================
function InitTrig_Timer_Interval_005 takes nothing returns nothing
set gg_trg_Timer_Interval_005 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Timer_Interval_005, 0.05 )
call TriggerAddAction( gg_trg_Timer_Interval_005, function Trig_Timer_Interval_005_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
timer Timer_01 = CreateTimer()
function Trig_Timer_Interval_01_UpdateCurveBallTimer takes nothing returns nothing
int i=1
loop
if udg_CurveBallFactor[i] > 0
set udg_CurveBallFactor[i] -= 0.05
elseif udg_CurveBallFactor[i] < 0
set udg_CurveBallFactor[i] += 0.05
endif
i++
exitwhen (i>15)
endloop
endfunction
function Trig_Timer_Interval_01_UpdateTimer01 takes nothing returns nothing
call PauseTimer(Timer_01)
call DestroyTimer(Timer_01)
set Timer_01 = null
set Timer_01 = CreateTimerBJ( false, INFINITY_TIME )
endfunction
function Trig_Timer_Interval_01_CloseShotAI takes nothing returns nothing
//bot ai: close X shot
/*conditionfunc cond = Condition(function AI_IsFilterPlayerBot)
force bots = GetPlayersMatching(cond)
call ForForce(bots, function AI_ShootToScore)*/
endfunction
function Trig_Timer_Interval_01_CurvedBallActions takes nothing returns nothing
real time = TimerGetElapsed(LastShotTimer)
integer lam = LastActionMade
real increment = CurveBallFactor
real speed_factor = Ball_GetSpeed()/522.
real sign_factor = (-1) // in game left curve is actually + (adding angle)
if CurvedBall && (time > 0.18) && (time < 1.68) && (lam == ACTION_LONG_PASS || (lam == ACTION_VZ && CurvedVZ) ) //&& udg_IsBallInAir
//call SetUnitFacing(Ball, GetUnitFacing(Ball)+1)
if time < 0.68 || time > 1.18
set udg_BallDirection += 0.5*increment*speed_factor*sign_factor
else
set udg_BallDirection += 1.0*increment*speed_factor*sign_factor
endif
endif
endfunction
function Trig_Timer_Interval_01_Actions takes nothing returns nothing
call Trig_Timer_Interval_01_UpdateTimer01()
call Trig_Timer_Interval_01_UpdateCurveBallTimer()
//call Curve_DisplayOwnCurveAngleToPlayersIfAny()
call ConditionalTriggerExecute( gg_trg_Ball_Possession )
call TriggerExecute( gg_trg_Ball_Timer_Action )
call TriggerExecute( gg_trg_Fix_Keeper_Position )
call TriggerExecute( gg_trg_MoveSpeed_of_Players )
call TriggerExecute( gg_trg_Sliding_and_jump )
call ManualHeaderLib_UpdateTimers()
call Trig_Timer_Interval_01_CurvedBallActions()
Ensure(not udg_MapReset)
call Camera_Update()
call TriggerExecute( gg_trg_Cant_Enter_Other_Side )
call Timer_01_Testing()
if IsTriggerEnabled( gg_trg_Computer_AI )
call TriggerExecuteIfEnabled( gg_trg_Heading_Action_AI )
endif
endfunction
//===========================================================================
function InitTrig_Timer_Interval_01 takes nothing returns nothing
set gg_trg_Timer_Interval_01 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Timer_Interval_01, 0.10 )
call TriggerAddAction( gg_trg_Timer_Interval_01, function Trig_Timer_Interval_01_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Timer_Interval_025_Actions takes nothing returns nothing
if KeeperAI >= KEEPER_AI_IMPROVED
call KeeperLib_MoveKeepers()
endif
endfunction
//===========================================================================
function InitTrig_Timer_Interval_025 takes nothing returns nothing
set gg_trg_Timer_Interval_025 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Timer_Interval_025, 0.25 )
call TriggerAddAction( gg_trg_Timer_Interval_025, function Trig_Timer_Interval_025_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Timer_Interval_05_Actions takes nothing returns nothing
if KeeperAI == KEEPER_AI_CLASSIC
call KeeperLib_MoveKeepers()
endif
call TriggerExecute( gg_trg_Move_Referee )
call TriggerExecute( gg_trg_Keeper_Actions )
call TriggerExecute( gg_trg_Move_Linesmen )
call TriggerExecuteIfEnabled( gg_trg_Computer_AI )
call TriggerExecute( gg_trg_Update_Timer )
call ConditionalTriggerExecute( gg_trg_Keeper_Speed )
call TriggerExecute( gg_trg_Ball_height_exclamation )
set udg_IgnoreAItimer = IMaxBJ(0, udg_IgnoreAItimer - 1 )
set udg_ThrowInWaitTimer = IMaxBJ(0, udg_ThrowInWaitTimer - 1 )
call Timer_05_Testing()
endfunction
//===========================================================================
function InitTrig_Timer_Interval_05 takes nothing returns nothing
set gg_trg_Timer_Interval_05 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Timer_Interval_05, 0.5 )
call TriggerAddAction( gg_trg_Timer_Interval_05, function Trig_Timer_Interval_05_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Ball_Timer_Action_DecreaseCantHoldBallTimerMain takes nothing returns nothing
int pid = GetConvertedPlayerId(GetEnumPlayer())
if udg_CantHoldBall[pid] > 0
Dec(udg_CantHoldBall[pid])
endif
endfunction
function Trig_Ball_Timer_Action_DecreaseCantHoldBallTimerActions takes nothing returns nothing
local conditionfunc cond = Condition(function FilterPlayerStatePlaying)
local force f = GetPlayersMatching(cond)
call ForForce( f, function Trig_Ball_Timer_Action_DecreaseCantHoldBallTimerMain )
call RemoveCond(cond)
call RemoveForce(f)
endfunction
function Trig_Ball_Timer_Action_Actions takes nothing returns nothing
if ( udg_ThrowinMode != 0 ) then
call RemoveEnemyUnitsFromRangeOfBall()
endif
call ConditionalTriggerExecute( gg_trg_Cant_move_in_throwins )
// ping was here
call Trig_Ball_Timer_Action_DecreaseCantHoldBallTimerActions()
if ( udg_BallOwner == null ) then
call TriggerExecute( gg_trg_General_Animations )
if ( udg_IsBallInAir ) then
call TriggerExecute( gg_trg_Vertical_Animations )
call TriggerExecute( gg_trg_Move_Flag_To_Certain_Point )
else
call BallSpeedDown(GROUND_FRICTION_FACTOR)
endif
else
call PlaceBallInFrontOfBallOwner()
endif
call Ensure(not udg_MapReset)
call PSLib_BallTimerActions()
// check linecross was here
call TriggerExecute( gg_trg_Set_Ball_Owner )
call DecIfPositive(BallImmuneTimer)
endfunction
//===========================================================================
function InitTrig_Ball_Timer_Action takes nothing returns nothing
set gg_trg_Ball_Timer_Action = CreateTrigger( )
call TriggerAddAction( gg_trg_Ball_Timer_Action, function Trig_Ball_Timer_Action_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Set_Ball_Owner_SlideAffectConditions takes nothing returns boolean
int pid_BallOwner = GetConvertedPlayerId(GetOwningPlayer(udg_BallOwner))
bool b1 = not udg_HeroInAir[pid_BallOwner]
bool b2 = IsUnitInGroup(GetEnumUnit(), udg_SlidingUnits)
bool b3 = udg_ThrowinMode == 0
return b1 and b2 and b3
endfunction
function Trig_Set_Ball_Owner_CanUnitHeadBall takes nothing returns boolean
unit u = GetEnumUnit()
int pid = GetExtendedId(u)
bool b1 = udg_HeroInAir[pid]
bool b21 = IsPlayerBot(GetOwningPlayer(u))
bool b22 = udg_HeroVY[pid] >= 0 //
bool b2 = b21 or b22
/*
// unit u = GetEnumUnit()
int team = GetUnitTeamSimple(u)
bool b3 = not IsUnitInRect(u, udg_PenaltyArea[team])
*/
return b1 && b2 // && b3
endfunction
function Trig_Set_Ball_Owner_EnemyAllyPreference takes nothing returns boolean
bool b1 = IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(BallOwner))
bool b21 = udg_ThrowinMode != 0
bool b22 = GetPlayerController(GetOwningPlayer(GetEnumUnit())) == MAP_CONTROL_USER // friendly bot won't steal in throwins
bool b2 = b21 and b22
return b1 or b2
endfunction
function Trig_Set_Ball_Owner_CanUnitGetBall takes nothing returns boolean
unit u = GetEnumUnit()
int pid = GetExtendedId(u)
bool b1 = not IsUnitType(u, UNIT_TYPE_STUNNED)
bool b2 = udg_BallImmuneTimer <= 0
bool b3 = udg_CantHoldBall[pid] <= 0
bool b4 = u != udg_BallOwner
real ball_h = GetBallHeight()
real unit_h = GetUnitFlyHeight(u)
real base_h = IntegerTertiaryOp(IsKeeper(u), 120, R2I(udg_HeroHeight))
bool b5 = ball_h >= unit_h
bool b6 = ball_h <= unit_h + base_h
bool b7 = Trig_Set_Ball_Owner_EnemyAllyPreference()
return b1 and b2 and b3 and b4 and b5 and b6 and b7
endfunction
function Trig_Set_Ball_Owner_Main takes nothing returns nothing
unit u = GetEnumUnit()
int pid = GetExtendedId(u)
set udg_TempDirection = AngleBetweenUnits( u, udg_Ball )
call ResetTempDirection()
call Ensure( Trig_Set_Ball_Owner_CanUnitGetBall() )
if ( Trig_Set_Ball_Owner_CanUnitHeadBall() ) then
if ( BallOwner == null ) then
call TriggerExecute( gg_trg_Do_Heading_Action )
endif
else
call HideUnit( udg_Flag )
if ( udg_HeroVX[pid] > 0 ) then
if ( Trig_Set_Ball_Owner_SlideAffectConditions() ) then
call TriggerExecute( gg_trg_Sliding )
endif
elseif ( udg_HeroSlidingWait[pid] <= 0 ) && (not IsKeeper(u)) && not Interval_001_Execution
call TriggerExecute( gg_trg_Get_Ball )
endif
endif
endfunction
function Trig_Set_Ball_Owner_Actions takes nothing returns nothing
location loc_ball = GetUnitLoc(udg_Ball)
conditionfunc cond = Condition(function IsFilterUnitHeroOrKeeper) // OrKeeper
group g = GetUnitsInRangeOfLocMatching(100, loc_ball, cond)
call ForGroup( g, function Trig_Set_Ball_Owner_Main )
call DestroyGroup(g)
call RemoveLocation(loc_ball)
call DestroyCondition(cond)
endfunction
//===========================================================================
function InitTrig_Set_Ball_Owner takes nothing returns nothing
set gg_trg_Set_Ball_Owner = CreateTrigger( )
call TriggerAddAction( gg_trg_Set_Ball_Owner, function Trig_Set_Ball_Owner_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
timer BallOwnerTimer = CreateTimer()
function Trig_Get_Ball_Actions takes nothing returns nothing
int pid
if ShowTimeSinceLastShot && InTesting then
TestMsg(R2S( GetBallH() ))
TestMsg(R2S(TimerGetElapsed(LastShotTimer))+ " - Time since last shot.")
endif
if ( udg_ThrowinMode == 0 ) then
udg_IndirectFreeKick = false
else // game stopped due to linecross
if ( udg_BallOwner == null ) then
udg_ThrowInWaitTimer = 4
endif
//call SetUnitPositionLocFacingLocBJ
//( GetEnumUnit(), udg_ThrowinLoc, loc_center )
endif
if ( udg_BallOwner != null ) then
player p = GetOwningPlayer(udg_BallOwner)
echo( p, "TRIGSTR_298" )
set pid = GetConvertedPlayerId(p)
set udg_CantHoldBall[pid] = 15
endif
// successful dribble!
if (not BallHitGroundAfterX) && (LastActionMade == ACTION_KICK) && (GetEnumUnit() == LK) // same player
unit u = GetEnumUnit()
set pid = cPid(GetOwningPlayer(GetEnumUnit()))
//create texttag
/*real R = udg_PlayerColorR[pid]
real G = udg_PlayerColorG[pid]
real B = udg_PlayerColorB[pid]
real h = GetUnitFlyHeight(u)
location loc_unit = GetUnitLoc(u)
texttag t = CreateExclamatoryTextTag("+1 dribble",loc_unit, h+200, 100,100,100) //0,100,0)
call ShowTextTagForceBJ(false, t, GetPlayersAll())
call ShowTextTagForceBJ(true, t, fShowMeTestMsgs)*/
// increment dribble counter
set udg_nSuccDribbles[pid] += 1
PlayerIncInt(pid, "dribbles_succ")
PlayerUpdateMaxInt(pid, "dribbles_succ", UPDATE_MAX_VAL)
endif
set udg_BallOwner = GetEnumUnit()
echo( GetOwningPlayer(udg_BallOwner), "TRIGSTR_295" )
call PassSuccessUpdate(PS_EVENT_PLAYER_GET_BALL)
call UpdateLK()
call PauseTimer(BallOwnerTimer)
call DestroyTimer(BallOwnerTimer)
set BallOwnerTimer = CreateTimer()
call StartTimerBJ(BallOwnerTimer, false, INFINITY_TIME)
set LastActionMade = 0
set BallHitGroundAfterX = false
set udg_IgnoreAItimer = 0
set udg_PassTarget = null
call BallSpeedDown(INFINITY_REAL)
call SetAcquiredBallScale()
endfunction
//===========================================================================
function InitTrig_Get_Ball takes nothing returns nothing
set gg_trg_Get_Ball = CreateTrigger( )
call TriggerAddAction( gg_trg_Get_Ball, function Trig_Get_Ball_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Sliding_Actions takes nothing returns nothing
unit slider = GetEnumUnit()
int pid_slider = GetConvertedPlayerId(GetOwningPlayer(slider))
if ( udg_ThrowinMode == 0 ) then
set udg_IndirectFreeKick = false
endif
call GroupRemoveUnit( udg_SlidingUnits, slider )
set udg_BallImmuneTimer = 5
call PlaySoundOnUnit(gg_snd_Kick, udg_Ball)
// EnumUnit as the sliding unit - actions
if ( slider != udg_BallOwner ) and ( udg_BallOwner != null ) then
int pid_owner = GetConvertedPlayerId(GetOwningPlayer(udg_BallOwner))
set udg_HeroSlidingWait[pid_owner] = 10
PlayerIncInt(pid_slider, "tackles")
PlayerUpdateMaxInt(pid_slider, "tackles", UPDATE_MAX_VAL)
DebugMsg(udg_PlayerNames[pid_slider] +": +1 tackle")
endif
//
set udg_BallOwner = null
call PassSuccessUpdate(PS_EVENT_PLAYER_SLIDE_BALL)
call UpdateLK()
set LastActionMade = ACTION_SLIDE
set udg_PassTarget = null
call SetUnitTimeScalePercent( udg_Ball, 100 )
PlayerIncInt(pid_slider, "slides_succ")
PlayerUpdateMaxInt(pid_slider, "slides_succ", UPDATE_MAX_VAL)
set udg_BallDirection = udg_SlidingDirection[pid_slider]
set udg_TempReal = 40
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
if ( udg_BallOwner == null ) then
call ConditionalTriggerExecute( gg_trg_General_Animations )
endif
call TriggerExecute( gg_trg_MoveSpeed_of_Players )
set slider = null
endfunction
//===========================================================================
function InitTrig_Sliding takes nothing returns nothing
set gg_trg_Sliding = CreateTrigger( )
call TriggerAddAction( gg_trg_Sliding, function Trig_Sliding_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_General_Animations_Actions takes nothing returns nothing
location loc_ball = GetUnitLoc(udg_Ball)
location loc_ball_new = PolarProjectionBJ( loc_ball, 100, udg_BallDirection)
real ball_speed = GetBallSpeed()
if ( ball_speed <= udg_MinSpeed ) then
call Ball_Stop()
else
real coef_move = CLASSIC_BALL_ANIM_SCALE_COEF_MOVING
call SetUnitTimeScalePercent( udg_Ball, coef_move * ball_speed )
call BallMove( loc_ball_new )
call ConditionalTriggerExecute( gg_trg_Z_Chase_Pass_Target )
endif
call CleanLocs(loc_ball, loc_ball_new)
endfunction
//===========================================================================
function InitTrig_General_Animations takes nothing returns nothing
set gg_trg_General_Animations = CreateTrigger( )
call TriggerAddAction( gg_trg_General_Animations, function Trig_General_Animations_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
bool BallHitsGroundCheck() {
real h_ball = Ball_GetHeight()
bool b1 = udg_BallVZ < 0
bool b2 = h_ball <= udg_BallDefaultHeight
return b1 && b2
}
void BallHitsGround_Actions() {
call BallSpeedDown(GROUND_HIT_FACTOR)
//call PlaySoundOnUnit(gg_snd_Land, Ball)
call Audio_PlaySound(SOUND_GROUND_HIT)
call Ball_ResetHeight()
real coef = 5.
if ( Abs(udg_BallVZ) < udg_G * coef ) then
call HideUnit( udg_Flag )
set udg_IsBallInAir = false
set udg_BallVZ = 0
else
set udg_BallVZ *= (-0.6)
endif
if LastActionMade == ACTION_KICK
set BallHitGroundAfterX = true
endif
}
bool Ball_IsUnderBar() {
real h_ball = Ball_GetHeight()
bool b = h_ball < MINIMUM_BAR_HEIGHT
return b
}
bool Ball_IsAboveBar() {
real h_ball = Ball_GetHeight()
bool b = h_ball > MAXIMUM_BAR_HEIGHT
return b
}
bool BallHitsBar() {
bool goal_roof = BallInRect(gg_rct_BarRight) || BallInRect(gg_rct_BarLeft) \
|| BallInRect(gg_rct_BarLeft_Copy) || BallInRect(gg_rct_BarRight_Copy) \
|| BallInRect(gg_rct_GoalLeft) || BallInRect(gg_rct_GoalRight)
real h_ball = Ball_GetHeight()
real h_bar_min = MINIMUM_BAR_HEIGHT
real h_bar_max = MAXIMUM_BAR_HEIGHT
bool low_hit = goal_roof && ( udg_BallVZ > 0 ) && Ball_IsUnderBar() && ( h_ball + udg_BallVZ >= h_bar_min )
bool high_hit = goal_roof && ( udg_BallVZ < 0 ) && Ball_IsAboveBar() && ( h_ball + udg_BallVZ <= h_bar_max )
bool bar_hit = low_hit || high_hit
return bar_hit
}
void BallHitsBar_Actions() {
real dist
real h_ball = Ball_GetHeight()
real h_bar_min = MINIMUM_BAR_HEIGHT
real h_bar_max = MAXIMUM_BAR_HEIGHT
bool low_hit = Ball_IsUnderBar()
if low_hit
DebugMsg("low hit!")
dist = h_bar_min - h_ball
else
DebugMsg("high hit!")
dist = h_ball - h_bar_max
endif
real dist_to_cover = 1 - dist / Abs(udg_BallVZ)
set udg_BallVZ *= -0.6
TestMsg(R2S(udg_BallVZ))
if udg_BallVZ < 4 && udg_BallVZ >= 0
if GetChance(0.25) then
set udg_BallVZ *= 10
//call OverHeadFlashEffect(udg_Ball)
//call SetBallHeight(GetBallH() + 20)
elseif GetChance(0.33)
set udg_TempReal = 25 //30
//call SetUnitMoveSpeed(udg_Ball, 522)
set udg_BallDirection = AngleBetweenPoints(GetBallLoc(), GetUnitLoc(LK))
set udg_BallInitialDirection = udg_BallDirection
set udg_BallVZ = 15 // 20
set udg_PassTarget = LK
location loc_new = PolarProjectionBJ(GetBallLoc(), 20, udg_BallDirection)
call SetUnitPositionLoc(udg_Ball, loc_new)
call TriggerExecute(gg_trg_Set_Ball_Move_Speed)
call RunBallGeneralAnimations()
endif
//real facing = AngleBetweenPoints(GetBallLoc(), GetPitchCenter())
//call SetUnitFacing(udg_Ball, facing)
endif
call BallSpeedDown(CROSSBAR_HIT_FACTOR)
call Audio_PlaySound(SOUND_GOAL_HIT)
if low_hit
SetBallHeight( h_bar_min + udg_BallVZ * dist_to_cover )
else
SetBallHeight( h_bar_max + udg_BallVZ * dist_to_cover )
endif
}
void Ball_UpdateHeight() {
real h_new
real rate
if SmoothBall
if RecentShot then
set h_new = Ball_GetHeight() + udg_BallVZ
call Ball_SetHeight(h_new)
call TestMsg("Instant set ball h = "+R2S(h_new))
set RecentShot = false
endif
set udg_BallVZ -= udg_G
//set h_new = GetBallHeight() + udg_BallVZ
//set rate = GetHeightRate(GetBallHeight(), h_new, 0.1) // Abs(udg_BallVZ)*10
//call SetUnitFlyHeight(udg_Ball, h_new, rate)
else
if BallHeight005Update && PartialSmooth
call Ball_SetHeight( GetBallHeight() + 0.5*udg_BallVZ )
set BallHeight005Update = false
else
call Ball_SetHeight( GetBallHeight() + udg_BallVZ )
endif
//creating text tag
real v_old = udg_BallVZ
set udg_BallVZ -= udg_G
real v_new = udg_BallVZ
real h_ball = Ball_GetHeight()
bool b1 = ShowCustomMaxHeights && (h_ball > CustomHeightMinimum) // && InTesting
bool b2 = h_ball > 250
if (v_old > 0) && (v_new < 0) && (b1 || b2) {
CreateExclamatoryTextTag(R2IS(h_ball), Ball_GetLoc(), h_ball + 100, 0,100,0)
}
endif
}
void Trig_Vertical_Animations_Actions() {
if BallHitsGroundCheck()
call BallHitsGround_Actions()
elseif BallHitsBar()
call BallHitsBar_Actions()
else
call Ball_UpdateHeight()
endif
}
//===========================================================================
function InitTrig_Vertical_Animations takes nothing returns nothing
set gg_trg_Vertical_Animations = CreateTrigger( )
call TriggerAddAction( gg_trg_Vertical_Animations, function Trig_Vertical_Animations_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Smoother_Ball_Action_Conditions takes nothing returns boolean
bool b1 = udg_IsBallInAir
bool b2 = udg_BallOwner == null
bool b3 = ( udg_BallVZ >= 0 ) || ( GetBallHeight() > udg_BallDefaultHeight )
bool b4 = udg_ThrowinMode == 0
bool b5 = not RecentShot
bool b6 = SmoothBall
return b1 and b2 and b4 and b5 and b6
endfunction
function Trig_Smoother_Ball_Action_Actions takes nothing returns nothing
real h_new = GetBallHeight() + 0.1 * udg_BallVZ
call SetBallHeight(h_new)
endfunction
//===========================================================================
function InitTrig_Smooth_Ball takes nothing returns nothing
set gg_trg_Smooth_Ball = CreateTrigger( )
call TriggerAddCondition( gg_trg_Smooth_Ball, Condition(function Trig_Smoother_Ball_Action_Conditions) )
call TriggerAddAction( gg_trg_Smooth_Ball, function Trig_Smoother_Ball_Action_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
void PeriodicJumpActions() {
unit u = GetEnumUnit()
int pid = GetExtendedId(u)
if ( udg_HeroInAir[pid] ) then
call SetUnitHeight( u, GetUnitFlyHeight(u) + udg_HeroVY[pid] )
set udg_HeroVY[pid] -= udg_G
if ( GetUnitFlyHeight(u) <= 0.01 ) then
set udg_HeroInAir[pid] = false
call SetUnitFlyHeight( u, 0, 0 )
set udg_HeroVY[pid] = 0
if ManualZ { ExchangeShortPassAbilsForth() }
endif
endif
set u = null
}
void PeriodicSlideActions() {
unit u = GetEnumUnit()
int pid = GetExtendedId(u) // cPid(GetOwningPlayer(u))// GetExtendedId(u)
location loc_hero = null
location loc_hero_new = null
if ( udg_HeroSlidingWait[pid] <= 0 ) then
//call SetUnitMoveSpeed(u, GetUnitDefaultMoveSpeed(u))
else
call Dec(udg_HeroSlidingWait[pid])
//call IssueImmediateOrder( u, "stop" )
real speed_new = 0.5 * GetUnitDefaultMoveSpeed(u)
call SetUnitMoveSpeed(u, speed_new) //150
if ( udg_HeroVX[pid] > 0 ) then
set loc_hero = GetUnitLoc(u)
set loc_hero_new = PolarProjectionBJ( loc_hero, udg_HeroVX[pid], udg_SlidingDirection[pid])
call SetUnitPositionLoc( u, loc_hero_new )
set udg_HeroVX[pid] -= 3
if ( udg_HeroVX[pid] < 15 ) then
call DestroyEffect( udg_SlidingEffect[pid] )
endif
endif
endif
call CleanLocs(loc_hero,loc_hero_new)
}
function Trig_Sliding_and_jump_Main takes nothing returns nothing
call PeriodicSlideActions()
call PeriodicJumpActions()
// 740d code was here
endfunction
function Trig_Sliding_and_jump_Actions takes nothing returns nothing
group g = CreateGroup()
call GroupAddGroup(udg_Team1Heroes, g)
call GroupAddGroup(udg_Team2Heroes, g)
call GroupAddUnit(g, udg_Keeper[1])
call GroupAddUnit(g, udg_Keeper[2])
call ForGroup(g, function Trig_Sliding_and_jump_Main)
call RemoveGroup(g)
endfunction
//===========================================================================
function InitTrig_Sliding_and_jump takes nothing returns nothing
set gg_trg_Sliding_and_jump = CreateTrigger( )
call TriggerAddAction( gg_trg_Sliding_and_jump, function Trig_Sliding_and_jump_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Cant_Get_Out_While_Throwin_Conditions takes nothing returns bool
location loc_unit = GetUnitLoc(udg_BallOwner)
bool b1 = DistanceBetweenPoints( loc_unit, udg_ThrowinLoc ) >= 10
bool b2 = udg_ThrowinMode != 0
call CleanLoc(loc_unit)
return b1 and b2
endfunction
function Trig_Cant_Get_Out_While_Throwin_Actions takes nothing returns nothing
call SetUnitPositionLoc( udg_BallOwner, udg_ThrowinLoc )
endfunction
//===========================================================================
function InitTrig_Cant_move_in_throwins takes nothing returns nothing
set gg_trg_Cant_move_in_throwins = CreateTrigger( )
call TrgAddCond( gg_trg_Cant_move_in_throwins, function Trig_Cant_Get_Out_While_Throwin_Conditions )
call TriggerAddAction( gg_trg_Cant_move_in_throwins, function Trig_Cant_Get_Out_While_Throwin_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function PushUnitToCenterLine takes unit u returns nothing
real center_x = GetRectCenterX(gg_rct_Center)
real unit_y = GetUnitY(u)
location loc_unit_new = Location(center_x, unit_y)
call SetUnitPositionLoc( u, loc_unit_new )
call CleanLoc(loc_unit_new)
endfunction
function Trig_Cant_Enter_Other_Side_Main takes nothing returns nothing
unit u = GetEnumUnit()
if IsUnitInRect( u, TempRect ) then
PushUnitToCenterLine(u)
endif
endfunction
function Trig_Cant_Enter_Other_Side_Actions takes nothing returns nothing
call Ensure(udg_CantEnterOtherSide)
//call Ensure(not udg_MapReset)
group g_left, g_right
if ( udg_Round == 0 ) then
set g_left = GetFullSquad(1)
set g_right = GetFullSquad(2)
else
set g_left = GetFullSquad(2)
set g_right = GetFullSquad(1)
endif
set TempRect = gg_rct_LeftArea
call ForGroup( g_right, function Trig_Cant_Enter_Other_Side_Main )
set TempRect = gg_rct_RightArea
call ForGroup( g_left, function Trig_Cant_Enter_Other_Side_Main )
call RemoveGroup(g_left)
call RemoveGroup(g_right)
endfunction
//===========================================================================
function InitTrig_Cant_Enter_Other_Side takes nothing returns nothing
set gg_trg_Cant_Enter_Other_Side = CreateTrigger( )
call TriggerAddAction( gg_trg_Cant_Enter_Other_Side, function Trig_Cant_Enter_Other_Side_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Move_Flag_To_Certain_Point_Actions takes nothing returns nothing
local location loc_ball = GetUnitLoc(udg_Ball)
local location loc_flag_new = null
real b_speed = GetUnitMoveSpeed(udg_Ball)
if ( b_speed > udg_MinSpeed ) then
real h_ball = GetUnitFlyHeight(udg_Ball)
real dist = 0.1*b_speed*(udg_BallVZ+SquareRoot(Pow(udg_BallVZ, 2)+2*udg_G*h_ball))/udg_G
set loc_flag_new = PolarProjectionBJ( loc_ball, dist, udg_BallDirection)
call SetUnitPositionLoc( udg_Flag, loc_flag_new )
else
call SetUnitPositionLoc( udg_Flag, loc_ball )
endif
call CleanLocs( loc_flag_new, loc_ball )
endfunction
//===========================================================================
function InitTrig_Move_Flag_To_Certain_Point takes nothing returns nothing
set gg_trg_Move_Flag_To_Certain_Point = CreateTrigger( )
call TriggerAddAction( gg_trg_Move_Flag_To_Certain_Point, function Trig_Move_Flag_To_Certain_Point_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Reduce_MoveSpeed_of_BallOwner_Main takes nothing returns nothing
integer pid = cPid(GetOwningPlayer(GetEnumUnit()))
integer val = udg_ReduceSpeedTimer[pid]
unit u = GetEnumUnit()
if ( u == BallOwner )
Inc(val)
if ( val > 20 ) || true
val = 20
endif
else
Dec(val)
if ( val < 0 ) || true
val = 0
endif
endif
set udg_ReduceSpeedTimer[pid] = val
// Setting new movement speed for the unit
player p = GetOwningPlayer(u)
real coef = 4.5
if EasyMode
if not (GetPlayerController(p) == MAP_CONTROL_COMPUTER)
set coef /= 2
endif
endif
real speed_new = GetUnitDefaultMoveSpeed(u) - coef * val
if ( speed_new < 200 )
speed_new = 200
endif
call SetUnitMoveSpeed( u, speed_new)
endfunction
function Trig_Reduce_MoveSpeed_of_BallOwner_Actions takes nothing returns nothing
conditionfunc cond = Condition(function IsFilterUnitHero)
group g = GetUnitsInRectMatching(GetPlayableMapRect(), cond)
call ForGroup( g, function Trig_Reduce_MoveSpeed_of_BallOwner_Main )
call RemoveCond(cond)
call RemoveGroup(g)
endfunction
//===========================================================================
function InitTrig_MoveSpeed_of_Players takes nothing returns nothing
set gg_trg_MoveSpeed_of_Players = CreateTrigger( )
call TriggerAddAction( gg_trg_MoveSpeed_of_Players, function Trig_Reduce_MoveSpeed_of_BallOwner_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Ball_height_texttag_Actions takes nothing returns nothing
real height = Ball_GetHeight()
int h = R2I(height)
string s = R2IS(height)
int lam = LastActionMade
bool b1 = not ( IsKeeper(LK) && lam == ACTION_KEEPER_THROW )
bool b2 = h > 320
bool b3 = udg_BallVZ > 0
bool b = b1 && b2 && b3
if b then
//call CreateExclamatoryTextTag(s,GetBallLoc(), height+50, 0,100,0)
echo (I2S(h)+"!")
endif
endfunction
//===========================================================================
function InitTrig_Ball_height_exclamation takes nothing returns nothing
set gg_trg_Ball_height_exclamation = CreateTrigger( )
call TriggerAddAction( gg_trg_Ball_height_exclamation, function Trig_Ball_height_texttag_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Update_Upper_Timer_Main takes nothing returns nothing
timer timer_used = udg_RoundTimer
if ( udg_Round == 1 ) then
timer_used = udg_RealTimer
endif
real time_left = TimerGetRemaining( timer_used )
set time_left += 0.1 // avoiding 9/59 starting time problem
int time = R2I(time_left)
int mins = time/60
int s = mod(time, 60)
call SetPlayerState( GetEnumPlayer(), PLAYER_STATE_RESOURCE_FOOD_USED, mins )
call SetPlayerState( GetEnumPlayer(), PLAYER_STATE_RESOURCE_FOOD_CAP, s )
call Scoreboard3D_UpdateTimer(mins, s)
endfunction
function Trig_Update_Upper_Timer_Actions takes nothing returns nothing
call ForForce(GetPlayersAll(), function Trig_Update_Upper_Timer_Main )
endfunction
//===========================================================================
function InitTrig_Update_Timer takes nothing returns nothing
set gg_trg_Update_Timer = CreateTrigger( )
call TriggerAddAction( gg_trg_Update_Timer, function Trig_Update_Upper_Timer_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Set_Ball_VX_Actions takes nothing returns nothing
set udg_TempReal *= 10
set udg_CurrentBallSpeed = udg_TempReal
if ( udg_CurrentBallSpeed > 522 ) then
Ball_SetSpeed(522)
else
Ball_SetSpeed(udg_CurrentBallSpeed)
endif
endfunction
//===========================================================================
function InitTrig_Set_Ball_Move_Speed takes nothing returns nothing
set gg_trg_Set_Ball_Move_Speed = CreateTrigger( )
call TriggerAddAction( gg_trg_Set_Ball_Move_Speed, function Trig_Set_Ball_VX_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib_init( Round, config, StdLib ), Scoreboard3D
enum (rounds) {
FIRST_HALF
HALF_TIME
SECOND_HALF
TIMES_UP
}
constant integer HALF_TIME_DURATION = 30
bool IsFirstHalf() {
return udg_Round == FIRST_HALF
}
bool IsSecondHalf() {
return udg_Round == SECOND_HALF
}
bool IsHalfTime() {
return udg_Round == HALF_TIME
}
public void Init() {
set udg_Round = 0
call Sleep( 0.01 )
call TimerStart( udg_RealTimer, udg_RoundTime * 60, false, null )
call PauseTimer( udg_RealTimer )
call TimerStart( udg_RoundTimer, udg_RoundTime * 60, false, null )
call PauseTimer( udg_RoundTimer )
call Scoreboard3D_SetHalfIndicator(FIRST_HALF)
}
private void BlowWhistleIfKeeperHasBall() {
bool blowWhistle = (udg_WhichKeeperHasBall != 0)
if blowWhistle
call Audio_PlaySound(SOUND_WHISTLE_MEDIUM)
endif
}
void HalfTimeMessages () {
echoln( "|c00ffcc00Half Time|r |c00ff0000STARTS!|r" )
int duration = HALF_TIME_DURATION
//echo( "Second half will commence in "+I2S(duration)+" seconds." )
call FlashQuestDialogButton()
Sleep(4)
echo( )
//echo("Check out " + Orange("F9") + " for Game Info." )
//echo( " " )
// If you want to contact me (comment or suggestion), type -email.
//echo("If you want to comment on the map, you can contact me. ")//type "+Orange("-email")+".")
//echo("If you want to comment on the map, contact me at " +Orange("[email protected]")+".")
// (comments/suggestions)
//call Sleep(2)
//echo("To see my email, type "+Orange("-email")+".")
//echo( )
Sleep(2)
//echo("For list of changes in this version, type "+Orange("-changes")+".")
//echo( )
//echo("To learn more about gameplay, type "+Orange("-help.") )
//echo( )
Sleep(20)
}
void StartHalfTime () {
call BlowWhistleIfKeeperHasBall()
call Sleep( 0.1 )
call DisableTrigger( gg_trg_Ball_Timer_Action )
call DisableTrigger(gg_trg_Show_Losstime )
int time = 30
if InTesting
time = 15
endif
call TimerStart( udg_RealTimer, time, false, null )
call Ball_Hide()
set Ball = null
call PSLib_NullifyParams()
set BallOwner = null
set LastActionMade = ACTION_GAME_PAUSED
set udg_Round = 1
set udg_KeeperBallHoldTimer = 0
set udg_WhichKeeperHasBall = 0
set udg_BallImmuneTimer = time*10 // 0
set udg_ThrowinMode = 0 // in case of goal kick and such
call DestroyEffect( udg_BallInHandEffect )
exec(HalfTimeMessages)
call PolledWait(3)
set udg_CantEnterOtherSide = false
set udg_ThrowinMode = 0
}
private void EnforceDraw() {
call ForForce(GetPlayersAll(), function MeleeDoDrawEnum)
}
private void PlayerWins(player p) {
/*call MMD_FlagPlayer(p, MMD_FLAG_WINNER)
if IsPlayerObs(p) then
call MMD_FlagPlayer(p, MMD_FLAG_DRAWER)
endif
if not IsPlayerPlaying(p) then
call MMD_FlagPlayer(p, MMD_FLAG_LEAVER)
endif*/
call CustomVictoryBJ( p, true, true )
}
private void PlayerLoses(player p) {
/*call MMD_FlagPlayer(p, MMD_FLAG_LOSER)
if IsPlayerObs(p) then
call MMD_FlagPlayer(p, MMD_FLAG_DRAWER)
endif
if not IsPlayerPlaying(p) then
call MMD_FlagPlayer(p, MMD_FLAG_LEAVER)
endif*/
call CustomDefeatBJ( p, "TRIGSTR_116" )
}
private void HumansWinEnum() {
player p = GetEnumPlayer()
//if ( IsPlayerAlly(GetEnumPlayer(), Player(0)) ) then
if IsPlayerInTeam(p, 1) then
call PlayerWins( p )
else
call PlayerLoses( p )
endif
}
private void HumansWin() {
echo( "TRIGSTR_184" )
call Sleep(2)
force f = GetPlayingPlayers()
call ForForce( f, function HumansWinEnum )
}
private void OrcsWinEnum() {
player p = GetEnumPlayer()
if IsPlayerInTeam(p, 1) then
call PlayerLoses( p )
else
call PlayerWins( p )
endif
}
private void OrcsWin() {
echo( "TRIGSTR_183" )
call Sleep(2)
force f = GetPlayingPlayers()
call ForForce( f, function OrcsWinEnum )
}
void TimesUp() {
echo( )
if ( not udg_GoldenGoal )
{
echo( "TRIGSTR_193" )
call StartSound( gg_snd_GoodJob )
}
if ( udg_Score[1] == udg_Score[2] )
{
echo( Orange("Draw!") )
echo( )
if IsGoldenGoalEnabled
{
echo("Score the "+ Green("Golden Goal") +" to win the game!")
//echo( "The first team to score wins!" )
call DisableTrigger( gg_trg_Show_Losstime )
set udg_GoldenGoal = true
return
}
}
/*call PlaySoundFromOffsetBJ( gg_snd_whistle_long, 100, 0.85 )
call WaitForSoundBJ( gg_snd_whistle_long, 0.00 )
call PolledWait( 0.20 )*/
call Audio_PlaySound(SOUND_WHISTLE_END)
set udg_Round = 3
call DestroyTrigger( gg_trg_Timer_Interval_01 )
call DestroyTrigger( gg_trg_Timer_Interval_001 )
call DestroyTrigger( gg_trg_Timer_Interval_05 )
call DestroyTrigger( gg_trg_Show_Losstime )
call PolledWait( 0.5 )
call TriggerExecute(gg_trg_Display_Stats)
call PolledWait( 60 )
if ( udg_Score[1] > udg_Score[2] ) then
call HumansWin()
elseif ( udg_Score[1] < udg_Score[2] ) then
call OrcsWin()
else
call EnforceDraw()
endif
}
private bool RoundEndConditions() {
bool b1 = udg_MapReset
bool b2 = udg_WhichKeeperHasBall != 0
return b1 || b2
}
private void WaitForRoundEndConditions() {
// infinity real timer to avoid critical bug from 7.35 b2
call TimerStart( udg_RealTimer, INFINITY_TIME, false, null )
//tstmsg(here)
whilenot RoundEndConditions() {
call Sleep(1)
}
}
function Trig_second_half_start_ResetLocations takes nothing returns nothing
local location loc_new
local player p = GetOwningPlayer(GetEnumUnit())
if ( IsPlayerInTeam(p,2) ) then
set loc_new = GetRandomLocInRect(gg_rct_LeftTeamStay)
else
set loc_new = GetRandomLocInRect(gg_rct_RightTeamStay)
endif
call SetUnitPositionLoc( GetEnumUnit(), loc_new )
integer pid = GetConvertedPlayerId(p)
if ( udg_CameraLock[pid] ) then
call SetCameraTargetControllerNoZForPlayer( p, udg_Hero[pid], 0, 0, false )
endif
endfunction
function Trig_second_half_start_UpdateRegions takes nothing returns nothing
set udg_AI_AttackPoint_U[1] = gg_rct_AItargetLEFTU
set udg_AI_AttackPoint_M[1] = gg_rct_AItargetLEFTM
set udg_AI_AttackPoint_D[1] = gg_rct_AItargetLEFTTD
set udg_AI_AttackPoint_U[2] = gg_rct_AItargetRIGHTU
set udg_AI_AttackPoint_M[2] = gg_rct_AItargetRIGHTM
set udg_AI_AttackPoint_D[2] = gg_rct_AItargetRIGHTD
set udg_KeeperMoveArea[2] = gg_rct_KeeperMoveAreaLeft
set udg_KeeperMoveArea[1] = gg_rct_KeeperMoveAreaRight
set udg_KeeperArea[2] = gg_rct_LeftKeeperArea
set udg_KeeperArea[1] = gg_rct_RightKeeperArea
set udg_PlayArea[2] = gg_rct_LeftArea
set udg_PlayArea[1] = gg_rct_RightArea
set udg_PenaltyArea[1] = gg_rct_PenaltyAreaRight
set udg_PenaltyArea[2] = gg_rct_PenaltyAreaLeft
set udg_GoalArea[2] = gg_rct_HeadingShootAreaLeft
set udg_GoalArea[1] = gg_rct_HeadingShootAreaRight
endfunction
function Trig_second_half_start_TimerActions takes nothing returns nothing
call TimerStart( udg_RoundTimer, udg_RoundTime * 60, false, null )
call PauseTimer( udg_RoundTimer )
call TimerStart( udg_RealTimer, udg_RoundTime * 60, false, null )
call PauseTimer( udg_RealTimer )
endfunction
function StartSecondHalf takes nothing returns nothing
call Trig_second_half_start_UpdateRegions()
call Scoreboard3D_SetHalfIndicator(SECOND_HALF)
set udg_LeftTeamName = TeamName[2]
set udg_RightTeamName = TeamName[1]
call SetUnitPositionLocFacingBJ( udg_Keeper[1], GetRectCenter(udg_KeeperArea[1]), 180 )
call SetUnitPositionLocFacingBJ( udg_Keeper[2], GetRectCenter(udg_KeeperArea[2]), 0 )
set udg_CantEnterOtherSide = true
call EnableTrigger( gg_trg_Ball_Timer_Action )
call EnableTrigger( gg_trg_Show_Losstime )
call EnableTrigger( gg_trg_Timer_Interval_01 )
call EnableTrigger( gg_trg_Timer_Interval_001 )
//echoln( "TRIGSTR_189" )
call HalfStartsMsg(2)
set Ball = Ball_GetHandle()
set udg_ThrowinMode = 2
set udg_BallImmuneTimer = 0
set BallOwner = null
call PSLib_NullifyParams()
set LastActionMade = 0
set udg_ThrowinLoc = GetPitchCenter()
call SetUnitPositionLoc( udg_Ball, udg_ThrowinLoc )
conditionfunc cond = Condition(function IsHeroNotObs)
group g = GetUnitsInRangeOfLocMatching(INFINITY_RANGE, GetPitchCenter(), cond)
call ForGroup( g, function Trig_second_half_start_ResetLocations )
call TriggerExecute(gg_trg_Reset_player_locations)
// pan camera to ball - might mess up with cam lock
call ShowUnit( Ball )
call PanCameraToCenter()
call TriggerExecute( gg_trg_Linecross_common_events )
call Trig_second_half_start_TimerActions()
set udg_Round = 2
set udg_IgnoreAItimer = 10
call Audio_PlaySound(SOUND_WHISTLE_MEDIUM)
/*
call TriggerSleepAction(10)
call ClearTextMessages()
*/
endfunction
void SwitchRounds() {
//testmsg("in switch func")
//testmsg(1)
if IsInSet(udg_Round,FIRST_HALF,SECOND_HALF) {
call WaitForRoundEndConditions()
//tstmsg(here2)
}
//testmsg(2)
if ( udg_Round == FIRST_HALF ) then
call StartHalfTime()
elseif ( udg_Round == HALF_TIME ) then
call StartSecondHalf()
elseif ( udg_Round == SECOND_HALF ) then
call TimesUp()
endif
//testmsg(3)
}
private timer TimerSubtract(timer t, real s) {
real s_timer = TimerGetRemaining(t)
call DestroyTimer(t)
set t = CreateTimerBJ(false, s_timer-s)
//call TimerStart(udg_RoundTimer, (s_round-s), false, null)
if ThrowinMode != 0
call PauseTimer(t)
endif
return t
}
void TimerSubtractMain(real seconds_to_subtract) {
real s = seconds_to_subtract
real s_round = TimerGetRemaining(udg_RoundTimer)
real s_real = TimerGetRemaining(udg_RealTimer)
if s_round > s
// subtract s from both
set udg_RoundTimer = TimerSubtract(udg_RoundTimer,s)
set udg_RealTimer = TimerSubtract(udg_RealTimer,s)
/*call DestroyTimer(udg_RoundTimer)
set udg_RoundTimer = CreateTimerBJ(false, s_round-s)
//call TimerStart(udg_RoundTimer, (s_round-s), false, null)
if ThrowinMode != 0
call PauseTimer(udg_RoundTimer)
endif*/
call TriggerRegisterTimerExpireEvent(gg_trg_Show_Losstime, udg_RoundTimer)
trigger t=CreateTrigger()
call TriggerRegisterTimerExpireEvent(t, udg_RealTimer)
call TriggerAddAction(t, function SwitchRounds)
/*elseif s_real > s
set udg_RoundTimer = TimerSubtract(udg_RoundTimer,abs(s_round-1))
set udg_RealTimer = TimerSubtract(udg_RealTimer,s)
else
set udg_RoundTimer = TimerSubtract(udg_RoundTimer,abs(s_round-1))
set udg_RealTimer = TimerSubtract(udg_RealTimer,abs(s_real-1))*/
endif
}
private timer TimerAdd(timer t, real s) {
real s_timer = TimerGetRemaining(t)
call DestroyTimer(t)
set t = CreateTimerBJ(false, s_timer+s)
//call TimerStart(udg_RoundTimer, (s_round-s), false, null)
if ThrowinMode != 0
call PauseTimer(t)
endif
return t
}
void TimerAddMain(real seconds_to_add) {
real s = seconds_to_add
real s_round = TimerGetRemaining(udg_RoundTimer)
real s_real = TimerGetRemaining(udg_RealTimer)
if s_round > 1.
// subtract s from both
set udg_RoundTimer = TimerAdd(udg_RoundTimer,s)
set udg_RealTimer = TimerAdd(udg_RealTimer,s)
call TriggerRegisterTimerExpireEvent(gg_trg_Show_Losstime, udg_RoundTimer)
trigger t=CreateTrigger()
call TriggerRegisterTimerExpireEvent(t, udg_RealTimer)
call TriggerAddAction(t, function SwitchRounds)
endif
}
private void config() {
trigger t
Sleep()
set t = CreateTrigger( )
call TriggerRegisterTimerExpireEvent( t, udg_RealTimer )
call TriggerAddAction( t, function SwitchRounds )
/*
set t = CreateTrigger( )
call TriggerRegisterTimerExpireEvent( t, udg_RoundTimer )
call TriggerAddAction( t, function Trig_Show_Losstime_Actions )*/
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function GetLossTimeString takes nothing returns string
real losstime = TimerGetRemaining(udg_RealTimer)
integer mins = R2I(losstime)/60
integer s = ModuloInteger(R2I(losstime), 60)
DebugMsg("Actual mins: "+I2S(mins)+" , Sec: "+I2S(s))
DebugMsg(" ")
if s >= 50
s = 0
mins ++
else
// rounding
int k = s/10
s = (k+1)*10
endif
string str_mins = AddLeadingZeroes(mins)
string str_s = AddLeadingZeroes(s)
string output = str_mins + ":" + str_s
output = Orange(output)
return output
endfunction
function Trig_Show_Losstime_Actions takes nothing returns nothing
bool b1 = IsInSet(udg_Round, FIRST_HALF, SECOND_HALF)
bool b2 = udg_GoldenGoal
call Audio_PlaySound(SOUND_HINT)
echoln( Red("STOPPAGE TIME!") )
//echo( "This round will finish soon!" )
echo("Extra time: "+GetLossTimeString())
echo( )
call TimerStart( udg_RoundTimer, 0.5, false, null ) // ?
call PauseTimer( udg_RoundTimer )
//
call DisableTrigger(gg_trg_Show_Losstime)
/*
call DisableTrigger(GetTriggeringTrigger())
whilenot(udg_Round == HALF_TIME) {
call Sleep(1)
}
call EnableTrigger(GetTriggeringTrigger())
*/
endfunction
//===========================================================================
function InitTrig_Show_Losstime takes nothing returns nothing
set gg_trg_Show_Losstime = CreateTrigger( )
call TriggerRegisterTimerExpireEvent( gg_trg_Show_Losstime, udg_RoundTimer )
call TriggerAddAction( gg_trg_Show_Losstime, function Trig_Show_Losstime_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
// types of keeper throw
constant integer IN_GET_BALL = 1
constant integer OUT_SIMPLE_THROW = 2
constant integer KEEPER_AI_CLASSIC = 1
constant integer KEEPER_AI_IMPROVED = 2
real KEEPER_GET_BALL_RANGE_NORMAL = 140. // 150, 135, 140, 142.5
real KEEPER_GET_BALL_RANGE_REDUCED = 120.
real KEEPER_GET_BALL_RANGE = KEEPER_GET_BALL_RANGE_NORMAL
integer KeeperAI = KEEPER_AI_IMPROVED
lib( KeeperLib , StdLib )
enum(keepers) {
NONE
CECH
CASILLAS
}
function Keeper_Hide takes int whichKeeper returns nothing
if whichKeeper < 1 || whichKeeper > 2
return
endif
call HideUnit(udg_Keeper[whichKeeper])
set udg_Keeper[whichKeeper] = null
endfunction
function IsUnitKeeperUnderControl takes unit u returns bool
bool b1 = IsKeeperPlayable
bool b2 = IsKeeper(u)
return b1 && b2
endfunction
function IsUnitKeeper takes unit u returns bool
return IsKeeper(u)
endfunction
function GetKeeperController takes int whichKeeper returns player
if IsKeeperPlayable
return GetOwningPlayer(udg_Keeper[whichKeeper])
else
return null
endif
endfunction
public function GetBall takes nothing returns nothing
set TempInt = 1
call ConditionalTriggerExecute(gg_trg_Keeper_Get_Ball)
set TempInt = 2
call ConditionalTriggerExecute(gg_trg_Keeper_Get_Ball)
endfunction
public function MoveKeepers takes nothing returns nothing
set TempInt = 1
call ConditionalTriggerExecute( gg_trg_Keeper_Movement )
set TempInt = 2
call ConditionalTriggerExecute( gg_trg_Keeper_Movement )
endfunction
function GetNextKeeperController takes integer team returns player
// using non-converted pids
local integer pid_keeper = GetPlayerId(GetOwningPlayer(udg_Keeper[udg_ThrowinMode]))
local integer pid_i = pid_keeper
local integer pid_last
local player p
if team == 1 then
set pid_last = 5
else
set pid_last = 11
endif
//if GetPlayerController(GetOwningPlayer(udg_Keeper[team])) ==
loop
if pid_i >= pid_last then
set pid_i = pid_last - 5
else
set pid_i = pid_i + 1
endif
set p = Player(pid_i)
exitwhen pid_i == pid_keeper // came back to the original controller
//exitwhen IsPlayerStatePlaying(p) and GetPlayerController(p) == MAP_CONTROL_USER and not IsPlayerInForce(p, Observers)
exitwhen IsPlayerPlaying(p) && GetHero(p) != udg_BallOwner && IsPlayerInTeam(p,team)
endloop
return p
endfunction
function ResetPlayableKeeper takes nothing returns nothing
// udg_ThrowinMode defines the number of team that conceded a goal
local integer pid = GetConvertedPlayerId(GetOwningPlayer(udg_Keeper[udg_ThrowinMode]))
local player p
// locations of keeper controllers have not been reset
// resetting former controller's hero loc
if IsLeftPlayer(GetOwningPlayer(udg_Keeper[udg_ThrowinMode])) then
call SetUnitPositionLoc(udg_Hero[pid], GetRandomLocInRect(gg_rct_LeftTeamStay))
else
call SetUnitPositionLoc(udg_Hero[pid], GetRandomLocInRect(gg_rct_RightTeamStay))
endif
//call SetUnitPositionLoc( udg_Hero[pid], )
call ShowUnitShow(udg_Hero[pid])
// Setting next controller
if udg_NextKeeperController[udg_ThrowinMode] == null
set p = GetNextKeeperController(udg_ThrowinMode)
else
set p = udg_NextKeeperController[udg_ThrowinMode]
endif
set pid = GetConvertedPlayerId(p)
call SetUnitOwner(udg_Keeper[udg_ThrowinMode], p, true)
call SetUnitPositionLoc(udg_Hero[pid], GetRectCenter(gg_rct_ObsMode))
call ShowUnitHide(udg_Hero[pid])
endfunction
function CanKeeperManipulate##Ball takes unit keeper, int mode returns bool
if keeper == null
return false
endif
int whichKeeper = GetKeeperId(keeper)
int pid = GetExtendedId(keeper)
bool b1 = DistanceBetweenUnits( udg_Ball, keeper ) < KEEPER_GET_BALL_RANGE
bool b2 = DistanceBetweenUnits( udg_Ball, keeper ) < 100
//bool b2 = not IsUnitType(keeper, UNIT_TYPE_STUNNED)
bool b3 = not IsUnitInTeam(udg_BallOwner, whichKeeper)
bool b41 = GetBallHeight() < 120 + GetUnitFlyHeight(keeper)
bool b42 = GetUnitFlyHeight(keeper) <= GetBallHeight()
bool b4 = b41 && b42
bool b5 = udg_CantHoldBall[pid] <= 0
bool b6 = udg_BallImmuneTimer <= 0
bool b7 = RectContainsBall( udg_PenaltyArea[whichKeeper] )
bool b8 = RectContainsUnit( udg_PenaltyArea[whichKeeper], keeper )
//bool b9 = udg_BallBound || GetBallSpeed() < 450 + GetRandomReal(0, 100) // always true, x shot speed = 372
bool b10 = udg_ThrowinMode == 0 || udg_ThrowinMode == whichKeeper
bool b11 = udg_WhichKeeperHasBall == 0
if mode == OUT_SIMPLE_THROW
return b2 && b3 && b4 && b5 && b6 && b10 && b11
else
return b1 && b3 && b4 && b5 && b6 && b7 && b8 && b10
endif
endfunction
function KeeperOutsideBox takes int whichKeeper returns bool
bool b1 = not RectContainsUnit(udg_PenaltyArea[whichKeeper], udg_Keeper[whichKeeper])
bool b2 = udg_WhichKeeperHasBall == whichKeeper
return b1 && b2
endfunction
#define CanKeeperManipulateBall(keeper) = {
CanKeeperManipulate##Ball(keeper, IN_GET_BALL)
}
#define CanKeeperManipulateBall(keeper, mode) = {
CanKeeperManipulate##Ball(keeper, mode)
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function PlayableKeeperActions takes nothing returns nothing
// bug fix - when keeper holds the ball for too long, you can obtain the ball by running through keeper
if ( udg_BallImmuneTimer <= 5 ) and ( udg_WhichKeeperHasBall != 0 ) then
udg_BallImmuneTimer += 5
endif
// if keeper holds the ball for too long, make him shoot at center
if ( udg_KeeperBallHoldTimer <= 0 ) and ( udg_WhichKeeperHasBall != 0 ) then
call TriggerExecute( gg_trg_Keeper_Throw_Ball )
endif
endfunction
function Trig_Keeper_Actions_CantHoldBallUpdate takes int whichKeeper returns nothing
int id = whichKeeper + 12
if ( udg_CantHoldBall[id] > 0 ) then
set udg_CantHoldBall[id] -= 1
endif
endfunction
function Trig_Keeper_Actions_Actions takes nothing returns nothing
call Ensure(not udg_KeeperThrowsBall)
call Trig_Keeper_Actions_CantHoldBallUpdate(1)
call Trig_Keeper_Actions_CantHoldBallUpdate(2)
call KeeperLib_GetBall()
//call KeeperLib_MoveKeepers() // already in 0.1 period trigger
if ( not IsKeeperPlayable ) and ( udg_WhichKeeperHasBall != 0 ) and ( udg_KeeperBallHoldTimer <= 0 ) then
call TriggerExecute( gg_trg_Keeper_Throw_Ball )
endif
if ( udg_KeeperBallHoldTimer > 0 ) then
udg_KeeperBallHoldTimer -= 1
endif
if ( IsKeeperPlayable ) then
PlayableKeeperActions()
endif
endfunction
//===========================================================================
function InitTrig_Keeper_Actions takes nothing returns nothing
set gg_trg_Keeper_Actions = CreateTrigger( )
call TriggerAddAction( gg_trg_Keeper_Actions, function Trig_Keeper_Actions_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib(KeeperMovement, KeeperLib), Round
function Trig_Keeper_Movement_Conditions takes nothing returns bool
int whichKeeper = TempInt
int id = whichKeeper + 12
unit keeper = udg_Keeper[whichKeeper]
bool b1 = (not IsKeeperPlayable) || IsPlayerBot(GetOwningPlayer(keeper))
bool b2 = udg_CantHoldBall[id] <= 0
set keeper = null
return b1 && b2
endfunction
private function IsBallNearKeeper takes int whichKeeper returns bool
real keeper_x = GetUnitX(udg_Keeper[whichKeeper])
real keeper_y = GetUnitY(udg_Keeper[whichKeeper])
real ball_x = GetBallX()
real ball_y = GetBallY()
bool b1 = Abs( keeper_x - ball_x ) < 50
bool b2 = Abs( keeper_y - ball_y ) < 50
return b1 and b2
endfunction
private function IsKeeperNearDesiredPosition takes int whichKeeper returns bool
real keeper_x = GetUnitX(udg_Keeper[whichKeeper])
real keeper_y = GetUnitY(udg_Keeper[whichKeeper])
real rect_x = GetRectCenterX(udg_KeeperArea[whichKeeper])
bool b1 = Abs( keeper_x - rect_x ) < 50
bool b2 = Abs( keeper_y - udg_KeeperDefPosY ) < 50
return b1 and b2
endfunction
private function EnemyWithBallInBox takes int whichKeeper returns bool
if not RectContainsBall(udg_KeeperMoveArea[whichKeeper]) then
return false
endif
if IsUnitInTeam(udg_BallOwner, whichKeeper) then
return false
endif
return true
endfunction
private function IsFilterUnitEnemy takes void returns bool
int whichKeeper = TempInt
unit keeper = Keeper[whichKeeper]
return IsUnitEnemyExt(GetFilterUnit(), keeper)
endfunction
private int CountEnemiesInPenaltyArea(int whichKeeper) {
set TempInt = whichKeeper
conditionfunc cond = Condition(function IsFilterUnitEnemy)
group g = GetUnitsInRectMatching(udg_PenaltyArea[whichKeeper], cond)
return countg(g)
}
private bool ShallMoveToBall(int whichKeeper) {
bool b1 = not Ball_IsInRect(udg_PenaltyArea[whichKeeper])
bool b2 = IsUnitInTeam(BallOwner, whichKeeper) //
// if ball owner == null, b2 = false, may proceed
// ball owner != null --> he must be from enemy team to continue
// ball must be in penalty zone
/*
call Ensure(BallOwner == null || IsUnitInTeam(BallOwner, whichKeeper),)
call Ensure(Ball_IsInRect(udg_PenaltyArea[whichKeeper]),)
*/
call Ensure(not (b1 || b2),)
int n_enemies = CountEnemiesInPenaltyArea(whichKeeper)
return (n_enemies <= 1)
}
function KeeperMove takes unit keeper, location loc_move returns void
// if udg_LastKeeperMoveLocation[] is within reach of loc_move, dont move keeper
int whichKeeper = GetKeeperId(keeper)
bool b1 = IsUnitInRangeLoc(keeper, loc_move, 50)
bool b2 = DistanceBetweenPoints(udg_LastKeeperMoveLocation[whichKeeper], loc_move) <= 50
bool b3 = udg_LastKeeperMoveLocation[whichKeeper] == null
//
call UnitMove(keeper, loc_move)
set udg_LastKeeperMoveLocation[whichKeeper] = loc_move
endfunction
function KeeperMoveToBall takes int whichKeeper returns void
location loc_ball = Ball_GetLoc()
real speed = Ball_GetSpeed()
/*real dist
if speed < 450
dist = speed *0.5
else
dist = speed *0.4
endif*/
real dist = speed *0.5
location loc_move = PolarProjectionBJ(loc_ball, dist, udg_BallDirection)
real loc_move_x = GetLocationX(loc_move)
real limit = 1880
// /*
if abs(loc_move_x) > limit
if loc_move_x < 0
loc_move_x = -limit
else
loc_move_x = limit
endif
real loc_move_y = GetLocationY(loc_move)
set loc_move = Location(loc_move_x,loc_move_y)
endif
// */
call KeeperMove(udg_Keeper[whichKeeper], loc_move)
endfunction
#define private RemoveLeaks(void) = {
CleanLocs(loc_move, loc_ball, loc_keeper)
}
void SetUnitFacingToFaceUnit(unit u, unit target) {
call SetUnitFacingToFaceUnitTimed(u, target, 0)
}
real sin(real degrees) {
return SinBJ(degrees)
}
private real GetKeeperMoveX(int whichKeeper) {
rect keeper_area = udg_KeeperArea[whichKeeper]
real ball_x = Ball_GetX()
real x
bool b1 = whichKeeper == 1 && IsFirstHalf()
bool b2 = whichKeeper == 2 && IsSecondHalf()
bool left_box_action = b1 || b2
bool b3 = whichKeeper == 2 && IsFirstHalf()
bool b4 = whichKeeper == 1 && IsSecondHalf()
bool right_box_action = b3 || b4
real defaultX
if KeeperAI == KEEPER_AI_CLASSIC
set defaultX = 1550
elseif KeeperAI == KEEPER_AI_IMPROVED
set defaultX = 1450
endif
if left_box_action
if ( ball_x > -1700 && ball_x < -1350 )
x = ball_x - 150 // 100?
elseif ( ball_x > -1350 )
x = -defaultX
else
x = GetRectCenterX(keeper_area)
endif
elseif right_box_action
if ( ball_x < 1700 && ball_x > 1350 )
x = ball_x + 150
elseif ( ball_x < 1350 )
x = defaultX
else
x = GetRectCenterX(keeper_area)
endif
else
x = GetRectCenterX(keeper_area)
endif
return x
}
private real GetKeeperMoveY(int whichKeeper) {
real keeper_x = GetUnitX(Keeper[whichKeeper])
set keeper_x = abs(keeper_x)
real offset = 0
if keeper_x < 1800
offset = (1800 - keeper_x) / (1800. - 1500) * (400 - 300) // keeper_x - 1500
endif
set udg_KeeperMoveY = RMinBJ(1250 - offset, udg_KeeperDefPosY) // 1280
set udg_KeeperMoveY = RMaxBJ(300 + offset, udg_KeeperMoveY) // 380
return udg_KeeperMoveY
}
private location GetKeeperMoveLoc(int whichKeeper) {
real x = GetKeeperMoveX(whichKeeper)
real y = GetKeeperMoveY(whichKeeper)
return Location(x,y)
}
function Trig_Keeper_Movement_Actions takes void returns void
int whichKeeper = TempInt
unit keeper = udg_Keeper[whichKeeper]
rect box = udg_PenaltyArea[whichKeeper]
if ShallMoveToBall(whichKeeper) {
call KeeperMoveToBall(whichKeeper)
return
}
if EnemyWithBallInBox(whichKeeper) then
if IsBallNearKeeper(whichKeeper)
if (udg_KeeperBallHoldTimer > 0) {
call SetUnitFacingToFaceUnit( keeper, Ball )
}
set udg_LastKeeperMoveLocation[whichKeeper] = null
else
call KeeperMoveToBall(whichKeeper)
endif
else
set udg_KeeperDefPosY = Ball_GetY()
if ( BallOwner == null ) {
real ball_x = Ball_GetX()
real keeper_x = GetUnitX(keeper)
real ball_facing = GetUnitFacing(Ball)
real ball_speed = Ball_GetSpeed()
if ball_speed > 100 || Ball_IsInRect(box) {
udg_KeeperDefPosY += abs(ball_x - keeper_x)*sin(ball_facing)
}
}
if IsKeeperNearDesiredPosition(whichKeeper)
call SetUnitFacingToFaceUnit( keeper, Ball )
set udg_LastKeeperMoveLocation[whichKeeper] = null
else
location loc_new = GetKeeperMoveLoc(whichKeeper)// Location(keeper_move_x, udg_KeeperMoveY)
call KeeperMove(keeper, loc_new)
endif
endif
endfunction
//===========================================================================
function InitTrig_Keeper_Movement takes void returns void
set gg_trg_Keeper_Movement = CreateTrigger( )
call TriggerAddAction( gg_trg_Keeper_Movement, function Trig_Keeper_Movement_Actions )
call TriggerAddConditionSimple( gg_trg_Keeper_Movement, function Trig_Keeper_Movement_Conditions )
endfunction
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Keeper_Get_Ball_Animation takes int whichKeeper returns nothing
call DestroyEffect( udg_BallInHandEffect )
// "Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl"
// "NewBall.mdl"
string path = "bignoanimball.mdl"
unit u = udg_Keeper[whichKeeper]
set udg_BallInHandEffect = AddSpecialEffectTarget( path, u, "hand,right" )
endfunction
function Trig_Keeper_Get_Ball_Conditions takes nothing returns boolean
int whichKeeper = TempInt
unit keeper = udg_Keeper[whichKeeper]
int id = whichKeeper + 12
bool b1 = CanKeeperManipulateBall(keeper, IN_GET_BALL)
bool b2 = udg_CantHoldBall[id] <= 0
set keeper = null
return b1 && b2
endfunction
function Trig_Keeper_Get_Ball_IsFilterUnitEnemy takes nothing returns bool
int whichKeeper = TempInt
bool b = IsUnitEnemyExt(GetFilterUnit(), udg_Keeper[whichKeeper])
return b
endfunction
void Keeper_UpdateSaves(int whichKeeper) {
set TempInt = whichKeeper
unit keeper = Keeper[whichKeeper]
conditionfunc cond = Condition(function Trig_Keeper_Get_Ball_IsFilterUnitEnemy)
int n_enemies = CountUnitsInRangeOfLocMatching( 200, Ball_GetLoc(), cond )
location loc_keeper = GetUnitLoc(keeper)
if (n_enemies > 0) || Ball_IsInRect(udg_GoalArea[whichKeeper])
{
int id = whichKeeper + 12
call PlayerIncInt(id, "saves")
int r = 100
color clr = color.create(r,r,r) //CreateById(id)
call CreateExclamatoryTextTag("Save",loc_keeper,clr)
DebugMsg("+save ")
}
}
bool BackPass(int whichKeeper) {
int lam = LastActionMade
bool b1 = lam == ACTION_SHORT_PASS
bool b2 = lam == ACTION_KICK
bool b3 = lam == ACTION_SLIDE
bool b4 = lam == ACTION_VZ
bool b5 = lam == ACTION_DROP_BALL
bool b6 = lam == ACTION_LONG_PASS
bool b = b1 || b2 || b3 || b4 || b5 || b6 // before 7.46a: b1 || b2
if IsUnitAllyExt(udg_Keeper[whichKeeper], LK)
if b
return true
//KeeperBallHoldTimer = 2 // before 7.46a: 3
endif
endif
return false
}
function Trig_Keeper_Get_Ball_Actions takes nothing returns nothing
int whichKeeper = TempInt
unit keeper = udg_Keeper[whichKeeper]
call ShowUnitHide( udg_Flag )
call Ball_Hide()
set udg_BallVZ = 0
set udg_IsBallInAir = false
call Ball_ResetHeight()
call Ball_Stop()
call Keeper_UpdateSaves(whichKeeper)
set TempInt = whichKeeper
call PassSuccessUpdate(PS_EVENT_KEEPER_GET_BALL)
call Keeper_Get_Ball_Animation(whichKeeper)
if ( not IsKeeperPlayable ) then
KeeperBallHoldTimer = 8
else
KeeperBallHoldTimer = 12
endif
if BackPass(whichKeeper)
set KeeperBallHoldTimer = 2 // before 7.46a: 3
endif
call PSLib_NullifyParams()
set udg_PassTarget = null // bug fix
set udg_BallOwner = null
set LastActionMade = 0
set udg_BallImmuneTimer = 60
set udg_WhichKeeperHasBall = whichKeeper
endfunction
//===========================================================================
function InitTrig_Keeper_Get_Ball takes nothing returns nothing
set gg_trg_Keeper_Get_Ball = CreateTrigger( )
call TriggerAddCondition( gg_trg_Keeper_Get_Ball, Condition( function Trig_Keeper_Get_Ball_Conditions ) )
call TriggerAddAction( gg_trg_Keeper_Get_Ball, function Trig_Keeper_Get_Ball_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Throw_Ball_to_Target_Conditions takes nothing returns boolean
bool b1 = GetSpellAbilityId() == SPELL_ID_KEEPER_THROW
// may cause weird bugs in debug mode (null pointer etc)
bool b21 = ( GetTriggerUnit() == udg_Keeper[1] ) and ( udg_WhichKeeperHasBall == 1 )
bool b22 = ( GetTriggerUnit() == udg_Keeper[2] ) and ( udg_WhichKeeperHasBall == 2 )
bool b23 = CanKeeperManipulateBall(GetTriggerUnit(), OUT_SIMPLE_THROW)
bool b2 = b21 or b22 or b23
int pid = GetExtendedId(GetTriggerUnit())
bool b3 = not udg_HeroInAir[pid]
return b1 && b2 && b3
endfunction
function Trig_Throw_Ball_to_Target_Actions takes nothing returns nothing
unit keeper = null
int mode = 0
// C in keeper mode when not obtaining ball
if IsKeeper(GetTriggerUnit()) && udg_WhichKeeperHasBall == 0 then
set keeper = GetTriggerUnit()
// C in keeper mode when obtaining ball or AI trigger execute
elseif udg_WhichKeeperHasBall != 0
set keeper = udg_Keeper[udg_WhichKeeperHasBall]
else
set keeper = udg_Keeper[udg_WhichKeeperHasBall]
endif
location loc_keeper = GetUnitLoc(keeper)
real angle
call DestroyEffect( udg_BallInHandEffect )
//call AddSpecialEffectTarget( "dummy.mdl", keeper, "hand,right" )
call ShowUnitShow( udg_Ball )
if not (IsKeeper(GetTriggerUnit()) && udg_WhichKeeperHasBall == 0)
call SetUnitPositionLoc( udg_Ball, loc_keeper )
endif
call ResumeTimer( udg_RoundTimer )
call ResumeTimer( udg_RealTimer )
set udg_CantEnterOtherSide = false
set udg_ThrowinMode = 0
int pid = GetExtendedId(keeper)
set udg_CantHoldBall[pid] = 2
set udg_BallOwner = null
set LastActionMade = ACTION_KEEPER_THROW
if ( udg_KeeperPassTarget == null ) then
set udg_KeeperThrowLoc = GetRectCenter(gg_rct_Center)
else
set udg_KeeperThrowLoc = GetUnitLoc(udg_KeeperPassTarget)
endif
location loc_target = GetSpellTargetLoc()
if ( loc_target != null ) then
set udg_KeeperThrowLoc = loc_target
endif
if AllyRequestsPassFromKeeper
if DistanceBetweenPoints(TempLoc, loc_keeper) > 1700
set angle = AngleBetweenPoints(loc_keeper, TempLoc)
set TempLoc = PolarProjectionBJ(loc_keeper, 1700, angle)
endif
set udg_KeeperThrowLoc = TempLoc // D "pass to me" request from an ally
endif
set LP = keeper
if ( LK != keeper ) then
L2K = LK
LK = keeper
endif
//call UpdateLK()
//set LK = LP
set udg_PassTarget = null
set udg_KeeperThrowsBall = true
set AllyRequestsPassFromKeeper = false
call SetUnitFacingToFaceLocTimed( udg_Keeper[udg_WhichKeeperHasBall], GetPitchCenter(), 0 )
call SetUnitAnimation( udg_Keeper[udg_WhichKeeperHasBall], "attack" )
call ShowUnitShow( udg_Flag )
set udg_BallImmuneTimer = 7 // 0.7 sec
set udg_IsBallInAir = true
set udg_BallDirection = AngleBetweenPoints(GetBallLoc(), udg_KeeperThrowLoc)
call SetUnitFacingTimed( udg_Keeper[udg_WhichKeeperHasBall], udg_BallDirection, 0 )
int id = GetKeeperId(keeper)
if IsUnitInRect(keeper, udg_PenaltyArea[id])
set udg_TempReal = 40
set udg_BallVZ = 0.5 * udg_G * DistanceBetweenPoints(GetUnitLoc(udg_Ball), udg_KeeperThrowLoc) / udg_TempReal
if ( IsKeeperPlayable ) then
set udg_BallVZ = RMinBJ(udg_BallVZ, 45)
endif
call PlaySoundOnUnitBJ( gg_snd_Throw, 100, keeper ) //udg_BallOwner
else
// classic long pass
set LastActionMade = ACTION_KEEPER_LONG_PASS
call Long_Pass_Calculate_Speed_and_vy()
call PlaySoundOnUnitBJ( gg_snd_Kick, 100, keeper ) //udg_BallOwner
endif
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
//call TriggerExecute(gg_trg_Common_Actions_for_shoot)
call RunBallGeneralAnimations()
if udg_ThrowinMode == 0
set udg_IndirectFreeKick = false
endif
set udg_WhichKeeperHasBall = 0
call PolledWait(1)
set udg_KeeperThrowsBall = false
endfunction
//===========================================================================
function InitTrig_Keeper_Throw_Ball takes nothing returns nothing
set gg_trg_Keeper_Throw_Ball = CreateTrigger( )
call TriggerAddCondition( gg_trg_Keeper_Throw_Ball, Condition(function Trig_Throw_Ball_to_Target_Conditions) )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Keeper_Throw_Ball, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddAction( gg_trg_Keeper_Throw_Ball, function Trig_Throw_Ball_to_Target_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function SetKeeperOwnership takes player p, int team returns nothing
int pid = GetConvertedPlayerId(p)
if not (InTesting && p == morganxl)
call ShowUnitHide(udg_Hero[pid])
call SetUnitPositionLoc(udg_Hero[pid], GetPitchCenter())
endif
call SetUnitOwner(udg_Keeper[team], p, true)
endfunction
function Trig_Initialize_Keepers_Main takes integer team returns nothing
// non-conv player ids
int pid_first, pid_last
local integer pid_i
local player p
if udg_NextKeeperController[team] != null then
set p = udg_NextKeeperController[team]
call SetKeeperOwnership( p, team )
return
endif
if team == 1 then
set pid_first = 0
set pid_last = 5
else
set pid_first = 6
set pid_last = 11
endif
set pid_i = pid_first
bool b
whilenot ( pid_i > pid_last ) {
set p = Player(pid_i)
set b = IsPlayerPlaying(p) && (Hero[pid_i+1] != BallOwner) && IsPlayerInTeam(p,team)
/*
set b = IsPlayerStatePlaying(p)
set b = b and GetPlayerController(p) == MAP_CONTROL_USER
set b = b and not IsPlayerInForce(p, Observers)
b = b && (GetHero(p) != udg_BallOwner)
*/
exitwhen b
pid_i++
}
call SetKeeperOwnership( p, team )
endfunction
function Trig_Initialize_Keepers_Actions takes nothing returns nothing
Ensure( IsKeeperPlayable )
call Trig_Initialize_Keepers_Main(1)
call Trig_Initialize_Keepers_Main(2)
endfunction
//===========================================================================
function InitTrig_Initialize_Keepers takes nothing returns nothing
set gg_trg_Initialize_Keepers = CreateTrigger( )
call TriggerAddAction( gg_trg_Initialize_Keepers, function Trig_Initialize_Keepers_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Keeper_Speed_Conditions takes int whichKeeper returns bool
unit keeper = udg_Keeper[whichKeeper]
rect box = udg_PenaltyArea[whichKeeper]
bool b1 = not IsUnitInRect(keeper, box)
bool b2 = true
return b1 && b2
endfunction
function Trig_Keeper_Speed_Main takes int whichKeeper returns nothing
unit keeper = udg_Keeper[whichKeeper]
rect box = udg_PenaltyArea[whichKeeper]
location loc_keeper = GetUnitLoc(keeper)
location loc_box = GetRectCenter(box)
location loc_center = GetPitchCenter()
real dist_main = DistanceBetweenPoints(loc_center, loc_box)
real dist_keeper = DistanceBetweenPoints(loc_keeper, loc_box)
real ratio = dist_keeper/dist_main
real speed_new = 200 + ratio*(290-200)
set speed_new = RMaxBJ(200, speed_new)
set speed_new = RMinBJ(290, speed_new)
call SetUnitMoveSpeed(keeper, speed_new)
call CleanLocs(loc_keeper, loc_box, loc_center)
endfunction
function Trig_Keeper_Speed_Actions takes nothing returns nothing
if Trig_Keeper_Speed_Conditions(1)
call Trig_Keeper_Speed_Main(1)
endif
if Trig_Keeper_Speed_Conditions(2)
call Trig_Keeper_Speed_Main(2)
endif
endfunction
//===========================================================================
function InitTrig_Keeper_Speed takes nothing returns nothing
set gg_trg_Keeper_Speed = CreateTrigger( )
call TriggerAddAction( gg_trg_Keeper_Speed, function Trig_Keeper_Speed_Actions )
//call TriggerAddConditionSimple( gg_trg_Keeper_Speed, function Trig_Keeper_Speed_Conditions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Fix_Keeper_Position_Actions takes nothing returns nothing
integer team
if KeeperOutsideBox(1) then
team = 1
elseif KeeperOutsideBox(2) then
team = 2
endif
location loc_keeper = GetUnitLoc(udg_Keeper[team])
location loc_center = GetRectCenter(udg_PenaltyArea[team])
real direction = AngleBetweenPoints( loc_keeper, loc_center )
real dist = 100
location loc_keeper_new = PolarProjectionBJ( loc_keeper, dist, direction)
call SetUnitPositionLoc( udg_Keeper[team], loc_keeper_new)
call CleanLocs(loc_keeper, loc_keeper_new, loc_center)
endfunction
//===========================================================================
function InitTrig_Fix_Keeper_Position takes nothing returns nothing
set gg_trg_Fix_Keeper_Position = CreateTrigger( )
call TriggerAddAction( gg_trg_Fix_Keeper_Position, function Trig_Fix_Keeper_Position_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Nominate_Keeper_ResetArray takes nothing returns nothing
int i = 0
whilenot i > 12 {
set udg_KeeperVotes[i] = false
i++
}
endfunction
function Trig_Nominate_Keeper_Conditions takes nothing returns bool
bool b1 = true
bool b2 = udg_Round >= 0
int pid_initiator = GetConvertedPlayerId(GetTriggerPlayer())
bool b3 = udg_nKeeperVotingAttempts[pid_initiator] < 4
string chat_str = GetEventPlayerChatString()
int len = StringLength(chat_str)
bool b4 = len > 9 // "-votekick color/name"
if not ( b1 && b2 && b3 && b4 )
return false
endif
string specifier = SubStringBJ(chat_str, 11, len)
int pid
/*
player p = GetPlayerBySpecifier(specifier)
if IsNull(p)
echoln (GetTriggerPlayer(), "Incorrect syntax. To specify a player, use color or nickname.")
return false
endif
int pid = GetPlayerId(p)
*/
if specifier == "0" || specifier == "none" || specifier=="default" || specifier == "normal"
set pid = -1
elseif specifier == GetPlayerNameById(0) || specifier == "red" || specifier == "1"
set pid = 0
elseif specifier == GetPlayerNameById(1) || specifier == "blue" || specifier == "2"
set pid = 1
elseif specifier == GetPlayerNameById(2) || specifier == "teal" || specifier == "cyan" || specifier == "3"
set pid = 2
elseif specifier == GetPlayerNameById(3) || specifier == "purple" || specifier == "4"
set pid = 3
elseif specifier == GetPlayerNameById(4) || specifier == "yellow" || specifier == "5"
set pid = 4
elseif specifier == GetPlayerNameById(5) || specifier == "orange" || specifier == "6"
set pid = 5
elseif specifier == GetPlayerNameById(6) || specifier == "green" || specifier == "7"
set pid = 6
elseif specifier == GetPlayerNameById(7) || specifier == "pink" || specifier == "8"
set pid = 7
elseif specifier == GetPlayerNameById(8) || specifier == "gray" || specifier == "grey" || \
specifier == "lightgray" || specifier == "lightgrey" || specifier == "9"
set pid = 8
elseif specifier == GetPlayerNameById(9) || specifier == "white" || specifier == "lightblue" || specifier == "10"
set pid = 9
elseif specifier == GetPlayerNameById(10) || specifier == "darkgreen" || specifier == "aqua" || specifier == "11"
set pid = 10
elseif specifier == GetPlayerNameById(11) || specifier == "brown" || specifier == "12"
set pid = 11
else
echoln (GetTriggerPlayer(), "Incorrect syntax. To specify a player, use color, player number, or nickname.")
return false
endif
int team = GetTeamNumberByPid(pid_initiator)
bool b10 = not udg_KeeperVotingPending[team]
if pid == -1 && b10
set TempInt = pid
return true
endif
player p = Player(pid)
bool b11 = IsPlayerAlly( p, GetTriggerPlayer() )
bool b12 = not IsPlayerBot(p)
bool b13 = not IsPlayerObs(p)
bool b14 = IsPlayerPlaying(p)
if not (b10 && b11 && b12 && b13 && b14)
return false
endif
set TempInt = pid
return true
endfunction
function Trig_Nominate_Keeper_Actions takes nothing returns nothing
player p
int pid_i, pid_last, pid
int nvoters = 0, votes_yes = 0, votes_needed
int pid_nominee = TempInt
int cpid = pid_nominee + 1
set pid = GetConvertedPlayerId(GetTriggerPlayer())
int team = GetTeamNumberByPid(pid)
set udg_KeeperVotingPending[team] = true
udg_nKeeperVotingAttempts[pid] += 1
if cpid > 0
echo( udg_PlayerNames[cpid] + " is nominated as keeper. Type -agree to vote.")
else
echo("Initiated voting for normal keeper rotation. Type -agree to vote.")
endif
if InTesting
call Sleep(5)
else
call Sleep(20)
endif
set pid_i = 0
set pid_last = 11
whilenot pid_i > pid_last
{
set p = Player(pid_i)
if IsPlayerStatePlaying(p) && not IsPlayerObs(p) && IsPlayerInTeam(p, team) && not IsPlayerBot(p)
++nvoters
if udg_KeeperVotes[pid_i + 1]
++votes_yes
endif
endif
++pid_i
}
if nvoters <= 1
set votes_needed = 1
elseif nvoters <= 4
set votes_needed = 2
else
set votes_needed = 3
endif
call Trig_Nominate_Keeper_ResetArray()
string figures = " ("+I2S(votes_needed)+")"
if ( votes_yes >= votes_needed )
if cpid > 0
set udg_NextKeeperController[team] = Player(pid_nominee)
echo ("Set new keeper for team "+I2S(team)+".")
else
set udg_NextKeeperController[team] = null
echo ("Normal keeper rotation enabled, team "+I2S(team)+".")
endif
//
else
echo ("Not enough votes, team "+I2S(team)+figures+".")
endif
set udg_KeeperVotingPending[team] = false
endfunction
//===========================================================================
function InitTrig_Nominate_Keeper takes nothing returns nothing
set gg_trg_Nominate_Keeper = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Nominate_Keeper, "-nominate ", false )
call TriggerAddCondition( gg_trg_Nominate_Keeper, Condition(function Trig_Nominate_Keeper_Conditions) )
call TriggerAddAction( gg_trg_Nominate_Keeper, function Trig_Nominate_Keeper_Actions )
set udg_KeeperVotingPending[1] = false
set udg_KeeperVotingPending[2] = false
set udg_NextKeeperController[1] = null
set udg_NextKeeperController[2] = null
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Player_voted_Conditions takes nothing returns boolean
bool b1 = udg_KeeperVotingPending[1]
bool b2 = udg_KeeperVotingPending[2]
return b1 || b2
endfunction
function Trig_Player_voted_Actions takes nothing returns nothing
local string chat_str = GetEventPlayerChatString()
local integer pid = GetConvertedPlayerId(GetTriggerPlayer())
//call ForceAddPlayer(Votekickers, GetTriggerPlayer())
set udg_KeeperVotes[pid] = ( chat_str == "-agree" )
echo(GetTriggerPlayer(), "Vote counted.")
endfunction
//===========================================================================
function InitTrig_Player_voted takes nothing returns nothing
set gg_trg_Player_voted = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Player_voted, "-agree", true )
call TriggerAddCondition( gg_trg_Player_voted, Condition(function Trig_Player_voted_Conditions) )
call TriggerAddAction( gg_trg_Player_voted, function Trig_Player_voted_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib (ModesLib, StdLib)
globals
enum (mode_status) {
MODE_STATUS_DISABLED
MODE_STATUS_ENABLED
MODE_STATUS_VOTING
}
enum (mode_action) {
MODE_ACTION_DO_NOTHING
MODE_ACTION_ENABLE
MODE_ACTION_DISABLE
MODE_ACTION_VOTE_YES
MODE_ACTION_VOTE_NO
}
constant int MODE_VOTING_TIME_STANDARD = 25
endglobals
function Trig_Mode_curve2_ActionsOnEnable takes nothing returns nothing
set CurvedBall = true
set CURVE_STATUS = CURVE_SINGLE_HKEY
call AddAbilityToAll(ABILITY_SINGLE_HKEY_CURVE)
endfunction
function Trig_Mode_Easy_ActionsOnEnable takes nothing returns nothing
set EasyMode = true
call HintsLib_DisplayToAll()
if PublicVersion {
call Ball_SwitchModelTo(BALL_BRAZUCA)
}
set CGoalsBan = false
call Trig_Mode_curve2_ActionsOnEnable()
set KeeperAI = KEEPER_AI_CLASSIC
set KEEPER_GET_BALL_RANGE = KEEPER_GET_BALL_RANGE_REDUCED
// Allow C goals
// set KeeperAI = KEEPER_AI_CLASSIC // old keeper AI
// faster ball owner movement // set BO_SpeedPenalty = 45
// 5-7.5 mins per half
// enable curve, 30 degrees
endfunction
public function Init takes nothing returns nothing
call Trig_Mode_curve2_ActionsOnEnable()
if PublicVersion
call Trig_Mode_Easy_ActionsOnEnable()
endif
endfunction
#define ModesLib_ActionsOnEnable (mode) = {
void Mode_ActionsOnEnable_##mode() {}
}
#define ModesLib_GetYesVotes (mode) = {
void Mode_GetYesVotes_##mode() {
return CountPlayersInForceBJ(Mode_Voters_##mode)
}
}
#define ModesLib_Globals (mode) = {
int Mode_##mode = MODE_STATUS_DISABLED
force Mode_Voters_##mode = CreateForce()
string Mode_MsgOnEnable_##mode = "Now you can do specific dummy stuff."
string Mode_VotingStartMsg_##mode = "Voting for Dummy Mode started. "
}
public function StandardVotingConditions takes player p returns boolean
bool b1 = IsPlayerPlayingObs(p)
bool b2 = not IsPlayerBot(p)
bool b3 = not IsPlayerObserver(p)
bool b4 = true
return b1 and b2 and b3 and b4
endfunction
public function GetAllVotesFilter takes nothing returns boolean
return ModesLib_StandardVotingConditions(GetFilterPlayer())
endfunction
public function GetAllVotes takes nothing returns int
force f = GetPlayersMatching(Condition(function ModesLib_GetAllVotesFilter))
int n = CountPlayersInForceBJ(f)
return n
endfunction
public function StandardInitiatingConditions takes nothing returns boolean
bool b1 = udg_Round >= 0 and udg_Round <= 2
bool b2 = true
bool b3 = true
bool b4 = true
return b1 and b2 and b3 and b4
endfunction
function IsModeEnabled takes int status returns boolean
return status == MODE_STATUS_ENABLED
endfunction
function IsModeDisabled takes int status returns boolean
return status == MODE_STATUS_DISABLED
endfunction
function IsModeInVoting takes int status returns boolean
return status == MODE_STATUS_VOTING
endfunction
public function EnableIfPossibleAbstracted takes bool EarlyRun, bool InitConditions, \
int votes_yes, int votes_needed, int votes_all returns int // status_new
int mode = MODE_STATUS_VOTING
string output = I2S(votes_yes)+"/"+I2S(votes_all)+": "
bool enoughVotes = votes_yes >= votes_needed
if enoughVotes && InitConditions
set mode = MODE_STATUS_ENABLED // !
output += "enabled."
echo(output)
endif
if EarlyRun || IsModeEnabled(mode)
return mode
endif
// Final actions [error msg, no enable]
if not InitConditions
output += "mode cannot be enabled."
elseif ( not enoughVotes )
output += "not enough votes ("+I2S(votes_needed)+")."
endif
set mode = MODE_STATUS_DISABLED
echo(output)
return mode
endfunction
public function GetNeededVotes takes int votes_all returns int
if votes_all <= 2
return votes_all
endif
int k = votes_all/2
return k + 1
endfunction
#define ModesLib_EnableIfPossible (mode) = {
void Mode_EnableIfPossible_##mode (bool EarlyRun) {
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Mode_GetYesVotes_##mode()
bool InitConditions = ModesLib_StandardInitiatingConditions()
// !global variable used!
set Mode_##mode = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_##)
echo(Mode_MsgOnEnable_##mode)
call Mode_ActionsOnEnable_##mode()
// Do not clear force here
return
endif
}
}
#define ModesLib_Actions (mode) = {
void Mode_Actions_##mode () {
call Ensure( not IsModeEnabled(Mode_##mode) )
//|| not EventStringExactMatch()
int action
if IsModeInVoting(Mode_##mode) then
set action = MODE_ACTION_VOTE_YES
elseif IsModeDisabled(Mode_##mode) then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_##mode()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_##mode()
endif
}
}
#define ModesLib_InitiateMode (mode) = {
void InitiateMode_##mode () {
trigger mode_##mode = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( mode_##mode, "-dummy", true )
call TriggerAddAction( mode_##mode, function Mode_Actions_##mode )
}
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_Dummy = MODE_STATUS_DISABLED
force Mode_Dummy_Voters = CreateForce() // Mode_Voters_Dummy
boolean Mode_Dummy_CanBeReused = false
string Mode_Dummy_MsgOnEnable = "Now you can do specific dummy stuff."
string Mode_Dummy_VotingStartMsg = "Voting to initiate Dummy Mode started. "
endglobals
function Trig_Mode_Dummy_ActionsOnEnable takes nothing returns nothing
endfunction
function Trig_Mode_Dummy_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_Dummy_Voters)
endfunction
function Trig_Mode_Dummy_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_Dummy_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_Dummy = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_Dummy)
echo(Mode_Dummy_MsgOnEnable)
call Trig_Mode_Dummy_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_Dummy () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_Dummy_Voters)
if b1 && b2
call ForceAddPlayer(Mode_Dummy_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_Dummy_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_Dummy () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_Dummy_Voters)
set Mode_Dummy = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_Dummy_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_Dummy) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_Dummy != MODE_STATUS_ENABLED then
// do not have to attempt intiating at the end, as it is done automatically after each vote
call Trig_Mode_Dummy_EnableIfPossible(false)
endif
//If there is a need to rerun the mode, uncomment line below
if Mode_Dummy_CanBeReused
set Mode_Dummy = MODE_STATUS_DISABLED
endif
}
function Trig_Mode_Dummy_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_Dummy) )
//|| not EventStringExactMatch()
int action
if Mode_Dummy == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_Dummy == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_Dummy()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_Dummy()
endif
endfunction
//===========================================================================
function InitTrig_Mode_Dummy takes nothing returns nothing
set gg_trg_Mode_Dummy = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_Dummy, "-dummy", true )
call TriggerAddAction( gg_trg_Mode_Dummy, function Trig_Mode_Dummy_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_Easy = MODE_STATUS_DISABLED
force Mode_Easy_Voters = CreateForce() // Mode_Voters_Easy
string Mode_Easy_MsgOnEnable = "Easy mode enabled (allowed C goals, inferior keepers, etc)."
string Mode_Easy_VotingStartMsg = "Voting to initiate Easy Mode started (recommended for new players). "
endglobals
function Trig_Mode_Easy_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_Easy_Voters)
endfunction
function Trig_Mode_Easy_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_Easy_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_Easy = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_Easy)
echo(Mode_Easy_MsgOnEnable)
call Trig_Mode_Easy_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_Easy () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_Easy_Voters)
if b1 && b2
call ForceAddPlayer(Mode_Easy_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_Easy_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_Easy () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_Easy_Voters)
set Mode_Easy = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_Easy_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_Easy) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_Easy != MODE_STATUS_ENABLED then
// do not have to attempt intiating at the end, as it is done automatically after each vote
//call Trig_Mode_Easy_EnableIfPossible(false)
endif
}
function Trig_Mode_Easy_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_Easy) )
//|| not EventStringExactMatch()
int action
if Mode_Easy == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_Easy == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_Easy()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_Easy()
endif
endfunction
//===========================================================================
function InitTrig_Mode_Easy takes nothing returns nothing
set gg_trg_Mode_Easy = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_Easy, "-easy", true )
call TriggerAddAction( gg_trg_Mode_Easy, function Trig_Mode_Easy_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_hard = MODE_STATUS_DISABLED
force Mode_hard_Voters = CreateForce() // Mode_Voters_hard
string Mode_hard_MsgOnEnable = "Pro/Hard mode enabled."
string Mode_hard_VotingStartMsg = "Voting to initiate Pro/Hard mode started (for experienced players). "
endglobals
function Trig_Mode_hard_ActionsOnEnable takes nothing returns nothing
set EasyMode = false
set CGoalsBan = true
set KeeperAI = KEEPER_AI_IMPROVED
set KEEPER_GET_BALL_RANGE = KEEPER_GET_BALL_RANGE_NORMAL
call HintsLib_StopDisplayingToAll()
call Ball_SwitchModelTo(BALL_CLASSIC)
//call Trig_Mode_curve2_ActionsOnEnable()
//set MAX_CURVE_ANGLE = 32.
endfunction
function Trig_Mode_hard_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_hard_Voters)
endfunction
function Trig_Mode_hard_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_hard_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_hard = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_hard)
echo(Mode_hard_MsgOnEnable)
call Trig_Mode_hard_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_hard () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_hard_Voters)
if b1 && b2
call ForceAddPlayer(Mode_hard_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_hard_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_hard () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_hard_Voters)
set Mode_hard = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_hard_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_Hard) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_hard != MODE_STATUS_ENABLED then
// do not have to attempt intiating at the end, as it is done automatically after each vote
//call Trig_Mode_hard_EnableIfPossible(false)
endif
}
function Trig_Mode_hard_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_hard) )
//|| not EventStringExactMatch()
int action
if Mode_hard == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_hard == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_hard()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_hard()
endif
endfunction
//===========================================================================
function InitTrig_Mode_Hard takes nothing returns nothing
set gg_trg_Mode_Hard = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_Hard, "-hard","-pro", true )
call TriggerAddAction( gg_trg_Mode_Hard, function Trig_Mode_hard_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_shorten = MODE_STATUS_DISABLED
force Mode_shorten_Voters = CreateForce() // Mode_Voters_shorten
string Mode_shorten_MsgOnEnable = "Shortened match by a few minutes."
string Mode_shorten_VotingStartMsg = "Voting to shorten match by 4 minutes started. "
endglobals
function Trig_Mode_shorten_ActionsOnEnable takes nothing returns nothing
call TimerSubtractMain(240)
endfunction
function Trig_Mode_shorten_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_shorten_Voters)
endfunction
function Trig_Mode_shorten_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_shorten_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_shorten = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_shorten)
echo(Mode_shorten_MsgOnEnable)
call Trig_Mode_shorten_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_shorten () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_shorten_Voters)
if b1 && b2
call ForceAddPlayer(Mode_shorten_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_shorten_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_shorten () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_shorten_Voters)
set Mode_shorten = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_shorten_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_shorten) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_shorten != MODE_STATUS_ENABLED then
// do not have to attempt intiating at the end, as it is done automatically after each vote
call Trig_Mode_shorten_EnableIfPossible(false)
endif
set Mode_shorten = MODE_STATUS_DISABLED // to be rerun
}
function Trig_Mode_shorten_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_shorten) )
//|| not EventStringExactMatch()
int action
if Mode_shorten == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_shorten == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_shorten()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_shorten()
endif
endfunction
//===========================================================================
function InitTrig_Mode_shorten takes nothing returns nothing
set gg_trg_Mode_shorten = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_shorten, "-shorten", true )
call TriggerAddAction( gg_trg_Mode_shorten, function Trig_Mode_shorten_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_lengthen = MODE_STATUS_DISABLED
force Mode_lengthen_Voters = CreateForce() // Mode_Voters_lengthen
string Mode_lengthen_MsgOnEnable = "Prolonged match by a few minutes."
string Mode_lengthen_VotingStartMsg = "Voting to prolong match by 5 minutes started. "
endglobals
function Trig_Mode_lengthen_ActionsOnEnable takes nothing returns nothing
call TimerAddMain(300)
endfunction
function Trig_Mode_lengthen_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_lengthen_Voters)
endfunction
function Trig_Mode_lengthen_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_lengthen_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_lengthen = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_lengthen)
echo(Mode_lengthen_MsgOnEnable)
call Trig_Mode_lengthen_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_lengthen () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_lengthen_Voters)
if b1 && b2
call ForceAddPlayer(Mode_lengthen_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_lengthen_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_lengthen () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_lengthen_Voters)
set Mode_lengthen = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_lengthen_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_lengthen) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_lengthen != MODE_STATUS_ENABLED then
// do not have to attempt intiating at the end, as it is done automatically after each vote
call Trig_Mode_lengthen_EnableIfPossible(false)
endif
set Mode_lengthen = MODE_STATUS_DISABLED // to be rerun
}
function Trig_Mode_lengthen_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_lengthen) )
//|| not EventStringExactMatch()
int action
if Mode_lengthen == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_lengthen == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_lengthen()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_lengthen()
endif
endfunction
//===========================================================================
function InitTrig_Mode_lengthen takes nothing returns nothing
set gg_trg_Mode_lengthen = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_lengthen, "-lengthen","-prolong", true )
call TriggerAddAction( gg_trg_Mode_lengthen, function Trig_Mode_lengthen_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_shorten_cmd_Actions takes nothing returns nothing
Ensure(IsUserMorgan())
string str = GetEventPlayerChatString()
string pattern = GetEventPlayerChatStringMatched()
integer strlen = StringLength(str)
integer patlen = StringLength(pattern)
real mins = S2R(SubStringBJ(str, patlen+1+1, strlen))
real s = mins*60
if pattern == "-minus"
call TimerSubtractMain(s)
elseif pattern == "-plus"
call TimerAddMain(s)
endif
endfunction
//===========================================================================
function InitTrig_minus_plus_cmd takes nothing returns nothing
set gg_trg_minus_plus_cmd = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_minus_plus_cmd, "-minus","-plus", false )
call TriggerAddAction( gg_trg_minus_plus_cmd, function Trig_shorten_cmd_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_nocurve_msg_Actions takes nothing returns nothing
call AllPlayersRemoveAbil(ABILITY_SINGLE_HKEY_CURVE)
endfunction
//===========================================================================
function InitTrig_nocurve_msg takes nothing returns nothing
set gg_trg_nocurve_msg = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_nocurve_msg, "-nocurve", true )
call TriggerAddAction( gg_trg_nocurve_msg, function Trig_nocurve_msg_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_nocurve = MODE_STATUS_DISABLED
force Mode_nocurve_Voters = CreateForce() // Mode_Voters_nocurve
string Mode_nocurve_MsgOnEnable = "Curve ability removed."
string Mode_nocurve_VotingStartMsg = "Voting to disable Curve started. "
endglobals
function Trig_Mode_nocurve_ActionsOnEnable takes nothing returns nothing
call AllPlayersRemoveAbil(ABILITY_SINGLE_HKEY_CURVE)
endfunction
function Trig_Mode_nocurve_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_nocurve_Voters)
endfunction
function Trig_Mode_nocurve_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_nocurve_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_nocurve = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_nocurve)
echo(Mode_nocurve_MsgOnEnable)
call Trig_Mode_nocurve_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_nocurve () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_nocurve_Voters)
if b1 && b2
call ForceAddPlayer(Mode_nocurve_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_nocurve_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_nocurve () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_nocurve_Voters)
set Mode_nocurve = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_nocurve_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_nocurve) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_nocurve != MODE_STATUS_ENABLED then
// do not have to attempt intiating at the end, as it is done automatically after each vote
call Trig_Mode_nocurve_EnableIfPossible(false)
endif
}
function Trig_Mode_nocurve_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_nocurve) )
//|| not EventStringExactMatch()
int action
if Mode_nocurve == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_nocurve == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_nocurve()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_nocurve()
endif
endfunction
//===========================================================================
function InitTrig_Mode_nocurve takes nothing returns nothing
set gg_trg_Mode_nocurve = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_nocurve, "-nocurve", true )
call TriggerAddAction( gg_trg_Mode_nocurve, function Trig_Mode_nocurve_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_Ball = MODE_STATUS_DISABLED
force Mode_Ball_Voters = CreateForce() // Mode_Voters_Ball
string Mode_Ball_MsgOnEnable = "To revert to previous ball, write -ball."
string Mode_Ball_VotingStartMsg = "Voting to change ball model started. "
endglobals
function Trig_Mode_Ball_ActionsOnEnable takes nothing returns nothing
call Ball_SwitchModel()
set Mode_Ball = MODE_STATUS_DISABLED
endfunction
function Trig_Mode_Ball_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_Ball_Voters)
endfunction
function Trig_Mode_Ball_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_Ball_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_Ball = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_Ball)
echo(Mode_Ball_MsgOnEnable)
call Trig_Mode_Ball_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_Ball () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_Ball_Voters)
if b1 && b2
call ForceAddPlayer(Mode_Ball_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_Ball_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_Ball () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_Ball_Voters)
set Mode_Ball = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_Ball_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_Ball) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_Ball != MODE_STATUS_ENABLED then
//call Trig_Mode_Ball_EnableIfPossible(false)
endif
}
function Trig_Mode_Ball_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_Ball) )
//|| not EventStringExactMatch()
int action
if Mode_Ball == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_Ball == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_Ball()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_Ball()
endif
endfunction
//===========================================================================
function InitTrig_Mode_Ball takes nothing returns nothing
set gg_trg_Mode_Ball = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_Ball, "-ball", true )
call TriggerAddAction( gg_trg_Mode_Ball, function Trig_Mode_Ball_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_curve2 = MODE_STATUS_DISABLED
force Mode_curve2_Voters = CreateForce() // Mode_Voters_curve2
string Mode_curve2_MsgOnEnable = "Press "+Orange("G")+" once for left curve, double-press for right curve."
string Mode_curve2_VotingStartMsg = "Voting to initiate single hotkey curve started. "
endglobals
function Trig_Mode_curve2_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_curve2_Voters)
endfunction
function Trig_Mode_curve2_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_curve2_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_curve2 = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_curve2)
echo(Mode_curve2_MsgOnEnable)
call Trig_Mode_curve2_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_curve2 () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_curve2_Voters)
if b1 && b2
call ForceAddPlayer(Mode_curve2_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_curve2_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_curve2 () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_curve2_Voters)
set Mode_curve2 = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_curve2_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_curve2) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_curve2 != MODE_STATUS_ENABLED then
call Trig_Mode_curve2_EnableIfPossible(false)
endif
}
function Trig_Mode_curve2_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_curve2) )
//|| not EventStringExactMatch()
int action
if Mode_curve2 == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_curve2 == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_curve2()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_curve2()
endif
endfunction
//===========================================================================
function InitTrig_Mode_curve2 takes nothing returns nothing
set gg_trg_Mode_curve2 = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_curve2, "-curve", true )
call TriggerAddAction( gg_trg_Mode_curve2, function Trig_Mode_curve2_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_curve = MODE_STATUS_DISABLED
force Mode_curve_Voters = CreateForce() // Mode_Voters_curve
string Mode_curve_MsgOnEnable = "Use F/G to set curving angle."
string Mode_curve_VotingStartMsg = "Voting to initiate curved ball started. "
endglobals
function Trig_Mode_curve_ActionsOnEnable takes nothing returns nothing
set CurvedBall = true
set CURVE_STATUS = CURVE_CLASSIC
//call AllPlayersExchangeAbils(ABILITY_PASS_TO_ME, ABILITY_PASS_TO_ME_B)
call AddAbilityToAll(ABILITY_LEFT_CURVE)
call AddAbilityToAll(ABILITY_RIGHT_CURVE)
//echo("'Pass to me' hotkey changed to B.")
echo("Warning: curve is incompatible with -train mode, fakie, etc.")
endfunction
function Trig_Mode_curve_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_curve_Voters)
endfunction
function Trig_Mode_curve_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_curve_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_curve = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_curve)
echo(Mode_curve_MsgOnEnable)
call Trig_Mode_curve_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_curve () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_curve_Voters)
if b1 && b2
call ForceAddPlayer(Mode_curve_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_curve_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_curve () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_curve_Voters)
set Mode_curve = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_curve_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_curve) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_curve != MODE_STATUS_ENABLED then
call Trig_Mode_curve_EnableIfPossible(false)
endif
}
function Trig_Mode_curve_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_curve) )
//|| not EventStringExactMatch()
int action
if Mode_curve == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_curve == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_curve()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_curve()
endif
endfunction
//===========================================================================
function InitTrig_Mode_curve takes nothing returns nothing
set gg_trg_Mode_curve = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_curve, "-curve2", true )
call TriggerAddAction( gg_trg_Mode_curve, function Trig_Mode_curve_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_nogoal = MODE_STATUS_DISABLED
force Mode_nogoal_Voters = CreateForce() // Mode_Voters_nogoal
string Mode_nogoal_MsgOnEnable = "Now you can do specific nogoal stuff."
string Mode_nogoal_VotingStartMsg = "Voting to initiate nogoal Mode started. "
endglobals
function Trig_Mode_nogoal_ActionsOnEnable takes nothing returns nothing
set NoGoals = true
call Keeper_Hide(1)
call Keeper_Hide(2)
endfunction
function Trig_Mode_nogoal_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_nogoal_Voters)
endfunction
function Trig_Mode_nogoal_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_nogoal_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_nogoal = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_nogoal)
echo(Mode_nogoal_MsgOnEnable)
call Trig_Mode_nogoal_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_nogoal () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_nogoal_Voters)
if b1 && b2
call ForceAddPlayer(Mode_nogoal_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_nogoal_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_nogoal () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_nogoal_Voters)
set Mode_nogoal = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_nogoal_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_nogoal) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_nogoal != MODE_STATUS_ENABLED then
call Trig_Mode_nogoal_EnableIfPossible(false)
endif
}
function Trig_Mode_nogoal_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_nogoal) )
//|| not EventStringExactMatch()
int action
if Mode_nogoal == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_nogoal == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_nogoal()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_nogoal()
endif
endfunction
//===========================================================================
function InitTrig_Mode_nogoal takes nothing returns nothing
set gg_trg_Mode_nogoal = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_nogoal, "-nogoal", "-nogoals", true )
call TriggerAddAction( gg_trg_Mode_nogoal, function Trig_Mode_nogoal_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_smooth = MODE_STATUS_DISABLED
force Mode_smooth_Voters = CreateForce() // Mode_Voters_smooth
string Mode_smooth_MsgOnEnable = "Smooth ball in front of ball owner enabled."
string Mode_smooth_VotingStartMsg = "This mode will enable smooth ball update in front of ball owner. Voting started. "
endglobals
function Trig_Mode_smooth_ActionsOnEnable takes nothing returns nothing
//set ContinuousBallUpdate = true
set PartialSmooth = true
endfunction
function Trig_Mode_smooth_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_smooth_Voters)
endfunction
function Trig_Mode_smooth_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_smooth_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_smooth = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_smooth)
echo(Mode_smooth_MsgOnEnable)
call Trig_Mode_smooth_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_smooth () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_smooth_Voters)
if b1 && b2
call ForceAddPlayer(Mode_smooth_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_smooth_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_smooth () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_smooth_Voters)
set Mode_smooth = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_smooth_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_smooth) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_smooth != MODE_STATUS_ENABLED then
call Trig_Mode_smooth_EnableIfPossible(false)
endif
}
function Trig_Mode_smooth_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_smooth) )
//|| not EventStringExactMatch()
int action
if Mode_smooth == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_smooth == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_smooth()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_smooth()
endif
endfunction
//===========================================================================
function InitTrig_Mode_smooth takes nothing returns nothing
set gg_trg_Mode_smooth = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_smooth, "-smooth", true )
call TriggerAddAction( gg_trg_Mode_smooth, function Trig_Mode_smooth_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_noc = MODE_STATUS_DISABLED
force Mode_noc_Voters = CreateForce() // Mode_Voters_noc
string Mode_noc_MsgOnEnable = "C goals disabled/enabled."
string Mode_noc_VotingStartMsg = "Voting to disable/enable C goals started. "
endglobals
function Trig_Mode_noc_ActionsOnEnable takes nothing returns nothing
set CGoalsBan = not CGoalsBan
endfunction
function Trig_Mode_noc_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_noc_Voters)
endfunction
function Trig_Mode_noc_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_noc_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_noc = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_noc)
echo(Mode_noc_MsgOnEnable)
call Trig_Mode_noc_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_noc () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_noc_Voters)
if b1 && b2
call ForceAddPlayer(Mode_noc_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_noc_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_noc () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_noc_Voters)
set Mode_noc = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_noc_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_noc) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_noc != MODE_STATUS_ENABLED then
call Trig_Mode_noc_EnableIfPossible(false)
endif
}
function Trig_Mode_noc_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_noc) )
//|| not EventStringExactMatch()
int action
if Mode_noc == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_noc == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_noc()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_noc()
endif
endfunction
//===========================================================================
function InitTrig_Mode_noc takes nothing returns nothing
set gg_trg_Mode_noc = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_noc, "-noc", "-c", "-cgoals", "-c goals", true )
call TriggerAddAction( gg_trg_Mode_noc, function Trig_Mode_noc_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_Training = MODE_STATUS_DISABLED
force Mode_Training_Voters = CreateForce() // Mode_Voters_Training
string Mode_Training_MsgOnEnable = "Enabled commands "+Orange("-tm, -ms, -hide")+". Added "+Orange("Teleport & Fetch Ball")+" abilities."
string Mode_Training_VotingStartMsg = "Voting to initiate Training Mode started. "
endglobals
function Trig_Mode_Training_ActionsOnEnable takes nothing returns nothing
set InTraining = true
/*set CanGetBallAfterGoal = false
set ShowTimeSinceLastShot = false
set ShowCustomMaxHeights = false
*/
call AddAbilityToAll(ABILITY_FETCH_BALL)
call AddAbilityToAll(ABILITY_TELEPORT)
call AllPlayersRemoveAbil(ABILITY_SINGLE_HKEY_CURVE)
endfunction
function Trig_Mode_Training_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_Training_Voters)
endfunction
function Trig_Mode_Training_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_Training_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_Training = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_Training)
echo(Mode_Training_MsgOnEnable)
call Trig_Mode_Training_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_Training () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_Training_Voters)
if b1 && b2
call ForceAddPlayer(Mode_Training_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_Training_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_Training () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_Training_Voters)
set Mode_Training = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_Training_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_Training) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_Training != MODE_STATUS_ENABLED then
call Trig_Mode_Training_EnableIfPossible(false)
endif
}
function Trig_Mode_Training_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_Training) )
//|| not EventStringExactMatch()
int action
if Mode_Training == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_Training == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_Training()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_Training()
endif
endfunction
//===========================================================================
function InitTrig_Mode_Training takes nothing returns nothing
set gg_trg_Mode_Training = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_Training, "-train", "-test", "-training", true )
call TriggerAddAction( gg_trg_Mode_Training, function Trig_Mode_Training_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_Keeper = MODE_STATUS_DISABLED
force Mode_Keeper_Voters = CreateForce()
constant integer Mode_Keeper_VotingTime = 30
string Mode_Keeper_MsgOnEnable = "Playable Keeper mode enabled."
endglobals
function Trig_Mode_Keeper_ActionsOnEnable takes nothing returns nothing
// do specific mode stuff
echo ("Use |cffffcc00-nominate|r to specify keeper controller.")
set IsKeeperPlayable = true
set CGoalsBan = false
call UnitRemoveLocust(udg_Keeper[1])
call UnitRemoveLocust(udg_Keeper[2])
call TriggerExecute(gg_trg_Initialize_Keepers)
endfunction
function Trig_Mode_Keeper_CustomInitiatingConditions takes nothing returns boolean
bool b1 = not IsKeeperPlayable
bool b2 = true //udg_BallOwner == null
bool b3 = true //not MatchStarted
bool b4 = true //udg_ThrowinMode != 0
return b1 and b2 and b3 and b4
endfunction
function Trig_Mode_Keeper_InitiatingConditions takes nothing returns boolean
if ModesLib_StandardInitiatingConditions() && Trig_Mode_Keeper_CustomInitiatingConditions()
return true
endif
return false
endfunction
function Trig_Mode_Keeper_CustomVotingConditions takes player p returns boolean
bool b1 = true
bool b2 = true
bool b3 = true
bool b4 = true
//bool b5 = not IsPlayerInForce(p, Observers)
return b1 and b2 and b3 and b4 //and b5
endfunction
function Trig_Mode_Keeper_VotingConditions takes player p returns boolean
if ModesLib_StandardVotingConditions(p) && Trig_Mode_Keeper_CustomVotingConditions(p)
return true
endif
return false
endfunction
function Trig_Mode_Keeper_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_Keeper_Voters)
endfunction
function Trig_Mode_Keeper_GetAllVotesFilter takes nothing returns boolean
return Trig_Mode_Keeper_VotingConditions(GetFilterPlayer())
endfunction
function Trig_Mode_Keeper_GetAllVotes takes nothing returns integer
force f = GetPlayersMatching(Condition(function Trig_Mode_Keeper_GetAllVotesFilter))
int n = CountPlayersInForceBJ(f)
return n
endfunction
function Trig_Mode_Keeper_GetNeededVotes takes int votes_all returns int
if votes_all <= 2
return votes_all
endif
int k = votes_all/2
return k + 1
endfunction
function Trig_Mode_Keeper_EnableIfPossible takes bool EarlyRun returns nothing
int votes_all = Trig_Mode_Keeper_GetAllVotes()
int votes_needed = Trig_Mode_Keeper_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_Keeper_GetYesVotes()
bool InitConditions = Trig_Mode_Keeper_InitiatingConditions()
set Mode_Keeper = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_Keeper)
echo(Mode_Keeper_MsgOnEnable)
call Trig_Mode_Keeper_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
function Trig_Mode_Keeper_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
bool ExactMatch = EventStringExactMatch()
int mode
if not ExactMatch || Mode_Keeper == MODE_STATUS_ENABLED
return
endif
if Mode_Keeper == MODE_STATUS_VOTING then
set mode = MODE_ACTION_VOTE_YES
elseif Mode_Keeper == MODE_STATUS_DISABLED then
set mode = MODE_ACTION_ENABLE
else
return
endif
if mode == MODE_ACTION_VOTE_YES
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
if Trig_Mode_Keeper_VotingConditions(p) then
ForceAddPlayer(Mode_Keeper_Voters ,p)
echo(p, "Vote counted.")
endif
Trig_Mode_Keeper_EnableIfPossible(true)
elseif mode == MODE_ACTION_ENABLE // if can be enabled, initiate a voting
if not Trig_Mode_Keeper_InitiatingConditions()
return
endif
call ForceClear(Mode_Keeper_Voters)
set Mode_Keeper = MODE_STATUS_VOTING
echo("Voting for Keeper Mode started. Type "+Orange("-keeper")+" to vote.")
//echo("DO NOT shoot the ball!")
call TriggerExecute(gg_trg_Mode_Keeper)
if InTesting
Sleep(5)
else
call Sleep(Mode_Keeper_VotingTime)
endif
if Mode_Keeper != MODE_STATUS_ENABLED then
Trig_Mode_Keeper_EnableIfPossible(false) // if not yet enabled, calc votes and enable
endif
endif
endfunction
//===========================================================================
function InitTrig_Mode_Keeper takes nothing returns nothing
set gg_trg_Mode_Keeper = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_Keeper, "-keeper", false )
call TriggerAddAction( gg_trg_Mode_Keeper, function Trig_Mode_Keeper_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_Endgame = MODE_STATUS_DISABLED
force Mode_Endgame_Voters = CreateForce()
constant integer Mode_Endgame_VotingTime = MODE_VOTING_TIME_STANDARD
string Mode_Endgame_MsgOnEnable = " "
string Mode_Endgame_VotingStartMsg = "Voting to end current game started. Type |cffffcc00-end|r to vote."
timer Mode_Endgame_Runtime_Timer = CreateTimer()
endglobals
function Trig_Mode_Endgame_ActionsOnEnable takes nothing returns nothing
set IsGoldenGoalEnabled = false
call TimesUp()
endfunction
function Trig_Mode_Endgame_GetNeededVotes takes int votes_all returns int
if votes_all <= 2
return votes_all
endif
int k = votes_all/2
return k + 1
endfunction
function Trig_Mode_Endgame_CustomInitiatingConditions takes nothing returns boolean
bool b1 = true
bool b2 = true
bool b3 = true
bool b4 = true
return b1 and b2 and b3 and b4
endfunction
function Trig_Mode_Endgame_CustomVotingConditions takes player p returns boolean
bool b1 = true
bool b2 = true
bool b3 = true
bool b4 = true
//bool b5 = not IsPlayerInForce(p, Observers)
return b1 and b2 and b3 and b4 //and b5
endfunction
function Trig_Mode_Endgame_InitiatingConditions takes nothing returns boolean
if ModesLib_StandardInitiatingConditions() && Trig_Mode_Endgame_CustomInitiatingConditions()
return true
endif
return false
endfunction
function Trig_Mode_Endgame_VotingConditions takes player p returns boolean
if ModesLib_StandardVotingConditions(p) && Trig_Mode_Endgame_CustomVotingConditions(p)
return true
endif
return false
endfunction
function Trig_Mode_Endgame_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_Endgame_Voters)
endfunction
function Trig_Mode_Endgame_GetAllVotesFilter takes nothing returns boolean
return Trig_Mode_Endgame_VotingConditions(GetFilterPlayer())
endfunction
function Trig_Mode_Endgame_GetAllVotes takes nothing returns integer
force f = GetPlayersMatching(Condition(function Trig_Mode_Endgame_GetAllVotesFilter))
int n = CountPlayersInForceBJ(f)
return n
endfunction
function Trig_Mode_Endgame_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = Trig_Mode_Endgame_GetAllVotes()
int votes_needed = Trig_Mode_Endgame_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_Endgame_GetYesVotes()
bool InitConditions = Trig_Mode_Endgame_InitiatingConditions()
set Mode_Endgame = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_Endgame)
echo(Mode_Endgame_MsgOnEnable)
call Trig_Mode_Endgame_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
function Trig_Mode_Endgame_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
int mode
if not EventStringExactMatch() || Mode_Endgame == MODE_STATUS_ENABLED
return
endif
if Mode_Endgame == MODE_STATUS_VOTING then
set mode = MODE_ACTION_VOTE_YES
elseif Mode_Endgame == MODE_STATUS_DISABLED then
set mode = MODE_ACTION_ENABLE
else
return
endif
if mode == MODE_ACTION_VOTE_YES
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
if Trig_Mode_Endgame_VotingConditions(p) then
ForceAddPlayer(Mode_Endgame_Voters ,p)
echo(p, "Vote counted.")
endif
Trig_Mode_Endgame_EnableIfPossible(true)
elseif mode == MODE_ACTION_ENABLE
// if can be enabled, initiate a voting
if not Trig_Mode_Endgame_InitiatingConditions()
return
endif
set Mode_Endgame = MODE_STATUS_VOTING
echo(Mode_Endgame_VotingStartMsg)
call TriggerExecute(gg_trg_Mode_End)
if InTesting
Sleep(5)
else
call Sleep(Mode_Endgame_VotingTime)
endif
if Mode_Endgame != MODE_STATUS_ENABLED then
Trig_Mode_Endgame_EnableIfPossible(false)
endif
call ForceClear(Mode_Endgame_Voters)
endif
endfunction
//===========================================================================
function InitTrig_Mode_End takes nothing returns nothing
set gg_trg_Mode_End = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_End, "-end", false )
call TriggerAddAction( gg_trg_Mode_End, function Trig_Mode_Endgame_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_xv = MODE_STATUS_DISABLED
force Mode_xv_Voters = CreateForce() // Mode_Voters_xv
string Mode_xv_MsgOnEnable = "xv fix from 7.44a2.2 enabled."
string Mode_xv_VotingStartMsg = "Voting to initiate xv fix mode started. "
endglobals
function Trig_Mode_xv_ActionsOnEnable takes nothing returns nothing
set xvFalseFixEnabled = true
endfunction
function Trig_Mode_xv_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_xv_Voters)
endfunction
function Trig_Mode_xv_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_xv_GetYesVotes()
bool InitConditions = ModesLib_StandardInitiatingConditions()
set Mode_xv = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_xv)
echo(Mode_xv_MsgOnEnable)
call Trig_Mode_xv_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
void Mode_VoteYesActions_xv () {
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
player p = GetTriggerPlayer()
bool b1 = ModesLib_StandardVotingConditions(p)
bool b2 = not IsPlayerInForce(p, Mode_xv_Voters)
if b1 && b2
call ForceAddPlayer(Mode_xv_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_xv_EnableIfPossible(true)
}
void Mode_InitiateVotingAttempt_xv () {
call Ensure( ModesLib_StandardInitiatingConditions() )
call ForceClear(Mode_xv_Voters)
set Mode_xv = MODE_STATUS_VOTING
string pattern = GetEventPlayerChatStringMatched()
string cmd = "Type "+Orange(pattern)+" to vote."
echoln(Mode_xv_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_xv) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(MODE_VOTING_TIME_STANDARD)
endif
if Mode_xv != MODE_STATUS_ENABLED then
call Trig_Mode_xv_EnableIfPossible(false)
endif
}
function Trig_Mode_xv_Actions takes nothing returns nothing
call Ensure( not IsModeEnabled(Mode_xv) )
//|| not EventStringExactMatch()
int action
if Mode_xv == MODE_STATUS_VOTING then
set action = MODE_ACTION_VOTE_YES
elseif Mode_xv == MODE_STATUS_DISABLED then
set action = MODE_ACTION_ENABLE
else
return
endif
if ( action == MODE_ACTION_VOTE_YES )
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
call Mode_VoteYesActions_xv()
elseif ( action == MODE_ACTION_ENABLE )
// if can be enabled, initiate a voting
call Mode_InitiateVotingAttempt_xv()
endif
endfunction
//===========================================================================
function InitTrig_Mode_xv takes nothing returns nothing
set gg_trg_Mode_xv = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_xv, "-xv", true )
call TriggerAddAction( gg_trg_Mode_xv, function Trig_Mode_xv_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_Walls = MODE_STATUS_DISABLED
force Mode_Walls_Voters = CreateForce()
constant integer Mode_Walls_VotingTime = MODE_VOTING_TIME_STANDARD
string Mode_Walls_MsgOnEnable = "Now you can bounce the ball off sidelines."
string Mode_Walls_VotingStartMsg = "Voting for Invisible Walls started. "
timer Mode_Walls_Runtime_Timer = CreateTimer()
endglobals
function MoveRect takes rect r, real xOffset, real yOffset returns void
location center_old = GetRectCenter(r)
location center_new = OffsetLocation(center_old, xOffset, yOffset)
call MoveRectToLoc(r, center_new)
endfunction
function Trig_Mode_Walls_ActionsOnEnable takes nothing returns nothing
set InvisibleWalls = true
set HighC = false
call MoveRect(gg_rct_LineTOP, 0, -16) // -32
call MoveRect(gg_rct_LineBTM, 0, -8) // 0
call MoveRect(gg_rct_LineRB, -32, 0)
call MoveRect(gg_rct_LineRT, -32, 0)
/*set center_new = OffsetLocation(GetRectCenter(gg_rct_LineRB), -32, 0)
call MoveRectToLoc(gg_rct_LineRB, center_new)*/
call TriggerRegisterEnterRectSimple( gg_trg_Hit_invisible_walls_top_bottom, gg_rct_LineTOP )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_invisible_walls_top_bottom, gg_rct_LineBTM )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_invisible_walls_top_bottom, gg_rct_BottomLinesman)
call TriggerRegisterEnterRectSimple( gg_trg_Hit_invisible_walls_top_bottom, gg_rct_TopLinesman)
call TriggerRegisterEnterRectSimple( gg_trg_Hit_invisible_walls_right_left, gg_rct_LineLB )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_invisible_walls_right_left, gg_rct_LineLT )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_invisible_walls_right_left, gg_rct_LineRT )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_invisible_walls_right_left, gg_rct_LineRB )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_invisible_walls_right_left, gg_rct_InvisibleWallLeft )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_invisible_walls_right_left, gg_rct_InvisibleWallRight )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_LineRB )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_LineRT )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_LineLB )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_LineLT )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_LineTOP )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_LineBTM )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_InvisibleWallLeft )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_InvisibleWallRight )
call DisableTrigger(gg_trg_Hit_Goalpost_right_left)
set MAXIMUM_BAR_HEIGHT = 350
/*call MoveRect(gg_rct_GoalPostLeft1, 300, 0)
call MoveRect(gg_rct_GoalPostLeft2, 300, 0)
call MoveRect(gg_rct_GoalPostRight1, -300, 0)
call MoveRect(gg_rct_GoalPostRight2, -300, 0)*/
//location center_new = OffsetLocation(GetRectCenter(gg_rct_PlayArea), 0, 1*64)
endfunction
function Trig_Mode_Walls_GetNeededVotes takes int votes_all returns int
if votes_all <= 2
return votes_all
endif
int k = votes_all/2
return k + 1
endfunction
function Trig_Mode_Walls_CustomInitiatingConditions takes nothing returns boolean
bool b1 = udg_ThrowinMode == 0 || IsBallInRect(gg_rct_Center)
bool b2 = true
bool b3 = true
bool b4 = true
return b1 and b2 and b3 and b4
endfunction
function Trig_Mode_Walls_CustomVotingConditions takes player p returns boolean
bool b1 = true
bool b2 = true
bool b3 = true
bool b4 = true
//bool b5 = not IsPlayerInForce(p, Observers)
return b1 and b2 and b3 and b4 //and b5
endfunction
function Trig_Mode_Walls_InitiatingConditions takes nothing returns boolean
if ModesLib_StandardInitiatingConditions() && Trig_Mode_Walls_CustomInitiatingConditions()
return true
endif
return false
endfunction
function Trig_Mode_Walls_VotingConditions takes player p returns boolean
if ModesLib_StandardVotingConditions(p) && Trig_Mode_Walls_CustomVotingConditions(p)
return true
endif
return false
endfunction
function Trig_Mode_Walls_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_Walls_Voters)
endfunction
function Trig_Mode_Walls_GetAllVotesFilter takes nothing returns boolean
return Trig_Mode_Walls_VotingConditions(GetFilterPlayer())
endfunction
function Trig_Mode_Walls_GetAllVotes takes nothing returns integer
force f = GetPlayersMatching(Condition(function Trig_Mode_Walls_GetAllVotesFilter))
int n = CountPlayersInForceBJ(f)
return n
endfunction
function Trig_Mode_Walls_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = Trig_Mode_Walls_GetAllVotes()
int votes_needed = Trig_Mode_Walls_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_Walls_GetYesVotes()
bool InitConditions = Trig_Mode_Walls_InitiatingConditions()
set Mode_Walls = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_Walls)
echo(Mode_Walls_MsgOnEnable)
call Trig_Mode_Walls_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
function Trig_Mode_Walls_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
int mode
string pattern = GetEventPlayerChatStringMatched()
if Mode_Walls == MODE_STATUS_ENABLED //|| not EventStringExactMatch()
return
endif
if Mode_Walls == MODE_STATUS_VOTING then
set mode = MODE_ACTION_VOTE_YES
elseif Mode_Walls == MODE_STATUS_DISABLED then
set mode = MODE_ACTION_ENABLE
else
return
endif
if mode == MODE_ACTION_VOTE_YES
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
if Trig_Mode_Walls_VotingConditions(p) && not IsPlayerInForce(p, Mode_Walls_Voters)
call ForceAddPlayer(Mode_Walls_Voters ,p)
echo(p, "Vote counted.")
endif
call Trig_Mode_Walls_EnableIfPossible(true)
elseif mode == MODE_ACTION_ENABLE
// if can be enabled, initiate a voting
if not Trig_Mode_Walls_InitiatingConditions()
return
endif
call ForceClear(Mode_Walls_Voters)
set Mode_Walls = MODE_STATUS_VOTING
string cmd = "Type "+Orange(pattern)+" to vote."
echo(Mode_Walls_VotingStartMsg + cmd)
call TriggerExecute(gg_trg_Mode_Walls) // initiator votes
if InTesting
call PolledWait(5)
else
call PolledWait(Mode_Walls_VotingTime)
endif
if Mode_Walls != MODE_STATUS_ENABLED then
call Trig_Mode_Walls_EnableIfPossible(false)
endif
endif
endfunction
//===========================================================================
function InitTrig_Mode_Walls takes nothing returns nothing
set gg_trg_Mode_Walls = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_Walls, "-iw", true )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_Walls, "-invisible walls", true )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_Walls, "-indoor", true )
call TriggerAddAction( gg_trg_Mode_Walls, function Trig_Mode_Walls_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
globals
int Mode_Tour = MODE_STATUS_DISABLED
force Mode_Tour_Voters = CreateForce()
constant integer Mode_Tour_VotingTime = MODE_VOTING_TIME_STANDARD
string Mode_Tour_MsgOnEnable = "Tournament mode enabled."
string Mode_Tour_VotingStartMsg = "Voting for Tournament Mode started. Type |cffffcc00-tour|r to vote."
timer Mode_Tour_Runtime_Timer = CreateTimer()
endglobals
void KillEnumUnit() { RemoveUnit(GetEnumUnit()) }
function HideLaggyDoodads takes nothing returns nothing
call SetDoodadAnimationRectBJ( "hide", 'YOcp', GetPlayableMapRect() )
call SetDoodadAnimationRectBJ( "hide", 'D00E', GetPlayableMapRect() )
call SetDoodadAnimationRectBJ( "hide", 'D00D', GetPlayableMapRect() )
call SetDoodadAnimationRectBJ( "hide", 'D009', GetPlayableMapRect() )
call SetDoodadAnimationRectBJ( "hide", 'D00B', GetPlayableMapRect() )
//for (unit banner; GroupEnumUnitsOfType(""))
call ForGroup(GetUnitsOfTypeIdAll('h002'), function KillEnumUnit)
call ForGroup(GetUnitsOfTypeIdAll('h00B'), function KillEnumUnit)
call ForGroup(GetUnitsOfTypeIdAll('h00C'), function KillEnumUnit)
/*call DestroyGroup(GetUnitsOfTypeIdAll('h002'))
call DestroyGroup(GetUnitsOfTypeIdAll('h00B'))
call DestroyGroup(GetUnitsOfTypeIdAll('h00C'))*/
endfunction
function Trig_Mode_Tour_ActionsOnEnable takes nothing returns nothing
// do specific mode stuff
call HideLaggyDoodads()
endfunction
function Trig_Mode_Tour_GetNeededVotes takes int votes_all returns int
if votes_all <= 2
return votes_all
endif
int k = votes_all/2
return k + 1
endfunction
function Trig_Mode_Tour_CustomInitiatingConditions takes nothing returns boolean
bool b1 = true
bool b2 = true
bool b3 = true
bool b4 = true
return b1 and b2 and b3 and b4
endfunction
function Trig_Mode_Tour_CustomVotingConditions takes player p returns boolean
bool b1 = true
bool b2 = true
bool b3 = true
bool b4 = true
//bool b5 = not IsPlayerInForce(p, Observers)
return b1 and b2 and b3 and b4 //and b5
endfunction
function Trig_Mode_Tour_InitiatingConditions takes nothing returns boolean
if ModesLib_StandardInitiatingConditions() && Trig_Mode_Tour_CustomInitiatingConditions()
return true
endif
return false
endfunction
function Trig_Mode_Tour_VotingConditions takes player p returns boolean
if ModesLib_StandardVotingConditions(p) && Trig_Mode_Tour_CustomVotingConditions(p)
return true
endif
return false
endfunction
function Trig_Mode_Tour_GetYesVotes takes nothing returns integer
return CountPlayersInForceBJ(Mode_Tour_Voters)
endfunction
function Trig_Mode_Tour_GetAllVotesFilter takes nothing returns boolean
return Trig_Mode_Tour_VotingConditions(GetFilterPlayer())
endfunction
function Trig_Mode_Tour_GetAllVotes takes nothing returns integer
force f = GetPlayersMatching(Condition(function Trig_Mode_Tour_GetAllVotesFilter))
int n = CountPlayersInForceBJ(f)
return n
endfunction
function Trig_Mode_Tour_EnableIfPossible takes boolean EarlyRun returns nothing
int votes_all = Trig_Mode_Tour_GetAllVotes()
int votes_needed = Trig_Mode_Tour_GetNeededVotes(votes_all)
int votes_yes = Trig_Mode_Tour_GetYesVotes()
bool InitConditions = Trig_Mode_Tour_InitiatingConditions()
set Mode_Tour = ModesLib_EnableIfPossibleAbstracted( EarlyRun, InitConditions, \
votes_yes, votes_needed, votes_all)
if IsModeEnabled(Mode_Tour)
echo(Mode_Tour_MsgOnEnable)
call Trig_Mode_Tour_ActionsOnEnable()
// Do not clear force here
return
endif
endfunction
function Trig_Mode_Tour_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
int mode
if not EventStringExactMatch() || Mode_Tour == MODE_STATUS_ENABLED
return
endif
if Mode_Tour == MODE_STATUS_VOTING then
set mode = MODE_ACTION_VOTE_YES
elseif Mode_Tour == MODE_STATUS_DISABLED then
set mode = MODE_ACTION_ENABLE
else
return
endif
if mode == MODE_ACTION_VOTE_YES
// add to force & check conditions, func
// if enough ppl disable voting and enable mode
if Trig_Mode_Tour_VotingConditions(p) then
ForceAddPlayer(Mode_Tour_Voters, p)
echo(p, "Vote counted.")
endif
Trig_Mode_Tour_EnableIfPossible(true)
elseif mode == MODE_ACTION_ENABLE
// if can be enabled, initiate a voting
if not Trig_Mode_Tour_InitiatingConditions()
return
endif
call ForceClear(Mode_Tour_Voters)
set Mode_Tour = MODE_STATUS_VOTING
echo(Mode_Tour_VotingStartMsg)
call TriggerExecute(gg_trg_Mode_Tour)
if InTesting
Sleep(5)
else
call Sleep(Mode_Tour_VotingTime)
endif
if Mode_Tour != MODE_STATUS_ENABLED then
//Trig_Mode_Tour_EnableIfPossible(false)
endif
endif
endfunction
//===========================================================================
function InitTrig_Mode_Tour takes nothing returns nothing
set gg_trg_Mode_Tour = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Mode_Tour, "-tour", false )
call TriggerAddAction( gg_trg_Mode_Tour, function Trig_Mode_Tour_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function ChangeHotkeysToQWER takes nothing returns nothing
player p = GetTriggerPlayer()
call PlayerExchangeAbils(p, ABILITY_SHORT_PASS, ABILITY_SHORT_PASS_Q)
call PlayerExchangeAbils(p, ABILITY_KICK_SLIDE, ABILITY_KICK_SLIDE_W)
call PlayerExchangeAbils(p, ABILITY_LONG_PASS, ABILITY_LONG_PASS_E)
call PlayerExchangeAbils(p, ABILITY_JUMP, ABILITY_JUMP_R)
echo(p,"Changed hotkeys to QWER. To reverse type "+Orange("-zxcv"))
endfunction
function ChangeHotkeysToZXCV takes nothing returns nothing
player p = GetTriggerPlayer()
call PlayerExchangeAbils(p, ABILITY_SHORT_PASS_Q, ABILITY_SHORT_PASS)
call PlayerExchangeAbils(p, ABILITY_KICK_SLIDE_W, ABILITY_KICK_SLIDE)
call PlayerExchangeAbils(p, ABILITY_LONG_PASS_E, ABILITY_LONG_PASS)
call PlayerExchangeAbils(p, ABILITY_JUMP_R, ABILITY_JUMP)
echo(p,"Changed hotkeys to ZXCV.")
endfunction
//===========================================================================
function InitTrig_qwer takes nothing returns nothing
trigger t = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( t, "-qwer","-qwerty", true )
call TriggerAddAction( t, function ChangeHotkeysToQWER )
set t = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( t, "-zxcv", true )
call TriggerAddAction( t, function ChangeHotkeysToZXCV )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
real CurveBallFactor = 0
real MAX_CURVE_ANGLE = 22. //32.
real CURVE_TEXTTAG_LIFESPAN = 0.11
real TEXTTAG_ZOFFSET = 100
texttag array CURVE_ANGLE_TEXTTAGS
constant integer CURVE_DISABLED = 0
constant integer CURVE_CLASSIC = 1
constant integer CURVE_SINGLE_HKEY = 2
integer CURVE_STATUS = CURVE_DISABLED
lib_init(Curve,config,StdLib)
public void AdjustTextTagLocations() {
int i=1
loop
call SetTextTagPosUnit(CURVE_ANGLE_TEXTTAGS[i], udg_Hero[i], TEXTTAG_ZOFFSET)
i++
exitwhen(i>12)
endloop
}
public string GetTextTagString(real curveFactor) {
string s = I2S(R2I(abs(curveFactor)*10))
set s += "°"
if curveFactor < 0
//s = "-" + s
s = "<-- " + s
else
//s = "+" + s
s = s + " -->"
endif
return s
}
public texttag CreateTextTag(real curveFactor, int pid) { // , real R, real G, real B) {
real R=255, G=255, B=255//255
unit u = Hero[pid]
real zOffset = TEXTTAG_ZOFFSET
string s = GetTextTagString(curveFactor)
texttag t = CreateTextTagUnitBJ( s, u, zOffset, 10, R, G, B, 0 )
call SetTextTagVelocityBJ( t, 0,0 )// 64, 90 )
call SetTextTagPermanentBJ( t, false )
call SetTextTagLifespanBJ( t, CURVE_TEXTTAG_LIFESPAN )
//call SetTextTagFadepointBJ( t, 0.1 )
call SetTextTagPosUnit(t, u, zOffset)
player p = ConvertedPlayer(pid)
call ShowTextTagForceBJ(false,t,GetPlayersAll())
call ShowTextTagForceBJ(true,t,GetForceOfPlayer(p))
return t
}
public function DisplayOwnCurveAngleToPlayersIfAny takes nothing returns nothing
int i=1
loop
real curveTimer = udg_CurveBallFactor[i]
if abs(curveTimer) > 2. //1. //0.05
set CURVE_ANGLE_TEXTTAGS[i] = Curve_CreateTextTag(curveTimer, i)
endif
i++
exitwhen (i>15)
endloop
endfunction
private void config() {
int i=0
loop
set CURVE_ANGLE_TEXTTAGS[i] = null
i++
exitwhen(i>20)
endloop
}
endlib
function Trig_Left_curve_Actions takes nothing returns nothing
call Ensure(Sid() == ABILITY_LEFT_CURVE || Sid() == ABILITY_RIGHT_CURVE || Sid() == ABILITY_SINGLE_HKEY_CURVE)
player p = GetTriggerPlayer()
integer pid = cPid(p)
boolean left//,right
if (Sid()==ABILITY_SINGLE_HKEY_CURVE)
if ( udg_CurveBallFactor[pid] < (0.4 - 0.1*MAX_CURVE_ANGLE) )
set left = false
else
set left = true
endif
// if no curve hotkey hit for the previous 0.5 sec, left curve
// else (double hit) right curve
else
set left = Sid() == ABILITY_LEFT_CURVE
endif
real power = udg_CurveBallFactor[pid]
real max = 0.1*MAX_CURVE_ANGLE
if left
/*if power > 0.05
set udg_CurveBallFactor[pid] = 0
else*/
set udg_CurveBallFactor[pid] = -max //RMaxBJ(-max, -max) //power-1)
//endif
else
/*if power < -0.05 // 0 would cause skipping of first F hit (=right curve btn hit)
set udg_CurveBallFactor[pid] = 0
else*/
set udg_CurveBallFactor[pid] = max //RMinBJ(max, max) //power+1)
//endif
endif
endfunction
//===========================================================================
function InitTrig_Curve_ball takes nothing returns nothing
trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( t, function Trig_Left_curve_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib (AbilsLib, AuxiliaryFuncs)
function Long_Pass_Calculate_Speed_and_vy takes nothing returns nothing
set udg_TempReal = 37.2
// + 1.5 * GetHeroStr( udg_BallOwner, true)
// can mess up with keepers
set udg_IsBallInAir = true
set udg_BallImmuneTimer = 7
location loc_ball = GetUnitLoc(udg_Ball)
location loc_target = GetSpellTargetLoc()
real dist = DistanceBetweenPoints(loc_ball, loc_target)
set udg_BallVZ = udg_G * dist * 0.5 / udg_TempReal
set udg_BallVZ = RMaxBJ(30, udg_BallVZ)
set udg_BallVZ = RMinBJ(30, udg_BallVZ)
// 30 + 1.5 * GetHeroStr(udg_BallOwner, true)
//set udg_BallVZ = 30
set udg_TempReal = udg_G * dist * 0.5 / udg_BallVZ
//echo(R2S(udg_TempReal*10))
endfunction
function UnitHasAbil takes unit u, int abil returns bool
int level = GetUnitAbilityLevel(u, abil)
return (level > 0)
endfunction
function PlayerRemoveAbil takes player p, int abil returns bool
int pid = GetConvertedPlayerId(p)
bool b = UnitRemoveAbility(udg_Hero[pid], abil)
return b
endfunction
function AllPlayersRemoveAbilEnum takes nothing returns nothing
int abil = TempInt
player p = GetEnumPlayer()
call PlayerRemoveAbil(p,abil)
endfunction
function AllPlayersRemoveAbil takes int abil returns nothing
force f = GetPlayersAll()
set TempInt = abil
call ForForce(f, function AllPlayersRemoveAbilEnum)
endfunction
function UnitExchangeAbils takes unit u, int abil_old, int abil_new returns bool
if not UnitHasAbil(u, abil_old) then
return false
endif
call UnitRemoveAbility( u, abil_old )
call UnitAddAbility( u, abil_new )
return true
endfunction
function UnitExchangeAbilsMsg takes unit u, int abil_old, int abil_new, string output returns bool
bool b = UnitExchangeAbils(u, abil_old, abil_new)
player p = GetOwningPlayer(u)
if b
echo(p, output)
endif
set p = null
return b
endfunction
function PlayerExchangeAbils takes player p, int abil_old, int abil_new returns bool
int pid = GetConvertedPlayerId(p)
bool b = UnitExchangeAbils(udg_Hero[pid], abil_old, abil_new)
return b
endfunction
function PlayerExchangeAbilsMsg takes player p, int abil_old, int abil_new, string output returns bool
int pid = GetConvertedPlayerId(p)
bool b = UnitExchangeAbilsMsg(udg_Hero[pid], abil_old, abil_new, output)
return b
endfunction
scope GroupExchangeAbils
private int Abil_Old, Abil_New
function GroupExchangeAbilsEnum takes nothing returns nothing
call UnitExchangeAbils(GetEnumUnit(), Abil_Old, Abil_New)
endfunction
function GroupExchangeAbils takes group g, int abil_old, int abil_new returns nothing
set Abil_Old = abil_old
set Abil_New = abil_new
call ForGroup(g, function GroupExchangeAbilsEnum)
endfunction
endscope
function AllPlayersExchangeAbils takes int abil_old, int abil_new returns nothing
call GroupExchangeAbils(udg_Team1Heroes, abil_old, abil_new)
call GroupExchangeAbils(udg_Team2Heroes, abil_old, abil_new)
endfunction
void GroupAddAbilityEnum() {
call UnitAddAbility(GetEnumUnit(), TempInt)
}
void GroupAddAbility(group g, int id) {
set TempInt = id
call ForGroup(g, function GroupAddAbilityEnum)
}
void AddAbilityToAll(int id) {
call GroupAddAbility(udg_Team1Heroes, id)
call GroupAddAbility(udg_Team2Heroes, id)
}
function ExchangeShortPassAbilsForth takes nothing returns nothing
call GroupExchangeAbils(ManualShortPassGroup, SPELL_SHORT_PASS, SPELL_TARGETABLE_SHORT_PASS)
call GroupExchangeAbils(ManualShortPassGroup, SPELL_SHORT_PASS_Y, SPELL_TARGETABLE_SHORT_PASS_Y)
//call AllPlayersExchangeAbils(SPELL_SHORT_PASS, SPELL_TARGETABLE_SHORT_PASS)
//call AllPlayersExchangeAbils(SPELL_SHORT_PASS_Y, SPELL_TARGETABLE_SHORT_PASS_Y)
endfunction
function ExchangeShortPassAbilsBack takes nothing returns nothing
call GroupExchangeAbils(ManualShortPassGroup, SPELL_TARGETABLE_SHORT_PASS, SPELL_SHORT_PASS)
call GroupExchangeAbils(ManualShortPassGroup, SPELL_TARGETABLE_SHORT_PASS_Y, SPELL_SHORT_PASS_Y)
//call AllPlayersExchangeAbils(SPELL_TARGETABLE_SHORT_PASS, SPELL_SHORT_PASS)
//call AllPlayersExchangeAbils(SPELL_TARGETABLE_SHORT_PASS_Y, SPELL_SHORT_PASS_Y)
endfunction
function UnitStop takes unit u returns bool
return IssueImmediateOrder(u, "stop")
endfunction
function IsSpellShortPass takes integer sid returns bool
bool b1 = sid == ABILITY_SHORT_PASS
bool b2 = sid == ABILITY_SHORT_PASS_Y
bool b3 = sid == ABILITY_SHORT_PASS_Q
if b1 || b2 || b3
return true
endif
return false
endfunction
bool IsSpellKickSlide(int sid) {
bool b1 = sid == ABILITY_KICK_SLIDE
bool b2 = sid == ABILITY_KICK_SLIDE_W
bool b = b1 || b2
return b
}
bool IsSpellLongPass(int sid) {
bool b1 = sid == ABILITY_LONG_PASS
bool b2 = sid == ABILITY_LONG_PASS_E
bool b3 = sid == ABILITY_LONG_PASS_REVEAL
bool b = b1 || b2 || b3
return b
}
function IsSpellJump takes integer sid returns boolean
bool b1 = sid == ABILITY_JUMP
bool b2 = sid == ABILITY_JUMP_F
bool b3 = sid == ABILITY_JUMP_R
bool b4 = sid == ABILITY_JUMP_SLOW
bool b = b1 || b2 || b3 || b4
return b
endfunction
function UnitRemoveLocust takes unit u returns bool
call HideUnit(u)
bool b = UnitRemoveAbility(u, 'Aloc')
call RevealUnit(u)
return b
endfunction
function UnitAddLocust takes unit u returns bool
return UnitAddAbility(u, 'Aloc')
endfunction
function UnitRemoveAddAbility takes unit u, int id_old, int id_new returns nothing
int h_lvl = GetUnitAbilityLevel(u, id_old)
if ( h_lvl > 0 ) then
call UnitRemoveAbility( u, id_old )
endif
call UnitAddAbility( u, id_new )
endfunction
// ability funcs (for AI)
function UnitUseAbility takes unit u, integer abil returns nothing
//call IssueImmediateOrder( udg_Hero[GetConvertedPlayerId(GetEnumPlayer())], "windwalk" )
endfunction
function UnitShortPass takes unit u returns nothing
call IssueImmediateOrder( u, "divineshield" )
endfunction
function PlayerShortPass takes player p returns nothing
if p == null
return
endif
integer pid = GetConvertedPlayerId(p)
call UnitShortPass(udg_Hero[pid])
endfunction
function UnitKick takes unit u, location loc returns nothing
if loc == null
return
endif
call IssuePointOrderByIdLoc( u, 852270, loc )
// thanks to waterknight of hive :)
endfunction
function PlayerKick takes player p, location loc returns nothing
if p == null
return
endif
integer pid = GetConvertedPlayerId(p)
UnitKick(udg_Hero[pid], loc)
endfunction
function UnitSlide takes unit u, location loc returns nothing
if udg_BallOwner == u
return
endif
//call IssuePointOrderByIdLoc( u, 852270, loc )
call UnitKick(u, loc)
endfunction
function PlayerSlide takes player p, location loc returns nothing
if p == null
return
endif
integer pid = GetConvertedPlayerId(p)
UnitSlide(udg_Hero[pid], loc)
endfunction
function UnitLongPass takes unit u, location loc returns nothing
if loc == null
return
endif
call IssuePointOrderLoc( u, "farsight", loc )
endfunction
function PlayerLongPass takes player p, location loc returns nothing
if p == null
return
endif
integer pid = GetConvertedPlayerId(p)
UnitLongPass( udg_Hero[pid], loc )
endfunction
function UnitJump takes unit u returns nothing
call IssueImmediateOrder( u, "windwalk" )
endfunction
function PlayerJump takes player p returns nothing
if p == null
return
endif
integer pid = GetConvertedPlayerId(p)
UnitJump(udg_Hero[pid])
endfunction
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Template_Actions takes nothing returns nothing
call Ensure(Sid() == 0)
endfunction
//===========================================================================
function InitTrig_Template takes nothing returns nothing
trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( t, function Trig_Template_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
bool Trig_A_Drop_Ball_Conditions() {
bool b1 = Sid() == ABILITY_DROP_BALL
bool b2 = BallOwner == GetTriggerUnit()
bool b3 = true // udg_ThrowinMode == 0
return b1 && b2 && b3
}
function Trig_A_Drop_Ball_Actions takes nothing returns nothing
int pid = cPid(GetTriggerPlayer())
//unit u = GetTriggerUnit()
if IsInSet( udg_ThrowinMode, 1,2 )
set udg_BallOwner = null
set udg_CantHoldBall[pid] = 15
call Ball_SetLoc(udg_ThrowinLoc)
return
endif
// if udg_HeroInAir[pid]
if Ball_GetHeight() > 15 // 5 leads to eternal bouncing
set udg_IsBallInAir = true //
else
call Ball_Land() // code was here
endif
call PlayKickSound()
set udg_CantHoldBall[pid] = 10
set udg_BallOwner = null
set LastActionMade = ACTION_DROP_BALL
call UpdateLK(GetTriggerUnit()) // unnecessary (PSMode = 0)
set udg_BallDirection = GetUnitFacing(GetTriggerUnit()) - 180
set udg_TempReal = 25
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
//call TriggerExecute( gg_trg_Common_Actions_for_shoot ) // udg_CantHoldBall[] conflict
endfunction
//===========================================================================
function InitTrig_A_Drop_Ball takes nothing returns nothing
set gg_trg_A_Drop_Ball = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_A_Drop_Ball, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddConditionSimple( gg_trg_A_Drop_Ball, function Trig_A_Drop_Ball_Conditions )
call TriggerAddAction( gg_trg_A_Drop_Ball, function Trig_A_Drop_Ball_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Auto_Pass_Conditions takes nothing returns boolean
local integer pid = GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))
local boolean b1 = udg_HeroSlidingWait[pid] == 0
local boolean b2 = udg_BallOwner == GetSpellAbilityUnit()
integer sid = GetSpellAbilityId()
local boolean b3 = IsSpellShortPass(GetSpellAbilityId())
if b3
PlayerIncInt(pid, "z_pressed")
PlayerUpdateMaxInt(pid, "z_pressed", UPDATE_MAX_PID)
endif
if b1 and b2 and b3
PlayerIncInt(pid, "z_made")
PlayerUpdateMaxInt(pid, "z_made", UPDATE_MAX_PID)
endif
return b1 and b2 and b3
endfunction
function Trig_Auto_Pass_DirectZPass takes nothing returns nothing
// "TRIGSTR_/155"
call SetBallHeight( udg_BallDefaultHeight )
set udg_BallVZ = 0
set udg_IsBallInAir = false
set udg_BallDirection = GetUnitFacing(udg_BallOwner)
set udg_BallInitialDirection = udg_BallDirection
set udg_BallImmuneTimer = 7
set udg_TempReal = 52.2 //57.2 + GetHeroStr(udg_BallOwner, true)
set LastActionMade = ACTION_SHORT_PASS
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
call TriggerExecute( gg_trg_Common_Actions_for_shoot )
endfunction
function Trig_Auto_Pass_Actions takes nothing returns nothing
local location loc_ball_new
local real dist
int pid = GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))
unit passer = GetSpellAbilityUnit()
bool ShortPass = not udg_HeroInAir[pid]
location loc_unit = GetUnitLoc(passer)
if ShortPass
call TriggerExecute( gg_trg_Z_Get_Pass_Target )
// ps was here
if ( udg_ThrowinMode != 0 ) then
set loc_ball_new = PolarProjectionBJ(loc_unit, 100, AngleBetweenUnits(passer, udg_PassTarget))
call SetUnitPositionLoc( udg_Ball, loc_ball_new )
endif
call SetBallHeight( udg_BallDefaultHeight )
set udg_BallVZ = 0
set udg_IsBallInAir = false
set udg_BallDirection = AngleBetweenUnits(udg_Ball, udg_PassTarget)
set udg_BallInitialDirection = udg_BallDirection
set udg_TempReal = 52.2 //57.2 + GetHeroStr(udg_BallOwner, true)
set LastActionMade = ACTION_SHORT_PASS
set dist = DistanceBetweenUnits(udg_PassTarget, udg_Ball)
set udg_BallImmuneTimer = IMinBJ(7, R2I(0.5 * dist / udg_TempReal) )
else
// V+Z actions
set LastActionMade = ACTION_VZ
set udg_BallVZ = 0
set udg_IsBallInAir = true
set udg_BallDirection = GetUnitFacing(udg_BallOwner)
set udg_BallInitialDirection = udg_BallDirection
set udg_BallImmuneTimer = 7
set udg_TempReal = 52.2 //57.2 + GetHeroStr(udg_BallOwner, true)
set CurveBallFactor = udg_CurveBallFactor[pid]
set udg_CurveBallFactor[pid] = 0
endif
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
call TriggerExecute( gg_trg_Common_Actions_for_shoot )
endfunction
//===========================================================================
function InitTrig_Z_and_VZ takes nothing returns nothing
set gg_trg_Z_and_VZ = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Z_and_VZ, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Z_and_VZ, Condition( function Trig_Auto_Pass_Conditions ) )
call TriggerAddAction( gg_trg_Z_and_VZ, function Trig_Auto_Pass_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Targetable_Z_Conditions takes nothing returns boolean
int pid = GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))
bool b1 = udg_HeroSlidingWait[pid] == 0
bool b2 = udg_BallOwner == GetSpellAbilityUnit()
int sid = GetSpellAbilityId()
bool b31 = sid == SPELL_TARGETABLE_SHORT_PASS
bool b32 = sid == SPELL_TARGETABLE_SHORT_PASS_Y
bool b3 = b31 || b32
bool b4 = GetSpellTargetUnit() != null
return b1 and b2 and b3 && b4
endfunction
function Trig_Targetable_Z_Actions takes nothing returns nothing
unit passer = GetSpellAbilityUnit()
int pid = GetConvertedPlayerId(GetOwningPlayer(passer))
location loc_passer = GetUnitLoc(passer)
location loc_target = GetSpellTargetLoc()
unit target_unit = GetSpellTargetUnit()
if target_unit != null
if ( udg_ThrowinMode != 0 )
{
real angle = AngleBetweenUnits(passer, target_unit)
location loc_ball_new = PolarProjectionBJ(loc_passer, 100, angle)
call Ball_SetLoc(loc_ball_new)
}
set udg_PassTarget = target_unit
set udg_BallDirection = AngleBetweenUnits(udg_Ball, udg_PassTarget)
set udg_TempReal = 52.2
real dist = DistanceBetweenUnits(udg_PassTarget, udg_Ball)
set udg_BallImmuneTimer = IMinBJ(7, R2I(0.5 * dist / udg_TempReal) )
elseif loc_target != null // unused in 7.42b+
set udg_BallDirection = AngleBetweenPoints(loc_passer, loc_target)
set udg_BallImmuneTimer = 7
set udg_TempReal = 52.2
endif
set LastActionMade = ACTION_SHORT_PASS
set udg_BallInitialDirection = udg_BallDirection
call Ball_ResetHeight()
set udg_BallVZ = 0
set udg_IsBallInAir = false
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
call TriggerExecute( gg_trg_Common_Actions_for_shoot )
endfunction
//===========================================================================
function InitTrig_Z_Manual takes nothing returns nothing
set gg_trg_Z_Manual = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Z_Manual, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Z_Manual, Condition( function Trig_Targetable_Z_Conditions ) )
call TriggerAddAction( gg_trg_Z_Manual, function Trig_Targetable_Z_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Get_Pass_Target_IsAlliedHero takes nothing returns boolean
unit u = GetFilterUnit()
unit passer = GetSpellAbilityUnit()
player p = GetOwningPlayer(u)
int pid = GetConvertedPlayerId(p)
bool b1 = IsUnitAlly(u, GetOwningPlayer(passer))
bool b2 = u == udg_Hero[pid]
bool b3 = u != passer
bool b4 = IsPlayerPlaying(p)
return b1 and b2 and b3 and b4
endfunction
function Trig_Get_Pass_Target_GetDistanceOfEnumUnit takes nothing returns nothing
unit passer = GetSpellAbilityUnit()
unit u = GetEnumUnit()
real facing_u = GetUnitFacing(u)
real dist = DistanceBetweenUnits(passer, u)
if Abs( GetUnitFacing(passer) - udg_TempDirection ) < 180
set udg_DistOfEnumUnit = dist + 50 * Abs( facing_u - udg_TempDirection )
else
set udg_DistOfEnumUnit = dist + 50 * Abs( Abs( facing_u - udg_TempDirection ) - 360 )
endif
endfunction
function Trig_Get_Pass_Target_Func002Func004Func001C takes nothing returns boolean
bool b1 = udg_PassTarget == null
bool b21 = udg_DistOfEnumUnit < udg_PassTargetDistance
bool b22 = RectContainsUnit(gg_rct_PlayArea, GetEnumUnit())
int pid = GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit()))
bool b23 = not udg_HeroInAir[pid]
bool b2 = b21 and b22 and b23
return b1 or b2
endfunction
function Trig_Get_Pass_Target_Func002Func005Func002C takes nothing returns boolean
bool b1 = udg_PassTarget == null
bool b2 = udg_DistOfEnumUnit < udg_PassTargetDistance
return b1 or b2
endfunction
function Trig_Get_Pass_Target_Main takes nothing returns nothing
unit passer = GetSpellAbilityUnit()
unit u = GetEnumUnit()
real dist = DistanceBetweenUnits(passer, u)
set udg_TempDirection = AngleBetweenUnits(passer, u)
call ResetTempDirection()
call Trig_Get_Pass_Target_GetDistanceOfEnumUnit()
if Abs( GetUnitFacing(passer) - udg_TempDirection ) < 180
if ( Trig_Get_Pass_Target_Func002Func004Func001C() ) then
set udg_PassTarget = u
set udg_PassTargetDistance = dist + 50 * Abs( GetUnitFacing(passer) - udg_TempDirection )
endif
endif
if Abs( Abs( GetUnitFacing(GetSpellAbilityUnit()) - udg_TempDirection ) - 360 ) < 180
if ( Trig_Get_Pass_Target_Func002Func005Func002C() ) then
set udg_PassTarget = u
set udg_PassTargetDistance = dist + 50 * Abs( Abs( GetUnitFacing(passer) - udg_TempDirection ) - 360 )
endif
endif
endfunction
function Trig_Get_Pass_Target_Actions takes nothing returns nothing
unit u = GetSpellAbilityUnit()
location loc_unit = GetUnitLoc(u)
int team = GetUnitTeamExt(u) // !!! Ext (in case keeper has Z abil)
set udg_PassTarget = null //udg_Keeper[team]
set udg_TempDirection = AngleBetweenUnits(u, udg_PassTarget)
real dist = DistanceBetweenUnits(u, udg_PassTarget)
set udg_PassTargetDistance = dist + 50 * Abs( GetUnitFacing(u) - udg_TempDirection )
conditionfunc cond = Condition(function Trig_Get_Pass_Target_IsAlliedHero)
group g = GetUnitsInRectMatching(GetPlayableMapRect(), cond)
if AlwaysPickNearestAllyForZ {
set udg_PassTarget = GroupPickClosestUnit(g, u)
return
}
call ForGroup( g, function Trig_Get_Pass_Target_Main )
// disable z to keeper
if dist > 1200 && not IsUnitGroupEmptyBJ(g) && (udg_PassTarget == null) // && IsKeeper(udg_PassTarget)
DebugMsg("Disabling Z back, dist = "+R2S(dist))
udg_PassTarget = GroupPickClosestUnit(g, u)// GroupPickRandomUnit(g) // FirstOfGroup(g)
endif
// done
endfunction
//===========================================================================
function InitTrig_Z_Get_Pass_Target takes nothing returns nothing
set gg_trg_Z_Get_Pass_Target = CreateTrigger( )
call TriggerAddAction( gg_trg_Z_Get_Pass_Target, function Trig_Get_Pass_Target_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Chase_Pass_Target_Func003C takes nothing returns boolean
bool b11 = Abs( udg_BallDirection - udg_BallInitialDirection ) < 80
bool b12 = Abs( Abs( udg_BallDirection - udg_BallInitialDirection ) - 360 ) < 80
bool b1 = b11 or b12
bool b21 = Abs( udg_BallDirection - udg_TempDirection ) < 80
bool b22 = Abs( Abs( udg_BallDirection - udg_TempDirection ) - 360 ) < 80
bool b2 = b21 or b22
return b1 and b2
endfunction
function Trig_Chase_Pass_Target_Actions takes nothing returns nothing
call Ensure(udg_PassTarget != null)
set udg_TempDirection = AngleBetweenUnits( udg_Ball, udg_PassTarget )
call ResetTempDirection()
if ( Trig_Chase_Pass_Target_Func003C() ) then
udg_BallDirection = AngleBetweenUnits( udg_Ball, udg_PassTarget )
endif
endfunction
//===========================================================================
function InitTrig_Z_Chase_Pass_Target takes nothing returns nothing
set gg_trg_Z_Chase_Pass_Target = CreateTrigger( )
call TriggerAddAction( gg_trg_Z_Chase_Pass_Target, function Trig_Chase_Pass_Target_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
group ManualShortPassGroup = CreateGroup()
function Trig_z_mode_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
int pid = GetConvertedPlayerId(p)
unit u = udg_Hero[pid]
string msg
// TODO - shorten the ability exchange lines
if UnitHasAbil(u, SPELL_SHORT_PASS) || UnitHasAbil(u, SPELL_SHORT_PASS_Y)
set msg = "Enabled manual Z."
call UnitExchangeAbilsMsg(u, SPELL_SHORT_PASS, SPELL_TARGETABLE_SHORT_PASS, msg)
call UnitExchangeAbilsMsg(u, SPELL_SHORT_PASS_Y, SPELL_TARGETABLE_SHORT_PASS_Y, msg)
call GroupAddUnit( ManualShortPassGroup, u )
else
set msg = "Disabled manual Z."
call UnitExchangeAbilsMsg(u, SPELL_TARGETABLE_SHORT_PASS, SPELL_SHORT_PASS, msg)
call UnitExchangeAbilsMsg(u, SPELL_TARGETABLE_SHORT_PASS_Y, SPELL_SHORT_PASS_Y, msg)
call GroupRemoveUnit( ManualShortPassGroup, u )
endif
//set ManualZ = true
//call ExchangeShortPassAbilsForth()
endfunction
//===========================================================================
function InitTrig_Z_mode takes nothing returns nothing
set gg_trg_Z_mode = CreateTrigger( )
//call TriggerRegisterAnyPlayerChatEvent( gg_trg_Z_mode, "-z", true )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Z_mode, "-manual z", true )
call TriggerAddAction( gg_trg_Z_mode, function Trig_z_mode_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Kick_or_Slide_Conditions takes nothing returns bool
int sid = GetSpellAbilityId()
int pid = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
bool b1 = IsSpellKickSlide(sid)
bool b2 = udg_HeroSlidingWait[pid] == 0
return b1 and b2
endfunction
#define CommonDeclarations_Kick_or_Slide(void) = {
DoNothing()
unit u = GetTriggerUnit()
int pid = GetConvertedPlayerId(GetOwningPlayer(u))
location loc_unit = GetUnitLoc(u)
location loc_target = GetSpellTargetLoc()
real unit2target = AngleBetweenPoints(loc_unit, loc_target)
}
void Trig_Kick_or_Slide_KickActions() {
call CommonDeclarations_Kick_or_Slide()
set LastActionMade = ACTION_KICK
set udg_BallImmuneTimer = 7
call RevealUnit( udg_Flag )
set udg_BallVZ = 20
set udg_IsBallInAir = true
set udg_BallDirection = AngleBetweenPoints(Ball_GetLoc(), loc_target)
set udg_TempReal = 36.2 // 37.2
// + 1.50 * GetHeroStr( udg_BallOwner, true)
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
call TriggerExecute( gg_trg_Common_Actions_for_shoot )
}
void Trig_Kick_or_Slide_SlideActions() {
call CommonDeclarations_Kick_or_Slide()
call PlayerIncInt(pid, "slides_all")
call GroupAddUnit( udg_SlidingUnits, u )
set udg_SlidingDirection[pid] = unit2target
set udg_HeroSlidingWait[pid] = 25
set udg_HeroVX[pid] = 40
call PlaySoundOnUnitBJ( gg_snd_Shockwave, 100, u )
string path = "Abilities\\Spells\\Orc\\Shockwave\\ShockwaveMissile.mdl"
set udg_SlidingEffect[pid] = AddSpecialEffectTarget( path, u, "origin" )
set udg_TempDirection = AngleBetweenPoints(loc_unit, Ball_GetLoc())
call ConditionalTriggerExecute(gg_trg_Jump_to_avoid_slide)
//call Trig_Shoot_or_Sliding_InsaneBotJumpsToAvoidSlide()
}
function Trig_Kick_or_Slide_Actions takes nothing returns nothing
call CommonDeclarations_Kick_or_Slide()
if ( udg_BallOwner == u ) then
call Trig_Kick_or_Slide_KickActions()
elseif ( not udg_HeroInAir[pid] ) then
call Trig_Kick_or_Slide_SlideActions()
else
call ManualHeaderLib_SetTimeout(pid, loc_target)
endif
//call Ensure(not WildX)
call UnitStop( u )
call SetUnitFacing(u, unit2target)
endfunction
//===========================================================================
function InitTrig_X_Kick_or_Slide takes nothing returns nothing
set gg_trg_X_Kick_or_Slide = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_X_Kick_or_Slide, EVENT_PLAYER_UNIT_SPELL_CAST )
call TrgAddCond(gg_trg_X_Kick_or_Slide, function Trig_Kick_or_Slide_Conditions)
call TriggerAddAction( gg_trg_X_Kick_or_Slide, function Trig_Kick_or_Slide_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_NEW_Long_Pass_Conditions takes nothing returns boolean
unit u = GetTriggerUnit()
int pid = GetExtendedId(u)
bool jumping = udg_HeroInAir[pid]
int sid = GetSpellAbilityId()
bool b1 = udg_HeroSlidingWait[pid] == 0
bool b2 = not jumping || (jumping && GetUnitFlyHeight(u) < 20)
bool b3 = BallOwner == u
bool b4 = IsSpellLongPass(sid)
bool b = b1 and b2 and b3 and b4
if HighC
// high C nerf 7.43b
if (b4 && b2 && !b) {udg_HeroSlidingWait[pid] = 10}
endif
return b
endfunction
function Trig_NEW_Long_Pass_Actions takes nothing returns nothing
unit u = GetTriggerUnit()
location loc_target = GetSpellTargetLoc()
location loc_ball = GetUnitLoc(udg_Ball)
integer pid = cPid(GetTriggerPlayer())
set LastActionMade = ACTION_LONG_PASS
call ShowUnitShow( udg_Flag )
set udg_BallDirection = AngleBetweenPoints( loc_ball, loc_target )
if (not HighC)
Ball_ResetHeight()
endif
call Long_Pass_Calculate_Speed_and_vy()
// curve actions
set CurveBallFactor = udg_CurveBallFactor[pid]
set udg_CurveBallFactor[pid] = 0
string s = Curve_GetTextTagString(CurveBallFactor)
location loc_unit = GetUnitLoc(u)
if (abs(CurveBallFactor) > 0.05)
set ShallAddExclamationMark = false
texttag t = CreateExclamatoryTextTagMain(s,loc_unit,150,255,255,255)
call ShowTextTagForceBJ(false,t, GetPlayersAll())
call ShowTextTagGroup(true,t,GetUnitSquad(u))
//call ShowTextTagForceBJ(true,t, null)
endif
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
call TriggerExecute( gg_trg_Common_Actions_for_shoot )
if not IsKeeper(u)
udg_HeroSlidingWait[pid] = 10
endif
endfunction
//===========================================================================
function InitTrig_C_Long_Pass takes nothing returns nothing
set gg_trg_C_Long_Pass = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_C_Long_Pass, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_C_Long_Pass, Condition( function Trig_NEW_Long_Pass_Conditions ) )
call TriggerAddAction( gg_trg_C_Long_Pass, function Trig_NEW_Long_Pass_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
bool AllyRequestsPassFromKeeper = false
function Trig_Pass_to_ME_Actions takes nothing returns nothing
call Ensure( Sid() == ABILITY_PASS_TO_ME )
player p = GetTriggerPlayer() //GetOwningPlayer(GetSpellAbilityUnit())
integer pid = GetConvertedPlayerId(p)
force f = GetPlayersAllies(p)
unit u = GetSpellAbilityUnit()
location loc_unit = GetUnitLoc(u)
//call UnitExchangeAbils(u, ABILITY_LONG_PASS, 'A00E')
//call PlayerExchangeAbils(p, ABILITY_LONG_PASS, 'A00E')
//call ForceUIKey("C")
//call PlayerExchangeAbils(p, 'A00E', ABILITY_LONG_PASS)
//wait(5)
real R = udg_PlayerColorR[pid]
real G = udg_PlayerColorG[pid]
real B = udg_PlayerColorB[pid]
call PingMinimapLocForForceEx( f, loc_unit, 1, bj_MINIMAPPINGSTYLE_FLASHY, R,G,B )
//call DisplayTextToForce( f, udg_PlayerNames[pid] + " : Pass to me!" )
real h = GetUnitFlyHeight(u)
texttag t = CreateExclamatoryTextTag("Pass",loc_unit, h+100, R,G,B) //0,100,0)
call ShowTextTagForceBJ(false, t, GetPlayersEnemies(p))
// request pass from keeper
int team = GetUnitTeamSimple(u)
int n = udg_WhichKeeperHasBall
bool b1 = IsPlayerPlaying(p)
bool b2 = not IsKeeperPlayable || (IsKeeperPlayable && IsPlayerBot(GetKeeperController(team)))
bool b3 = team > 0
bool b4 = n!=0
bool b5 = n == team || InTesting || InTraining
bool b = b1 && b2 && b3 && b4 && b5
if b then
set AllyRequestsPassFromKeeper = true
set TempLoc = loc_unit
call TriggerExecute(gg_trg_Keeper_Throw_Ball)
endif
//call Trig_Pass_to_ME_BotMakesShortPass()
call ConditionalTriggerExecute(gg_trg_Short_pass_on_request)
endfunction
//===========================================================================
function InitTrig_D_Pass_to_me takes nothing returns nothing
set gg_trg_D_Pass_to_me = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_D_Pass_to_me, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( gg_trg_D_Pass_to_me, function Trig_Pass_to_ME_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Fetch_ball_Actions takes nothing returns nothing
//call Ensure(Sid() != 0 && Sid() == ABILITY_FETCH_BALL || Sid() == 0)
call Ensure(Sid() == ABILITY_FETCH_BALL)
int pid = GetConvertedPlayerId(GetTriggerPlayer())
unit u = udg_Hero[pid]
real facing = GetUnitFacing(u)
location loc_unit = GetUnitLoc(u)
location loc_new = PolarProjectionBJ(loc_unit, 100, facing)
call SetUnitPositionLoc(udg_Ball, loc_new)
call StopBall()
call SetBallHeight(170)
set udg_IsBallInAir = true //
set udg_BallVZ = 0
set udg_ThrowinMode = 0
set udg_BallOwner = null //
set udg_CantEnterOtherSide = false
endfunction
//===========================================================================
function InitTrig_F_Fetch_ball takes nothing returns nothing
set gg_trg_F_Fetch_ball = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_F_Fetch_ball, EVENT_PLAYER_UNIT_SPELL_EFFECT )
//call TriggerRegisterAnyPlayerChatEvent( gg_trg_F_Fetch_ball, "-fetch", true )
call TriggerAddAction( gg_trg_F_Fetch_ball, function Trig_Fetch_ball_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_T_Teleport_Actions takes nothing returns nothing
call Ensure(Sid() == ABILITY_TELEPORT)
unit u = GetTriggerUnit()
player p = GetTriggerPlayer()
if u == BallOwner { ThrowinMode = 0 }
location loc_target = GetSpellTargetLoc()
set udg_CantEnterOtherSide = false
call SetUnitLoc(u, loc_target)
endfunction
//===========================================================================
function InitTrig_T_Teleport takes nothing returns nothing
trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( t, function Trig_T_Teleport_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_v2f_heading_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
string msg = "Heading hotkey: F."
call PlayerExchangeAbilsMsg(p, 'A009', 'A004', msg)
endfunction
function Trig_f2v_heading_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
string msg = "Heading hotkey: V."
call PlayerExchangeAbilsMsg(p, 'A004', 'A009', msg)
endfunction
function Trig_v_slow_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
string msg = "Slow V enabled."
call PlayerExchangeAbilsMsg(p, 'A009', 'A005', msg)
endfunction
function Trig_v_fast_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
string msg = "Normal V enabled."
call PlayerExchangeAbilsMsg(p, 'A005', 'A009', msg)
endfunction
function Trig_Z2Y_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
string msg = "Short Pass hotkey: Y."
call PlayerExchangeAbilsMsg(p, 'A007', 'A00D', msg)
call PlayerExchangeAbilsMsg(p, 'A001', 'A006', msg)
endfunction
function Trig_y2z_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
string msg = "Short Pass hotkey: Z."
call PlayerExchangeAbilsMsg(p, 'A00D', 'A007', msg)
call PlayerExchangeAbilsMsg(p, 'A006', 'A00a', msg)
endfunction
//===========================================================================
function InitTrig_Swap_Abils takes nothing returns nothing
trigger t
set t = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( t, "-v2f", "-fr", true )
call TriggerAddAction( t, function Trig_v2f_heading_Actions )
set t = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( t, "-f2v", "-nofr", true )
call TriggerAddAction( t, function Trig_f2v_heading_Actions )
set t = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( t, "-slow", "-slow v", true )
call TriggerAddAction( t, function Trig_v_slow_Actions )
set t = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( t, "-fast", "-fast v", true )
call TriggerAddAction( t, function Trig_v_fast_Actions )
set t = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( t, "-z2y", "-ger", true )
call TriggerAddAction( t, function Trig_Z2Y_Actions )
set t = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( t, "-y2z", "-noger", true )
call TriggerAddAction( t, function Trig_y2z_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Fakie_button_Actions takes nothing returns nothing
// TODO - do not allow execution if F-ability is present (jump F, Fetch Ball)
player p = GetTriggerPlayer()
unit u = GetHero(p)
call UnitAddAbility(u, ABILITY_FAKIE)
echo(p, "Type -nofakie to remove Fakie.")
endfunction
//===========================================================================
function InitTrig_F_Fakie takes nothing returns nothing
set gg_trg_F_Fakie = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_F_Fakie, "-fakie", true )
call TriggerAddAction( gg_trg_F_Fakie, function Trig_Fakie_button_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function RemoveFakie takes nothing returns nothing
player p = GetTriggerPlayer()
unit u = GetHero(p)
call UnitRemoveAbility(u, ABILITY_FAKIE)
endfunction
//===========================================================================
function InitTrig_nofakie takes nothing returns nothing
set gg_trg_nofakie = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_nofakie, "-nofakie", true )
call TriggerAddAction( gg_trg_nofakie, function RemoveFakie )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
location LastShotLoc = null
timer LastShotTimer = CreateTimer()
boolean RecentShot = true // used only in smooth mode
function MatchStartedActions takes nothing returns nothing
static bool MatchStarted = false
call Ensure(not MatchStarted)
set MatchStarted = true
if not IsKeeperPlayable then
call UnitAddLocust(udg_Keeper[1])
call UnitAddLocust(udg_Keeper[2])
endif
endfunction
function Trig_Common_Actions_for_shoot_KeeperActions takes nothing returns nothing
set udg_CantEnterOtherSide = false
set udg_ThrowinMode = 0
call ShowUnit( udg_Ball )
call PlaySoundOnUnit(gg_snd_Kick, udg_BallOwner)
set udg_BallOwner = null
call ResumeTimer( udg_RoundTimer )
call ResumeTimer( udg_RealTimer )
call RunBallGeneralAnimations()
endfunction
function Trig_Common_Actions_for_shoot_Actions takes nothing returns nothing
unit u = GetTriggerUnit()
if IsKeeper(u) then
call Trig_Common_Actions_for_shoot_KeeperActions()
return
endif
// setting curve factor
// code disabled due to bug - can't do c or vz at all
/*int lam = LastActionMade
if CurvedBall && (lam == ACTION_LONG_PASS || lam == ACTION_VZ && CurvedVZ)
set CurveBallFactor = udg_CurveBallFactor[pid]
set udg_CurveBallFactor[pid] = 0
else
set CurveBallFactor = 0
endif*/
set LastShotLoc = GetUnitLoc(udg_BallOwner)
call MatchStartedActions()
call ShowUnit( udg_Ball )
call ResumeTimer( udg_RoundTimer )
call ResumeTimer( udg_RealTimer )
set udg_CantEnterOtherSide = false
set udg_ThrowinMode = 0
int pid = cPid(GetOwningPlayer(udg_BallOwner))
set udg_CantHoldBall[pid] = 10
//call PlaySoundOnUnit(gg_snd_Kick, udg_BallOwner)
call Audio_PlaySound(SOUND_PLAYER_KICK)
set udg_BallOwner = null
call TriggerExecute( gg_trg_MoveSpeed_of_Players )
call RunBallGeneralAnimations()
//call Ensure(InTesting)
set LastShotTimer = CreateTimerBJ( false, INFINITY_TIME )
endfunction
//===========================================================================
function InitTrig_Common_Actions_for_shoot takes nothing returns nothing
set gg_trg_Common_Actions_for_shoot = CreateTrigger( )
call TriggerAddAction( gg_trg_Common_Actions_for_shoot, function Trig_Common_Actions_for_shoot_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Heading_Conditions takes nothing returns boolean
int pid = GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))
int sid = GetSpellAbilityId()
bool b1 = not udg_HeroInAir[pid]
bool b2 = IsSpellJump(sid)
bool b3 = udg_HeroSlidingWait[pid] <= 0
return b1 and b2 and b3
endfunction
function Trig_Heading_Actions takes nothing returns nothing
unit u = GetSpellAbilityUnit()
int pid = GetExtendedId(u)
if ManualZ
call ExchangeShortPassAbilsBack()
endif
if ( udg_BallOwner == u ) then
set udg_HeroVY[pid] = 15
set udg_HeroInAir[pid] = true
call PolledWait( 2 )
call UnitRemoveBuffBJ( 'Bowk', u )
else
set udg_HeroVY[pid] = 20 + GetHeroStr(u, true)
set udg_HeroInAir[pid] = true
endif
endfunction
//===========================================================================
function InitTrig_Jumping takes nothing returns nothing
set gg_trg_Jumping = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Jumping, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddConditionSimple( gg_trg_Jumping, function Trig_Heading_Conditions )
call TriggerAddAction( gg_trg_Jumping, function Trig_Heading_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
define IsUnitInRects(u, r1, r2) = {
( IsUnitInRect(u, r1) || IsUnitInRect(u, r2) )
}
enum (penalty zones) { NONE, LEFT_BOX, RIGHT_BOX }
bool IsBallShootable(int whichBox) {
rect r1,r2
if whichBox == LEFT_BOX {
set r1 = gg_rct_PenaltyAreaLeft
set r2 = gg_rct_GoalLeft
} else {
set r1 = gg_rct_PenaltyAreaRight
set r2 = gg_rct_GoalRight
}
bool b1 = IsUnitInRects(GetEnumUnit(),r1,r2)
bool b2 = IsUnitInRects(Ball,r1,r2)
return b1 || b2
}
function Trig_Do_Headding_Action_Actions takes nothing returns nothing
unit u = GetEnumUnit()
int pid = GetExtendedId(u)
if ( udg_ThrowinMode == 0 ) then
udg_IndirectFreeKick = false
endif
set BallOwner = null
call PassSuccessUpdate(PS_EVENT_PLAYER_HEAD_BALL)
call UpdateLK()
if ( xvFalseFixEnabled && Interval_001_Execution ) then
set CantHoldBall[pid] = 9
set BallImmuneTimer = 9
else
set CantHoldBall[pid] = 10
set BallImmuneTimer = 10
endif
if IsBallShootable(LEFT_BOX) && IsUnitFromRightTeam(u) then
call TriggerExecute( gg_trg_Heading_Ball_to_left_goal )
set LastActionMade = ACTION_HEADING_SHOT
elseif IsBallShootable(RIGHT_BOX) && IsUnitFromLeftTeam(u) then
call TriggerExecute( gg_trg_Heading_Ball_to_right_goal )
set LastActionMade = ACTION_HEADING_SHOT
else
call TriggerExecute( gg_trg_Heading_Ball_to_nearby_friend )
set LastActionMade = ACTION_HEADING_PASS
endif
endfunction
//===========================================================================
function InitTrig_Do_Heading_Action takes nothing returns nothing
set gg_trg_Do_Heading_Action = CreateTrigger( )
call TriggerAddAction( gg_trg_Do_Heading_Action, function Trig_Do_Headding_Action_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Set_Nearby_Friend_to_Headding_Target_FilterFunc takes nothing returns boolean
bool b1 = FilterPlayerStatePlaying()
bool b2 = IsUnitAlly(GetEnumUnit(), GetFilterPlayer())
return b1 && b2
endfunction
function Trig_Set_Nearby_Friend_to_Headding_Target_Func001Func001Func002002 takes nothing returns boolean
int pid = GetConvertedPlayerId(GetEnumPlayer())
unit u = GetEnumUnit()
real dist1 = DistanceBetweenUnits(u, udg_Hero[pid])
real dist2 = DistanceBetweenUnits(u, udg_UnitHeadingTarget)
return dist1 < dist2
endfunction
function Trig_Set_Nearby_Friend_to_Headding_Target_Func001Func001C takes nothing returns boolean
bool b11 = udg_UnitHeadingTarget == null
bool b12 = Trig_Set_Nearby_Friend_to_Headding_Target_Func001Func001Func002002()
bool b1 = b11 || b12
player p = GetEnumPlayer()
int pid = GetConvertedPlayerId(p)
bool b2 = GetEnumUnit() != udg_Hero[pid]
bool b3 = IsPlayerPlaying(p)
return b1 && b2 && b3
endfunction
function Trig_Set_Nearby_Friend_to_Headding_Target_Main takes nothing returns nothing
int pid = GetConvertedPlayerId(GetEnumPlayer())
if ( Trig_Set_Nearby_Friend_to_Headding_Target_Func001Func001C() ) then
set udg_UnitHeadingTarget = udg_Hero[pid]
endif
endfunction
function Trig_Set_Nearby_Friend_to_Headding_Target_Actions takes nothing returns nothing
force f = GetPlayersMatching(Condition(function Trig_Set_Nearby_Friend_to_Headding_Target_FilterFunc))
call ForForce( f, function Trig_Set_Nearby_Friend_to_Headding_Target_Main )
endfunction
//===========================================================================
function InitTrig_Set_Nearby_Friend_to_Heading_Target takes nothing returns nothing
set gg_trg_Set_Nearby_Friend_to_Heading_Target = CreateTrigger( )
call TriggerAddAction( gg_trg_Set_Nearby_Friend_to_Heading_Target, function Trig_Set_Nearby_Friend_to_Headding_Target_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Headding_Ball_to_left_goal_Actions takes nothing returns nothing
set udg_HeadingTarget = GetRandomLocInRect(gg_rct_HeadingShootAreaLeft)
call TriggerExecute( gg_trg_Calculate_Speed_and_vy_for_heading_shot )
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
call TriggerExecute( gg_trg_Common_Actions_for_shoot )
endfunction
//===========================================================================
function InitTrig_Heading_Ball_to_left_goal takes nothing returns nothing
set gg_trg_Heading_Ball_to_left_goal = CreateTrigger( )
call TriggerAddAction( gg_trg_Heading_Ball_to_left_goal, function Trig_Headding_Ball_to_left_goal_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Headding_Ball_to_right_goal_Actions takes nothing returns nothing
set udg_HeadingTarget = GetRandomLocInRect(gg_rct_HeadingShootAreaRight)
call TriggerExecute( gg_trg_Calculate_Speed_and_vy_for_heading_shot )
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
call TriggerExecute( gg_trg_Common_Actions_for_shoot )
endfunction
//===========================================================================
function InitTrig_Heading_Ball_to_right_goal takes nothing returns nothing
set gg_trg_Heading_Ball_to_right_goal = CreateTrigger( )
call TriggerAddAction( gg_trg_Heading_Ball_to_right_goal, function Trig_Headding_Ball_to_right_goal_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Headding_Ball_to_nearby_friend_Actions takes nothing returns nothing
call ShowUnitShow( udg_Flag )
call TriggerExecute( gg_trg_Calculate_Speed_and_vy_for_heading )
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
call TriggerExecute( gg_trg_Common_Actions_for_shoot )
endfunction
//===========================================================================
function InitTrig_Heading_Ball_to_nearby_friend takes nothing returns nothing
set gg_trg_Heading_Ball_to_nearby_friend = CreateTrigger( )
call TriggerAddAction( gg_trg_Heading_Ball_to_nearby_friend, function Trig_Headding_Ball_to_nearby_friend_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Calcurate_Speed_and_vy_for_headding_Actions takes nothing returns nothing
set udg_IsBallInAir = true
set udg_TempReal = 35 //+ GetHeroStr(GetEnumUnit(), true) * 2
set udg_TempReal = RMaxBJ( 0.1*GetBallSpeed(), udg_TempReal)
call TriggerExecute( gg_trg_Get_Heading_Target )
location loc_target = GetUnitLoc(udg_UnitHeadingTarget)
// manual header part begins
int pid = cPid(GetOwningPlayer(GetEnumUnit())) //GetTriggerPlayer() caused bug in a3.1
/* if pid == 1
{ echo ("c_pid = 1 !!!") } */
if ManualHeaderLib_IsAimingManual(pid)
set loc_target = HeaderAimingLocation[pid]
set HeaderAimingTimer[pid] = 0
endif
// manual header part ends
real dist = DistanceBetweenPoints( Ball_GetLoc(), loc_target)
real h_ball = Ball_GetHeight()
real coef = SquareRoot( 2 * h_ball / udg_G )
if dist <= udg_TempReal * coef
set udg_BallVZ = 0
set udg_TempReal = dist / coef
else
set udg_BallVZ = RMinBJ(udg_MaxBVYforHeading, udg_G * dist * 0.5 / udg_TempReal )
endif
set udg_BallDirection = AngleBetweenPoints(Ball_GetLoc(), loc_target)
endfunction
//===========================================================================
function InitTrig_Calculate_Speed_and_vy_for_heading takes nothing returns nothing
set gg_trg_Calculate_Speed_and_vy_for_heading = CreateTrigger( )
call TriggerAddAction( gg_trg_Calculate_Speed_and_vy_for_heading, function Trig_Calcurate_Speed_and_vy_for_headding_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Calcurate_Speed_and_vy_for_headding_shoot_Actions takes nothing returns nothing
int pid = cPid(GetOwningPlayer(GetEnumUnit()))
bool IsAimingManual = ManualHeaderLib_IsAimingManual(pid)
call ManualHeaderLib_SetHeadingTargetIfNeeded()
location loc_ball = GetUnitLoc(udg_Ball)
real dist = DistanceBetweenPoints(loc_ball, udg_HeadingTarget)
set udg_BallVZ = 0
set udg_IsBallInAir = true
set udg_BallDirection = AngleBetweenPoints( loc_ball, udg_HeadingTarget)
set udg_TempReal = 35 // + GetHeroStr(GetEnumUnit(), true) * 2
set udg_TempReal = RMaxBJ( Ball_GetSpeed() * 0.1, udg_TempReal)
if IsAimingManual
real h_ball = Ball_GetHeight()
real coef = SquareRoot( 2 * h_ball / udg_G )
if dist <= udg_TempReal * coef
set udg_BallVZ = 0
set udg_TempReal = dist / coef
else
set udg_BallVZ = RMinBJ(udg_MaxBVYforHeading, udg_G * dist * 0.5 / udg_TempReal )
endif
else
set udg_BallVZ = udg_TempReal/dist*( 120 - Ball_GetHeight() ) + udg_G*dist*0.5/udg_TempReal
endif
endfunction
//===========================================================================
function InitTrig_Calculate_Speed_and_vy_for_heading_shot takes nothing returns nothing
set gg_trg_Calculate_Speed_and_vy_for_heading_shot = CreateTrigger( )
call TriggerAddAction( gg_trg_Calculate_Speed_and_vy_for_heading_shot, function Trig_Calcurate_Speed_and_vy_for_headding_shoot_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Get_Headding_Target_ChooseKeeperAsTarget takes int whichKeeper returns bool
return FALSE
unit u = GetEnumUnit()
bool b21 = HeadToKeeperOnlyInBox
bool b22 = IsUnitInRect(u, udg_PenaltyArea[whichKeeper])
//bool b2 = b21 && b22
if b21 && not b22
return false
endif
//Ensure(b2,)
bool b = DistanceBetweenUnits(udg_Keeper[whichKeeper], udg_Ball) <= udg_TempReal / udg_G * ( udg_MaxBVYforHeading + SquareRoot( Pow(udg_MaxBVYforHeading, 2) + 2 * udg_G * GetBallHeight() ) )
return b
endfunction
function IsFilterUnitEnemyOfTempPlayer takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), TempPlayer)
endfunction
function Trig_Get_Headding_Target_Func002Func002C takes int pid returns bool
unit hero = udg_Hero[pid]
player p = ConvertedPlayer(pid)
bool b1 = udg_HeadingTargetFitness > udg_FitnessOfPlayerA
bool b2 = DistanceBetweenUnits(GetEnumUnit(), hero) <= udg_TempReal * ( udg_MaxBVYforHeading + SquareRoot( Pow(udg_MaxBVYforHeading, 2) + 2 * udg_G * GetBallHeight() ) ) / udg_G
bool b3 = IsUnitAlly(GetEnumUnit(), p)
bool b4 = GetEnumUnit() != hero
bool b5 = IsPlayerPlaying(p)
bool b = b1 && b2 && b3 && b4 && b5
return b
endfunction
function CalculateHeadingTargetFitness takes unit u, conditionfunc cond returns int
int n1,n2,n3,n4
int n
location loc_unit = GetUnitLoc(u)
set n1 = CountUnitsInRangeOfLocMatching(200, loc_unit, cond)
set n2 = CountUnitsInRangeOfLocMatching(400, loc_unit, cond)
set n3 = CountUnitsInRangeOfLocMatching(600, loc_unit, cond)
set n4 = CountUnitsInRangeOfLocMatching(800, loc_unit, cond)
set n = n1 + n2 + n3 + n4
return n
endfunction
function Trig_Get_Headding_Target_Actions takes nothing returns nothing
conditionfunc cond
if IsEnumUnitPeasant() then
if ( Trig_Get_Headding_Target_ChooseKeeperAsTarget(1) ) then
set cond = Condition(function IsFilterUnitPeon)
set udg_UnitHeadingTarget = udg_Keeper[1]
set udg_HeadingTargetFitness = CalculateHeadingTargetFitness(udg_UnitHeadingTarget, cond)
else
set udg_UnitHeadingTarget = null
set udg_HeadingTargetFitness = 40
endif
else
if ( Trig_Get_Headding_Target_ChooseKeeperAsTarget(2) ) then
set cond = Condition(function IsFilterUnitPeasant)
set udg_UnitHeadingTarget = udg_Keeper[2]
set udg_HeadingTargetFitness = CalculateHeadingTargetFitness(udg_UnitHeadingTarget, cond)
else
set udg_UnitHeadingTarget = null
set udg_HeadingTargetFitness = 40
endif
endif
int pid = 1
whilenot (pid > 12) {
set TempPlayer = ConvertedPlayer(pid)
set cond = Condition(function IsFilterUnitEnemyOfTempPlayer)
set udg_FitnessOfPlayerA = CalculateHeadingTargetFitness(udg_Hero[pid], cond)
if ( Trig_Get_Headding_Target_Func002Func002C(pid) ) then
set udg_UnitHeadingTarget = udg_Hero[pid]
set udg_HeadingTargetFitness = udg_FitnessOfPlayerA
endif
pid++
}
if IsKeeper(GetEnumUnit()) then
udg_UnitHeadingTarget = null
endif
if ( udg_UnitHeadingTarget == null ) then
call TriggerExecute( gg_trg_Set_Nearby_Friend_to_Heading_Target )
endif
endfunction
//===========================================================================
function InitTrig_Get_Heading_Target takes nothing returns nothing
set gg_trg_Get_Heading_Target = CreateTrigger( )
call TriggerAddAction( gg_trg_Get_Heading_Target, function Trig_Get_Headding_Target_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
bool IsManualHeaderAimingEnabled = true
int array HeaderAimingTimer
location array HeaderAimingLocation
constant integer HEADER_AIMING_TIMEOUT = 7
lib_init( ManualHeaderLib, init , StdLib )
// executed from Timer Interval 01 trigger
public void UpdateTimers() {
int i=0
while i<=15
{
call DecIfPositive(HeaderAimingTimer[i])
if HeaderAimingTimer[i] == 0
set HeaderAimingLocation[i] = null
endif
i++
}
}
public bool IsAimingManual(int pid) {
bool b1 = IsManualHeaderAimingEnabled
bool b2 = HeaderAimingTimer[pid] > 0
bool b3 = HeaderAimingLocation[pid] != null
return b1 && b2 && b3
}
public void SetHeadingTargetIfNeeded() {
int pid = cPid(GetOwningPlayer(GetEnumUnit()))
if IsAimingManual(pid)
set udg_HeadingTarget = HeaderAimingLocation[pid]
set HeaderAimingTimer[pid] = 0
endif
}
public void SetTimeout(int pid, location loc_target) {
set HeaderAimingTimer[pid] = HEADER_AIMING_TIMEOUT
set HeaderAimingLocation[pid] = loc_target
}
private void init() {
int i=0
while i<=15
{
set HeaderAimingTimer[i] = 0
set HeaderAimingLocation[i] = null
i++
}
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function GetTriggerGoal takes nothing returns int
if RectContainsBall(gg_rct_GoalLeft) then
return 1
elseif RectContainsBall(gg_rct_GoalRight) then
return 2
endif
return 0
endfunction
function UncountedCGoal takes nothing returns bool
bool b1 = CGoalsBan
bool b2 = LastActionMade == ACTION_LONG_PASS
bool b3 = not NoGoals
return b1 && b2 && b3
endfunction
function GoalCounts takes nothing returns bool
bool b1 = not udg_IndirectFreeKick
bool b2 = not UncountedCGoal()
bool b3 = not NoGoals
return b1 && b2 && b3
endfunction
function Trig_Check_Linecross_GoalCheck takes real h, real h_count returns nothing
if RectContainsBall(gg_rct_GoalLeft) or RectContainsBall(gg_rct_GoalRight) then
if ( h <= h_count ) && GoalCounts() then
call TriggerExecute( gg_trg_Goal )
endif
endif
endfunction
void CGoalMsg() {
echo()
echo("C goals count only in "+Hotkey("-easy")+" mode.")
}
function Trig_Check_Linecross_Actions takes nothing returns nothing
call Ensure(udg_ThrowinMode == 0)
int time = udg_BallImmuneTimer
real time_passed = TimerGetElapsed(LastShotTimer)
real h_count = MINIMUM_BAR_HEIGHT + 5
real h = GetUnitFlyHeight(udg_Ball)
int whichGoal = GetTriggerGoal()
/*if InvisibleWalls then
call Trig_Check_Linecross_GoalCheck(h, h_count)
return // don't check for linecross
endif*/
if ( time <= 0 ) then
if RectContainsBall(gg_rct_LineBTM) || RectContainsBall(gg_rct_LineTOP)
bool b = LastActionMade == ACTION_LONG_PASS
if !b || (b && time_passed > 0.9) then // C throw-in protectionism
call TriggerExecute( gg_trg_Line_Top_Bottom_Crossed )
return
endif
elseif RectContainsBall(gg_rct_LineLT) || RectContainsBall(gg_rct_LineLB)
call TriggerExecute( gg_trg_Left_Top_Bottom_Crossed )
return
elseif RectContainsBall(gg_rct_LineRT) || RectContainsBall(gg_rct_LineRB)
call TriggerExecute( gg_trg_Right_Top_Bottom_Crossed )
return
endif
endif
// TOP LEFT GOAL LINE, BOTTOM LEFT GOAL LINE, TOP RIGHT GOAL LINE, BOTTOM RIGHT GOAL LINE
if ( h > h_count ) || udg_IndirectFreeKick || UncountedCGoal() // && h <= h_count // && IsOwnGoal(whichGoal, LK)
if RectContainsBall(gg_rct_LeftTop2) || RectContainsBall(gg_rct_LeftBottom2) then
if UncountedCGoal() && h <= h_count
call CGoalMsg()
endif
call TriggerExecute( gg_trg_Left_Top_Bottom_Crossed )
return
elseif RectContainsBall(gg_rct_RightTop2) || RectContainsBall(gg_rct_RightBottom2) then
if UncountedCGoal() && h <= h_count
call CGoalMsg()
endif
call TriggerExecute( gg_trg_Right_Top_Bottom_Crossed )
return
endif
endif
call Trig_Check_Linecross_GoalCheck(h, h_count)
endfunction
//===========================================================================
function InitTrig_Check_Linecross takes nothing returns nothing
set gg_trg_Check_Linecross = CreateTrigger( )
call TriggerAddAction( gg_trg_Check_Linecross, function Trig_Check_Linecross_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Top_Line_Crossed_Actions takes nothing returns nothing
int team
echo()
if IsUnitInTeamExt(LK,1) then
team = 2
//echo( "TRIGSTR_111" )
else
team = 1
//echo( "TRIGSTR_110" )
endif
call TeamIncInt( team, "throwins")
echo( TeamName[team] + "'s throw-in!" )
location loc_line
if Ball_IsInRect(gg_rct_LineTOP)
loc_line = GetRectCenter(gg_rct_TopLine)
else
loc_line = GetRectCenter(gg_rct_BottomLine)
endif
set udg_ThrowinLoc = Location(Ball_GetX(), GetLocationY(loc_line))
set TempInt = team
call TriggerExecute( gg_trg_Linecross_common_events )
endfunction
//===========================================================================
function InitTrig_Line_Top_Bottom_Crossed takes nothing returns nothing
set gg_trg_Line_Top_Bottom_Crossed = CreateTrigger( )
call TriggerAddAction( gg_trg_Line_Top_Bottom_Crossed, function Trig_Top_Line_Crossed_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Top_Left_Crossed_Actions takes nothing returns nothing
int team
echo()
if ( IsUnitFromLeftTeam(LK) ) then
if ( udg_Round == 0 ) then
set team = 2
else
set team = 1
endif
call TeamIncInt( team, "corners")
echo( "TRIGSTR_123" )
echo( udg_RightTeamName + "'s corner kick!" )
set udg_ThrowinLoc = GetCornerLoc()
else
if ( udg_Round == 0 ) then
set team = 1
else
set team = 2
endif
call TeamIncInt( team, "goalkicks")
echo( "TRIGSTR_123" )
echo( udg_LeftTeamName + "'s goal kick!" )
set udg_ThrowinLoc = GetRandomLocInRect(gg_rct_LeftGoalKick)
endif
set TempInt = team
call TriggerExecute( gg_trg_Linecross_common_events )
endfunction
//===========================================================================
function InitTrig_Left_Top_Bottom_Crossed takes nothing returns nothing
set gg_trg_Left_Top_Bottom_Crossed = CreateTrigger( )
call TriggerAddAction( gg_trg_Left_Top_Bottom_Crossed, function Trig_Top_Left_Crossed_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Top_Right_Crossed_Actions takes nothing returns nothing
int team
echoln( "TRIGSTR_123" )
if ( IsUnitFromLeftTeam(LK) ) then
set team = IntegerTertiaryOp( (udg_Round == 0), 2, 1 )
call TeamIncInt( team, "goalkicks")
echo( udg_RightTeamName + "'s goal kick!" )
set udg_ThrowinLoc = GetRandomLocInRect(gg_rct_RightGoalKick)
else
set team = IntegerTertiaryOp( (udg_Round == 0), 1, 2 )
call TeamIncInt( team, "corners")
echo( udg_LeftTeamName + "'s corner kick!" )
set udg_ThrowinLoc = GetCornerLoc()
endif
set TempInt = team
call TriggerExecute( gg_trg_Linecross_common_events )
endfunction
//===========================================================================
function InitTrig_Right_Top_Bottom_Crossed takes nothing returns nothing
set gg_trg_Right_Top_Bottom_Crossed = CreateTrigger( )
call TriggerAddAction( gg_trg_Right_Top_Bottom_Crossed, function Trig_Top_Right_Crossed_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
bool ShallRemoveUnitsFromRange = true
function Trig_Linecross_common_events_Actions takes nothing returns nothing
set udg_ThrowinMode = TempInt
set BallOwner = null
set BallImmuneTimer = 15 // 11/10 is unstable (comm.needed - unstable for what?)
set ShallRemoveUnitsFromRange = false
call PauseTimer( udg_RealTimer )
if GetChance(1)
//call Audio_PlaySound(SOUND_WHISTLE_MEDIUM)
endif
call PolledWait(1)
echo( )
set ShallRemoveUnitsFromRange = true
call Ball_SetLoc( udg_ThrowinLoc )
call RemoveEnemyUnitsFromRangeOfBall()
set udg_ThrowInWaitTimer = 4
set udg_IndirectFreeKick = true
call GroupClear( udg_SlidingUnits )
call HideUnit( udg_Flag )
call Ball_Stop()
call Ball_Land()
call PS_Update(PS_EVENT_LINECROSS)
call PS_NullifyParams()
set BallOwner = null
set LastActionMade = ACTION_GAME_PAUSED
set BallHitGroundAfterX = false
set BallImmuneTimer = 0
endfunction
//===========================================================================
function InitTrig_Linecross_common_events takes nothing returns nothing
set gg_trg_Linecross_common_events = CreateTrigger( )
call TriggerAddAction( gg_trg_Linecross_common_events, function Trig_Linecross_common_events_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib ( GoalLib , StatsLib )
function UpdateUpperScoreEnum takes nothing returns nothing
call SetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD, udg_Score[1])
call SetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_LUMBER, udg_Score[2])
endfunction
function UpdateUpperScore takes nothing returns nothing
call ForForce(GetPlayersAll(), function UpdateUpperScoreEnum)
endfunction
function UpdateTeamScore takes integer whichGoal returns nothing
integer team = 0
if ( whichGoal == 1 ) then // left goal
if ( udg_Round == 0 ) then
team = 2
else
team = 1
endif
endif
if ( whichGoal == 2 ) then // right goal
if ( udg_Round == 0 ) then
team = 1
else
team = 2
endif
endif
set udg_Score[team] += 1
call TeamIncInt(team, "score")
//call MMD_LogEvent1("goal", I2S(team))
endfunction
function IsOwnGoal takes integer whichGoal, unit scorer returns boolean
// Checks globals: RoundCheck, Keeper[]
// for use in G&A update funcs in goal trigger(s)
local boolean b
if ( udg_Round == 0 ) then
if ( whichGoal == 1 ) then
// Left goal, 1st half --> Is scorer from team 1?
set b = IsUnitInTeamExt(scorer,1)
else
// Right goal, 1st half --> Is scorer from team 2?
set b = IsUnitInTeamExt(scorer,2)
endif
else
if ( whichGoal == 1 ) then
// Left goal, 2nd half --> Is scorer from team 2?
set b = IsUnitInTeamExt(scorer,2)
else
// Right goal, 2nd half --> Is scorer from team 1?
set b = IsUnitInTeamExt(scorer,1)
endif
endif
return b
endfunction
function UpdateAssists takes int pid returns nothing
++ udg_nAssists[pid]
call PlayerIncInt(pid, "assists")
//call MMD_UpdateValueInt("assists", ConvertedPlayer(pid), MMD_OP_ADD, 1)
// max number of assists
int nassists = PlayerGetInt(pid, "assists")
if ( nassists > PlayerGetInt(0, "assists") )
PlayerStoreInt(0, "assists", nassists)
endif
endfunction
function UpdateAssistInfo takes integer whichGoal returns nothing
if IsOwnGoal(whichGoal, LK) || L2K == null || L2K == LK then
return
endif
bool b1 = IsKeeperAlly(L2K,LK)
bool b2 = not IsKeeper(L2K) && IsUnitAlly(L2K,GetOwningPlayer(LK))
if not (b1 || b2)
return
endif
call OverHeadFlashEffect(L2K)
int pid_L2K = GetExtendedId(L2K)
int pid_owner = GetOwnerId(L2K)
call UpdateAssists(pid_L2K)
if pid_owner != pid_L2K && IsUnitKeeperUnderControl(L2K)
call UpdateAssists(pid_owner)
set pid_L2K = pid_owner
endif
string assister = udg_PlayerNames[pid_L2K]
echo( "Assists: " + assister )
endfunction
function UpdateGoals takes int pid returns nothing
udg_PlayerScore[pid] ++
PlayerIncInt(pid, "goals")
//call MMD_UpdateValueInt("goals", ConvertedPlayer(pid), MMD_OP_ADD, 1)
int ngoals = PlayerGetInt(pid, "goals")
if ( ngoals > PlayerGetInt(0, "goals") )
PlayerStoreInt(0, "goals", ngoals)
endif
endfunction
function UpdatePlayerScore takes integer whichGoal returns nothing
integer pid_LK = GetExtendedId(LK)
if ( IsOwnGoal(whichGoal, LK) ) then
call PlayerIncInt(pid_LK, "owngoals")
return
endif
call OverHeadFlashEffect(LK)
call UpdateGoals(pid_LK)
int pid_owner = GetOwnerId(LK)
if pid_owner != pid_LK
call UpdateGoals(pid_owner)
endif
endfunction
function SetThrowinMode takes integer whichGoal returns integer
if ( udg_Round == 0 ) then
if ( whichGoal == 1 ) then
set udg_ThrowinMode = 1
else
set udg_ThrowinMode = 2
if CanGetBallAfterGoal && InTesting
udg_ThrowinMode = 1
endif
endif
else
if ( whichGoal == 1 ) then
set udg_ThrowinMode = 2
else
set udg_ThrowinMode = 1
endif
endif
return udg_ThrowinMode
endfunction
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Left_Goal_Actions takes nothing returns nothing
string name
integer pid_LK = GetExtendedId(LK)
int whichGoal
//testmsg(1)
if RectContainsBall(gg_rct_GoalLeft) then
set whichGoal = 1
else
set whichGoal = 2
endif
// int whichGoal = Ball_IsInRect(rct) ? 1 : 2
//testmsg(2)
call DisableTrigger( gg_trg_Timer_Interval_001 )
//call DisableTrigger( gg_trg_Timer_Interval_01 )
call PauseTimer( udg_RealTimer )
unit u = Hero[pid_LK]
set name = GetHeroProperName(u) //udg_PlayerNames[pid_LK]
if not IsKeeper(LK)
integer team = GetUnitTeamSimple(u)
set name = ColorizeByNation(name, TeamGetInt(team,"nation_id"))
endif
string controller = ""
int pid = GetConvertedPlayerId(GetOwningPlayer(LK))
set controller = udg_PlayerNames[pid_LK]
if not(IsKeeperPlayable && IsKeeper(LK)) && not IsKeeper(LK)
set controller = " ("+controller+")"
endif
echoln( name + controller + " made a goal!" )
if ( whichGoal == 1 ) then
name = udg_RightTeamName
else
name = udg_LeftTeamName
endif
echo( name + " Scored!" )
//testmsg(4)
//testmsg(5)
call SetThrowinMode( whichGoal )
call UpdateTeamScore(whichGoal)
call UpdateAssistInfo(whichGoal)
call TriggerExecute( gg_trg_Common_actions_after_a_goal )
call Ensure(not udg_GoldenGoal)
//testmsg(6)
call PolledWait( 2 )
call UpdatePlayerScore(whichGoal)
call Scoreboard3D_UpdateScore()
call UpdateUpperScore()
call Scoreboard_Refresh()
call Ensure(IsInSet(udg_Round, FIRST_HALF, SECOND_HALF))
// exiting in case when stoppage time finished
// indicator: roundcheck
if ( whichGoal == 1 ) then
set name = udg_LeftTeamName
else
set name = udg_RightTeamName
endif
// set name = whichGoal == 1 ? udg_LeftTeamName : udg_RightTeamName
echo( name + "'s ball!" )
echo( )
endfunction
//===========================================================================
function InitTrig_Goal takes nothing returns nothing
set gg_trg_Goal = CreateTrigger( )
call TriggerAddAction( gg_trg_Goal, function Trig_Left_Goal_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_common_actions_after_a_goal_ResetPlayerProperties takes nothing returns nothing
player p = GetEnumPlayer()
int pid = GetConvertedPlayerId(p)
call DestroyEffectBJ( udg_SlidingEffect[pid] )
call SetUnitFlyHeightBJ( udg_Hero[pid], 0.00, 0.00 )
set udg_HeroVX[pid] = 0.00
set udg_HeroVY[pid] = 0.00
set udg_HeroInAir[pid] = false
set udg_HeroSlidingWait[pid] = 0
location loc_center = GetPitchCenter()
call PanCameraToTimedLocForPlayer( p, loc_center, 0 )
if ( udg_CameraLock[pid] ) then
call SetCameraTargetControllerNoZForPlayer( p, udg_Hero[pid], 0, 0, false )
endif
endfunction
function Trig_common_actions_after_a_goal_Actions takes nothing returns nothing
//call Ensure(IsInSet(udg_Round, FIRST_HALF, SECOND_HALF))
set udg_MapReset = true
call ShowUnit( udg_Ball )
call HideUnit( udg_Flag )
set udg_IndirectFreeKick = true
set udg_BallOwner = null
call StartSound( gg_snd_GoodJob )
call SetMusicVolume(100)
call Audio_PlaySound( SOUND_GOLAZO )
set udg_BallImmuneTimer = 20 // added
call PolledWait( 0.5 )
call MaskFadeOut( 1.5 )
call PolledWait( 2.5 )
//===========================================================================
// TIME PERIOD 2
call SetUnitPositionLoc(udg_Keeper[1], GetRectCenter(udg_PenaltyArea[1]))
call SetUnitPositionLoc(udg_Keeper[2], GetRectCenter(udg_PenaltyArea[2]))
call Ball_Land()
call Ball_Stop()
set udg_WhichKeeperHasBall = 0
set udg_KeeperBallHoldTimer = 0
//call DestroyEffect( udg_BallInHandEffect )
call Ball_Show()
if ( udg_GoldenGoal ) && ( udg_Score[1] != udg_Score[2] )
{
call TimesUp()
return
}
call GroupClear( udg_SlidingUnits )
force f = GetPlayersMatching(Condition(function FilterPlayerStatePlaying))
call ForForce( f, function Trig_common_actions_after_a_goal_ResetPlayerProperties )
Sleep()
/*call PanCameraToTimedLocForPlayer(GetLocalPlayer(), Scoreboard3D_GetLoc(), 1. )
call PanCameraToTimedLocForPlayer(GetLocalPlayer(), GetPitchCenter(), 1. )*/
//call Scoreboard_Refresh() // moved to Goal trg
set udg_ThrowinLoc = GetPitchCenter()
call Ball_SetLoc( udg_ThrowinLoc )
call TriggerExecute(gg_trg_Reset_player_locations)
if ( IsKeeperPlayable ) then
call ResetPlayableKeeper()
endif
if udg_Round < 3 // fade-in issue fix
call MaskFadeIn(1)
endif
if udg_Round != 1 then
set udg_CantEnterOtherSide = true
endif
set LastActionMade = ACTION_GAME_PAUSED
call PSLib_NullifyParams()
set BallImmuneTimer = 0
set udg_MapReset = false
//call Audio_PlaySound(SOUND_WHISTLE_MEDIUM)
call EnableTrigger( gg_trg_Timer_Interval_01 )
call EnableTrigger( gg_trg_Timer_Interval_001 )
call WaitForSoundBJ(snd_golazo, 0)
call SetMusicVolume(500)
endfunction
//===========================================================================
function InitTrig_Common_actions_after_a_goal takes nothing returns nothing
set gg_trg_Common_actions_after_a_goal = CreateTrigger( )
call TriggerAddAction( gg_trg_Common_actions_after_a_goal, function Trig_common_actions_after_a_goal_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_common_actions_after_a_goal_IsHero takes nothing returns boolean
local integer pid = GetConvertedPlayerId(GetOwningPlayer(GetFilterUnit()))
local boolean b1 = udg_Hero[pid] == GetFilterUnit()
local boolean b2 = not IsPlayerInForce( GetOwningPlayer(GetFilterUnit()), Observers )
local boolean b3 = true
local boolean b4 = true
if IsKeeperPlayable then
set b3 = GetOwningPlayer(udg_Hero[pid]) != GetOwningPlayer(udg_Keeper[1])
set b4 = GetOwningPlayer(udg_Hero[pid]) != GetOwningPlayer(udg_Keeper[2])
endif
return b1 and b2 and b3 and b4
endfunction
function GetBaseLoc takes player p returns location
if IsLeftPlayer(p) then
return GetRectCenter(gg_rct_LeftTeamStay)
else
return GetRectCenter(gg_rct_RightTeamStay)
endif
endfunction
function GetBaseX takes player p returns real
if IsLeftPlayer(p) then
return GetRectCenterX(gg_rct_LeftTeamStay)
else
return GetRectCenterX(gg_rct_RightTeamStay)
endif
endfunction
function GetBaseY takes nothing returns real
return GetRectCenterY(gg_rct_LeftTeamStay)
endfunction
function ResetPlayerPosition takes player p, location loc_unit_new returns nothing
int pid = GetConvertedPlayerId(p)
unit u = udg_Hero[pid]
call SetUnitPositionLoc( u, loc_unit_new )
endfunction
rect GetStartingRectByPid(int pid) {
if IsUnitFromLeftTeam(Hero[pid])
return gg_rct_LeftTeamStay
else
return gg_rct_RightTeamStay
endif
}
function Trig_Reset_player_locations_Actions takes nothing returns nothing
/*conditionfunc cond = Condition(function Trig_common_actions_after_a_goal_IsHero)
group g = GetUnitsInRangeOfLocMatching(INFINITY_RANGE, udg_ThrowinLoc, cond)
call ForGroup( g, function Trig_common_actions_after_a_goal_ResetLocations )
*/
int i = 0, j = 0
location loc_new
location loc_base
real loc_x
real base_y = GetBaseY()
real loc_y = base_y
player p
real step = 0
int sign = 1
while (i < 12)
{
if i == 7 // TODO: 6 maybe?
step = 0
sign = 1
loc_y = base_y
endif
set p = Player(i)
if IsPlayerPlaying(p)
{
// place player on a specific location
set loc_base = GetBaseLoc(p)
set loc_x = GetLocationX(loc_base)
loc_y += step*sign
sign *= -1
step += 200
set loc_new = Location(loc_x, loc_y)
//
set loc_new = GetRandomLocInRect(GetStartingRectByPid(i+1))
//
call ResetPlayerPosition(p, loc_new)
}
i++
}
endfunction
//===========================================================================
function InitTrig_Reset_player_locations takes nothing returns nothing
set gg_trg_Reset_player_locations = CreateTrigger( )
call TriggerAddAction( gg_trg_Reset_player_locations, function Trig_Reset_player_locations_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Hit_Goalpost_right_left_Conditions takes nothing returns boolean
boolean b1 = GetEnteringUnit() == udg_Ball
boolean b2 = GetUnitFlyHeight(udg_Ball) <= MAXIMUM_BAR_HEIGHT
return b1 and b2
endfunction
function Trig_Hit_Goalpost_right_left_Actions takes nothing returns nothing
set udg_BallDirection = 180 - udg_BallDirection
call TriggerExecute( gg_trg_Hit_obstacle_common_actions )
endfunction
//===========================================================================
function InitTrig_Hit_Goalpost_right_left takes nothing returns nothing
set gg_trg_Hit_Goalpost_right_left = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_right_left, gg_rct_GoalPostLeft1 )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_right_left, gg_rct_GoalPostLeft2 )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_right_left, gg_rct_GoalPostRight1 )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_right_left, gg_rct_GoalPostRight2 )
call TriggerAddCondition( gg_trg_Hit_Goalpost_right_left, Condition( function Trig_Hit_Goalpost_right_left_Conditions ) )
call TriggerAddAction( gg_trg_Hit_Goalpost_right_left, function Trig_Hit_Goalpost_right_left_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Hit_Goalpost_goal_back_Conditions takes nothing returns boolean
boolean b1 = GetEnteringUnit() == udg_Ball
boolean b2 = GetUnitFlyHeight(udg_Ball) <= MAXIMUM_BAR_HEIGHT
return b1 and b2
endfunction
function Trig_Hit_Goalpost_goal_back_Actions takes nothing returns nothing
set udg_BallDirection = 180 - udg_BallDirection
call TriggerExecute( gg_trg_Hit_obstacle_common_actions )
endfunction
//===========================================================================
function InitTrig_Hit_Goalpost_goal_back takes nothing returns nothing
set gg_trg_Hit_Goalpost_goal_back = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_goal_back, gg_rct_GoalBack1 )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_goal_back, gg_rct_GoalBack2 )
call TriggerAddCondition( gg_trg_Hit_Goalpost_goal_back, Condition( function Trig_Hit_Goalpost_goal_back_Conditions ) )
call TriggerAddAction( gg_trg_Hit_Goalpost_goal_back, function Trig_Hit_Goalpost_goal_back_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Hit_Goalpost_top_bottom_Conditions takes nothing returns boolean
boolean b1 = GetEnteringUnit() == udg_Ball
boolean b2 = GetUnitFlyHeight(udg_Ball) <= MAXIMUM_BAR_HEIGHT
return b1 and b2
endfunction
function Trig_Hit_Goalpost_top_bottom_Actions takes nothing returns nothing
set udg_BallDirection = 360 - udg_BallDirection
call TriggerExecute( gg_trg_Hit_obstacle_common_actions )
endfunction
//===========================================================================
function InitTrig_Hit_Goalpost_top_bottom takes nothing returns nothing
set gg_trg_Hit_Goalpost_top_bottom = CreateTrigger( )
//call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_top_bottom, gg_rct_GoalPostBottom1 )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_top_bottom, gg_rct_GoalPostBottom2 )
//call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_top_bottom, gg_rct_GoalPostBottom3 )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_top_bottom, gg_rct_GoalPostBottom4 )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_top_bottom, gg_rct_GoalPostTop1 )
//call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_top_bottom, gg_rct_GoalPostTop2 )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_top_bottom, gg_rct_GoalPostTop3 )
//call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost_top_bottom, gg_rct_GoalPostTop4 )
call TriggerAddCondition( gg_trg_Hit_Goalpost_top_bottom, Condition( function Trig_Hit_Goalpost_top_bottom_Conditions ) )
call TriggerAddAction( gg_trg_Hit_Goalpost_top_bottom, function Trig_Hit_Goalpost_top_bottom_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Hit_Goalpost_Conditions takes nothing returns boolean
return ( GetUnitFlyHeight(udg_Ball) <= MAXIMUM_BAR_HEIGHT ) and ( GetEnteringUnit() == udg_Ball )
endfunction
function Trig_Hit_Goalpost_Actions takes nothing returns nothing
set udg_BallDirection += 180
call TriggerExecute( gg_trg_Hit_obstacle_common_actions )
endfunction
//===========================================================================
function InitTrig_Hit_Goalpost takes nothing returns nothing
set gg_trg_Hit_Goalpost = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost, gg_rct_GoalPost1 )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost, gg_rct_GoalPost2 )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost, gg_rct_GoalPost3 )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Goalpost, gg_rct_GoalPost4 )
call TriggerAddCondition( gg_trg_Hit_Goalpost, Condition( function Trig_Hit_Goalpost_Conditions ) )
call TriggerAddAction( gg_trg_Hit_Goalpost, function Trig_Hit_Goalpost_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Hit_Bar_Conditions takes nothing returns boolean
if not ( GetEnteringUnit() == udg_Ball ) then
return false
endif
real h_ball = GetUnitFlyHeight(udg_Ball)
bool b1 = h_ball >= MINIMUM_BAR_HEIGHT
bool b2 = h_ball <= MAXIMUM_BAR_HEIGHT
boolean IsBarHit = b1 && b2
if IsBarHit then
call CreateExclamatoryTextTag(R2IS(h_ball), GetBallLoc(), h_ball+100, 0, 100, 0)
endif
return IsBarHit
endfunction
function Trig_Hit_Bar_Actions takes nothing returns nothing
set udg_BallDirection = 180 - udg_BallDirection
call TriggerExecute( gg_trg_Hit_obstacle_common_actions )
endfunction
//===========================================================================
function InitTrig_Hit_Crossbar takes nothing returns nothing
set gg_trg_Hit_Crossbar = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Crossbar, gg_rct_BarLeft )
//call TriggerRegisterEnterRectSimple( gg_trg_Hit_Crossbar, gg_rct_BarLeft/2 )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Crossbar, gg_rct_BarRight )
call TriggerRegisterEnterRectSimple( gg_trg_Hit_Crossbar, gg_rct_BarRight_Copy )
//call TriggerRegisterEnterRectSimple( gg_trg_Hit_Crossbar, gg_rct_BarRight/2 )
call TriggerAddCondition( gg_trg_Hit_Crossbar, Condition( function Trig_Hit_Bar_Conditions ) )
call TriggerAddAction( gg_trg_Hit_Crossbar, function Trig_Hit_Bar_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Players_Cant_enter_the_post_Conditions takes nothing returns bool
return IsUnitHero(GetEnteringUnit())
endfunction
function Trig_Players_Cant_enter_the_post_Actions takes nothing returns nothing
unit u = GetEnteringUnit()
location loc_unit = GetUnitLoc(u)
location loc_temp = PolarProjectionBJ( loc_unit, -25, GetUnitFacing(u))
real unit_x = GetLocationX(loc_unit)
real sign = unit_x / Abs(unit_x)
location loc_new = OffsetLocation( loc_temp, -25 * sign, 0)
call SetUnitPositionLoc( u, loc_new )
endfunction
//===========================================================================
function InitTrig_Players_Cant_enter_the_post takes nothing returns nothing
set gg_trg_Players_Cant_enter_the_post = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalBack1 )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalBack2 )
/*call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPost1 )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPost2 )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPost3 )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPost4 )*/
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPostLeft1 )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPostLeft2 )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPostRight1 )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPostRight2 )
//call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPostBottom1 )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPostBottom2 )
//call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPostBottom3 )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPostBottom4 )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPostTop1 )
//call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPostTop2 )
call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPostTop3 )
//call TriggerRegisterEnterRectSimple( gg_trg_Players_Cant_enter_the_post, gg_rct_GoalPostTop4 )
call TriggerAddCondition( gg_trg_Players_Cant_enter_the_post, Condition( function Trig_Players_Cant_enter_the_post_Conditions ) )
call TriggerAddAction( gg_trg_Players_Cant_enter_the_post, function Trig_Players_Cant_enter_the_post_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
//===========================================================================
function InitTrig_Hit_obstacle_common_actions takes nothing returns nothing
set gg_trg_Hit_obstacle_common_actions = CreateTrigger( )
call TriggerAddAction( gg_trg_Hit_obstacle_common_actions, function Ball_ActionsOnImpact)
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
lib( ImpactPhysics, StdLib )
bool IsBallEnteringUnit() {
return ( GetEnteringUnit() == Ball )
}
private void Ball_ResetDirection() {
real r = BallDirection
if ( r >= 360 )
r -= 360
elseif ( r < 0 )
r += 360
endif
BallDirection = r
if ( r >= 360 ) or ( r < 0 )
Ball_ResetDirection()
endif
}
// ImpactPhysics_BallActions
void Ball_ActionsOnImpact() {
call Ball_ResetDirection()
//call PlaySoundOnUnit( gg_snd_Kick, Ball )
call Audio_PlaySound( SOUND_GOAL_HIT )
call Ball_SlowDown(0.15 * Ball_GetSpeed())
call RunBallGeneralAnimations()
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Hit_invisible_walls_Conditions takes nothing returns boolean
bool b = GetEnteringUnit() == udg_Ball
return b
endfunction
function Trig_Hit_invisible_walls_Actions takes nothing returns nothing
set udg_BallDirection = 180 - udg_BallDirection
call TriggerExecute( gg_trg_Hit_obstacle_common_actions )
endfunction
//===========================================================================
function InitTrig_Hit_invisible_walls_right_left takes nothing returns nothing
set gg_trg_Hit_invisible_walls_right_left = CreateTrigger( )
call TriggerAddCondition( gg_trg_Hit_invisible_walls_right_left, Condition( function Trig_Hit_invisible_walls_Conditions ) )
call TriggerAddAction( gg_trg_Hit_invisible_walls_right_left, function Trig_Hit_invisible_walls_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Hit_invisible_walls_top_bottom_Conditions takes nothing returns boolean
bool b = GetEnteringUnit() == udg_Ball
return b
endfunction
function Trig_Hit_invisible_walls_top_bottom_Actions takes nothing returns nothing
set udg_BallDirection = 360 - udg_BallDirection
call TriggerExecute( gg_trg_Hit_obstacle_common_actions )
endfunction
//===========================================================================
function InitTrig_Hit_invisible_walls_top_bottom takes nothing returns nothing
set gg_trg_Hit_invisible_walls_top_bottom = CreateTrigger( )
call TriggerAddCondition( gg_trg_Hit_invisible_walls_top_bottom, Condition( function Trig_Hit_invisible_walls_top_bottom_Conditions ) )
call TriggerAddAction( gg_trg_Hit_invisible_walls_top_bottom, function Trig_Hit_invisible_walls_top_bottom_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Changes_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
endl(p)
MsgTimed("- Curved C (-curve mode)")
MsgTimed("- Keeper ball holding time reduced to 1 sec in case of back-pass")
//msgtimed(- )
endl(p)
return
//echo("Over 10 new sounds have been added. Enable your sound by pressing Ctrl+S.")
endl(p)
MsgTimed("- Game detects and counts X dribbles")
MsgTimed("- New calculation mechanism for team B.P.")
MsgTimed("- Smooth 'ball in front of owner' action, based on 0.01 sec update")
//msgtimed(- )
endl(p)
return
MsgTimed("|cffffcc007.44a1.9|r")
msgtimed(- Switch command swaps models)
msgtimed(- added keeper mode (version from April 2011))
msgtimed(- Fixed discs)
msgtimed(- unobs is no longer abusable)
endl(p)
return
MsgTimed("|cffffcc007.44|r")
msgtimed(- Improved keeper positioning)
msgtimed(- switch command: -switch p1 p2)
msgtimed(- Player possession in stats)
msgtimed(- Simple Z aiming by default)
msgtimed(- Fakie command)
msgtimed(- New tiles)
msgtimed(- Save message)
msgtimed(- Updated top10 EU)
endl(p)
return
///*
MsgTimed("|cffffcc007.43|r")
msgtimed(- 3D Scoreboard)
msgtimed(- Indoor soccer mode)
msgtimed(- Training mode)
msgtimed(- Simple Z mode (-aimless))
msgtimed(- -manual z)
MsgTimed("- Penalty for C fail")
msgtimed(- Mode to change balls (-ball))
msgtimed(- D notifier & height exclamations)
msgtimed(- Instant slides & headers)
MsgTimed("- Keeper AI improved")
msgtimed(- -help command)
/*
*/
//msgtimed(- 5 new modes)
endl(p)
return
//TODO - automate messages somehow?
//TODO - helpLib-like abstraction
MsgTimed("|cffffcc007.42d|r")
MsgTimed("- Keeper AI improved")
MsgTimed("- Pass! - old hotkey (D)")
MsgTimed("- Pass! notification")
MsgTimed("- Drop Ball can be used in throwins")
MsgTimed("- Instant slides and headers")
MsgTimed("- Gameplay help command: -help")
//MsgTimed("- Drop ball enhancements")
//MsgTimed("- Drop ball ")
//MsgTimed("- Slides buff")
//MsgTimed("- Exclamations (floating text)")
//MsgTimed("- Floating text (for max heights)")
//MsgTimed("- ")
/*
- Pass! - old hotkey (D)
- Drop Ball can be used in throwins
- Instant slides and headers
- "-help" command for info on gameplay
- Pass! notification
- Floating text (for max heights)
- Saves
- 4v4 max
- Old ball
*/
endl(p)
return
MsgTimed("|cffffcc007.42c|r")
MsgTimed("- Drop Ball ability, hotkey = "+Orange("D"))
MsgTimed("- Fast C is higher and longer than normal C")
MsgTimed("- Crossbar height reverted")
MsgTimed("- Rating formula now benefits passers")
MsgTimed("- New ball")
return
//MsgTimed("|cffffcc007.43a|r")
/*
MsgTimed("- Keepers can head (keeper mode)")
MsgTimed("- Keepers are faster outside box (keeper mode)")
MsgTimed("- You can pick next keeper controller using \"-nominate\" command" )
*/
//MsgTimed("- Invisible Walls mode (-iw)")
// keeper C?
//MsgTimed("- Fast C advantage: higher C") // reworked, freedom
//MsgTimed("- 30 new player names (check out!)")
return
MsgTimed("|cffffcc007.42a|r")
MsgTimed("- Keeper can jump to block high shots (keeper mode)")
MsgTimed("- Keeper can interact with ball anywhere on the pitch (keeper mode)")
MsgTimed("- Targetable Z mode: \"-new z\"")
MsgTimed("- Keepers slightly buffed")
MsgTimed("- Crossbar height lowered from 210 to 200")
MsgTimed("- New awards at the end")
//MsgTimed("- Added F9 Gameplay and Community chapters")
//MsgTimed("- Start positions (after a goal) are now ordered")
MsgTimed("- Top 10 Europe on the loading screen")
MsgTimed("- New Icons")
endl(p)
endfunction
//===========================================================================
function InitTrig_Changes takes nothing returns nothing
trigger t = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( t, "-info","-changes","-changelog","-features", true )
call TriggerAddAction( t, function Trig_Changes_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Smooth_cmd_Actions takes nothing returns nothing
call Ensure(IsUserMorgan())
set SmoothBall = not SmoothBall
endfunction
//===========================================================================
function InitTrig_sm takes nothing returns nothing
set gg_trg_sm = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_sm, "-sm", true )
call TriggerAddAction( gg_trg_sm, function Trig_Smooth_cmd_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib(SwitchPlayers, StdLib), Init
private bool VotingInProgress = false
private force YesVoters = CreateForce()
#define Swap(var1,var2) = {
DoNothing()
vblock {
var1 = var1 + var2
var2 = var1 - var2
var2 = (var1 + var2)/2
var1 = var1 - var2
}
}
#define rSwap(var1,var2) = {
DoNothing()
vblock {
real temp = var2
var2 = var1
var1 = temp
}
}
private void SetPlayerForceAllianceEnum() {
if TempPlayer != GetEnumPlayer()
call SetPlayerAllianceStateAllyBJ(TempPlayer, GetEnumPlayer(), TempBool)
call SetPlayerAllianceStateAllyBJ(GetEnumPlayer(), TempPlayer, TempBool)
// below is false fixer for inability to share after using switch
// which actually causes sharing by default or something
//call SetPlayerAllianceStateControlBJ(TempPlayer, GetEnumPlayer(), TempBool)
//call SetPlayerAllianceStateControlBJ(TempPlayer, GetEnumPlayer(), TempBool)
endif
}
void SetPlayerForceAlliance(player p, force f, bool flag) {
set TempPlayer = p
set TempBool = flag
call ForForce(f, function SetPlayerForceAllianceEnum)
//force pForce = GetForceOfPlayer(p)
//call SetForceAllianceStateBJ(pForce, f, ?)
// SetPlayerAllianceStateAllyBJ
/*
call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_PASSIVE, flag)
call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_HELP_REQUEST, flag)
call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_HELP_RESPONSE, flag)
call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_XP, flag)
call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_SPELLS, flag)
*/
}
string HD2S(int hd) {
int decimal_1 = hd/16
int decimal_2 = mod(hd,16)
return null
}
void pnamecolor(int pid_1, int pid_2) {
int R = R2I(udg_PlayerColorR[pid_1])
set udg_PlayerNames[pid_1] = "|cff"+HD2S(R)+"FF0202" + GetPlayerNameById(0) + "|r"
}
void ChangePlayersTeam(player p, int team) {
call Ensure(p != null && IsInSet(team,0,1,2))
call SetPlayerTeam(p,team) // maybe put a little later?
int pid = cPid(p)
unit u = Hero[pid]
int original_team = GetUnitTeamSimple(u)
int enemy_team = GetEnemyTeamNumber(original_team)
force former_allies = GetPlayersByTeam(original_team) //GetPlayersEnemies(p)
force former_enemies = GetPlayersByTeam(enemy_team) //GetPlayersAllies(p)
call SetPlayerForceAlliance(p,former_allies,false)
call SetPlayerForceAlliance(p,former_enemies,true)
call GroupRemoveUnit(TeamHeroes[original_team], u)
// 7.47b0.7 - bug #1 fix
integer new_type_id = NationToUnitTypeId(enemy_team)
set u = ReplaceUnitBJ(u, new_type_id, 0)
// 7.47b0.7 - bug #2 fix
call AddFeetToPlayer(p)
/*if original_team == 1
u = ReplaceUnitBJ(u, 'H003', 0)
else
u = ReplaceUnitBJ(u, 'H001', 0)
endif*/
set Hero[pid] = u
call GroupAddUnit(TeamHeroes[enemy_team], u)
}
void SwapPlayers(player p1, player p2) {
// TODO actions if a player is null
call Ensure(p1 != null && p2 != null)
// GetPlayerTeam return value -- 0/1 or 1/2 ?
int team_p1 = GetPlayerTeam(p1)
int team_p2 = GetPlayerTeam(p2)
call Ensure(team_p1 != team_p2)
call ChangePlayersTeam(p1, team_p2)
call ChangePlayersTeam(p2, team_p1)
unit u1 = GetHero(p1)
unit u2 = GetHero(p2)
playercolor color_p1 = GetPlayerColor(p1)
playercolor color_p2 = GetPlayerColor(p2)
call SetUnitColor(u1, color_p2)
call SetUnitColor(u2, color_p1)
call SetPlayerColor(p1, color_p2)
call SetPlayerColor(p2, color_p1)
int pid_1 = cPid(p1)
int pid_2 = cPid(p2)
call rSwap(udg_PlayerColorR[pid_1], udg_PlayerColorR[pid_2])
call rSwap(udg_PlayerColorG[pid_1], udg_PlayerColorG[pid_2])
call rSwap(udg_PlayerColorB[pid_1], udg_PlayerColorB[pid_2])
// swap udg_PlayerColorR G B
/*
playercolor p1_color = GetPlayerColor(p1)
playercolor p2_color = GetPlayerColor(p2)
call SetPlayerColor(p1, p2_color)
call SetPlayerColor(p2, p1_color)
*/
// TODO - GetTeam(1) ?
//call SetPlayerForceAlliance(p1, ?)
// PlayersAreCoAllied // ?
// SetForceAllianceStateBJ
// TODO groups update
//call GroupRemoveUnit(udg_Team?Heroes, p1)
//call GroupAddUnit(udg_Team?Heroes, p1)
// TODO
//call SetPlayerAllianceStateAllyBJ(p1, ?, true)
}
bool IsVotingSuccessful() {
int votes_yes = CountPlayersInForceBJ(YesVoters)
int votes_all = ModesLib_GetAllVotes()
int votes_needed = ModesLib_GetNeededVotes(votes_all)
if votes_yes >= votes_needed
return true
else
return false
endif
}
private bool Voting() {
int time = 0
while (time<20)
{
wait(1)
time++
if IsVotingSuccessful()
return true
endif
}
return false
}
private string Usage() {
return "Type -switch player1 player2 "
}
private function Parser takes nothing returns nothing
declare string
Ensure( not IsKeeperPlayable )
if not (strlen > patlen) //&& SubChar(input,8) == " ")
echo(GetTriggerPlayer(), Usage() )
return
endif
int c = patlen
c = IgnoreSpaces(input,c)
int nick_start = c
c = IgnoreSymbols(input,c)
int nick_end = c-1
string pname = SubStringBJ(input, nick_start, nick_end)
c = IgnoreSpaces(input,c)
set nick_start = c
c = IgnoreSymbols(input,c)
set nick_end = c-1
string p2name = SubStringBJ(input, nick_start, nick_end)
//TestMsg(pname)
player p = GetPlayerByShortName(pname)
player p2 = GetPlayerByShortName(p2name)
// the check below should allow players to swap with those who left - 7.47a
if p!=null || p2 != null {
TestMsg(pname)
TestMsg(p2name)
} elseif (p==null)&&(p2==null) {
echo(GetTriggerPlayer(), "Cannot find players. "+Usage())
return
}
//IsPlayerAlly( p, GetTriggerPlayer() )
//not IsPlayerBot(p)
//IsPlayerPlaying()//IsPlayerPlaying(p)
int team_p1 = GetPlayerTeam(p)
int team_p2 = GetPlayerTeam(p2)
bool b1 = not IsPlayerObs(p) && not IsPlayerObs(p2)
bool b2 = not IsPlayerObserver(p) && not IsPlayerObserver(p2)
bool b3 = team_p1 != team_p2
bool b = b1 && b2 && b3
if not b
echo(GetTriggerPlayer(), "Cannot swap players.")
return
endif
Ensure(b)
set VotingInProgress = true
echo ("Voting to swap players "+GetPlayerName(p)+" and "+GetPlayerName(p2)+" started. Type -yes to vote.")
//echo ("Voting started. Type -yes to vote.")
bool positive_result = Voting()
call ForceClear(YesVoters)
set VotingInProgress = false
if positive_result
call SwapPlayers(p,p2)
echo ("Swapped players "+GetPlayerName(p)+" and "+GetPlayerName(p2)+".")
else
echo ("Not enough votes to swap players.")
endif
/*
FORMATS
-switch name team
-switch name name
*/
endfunction
private void PlayerCastVote() {
declare string
Ensure( VotingInProgress )
player p = GetTriggerPlayer()
//Ensure(not IsPlayerInForce(p,YesVoters))
echo(p, "Vote counted.")
if (input == "-yes") then
ForceAddPlayer(YesVoters, p)
else
ForceRemovePlayer(YesVoters, p)
endif
}
//===========================================================================
function InitTrig_Switch_players takes nothing returns nothing
trigger t
set t = CreateTrigger()
call TriggerRegisterAnyPlayerChatEvent( t, "-switch ", "-swap ", false )
call TriggerAddAction( t, function Parser )
set t = CreateTrigger()
call TriggerRegisterAnyPlayerChatEvent( t, "-yes","-no", true )
call TriggerAddAction( t, function PlayerCastVote )
endfunction
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=0
force Observers = CreateForce()
function Trig_obs_mode_Conditions takes nothing returns bool
player p = GetTriggerPlayer()
int pid = cPid(p)
unit u = Hero[pid]
bool b1 = u != udg_BallOwner
bool b2 = IsPlayerPlaying(p)
/*bool b3 = not IsPlayerObs(p)
bool b4 = not IsUnitHidden(u)*/
return b1 && b2
endfunction
function Trig_obs_mode_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
int pid = GetConvertedPlayerId(p)
unit u = Hero[pid]
call SetUnitPositionLoc( u, GetRectCenter(gg_rct_ObsMode) ) // TBR
call ShowUnitHide( u )
call ForceAddPlayer( Observers, p ) // TBR
call SetPlayerName(p, "|cffffffff" + GetPlayerName(p) + "|r")
//call SetPlayerName(<player>, "|cffffffff (Referee) " + GetPlayerName(<player> + "|r")
//call SetPlayerState( p, PLAYER_STATE_OBSERVER, 1 )
//call GroupRemoveUnit( udg_Team?Heroes, u ) // TODO
string name = udg_PlayerNames[pid]
//echoln( p, name +" has entered observer mode." )
udg_CanUseUnobs[pid] = false
wait(60)
udg_CanUseUnobs[pid] = true
endfunction
//===========================================================================
function InitTrig_Obs_mode takes nothing returns nothing
set gg_trg_Obs_mode = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Obs_mode, "-obs","-observer","-ref","-referee", true)
call TriggerAddConditionSimple( gg_trg_Obs_mode, function Trig_obs_mode_Conditions )
call TriggerAddAction( gg_trg_Obs_mode, function Trig_obs_mode_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_unobs_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
int pid = GetConvertedPlayerId(p)
Ensure(udg_CanUseUnobs[pid] && IsPlayerObs(p))
call ForceRemovePlayer(Observers, p)
call ShowUnit(Hero[pid])
call SetPlayerName(p, udg_PlayerNames[pid])
endfunction
//===========================================================================
function InitTrig_unobs takes nothing returns nothing
set gg_trg_unobs = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_unobs, "-unobs", true )
call TriggerAddAction( gg_trg_unobs, function Trig_unobs_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib_init( Banners, onInit, StdLib )
enum (banner_animations) {
BANNER_ANIMATION_CLAN
BANNER_ANIMATION_WEBSITE
BANNER_ANIMATION
}
define {
BANNER_ANIMATION_NONE = null
BANNER_ANIMATION_TFT = "one"
BANNER_ANIMATION_BNET = "two"
BANNER_ANIMATION_BLIZZARD = "three"
}
private int array counterArray[4] // animation counter
private string array BannerIdArray[4]
private int GetNextCounterValue(int counter) {
set counter += 1
if counter == 4
counter = 1
endif
return counter
}
private string Number2Animation(int n) {
if n==1
return "one"
elseif n==2
return "two"
elseif n==3
return "three"
endif
return null
}
void SetGroupAnimation(group g, string animation) {
/*
for (unit u; UnitsInGroup(g)) {
call SetUnitAnimation(u, animation)
}
*/
}
private void UpdateCounter(int cell) {
set counterArray[cell] = GetNextCounterValue(counterArray[cell])
}
private void UpdateAnimationByType(int bannerType) {
string whichType = BannerIdArray[bannerType]
for(unit banner; UnitsOfType(whichType))
{
int counter = counterArray[bannerType]
string anim = Number2Animation(counter)
call SetUnitAnimation(banner, anim)
}
}
private void SetNewAnimations() {
call UpdateAnimationByType(1)
call UpdateAnimationByType(2)
call UpdateAnimationByType(3)
}
private void UpdateAnimationCounters() {
call UpdateCounter(1)
call UpdateCounter(2)
call UpdateCounter(3)
}
private void PlayAnimationByType(int bannerType) {
//int bannerType = TempInt
call UpdateCounter(bannerType)
call UpdateAnimationByType(bannerType)
}
void PlayAnimationByTypeLoopTrg() {
int bannerType = TempInt
loop
sleep(6)
call PlayAnimationByType(bannerType)
endloop
}
private void PlayAnimationByTypeLoop(int bannerType) {
set TempInt = bannerType
exec(PlayAnimationByTypeLoopTrg)
}
void Banners() {
//group g = CreateGroup()
//TestMsg(unitname)
///*
call PlayAnimationByTypeLoop(1)
wait(2)
call PlayAnimationByTypeLoop(2)
wait(2)
call PlayAnimationByTypeLoop(3)
return
//*/
loop
//call SetNextAnim()
sleep(2)
call UpdateAnimationCounters()
call SetNewAnimations()
/*call GroupEnumUnitsOfType(g, BannerIdArray[1], null)
call SetGroupAnimation(g, counterArray[1])
call GroupEnumUnitsOfType(g, BannerIdArray[2], null)
call SetGroupAnimation(g, counterArray[2])*/
/* // alternate code
string anim
for (unit banner; UnitsOfType(BannerIdArray[1])) {
set anim = Number2Animation(counterArray[1])
call SetUnitAnimation(banner, anim)
// call SetBannerAnimationInt(banner, whichAnimation)
}
*/
//GetNextCounterValue
//'h00B'
// "custom_banner" doesn't work
// it's custom_h002
//call GroupAddUnit(g, gg_unit_/h002_0024)
//call GroupAddUnit(g, gg_unit_/h002_0025)
//int k = CountUnitsInGroup(g)
//TestMsg(I2S(k))
endloop
}
private void onInit() {
set BannerIdArray[1] = UnitId2String('D00B')
set BannerIdArray[2] = UnitId2String('D009')
set BannerIdArray[3] = UnitId2String('D00D')
set counterArray[1] = 1
set counterArray[2] = 2
set counterArray[3] = 3
call SetNewAnimations()
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib ( Audio, StdLib )
sound snd_golazo = null
define {
SOUND_CROSSBAR_HIT = 3
SOUND_POST_HIT = 4
SOUND_GOAL_HIT = 2
SOUND_NET_HIT = 1
SOUND_GROUND_HIT = 5
SOUND_PLAYER_KICK = 6
SOUND_PLAYER_LONG_PASS = 7
SOUND_PLAYER_HEAD = 8
SOUND_PLAYER_JUMP = 9
SOUND_PLAYER_SHORT_PASS = 10
SOUND_PLAYER_VZ = 11
SOUND_CHEER = 15
SOUND_GOLAZO = 16
SOUND_WHISTLE_END = 17
SOUND_WHISTLE_MEDIUM = 18
SOUND_HINT = 20
}
function StopPlaySoundOnUnit takes sound snd, unit u returns nothing
call StopSoundBJ( snd, false ) // causes sound issue?
call PlaySoundOnUnitBJ( snd, 100, u )
endfunction
function PlaySoundOnUnit takes sound snd, unit u returns nothing
call StopPlaySoundOnUnit(snd, u)
endfunction
void PlaySoundOnBall(sound snd) {
call PlaySoundOnUnit( snd, Ball )
}
void Ball_PlaySound(sound snd) {
call PlaySoundOnUnit( snd, Ball )
}
public void PlaySound(int whichSound) {
//call PlaySoundBJ(gg_snd_NameOfSound) // doesnt work for some reason?
sound snd = null
if whichSound == SOUND_GOAL_HIT then
if Ball_GetSpeed() >= 425 then
if GetChance(0.33) then
call PlaySoundOnUnit(gg_snd_WoodLightBashMetal1, Ball)
elseif GetChance(0.5) then
call PlaySoundOnUnit(gg_snd_WoodLightBashMetal2, Ball)
else
call PlaySoundOnUnit(gg_snd_WoodLightBashMetal3, Ball)
endif
else
if GetChance(0.5) then
call Ball_PlaySound(gg_snd_Stomp_01)
else
call Ball_PlaySound(gg_snd_Stomp_02)
endif
//call PlaySoundOnUnit( gg_snd_Kick, Ball )
endif
elseif whichSound == SOUND_PLAYER_KICK
if GetChance(0.5) then
call Ball_PlaySound(gg_snd_Kick_01)
else
call Ball_PlaySound(gg_snd_Kick_02)
endif
elseif whichSound == SOUND_GROUND_HIT then
if GetChance(1.0)
call Ball_PlaySound(gg_snd_Land_02)
else
call Ball_PlaySound(gg_snd_Land_01)
endif
elseif whichSound == SOUND_CHEER then
call Ball_PlaySound(gg_snd_cheer_mp3)
elseif whichSound == SOUND_GOLAZO then
int pid = cPid(GetTriggerPlayer())
unit u = Hero[pid]
if GetChance(0.25) // 0.25
set snd = gg_snd_goal4
elseif GetChance(0.33)
set snd = gg_snd_goal3
elseif GetChance(0.5)
set snd = gg_snd_golazo1
else
set snd = gg_snd_golazo2
endif
//call SetSoundVolume(snd, 500) // setting volume before playing sound won't do it
set snd_golazo = snd
call PlaySoundOnUnit(snd, u)
call SetSoundVolume(snd, 500)
elseif whichSound == SOUND_WHISTLE_END then
call PlaySoundFromOffsetBJ( gg_snd_whistle_short, 100, 0.0 )
call WaitForSoundBJ( gg_snd_whistle_short, 0.00 )
call PolledWait( 0.30 )
call PlaySoundFromOffsetBJ( gg_snd_whistle_short, 100, 0.0 )
call WaitForSoundBJ( gg_snd_whistle_short, 0.00 )
call PolledWait( 0.30 )
call PlaySoundFromOffsetBJ( gg_snd_whistle_medium, 100, 0.0 )
elseif whichSound == SOUND_WHISTLE_MEDIUM then
call PlaySoundOnUnit(gg_snd_whistle_medium, udg_Referee)
elseif whichSound == SOUND_HINT
call StartSound(gg_snd_Hint)
endif
//call PlaySoundOnUnit(gg_snd_AxeMediumChopWood2, Ball) // funny sound, better suited for lil kick
}
public void Init() {
call Sleep( 0.01 )
//call PlayMusic( gg_snd_Wavin_Flag )
if NationVotingAtStart
call PlayMusic( gg_snd_wcup_theme )
call SetMusicVolume(500)
else
call PlayMusic( gg_snd_BGM )
endif
call Audio_PlaySound( SOUND_CHEER )
}
void PlayKickSound() {
call Audio_PlaySound(SOUND_PLAYER_KICK)
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Player_Leave_Actions takes nothing returns nothing
int pid = cPid(GetTriggerPlayer())
unit u = udg_Hero[pid]
// Ball Owner leaves bug fix
if (u == BallOwner) { BallOwner = null }
/// call GroupRemoveUnit( udg_Team?Heroes, u )
call RemoveUnit( u )
set udg_Hero[pid] = null
echoln( udg_PlayerNames[pid] + " has left the game." )
/// echo("You may use -switch command to change teams.")
endfunction
//===========================================================================
function InitTrig_Player_Leave takes nothing returns nothing
set gg_trg_Player_Leave = CreateTrigger( )
call TriggerRegisterAnyPlayerEvent( gg_trg_Player_Leave, EVENT_PLAYER_LEAVE )
call TriggerRegisterAnyPlayerEvent( gg_trg_Player_Leave, EVENT_PLAYER_DEFEAT )
call TriggerAddAction( gg_trg_Player_Leave, function Trig_Player_Leave_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Move_Referee_Actions takes nothing returns nothing
location loc_ball = GetUnitLoc(udg_Ball)
location loc_ref_new = null
real ref2ball = AngleBetweenUnits( udg_Ball, udg_Referee)
real dist = DistanceBetweenUnits( udg_Ball, udg_Referee)
if ( dist > 1400 ) then
call IssueTargetOrder( udg_Referee, "move", udg_Ball )
elseif ( dist < 1000 ) then
set loc_ref_new = PolarProjectionBJ(loc_ball, 1200, ref2ball)
call UnitMove( udg_Referee, loc_ref_new )
else
call SetUnitFacingToFaceUnitTimed( udg_Referee, udg_Ball, 0 )
endif
call CleanLocs( loc_ball, loc_ref_new )
endfunction
//===========================================================================
function InitTrig_Move_Referee takes nothing returns nothing
set gg_trg_Move_Referee = CreateTrigger( )
call TriggerAddAction( gg_trg_Move_Referee, function Trig_Move_Referee_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Move_Linesmen_GetUsedRect takes int whichRef returns rect
if whichRef == 1
return gg_rct_TopLinesman
else
return gg_rct_BottomLinesman
endif
endfunction
function IsLinesmanPositionNormal takes int whichRef returns boolean
real ball_x = GetBallX()
real ref_x = GetUnitX(udg_Linesman[whichRef])
real ref_y = GetUnitY(udg_Linesman[whichRef])
rect rect_used = Trig_Move_Linesmen_GetUsedRect(whichRef)
real rect_y = GetRectCenterY(rect_used)
bool b1 = Abs( ball_x - ref_x ) < 50
bool b2 = Abs( ref_y - rect_y ) < 50
set rect_used = null
return b1 and b2
endfunction
function UpdateLinesmanPosition takes int whichRef returns nothing
if ( IsLinesmanPositionNormal(whichRef) ) then
call SetUnitFacingToFaceUnitTimed( udg_Linesman[whichRef], udg_Ball, 0 )
return
endif
rect rect_used = Trig_Move_Linesmen_GetUsedRect(whichRef)
real rect_y = GetRectCenterY(rect_used)
real ball_x = GetBallX()
location loc_move = Location(ball_x, rect_y)
call UnitMove( udg_Linesman[whichRef], loc_move )
call CleanLoc(loc_move)
set rect_used = null
endfunction
function Trig_Move_Linesmen_Actions takes nothing returns nothing
call UpdateLinesmanPosition(1)
call UpdateLinesmanPosition(2)
endfunction
//===========================================================================
function InitTrig_Move_Linesmen takes nothing returns nothing
set gg_trg_Move_Linesmen = CreateTrigger( )
call TriggerAddAction( gg_trg_Move_Linesmen, function Trig_Move_Linesmen_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
library HelpLib uses StdLib
enum (help topics) {
HELP_TOPIC_NONE
HELP_TOPIC_DEFENSE
HELP_TOPIC_ATTACK
}
public function DisplayHintsOnTopic takes int topic returns void
player p = GetTriggerPlayer()
//endl(p)
call ClearTextMessagesBJ(GetForceOfPlayer(p))
if (topic == HELP_TOPIC_NONE) then
MsgTimed("|cffffcc00GAMEPLAY HELP|r")
MsgTimed("- To get more info on a topic, type "+Orange("-help topic")+".")
MsgTimed("- Available topics: "+Orange("defense, attack")+".")
elseif (topic == HELP_TOPIC_DEFENSE) then
MsgTimed("|cffffcc00DEFENSE|r")
MsgTimed("- When your team defends, everyone must cover ONE enemy player.")
//MsgTimed("- The defender should always mark one enemy attacker.")
MsgTimed("- When you are the last defender (last man), play very safely.")
//MsgTimed("- Use headers to block.")
MsgTimed("- Jumping is a powerful blocking weapon, but it has long (3 sec) cooldown.")
//but it has long cooldown. Don't jump every single time!")
//MsgTimed("- A defender must be good at C passes.")
MsgTimed("- Defender's primary offense weapon is accurate C passes.")
//MsgTimed("- Try to predict enemy actions, so you can respond better.")
elseif (topic == HELP_TOPIC_ATTACK) then
MsgTimed("|cffffcc00ATTACK|r")
MsgTimed("- Main ways to shoot: V+Z and V+X")
MsgTimed("- When you shoot, try to target an exposed part of goal.")
MsgTimed("- To shoot above keeper, use V+X.")
endif
endl(p)
endfunction
//public function HelpCmdIntro takes void returns void
//public function DefenseHints takes void returns void
//HelpLib_IsTopicDef(topic)
public function GetTopic takes string s returns int
if IsInSet(s, "def", "defense", "defence", "defend", "defending", "defender")
return HELP_TOPIC_DEFENSE
elseif IsInSet(s, "atk", "attack", "attacking", "offense", "attacker", "forward")
return HELP_TOPIC_ATTACK
endif
return HELP_TOPIC_NONE
endfunction
endlibrary
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Help_Actions takes nothing returns nothing
string input = GetEventPlayerChatString()
int strlen = StringLength(input)
string specifier = SubStringBJ(input, 7, strlen)
int topic = HelpLib_GetTopic(specifier)
call HelpLib_DisplayHintsOnTopic(topic)
endfunction
//===========================================================================
function InitTrig_Help takes nothing returns nothing
set gg_trg_Help = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent( gg_trg_Help, "-help", false )
call TriggerAddAction( gg_trg_Help, function Trig_Help_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib_init( HintsLib, config, StdLib )
private timer HintsTimer
private force HintsForce = CreateForce()
private string array HintsArray[20]
private constant integer HINTS_DISPLAY_INTERVAL = 90
private void PlayerAddToHintsForce(player p) {
call ForceAddPlayer(HintsForce,p)
//echo(p,"Hints enabled. To disable, type -hints again.")
}
private void DisplayToAllEnum() {
call PlayerAddToHintsForce(GetEnumPlayer())
}
public void DisplayToAll() {
call ForForce(GetPlayersAll(), function DisplayToAllEnum)
}
public void StopDisplayingToAll() {
//call ForForce(GetPlayersAll(), function StopDisplayingToAllEnum)
call ForceClear(HintsForce)
}
private string GetRandomHint() {
string hint = null
integer i
loop
set i = GetRandomInt(1,HintsArray.size)
//echo(I2S(i))
set hint = HintsArray[i]
exitwhen (hint!=null)&&(hint!="")
endloop
return hint
}
private void DisplayHintsEnum() {
player p = GetEnumPlayer()
string hint = GetRandomHint()
hint = Hotkey("HINT: ")+hint
echo(p," ")
echo(p,hint)
call StartSoundForPlayerBJ(p,gg_snd_Hint)
}
private void DisplayHints() {
call ForForce(HintsForce, function DisplayHintsEnum)
}
private void HintsParser() {
player p = GetTriggerPlayer()
integer pid = cPid(p)
if IsPlayerInForce(p,HintsForce)
// disable hints for player
call ForceRemovePlayer(HintsForce,p)
echo(p,"Hints disabled.")
else
// enable hints
call ForceAddPlayer(HintsForce,p)
echo(p,"Hints enabled. To disable, type -hints again.")
endif
}
private void InitializeHintsArray() {
integer i=0
whilenot i>HintsArray.size
set HintsArray[i] = null
i++
endwhile
set i=1
//set HintsArray[i++] = ""
set HintsArray[i++] = "You can use D to request a pass from your goalkeeper."
set HintsArray[i++] = "Do not try to score alone. Instead, pass to a teammate who is in a better position."
set HintsArray[i++] = "Use C only at maximum range. Avoid making short C."
set HintsArray[i++] = "If your ally is in penalty area, pass to him with C!"
set HintsArray[i++] = "Jump near the ball to head it (V)."
set HintsArray[i++] = "Don't hold the ball for too long. Instead, pass it!"
set HintsArray[i++] = "The 2 main ways to pass are C (long pass) and Z (short pass)."
set HintsArray[i++] = "Don't know what to do with ball? Just pass it to a teammate with C!"
// shooting
set HintsArray[i++] = "You can use C to shoot from moderate distance."
set HintsArray[i++] = "Do not use X to shoot. Instead, try C or V+Z shots."
set HintsArray[i++] = "The main ways to score are: C shot, V header and V+Z."
set HintsArray[i++] = "Do not shoot through goalkeeper. It won't work."
set HintsArray[i++] = "If ball is flying in penalty area, jump near it (V)."
set HintsArray[i++] = ""
// community info
set HintsArray[i++] = "For games, join our channel 'Clan FOOT' in Battle.net, Europe."
set HintsArray[i++] = ""
}
private void config() {
trigger t = CreateTrigger()
call TriggerRegisterAnyPlayerChatEvent(t, "-hints", false)
call TriggerAddAction(t, function HintsParser)
set HintsTimer = CreateTimer()
call TimerStart(HintsTimer, HINTS_DISPLAY_INTERVAL, true, function DisplayHints)
call InitializeHintsArray()
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Set_Ball_Possession_Conditions takes nothing returns boolean
boolean b1 = udg_ThrowinMode == 0
boolean b2 = udg_Round == 0 || udg_Round == 2
return b1 && b2
endfunction
function Trig_Set_Ball_Possession_Actions takes nothing returns nothing
static real step = 0.1
int pid
if ( BallOwner != null )
pid = GetExtendedId(BallOwner)
udg_PlayerPossession[pid] += step
if IsUnitInTeam(BallOwner, 1)
udg_TeamPossession[1] += step
elseif IsUnitInTeam(BallOwner, 2)
udg_TeamPossession[2] += step
endif
elseif (udg_WhichKeeperHasBall != 0)
udg_TeamPossession[udg_WhichKeeperHasBall] += step
/*
elseif (LK != null && not IsKeeper(LK))
pid = GetConvertedPlayerId(GetOwningPlayer(LK))
if IsUnitInTeam(LK, 1)
udg_TeamPossession[1] += step
elseif IsUnitInTeam(LK, 2)
udg_TeamPossession[2] += step
endif
elseif ( IsKeeper(LK) )
pid = GetKeeperId(LK)
udg_TeamPossession[pid] += step
*/
else
//! report error
// impossible branch of execution
endif
endfunction
//===========================================================================
function InitTrig_Ball_Possession takes nothing returns nothing
set gg_trg_Ball_Possession = CreateTrigger( )
call TriggerAddConditionSimple( gg_trg_Ball_Possession, function Trig_Set_Ball_Possession_Conditions )
call TriggerAddAction( gg_trg_Ball_Possession, function Trig_Set_Ball_Possession_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib ( PSLib, StdLib )
globals
unit LK = null
unit L2K = null
unit LP = null
unit L2P = null
unit Assister = null
real BallObtainTimer = 0.0 // TBR
real BallHoldTime = 0.0
constant real PS_MinHoldTime = 0.75 // seconds
constant int PS_EVENT_LINECROSS = 1
constant int PS_EVENT_KEEPER_GET_BALL = 2
constant int PS_EVENT_PLAYER_GET_BALL = 3
constant int PS_EVENT_PLAYER_SLIDE_BALL = 4
constant int PS_EVENT_PLAYER_HEAD_BALL = 5
constant int PS_MODE_CLASSIC = 0
constant int PS_MODE_TIMED = 1
constant int PSMode = 0
endglobals
define UpdateLK(u) = {
DoNothing()
if ( LK != u ) then
L2K = LK
LK = u
endif
}
define UpdateLK() = {
UpdateLK(GetEnumUnit())
}
public function NullifyParams takes nothing returns nothing
set LK = null
set L2K = null
set LP = null
set L2P = null
set Assister = null
set BallHoldTime = 0.0
set BallObtainTimer = 0.0
//set LastActionMade = 0
endfunction
void PS_NullifyParams() {
call NullifyParams()
}
function PassPending takes nothing returns bool
return LP != null
endfunction
public function BallTimerActions takes nothing returns nothing
if PSMode == 1 && PassPending() && BallObtainTimer > 0.7
if LP != udg_BallOwner && IsUnitAllyExt(udg_BallOwner, LP)
Assister = LP
endif
if IsUnitAllyExt(udg_BallOwner, LP)
TestMsg("succ pass")
endif
LP = null
endif
endfunction
function GetAssister takes unit scorer returns unit
if scorer != LP
if IsUnitAllyExt(scorer,LP)
return LP
endif
elseif scorer != L2P
if IsUnitAllyExt(scorer, L2P)
return L2P
endif
endif
return null
endfunction
function UpdateLastPassers takes unit shooter returns nothing
if shooter == null // ball hold (> min_T) // need to know new owner here
if LP != null // ???
set L2P = LP
return
endif
elseif shooter != null // normal shots, slides/headers, keeper save
if LP == shooter
call DoNothing()
elseif LP != null
set L2P = LP
endif
set LP = shooter
endif
endfunction
private function SuccPass takes nothing returns nothing
int pid_LK = GetExtendedId(LK)
set udg_nSuccPasses[pid_LK] += 1
call DebugMsg(udg_PlayerNames[pid_LK] + ": +1 succ pass")
endfunction
private function FailPass takes nothing returns nothing
int pid_LK = GetExtendedId(LK)
set udg_nFailedPasses[pid_LK] += 1
call DebugMsg(udg_PlayerNames[pid_LK] + ": +1 fail pass")
endfunction
private void PS_##UpdateMain (unit u, int lamAdded) {
int lam = LastActionMade
if IsUnitAllyExt(u, LK) //&& (u!=null) then
call SuccPass()
elseif IsInSet(lam, 1,3,4,10,11,12,lamAdded)
call FailPass()
endif
}
#define PS_UpdateMain(u) = {
PS_##UpdateMain(u,-10)
}
#define PS_UpdateMain(u, lam) = {
PS_##UpdateMain(u,lam)
}
function PassSuccessUpdate takes int whichEvent returns nothing
int lam = LastActionMade
unit u = GetEnumUnit()
call Ensure( LK != null && lam != 0 && LK != u )
//set u = null
//whichEvent == PS_EVENT_LINECROSS
if IsInSet( whichEvent, PS_EVENT_LINECROSS, PS_EVENT_PLAYER_HEAD_BALL, PS_EVENT_PLAYER_GET_BALL)
call PS_UpdateMain(u,6)
elseif whichEvent == PS_EVENT_KEEPER_GET_BALL
int whichKeeper = TempInt
set u = udg_Keeper[whichKeeper]
call PS_UpdateMain(u)
elseif whichEvent == PS_EVENT_PLAYER_SLIDE_BALL
call PS_UpdateMain(u)
endif
endfunction
#define PS_Update(event) = {
PassSuccessUpdate(event)
}
public void Update(int whichEvent) {
call PassSuccessUpdate(whichEvent)
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib_init( Scoreboard3D, onInit, StdLib )
private unit Scoreboard3D = null
enum (number box) {
TEN_MINUTES
MINUTES
TEN_SECONDS
SECONDS
TEN_GOALS_PEASANTS
GOALS_PEASANTS
TEN_GOALS_PEONS
GOALS_PEONS
}
public location GetLoc() {
return GetUnitLoc(Scoreboard3D)
}
public void SetHalfIndicator(int whichHalf) {
string animation // = whichHalf == 1 ? "one" : "two"
if whichHalf == FIRST_HALF
set animation = "one"
else
set animation = "second"
endif
call SetUnitAnimation( Scoreboard3D, animation)
//call SetDoodadAnimationRectBJ(animation, 'D00H', GetPlayableMapRect())
}
private string Number2Animation(int s) {
if s==0
return "ready"
elseif s==1
return "one"
elseif s==2
return "two"
elseif s==3
return "three"
elseif s==4
return "four"
elseif s==5
return "five"
elseif s==6
return "spin"
elseif s==7
return "severe"
elseif s==8
return "eattree"
elseif s==9
return "complete"
endif
return null
}
private void SetNumberBox(int s, int whichBox) {
string animation = Number2Animation(s)
unit box = null
if whichBox == SECONDS
set box = gg_unit_h008_0009
elseif whichBox == TEN_SECONDS
set box = gg_unit_h008_0010
elseif whichBox == MINUTES
set box = gg_unit_h008_0011
elseif whichBox == TEN_MINUTES
set box = gg_unit_h008_0012
elseif whichBox == TEN_GOALS_PEASANTS
set box = gg_unit_h009_0014
elseif whichBox == GOALS_PEASANTS
set box = gg_unit_h009_0021
elseif whichBox == TEN_GOALS_PEONS
set box = gg_unit_h009_0008
elseif whichBox == GOALS_PEONS
set box = gg_unit_h009_0023
endif
call Ensure(box != null && animation != null)
call SetUnitAnimation( box, animation )
set box = null
}
public void UpdateTimer(int mins, int s) {
// call Ensure(s>=0 && s<=9)
int s01 = mod(s,10)
int s10 = s/10
call SetNumberBox(s01, SECONDS)
call SetNumberBox(s10, TEN_SECONDS)
int m01 = mod(mins,10)
int m10 = mins/10
call SetNumberBox(m01, MINUTES)
call SetNumberBox(m10, TEN_MINUTES)
}
public void UpdateScore() {
int peasantsScore01 = mod(Score[1],10)
int peasantsScore10 = Score[1]/10
call SetNumberBox(peasantsScore01, GOALS_PEASANTS)
call SetNumberBox(peasantsScore10, TEN_GOALS_PEASANTS)
int peonsScore01 = mod(Score[2],10)
int peonsScore10 = Score[2]/10
call SetNumberBox(peonsScore01, GOALS_PEONS)
call SetNumberBox(peonsScore10, TEN_GOALS_PEONS)
}
private void onInit() {
set Scoreboard3D = gg_unit_h005_0013
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib_init ( Scoreboard, config, StdLib ), StatsLib
private multiboard SB = null
private bool Switch_Conditions () {
bool b1 = udg_Round >= 0 && udg_Round <= 2
bool b2 = true
bool b3 = SB != null
return b1 && b2 && b3
}
private void SwitchMode () {
call Ensure( GetLocalPlayer() == GetTriggerPlayer() )
if ( not IsMultiboardDisplayed(SB) ) then
call MultiboardDisplay(SB, true)
call MultiboardMinimize(SB, false)
elseif ( IsMultiboardMinimized(SB) ) then
call MultiboardDisplay(SB, false)
else
call MultiboardMinimize(SB, true)
endif
}
private string GetTitle() {
string peasants_score = TeamNameShort[1] + " " + I2S(udg_Score[1]) //"|c00ffff00Peasants " + I2S(udg_Score[1]) + "|r"
string peons_score = TeamNameShort[2] + " " + I2S(udg_Score[2]) //"|c00ff0000Peons " + I2S(udg_Score[2]) + "|r"
string delimiter = " : " // " : "
string esc_hint = White(" [")+Orange("Esc")+white(]) //"]"
string title = peasants_score + delimiter + peons_score + esc_hint
return title
}
public void Refresh() {
call MultiboardSetTitleText(SB, GetTitle())
int ngoals, nassists
int row = 2
int pid = 1
whilenot pid > 12 {
if IsPlayerStatePlayingOrLeft(ConvertedPlayer(pid))
{
set ngoals = PlayerGetInt(pid, "goals")
set nassists = PlayerGetInt(pid, "assists")
call MultiboardSetItemValueBJ(SB, 2, row, I2S(ngoals))
call MultiboardSetItemValueBJ(SB, 3, row, I2S(nassists))
row++
}
pid++
}
}
private void MultiboardSetItemNationalFlag(multiboard mb, integer col, integer row, integer pid) {
player p = ConvertedPlayer(pid)
integer team = GetPlayerConvertedTeam(p)
integer nation = TeamGetInt(team,"nation_id")
string str_nation = NationToStr(nation)
string path = "war3mapImported\\Flag_of_"+str_nation+".blp"
if (nation!=0)
call MultiboardSetItemStyleBJ(mb, col, row, true, true)
call MultiboardSetItemIconBJ(mb, col, row, path)
endif
}
public void Create() {
call Sleep( 0.1 )
conditionfunc cond = Condition(function FilterPlayerStatePlayingOrLeft)
force f = GetPlayersMatching(cond)
int nplayers = CountPlayersInForceBJ(f)
int nrows = nplayers + 1 // used to be +3
int ncols = 3
string title = GetTitle()
real width = 12.2
set SB = CreateMultiboardBJ(ncols, nrows, title)
call MultiboardSetItemsStyle(SB, true, false)
call MultiboardSetItemWidthBJ(SB, 1, 1, width)
//call MultiboardSetItemValueBJ(SB, 1, 1, Orange("Esc") + " to hide")
call MultiboardSetItemValueBJ(SB, 2, 1, "G")
call MultiboardSetItemValueBJ(SB, 3, 1, "A")
real R,G,B
int row = 1, curPlayer = 0
int pid
whilenot curPlayer > 11
{
if ( IsPlayerStatePlayingOrLeft(Player(curPlayer)) ) then
pid = curPlayer + 1
row ++
call MultiboardSetItemValueBJ(SB, 1, row, udg_PlayerNames[pid])
call MultiboardSetItemWidthBJ(SB, 1, row, width)
call MultiboardSetItemNationalFlag(SB,1,row,pid)
call MultiboardSetItemValueBJ(SB, 2, row, I2S(udg_PlayerScore[pid]))
call MultiboardSetItemValueBJ(SB, 3, row, I2S(udg_nAssists[pid]))
set R = udg_PlayerColorR[pid]
set G = udg_PlayerColorG[pid]
set B = udg_PlayerColorB[pid]
call MultiboardSetItemColorBJ(SB, 2, row, R,G,B, 0)
call MultiboardSetItemColorBJ(SB, 3, row, R,G,B, 0)
endif
curPlayer ++
}
return
row += 1
width = 25.
//call MultiboardSetItemValueBJ(SB, 1, row, "|cff808080Time left: 0:00|r")
call MultiboardSetItemWidthBJ(SB, 1, row, width)
row += 1
call MultiboardSetItemValueBJ(SB, 1, row, Orange("ESC")+" = hide/show scoreboard.")
call MultiboardSetItemWidthBJ(SB, 1, row, width)
call MultiboardMinimize(SB, false)
}
public void Destroy() {
call DestroyMultiboard(SB)
}
private void config() {
trigger t = CreateTrigger( )
call TriggerRegisterAnyPlayerEvent(t, EVENT_PLAYER_END_CINEMATIC)
call TriggerAddConditionSimple( t, function Switch_Conditions)
call TriggerAddAction( t, function SwitchMode )
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib_init (StatsLib, onInit, StdLib)
globals
multiboard StatsMB = null
int StepByStepDisplay = 0
real MI_ColDisplayDelay = 0.6
enum (stats extract styles) {
UPDATE_MAX_VAL
UPDATE_MAX_PID
}
endglobals
// PLAYER
function PlayerStoreInt takes int pid, string key, int val returns nothing
call StoreInteger( Cache, "player_"+I2S(pid), key, val )
endfunction
function PlayerGetInt takes int pid, string key returns int
return GetStoredInteger( Cache, "player_"+I2S(pid), key )
endfunction
function PlayerIncInt takes int pid, string key returns nothing
int val = PlayerGetInt( pid, key )
call PlayerStoreInt(pid, key, ++val)
endfunction
function PlayerStoreReal takes int pid, string key, real val returns nothing
call StoreReal( Cache, "player_"+I2S(pid), key, val )
endfunction
function PlayerGetReal takes int pid, string key returns real
return GetStoredReal( Cache, "player_"+I2S(pid), key )
endfunction
function PlayerIncReal takes int pid, string key, real toadd returns nothing
real val = PlayerGetReal( pid, key )
call PlayerStoreReal(pid, key, val + toadd)
endfunction
function PlayerStoreStr takes int pid, string key, string val returns nothing
call StoreString( Cache, "player_"+I2S(pid), key, val)
endfunction
function PlayerGetStr takes int pid, string key returns string
return GetStoredString( Cache, "player_"+I2S(pid), key)
endfunction
// TEAM
function TeamStoreInt takes int team, string key, int val returns nothing
call StoreInteger( Cache, "team_"+I2S(team), key, val )
endfunction
function TeamGetInt takes int team, string key returns int
return GetStoredInteger( Cache, "team_"+I2S(team), key )
endfunction
function TeamIncInt takes int team, string key returns nothing
int val = TeamGetInt( team, key )
call TeamStoreInt(team, key, ++val)
endfunction
function TeamIncIntExt takes int team, string key, int toadd returns nothing
int val = TeamGetInt( team, key )
call TeamStoreInt(team, key, val + toadd)
endfunction
function TeamStoreReal takes int team, string key, real val returns nothing
call StoreReal( Cache, "team_"+I2S(team), key, val )
endfunction
function TeamGetReal takes int team, string key returns real
return GetStoredReal( Cache, "team_"+I2S(team), key )
endfunction
function TeamIncReal takes int team, string key, real toadd returns nothing
real val = TeamGetReal( team, key )
call TeamStoreReal(team, key, val + toadd)
endfunction
function TeamStoreStr takes int team, string key, string val returns nothing
call StoreString( Cache, "team_"+I2S(team), key, val)
endfunction
function TeamGetStr takes int team, string key returns string
return GetStoredString( Cache, "team_"+I2S(team), key)
endfunction
// GAME
function GameStoreInt takes string key, int val returns nothing
StoreInteger(Cache, "game", key, val)
endfunction
function GameGetInt takes string key returns int
return GetStoredInteger(Cache, "game", key)
endfunction
function GameIncInt takes string key returns nothing
int val = GameGetInt(key)
GameStoreInt(key, ++val)
endfunction
function GameIncIntExt takes string key, int toadd returns nothing
int val = GameGetInt(key)
GameStoreInt(key, val + toadd)
endfunction
function GameStoreReal takes string key, real val returns nothing
StoreReal(Cache, "game", key, val)
endfunction
function GameGetReal takes string key returns real
return GetStoredReal(Cache, "game", key)
endfunction
// update max val funcs
function PlayerUpdateMaxInt takes int pid, string key, int style returns nothing
int val = PlayerGetInt(pid, key)
int val_max
// ZERO_CELL_MAX_PID
// ZERO_CELL_FOR_MAX_PID
// STYLE_MAX_PID
// STYLE_ZERO_MAX_PID
if style == UPDATE_MAX_PID
int pid_max = PlayerGetInt(0, key)
val_max = PlayerGetInt(pid_max, key)
if val_max < val
PlayerStoreInt(0, key, pid)
endif
elseif style == UPDATE_MAX_VAL
val_max = PlayerGetInt(0, key)
if val_max < val
PlayerStoreInt(0, key, val)
endif
endif
endfunction
function PlayerGetMaxInt takes string key, int style returns int
int retval = 0
if style == UPDATE_MAX_PID
int pid_max = PlayerGetInt(0, key)
retval = PlayerGetInt(pid_max, key)
elseif style == UPDATE_MAX_VAL
retval = PlayerGetInt(0, key)
endif
return retval
endfunction
function PlayerUpdateMaxReal takes int pid, string key, int style returns nothing
real val = PlayerGetReal(pid, key)
real val_max
if style == UPDATE_MAX_PID
int pid_max = R2I(PlayerGetReal(0, key))
val_max = PlayerGetReal(pid_max, key)
if val_max < val
PlayerStoreReal(0, key, pid)
endif
elseif style == UPDATE_MAX_VAL
val_max = PlayerGetReal(0, key)
if val_max < val
PlayerStoreReal(0, key, val)
endif
endif
endfunction
function PlayerGetMaxReal takes string key, int style returns real
real retval = 0
if style == UPDATE_MAX_PID
int pid_max = R2I(PlayerGetReal(0, key))
retval = PlayerGetReal(pid_max, key)
elseif style == UPDATE_MAX_VAL
retval = PlayerGetReal(0, key)
endif
return retval
endfunction
// end cache
function MI_SetItem takes int col, int row, real width, string str returns nothing
call MultiboardSetItemValueBJ(StatsMB, col, row, str)
call MultiboardSetItemWidthBJ(StatsMB, col, row, width) // causes error
endfunction
function MI_SetItemIcon takes int col, int row, string path returns nothing
call MultiboardSetItemIconBJ(StatsMB, col, row, path)
call MultiboardSetItemStyleBJ(StatsMB, col, row, true, true)
endfunction
function MI_PlayerGetStats takes int pid, string key returns string
int val_int
real val_real
string val_str
string str_output=" "
// real keys
if key == "rating"
val_real = PlayerGetReal(pid, key)
str_output = R2SW(val_real, 2, 1)
string str_output_long = R2SW(val_real, 3, 2)
if ( PlayerGetMaxReal(key, UPDATE_MAX_PID) == val_real && val_real != 0 ) || val_real >= 8.95
str_output = Green(str_output_long)
endif
elseif key == "pass_accuracy"
real pass_success = PlayerGetReal(pid, key)
val_real = pass_success * 100.0
str_output = I2S(Round(val_real)) + " %"
if PlayerGetMaxReal(key, UPDATE_MAX_PID) == pass_success && pass_success != 0
str_output = Green(str_output)
endif
// string keys
elseif key == "name"
val_str = PlayerGetStr(pid, key)
str_output = val_str
elseif key == "blank"
str_output = " "
// int keys
// style == UPDATE_MAX_VAL
elseif IsInSet( key, "goals", "assists", "slides_succ", "tackles", "slides_all", "dribbles_succ" )
val_int = PlayerGetInt(pid, key)
str_output = I2S(val_int)
if val_int == PlayerGetMaxInt(key, UPDATE_MAX_VAL) && val_int != 0
str_output = Green(str_output)
endif
// style == UPDATE_MAX_PID
elseif IsInSet(key, "z_pressed", "z_made", "passes_failed", "passes_all", "passes_succ")
val_int = PlayerGetInt(pid, key)
str_output = I2S(val_int)
if val_int == PlayerGetMaxInt(key, UPDATE_MAX_PID) && val_int != 0
str_output = Green(str_output)
endif
elseif IsInSet(key, "possession")
val_real = PlayerGetReal(pid, key)
val_int = R2I(val_real)
int mins = val_int/60
int seconds = mod(val_int, 60)
string str_seconds = AddLeadingZeroes(seconds)
str_output = I2S(mins)+":"+str_seconds
//str_output = R2SW(val_real,5,2)
if val_real == PlayerGetMaxReal(key, UPDATE_MAX_PID) && val_real != 0
str_output = Green(str_output)
endif
endif
return str_output
endfunction
function MI_PlayerDisplayStats takes int col, int row, int header_spacing, \
int team_spacing, real width, string header, string key returns nothing
MI_SetItem(col, row, width, header)
int curPlayer = 0, pid, val
player p
boolean p_state
string str_output
row += header_spacing + 1
whilenot curPlayer > 11 {
p = Player(curPlayer)
p_state = IsPlayerStatePlayingOrLeft(p)
pid = curPlayer + 1
// if p_state //|| ( not p_state && ShowFictivePlayers )//&& pid != 4 && pid != 9)
str_output = MI_PlayerGetStats(pid, key)
MI_SetItem(col, row, width, str_output)
//testmsg(here! 2)
if not p_state
int grey = 32
MultiboardSetItemColorBJ(StatsMB, col, row, grey,grey,grey,0)
endif
row ++
if ( curPlayer == 5 )
row += team_spacing
endif
curPlayer ++
}
if StepByStepDisplay == 1 && key != "blank"
Sleep(MI_ColDisplayDelay)
endif
endfunction
function MI_TeamGetStats takes int team, string key returns string
string val_str
int val_int
real val_real
string str_output = ""
// reals
if key == "possession"
val_real = TeamGetReal(team, key)
str_output = R2SW(val_real, 2, 1) + " %"
// ints
elseif IsInSet(key , "score", "corners", "throwins", "goalkicks")
val_int = TeamGetInt(team, key)
str_output = I2S(val_int)
// strings
elseif IsInSet(key, "name", "name_short")
val_str = TeamGetStr(team, key)
str_output = val_str
endif
return str_output
endfunction
void MI_TeamDisplayStats (int col, int row, int header_spacing, int team_spacing, \
real width, string header, string key) {
string str_output
MI_SetItem(col, row, width, header)
row += header_spacing + 1
str_output = MI_TeamGetStats(1, key)
MI_SetItem(col, row, width, str_output)
row += team_spacing + 1
str_output = MI_TeamGetStats(2, key)
MI_SetItem(col, row, width, str_output)
if StepByStepDisplay == 1
Sleep(MI_ColDisplayDelay)
endif
}
private void onInit () {
int pid = 1
string str = ""
/*
PlayerStoreInt(pid, "", 0)
TeamStoreInt(pid, "", 0)
TeamStoreStr(team, "", str)
*/
//PlayerStoreStr(pid, "name", str)
PlayerStoreInt(pid, "goals", 0)
PlayerStoreInt(pid, "assists", 0)
PlayerStoreInt(pid, "z_pressed", 0)
PlayerStoreInt(pid, "z_made", 0)
PlayerStoreInt(pid, "slides_succ", 0)
PlayerStoreInt(pid, "tackles", 0)
PlayerStoreInt(pid, "slides_all", 0)
PlayerStoreInt(pid, "passes_succ", 0)
PlayerStoreInt(pid, "passes_failed", 0)
PlayerStoreInt(pid, "passes_all", 0)
PlayerStoreReal(pid, "pass_accuracy", 0)
PlayerStoreReal(pid, "rating", 0)
//TeamStoreStr(team, "name", str)
//TeamStoreStr(team, "name_short", str)
TeamStoreInt(1, "score", 0)
TeamStoreInt(1, "corners", 0)
TeamStoreInt(1, "throwins", 0)
TeamStoreInt(1, "goalkicks", 0)
TeamStoreReal(1, "possession", 0)
GameStoreReal("passes_all_average", 0 )
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function GetRealMatchTimeElapsed takes nothing returns real
if udg_Round < 0
return 0.0
elseif udg_Round == 0 // first half
return TimerGetElapsed(udg_RealTimer)
elseif udg_Round == 1 // half time
return (1*60*udg_RoundTime)
elseif udg_Round == 2 // second half
return ( 1*60*udg_RoundTime + TimerGetElapsed(udg_RealTimer) )
elseif udg_Round > 2
return (2*60*udg_RoundTime)
endif
return 0.0
endfunction
function Trig_Calculate_MI_Actions takes nothing returns nothing
//TestMsg("Entering calc MI")
integer ScoreSum = udg_Score[1] + udg_Score[2]
// Team Possession
real array team_pos
real pass_success
if udg_TeamPossession[1] == 0 && udg_TeamPossession[2] == 0
team_pos[1] = 50.0
team_pos[2] = 50.0
else
// real pos_sum = udg_TeamPossession[1] + udg_TeamPossession[2]
real pos_sum = GetRealMatchTimeElapsed() //2*60*udg_RoundTime
team_pos[1] = 100 * udg_TeamPossession[1] / pos_sum
team_pos[2] = 100 * udg_TeamPossession[2] / pos_sum
endif
//team_pos[2] = abs(100 - team_pos[1])
TeamStoreReal(1, "possession", team_pos[1])
TeamStoreReal(2, "possession", team_pos[2])
//TestMsg("point: about to calc ps")
integer pid = 1
whilenot pid > 12
{
// possession
PlayerStoreReal(pid, "possession", udg_PlayerPossession[pid])
PlayerUpdateMaxReal(pid, "possession", UPDATE_MAX_PID)
//call MMD_UpdateValueReal("ball_possession", ConvertedPlayer(pid), MMD_OP_SET, udg_PlayerPossession[pid])
// dribbles
/*
PlayerStoreInt(pid, "dribbles_succ", udg_nSuccDribbles[pid])
PlayerUpdateMaxInt(pid, "dribbles_succ", UPDATE_MAX_PID)
//udg_nSuccDribbles[pid]
*/
// all passes
int passes_failed = udg_nFailedPasses[pid]
int passes_succ = udg_nSuccPasses[pid]
int passes_all = passes_failed + passes_succ
udg_nAllPasses[pid] = passes_all
PlayerStoreInt(pid, "passes_succ", passes_succ)
PlayerStoreInt(pid, "passes_failed", passes_failed)
PlayerStoreInt(pid, "passes_all", passes_all)
//call MMD_UpdateValueInt("passes_succ", ConvertedPlayer(pid), MMD_OP_SET, passes_succ)
//call MMD_UpdateValueInt("passes_all", ConvertedPlayer(pid), MMD_OP_SET, passes_all)
//TestMsg("point ps 0")
PlayerUpdateMaxInt(pid, "passes_all", UPDATE_MAX_PID)
PlayerUpdateMaxInt(pid, "passes_failed", UPDATE_MAX_PID)
PlayerUpdateMaxInt(pid, "passes_succ", UPDATE_MAX_PID)
integer team = GetTeamNumberByPid(pid)
player p = ConvertedPlayer(pid)
//TestMsg("point ps 1")
if IsPlayerStatePlaying(p) && passes_all >= 10 && not IsPlayerInForce(p, Observers)
GameIncIntExt("passes_all", passes_all)
GameIncInt("passers_all")
endif
//TestMsg("point ps 2")
// pass success
pass_success = 0.0
if passes_all != 0
pass_success = passes_succ/I2R(passes_all)
endif
//TestMsg("point ps 3")
PlayerStoreReal(pid, "pass_accuracy", pass_success)
PlayerUpdateMaxReal(pid, "pass_accuracy", UPDATE_MAX_PID)
pid += 1
}
// rating
//TestMsg("point: before rating calc 0, Sleep")
Sleep(0)
real npasses = GameGetInt("passes_all")
real npassers = GameGetInt("passers_all")
real passes_avg = 0.0
if npassers != 0
passes_avg = npasses/npassers
endif
GameStoreReal("passes_all_average", passes_avg )
pid = 1
real score_part, pass_part
//TestMsg("point: before rating calc 1")
whilenot pid > 12
{
score_part = 0
if ScoreSum != 0
integer nassists = PlayerGetInt(pid, "assists")
integer pscore = udg_PlayerScore[pid]
score_part = 4.5 * (nassists + pscore)/(0.5 * ScoreSum)
endif
pass_success = PlayerGetReal(pid, "pass_accuracy")
npasses = PlayerGetInt(pid, "passes_all")
passes_avg = GameGetReal("passes_all_average")
pass_part = 0
if passes_avg != 0
pass_part = 5.5 * ( npasses/ passes_avg) * pass_success
endif
real prating = score_part + pass_part
if prating >= 9.0
real diff = prating - 9
diff /= (15 - 9)
prating = 9 + diff
endif
//udg_/PlayerRating[pid] = val_real
call PlayerStoreReal(pid, "rating", prating)
call PlayerUpdateMaxReal(pid, "rating", UPDATE_MAX_PID)
//call MMD_UpdateValueReal("rating", ConvertedPlayer(pid), MMD_OP_SET, prating)
if Player(pid-1) == morganxl
TestMsg("rating = "+R2S(prating))
endif
pid ++
}
endfunction
//===========================================================================
function InitTrig_Calculate_MS takes nothing returns nothing
set gg_trg_Calculate_MS = CreateTrigger( )
call TriggerAddAction( gg_trg_Calculate_MS, function Trig_Calculate_MI_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Statistical_Multiboard_Actions takes nothing returns nothing
int row, col
real width
int pid
int team_spacing = 0, header_spacing = 0
call ClearMapMusic()
call PlayMusic( gg_snd_Credits )
call Scoreboard_Destroy()
call DestroyTimerDialog(udg_TimerDialog)
call TriggerExecute(gg_trg_Calculate_MS)
call Sleep(0.5)
call MaskFadeOut(1)
int ncols = 35
int nrows = 30
string title = "Match Stats"
set StatsMB = CreateMultiboardBJ(ncols, nrows, title)
if StepByStepDisplay == 0
call MultiboardMinimize(StatsMB, true)
endif
call MultiboardSetItemsStyle( StatsMB, true, false )
//MultiboardSetItemsWidth( StatsMB, 0.5 )
if StepByStepDisplay == 1
Sleep(0)
endif
col = 1; row = 1; width = 9.0
call MI_PlayerDisplayStats(col, row, 0, 2, 9.0, " ", "name")
//MI_SetItemIcon (col, row, "ReplaceableTextures\\CommandButtons\\BTNPeasant.blp")
/*
row = 9
MI_SetItem(col, row, width, TeamName[2])
*/
//MI_SetItemIcon (col, row, "ReplaceableTextures\\CommandButtons\\BTNPeon.blp")
col ++
row = 1
real sleep_time = MI_ColDisplayDelay
header_spacing = 0
call MI_PlayerDisplayStats(col, row, header_spacing, 2, 4.5, "Goals", "goals")
col++
call MI_PlayerDisplayStats(col, row, header_spacing, 2, 5.0, "Assists", "assists")
col++
if StepByStepDisplay == 0
Sleep(0)
endif
call MI_PlayerDisplayStats(col, row, header_spacing, 2, 4.5, "P.S.*", "pass_accuracy") // Pass Success
col++
call MI_PlayerDisplayStats(col, row, header_spacing, 2, 5.0, "Passes", "passes_all")
col++
//call MI_PlayerDisplayStats(col, row, header_spacing, 2, 5.0, "Tackles", "tackles")
//col++
/*call MI_PlayerDisplayStats(col, row, header_spacing, 2, 4.5, "B.P.**", "possession")
col++*/
///*
call MI_PlayerDisplayStats(col, row, header_spacing, 2, 5.5, "Dribbles", "dribbles_succ")
col++
//*/
call MI_PlayerDisplayStats(col, row, header_spacing, 2, 4.5, "Rating", "rating")
//col++ // ?
//call MI_PlayerDisplayStats(col, row, header_spacing, 2, 4.5, " ", "blank")
// for StepByStepDisplay == 1
int col_rating = col
int row_rating = row
row += 18
col = 1
//call MI_PlayerDisplayStats(col, row, 0, 0, 7, " ", "blank")
// causes displacement of text to the right (potm message)
/*MI_SetItem(col,row,15.0,"*P.S. = Pass Success")
row++
MI_SetItem(col,row,15.0,"**B.P. = Ball Possession")
row++*/
set col = col_rating
set row = row_rating
if StepByStepDisplay == 0
Sleep(0)
endif
/*
****************
** TEAM STATS **
****************
*/
col += 3
int row_start = 1; row = row_start
team_spacing = 0; header_spacing = 0
int col_teams = col
MI_TeamDisplayStats(col, row_start, header_spacing, team_spacing, 9.0, "Team", "name")
/*
row += header_spacing + 1
MI_SetItemIcon (col, row, "ReplaceableTextures\\CommandButtons\\BTNPeasant.blp")
row += team_spacing + 1
MI_SetItemIcon (col, row, "ReplaceableTextures\\CommandButtons\\BTNPeon.blp")
*/
col ++
MI_TeamDisplayStats(col, row_start, header_spacing, team_spacing, 4.5, "Score", "score")
col ++
MI_TeamDisplayStats(col, row_start, header_spacing, team_spacing, 4.5, "B.P.**", "possession")
col ++
//MI_TeamDisplayStats(col, row_start, header_spacing, team_spacing, 6.0, "Throwins", "throwins")
//col ++
set col = col_teams
set row = row_start + 9
set width = 12.0
string str
set str = "Keepers"
MI_SetItem (col, row, width, str)
set str = udg_PlayerNames[13]
MI_SetItem (col, row+1, width, str)
set str = udg_PlayerNames[14]
MI_SetItem (col, row+2, width, str)
col++
width = 5.0
set str = "Saves"
MI_SetItem (col, row, width, str)
set str = I2S(PlayerGetInt(13, "saves"))
MI_SetItem (col, row+1, width, str)
set str = I2S(PlayerGetInt(14, "saves"))
MI_SetItem (col, row+2, width, str)
/*
****************
**** AWARDS ****
****************
*/
// man of the match
set width = 35
set row = 18
int col_motm = 17
MI_SetItem(col_motm, row, width, Orange("AWARDS") )
//int pid_motm = R2I(udg_Player/Rating[0])
row+= 1
int pid_motm = R2I(PlayerGetReal(0, "rating"))
// Comment (high rating)
real rating = PlayerGetReal(pid_motm, "rating")
string comment = ""
// Orange("GODLIKE")
if rating >= 9.2
comment = Orange("GODLIKE")
elseif rating >= 9.0
comment = Orange("WICKED SICK")
elseif rating >= 8.5
comment = Orange("UNSTOPPABLE")
endif
if rating >= 8.5
comment = "("+comment+")"
endif
call MI_SetItem(col_motm, row, width, "Player of the match: " + udg_PlayerNames[pid_motm] + " "+comment)
// done motm
// + need to green max val in col in here
if StepByStepDisplay == 0
Sleep(0)
elseif StepByStepDisplay == 1
Sleep(sleep_time)
endif
// best out of team 2
row += 1
/*int pid_start = 1
int pid_end = 6*/
int team_number = GetTeamNumberByPid(pid_motm)
set team_number = GetEnemyTeamNumber(team_number)
string team_max = TeamNameShort[team_number]
/*string team_max = TeamNameShort[1]
if pid_motm <= 6
pid_start = 7
pid_end = 12
team_max = TeamNameShort[2]
endif*/
real rating_max = 0.0
int pid_max = 0
int pid_i = 1
whilenot (pid_i > 12)
{
if IsUnitInTeam(Hero[pid_i], team_number)
{
if rating_max < PlayerGetReal(pid_i, "rating" )
rating_max = PlayerGetReal(pid_i, "rating" )
pid_max = pid_i
endif
}
pid_i ++
}
MI_SetItem(col_motm, row, width, "Best out of "+team_max+": " + udg_PlayerNames[pid_max]) // not pid_motm
// done best out of another team
row+= 1
int pid_bp = PlayerGetInt(0, "passes_succ")
int sp_max = PlayerGetMaxInt("passes_succ", UPDATE_MAX_PID)
MI_SetItem(col_motm, row, width, "Best Passer: " + udg_PlayerNames[pid_bp]+" ("+Green(I2S(sp_max))+")")
/*
row+= 1
MI_SetItem(col_motm, row, width, "Wicked sick: " + HighRatingAchievers)
*/
Sleep(sleep_time)
// z sotm
/*
row += 1
int pid_z_max = PlayerGetInt(0, "z_pressed")
//int z_max = PlayerGetInt(pid_z_max, "z_pressed")
int z_max = PlayerGetMaxInt("z_pressed", UPDATE_MAX_PID)
//MI_SetItem(col_motm, row, width, "Z spammer of the match: "+udg_PlayerNames[pid_z_max]+" ("+Green(I2S(z_max))+" Z hits)" )
*/
// done z sotm
if StepByStepDisplay == 0
Sleep(0)
elseif StepByStepDisplay == 1
Sleep(sleep_time)
endif
// end
// rating :))
if StepByStepDisplay == 1
col = col_rating
row = row_rating
call MI_PlayerDisplayStats(col, row, 0, 2, 4.5, "Rating", "rating")
endif
row += 2 // ~26?
//MI_SetItem(col_motm, row, width, )
col = col_motm
width = 35
MI_SetItem(col, row, width, Orange("CONTACTS") )
row += 1
MI_SetItem(col, row, width, "Battle.net, Europe: "+Orange("Clan FOOT") )
//row += 1
//MI_SetItem(col, row, width, "Battle.net, US West: "+Orange("Clan Pass") )
row += 1
MI_SetItem(col, row, width, "Forums: "+Cyan/*Orange*/("http://warcraftsoccereu.forumotion.com") )
/*
row += 1
MI_SetItem(col, row, width, Cyan("War3 RPG > Europe > Europe Football Room") )
*/
call Sleep(0)
call ClearTextMessages()
call MultiboardMinimize(StatsMB, false)
call Sleep(1)
call FlashQuestDialogButton()
endfunction
//===========================================================================
function InitTrig_Display_Stats takes nothing returns nothing
set gg_trg_Display_Stats = CreateTrigger( )
call TriggerAddAction( gg_trg_Display_Stats, function Trig_Statistical_Multiboard_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib_init( Camera, config, StdLib )
//define
constant int ITEM_ID_ZOOM_IN = 'I000'
constant int ITEM_ID_ZOOM_OUT = 'I001'
constant int ITEM_ID_ANGLE_LOWER = 'I002'
constant int ITEM_ID_ANGLE_HIGHER = 'I003'
private void CameraLookAtBallEnum() {
unit u = GetEnumUnit()
real facing = AngleBetweenUnits(u,Ball)
call SetUnitFacing(u,facing+180)
}
private void CameraOperatorActionsEnum() {
unit u = GetEnumUnit()
call SetUnitAnimation(u,"work")
}
function Timer_Interval_SmartCameraActions takes nothing returns nothing
group g = GetUnitsOfTypeIdAll('h00S')
call ForGroup(g, function CameraLookAtBallEnum)
call DestroyGroup(g)
endfunction
private void CameraOperatorsWorkAnimation() {
group g = GetUnitsOfTypeIdAll('h00T')
call ForGroup(g, function CameraOperatorActionsEnum)
call DestroyGroup(g)
}
function RealAngle2GameAngle takes real angle_input returns real
if angle_input < 1
angle_input = 1
elseif angle_input > 89
angle_input = 89
endif
real angle = -angle_input + 360
return angle
endfunction
function GameAngle2RealAngle takes real angle_input returns real
real angle = 360 - angle_input
if angle < 1
angle = 1
elseif angle > 89
angle = 89
endif
return angle
endfunction
private real GetGameAngle() {
return bj_RADTODEG * GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK)
}
real GetAngle() {
real angle = GetGameAngle()
set angle = GameAngle2RealAngle(angle)
return angle
}
private void SetGameAngleForPlayer(player p, real angle, real time) {
call SetCameraFieldForPlayer( p, CAMERA_FIELD_ANGLE_OF_ATTACK, angle, time )
}
void SetCameraAngleForPlayer(player p, real angle, real time) {
set angle = RealAngle2GameAngle(angle)
call SetGameAngleForPlayer( p, angle, time )
}
#define PanCameraToCenter(p) = {
PanCameraToTimedLocForPlayer( p, GetPitchCenter(), 1.5 )
}
#define PanCameraToCenter() = {
PanCameraToCenter( GetLocalPlayer() )
}
private function CamInitEnum takes nothing returns nothing
player p = GetEnumPlayer()
int pid = cPid(p)
//call PanCameraToCenter(p)
if p != morganxl {
call SetGameAngleForPlayer( p, 330, 2 )
}
set udg_CameraDistance[pid] = 1870
if (p == morganxl) { udg_CameraDistance[pid] = 2070 }
//sleep(2)
//call SetCameraFieldForPlayer( p, CAMERA_FIELD_TARGET_DISTANCE, CameraSetupGetFieldSwap(CAMERA_FIELD_TARGET_DISTANCE, gg_cam_Camera_001), 0 )
endfunction
public function Init takes nothing returns nothing
call PolledWait( 0.1 )
call ForForce( GetPlayersAll(), function CamInitEnum )
//call CameraOperatorsWorkAnimation()
endfunction
private void UpdateEnum() {
player p = GetEnumPlayer()
integer pid = GetConvertedPlayerId(p)
if not IsPlayerStatePlaying(p) then
pid = 0 // for obs // ?
endif
call SetCameraFieldForPlayer( p, CAMERA_FIELD_TARGET_DISTANCE, udg_CameraDistance[pid], 0.5 )
}
public void Update() {
call ForForce( GetPlayersAll(), function UpdateEnum )
}
private bool IsAngleAdjustedThroughItems() {
integer item_id = GetItemTypeId(GetManipulatedItem())
boolean b1 = item_id == ITEM_ID_ANGLE_LOWER
boolean b2 = item_id == ITEM_ID_ANGLE_HIGHER
return b1 or b2
}
private void AngleItemIsUsed() {
call Ensure( IsAngleAdjustedThroughItems() )
int item_id = GetItemTypeId(GetManipulatedItem())
real angle = GetAngle()
TestMsg(R2S(angle))
static real step = 6.5
static real time = 0.3
if item_id == ITEM_ID_ANGLE_LOWER
angle -= step
else
angle += step
endif
call SetCameraAngleForPlayer( GetTriggerPlayer(), angle, time )
}
private void config() {
trigger t
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_USE_ITEM )
call TriggerAddAction( t, function AngleItemIsUsed )
}
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_angle_cmd_Actions takes nothing returns nothing
integer patlen = StringLength(GetEventPlayerChatStringMatched())
string input = GetEventPlayerChatString()
integer strlen = StringLength(input)
call Ensure( strlen > patlen )
string str_angle = SubStringBJ(input, patlen+1, strlen)
real angle_input = S2R(str_angle)
real angle_game = RealAngle2GameAngle(angle_input)
call SetCameraFieldForPlayer( GetTriggerPlayer(), CAMERA_FIELD_ANGLE_OF_ATTACK, angle_game, 2 )
endfunction
//===========================================================================
function InitTrig_angle_cmd takes nothing returns nothing
set gg_trg_angle_cmd = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent(gg_trg_angle_cmd, "-angle ", "-view ", false)
call TriggerAddAction( gg_trg_angle_cmd, function Trig_angle_cmd_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Zoom_in_Conditions takes nothing returns boolean
integer item_id = GetItemTypeId(GetManipulatedItem())
local boolean b11 = item_id == ITEM_ID_ZOOM_IN
local boolean b12 = item_id == ITEM_ID_ZOOM_OUT
local boolean b1 = b11 or b12
return b1
endfunction
function Trig_Zoom_in_Actions takes nothing returns nothing
local player p = GetOwningPlayer(GetManipulatingUnit())
local integer pid = GetConvertedPlayerId(p)
local integer type_id = GetItemTypeId(GetManipulatedItem())
// TODO - possibly simplify the boolean tree below
if type_id == ITEM_ID_ZOOM_IN {
if InTesting || InTraining
udg_CameraDistance[pid] -= 100
else
udg_CameraDistance[pid] = RMaxBJ( 1800, udg_CameraDistance[pid] - 100 )
endif
} else {
if InTesting || InTraining
udg_CameraDistance[pid] += 100
else
udg_CameraDistance[pid] = RMinBJ( 4000, udg_CameraDistance[pid] + 100 )
endif
}
endfunction
//===========================================================================
function InitTrig_Zoom takes nothing returns nothing
set gg_trg_Zoom = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Zoom, EVENT_PLAYER_UNIT_USE_ITEM )
call TriggerAddConditionSimple( gg_trg_Zoom, function Trig_Zoom_in_Conditions )
call TriggerAddAction( gg_trg_Zoom, function Trig_Zoom_in_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_camera_cmd_Actions takes nothing returns nothing
string chat_str = GetEventPlayerChatString()
string str_pattern = GetEventPlayerChatStringMatched()
integer patternlen = StringLength(str_pattern)
integer strlen = StringLength(chat_str)
if strlen < patternlen + 2 // space and next letter
return
endif
string str_val = SubStringBJ(chat_str, patternlen+2, strlen)
real val = S2R(str_val)
if val < 1500 or val > 3500
return
endif
integer pid = GetConvertedPlayerId(GetTriggerPlayer())
set udg_CameraDistance[pid] = val
endfunction
//===========================================================================
function InitTrig_camera_cmd takes nothing returns nothing
set gg_trg_camera_cmd = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent(gg_trg_camera_cmd, "-cam", "-camera" ,false)
call TriggerAddAction( gg_trg_camera_cmd, function Trig_camera_cmd_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Camera_Lock_and_Unlock_Actions takes nothing returns nothing
player p = GetTriggerPlayer()
int pid = GetConvertedPlayerId(p)
unit u = udg_Hero[pid]
if not udg_CameraLock[pid] then
call echo( p, "TRIGSTR_291" )
set udg_CameraLock[pid] = true
call SetCameraTargetControllerNoZForPlayer( p, u, 0, 0, false )
else
call echo( p, "TRIGSTR_292" )
set udg_CameraLock[pid] = false
set udg_CameraAutoZoom[pid] = false
call ResetToGameCameraForPlayer( p, INFINITY_TIME )
endif
endfunction
//===========================================================================
function InitTrig_Camera_Lock takes nothing returns nothing
set gg_trg_Camera_Lock = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEvent(gg_trg_Camera_Lock, "-camlock", "-cam lock", "-camera lock", true)
call TriggerAddAction( gg_trg_Camera_Lock, function Trig_Camera_Lock_and_Unlock_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Multiplayer_Camera_Actions takes nothing returns nothing
local boolean b
local integer i = 1
local location l = Location(0,0) //declare this in the beginning
local real aoa
local real v
local real x
local real y
local real z
local real x1
local real y1
local real z1
loop
if Hero[i] != null and (GetWidgetLife(Hero[i]) > 0.405) then
set v = 25
set x = GetUnitX(Hero[i])
set y = GetUnitY(Hero[i])
call MoveLocation(l,x,y) //instead, just move the location to prevent several location creations/removals
set z = GetLocationZ(l)
set x1 = x + 64 * Cos(GetUnitFacing(Hero[i]) * bj_DEGTORAD)
set y1 = y + 64 * Sin(GetUnitFacing(Hero[i]) * bj_DEGTORAD)
call MoveLocation(l,x1,y1)
set z1 = GetLocationZ(l)
loop
set x1 = x - v * Cos(GetUnitFacing(Hero[i]) * bj_DEGTORAD)
set y1 = y - v * Sin(GetUnitFacing(Hero[i]) * bj_DEGTORAD)
set b = true //IsTerrainPathable(x1, y1, PATHING_TYPE_WALKABILITY) //IsTerrainPathingType(x1, y1, TERRAIN_PATHING_WALKABLE)
if ((b == true) and (v < 450)) then
set v = v + 25
elseif ((b == false) or (v == 450)) then
exitwhen true
endif
endloop
//The following "if" works for Player(1), the owner of Hero[i].
if GetLocalPlayer() == Player(i - 1) then
//We change the rotation according to Hero[i].
call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(Hero[i]), 0.08)
//We set the view distance to real v.
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, v, 0.08)
//We change the angle of attack according to the terrain.
//By changing the number 335, the angle of attack will change ingame.
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, 335 + ((z1 - z) * 0.5), 0.32)
//We change the field of view.
//I prefer to have it at 120.
call SetCameraField(CAMERA_FIELD_FIELD_OF_VIEW, 120, 0)
//Change the view distance.
//You can change it to whatever you like.
call SetCameraField(CAMERA_FIELD_FARZ, 5000, 5)
//We lock the camera to Hero[i], to make sure the player doesn't reset it.
call SetCameraTargetController(Hero[i], 0, 0, false)
//Set the height of the camera according to the height of the terrain.
call SetCameraField(CAMERA_FIELD_ZOFFSET, GetCameraField(CAMERA_FIELD_ZOFFSET) + z - GetCameraTargetPositionZ() + 128, -0.01)
call SetCameraField(CAMERA_FIELD_ZOFFSET, GetCameraField(CAMERA_FIELD_ZOFFSET) + z - GetCameraTargetPositionZ() + 128, 0.01)
endif
endif
exitwhen i == 1
set i = i + 1
endloop
call RemoveLocation(l)
set l = null
endfunction
function InitTrig_Multiplayer_Camera takes nothing returns nothing
set gg_trg_Multiplayer_Camera = CreateTrigger( )
call TriggerRegisterTimerEvent(gg_trg_Multiplayer_Camera,0.04,true)
call TriggerAddAction( gg_trg_Multiplayer_Camera, function Trig_Multiplayer_Camera_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
library TerrainPathability initializer Init
//******************************************************************************
//* BY: Rising_Dusk
//*
//* This script can be used to detect the type of pathing at a specific point.
//* It is valuable to do it this way because the IsTerrainPathable is very
//* counterintuitive and returns in odd ways and aren't always as you would
//* expect. This library, however, facilitates detecting those things reliably
//* and easily.
//*
//******************************************************************************
//*
//* > function IsTerrainDeepWater takes real x, real y returns boolean
//* > function IsTerrainShallowWater takes real x, real y returns boolean
//* > function IsTerrainLand takes real x, real y returns boolean
//* > function IsTerrainPlatform takes real x, real y returns boolean
//* > function IsTerrainWalkable takes real x, real y returns boolean
//*
//* These functions return true if the given point is of the type specified
//* in the function's name and false if it is not. For the IsTerrainWalkable
//* function, the MAX_RANGE constant below is the maximum deviation range from
//* the supplied coordinates that will still return true.
//*
//* The IsTerrainPlatform works for any preplaced walkable destructable. It will
//* return true over bridges, destructable ramps, elevators, and invisible
//* platforms. Walkable destructables created at runtime do not create the same
//* pathing hole as preplaced ones do, so this will return false for them. All
//* other functions except IsTerrainWalkable return false for platforms, because
//* the platform itself erases their pathing when the map is saved.
//*
//* After calling IsTerrainWalkable(x, y), the following two global variables
//* gain meaning. They return the X and Y coordinates of the nearest walkable
//* point to the specified coordinates. These will only deviate from the
//* IsTerrainWalkable function arguments if the function returned false.
//*
//* Variables that can be used from the library:
//* [real] TerrainPathability_X
//* [real] TerrainPathability_Y
//*
globals
private constant real MAX_RANGE = 10.
private constant integer DUMMY_ITEM_ID = 'wolg'
endglobals
globals
private item Item = null
private rect Find = null
private item array Hid
private integer HidMax = 0
public real X = 0.
public real Y = 0.
endglobals
function IsTerrainDeepWater takes real x, real y returns boolean
return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
endfunction
function IsTerrainShallowWater takes real x, real y returns boolean
return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_BUILDABILITY)
endfunction
function IsTerrainLand takes real x, real y returns boolean
return IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY)
endfunction
function IsTerrainPlatform takes real x, real y returns boolean
return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_BUILDABILITY)
endfunction
private function HideItem takes nothing returns nothing
if IsItemVisible(GetEnumItem()) then
set Hid[HidMax] = GetEnumItem()
call SetItemVisible(Hid[HidMax], false)
set HidMax = HidMax + 1
endif
endfunction
function IsTerrainWalkable takes real x, real y returns boolean
//Hide any items in the area to avoid conflicts with our item
call MoveRectTo(Find, x, y)
call EnumItemsInRect(Find ,null, function HideItem)
//Try to move the test item and get its coords
call SetItemPosition(Item, x, y) //Unhides the item
set X = GetItemX(Item)
set Y = GetItemY(Item)
static if LIBRARY_IsTerrainWalkable then
//This is for compatibility with the IsTerrainWalkable library
set IsTerrainWalkable_X = X
set IsTerrainWalkable_Y = Y
endif
call SetItemVisible(Item, false)//Hide it again
//Unhide any items hidden at the start
loop
exitwhen HidMax <= 0
set HidMax = HidMax - 1
call SetItemVisible(Hid[HidMax], true)
set Hid[HidMax] = null
endloop
//Return walkability
return (X-x)*(X-x)+(Y-y)*(Y-y) <= MAX_RANGE*MAX_RANGE and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
endfunction
private function Init takes nothing returns nothing
set Find = Rect(0., 0., 128., 128.)
set Item = CreateItem(DUMMY_ITEM_ID, 0, 0)
call SetItemVisible(Item, false)
endfunction
endlibrary
//TESH.scrollpos=-1
//TESH.alwaysfold=1
lib_init(AI, onInit, StdLib)
constant real SHOOT_TO_SCORE_DISTANCE = 150.
public function IsFilterPlayerBot takes nothing returns bool
bool b1 = GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_COMPUTER
bool b2 = GetFilterPlayer() != Player(PLAYER_NEUTRAL_PASSIVE)
return b1 and b2
endfunction
public function ShootToScore takes nothing returns nothing
player p = GetEnumPlayer()
unit u = udg_Hero[cPid(p)]
rect rect_1 = gg_rct_GoalLeft
rect rect_2 = gg_rct_GoalRight
real ball_x = Ball_GetX()
real ball_y = Ball_GetY()
if not (u == udg_BallOwner)
return
endif
if not ( ball_y > GetRectMinY(rect_1) && ball_y < GetRectMaxY(rect_1) )
return
endif
real dist_1 = abs( ball_x - GetRectMaxX(rect_1) )
real dist_2 = abs( ball_x - GetRectMinX(rect_2) )
location loc_shoot = null
if (dist_1 < SHOOT_TO_SCORE_DISTANCE)
// shoot into left goal, if enemy's
if (not IsLeftPlayer(p))
//shoot!
set loc_shoot = Location(GetRectCenterX(rect_1), ball_y)
call UnitKick(u, loc_shoot)
endif
elseif (dist_2 < SHOOT_TO_SCORE_DISTANCE)
if IsLeftPlayer(p)
set loc_shoot = Location(GetRectCenterX(rect_2), ball_y)
call UnitKick(u, loc_shoot)
endif
endif
call RemoveLocation(loc_shoot)
endfunction
// init
private void DisableBotAI() {
force bots = GetPlayersByMapControl(MAP_CONTROL_COMPUTER)
int nbots = CountPlayersInForceBJ(bots)
if nbots == 0 then
call DisableTrigger( gg_trg_Computer_AI )
endif
}
private void SetBotNamesEnum() {
player p = GetEnumPlayer()
integer pid = GetConvertedPlayerId(p)
aidifficulty ai_lvl = GetAIDifficulty(p)
string tag
if ( ai_lvl == AI_DIFFICULTY_NEWBIE ) then
set tag = " (EASY)"
elseif ( ai_lvl == AI_DIFFICULTY_NORMAL ) then
set tag = " (NORMAL)"
else
set tag = " (INSANE)"
endif
call SetPlayerName( p, "Bot " + I2S(pid) + tag )
}
private void SetBotNames() {
force f = GetPlayersByMapControl(MAP_CONTROL_COMPUTER)
call ForForce( f, function SetBotNamesEnum )
}
private void onInit() {
call SetBotNames()
call DisableBotAI()
}
//
function GetUnitAI takes unit u returns aidifficulty
return GetAIDifficulty(GetOwningPlayer(u))
endfunction
function GetUnitController takes unit u returns mapcontrol
return GetPlayerController(GetOwningPlayer(u))
endfunction
// AI FUNCTIONS
function BallOwnerAI_Easy takes nothing returns boolean
return GetUnitAI(udg_BallOwner) == AI_DIFFICULTY_NEWBIE
endfunction
function BallOwnerAI_Normal takes nothing returns boolean
return GetUnitAI(udg_BallOwner) == AI_DIFFICULTY_NORMAL
endfunction
function BallOwnerAI_Insane takes nothing returns boolean
return GetUnitAI(udg_BallOwner) == AI_DIFFICULTY_INSANE
endfunction
//
function CompControlsTempUnit takes nothing returns boolean
return GetUnitController(udg_TempUnit) == MAP_CONTROL_COMPUTER
endfunction
function CompControlsEnumUnit takes nothing returns boolean
return GetUnitController(GetEnumUnit()) == MAP_CONTROL_COMPUTER
endfunction
function CompControlsBallOwner takes nothing returns boolean
return GetUnitController(udg_BallOwner) == MAP_CONTROL_COMPUTER
endfunction
endlib
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Computer_AI_Func001Func013A takes nothing returns nothing
call UnitStop( GetHero(GetEnumPlayer()) )
endfunction
function Trig_Computer_AI_Actions takes nothing returns nothing
conditionfunc cond = Condition(function AI_IsFilterPlayerBot)
force bots = GetPlayersMatching(cond)
if ( udg_IgnoreAItimer > 0 ) then
call ForForce( bots, function Trig_Computer_AI_Func001Func013A )
call RemoveForce(bots); call RemoveCond(cond)
return
else // added
call ForForce(bots, function AI_ShootToScore)
endif
call RemoveForce(bots); call RemoveCond(cond)
call TriggerExecute( gg_trg_Clear_UnitGroups )
set udg_ThinkingTeamNumber = 1
set udg_ThinkingTeamEnemyNumber = 2
call GroupAddGroup( udg_Team1Heroes, udg_TempUnitGroup1 )
call GroupAddGroup( udg_Team2Heroes, udg_TempUnitGroup2 )
call TriggerExecute( gg_trg_Team_Actions )
call TriggerExecute( gg_trg_Clear_UnitGroups )
set udg_ThinkingTeamNumber = 2
set udg_ThinkingTeamEnemyNumber = 1
call GroupAddGroup( udg_Team1Heroes, udg_TempUnitGroup2 )
call GroupAddGroup( udg_Team2Heroes, udg_TempUnitGroup1 )
call TriggerExecute( gg_trg_Team_Actions )
endfunction
//===========================================================================
function InitTrig_Computer_AI takes nothing returns nothing
set gg_trg_Computer_AI = CreateTrigger( )
call TriggerAddAction( gg_trg_Computer_AI, function Trig_Computer_AI_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Headding_Action_Func001Func001A takes nothing returns nothing
set udg_ThinkingTeamNumber = 1
set udg_ThinkingTeamEnemyNumber = 2
call ConditionalTriggerExecute( gg_trg_Common_headding_action )
endfunction
function Trig_Headding_Action_Func001Func002A takes nothing returns nothing
set udg_ThinkingTeamNumber = 2
set udg_ThinkingTeamEnemyNumber = 1
call ConditionalTriggerExecute( gg_trg_Common_headding_action )
endfunction
function Trig_Headding_Action_IsBallHeadable takes nothing returns boolean
local boolean b1 = udg_IsBallInAir
local boolean b2 = udg_BallOwner == null
local boolean b3 = 200. * udg_G <= Pow(udg_BallVZ, 2.)
return b1 and b2 and b3
endfunction
function Trig_Headding_Action_Actions takes nothing returns nothing
local force peasants = GetPlayersAllies(Player(0))
local force peons = GetPlayersEnemies(Player(0))
if ( Trig_Headding_Action_IsBallHeadable() ) then
call ForForce( peasants, function Trig_Headding_Action_Func001Func001A )
call ForForce( peons, function Trig_Headding_Action_Func001Func002A )
endif
call DestroyForce( peasants )
call DestroyForce( peons )
endfunction
//===========================================================================
function InitTrig_Heading_Action_AI takes nothing returns nothing
set gg_trg_Heading_Action_AI = CreateTrigger( )
call TriggerAddAction( gg_trg_Heading_Action_AI, function Trig_Headding_Action_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Common_headding_action_Func001Func002C takes nothing returns boolean
if ( not ( GetUnitFlyHeight(udg_Ball) <= ( ( 20.00 + I2R(GetHeroStatBJ(bj_HEROSTAT_STR, udg_Hero[GetConvertedPlayerId(GetEnumPlayer())], true)) ) + udg_HeroHeight ) ) ) then
return false
endif
if ( not ( IsUnitInRange(udg_Ball, udg_Hero[GetConvertedPlayerId(GetEnumPlayer())], 100.00) == true ) ) then
return false
endif
return true
endfunction
function Trig_Common_headding_action_Func001Func006C takes nothing returns boolean
if ( ( GetRandomInt(1, 5) == 1 ) ) then
return true
endif
if ( ( RectContainsUnit(udg_PenaltyArea[udg_ThinkingTeamEnemyNumber], udg_Hero[GetConvertedPlayerId(GetEnumPlayer())]) == true ) ) then
return true
endif
return false
endfunction
function Trig_Common_headding_action_Conditions takes nothing returns boolean
local boolean b1 = GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_COMPUTER
local boolean b2 = GetAIDifficulty(GetEnumPlayer()) != AI_DIFFICULTY_NEWBIE
local boolean b3 = Trig_Common_headding_action_Func001Func006C()
return b1 and b2 and b3
endfunction
function Trig_Common_headding_action_Actions takes nothing returns nothing
local location loc_ball
local location loc_flag
local location heroloc
set udg_TempReal = ( ( ( -2.00 * udg_BallVZ ) + SquareRoot(( ( 4.00 * Pow(udg_BallVZ, 2.00) ) - ( ( 8.00 * udg_G ) * GetUnitFlyHeight(udg_Ball) ) )) ) / ( 2.00 * udg_G ) )
if ( Trig_Common_headding_action_Func001Func002C() ) then
call IssueTargetOrder( udg_Hero[GetConvertedPlayerId(GetEnumPlayer())], "move", udg_Ball )
// call IssueImmediateOrder( udg_Hero[GetConvertedPlayerId(GetEnumPlayer())], "windwalk" )
call PlayerJump(GetEnumPlayer())
endif
set loc_flag = GetUnitLoc(udg_Flag)
set heroloc = GetUnitLoc(udg_Hero[GetConvertedPlayerId(GetEnumPlayer())])
if ( ( ( DistanceBetweenPoints( heroloc, loc_flag) - 50.00 ) / GetUnitMoveSpeed(udg_Hero[GetConvertedPlayerId(GetEnumPlayer())]) ) <= ( udg_TempReal * 0.10 ) ) then
set loc_ball = GetUnitLoc(udg_Ball)
call IssuePointOrderLoc( udg_Hero[GetConvertedPlayerId(GetEnumPlayer())], "move", PolarProjectionBJ( loc_flag, ( DistanceBetweenPoints(loc_ball, loc_flag) / 10.00 ), AngleBetweenPoints(loc_flag, loc_ball)) )
call RemoveLocation( loc_ball )
endif
call RemoveLocation( loc_flag )
call RemoveLocation( heroloc )
set loc_ball = null
set loc_flag = null
set heroloc = null
endfunction
//===========================================================================
function InitTrig_Common_headding_action takes nothing returns nothing
set gg_trg_Common_headding_action = CreateTrigger( )
call TriggerAddCondition(gg_trg_Common_headding_action, Condition(function Trig_Common_headding_action_Conditions))
call TriggerAddAction( gg_trg_Common_headding_action, function Trig_Common_headding_action_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
bool Trig_Short_pass_on_request_Conditions() {
player p = GetOwningPlayer(GetSpellAbilityUnit())
bool b1 = IsUnitAlly(udg_BallOwner, p)
bool b2 = GetPlayerController(GetOwningPlayer(udg_BallOwner)) == MAP_CONTROL_COMPUTER
return b1 && b2
}
function Trig_Short_pass_on_request_Actions takes nothing returns nothing
set udg_PassTarget = GetSpellAbilityUnit()
call SetBallHeight( udg_BallDefaultHeight )
set udg_BallVZ = 0
set udg_IsBallInAir = false
set udg_BallDirection = AngleBetweenUnits(udg_Ball, udg_PassTarget)
set udg_BallInitialDirection = udg_BallDirection
set udg_TempReal = 52.2 // 57.2 + GetHeroStr(udg_BallOwner, true)
set udg_BallImmuneTimer = IMinBJ(7, R2I( 0.5*DistanceBetweenUnits(udg_PassTarget, udg_Ball)/udg_TempReal ) )
set LastActionMade = ACTION_SHORT_PASS
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
call TriggerExecute( gg_trg_Common_Actions_for_shoot )
endfunction
//===========================================================================
function InitTrig_Short_pass_on_request takes nothing returns nothing
set gg_trg_Short_pass_on_request = CreateTrigger( )
call TriggerAddConditionSimple( gg_trg_Short_pass_on_request, function Trig_Short_pass_on_request_Conditions )
call TriggerAddAction( gg_trg_Short_pass_on_request, function Trig_Short_pass_on_request_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Shoot_or_Sliding_Func001Func003Func010Func003001 takes nothing returns bool
int pid = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
return ( udg_TempDirection - udg_SlidingDirection[pid] ) < 30 // mb Abs?
endfunction
function Trig_Shoot_or_Sliding_Func001Func003Func010Func003002 takes nothing returns bool
int pid = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
return Abs( Abs( udg_TempDirection - udg_SlidingDirection[pid] ) - 360 ) < 30
endfunction
function Trig_Jump_to_avoid_slide_Conditions takes nothing returns bool
location loc_ball = GetUnitLoc(udg_Ball)
location loc_target = GetSpellTargetLoc()
player p = GetOwningPlayer(udg_BallOwner)
bool b1 = DistanceBetweenPoints(loc_ball, loc_target) < 256
bool b2 = GetBooleanOr( Trig_Shoot_or_Sliding_Func001Func003Func010Func003001(), Trig_Shoot_or_Sliding_Func001Func003Func010Func003002() )
bool b3 = GetPlayerController(p) == MAP_CONTROL_COMPUTER
bool b4 = GetAIDifficulty(p) == AI_DIFFICULTY_INSANE
return b1 and b2 and b3 and b4
endfunction
function Trig_Jump_to_avoid_slide_Actions takes nothing returns nothing
call UnitJump(udg_BallOwner)
endfunction
//===========================================================================
function InitTrig_Jump_to_avoid_slide takes nothing returns nothing
set gg_trg_Jump_to_avoid_slide = CreateTrigger( )
call TriggerAddConditionSimple( gg_trg_Jump_to_avoid_slide, function Trig_Jump_to_avoid_slide_Conditions )
call TriggerAddAction( gg_trg_Jump_to_avoid_slide, function Trig_Jump_to_avoid_slide_Actions )
endfunction
function Trig_Release_UnitGroups_Actions takes nothing returns nothing
call GroupClear( udg_TempUnitGroup2 )
call GroupClear( udg_TempUnitGroup1 )
endfunction
//===========================================================================
function InitTrig_Clear_UnitGroups takes nothing returns nothing
set gg_trg_Clear_UnitGroups = CreateTrigger( )
call TriggerAddAction( gg_trg_Clear_UnitGroups, function Trig_Release_UnitGroups_Actions )
endfunction
function Trig_Team_Actions_Actions takes nothing returns nothing
if ( udg_BallOwner == null ) then
call TriggerExecute( gg_trg_Team_Actions_No_BallOwner )
else
call TriggerExecute( gg_trg_Team_Actions_with_BallOwner )
endif
endfunction
//===========================================================================
function InitTrig_Team_Actions takes nothing returns nothing
set gg_trg_Team_Actions = CreateTrigger( )
call TriggerAddAction( gg_trg_Team_Actions, function Trig_Team_Actions_Actions )
endfunction
function Trig_Team_Actions_No_BallOwner_Actions takes nothing returns nothing
call ConditionalTriggerExecute( gg_trg_Attack_a_friend_to_Ball )
if ( udg_ThrowinMode == udg_ThinkingTeamEnemyNumber ) then
call ConditionalTriggerExecute( gg_trg_Pick_a_friend_for_Defence )
call TriggerExecute( gg_trg_Mark_Enemies )
elseif ( RectContainsUnit(udg_PlayArea[udg_ThinkingTeamNumber], udg_Ball) ) then
call TriggerExecute( gg_trg_Wander_Around_the_ball_for_Defend )
else
call ConditionalTriggerExecute( gg_trg_Pick_a_friend_for_Defence )
call TriggerExecute( gg_trg_Wander_Around_the_ball_for_Attack )
endif
endfunction
//===========================================================================
function InitTrig_Team_Actions_No_BallOwner takes nothing returns nothing
set gg_trg_Team_Actions_No_BallOwner = CreateTrigger( )
call TriggerAddAction( gg_trg_Team_Actions_No_BallOwner, function Trig_Team_Actions_No_BallOwner_Actions )
endfunction
function Trig_Team_Actions_with_BallOwner_Actions takes nothing returns nothing
if ( IsUnitAlly(udg_BallOwner, Player(0)) ) then
if ( udg_ThinkingTeamNumber == 1 ) then
call TriggerExecute( gg_trg_Friend_has_the_ball )
else
call TriggerExecute( gg_trg_Enemy_has_the_ball )
endif
else
if ( udg_ThinkingTeamNumber == 2 ) then
call TriggerExecute( gg_trg_Friend_has_the_ball )
else
call TriggerExecute( gg_trg_Enemy_has_the_ball )
endif
endif
endfunction
//===========================================================================
function InitTrig_Team_Actions_with_BallOwner takes nothing returns nothing
set gg_trg_Team_Actions_with_BallOwner = CreateTrigger( )
call TriggerAddAction( gg_trg_Team_Actions_with_BallOwner, function Trig_Team_Actions_with_BallOwner_Actions )
endfunction
function Trig_Attack_a_friend_to_Ball_Conditions takes nothing returns boolean
return ( udg_WhichKeeperHasBall == 0 ) and ( udg_ThrowInWaitTimer <= 0 )
endfunction
function Trig_Attack_a_friend_to_Ball_Actions takes nothing returns nothing
call TriggerExecute( gg_trg_Set_AttackPoint )
if ( CompControlsTempUnit() ) then
call TriggerExecute( gg_trg_Attack_Animations )
endif
endfunction
//===========================================================================
function InitTrig_Attack_a_friend_to_Ball takes nothing returns nothing
set gg_trg_Attack_a_friend_to_Ball = CreateTrigger( )
call TriggerAddCondition( gg_trg_Attack_a_friend_to_Ball, Condition( function Trig_Attack_a_friend_to_Ball_Conditions ) )
call TriggerAddAction( gg_trg_Attack_a_friend_to_Ball, function Trig_Attack_a_friend_to_Ball_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Pick_a_friend_for_Defence_Actions takes nothing returns nothing
call RemoveLocation( udg_TempPoint )
set udg_TempPoint = GetRectCenter(udg_PlayArea[udg_ThinkingTeamNumber])
call TriggerExecute( gg_trg_Set_nearest_friendly_unit )
if ( CompControlsTempUnit() ) then
call GroupRemoveUnitSimple( udg_TempUnit, udg_TempUnitGroup1 )
call IssuePointOrderLoc( udg_TempUnit, "move", udg_TempPoint )
else
call GroupRemoveUnitSimple( udg_TempUnit, udg_TempUnitGroup1 )
if ( not ( IsUnitGroupEmptyBJ(udg_TempUnitGroup1) ) ) then
call ConditionalTriggerExecute( gg_trg_Pick_a_friend_for_Defence )
endif
endif
endfunction
//===========================================================================
function InitTrig_Pick_a_friend_for_Defence takes nothing returns nothing
set gg_trg_Pick_a_friend_for_Defence = CreateTrigger( )
call TriggerAddAction( gg_trg_Pick_a_friend_for_Defence, function Trig_Pick_a_friend_for_Defence_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Mark_Enemies_Func001A takes nothing returns nothing
local location loc_ball
local location loc_unit
local location loc_new
local real dist
local real angle
call RemoveLocation( udg_TempPoint )
set udg_TempPoint = GetUnitLoc(GetEnumUnit())
call TriggerExecute( gg_trg_Set_nearest_friendly_unit )
if ( CompControlsTempUnit() ) then
set loc_unit = GetUnitLoc(GetEnumUnit())
set loc_ball = GetUnitLoc(udg_Ball)
set dist = DistanceBetweenPoints(loc_unit, loc_ball)
set angle = AngleBetweenPoints(loc_unit, loc_ball)
set loc_new = PolarProjectionBJ(loc_unit, RMinBJ(100.00, dist), angle)
call IssuePointOrderLoc( udg_TempUnit, "move", loc_new )
call GroupRemoveUnitSimple( udg_TempUnit, udg_TempUnitGroup1 )
call RemoveLocation( loc_ball)
call RemoveLocation( loc_unit)
call RemoveLocation( loc_new)
endif
set loc_ball = null
set loc_unit = null
set loc_new = null
endfunction
function Trig_Mark_Enemies_Actions takes nothing returns nothing
call ForGroupBJ( udg_TempUnitGroup2, function Trig_Mark_Enemies_Func001A )
endfunction
//===========================================================================
function InitTrig_Mark_Enemies takes nothing returns nothing
set gg_trg_Mark_Enemies = CreateTrigger( )
call TriggerAddAction( gg_trg_Mark_Enemies, function Trig_Mark_Enemies_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Wander_Around_the_ball_for_Defend_Func001A takes nothing returns nothing
local unit u = GetEnumUnit()
local location loc_new
if ( GetUnitCurrentOrder(u) != String2OrderIdBJ("move")) and (CompControlsEnumUnit()) then
set loc_new = GetRandomLocInRect(udg_PlayArea[udg_ThinkingTeamNumber])
call IssuePointOrderLoc( u, "move", loc_new )
call RemoveLocation( loc_new )
endif
set u = null
set loc_new = null
endfunction
function Trig_Wander_Around_the_ball_for_Defend_Actions takes nothing returns nothing
call ForGroupBJ( udg_TempUnitGroup1, function Trig_Wander_Around_the_ball_for_Defend_Func001A )
endfunction
//===========================================================================
function InitTrig_Wander_Around_the_ball_for_Defend takes nothing returns nothing
set gg_trg_Wander_Around_the_ball_for_Defend = CreateTrigger( )
call TriggerAddAction( gg_trg_Wander_Around_the_ball_for_Defend, function Trig_Wander_Around_the_ball_for_Defend_Actions )
endfunction
function Trig_Wander_Around_the_ball_for_Attack_Func001Func001C takes nothing returns boolean
return ( GetUnitCurrentOrder(GetEnumUnit()) != String2OrderIdBJ("move") ) and ( CompControlsEnumUnit() )
endfunction
function Trig_Wander_Around_the_ball_for_Attack_Func001A takes nothing returns nothing
if ( Trig_Wander_Around_the_ball_for_Attack_Func001Func001C() ) then
call IssuePointOrderLoc( GetEnumUnit(), "move", GetRandomLocInRect(udg_PlayArea[udg_ThinkingTeamEnemyNumber]) )
endif
endfunction
function Trig_Wander_Around_the_ball_for_Attack_Actions takes nothing returns nothing
call ForGroupBJ( udg_TempUnitGroup1, function Trig_Wander_Around_the_ball_for_Attack_Func001A )
endfunction
//===========================================================================
function InitTrig_Wander_Around_the_ball_for_Attack takes nothing returns nothing
set gg_trg_Wander_Around_the_ball_for_Attack = CreateTrigger( )
call TriggerAddAction( gg_trg_Wander_Around_the_ball_for_Attack, function Trig_Wander_Around_the_ball_for_Attack_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Set_nearest_friendly_unit_Func002A takes nothing returns nothing
local location loc_TempUnit = GetUnitLoc(udg_TempUnit)
local location loc_EnumUnit = GetUnitLoc(GetEnumUnit())
local real dist1 = DistanceBetweenPoints(loc_TempUnit, udg_TempPoint)
local real dist2 = DistanceBetweenPoints(loc_EnumUnit, udg_TempPoint)
local boolean b1 = ( dist1 >= dist2 )
local boolean b2 = ( udg_TempUnit == null )
call RemoveLocation(loc_TempUnit)
call RemoveLocation(loc_EnumUnit)
if ( b1 or b2 ) then
set udg_TempUnit = GetEnumUnit()
endif
set loc_TempUnit = null
set loc_EnumUnit = null
endfunction
function Trig_Set_nearest_friendly_unit_Actions takes nothing returns nothing
set udg_TempUnit = null
//if IsUnitGroupEmptyBJ(udg_TempUnitGroup1) and udg_DisplayScoreboardAsMB == false then
// call BJDebugMsg("empty group !!!")
//endif
call ForGroupBJ( udg_TempUnitGroup1, function Trig_Set_nearest_friendly_unit_Func002A )
endfunction
//===========================================================================
function InitTrig_Set_nearest_friendly_unit takes nothing returns nothing
set gg_trg_Set_nearest_friendly_unit = CreateTrigger( )
call TriggerAddAction( gg_trg_Set_nearest_friendly_unit, function Trig_Set_nearest_friendly_unit_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Friend_has_the_ball_Func5112 takes nothing returns boolean
return IsUnitInGroup(GetFilterUnit(), udg_TempUnitGroup1)
endfunction
function Trig_Friend_has_the_ball_Func5312 takes nothing returns boolean
return IsUnitInGroup(GetFilterUnit(), udg_TempUnitGroup2)
endfunction
function Trig_Friend_has_the_ball_Func005Func001Func003Func003C takes nothing returns boolean
local conditionfunc cond1 = Condition(function Trig_Friend_has_the_ball_Func5112)
local group g1 = GetUnitsInRectMatching(udg_PenaltyArea[udg_ThinkingTeamEnemyNumber], cond1)
local conditionfunc cond2 = Condition(function Trig_Friend_has_the_ball_Func5312)
local group g2 = GetUnitsInRectMatching(udg_PenaltyArea[udg_ThinkingTeamEnemyNumber], cond2)
local boolean b1 = GetRandomInt(0, udg_TempInt) == 0
local boolean b2 = RectContainsUnit(udg_PenaltyArea[udg_ThinkingTeamEnemyNumber], udg_BallOwner)
local boolean b3 = CountUnitsInGroup(g1) >= CountUnitsInGroup(g2)
call DestroyGroup(g1)
call DestroyGroup(g2)
call DestroyCondition(cond1)
call DestroyCondition(cond2)
set g1 = null
set g2 = null
set cond1 = null
set cond2 = null
return (b1 and b2 and b3)
endfunction
function Trig_Friend_has_the_ball_IsFilterUnitEnemy takes nothing returns boolean
return IsUnitEnemy(udg_BallOwner, GetOwningPlayer(GetFilterUnit()))
endfunction
function Trig_Friend_has_the_ball_IsEnemyApproaching takes nothing returns boolean
local conditionfunc cond = Condition(function Trig_Friend_has_the_ball_IsFilterUnitEnemy)
local location loc_ball = GetUnitLoc(udg_Ball)
local group g = GetUnitsInRangeOfLocMatching(256.00, loc_ball, cond)
local boolean b1 = CountUnitsInGroup(g) > 0
local boolean b2 = GetRandomInt(0, 10) <= 3
call DestroyCondition(cond)
call DestroyGroup(g)
call RemoveLocation(loc_ball)
set cond = null
set loc_ball = null
set g = null
return (b1 and b2)
endfunction
function Trig_Friend_has_the_ball_Actions takes nothing returns nothing
local location loc_new
local location loc_BallOwner
local location loc_TempUnit
local conditionfunc cond
local group g
call GroupRemoveUnitSimple( udg_BallOwner, udg_TempUnitGroup1 )
call ConditionalTriggerExecute( gg_trg_Pick_a_friend_for_Defence )
call ConditionalTriggerExecute( gg_trg_Pick_a_friend_for_headding )
call TriggerExecute( gg_trg_Wander_Around_the_ball_for_Attack )
if ( CompControlsBallOwner() and udg_ThrowinMode == 0 ) then
call TriggerExecute( gg_trg_Shoot )
if ( Trig_Friend_has_the_ball_IsEnemyApproaching() ) then
call TriggerExecute( gg_trg_Enemy_is_approaching_to_ballowner )
else
if ( BallOwnerAI_Easy() ) then
set udg_TempInt = 15
elseif ( BallOwnerAI_Normal() ) then
set udg_TempInt = 7
else
set udg_TempInt = 3
endif
if ( Trig_Friend_has_the_ball_Func005Func001Func003Func003C() ) then
set cond = Condition(function Trig_Friend_has_the_ball_Func5112)
set g = GetUnitsInRectMatching(udg_PenaltyArea[udg_ThinkingTeamEnemyNumber], cond)
set loc_new = GetUnitLoc(GroupPickRandomUnit(g))
//call IssuePointOrderLoc( udg_BallOwner, "darkportal", loc_new )
call UnitLongPass(udg_BallOwner, loc_new)
call DestroyCondition(cond)
call DestroyGroup(g)
call RemoveLocation(loc_new)
else
call TriggerExecute( gg_trg_Move_To )
endif
endif
// udg_ThrowinMode != 0
elseif ( CompControlsBallOwner() and udg_ThrowInWaitTimer <= 0 ) then
call RemoveLocation( udg_TempPoint)
set udg_TempPoint = GetUnitLoc(udg_BallOwner)
//set udg_DisplayScoreboardAsMB = false
call TriggerExecute( gg_trg_Set_nearest_friendly_unit )
//set udg_DisplayScoreboardAsMB = true
//call BJDebugMsg(R2S(DistanceBetweenPoints(loc_BallOwner, loc_TempUnit)))
// AI Throwin BUG FIX
if ( udg_TempUnit == null ) then
if ( udg_ThinkingTeamNumber == 1 ) then
if ( IsUnitGroupEmptyBJ(udg_Team1Heroes) ) then
set udg_TempUnit = udg_Keeper[1]
else
set udg_TempUnit = FirstOfGroup(udg_Team1Heroes)
endif
else
if ( IsUnitGroupEmptyBJ(udg_Team2Heroes) ) then
set udg_TempUnit = udg_Keeper[2]
else
set udg_TempUnit = FirstOfGroup(udg_Team2Heroes)
endif
endif
endif
//DONE
set loc_TempUnit = GetUnitLoc(udg_TempUnit)
set loc_BallOwner = GetUnitLoc(udg_BallOwner)
if ( DistanceBetweenPoints(loc_BallOwner, loc_TempUnit) <= 1024.00 ) then
//call IssueImmediateOrder( udg_BallOwner, "divineshield" )
call UnitShortPass(udg_BallOwner)
else
call UnitLongPass(udg_BallOwner, loc_TempUnit)
//call IssuePointOrderLoc( udg_BallOwner, "darkportal", loc_TempUnit )
//if ( udg_TempUnit == null ) then
// set loc_TempUnit = GetRandomLocInRect(GetPlayableMapRect())
//endif
endif
call RemoveLocation(loc_BallOwner)
call RemoveLocation(loc_TempUnit)
endif
set loc_BallOwner = null
set loc_TempUnit = null
set g = null
set cond = null
set loc_new = null
endfunction
//===========================================================================
function InitTrig_Friend_has_the_ball takes nothing returns nothing
set gg_trg_Friend_has_the_ball = CreateTrigger( )
call TriggerAddAction( gg_trg_Friend_has_the_ball, function Trig_Friend_has_the_ball_Actions )
endfunction
function Trig_Enemy_has_the_ball_Actions takes nothing returns nothing
call ConditionalTriggerExecute( gg_trg_Attack_a_friend_to_Ball )
call TriggerExecute( gg_trg_Mark_Enemies )
endfunction
//===========================================================================
function InitTrig_Enemy_has_the_ball takes nothing returns nothing
set gg_trg_Enemy_has_the_ball = CreateTrigger( )
call TriggerAddAction( gg_trg_Enemy_has_the_ball, function Trig_Enemy_has_the_ball_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Set_AttackPoint_Actions takes nothing returns nothing
if ( udg_IsBallInAir ) then
set udg_TempPoint = GetUnitLoc(udg_Flag)
call TriggerExecute( gg_trg_Set_nearest_friendly_unit )
else
set udg_TempPoint = GetUnitLoc(udg_Ball)
call TriggerExecute( gg_trg_Set_nearest_friendly_unit )
endif
endfunction
//===========================================================================
function InitTrig_Set_AttackPoint takes nothing returns nothing
set gg_trg_Set_AttackPoint = CreateTrigger( )
call TriggerAddAction( gg_trg_Set_AttackPoint, function Trig_Set_AttackPoint_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Attack_Animations_Func002Func002Func002C takes nothing returns boolean
if ( not ( GetUnitFlyHeight(udg_Ball) > ( GetUnitFlyHeight(udg_TempUnit) + udg_HeroHeight ) ) ) then
return false
endif
if ( not ( udg_IsBallInAir == true ) ) then
return false
endif
return true
endfunction
function Trig_Attack_Animations_Func002Func002C takes nothing returns boolean
if ( not ( udg_BallOwner != null ) ) then
return false
endif
if ( not ( IsUnitEnemy(udg_BallOwner, GetOwningPlayer(udg_TempUnit)) == true ) ) then
return false
endif
if ( not ( DistanceBetweenPoints(GetUnitLoc(udg_TempUnit), GetUnitLoc(udg_Ball)) <= 200.00 ) ) then
return false
endif
if ( not ( GetRandomInt(0, 10) < 3 ) ) then
return false
endif
return true
endfunction
function Trig_Attack_Animations_Actions takes nothing returns nothing
call GroupRemoveUnitSimple( udg_TempUnit, udg_TempUnitGroup1 )
if ( GetAIDifficulty(GetOwningPlayer(udg_TempUnit)) != AI_DIFFICULTY_NEWBIE ) then
if ( Trig_Attack_Animations_Func002Func002C() ) then
//call IssuePointOrderLoc( udg_TempUnit, "ward", GetUnitLoc(udg_Ball) )
call UnitSlide(udg_TempUnit, GetUnitLoc(udg_Ball))
elseif ( Trig_Attack_Animations_Func002Func002Func002C() ) then
call IssuePointOrderLoc( udg_TempUnit, "move", PolarProjectionBJ(GetUnitLoc(udg_Flag), 90.00, AngleBetweenPoints(GetUnitLoc(udg_Flag), GetUnitLoc(udg_Ball))) )
else
call IssuePointOrderLoc( udg_TempUnit, "move", GetUnitLoc(udg_Ball) )
endif
// GetAIDifficulty(GetOwningPlayer(udg_TempUnit)) == AI_DIFFICULTY_NEWBIE
elseif ( GetRandomInt(0, 2) == 0 ) then
call IssuePointOrderLoc( udg_TempUnit, "move", GetUnitLoc(udg_Ball) )
endif
endfunction
//===========================================================================
function InitTrig_Attack_Animations takes nothing returns nothing
set gg_trg_Attack_Animations = CreateTrigger( )
call TriggerAddAction( gg_trg_Attack_Animations, function Trig_Attack_Animations_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Pick_a_friend_for_headding_Func003Func002C takes nothing returns boolean
if ( not ( IsUnitGroupEmptyBJ(udg_TempUnitGroup1) == false ) ) then
return false
endif
return true
endfunction
function Trig_Pick_a_friend_for_headding_Func003C takes nothing returns boolean
if ( not ( GetPlayerController(GetOwningPlayer(udg_TempUnit)) == MAP_CONTROL_COMPUTER ) ) then
return false
endif
return true
endfunction
function Trig_Pick_a_friend_for_headding_Actions takes nothing returns nothing
set udg_TempPoint = GetRandomLocInRect(udg_PenaltyArea[udg_ThinkingTeamEnemyNumber])
call TriggerExecute( gg_trg_Set_nearest_friendly_unit )
if ( Trig_Pick_a_friend_for_headding_Func003C() ) then
call GroupRemoveUnitSimple( udg_TempUnit, udg_TempUnitGroup1 )
call IssuePointOrderLoc( udg_TempUnit, "move", udg_TempPoint )
else
call GroupRemoveUnitSimple( udg_TempUnit, udg_TempUnitGroup1 )
if ( Trig_Pick_a_friend_for_headding_Func003Func002C() ) then
call ConditionalTriggerExecute( gg_trg_Pick_a_friend_for_headding )
else
endif
endif
endfunction
//===========================================================================
function InitTrig_Pick_a_friend_for_headding takes nothing returns nothing
set gg_trg_Pick_a_friend_for_headding = CreateTrigger( )
call TriggerAddAction( gg_trg_Pick_a_friend_for_headding, function Trig_Pick_a_friend_for_headding_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Shoot_Func001C takes nothing returns boolean
int team = udg_ThinkingTeamEnemyNumber
real keeper_x = GetUnitX(udg_Keeper[team])
real ball_x = GetBallX()
int hero_str = GetHeroStr(udg_BallOwner, true)
rect pen_zone = udg_PenaltyArea[team]
bool b1 = Abs( keeper_x - ball_x ) <= GetRandomReal(500, 800 + hero_str * 30)
bool b2 = RectContainsUnit(pen_zone, BallOwner)
set pen_zone = null
return b1 or b2
endfunction
function Trig_Shoot_Actions takes nothing returns nothing
if ( Trig_Shoot_Func001C() ) then
if ( BallOwnerAI_Easy() ) then
call TriggerExecute( gg_trg_Shoot_Easy )
elseif ( BallOwnerAI_Normal() ) then
call TriggerExecute( gg_trg_Shoot_Normal )
else
call TriggerExecute( gg_trg_Shoot_Normal )
//call TriggerExecute( gg_trg_Shoot_Insane )
endif
//call IssuePointOrderLoc( udg_BallOwner, "ward", udg_TempPoint )
call UnitKick(udg_BallOwner, udg_TempPoint)
endif
endfunction
//===========================================================================
function InitTrig_Shoot takes nothing returns nothing
set gg_trg_Shoot = CreateTrigger( )
call TriggerAddAction( gg_trg_Shoot, function Trig_Shoot_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Shoot_Easy_Actions takes nothing returns nothing
int team = udg_ThinkingTeamEnemyNumber
real penbox_x = GetRectCenterX(udg_GoalArea[team])
real keeper_y = GetUnitY(udg_Keeper[team])
set udg_TempPoint = Location(penbox_x, keeper_y)
endfunction
//===========================================================================
function InitTrig_Shoot_Easy takes nothing returns nothing
set gg_trg_Shoot_Easy = CreateTrigger( )
call TriggerAddAction( gg_trg_Shoot_Easy, function Trig_Shoot_Easy_Actions )
endfunction
function Trig_Shoot_Normal_Actions takes nothing returns nothing
set udg_TempPoint = GetRandomLocInRect(udg_GoalArea[udg_ThinkingTeamEnemyNumber])
endfunction
//===========================================================================
function InitTrig_Shoot_Normal takes nothing returns nothing
set gg_trg_Shoot_Normal = CreateTrigger( )
call TriggerAddAction( gg_trg_Shoot_Normal, function Trig_Shoot_Normal_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Shoot_Insane_Actions takes nothing returns nothing
int team = udg_ThinkingTeamEnemyNumber
real keeper_y = GetUnitY(udg_Keeper[team])
real center_y = GetRectCenterY(gg_rct_Center)
rect pen_zone = udg_GoalArea[team]
real pen_zone_x = GetRectCenterX(pen_zone)
if ( keeper_y >= center_y ) then
real pen_zone_min_y = GetRectMinY(pen_zone)
set udg_TempPoint = Location(pen_zone_x, pen_zone_min_y)
else
real pen_zone_max_y = GetRectMaxY(pen_zone)
set udg_TempPoint = Location(pen_zone_x, pen_zone_max_y)
endif
set pen_zone = null
endfunction
//===========================================================================
function InitTrig_Shoot_Insane takes nothing returns nothing
set gg_trg_Shoot_Insane = CreateTrigger( )
call TriggerAddAction( gg_trg_Shoot_Insane, function Trig_Shoot_Insane_Actions )
endfunction
function Trig_Enemy_is_approaching_to_ballowner_Actions takes nothing returns nothing
if ( BallOwnerAI_Easy() ) then
call ConditionalTriggerExecute( gg_trg_Enemy_Approach_Easy )
elseif ( BallOwnerAI_Normal() ) then
call ConditionalTriggerExecute( gg_trg_Enemy_Approach_Normal )
else
call ConditionalTriggerExecute( gg_trg_Enemy_Approach_Insane )
endif
endfunction
//===========================================================================
function InitTrig_Enemy_is_approaching_to_ballowner takes nothing returns nothing
set gg_trg_Enemy_is_approaching_to_ballowner = CreateTrigger( )
call TriggerAddAction( gg_trg_Enemy_is_approaching_to_ballowner, function Trig_Enemy_is_approaching_to_ballowner_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Enemy_Approach_Easy_Conditions takes nothing returns boolean
int pid = GetConvertedPlayerId(GetOwningPlayer(udg_BallOwner))
bool b1 = GetChance(1./15.)
bool b2 = udg_HeroInAir[pid]
return b1 and b2
endfunction
function Trig_Enemy_Approach_Easy_Actions takes nothing returns nothing
//call IssueImmediateOrder( udg_BallOwner, "divineshield" )
call UnitShortPass(udg_BallOwner)
endfunction
//===========================================================================
function InitTrig_Enemy_Approach_Easy takes nothing returns nothing
set gg_trg_Enemy_Approach_Easy = CreateTrigger( )
call TriggerAddCondition( gg_trg_Enemy_Approach_Easy, Condition( function Trig_Enemy_Approach_Easy_Conditions ) )
call TriggerAddAction( gg_trg_Enemy_Approach_Easy, function Trig_Enemy_Approach_Easy_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Enemy_Approach_Normal_Conditions takes nothing returns boolean
return GetChance(0.20)
endfunction
function Trig_Enemy_Approach_Normal_Func003Func001C takes nothing returns boolean
if ( not ( DistanceBetweenPoints(GetUnitLoc(udg_BallOwner), GetUnitLoc(udg_TempUnit)) <= 1024.00 ) ) then
return false
endif
if ( not ( udg_HeroInAir[GetConvertedPlayerId(GetOwningPlayer(udg_BallOwner))] == false ) ) then
return false
endif
return true
endfunction
function Trig_Enemy_Approach_Normal_Func003C takes nothing returns boolean
int team = udg_ThinkingTeamNumber
return Abs(( DistanceBetweenPoints(GetRectCenter(udg_AI_AttackPoint_M[team]), GetUnitLoc(udg_BallOwner)) - DistanceBetweenPoints(GetRectCenter(udg_AI_AttackPoint_M[team]), GetUnitLoc(udg_TempUnit)) )) < 1000
endfunction
function Trig_Enemy_Approach_Normal_Actions takes nothing returns nothing
set udg_TempPoint = GetUnitLoc(udg_BallOwner)
call TriggerExecute( gg_trg_Set_nearest_friendly_unit )
if ( Trig_Enemy_Approach_Normal_Func003C() ) then
if ( Trig_Enemy_Approach_Normal_Func003Func001C() ) then
//call IssueImmediateOrder( udg_BallOwner, "divineshield" )
call UnitShortPass(udg_BallOwner)
else
//call IssuePointOrderLoc( udg_BallOwner, "darkportal", GetUnitLoc(udg_TempUnit) )
call UnitLongPass(udg_BallOwner, GetUnitLoc(udg_TempUnit))
endif
endif
endfunction
//===========================================================================
function InitTrig_Enemy_Approach_Normal takes nothing returns nothing
set gg_trg_Enemy_Approach_Normal = CreateTrigger( )
call TriggerAddCondition( gg_trg_Enemy_Approach_Normal, Condition( function Trig_Enemy_Approach_Normal_Conditions ) )
call TriggerAddAction( gg_trg_Enemy_Approach_Normal, function Trig_Enemy_Approach_Normal_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Enemy_Approach_Insane_Func001Func001C takes nothing returns boolean
if ( not ( GetLocationY(GetUnitLoc(udg_Keeper[udg_ThinkingTeamEnemyNumber])) >= GetLocationY(GetRectCenter(gg_rct_Center)) ) ) then
return false
endif
return true
endfunction
function Trig_Enemy_Approach_Insane_Func001Func003Func001Func001Func001Func002C takes nothing returns boolean
if ( not ( GetLocationY(GetUnitLoc(udg_Keeper[udg_ThinkingTeamEnemyNumber])) >= GetLocationY(GetRectCenter(gg_rct_Center)) ) ) then
return false
endif
return true
endfunction
function Trig_Enemy_Approach_Insane_Func001Func003Func001Func001Func001C takes nothing returns boolean
if ( not ( GetRandomInt(0, 2) == 0 ) ) then
return false
endif
return true
endfunction
function Trig_Enemy_Approach_Insane_Func001Func003Func001Func001Func006001001003 takes nothing returns boolean
return ( IsUnitInGroup(GetFilterUnit(), udg_TempUnitGroup2) == true )
endfunction
function Trig_Enemy_Approach_Insane_Func001Func003Func001Func001C takes nothing returns boolean
if ( not ( GetEnumUnit() != udg_BallOwner ) ) then
return false
endif
if ( not ( DistanceBetweenPoints(GetUnitLoc(udg_BallOwner), GetUnitLoc(GetEnumUnit())) >= 1000.00 ) ) then
return false
endif
if ( not ( DistanceBetweenPoints(GetUnitLoc(GetEnumUnit()), GetUnitLoc(udg_Ball)) <= ( ( ( 4.50 * I2R(GetHeroStatBJ(bj_HEROSTAT_STR, udg_BallOwner, true)) ) + ( ( 201.60 * I2R(GetHeroStatBJ(bj_HEROSTAT_STR, udg_BallOwner, true)) ) + 2232.00 ) ) / udg_G ) ) ) then
return false
endif
if ( not ( IsUnitGroupEmptyBJ(GetUnitsInRangeOfLocMatching(256.00, GetUnitLoc(GetEnumUnit()), Condition(function Trig_Enemy_Approach_Insane_Func001Func003Func001Func001Func006001001003))) == true ) ) then
return false
endif
return true
endfunction
function Trig_Enemy_Approach_Insane_Func001Func003Func001A takes nothing returns nothing
if ( Trig_Enemy_Approach_Insane_Func001Func003Func001Func001C() ) then
//call IssuePointOrderLoc( udg_BallOwner, "darkportal", GetUnitLoc(GetEnumUnit()) )
call UnitLongPass(udg_BallOwner, GetUnitLoc(GetEnumUnit()))
else
if ( Trig_Enemy_Approach_Insane_Func001Func003Func001Func001Func001C() ) then
if ( Trig_Enemy_Approach_Insane_Func001Func003Func001Func001Func001Func002C() ) then
set udg_TempPoint = Location(GetLocationX(GetRectCenter(udg_GoalArea[udg_ThinkingTeamEnemyNumber])), GetRectMinY(udg_GoalArea[udg_ThinkingTeamEnemyNumber]))
else
set udg_TempPoint = Location(GetLocationX(GetRectCenter(udg_GoalArea[udg_ThinkingTeamEnemyNumber])), GetRectMaxY(udg_GoalArea[udg_ThinkingTeamEnemyNumber]))
endif
//call IssuePointOrderLoc( udg_BallOwner, "darkportal", udg_TempPoint )
call UnitLongPass(udg_BallOwner, udg_TempPoint)
else
endif
endif
endfunction
function Trig_Enemy_Approach_Insane_Func001Func003C takes nothing returns boolean
if ( not ( udg_PassTarget != null ) ) then
return false
endif
if ( not ( DistanceBetweenPoints(GetUnitLoc(udg_BallOwner), GetUnitLoc(udg_Keeper[udg_ThinkingTeamEnemyNumber])) >= DistanceBetweenPoints(GetUnitLoc(udg_PassTarget), GetUnitLoc(udg_Keeper[udg_ThinkingTeamEnemyNumber])) ) ) then
return false
endif
if ( not ( udg_HeroInAir[GetConvertedPlayerId(GetOwningPlayer(udg_BallOwner))] == false ) ) then
return false
endif
return true
endfunction
function Trig_Enemy_Approach_Insane_Func001C takes nothing returns boolean
if ( not ( RectContainsUnit(udg_PenaltyArea[udg_ThinkingTeamEnemyNumber], udg_BallOwner) == true ) ) then
return false
endif
return true
endfunction
function Trig_Enemy_Approach_Insane_Actions takes nothing returns nothing
if ( Trig_Enemy_Approach_Insane_Func001C() ) then
if ( Trig_Enemy_Approach_Insane_Func001Func001C() ) then
set udg_TempPoint = Location(GetLocationX(GetRectCenter(udg_GoalArea[udg_ThinkingTeamEnemyNumber])), GetRectMinY(udg_GoalArea[udg_ThinkingTeamEnemyNumber]))
else
set udg_TempPoint = Location(GetLocationX(GetRectCenter(udg_GoalArea[udg_ThinkingTeamEnemyNumber])), GetRectMaxY(udg_GoalArea[udg_ThinkingTeamEnemyNumber]))
endif
else
call TriggerExecute( gg_trg_Z_Get_Pass_Target )
if ( Trig_Enemy_Approach_Insane_Func001Func003C() ) then
//call IssueImmediateOrder( udg_BallOwner, "divineshield" )
call UnitShortPass(udg_BallOwner)
else
call ForGroupBJ( udg_TempUnitGroup1, function Trig_Enemy_Approach_Insane_Func001Func003Func001A )
endif
endif
endfunction
//===========================================================================
function InitTrig_Enemy_Approach_Insane takes nothing returns nothing
set gg_trg_Enemy_Approach_Insane = CreateTrigger( )
call TriggerAddAction( gg_trg_Enemy_Approach_Insane, function Trig_Enemy_Approach_Insane_Actions )
endfunction
function Trig_Move_To_Actions takes nothing returns nothing
if ( BallOwnerAI_Easy() ) then
call TriggerExecute( gg_trg_MoveTo_Easy )
elseif ( BallOwnerAI_Normal() ) then
call TriggerExecute( gg_trg_MoveTo_Normal )
else
call TriggerExecute( gg_trg_MoveTo_Insane )
endif
endfunction
//===========================================================================
function InitTrig_Move_To takes nothing returns nothing
set gg_trg_Move_To = CreateTrigger( )
call TriggerAddAction( gg_trg_Move_To, function Trig_Move_To_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_MoveTo_Easy_Actions takes nothing returns nothing
if ( GetChance(1./3.) ) then
call UnitStop( udg_BallOwner)
return
endif
location loc_move = GetRectCenter(udg_AI_AttackPoint_M[udg_ThinkingTeamNumber])
call UnitMove(udg_BallOwner, loc_move)
call CleanLoc(loc_move)
endfunction
//===========================================================================
function InitTrig_MoveTo_Easy takes nothing returns nothing
set gg_trg_MoveTo_Easy = CreateTrigger( )
call TriggerAddAction( gg_trg_MoveTo_Easy, function Trig_MoveTo_Easy_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_MoveTo_Normal_Actions takes nothing returns nothing
if ( GetChance(1./3.) ) then
call IssuePointOrderLoc( udg_BallOwner, "move", GetRectCenter(udg_AI_AttackPoint_M[udg_ThinkingTeamNumber]) )
elseif ( GetChance(1./2.) ) then
call IssuePointOrderLoc( udg_BallOwner, "move", GetRectCenter(udg_AI_AttackPoint_D[udg_ThinkingTeamNumber]) )
else
call IssuePointOrderLoc( udg_BallOwner, "move", GetRectCenter(udg_AI_AttackPoint_U[udg_ThinkingTeamNumber]) )
endif
endfunction
//===========================================================================
function InitTrig_MoveTo_Normal takes nothing returns nothing
set gg_trg_MoveTo_Normal = CreateTrigger( )
call TriggerAddAction( gg_trg_MoveTo_Normal, function Trig_MoveTo_Normal_Actions )
endfunction
function Trig_MoveTo_Insane_Func006Func001C takes nothing returns boolean
if ( not ( udg_TempRealArray[1] >= udg_TempRealArray[0] ) ) then
return false
endif
if ( not ( udg_TempRealArray[1] >= udg_TempRealArray[2] ) ) then
return false
endif
return true
endfunction
function Trig_MoveTo_Insane_Func006C takes nothing returns boolean
if ( not ( udg_TempRealArray[0] >= udg_TempRealArray[1] ) ) then
return false
endif
if ( not ( udg_TempRealArray[0] >= udg_TempRealArray[2] ) ) then
return false
endif
return true
endfunction
function Trig_MoveTo_Insane_Actions takes nothing returns nothing
set udg_TempPoint = GetUnitLoc(udg_BallOwner)
call TriggerExecute( gg_trg_Set_nearest_enemy_unit )
set udg_TempRealArray[0] = DistanceBetweenPoints(GetUnitLoc(udg_TempUnit), GetRectCenter(udg_AI_AttackPoint_U[udg_ThinkingTeamNumber]))
set udg_TempRealArray[1] = DistanceBetweenPoints(GetUnitLoc(udg_TempUnit), GetRectCenter(udg_AI_AttackPoint_M[udg_ThinkingTeamNumber]))
set udg_TempRealArray[2] = DistanceBetweenPoints(GetUnitLoc(udg_TempUnit), GetRectCenter(udg_AI_AttackPoint_D[udg_ThinkingTeamNumber]))
if ( Trig_MoveTo_Insane_Func006C() ) then
call IssuePointOrderLoc( udg_BallOwner, "move", GetRectCenter(udg_AI_AttackPoint_U[udg_ThinkingTeamNumber]) )
else
if ( Trig_MoveTo_Insane_Func006Func001C() ) then
call IssuePointOrderLoc( udg_BallOwner, "move", GetRectCenter(udg_AI_AttackPoint_M[udg_ThinkingTeamNumber]) )
else
call IssuePointOrderLoc( udg_BallOwner, "move", GetRectCenter(udg_AI_AttackPoint_D[udg_ThinkingTeamNumber]) )
endif
endif
endfunction
//===========================================================================
function InitTrig_MoveTo_Insane takes nothing returns nothing
set gg_trg_MoveTo_Insane = CreateTrigger( )
call TriggerAddAction( gg_trg_MoveTo_Insane, function Trig_MoveTo_Insane_Actions )
endfunction
function Trig_Set_nearest_enemy_unit_Func002Func001Func002001 takes nothing returns boolean
return ( udg_TempUnit == null )
endfunction
function Trig_Set_nearest_enemy_unit_Func002Func001Func002002 takes nothing returns boolean
return ( DistanceBetweenPoints(GetUnitLoc(udg_TempUnit), udg_TempPoint) >= DistanceBetweenPoints(GetUnitLoc(GetEnumUnit()), udg_TempPoint) )
endfunction
function Trig_Set_nearest_enemy_unit_Func002Func001C takes nothing returns boolean
if ( not GetBooleanOr( Trig_Set_nearest_enemy_unit_Func002Func001Func002001(), Trig_Set_nearest_enemy_unit_Func002Func001Func002002() ) ) then
return false
endif
return true
endfunction
function Trig_Set_nearest_enemy_unit_Func002A takes nothing returns nothing
if ( Trig_Set_nearest_enemy_unit_Func002Func001C() ) then
set udg_TempUnit = GetEnumUnit()
else
endif
endfunction
function Trig_Set_nearest_enemy_unit_Actions takes nothing returns nothing
set udg_TempUnit = null
call ForGroupBJ( udg_TempUnitGroup2, function Trig_Set_nearest_enemy_unit_Func002A )
endfunction
//===========================================================================
function InitTrig_Set_nearest_enemy_unit takes nothing returns nothing
set gg_trg_Set_nearest_enemy_unit = CreateTrigger( )
call TriggerAddAction( gg_trg_Set_nearest_enemy_unit, function Trig_Set_nearest_enemy_unit_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Cant_Get_Ball_Conditions takes unit u returns boolean
//unit u = GetEnumUnit()
bool b11 = ( udg_ThrowinMode == 1 ) and ( IsUnitInTeamExt(u, 2) )
bool b12 = ( udg_ThrowinMode == 2 ) and ( IsUnitInTeamExt(u, 1) )
bool b1 = b11 || b12
bool b21 = GetOwningPlayer(u) != Player(PLAYER_NEUTRAL_PASSIVE)
bool b22 = IsKeeper(u)
bool b2 = b21 || b22
set u = null
return b1 && b2
endfunction
function Trig_Cant_Get_Ball_Actions takes unit u returns nothing
real ball2unit = AngleBetweenUnits( udg_Ball, u )
location loc_ball = GetUnitLoc(udg_Ball)
real dist = CANT_GET_BALL_PUSHBACK_RADIUS
location loc_unit_new = PolarProjectionBJ( loc_ball, dist, ball2unit)
call SetUnitPositionLoc( u, loc_unit_new )
call CleanLocs(loc_unit_new, loc_ball)
endfunction
//===========================================================================
function InitTrig_Cant_Get_Ball takes nothing returns nothing
set gg_trg_Cant_Get_Ball = CreateTrigger( )
call TriggerAddCondition( gg_trg_Cant_Get_Ball, Condition( function Trig_Cant_Get_Ball_Conditions ) )
call TriggerAddAction( gg_trg_Cant_Get_Ball, function Trig_Cant_Get_Ball_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Set_Camera_Distance_AutoZoomActions takes nothing returns nothing
int pid = GetConvertedPlayerId(GetEnumPlayer())
call Ensure( udg_CameraAutoZoom[pid] )
real hero_y = GetUnitY(udg_Hero[pid]), hero_x = GetUnitX(udg_Hero[pid])
real ball_y = GetBallY(), ball_x = GetBallX()
real r = ball_y - hero_y
if ( r >= 0 ) then
set udg_CameraDistance[pid] = RMaxBJ(udg_CameraDistance[0], 1.5 * r )
else
set udg_CameraDistance[pid] = RMaxBJ(udg_CameraDistance[0], -3 * r )
endif
set r = Abs( ball_x - hero_x )
set udg_CameraDistance[pid] = RMaxBJ(udg_CameraDistance[pid], 2.8 * r )
endfunction
function IsAutoZoomEnabled takes int pid returns bool
return udg_CameraAutoZoom[pid]
endfunction
function Trig_Camera_AutoZoom_Actions takes nothing returns nothing
player p = GetTriggerPlayer() // GetOwningPlayer(u)
int pid = GetConvertedPlayerId(p)
unit u = udg_Hero[pid]
if ( udg_CameraAutoZoom[pid] ) then
call echo(p, "TRIGSTR_293" )
set udg_CameraAutoZoom[pid] = false
set udg_CameraLock[pid] = false
call ResetToGameCameraForPlayer( p, INFINITY_TIME )
set udg_CameraDistance[pid] = udg_CameraDistance[0]
else
call echo(p, "TRIGSTR_294" )
set udg_CameraAutoZoom[pid] = true
set udg_CameraLock[pid] = true
call SetCameraTargetControllerNoZForPlayer( p, u, 0, 0, false )
endif
endfunction
//===========================================================================
function InitTrig_Camera_AutoZoom takes nothing returns nothing
set gg_trg_Camera_AutoZoom = CreateTrigger( )
//call TriggerRegisterAnyUnitEventBJ( gg_trg_Camera_AutoZoom, EVENT_PLAYER_UNIT_USE_ITEM )
call TriggerRegisterAnyPlayerChatEvent(gg_trg_Camera_AutoZoom, "-autozoom", "-auto zoom", true)
call TriggerAddAction( gg_trg_Camera_AutoZoom, function Trig_Camera_AutoZoom_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_common_actions_after_a_goal_OldSuddenDeathActions takes nothing returns nothing
call DestroyTrigger( gg_trg_Timer_Interval_001 )
call DestroyTrigger( gg_trg_Timer_Interval_01 )
call PolledWait(0.5)
//call PlaySoundFromOffsetBJ( gg_snd_whistle_long, 100, 0.85 )
//call WaitForSoundBJ( gg_snd_whistle_long, 0.00 )
//call PolledWait( 0.20 )
//call PlaySoundFromOffsetBJ( gg_snd_whistle_long, 100, 0.85 )
//call WaitForSoundBJ( gg_snd_whistle_long, 0.00 )
//call PolledWait( 0.20 )
//call PlaySoundBJ( gg_snd_whistle_long )
//call WaitForSoundBJ( gg_snd_whistle_long, 0.00 )
if ( udg_Score[1] > udg_Score[2] ) then
call TriggerExecute( gg_trg_Humans_Win )
else
call TriggerExecute( gg_trg_Orcs_Win )
endif
endfunction
function Trig_Keeper_Get_Ball_StunKeeper takes integer whichKeeper returns nothing
location loc_keeper = GetUnitLoc(udg_Keeper[whichKeeper])
location loc_keeper_new = PolarProjectionBJ(loc_keeper, 50, udg_BallDirection)
call SetUnitPositionLoc( udg_Keeper[whichKeeper], loc_keeper_new )
//set udg_LastKicker = FirstOfGroup(udg_Team2Heroes)
//set udg_UnitBeStunned = udg_Keeper[2]
//call TriggerExecute( gg_trg_Unit_cant_catch_the_ball )
endfunction
//===========================================================================
function Trig_first_half_was_over_Func017A takes nothing returns nothing
//call ForForce( GetPlayersByMapControl(MAP_CONTROL_COMPUTER), function Trig_first_half_was_over_Func017A )
local integer pid = GetConvertedPlayerId(GetEnumPlayer())
call UnitUseItem( udg_Hero[pid], GetItemOfTypeFromUnitBJ(udg_Hero[pid], 'tret') )
endfunction
function Trig_first_half_was_over_Func019A takes nothing returns nothing
//call ForForce( GetPlayersByMapControl(MAP_CONTROL_COMPUTER), function Trig_first_half_was_over_Func019A )
//call TriggerExecute( gg_trg_Com_Get_Abilities )
endfunction
function Trig_Long_Pass_SetNewFacing takes nothing returns nothing
return
unit u = GetTriggerUnit()
location loc_unit = GetUnitLoc(u)
real unit2target = AngleBetweenPoints(loc_unit, GetSpellTargetLoc())
call IssueImmediateOrder(u, "stop")
call SetUnitFacing(u, unit2target)
endfunction
//===========================================================================
function AddGlowEffectEnum takes nothing returns nothing
unit u = GetEnumUnit()
call UnitAddAbility(u, ABILITY_ID_GLOW )
call OverHeadFlashEffect(u)
endfunction
function Trig_Mode_Glow_ActionsOnEnable takes nothing returns nothing
// do specific mode stuff
call ForGroup(udg_Team1Heroes, function AddGlowEffectEnum)
call ForGroup(udg_Team2Heroes, function AddGlowEffectEnum)
endfunction
// scoreboard timer update
function GetRoundName takes int round returns string
string str_round = ""
if round == 0
str_round = "1st Half" // "TRIGSTR_/090"
elseif round == 1
str_round = "Half Time" // "TRIGSTR_/199"
elseif round == 2
str_round = "2nd Half" // "TRIGSTR_/201"
endif
return str_round
endfunction
function StunTarget takes unit u returns nothing
call IssueTargetOrder( gg_unit_nshe_0078, "thunderbolt", u )
endfunction
//
function Trig_Vote_Finished_NotBall takes nothing returns boolean
return ( udg_Ball != GetFilterUnit() )
endfunction
function Trig_Vote_Finished_StandVictoryAnimation takes nothing returns nothing
call SetUnitAnimation( GetEnumUnit(), "Stand Victory" )
endfunction
function Trig_Vote_Finished_VictoryAnimation takes nothing returns nothing
// Neutral Passive Units doing Stand Victory animation
conditionfunc cond = Condition(function Trig_Vote_Finished_NotBall)
group g = GetUnitsOfPlayerMatching(Player(PLAYER_NEUTRAL_PASSIVE), cond)
call ForGroup( g, function Trig_Vote_Finished_StandVictoryAnimation )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Rebound_FastBall_Actions takes nothing returns nothing
local location loc_unit = GetUnitLoc(GetEnumUnit())
local location loc_unit_new = PolarProjectionBJ(loc_unit, 50, udg_BallDirection)
set udg_LastOwner = GetEnumUnit()
call SetUnitPositionLoc( GetEnumUnit(), loc_unit_new )
set udg_BallImmuneTimer = 7
set udg_BallDirection = udg_BallDirection + GetRandomReal(90, 270)
set udg_SpeedDownFactor = GetUnitMoveSpeed(udg_Ball) * 5.
call TriggerExecute( gg_trg_SpeedDown )
set udg_UnitBeStunned = GetEnumUnit()
call TriggerExecute( gg_trg_Stun_Target )
endfunction
//===========================================================================
function InitTrig_Rebound_FastBall takes nothing returns nothing
set gg_trg_Rebound_FastBall = CreateTrigger( )
call TriggerAddAction( gg_trg_Rebound_FastBall, function Trig_Rebound_FastBall_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Unit_cant_catch_the_ball_Actions takes nothing returns nothing
set udg_BallImmuneTimer = 7
set udg_BallDirection = udg_BallDirection + GetRandomReal(90, 270)
set udg_SpeedDownFactor = GetUnitMoveSpeed(udg_Ball) * 0.5
call TriggerExecute( gg_trg_SpeedDown )
call TriggerExecute( gg_trg_Stun_Target )
endfunction
//===========================================================================
function InitTrig_Unit_cant_catch_the_ball takes nothing returns nothing
set gg_trg_Unit_cant_catch_the_ball = CreateTrigger( )
call TriggerAddAction( gg_trg_Unit_cant_catch_the_ball, function Trig_Unit_cant_catch_the_ball_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Select_Keeper_Conditions takes nothing returns boolean
//local boolean b2 = GetSelectedUnit() == udg_Keeper[1] //or GetSelectedUnit() == udg_Keeper[2]
local boolean b11 = GetTriggerUnit() == udg_Keeper[1]
local boolean b12 = GetTriggerUnit() == udg_Keeper[2]
local boolean b1 = b11 or b12
local boolean b2
local boolean b3 = true //KeeperControlTime <= 0
local boolean b4 = true //IsKeeperPlayable
local boolean b5 = not IsPlayerInForce( GetTriggerPlayer(), Observers )
local integer pid = GetConvertedPlayerId(GetTriggerPlayer())
if not ( b1 and b3 and b4 and b5) then
return false
endif
//call BJDebugMsg("pid = "+I2S(pid))
if b11 then
set b2 = pid <= 6
else
set b2 = pid >= 7
endif
//if b1 and b2 and not b3 and b4 and Player(pid - 1) != GetOwningPlayer(GetTriggerUnit()) then
// call DisplayTextToPlayer( Player(pid - 1), 0, 0, "The keeper is controlled by another player." )
//endif
if not InTesting
return false
endif
return b1 and b2 and b3 and b4 and b5
endfunction
function Trig_Select_Keeper_Actions takes nothing returns nothing
local integer pid = GetConvertedPlayerId(GetTriggerPlayer())
local integer curPlayer = pid - 1
local integer nkeeper
set IsKeeperPlayable = true
if pid <= 6 then
set nkeeper = 1
else
set nkeeper = 2
endif
//call BJDebugMsg("works !!")
//set KeeperControlTime = 12
//call DisplayTextToForce(GetPlayersAllies(Player(curPlayer)), udg_PlayerNames[pid] + " has claimed keeper control for 6 seconds.")
call SetUnitOwner(udg_Keeper[nkeeper], Player(curPlayer), true)
endfunction
//===========================================================================
function InitTrig_Select_Keeper takes nothing returns nothing
local integer pcount = 0
set gg_trg_Select_Keeper = CreateTrigger( )
loop
exitwhen pcount > 11
call TriggerRegisterPlayerSelectionEventBJ(gg_trg_Select_Keeper, Player(pcount), true)
set pcount = pcount + 1
endloop
call TriggerAddCondition(gg_trg_Select_Keeper, Condition(function Trig_Select_Keeper_Conditions))
//call TriggerRegisterUnitEvent(gg_trg_Select_Keeper, udg_Hero[1], EVENT_UNIT_SELECTED)
//call TriggerRegisterUnitEvent(gg_trg_Select_Keeper, udg_Keeper[1], EVENT_UNIT_SELECTED)
call TriggerAddAction( gg_trg_Select_Keeper, function Trig_Select_Keeper_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Get_best_target_for_pass_Func002001002001 takes nothing returns boolean
return ( GetFilterUnit() == udg_Hero[GetConvertedPlayerId(GetOwningPlayer(GetFilterUnit()))] )
endfunction
function Trig_Get_best_target_for_pass_Func002001002002 takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit(), GetEnumPlayer()) == true )
endfunction
function Trig_Get_best_target_for_pass_NEW takes nothing returns boolean
bool b1 = GetBooleanAnd( Trig_Get_best_target_for_pass_Func002001002001(), Trig_Get_best_target_for_pass_Func002001002002() )
bool b2 = true
return b1 and b2
endfunction
function Trig_Get_best_target_for_pass_Func002Func001C takes nothing returns boolean
local location heroloc = GetUnitLoc(udg_Hero[GetConvertedPlayerId(GetEnumPlayer())])
local location unitloc = GetUnitLoc(GetEnumUnit())
bool b1 = RectContainsUnit(gg_rct_PlayArea, udg_Hero[GetConvertedPlayerId(GetEnumPlayer())])
bool b2 = udg_NearestEnemyDist[GetConvertedPlayerId(GetEnumPlayer())] > DistanceBetweenPoints( heroloc, unitloc )
call RemoveLocation( heroloc )
call RemoveLocation( unitloc )
set heroloc = null
set unitloc = null
return ( b1 ) and ( b2 )
endfunction
function Trig_Get_best_target_for_pass_Func002A takes nothing returns nothing
local location loc1
local location loc2
if ( Trig_Get_best_target_for_pass_Func002Func001C() ) then
set loc1 = GetUnitLoc(udg_Hero[GetConvertedPlayerId(GetEnumPlayer())])
set loc2 = GetUnitLoc(GetEnumUnit())
set udg_NearestEnemyDist[GetConvertedPlayerId(GetEnumPlayer())] = DistanceBetweenPoints( loc1, loc2 )
call RemoveLocation( loc1 )
call RemoveLocation( loc2 )
endif
set loc1 = null
set loc2 = null
endfunction
function Trig_Get_best_target_for_pass_Func003C takes nothing returns boolean
int pid = GetConvertedPlayerId(GetEnumPlayer())
unit hero = udg_Hero[pid]
unit keeper = udg_Keeper[udg_WhichKeeperHasBall]
real keeper_x = GetUnitX(keeper)
real hero_x = GetUnitX(hero)
bool b1 = Abs(keeper_x) - Abs(hero_x) >= 0
bool b2 = udg_NearestEnemyDistFromPassTarget < udg_NearestEnemyDist[pid]
real dist = DistanceBetweenUnits(keeper, hero)
bool b3 = ( dist > 640 ) && ( dist < 1700 ) // used to be 1664
set hero = null; set keeper = null
return b1 and b2 and b3
endfunction
function Trig_Get_best_target_for_pass_Actions takes nothing returns nothing
int pid = GetConvertedPlayerId(GetEnumPlayer())
local group g = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Get_best_target_for_pass_NEW))
set udg_NearestEnemyDist[pid] = INFINITY_REAL
call ForGroup( g, function Trig_Get_best_target_for_pass_Func002A )
call DestroyGroup( g )
if ( Trig_Get_best_target_for_pass_Func003C() ) then
set udg_NearestEnemyDistFromPassTarget = udg_NearestEnemyDist[pid]
set udg_KeeperPassTarget = udg_Hero[pid]
endif
set g = null
endfunction
//===========================================================================
function InitTrig_Get_best_target_for_pass takes nothing returns nothing
set gg_trg_Get_best_target_for_pass = CreateTrigger( )
call TriggerAddAction( gg_trg_Get_best_target_for_pass, function Trig_Get_best_target_for_pass_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Keeper_Has_a_ball_Func003Func001001001 takes nothing returns boolean
return ( FilterPlayerStatePlaying() ) and ( IsPlayerEnemy(GetFilterPlayer(), Player(11)) )
endfunction
function Trig_Keeper_Has_a_ball_Func003Func001A takes nothing returns nothing
if ( GetEnumPlayer() != Player(PLAYER_NEUTRAL_PASSIVE) ) then
call TriggerExecute( gg_trg_Get_best_target_for_pass )
endif
endfunction
function Trig_Keeper_Has_a_ball_Func004Func001001001 takes nothing returns boolean
return ( FilterPlayerStatePlaying() ) and ( IsPlayerEnemy(GetFilterPlayer(), Player(0)) )
endfunction
function Trig_Keeper_Has_a_ball_Actions takes nothing returns nothing
set udg_NearestEnemyDistFromPassTarget = 0.00
set udg_KeeperPassTarget = null
conditionfunc cond
if ( udg_WhichKeeperHasBall == 1 ) then
set cond = Condition(function Trig_Keeper_Has_a_ball_Func003Func001001001)
elseif ( udg_WhichKeeperHasBall == 2 ) then
set cond = Condition(function Trig_Keeper_Has_a_ball_Func004Func001001001)
endif
force f = GetPlayersMatching(cond)
//call ForForce( f, function Trig_Keeper_Has_a_ball_Func003Func001A )
if ( udg_KeeperBallHoldTimer <= 0 ) //or ( udg_NearestEnemyDistFromPassTarget >= 640 ) then
call TriggerExecute( gg_trg_Keeper_Throw_Ball )
endif
endfunction
//===========================================================================
function InitTrig_Keeper_Has_a_ball takes nothing returns nothing
set gg_trg_Keeper_Has_a_ball = CreateTrigger( )
call TriggerAddAction( gg_trg_Keeper_Has_a_ball, function Trig_Keeper_Has_a_ball_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Indirect_Free_Kick_Actions takes nothing returns nothing
set udg_ThrowinMode = GetEnemyTeamNumber(GetTeamNumberOfUnit(LK))
echo("C goals do not count.")
echo(TeamName[udg_ThrowinMode]+"' free kick!")
set udg_ThrowinLoc = LastShotLoc
call SetUnitPositionLoc(udg_Ball, udg_ThrowinLoc)
set udg_IndirectFreeKick = true
call TriggerExecute( gg_trg_Linecross_common_events )
endfunction
//===========================================================================
function InitTrig_Indirect_Free_Kick takes nothing returns nothing
set gg_trg_Indirect_Free_Kick = CreateTrigger( )
call TriggerAddAction( gg_trg_Indirect_Free_Kick, function Trig_Indirect_Free_Kick_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Jump_Ball_ResetHeroState takes nothing returns nothing
int pid = GetConvertedPlayerId(GetEnumPlayer())
set udg_HeroVX[pid] = 0
set udg_HeroVY[pid] = 0
set udg_HeroSlidingWait[pid] = 0
set udg_HeroInAir[pid] = false
call GroupClear( udg_SlidingUnits )
call DestroyEffect( udg_SlidingEffect[pid] )
call SetUnitFlyHeight( udg_Hero[pid], GetUnitDefaultFlyHeight(udg_Hero[pid]), 0 )
endfunction
function Trig_Jump_Ball_Actions takes nothing returns nothing
force f = GetPlayersMatching(Condition(function FilterPlayerStatePlaying))
call ForForce( f, function Trig_Jump_Ball_ResetHeroState )
call StartSound( gg_snd_whistle_long )
call echo( "TRIGSTR_241" )
call EnableTrigger( gg_trg_Timer_Interval_01 )
call EnableTrigger( gg_trg_Timer_Interval_001 )
set udg_BallImmuneTimer = 15
call SetBallHeight( udg_BallDefaultHeight, 0 )
call BallSpeedDown(INFINITY_REAL)
call SetUnitTimeScalePercent( udg_Ball, 100 )
set udg_BallVZ = 20 * udg_G
set udg_BallDirection = 270
set udg_IsBallInAir = true
endfunction
//===========================================================================
function InitTrig_Jump_Ball takes nothing returns nothing
set gg_trg_Jump_Ball = CreateTrigger( )
call TriggerRegisterTimerExpireEvent( gg_trg_Jump_Ball, udg_JumpBall )
call TriggerAddAction( gg_trg_Jump_Ball, function Trig_Jump_Ball_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Shoot_or_Sliding_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetSummonedUnit()) == 'osp1' ) ) then
// call DisplayTextToForce(GetPlayersAll(), "FALSE !")
return false
endif
if ( not ( udg_HeroSlidingWait[GetConvertedPlayerId(GetOwningPlayer(GetSummonedUnit()))] == 0 ) ) then
// call DisplayTextToForce(GetPlayersAll(), "FALSE 2 !")
return false
endif
//
// call DisplayTextToForce(GetPlayersAll(), "cond func exec")
return true
endfunction
function Trig_Shoot_or_Sliding_Func001Func003Func010Func003001 takes nothing returns boolean
return ( ( udg_TempDirection - udg_SlidingDirection[GetConvertedPlayerId(GetOwningPlayer(GetSummoningUnit()))] ) <= 30.00 )
endfunction
function Trig_Shoot_or_Sliding_Func001Func003Func010Func003002 takes nothing returns boolean
return ( RAbsBJ(( RAbsBJ(( udg_TempDirection - udg_SlidingDirection[GetConvertedPlayerId(GetOwningPlayer(GetSummoningUnit()))] )) - 360.00 )) <= 30.00 )
endfunction
function Trig_Shoot_or_Sliding_Func001Func003Func010C takes nothing returns boolean
if ( not ( DistanceBetweenPoints(GetUnitLoc(udg_Ball), GetUnitLoc(GetSummoningUnit())) <= 256.00 ) ) then
return false
endif
if ( not GetBooleanOr( Trig_Shoot_or_Sliding_Func001Func003Func010Func003001(), Trig_Shoot_or_Sliding_Func001Func003Func010Func003002() ) ) then
return false
endif
if ( not ( GetPlayerController(GetOwningPlayer(udg_BallOwner)) == MAP_CONTROL_COMPUTER ) ) then
return false
endif
if ( not ( GetAIDifficulty(GetOwningPlayer(udg_BallOwner)) == AI_DIFFICULTY_INSANE ) ) then
return false
endif
return true
endfunction
function Trig_Shoot_or_Sliding_Func001Func003C takes nothing returns boolean
if ( not ( udg_HeroInAir[GetConvertedPlayerId(GetOwningPlayer(GetSummoningUnit()))] == false ) ) then
return false
endif
return true
endfunction
function Trig_Shoot_or_Sliding_Func001C takes nothing returns boolean
if ( not ( udg_BallOwner == GetSummoningUnit() ) ) then
return false
endif
return true
endfunction
function Trig_Shoot_or_Sliding_Actions takes nothing returns nothing
if ( Trig_Shoot_or_Sliding_Func001C() ) then
set udg_BallBound = false
set udg_BallImmuneTimer = 7
call ShowUnitShow( udg_Flag )
set udg_BallVZ = 20.00
set udg_IsBallInAir = true
set udg_BallDirection = AngleBetweenPoints(GetUnitLoc(udg_Ball), GetUnitLoc(GetSummonedUnit()))
set udg_TempReal = ( 37.20 + ( I2R(GetHeroStatBJ(bj_HEROSTAT_STR, udg_BallOwner, true)) * 1.50 ) )
call TriggerExecute( gg_trg_Set_Ball_Move_Speed )
call TriggerExecute( gg_trg_Common_Actions_for_shoot )
else
if ( Trig_Shoot_or_Sliding_Func001Func003C() ) then
call GroupAddUnitSimple( GetSummoningUnit(), udg_SlidingUnits )
set udg_SlidingDirection[GetConvertedPlayerId(GetOwningPlayer(GetSummoningUnit()))] = AngleBetweenPoints(GetUnitLoc(GetSummoningUnit()), GetUnitLoc(GetSummonedUnit()))
set udg_HeroSlidingWait[GetConvertedPlayerId(GetOwningPlayer(GetSummoningUnit()))] = 25
set udg_HeroVX[GetConvertedPlayerId(GetOwningPlayer(GetSummoningUnit()))] = 40.00
call PlaySoundOnUnitBJ( gg_snd_Shockwave, 100, GetSummoningUnit() )
call AddSpecialEffectTargetUnitBJ( "origin", GetSummoningUnit(), "Abilities\\Spells\\Orc\\Shockwave\\ShockwaveMissile.mdl" )
set udg_SlidingEffect[GetConvertedPlayerId(GetOwningPlayer(GetSummoningUnit()))] = GetLastCreatedEffectBJ()
set udg_TempDirection = AngleBetweenPoints(GetUnitLoc(GetSummoningUnit()), GetUnitLoc(udg_Ball))
if ( Trig_Shoot_or_Sliding_Func001Func003Func010C() ) then
call IssueImmediateOrder( udg_BallOwner, "windwalk" )
else
endif
else
endif
endif
endfunction
//===========================================================================
function InitTrig_Shoot_or_Sliding_old takes nothing returns nothing
set gg_trg_Shoot_or_Sliding_old = CreateTrigger( )
// EVENT_PLAYER_UNIT_SUMMON
// EVENT_PLAYER_UNIT_SPELL_ENDCAST
call TriggerRegisterAnyUnitEventBJ( gg_trg_Shoot_or_Sliding_old, EVENT_PLAYER_UNIT_SUMMON )
call TriggerAddCondition( gg_trg_Shoot_or_Sliding_old, Condition( function Trig_Shoot_or_Sliding_Conditions ) )
call TriggerAddAction( gg_trg_Shoot_or_Sliding_old, function Trig_Shoot_or_Sliding_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Sudden_death_Func024001001 takes nothing returns boolean
return ( GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING )
endfunction
function Trig_Sudden_death_Func024A takes nothing returns nothing
call DestroyEffectBJ( udg_SlidingEffect[GetConvertedPlayerId(GetEnumPlayer())] )
call SetUnitFlyHeightBJ( udg_Hero[GetConvertedPlayerId(GetEnumPlayer())], 0.00, 0.00 )
set udg_HeroVX[GetConvertedPlayerId(GetEnumPlayer())] = 0.00
set udg_HeroVY[GetConvertedPlayerId(GetEnumPlayer())] = 0.00
set udg_HeroInAir[GetConvertedPlayerId(GetEnumPlayer())] = false
set udg_HeroSlidingWait[GetConvertedPlayerId(GetEnumPlayer())] = 0
endfunction
function Trig_Sudden_death_Func028001002 takes nothing returns boolean
return ( udg_Hero[GetConvertedPlayerId(GetOwningPlayer(GetFilterUnit()))] == GetFilterUnit() )
endfunction
function Trig_Sudden_death_Func028Func001Func005001001 takes nothing returns boolean
return ( udg_Round == 0 )
endfunction
function Trig_Sudden_death_Func028Func001Func005001002 takes nothing returns boolean
return ( IsUnitAlly(GetEnumUnit(), Player(0)) == true )
endfunction
function Trig_Sudden_death_Func028Func001Func005001 takes nothing returns boolean
return GetBooleanAnd( Trig_Sudden_death_Func028Func001Func005001001(), Trig_Sudden_death_Func028Func001Func005001002() )
endfunction
function Trig_Sudden_death_Func028Func001Func005002001 takes nothing returns boolean
return ( udg_Round != 0 )
endfunction
function Trig_Sudden_death_Func028Func001Func005002002 takes nothing returns boolean
return ( IsUnitEnemy(GetEnumUnit(), Player(0)) == true )
endfunction
function Trig_Sudden_death_Func028Func001Func005002 takes nothing returns boolean
return GetBooleanAnd( Trig_Sudden_death_Func028Func001Func005002001(), Trig_Sudden_death_Func028Func001Func005002002() )
endfunction
function Trig_Sudden_death_Func028Func001C takes nothing returns boolean
if ( not GetBooleanOr( Trig_Sudden_death_Func028Func001Func005001(), Trig_Sudden_death_Func028Func001Func005002() ) ) then
return false
endif
return true
endfunction
function Trig_Sudden_death_Func028A takes nothing returns nothing
if ( Trig_Sudden_death_Func028Func001C() ) then
call SetUnitPositionLoc( GetEnumUnit(), GetRandomLocInRect(gg_rct_LeftTeamStay) )
call PanCameraToTimedLocForPlayer( GetOwningPlayer(GetEnumUnit()), GetUnitLoc(GetEnumUnit()), 0 )
else
call SetUnitPositionLoc( GetEnumUnit(), GetRandomLocInRect(gg_rct_RightTeamStay) )
call PanCameraToTimedLocForPlayer( GetOwningPlayer(GetEnumUnit()), GetUnitLoc(GetEnumUnit()), 0 )
endif
endfunction
function Trig_Sudden_death_Actions takes nothing returns nothing
call StopMusicBJ( false )
call PlayMusicBJ( gg_snd_SuddenDeathBGM )
call DisableTrigger( gg_trg_Show_Losstime )
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_211" )
set udg_SuddenDeath = true
set udg_IndirectFreeKick = true
set udg_MapReset = true
call DestroyEffectBJ( udg_BallInHandEffect )
set udg_KeeperBallHoldTimer = 0
set udg_WhichKeeperHasBall = 0
set udg_BallImmuneTimer = 0
call DisableTrigger( gg_trg_Timer_Interval_01 )
call ShowUnitHide( udg_Flag )
call PlaySoundBJ( gg_snd_whistle_long )
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 1.00, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 100.00, 100.00, 100.00, 0.00 )
set udg_IsBallInAir = false
call SetUnitTimeScalePercent( udg_Ball, 0.00 )
call SetUnitFlyHeightBJ( udg_Ball, udg_BallDefaultHeight, 0.00 )
set udg_SpeedDownFactor = 1000000000.00
call TriggerExecute( gg_trg_SpeedDown )
set udg_BallBound = true
call PolledWait( 1.00 )
call GroupClear( udg_SlidingUnits )
call ForForce( GetPlayersMatching(Condition(function Trig_Sudden_death_Func024001001)), function Trig_Sudden_death_Func024A )
set udg_BallOwner = null
call TriggerExecute( gg_trg_Refresh_Leaderboard )
call SetUnitPositionLoc( udg_Ball, GetRectCenter(gg_rct_Center) )
call ForGroupBJ( GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Sudden_death_Func028001002)), function Trig_Sudden_death_Func028A )
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 1.00, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 100.00, 100.00, 100.00, 0.00 )
call PolledWait( 1.00 )
set udg_BallOwner = null
set udg_MapReset = false
call SetUnitPositionLocFacingLocBJ( udg_Referee, OffsetLocation(GetUnitLoc(udg_Ball), 0.00, 150.00), GetUnitLoc(udg_Ball) )
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_212" )
// ORIG_CreateTimerBJ
//call CreateTimerBJ( udg_JumpBall, "TRIGSTR_240", 10.00, false )
call CreateTimerBJ( false,10.00 )
call ShowUnitShow( udg_Ball )
set udg_ThrowinMode = 0
endfunction
//===========================================================================
function InitTrig_Sudden_death_old takes nothing returns nothing
set gg_trg_Sudden_death_old = CreateTrigger( )
call TriggerAddAction( gg_trg_Sudden_death_old, function Trig_Sudden_death_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=1
function Trig_Headding_Action_BKUP_Func001Func001001002 takes nothing returns boolean
return ( GetPlayerController(GetOwningPlayer(GetFilterUnit())) == MAP_CONTROL_COMPUTER )
endfunction
function Trig_Headding_Action_BKUP_Func001Func001Func003Func005C takes nothing returns boolean
if ( not ( IsUnitAlly(GetEnumUnit(), Player(0)) == true ) ) then
return false
endif
return true
endfunction
function Trig_Headding_Action_BKUP_Func001Func001Func003Func006Func002001 takes nothing returns boolean
return ( GetRandomInt(0, 4) == 0 )
endfunction
function Trig_Headding_Action_BKUP_Func001Func001Func003Func006Func002002 takes nothing returns boolean
return ( RectContainsUnit(udg_PlayArea[udg_ThinkingTeamEnemyNumber], GetEnumUnit()) == true )
endfunction
function Trig_Headding_Action_BKUP_Func001Func001Func003Func006Func004C takes nothing returns boolean
if ( not ( udg_TempReal2 <= ( udg_TempReal + udg_HeroHeight ) ) ) then
return false
endif
if ( not ( udg_TempReal2 >= udg_TempReal ) ) then
return false
endif
if ( not ( udg_TempRealArray[1] >= 0.00 ) ) then
return false
endif
return true
endfunction
function Trig_Headding_Action_BKUP_Func001Func001Func003Func006C takes nothing returns boolean
if ( not ( GetAIDifficulty(GetOwningPlayer(GetEnumUnit())) != AI_DIFFICULTY_NEWBIE ) ) then
return false
endif
if ( not GetBooleanOr( Trig_Headding_Action_BKUP_Func001Func001Func003Func006Func002001(), Trig_Headding_Action_BKUP_Func001Func001Func003Func006Func002002() ) ) then
return false
endif
if ( not ( udg_HeroInAir[GetConvertedPlayerId(GetOwningPlayer(GetEnumUnit()))] == false ) ) then
return false
endif
if ( not Trig_Headding_Action_BKUP_Func001Func001Func003Func006Func004C() ) then
return false
endif
return true
endfunction
function Trig_Headding_Action_BKUP_Func001Func001Func003C takes nothing returns boolean
if ( not ( GetUnitMoveSpeed(GetEnumUnit()) >= ( ( 10.00 * DistanceBetweenPoints(GetUnitLoc(GetEnumUnit()), GetUnitLoc(udg_Flag)) ) / udg_TempReal ) ) ) then
return false
endif
return true
endfunction
function Trig_Headding_Action_BKUP_Func001Func001A takes nothing returns nothing
set udg_TempReal = ( DistanceBetweenPoints(GetUnitLoc(GetEnumUnit()), GetUnitLoc(udg_Ball)) / ( GetUnitMoveSpeed(udg_Ball) / 10.00 ) )
set udg_TempReal2 = ( GetUnitFlyHeight(udg_Ball) + ( ( udg_BallVZ * udg_TempReal ) - ( ( udg_G * Pow(udg_TempReal, 2.00) ) / 2.00 ) ) )
if ( Trig_Headding_Action_BKUP_Func001Func001Func003C() ) then
set udg_TempInt = ( 20 + GetHeroStatBJ(bj_HEROSTAT_STR, GetEnumUnit(), true) )
set udg_TempRealArray[1] = ( I2R(udg_TempInt) - ( udg_G * udg_TempReal ) )
set udg_TempReal = ( ( I2R(udg_TempInt) * udg_TempReal ) - ( ( udg_G * Pow(udg_TempReal, 2.00) ) / 2.00 ) )
if ( Trig_Headding_Action_BKUP_Func001Func001Func003Func005C() ) then
set udg_ThinkingTeamNumber = 1
set udg_ThinkingTeamEnemyNumber = 2
else
set udg_ThinkingTeamNumber = 2
set udg_ThinkingTeamEnemyNumber = 1
endif
if ( Trig_Headding_Action_BKUP_Func001Func001Func003Func006C() ) then
call IssuePointOrderLoc( GetEnumUnit(), "move", PolarProjectionBJ(GetUnitLoc(udg_Flag), 100.00, AngleBetweenPoints(GetUnitLoc(udg_Flag), GetUnitLoc(udg_Ball))) )
call IssueImmediateOrder( GetEnumUnit(), "windwalk" )
else
endif
else
endif
endfunction
function Trig_Headding_Action_BKUP_Func001C takes nothing returns boolean
if ( not ( udg_IsBallInAir == true ) ) then
return false
endif
return true
endfunction
function Trig_Headding_Action_BKUP_Actions takes nothing returns nothing
if ( Trig_Headding_Action_BKUP_Func001C() ) then
call ForGroupBJ( GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Headding_Action_BKUP_Func001Func001001002)), function Trig_Headding_Action_BKUP_Func001Func001A )
else
endif
endfunction
//===========================================================================
function InitTrig_Headding_Action_BKUP takes nothing returns nothing
set gg_trg_Headding_Action_BKUP = CreateTrigger( )
call TriggerAddAction( gg_trg_Headding_Action_BKUP, function Trig_Headding_Action_BKUP_Actions )
endfunction
//TESH.scrollpos=-1
//TESH.alwaysfold=0
function Trig_Cheer_Func001Func001Func003001001 takes nothing returns boolean
return ( RectContainsUnit(gg_rct_CheerLeft, udg_Ball) == true )
endfunction
function Trig_Cheer_Func001Func001Func003001002 takes nothing returns boolean
return ( IsUnitAlly(udg_LastOwner, Player(0)) == true )
endfunction
function Trig_Cheer_Func001Func001Func003001 takes nothing returns boolean
return GetBooleanAnd( Trig_Cheer_Func001Func001Func003001001(), Trig_Cheer_Func001Func001Func003001002() )
endfunction
function Trig_Cheer_Func001Func001Func003002001 takes nothing returns boolean
return ( RectContainsUnit(gg_rct_CheerRight, udg_Ball) == true )
endfunction
function Trig_Cheer_Func001Func001Func003002002 takes nothing returns boolean
return ( IsUnitAlly(udg_LastOwner, Player(11)) == true )
endfunction
function Trig_Cheer_Func001Func001Func003002 takes nothing returns boolean
return GetBooleanAnd( Trig_Cheer_Func001Func001Func003002001(), Trig_Cheer_Func001Func001Func003002002() )
endfunction
function Trig_Cheer_Func001Func001C takes nothing returns boolean
if ( not ( udg_ThrowinMode == 0 ) ) then
return false
endif
if ( not GetBooleanOr( Trig_Cheer_Func001Func001Func003001(), Trig_Cheer_Func001Func001Func003002() ) ) then
return false
endif
return true
endfunction
function Trig_Cheer_Func001Func002Func003001001 takes nothing returns boolean
return ( RectContainsUnit(gg_rct_CheerLeft, udg_Ball) == true )
endfunction
function Trig_Cheer_Func001Func002Func003001002 takes nothing returns boolean
return ( IsUnitAlly(udg_LastOwner, Player(11)) == true )
endfunction
function Trig_Cheer_Func001Func002Func003001 takes nothing returns boolean
return GetBooleanAnd( Trig_Cheer_Func001Func002Func003001001(), Trig_Cheer_Func001Func002Func003001002() )
endfunction
function Trig_Cheer_Func001Func002Func003002001 takes nothing returns boolean
return ( RectContainsUnit(gg_rct_CheerRight, udg_Ball) == true )
endfunction
function Trig_Cheer_Func001Func002Func003002002 takes nothing returns boolean
return ( IsUnitAlly(udg_LastOwner, Player(0)) == true )
endfunction
function Trig_Cheer_Func001Func002Func003002 takes nothing returns boolean
return GetBooleanAnd( Trig_Cheer_Func001Func002Func003002001(), Trig_Cheer_Func001Func002Func003002002() )
endfunction
function Trig_Cheer_Func001Func002C takes nothing returns boolean
if ( not ( udg_ThrowinMode == 0 ) ) then
return false
endif
if ( not GetBooleanOr( Trig_Cheer_Func001Func002Func003001(), Trig_Cheer_Func001Func002Func003002() ) ) then
return false
endif
return true
endfunction
function Trig_Cheer_Actions takes nothing returns nothing
if ( udg_Round == 0 ) then
if ( Trig_Cheer_Func001Func002C() ) then
call StartSound( gg_snd_Cheer2 )
endif
elseif ( Trig_Cheer_Func001Func001C() ) then
call StartSound( gg_snd_Cheer2 )
endif
endfunction
//===========================================================================
function InitTrig_Cheer takes nothing returns nothing
set gg_trg_Cheer = CreateTrigger( )
call TriggerAddAction( gg_trg_Cheer, function Trig_Cheer_Actions )
endfunction