-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathME5_ObjectiveTDM.lua
166 lines (138 loc) · 4.78 KB
/
ME5_ObjectiveTDM.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--
local __SCRIPT_NAME = "ME5_ObjectiveTDM";
local debug = true
local function PrintLog(...)
if debug == true then
print("["..__SCRIPT_NAME.."]", unpack(arg));
end
end
PrintLog("Entered")
ScriptCB_DoFile("ME5_Objective")
if bStockFontLoaded == nil then
-- Has the stock font been loaded?
bStockFontLoaded = false
end
MEU_GameMode = "meu_tdm"
--=============================
-- ObjectiveTDM
-- Handles the logic for a team deathmatch game
-- Aaaactually, this has morphed into the Hunt gametype (at the last minute, hence the lack of name-change), but only in multiplayer/instant-action mode
--=============================
ObjectiveTDM = Objective:New
{
-- external values
pointsPerKillATT = 1,
pointsPerKillDEF = 1,
isCelebrityDeathmatch = false, -- exactly what it sounds like.
isUberMode = false, -- ditto
uberScoreLimit = 400, -- score limit for, get this, uber mode
}
function ObjectiveTDM:GetGameTimeLimit()
if ( self.isCelebrityDeathmatch or self.isUberMode) then
return 0
else
return ScriptCB_GetHuntMaxTimeLimit()
end
end
function ObjectiveTDM:GameOptionsTimeLimitUp()
local team1pts = GetTeamPoints(1)
local team2pts = GetTeamPoints(2)
if ( team1pts > team2pts ) then
ScriptCB_SndBusFade("music", 0.0, 1.0)
MissionVictory(1)
elseif ( team1pts < team2pts ) then
ScriptCB_SndBusFade("music", 0.0, 1.0)
MissionVictory(2)
else
ScriptCB_SndBusFade("music", 0.0, 1.0)
--tied, so victory for both
MissionVictory({1,2})
end
end
function ObjectiveTDM:Start()
if ( self.isCelebrityDeathmatch == true ) then
ScriptCB_SetNumBots(ScriptCB_GetASSNumBots())
end
--===============================
-- Initialization logic
--===============================
--initialize the base objective data first
Objective.Start(self)
if self.multiplayerRules then
ShowTeamPoints(self.teamATT, true)
ShowTeamPoints(self.teamDEF, true)
SetReinforcementCount(self.teamATT, -1)
SetReinforcementCount(self.teamDEF, -1)
SetTeamPoints(self.teamATT, 0)
SetTeamPoints(self.teamDEF, 0)
if ( self.isCelebrityDeathmatch ) then
ScriptCB_ShowHuntScoreLimit(2)
elseif ( self.isUberMode ) then
ScriptCB_ShowHuntScoreLimit(3)
ScriptCB_SetUberScoreLimit(self.uberScoreLimit)
else
ScriptCB_ShowHuntScoreLimit(1)
end
end
--set AI goals
self.AIGoals = {}
if self.AIGoalWeight > 0.0 then
table.insert(self.AIGoals, AddAIGoal(self.teamATT, "Deathmatch", 100*self.AIGoalWeight))
table.insert(self.AIGoals, AddAIGoal(self.teamDEF, "Deathmatch", 100*self.AIGoalWeight))
end
--=======================================
-- Event responses
--=======================================
--when used in multiplayer, TDM will count points upwards until a score limit is reached
if self.multiplayerRules then
local eventResponseCharacterDeath = OnCharacterDeath(
function(character, killer)
if not killer then return end --no points for suicides
local victimTeam = GetCharacterTeam(character)
local killerTeam = GetCharacterTeam(killer)
if victimTeam == killerTeam then return end --no points for killing guys on your team
if killerTeam == self.teamATT then
AddTeamPoints(killerTeam, self.pointsPerKillATT)
elseif killerTeam == self.teamDEF then
AddTeamPoints(killerTeam, self.pointsPerKillDEF)
end
local scorelimit = ScriptCB_GetHuntScoreLimit()
if ( self.isCelebrityDeathmatch ) then
scorelimit = ScriptCB_GetAssaultScoreLimit()
elseif ( self.isUberMode ) then
scorelimit = ScriptCB_GetUberScoreLimit()
end
if GetTeamPoints(killerTeam) >= scorelimit then
if killerTeam == CIS then
BroadcastVoiceOver( rep_sndcue.."com_report_defeat", REP )
BroadcastVoiceOver( cis_sndcue.."com_report_victory", CIS )
elseif killerTeam == REP then
BroadcastVoiceOver( rep_sndcue.."com_report_victory", REP )
BroadcastVoiceOver( cis_sndcue.."com_report_defeat", CIS )
end
tdmDefeatTimer = CreateTimer("tdmDefeatTimer")
SetTimerValue("tdmDefeatTimer", 6.0)
StartTimer("tdmDefeatTimer")
OnTimerElapse(
function(timer)
self:Complete(killerTeam)
ReleaseCharacterDeath(eventResponseCharacterDeath)
--[[if ME5_CustomHUD == 1 then
if bStockFontLoaded == false then
bStockFontLoaded = true
PrintLog("Loading hud_font_stock.lvl...")
-- hotfix that reloads the stock fonts in the stats screen
ReadDataFile("..\\..\\addon\\ME5\\data\\_LVL_PC\\hud_font_stock.lvl")
end
end]]
end,
"tdmDefeatTimer"
)
end
end
)
end
end
PrintLog("Exited")