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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
-- Capture Meter constants
-----------------
local MIN_NUM_PLAYERS_ONE_ARROW = 1
local MIN_NUM_PLAYERS_TWO_ARROWS = 3
local MIN_NUM_PLAYERS_THREE_ARROWS = 5
local CAPTURE_BAR_BEGIN_OFFSET = . 125 -- Begins 12.5% of the way through the circle
local CAPTURE_BAR_LENGTH = . 76 -- Is 75% of a circle long. We add an extra 1% to allow the semitransparent texture to overlap the bar
local ARROW_LENGTH = . 04 -- Arrow's about 4% of the circle long
local ENDCAP_LENGTH = . 02 -- About 2% of the circle long.
local CAPTURE_BAR_ARCLENGTH = CAPTURE_BAR_LENGTH * 2 * math . pi
local ARROW_ARCLENGTH = ARROW_LENGTH * 2 * math . pi
local ENDCAP_ARCLENGTH = ENDCAP_LENGTH * 2 * math . pi
local FADE_DURATION_MS = 150
local FULL_BAR_TIMEOUT_MS = 4000
-- Capture Meter textures
-----------------
-- badge textures
local ALLIANCE_BADGE_TEXTURES =
{
[ ALLIANCE_ALDMERI_DOMINION ] = "EsoUI/Art/AvA/avaCaptureBar_allianceBadge_aldmeri.dds" ,
[ ALLIANCE_EBONHEART_PACT ] = "EsoUI/Art/AvA/avaCaptureBar_allianceBadge_ebonheart.dds" ,
[ ALLIANCE_DAGGERFALL_COVENANT ] = "EsoUI/Art/AvA/avaCaptureBar_allianceBadge_daggerfall.dds" ,
}
local BATTLEGROUND_TEAM_BADGE_TEXTURES =
{
[ BATTLEGROUND_ALLIANCE_FIRE_DRAKES ] = "EsoUI/Art/Battlegrounds/battlegroundsCaptureBar_teamBadge_orange.dds" ,
[ BATTLEGROUND_ALLIANCE_STORM_LORDS ] = "EsoUI/Art/Battlegrounds/battlegroundsCaptureBar_teamBadge_purple.dds" ,
[ BATTLEGROUND_ALLIANCE_PIT_DAEMONS ] = "EsoUI/Art/Battlegrounds/battlegroundsCaptureBar_teamBadge_green.dds" ,
}
-- bar textures
local ALLIANCE_BAR_TEXTURES =
{
[ ALLIANCE_ALDMERI_DOMINION ] = "EsoUI/Art/AvA/avaCaptureBar_fill_aldmeri.dds" ,
[ ALLIANCE_EBONHEART_PACT ] = "EsoUI/Art/AvA/avaCaptureBar_fill_ebonheart.dds" ,
[ ALLIANCE_DAGGERFALL_COVENANT ] = "EsoUI/Art/AvA/avaCaptureBar_fill_daggerfall.dds" ,
}
local BATTLEGROUND_TEAM_BAR_TEXTURES =
{
[ BATTLEGROUND_ALLIANCE_FIRE_DRAKES ] = "EsoUI/Art/Battlegrounds/battlegroundsCaptureBar_fill_orange.dds" ,
[ BATTLEGROUND_ALLIANCE_STORM_LORDS ] = "EsoUI/Art/Battlegrounds/battlegroundsCaptureBar_fill_purple.dds" ,
[ BATTLEGROUND_ALLIANCE_PIT_DAEMONS ] = "EsoUI/Art/Battlegrounds/battlegroundsCaptureBar_fill_green.dds" ,
}
-- point textures
local ALLIANCE_POINT_TEXTURES =
{
[ ALLIANCE_ALDMERI_DOMINION ] = "EsoUI/Art/AvA/avaCaptureBar_point_aldmeri.dds" ,
[ ALLIANCE_EBONHEART_PACT ] = "EsoUI/Art/AvA/avaCaptureBar_point_ebonheart.dds" ,
[ ALLIANCE_DAGGERFALL_COVENANT ] = "EsoUI/Art/AvA/avaCaptureBar_point_daggerfall.dds" ,
}
local BATTLEGROUND_TEAM_POINT_TEXTURES =
{
[ BATTLEGROUND_ALLIANCE_FIRE_DRAKES ] = "EsoUI/Art/Battlegrounds/battlegroundsCaptureBar_point_orange.dds" ,
[ BATTLEGROUND_ALLIANCE_STORM_LORDS ] = "EsoUI/Art/Battlegrounds/battlegroundsCaptureBar_point_purple.dds" ,
[ BATTLEGROUND_ALLIANCE_PIT_DAEMONS ] = "EsoUI/Art/Battlegrounds/battlegroundsCaptureBar_point_green.dds" ,
}
-- tail textures
local ALLIANCE_TAIL_TEXTURES =
{
[ ALLIANCE_ALDMERI_DOMINION ] = "EsoUI/Art/AvA/avaCaptureBar_point-inverse_aldmeri.dds" ,
[ ALLIANCE_EBONHEART_PACT ] = "EsoUI/Art/AvA/avaCaptureBar_point-inverse_ebonheart.dds" ,
[ ALLIANCE_DAGGERFALL_COVENANT ] = "EsoUI/Art/AvA/avaCaptureBar_point-inverse_daggerfall.dds" ,
}
local BATTLEGROUND_TEAM_TAIL_TEXTURES =
{
[ BATTLEGROUND_ALLIANCE_FIRE_DRAKES ] = "EsoUI/Art/Battlegrounds/battlegroundsCaptureBar_point-inverse_orange.dds" ,
[ BATTLEGROUND_ALLIANCE_STORM_LORDS ] = "EsoUI/Art/Battlegrounds/battlegroundsCaptureBar_point-inverse_purple.dds" ,
[ BATTLEGROUND_ALLIANCE_PIT_DAEMONS ] = "EsoUI/Art/Battlegrounds/battlegroundsCaptureBar_point-inverse_green.dds" ,
}
-------------------
-- Object functions
-------------------
return object
end
-- Store references to controls
self . lastOwningAlliance = nil
--Set up fade in/out anim
self . capTimeline . startPct = 0
--Register for updates
EVENT_MANAGER : RegisterForEvent ( "GameScore" , EVENT_CAPTURE_AREA_STATUS , function ( ... ) self : ServerUpdate ( ... ) end )
EVENT_MANAGER : RegisterForEvent ( "GameScore" , EVENT_HIDE_OBJECTIVE_STATUS , function ( ... ) self : Hide ( ... ) end )
local KEYBOARD_STYLE = { meter = "ZO_ObjectiveCapture_Keyboard_Template" }
local GAMEPAD_STYLE = { meter = "ZO_ObjectiveCapture_Gamepad_Template" }
ZO_PlatformStyle : New ( function ( style ) self : ApplyPlatformStyle ( style ) end , KEYBOARD_STYLE , GAMEPAD_STYLE )
end
if isBattleground then
return BATTLEGROUND_TEAM_BADGE_TEXTURES [ alliance ]
else
return ALLIANCE_BADGE_TEXTURES [ alliance ]
end
end
if isBattleground then
return BATTLEGROUND_TEAM_BAR_TEXTURES [ alliance ]
else
return ALLIANCE_BAR_TEXTURES [ alliance ]
end
end
if isBattleground then
return BATTLEGROUND_TEAM_POINT_TEXTURES [ alliance ]
else
return ALLIANCE_POINT_TEXTURES [ alliance ]
end
end
if isBattleground then
return BATTLEGROUND_TEAM_TAIL_TEXTURES [ alliance ]
else
return ALLIANCE_TAIL_TEXTURES [ alliance ]
end
end
function ZO_ObjectiveCaptureMeter : ServerUpdate ( eventCode , keepId , objectiveId , battlegroundContext , capturePoolValue , capturePoolSize , capturingPlayers , contestingPlayers , owningAlliance )
-- Short-circuit if we're walking in to an already-owned flag.
if capturePoolValue / capturePoolSize == 1 and ( self . capturePercentage == nil or self . capturePercentage == 1 ) then
return
end
-- Show the bar frame if we're within range
-- Calculate percentage complete
self . capturePercentage = capturePoolValue / capturePoolSize ;
-- Turn on appropriate arrows
local numMoreContestingPlayers = contestingPlayers - capturingPlayers
local numMoreCapturingPlayers = capturingPlayers - contestingPlayers
-- Determine visibility of UI
if owningAlliance ~= 0 then
-- Show alliance-specific UI elements
self . lastOwningAlliance = owningAlliance
-- Show appropriate endcap and arrows
if self . capturePercentage == 1 then
-- Flag is fully captured, start the timer to fade out this UI
else
if capturingPlayers > contestingPlayers then
-- Flag is being captured; make the endcap a point
-- if we are the team that "owns" the flag (i.e. we are capturing the point for our team)
-- then play a sound indicating that the point is being captured
end
elseif capturingPlayers < contestingPlayers then
-- Flag is being contested; make the endcap a tail
-- if we aren't the team that owns the flag (i.e. we are taking the point from another team)
-- then play a sound indicating that the point is being contested
end
else
-- Stalemate
end
end
elseif not self . lastOwningAlliance then -- Checks lastOwning alliance against both nil and 0
-- Hide alliance-specific UI elements
else
-- In this case, the capture bar is going from nonzero to zero, which means we need to tween it down to zero and then
-- hide the alliance-specific textures. This is handled in the AnimationTimeline's OnStop event.
end
if self . capTimeline . endPct == nil then
self . capTimeline . endPct = self . capturePercentage
end
self . capTimeline . startPct = self . capTimeline . endPct
self . capTimeline . endPct = self . capturePercentage
end
local arrowAnchorPointPct -- The percentage of the way around the circle that the arrows should anchor to
-- Goes from 0.0-1.0, where 0.0 is 12.5% around the circle (starting from the top center)
-- and 1.0 is 87.5% of the way around.
if visibleArrows > 0 then
-- We're displaying capturing arrows
-- Our arrows are longer than our capture bar, anchor to the end
else
-- Our capture bar is longer than our arrows, position arrows to follow capture bar
arrowAnchorPointPct = captureBarFillPercentage
end
elseif visibleArrows < 0 then
-- We're displaying contesting arrows
if ARROW_ARCLENGTH * zo_abs ( visibleArrows ) + ENDCAP_ARCLENGTH > ( 1 - captureBarFillPercentage ) * CAPTURE_BAR_ARCLENGTH then
-- Our arrows are longer than our capture bar, anchor to the end
else
-- Our capture bar is longer than our arrows, position arrows to follow capture bar
arrowAnchorPointPct = captureBarFillPercentage
end
else
-- No arrows to display, but keep updating the position for the next time we unhide them
arrowAnchorPointPct = captureBarFillPercentage
end
local textureRotation = - arrowAnchorPointPct * CAPTURE_BAR_ARCLENGTH
end
local captureBarFillPercentage = ( progress * ( self . capTimeline . endPct - self . capTimeline . startPct ) ) + self . capTimeline . startPct ;
self . progressBar : StartFixedCooldown ( ( captureBarFillPercentage * CAPTURE_BAR_LENGTH ) + CAPTURE_BAR_BEGIN_OFFSET , CD_TYPE_RADIAL , CD_TIME_TYPE_TIME_REMAINING , NO_LEADING_EDGE ) -- CD_TIME_TYPE_TIME_REMAINING causes clockwise scroll
end
if self . capturePercentage == 0 then
-- Hide alliance-specific UI elements
end
end
-- Give the fade-out animation time to play before hiding the control
end , FADE_DURATION_MS )
end
end
-- Param numArrows: A number between -3 and 3, determining which arrows to show and which to hide
-- -3 corresponds to 3 contesting arrows, and
-- +3 corresponds to 3 capturing arrows.
-- If the number is <-3 or >3, 3 arrows will be shown in the corresponding direction
-- Hide and show arrows
end
local numArrows = 0
numArrows = 1
numArrows = 2
numArrows = 3
end
end
numArrows = - 1
numArrows = - 2
numArrows = - 3
end
end
end
return numArrows
end
end
--------------
-- Global XML
--------------
end
end
end |