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 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
ZO_CROWN_CRATE_TRIGGER_COMMANDS =
{
SCENE_SHOWN = "OnSceneShowing" ,
CAT_SUMMON_COMPLETE = "UI_Greet" , -- Anim Note
CAT_GREETING_COMPLETE = "UI_OpenManifest" , -- Anim Note
MANIFEST_IN_COMPLETE = "OnManifestInComplete" ,
DEAL_REQUESTED = "OnDealRequested" ,
MANIFEST_OUT_COMPLETE = "OnManifestOutComplete" ,
PRIMARY_DEAL_COMPLETE_CAT = "UI_Deal_Primary" , -- Anim Note
PRIMARY_DEAL_COMPLETE = "OnPrimaryDealComplete" ,
BONUS_DEAL_COMPLETE_CAT = "UI_Deal_Bonus" , -- Anim Note
BONUS_DEAL_COMPLETE = "OnBonusDealComplete" ,
CARD_REVEALED = "OnCardRevealed" ,
CARD_OUT_COMPLETE = "OnCardOutComplete" ,
CARD_DEAL_COMPLETE = "OnCardDealComplete" ,
CARD_SELECTED = "OnCardSelected" ,
FLIP_CARD = "OnFlipCard" ,
CARD_DESELECTED = "OnCardDeselected" ,
CARD_FLIP_COMPLETE = "OnFlipComplete" ,
CARD_GEMIFY_COMPLETE = "OnGemifyComplete" ,
CARD_LEAVE = "OnCardLeave" ,
BACK_TO_MANIFEST = "BackToManifest" ,
GEMIFICATION_HIDDEN = "GemificationHidden" ,
}
end
function ZO_CrownCratesStateMachine : Initialize ( manager , packChoosing , packOpening , gemificationKeyboard , gemificationGamepad , gemificationSlot )
--States--
local states =
{
MANIFEST_OUT_FOR_GEMIFICATION = ZO_StateMachine_State : New ( self , "MANIFEST_OUT_FOR_GEMIFICATION" ) , --15
}
--Edges--
local edges =
{
FRAMING_PLAYER_TO_SUMMON_CAT = ZO_StateMachine_Edge : New ( states . FRAMING_PLAYER , states . SUMMON_CAT ) , --14 -> 2
SUMMON_CAT_TO_MANIFEST_IN = ZO_StateMachine_Edge : New ( states . SUMMON_CAT , states . MANIFEST_IN ) , --2 -> 3
MANIFEST_TO_MANIFEST_OUT_FOR_DEAL = ZO_StateMachine_Edge : New ( states . MANIFEST , states . MANIFEST_OUT_FOR_DEAL ) , --4 -> 5
MANIFEST_OUT_FOR_DEAL_TO_MANIFEST_IN = ZO_StateMachine_Edge : New ( states . MANIFEST_OUT_FOR_DEAL , states . MANIFEST_IN ) , --5 -> 3
MANIFEST_OUT_FOR_DEAL_TO_CAT_PRIMARY_DEAL = ZO_StateMachine_Edge : New ( states . MANIFEST_OUT_FOR_DEAL , states . CAT_PRIMARY_DEAL ) , --5 -> 6
CAT_PRIMARY_DEAL_TO_UI_PRIMARY_DEAL = ZO_StateMachine_Edge : New ( states . CAT_PRIMARY_DEAL , states . UI_PRIMARY_DEAL ) , --6 -> 7
UI_PRIMARY_DEAL_TO_ACTIVE_HAND_MANIPULATION = ZO_StateMachine_Edge : New ( states . UI_PRIMARY_DEAL , states . ACTIVE_HAND_MANIPULATION ) , --7 -> 10
UI_PRIMARY_DEAL_TO_CAT_BONUS_DEAL = ZO_StateMachine_Edge : New ( states . UI_PRIMARY_DEAL , states . CAT_BONUS_DEAL ) , --7 -> 8
CAT_BONUS_DEAL_TO_UI_BONUS_DEAL = ZO_StateMachine_Edge : New ( states . CAT_BONUS_DEAL , states . UI_BONUS_DEAL ) , --8 -> 9
UI_BONUS_DEAL_TO_ACTIVE_HAND_MANIPULATION = ZO_StateMachine_Edge : New ( states . UI_BONUS_DEAL , states . ACTIVE_HAND_MANIPULATION ) , --9 -> 10
ACTIVE_HAND_MANIPULATION_TO_ALL_REVEALED = ZO_StateMachine_Edge : New ( states . ACTIVE_HAND_MANIPULATION , states . ALL_REVEALED ) , --10 -> 11
ALL_REVEALED_TO_CARDS_OUT_BACK = ZO_StateMachine_Edge : New ( states . ALL_REVEALED , states . CARDS_OUT_BACK ) , --11 -> 12 (Back to Manifest)
ALL_REVEALED_TO_CARDS_OUT_NEXT = ZO_StateMachine_Edge : New ( states . ALL_REVEALED , states . CARDS_OUT_NEXT ) , --11 -> 13 (Open next pack)
CARDS_OUT_BACK_TO_MANIFEST_IN = ZO_StateMachine_Edge : New ( states . CARDS_OUT_BACK , states . MANIFEST_IN ) , --12 -> 3
CARDS_OUT_NEXT_TO_MANIFEST_IN = ZO_StateMachine_Edge : New ( states . CARDS_OUT_NEXT , states . MANIFEST_IN ) , --13 -> 3
CARDS_OUT_NEXT_TO_CAT_PRIMARY_DEAL = ZO_StateMachine_Edge : New ( states . CARDS_OUT_NEXT , states . CAT_PRIMARY_DEAL ) , --13 -> 6
MANIFEST_TO_MANIFEST_OUT_FOR_GEMIFICATION = ZO_StateMachine_Edge : New ( states . MANIFEST , states . MANIFEST_OUT_FOR_GEMIFICATION ) , --4 -> 15
MANIFEST_OUT_FOR_GEMIFICATION_TO_GEMIFICATION = ZO_StateMachine_Edge : New ( states . MANIFEST_OUT_FOR_GEMIFICATION , states . GEMIFICATION ) , --15 -> 16
GEMIFICATION_TO_MANIFEST_IN = ZO_StateMachine_Edge : New ( states . GEMIFICATION , states . MANIFEST_IN ) , --16 -> 3
}
--Triggers--
local triggers
do
local MANIFEST_TO_GEMIFICATION_KEYBIND =
{
alignment = KEYBIND_STRIP_ALIGN_CENTER ,
keybind = "UI_SHORTCUT_TERTIARY" ,
local gemIcon = ZO_Currency_GetPlatformFormattedCurrencyIcon ( ZO_Currency_MarketCurrencyToUICurrency ( MKCT_CROWN_GEMS ) , "100%" )
end ,
gamepadOrder = 10000 ,
order = - 10000 ,
}
local ALL_REVEALED_TO_CARDS_OUT_NEXT_KEYBIND =
{
alignment = KEYBIND_STRIP_ALIGN_CENTER ,
keybind = "UI_SHORTCUT_PRIMARY" ,
local remainingCountColor = remainingCount == 0 and ZO_ERROR_COLOR or ZO_SELECTED_TEXT
end ,
end
if freeSlots < numSlotsForCrate then
return false , zo_strformat ( GetString ( "SI_LOOTCRATEOPENRESPONSE" , LOOT_CRATE_OPEN_RESPONSE_FAIL_NO_INVENTORY_SPACE ) , numSlotsForCrate - freeSlots )
end
return true
end
}
return response == LOOT_CRATE_OPEN_RESPONSE_SUCCESS
end
return response ~= LOOT_CRATE_OPEN_RESPONSE_SUCCESS
end
local function CreateServerResponseAndAnimationMultiTrigger ( animationCompleteTriggerCommand , serverResponseFilterCallback , animationEventCountCallback )
local serverResponseTrigger = ZO_StateMachine_TriggerEventManager : New ( EVENT_CROWN_CRATE_OPEN_RESPONSE )
if animationEventCountCallback then
end
end
local packsOnPage = self . packChoosing : GetNumPacksToDisplayOnPage ( self . packChoosing : GetCurrentPage ( ) )
-- If there are no packs, expect the manifest to tell us it's done immediately
return packsOnPage > 0 and packsOnPage or 1
end
triggers =
{
START_TO_FRAMING_PLAYER = ZO_StateMachine_TriggerStateCallback : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . SCENE_SHOWN ) , --1 -> 14
FRAMING_PLAYER_TO_SUMMON_CAT = ZO_StateMachine_TriggerEventManager : New ( EVENT_GAME_CAMERA_CHARACTER_FRAMING_STARTED ) , --14 -> 2
SUMMON_CAT_TO_MANIFEST_IN = ZO_StateMachine_TriggerAnimNote : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . CAT_SUMMON_COMPLETE ) , --2 -> 3
MANIFEST_IN_TO_MANIFEST = ZO_StateMachine_TriggerStateCallback : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . MANIFEST_IN_COMPLETE ) , --3 -> 4
MANIFEST_TO_MANIFEST_OUT_FOR_DEAL = ZO_StateMachine_TriggerStateCallback : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . DEAL_REQUESTED ) , --4 -> 5
MANIFEST_OUT_FOR_DEAL_TO_MANIFEST_IN = CreateServerResponseAndAnimationMultiTrigger ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . MANIFEST_OUT_COMPLETE , FilterOpenResponseFailed , ManifestOutEventCountCallback ) , --5 -> 3
MANIFEST_OUT_FOR_DEAL_TO_CAT_PRIMARY_DEAL = CreateServerResponseAndAnimationMultiTrigger ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . MANIFEST_OUT_COMPLETE , FilterOpenResponseSuccess , ManifestOutEventCountCallback ) , --5 -> 6
CAT_PRIMARY_DEAL_TO_UI_PRIMARY_DEAL = ZO_StateMachine_TriggerAnimNote : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . PRIMARY_DEAL_COMPLETE_CAT ) , --6 -> 7
UI_PRIMARY_DEAL_TO_ACTIVE_HAND_MANIPULATION = ZO_StateMachine_TriggerStateCallback : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . PRIMARY_DEAL_COMPLETE ) , --7 -> 10
UI_PRIMARY_DEAL_TO_CAT_BONUS_DEAL = ZO_StateMachine_TriggerStateCallback : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . PRIMARY_DEAL_COMPLETE ) , --7 -> 8
CAT_BONUS_DEAL_TO_UI_BONUS_DEAL = ZO_StateMachine_TriggerAnimNote : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . BONUS_DEAL_COMPLETE_CAT ) , --8 -> 9
UI_BONUS_DEAL_TO_ACTIVE_HAND_MANIPULATION = ZO_StateMachine_TriggerStateCallback : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . BONUS_DEAL_COMPLETE ) , --9 -> 10
ACTIVE_HAND_MANIPULATION_TO_ALL_REVEALED = ZO_StateMachine_TriggerStateCallback : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . CARD_REVEALED ) , --10 -> 11
ALL_REVEALED_TO_CARDS_OUT_BACK = ZO_StateMachine_TriggerStateCallback : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . BACK_TO_MANIFEST ) , --11 -> 12
ALL_REVEALED_TO_CARDS_OUT_NEXT = ZO_StateMachine_TriggerKeybind : New ( ALL_REVEALED_TO_CARDS_OUT_NEXT_KEYBIND ) , --11 -> 13
CARDS_OUT_BACK_TO_MANIFEST_IN = ZO_StateMachine_TriggerStateCallback : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . CARD_OUT_COMPLETE ) , --12 -> 3
CARDS_OUT_NEXT_TO_MANIFEST_IN = CreateServerResponseAndAnimationMultiTrigger ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . CARD_OUT_COMPLETE , FilterOpenResponseFailed , GetNumCurrentCrownCrateTotalRewards ) , --13 -> 3
CARDS_OUT_NEXT_TO_CAT_PRIMARY_DEAL = CreateServerResponseAndAnimationMultiTrigger ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . CARD_OUT_COMPLETE , FilterOpenResponseSuccess , GetNumCurrentCrownCrateTotalRewards ) , --13 -> 6
MANIFEST_TO_MANIFEST_OUT_FOR_GEMIFICATION = ZO_StateMachine_TriggerKeybind : New ( MANIFEST_TO_GEMIFICATION_KEYBIND ) , --4 -> 15
MANIFEST_OUT_FOR_GEMIFICATION_TO_GEMIFICATION = ZO_StateMachine_TriggerStateCallback : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . MANIFEST_OUT_COMPLETE ) , --15 -> 16
GEMIFICATION_TO_MANIFEST_IN = ZO_StateMachine_TriggerStateCallback : New ( ZO_CROWN_CRATE_TRIGGER_COMMANDS . GEMIFICATION_HIDDEN ) --16 -> 3
}
--Add Conditionals
triggers . UI_PRIMARY_DEAL_TO_ACTIVE_HAND_MANIPULATION : SetEventCount ( GetNumCurrentCrownCratePrimaryRewards )
triggers . UI_BONUS_DEAL_TO_ACTIVE_HAND_MANIPULATION : SetEventCount ( GetNumCurrentCrownCrateBonusRewards )
triggers . ACTIVE_HAND_MANIPULATION_TO_ALL_REVEALED : SetEventCount ( GetNumCurrentCrownCrateTotalRewards )
end
--Add triggers to edges--
edges . MANIFEST_OUT_FOR_DEAL_TO_MANIFEST_IN : AddTrigger ( triggers . MANIFEST_OUT_FOR_DEAL_TO_MANIFEST_IN )
edges . MANIFEST_OUT_FOR_DEAL_TO_CAT_PRIMARY_DEAL : AddTrigger ( triggers . MANIFEST_OUT_FOR_DEAL_TO_CAT_PRIMARY_DEAL )
edges . UI_PRIMARY_DEAL_TO_ACTIVE_HAND_MANIPULATION : AddTrigger ( triggers . UI_PRIMARY_DEAL_TO_ACTIVE_HAND_MANIPULATION )
edges . UI_BONUS_DEAL_TO_ACTIVE_HAND_MANIPULATION : AddTrigger ( triggers . UI_BONUS_DEAL_TO_ACTIVE_HAND_MANIPULATION )
edges . ACTIVE_HAND_MANIPULATION_TO_ALL_REVEALED : AddTrigger ( triggers . ACTIVE_HAND_MANIPULATION_TO_ALL_REVEALED )
edges . MANIFEST_TO_MANIFEST_OUT_FOR_GEMIFICATION : AddTrigger ( triggers . MANIFEST_TO_MANIFEST_OUT_FOR_GEMIFICATION )
edges . MANIFEST_OUT_FOR_GEMIFICATION_TO_GEMIFICATION : AddTrigger ( triggers . MANIFEST_OUT_FOR_GEMIFICATION_TO_GEMIFICATION )
--Add Conditionals--
edges . UI_PRIMARY_DEAL_TO_ACTIVE_HAND_MANIPULATION : SetConditional ( function ( ) return GetNumCurrentCrownCrateBonusRewards ( ) == 0 end )
edges . UI_PRIMARY_DEAL_TO_CAT_BONUS_DEAL : SetConditional ( function ( ) return GetNumCurrentCrownCrateBonusRewards ( ) > 0 end )
do
-- This essentially returns how many packs we expect to be on the first page.
-- Since the manifest possibly hasn't actually begun loading yet at this point, we can't be sure it has page data, so determine it by hand
if numOwnedCrateTypes == 0 then
-- If there are no packs, expect the manifest to tell us it's done immediately
return 1
elseif numOwnedCrateTypes > ZO_CROWN_CRATES_PACK_CHOOSING_PACKS_PER_PAGE then
return ZO_CROWN_CRATES_PACK_CHOOSING_PACKS_PER_PAGE
else
return numOwnedCrateTypes
end
end
end
--Register actions on states--
local IMMEDIATE = true
end )
end )
end )
--NPC passively reacts to your current supply of crates
if numOwnedCrateTypes == 0 then
elseif numOwnedCrateTypes == 1 then
else
end
end )
end )
end )
--Start the flourish while we wait so it doesn't feel unresponsive
end )
end )
end )
local gemificationSystem
else
end
end )
end )
end )
end )
local success , worldX , worldY , worldZ = GetCrownCrateNPCBoneWorldPosition ( GetCrownCrateNPCCardThrowingBoneName ( ) )
if success then
local localX , localY , localZ = self . manager : GetCameraLocalPositionFromWorldPosition ( worldX , worldY , worldZ )
end
end )
end )
end )
local success , worldX , worldY , worldZ = GetCrownCrateNPCBoneWorldPosition ( GetCrownCrateNPCCardThrowingBoneName ( ) )
if success then
local localX , localY , localZ = self . manager : GetCameraLocalPositionFromWorldPosition ( worldX , worldY , worldZ )
end
end )
end )
end )
--NPC passively reacts to you being done, depending on your current supply of crates
else
end
end )
end )
end )
--Start the shuffle while we wait so it doesn't feel unresponsive
end )
{
[ states . MANIFEST_OUT_FOR_DEAL ] = true ,
[ states . CAT_PRIMARY_DEAL ] = true ,
[ states . UI_PRIMARY_DEAL ] = true ,
[ states . CAT_BONUS_DEAL ] = true ,
[ states . UI_BONUS_DEAL ] = true ,
[ states . ACTIVE_HAND_MANIPULATION ] = true ,
}
end
end
end
end
end
return false
else
return true
end
end |