mirror of
https://codeberg.org/Duvelcorp/MetaHunt.git
synced 2026-09-30 03:26:06 +00:00
Refine level-up notifications
This commit is contained in:
+62
-14
@@ -96,11 +96,11 @@ local MTH_LT_PetLines = {
|
||||
}
|
||||
|
||||
local MTH_LT_LoyaltyLines = {
|
||||
"has decided you are less terrible than expected.",
|
||||
"has upgraded its opinion of you. Keep the food coming.",
|
||||
"is learning to trust your decision-making. This may be a mistake.",
|
||||
"has accepted the arrangement. The arrangement includes snacks.",
|
||||
"now trusts you more. Do not immediately test this with a cliff.",
|
||||
[2] = "is now Unruly. It tolerates your leadership as long as the food arrives on time.",
|
||||
[3] = "is now Submissive. Your authority has been acknowledged, reluctantly.",
|
||||
[4] = "is now Dependable. It has decided your plans are survivable often enough.",
|
||||
[5] = "is now Faithful. Please do not reward this trust with an elite pull.",
|
||||
[6] = "is your Best Friend. Against all evidence, it trusts you completely.",
|
||||
}
|
||||
|
||||
local function MTH_LT_Store()
|
||||
@@ -154,6 +154,43 @@ local function MTH_LT_FormatRows(plan)
|
||||
return table.concat(labels, ", ")
|
||||
end
|
||||
|
||||
local function MTH_LT_GrowlRankForLevel(level)
|
||||
local rank = math.floor((tonumber(level) or 1) / 10) + 1
|
||||
if rank < 1 then rank = 1 end
|
||||
if rank > 7 then rank = 7 end
|
||||
return rank
|
||||
end
|
||||
|
||||
local function MTH_LT_BuildPetGrowlPlan(level, preview, honored)
|
||||
if type(MTH_TrainerPlan_BuildLevel) ~= "function" then return nil end
|
||||
local plan = MTH_TrainerPlan_BuildLevel("pet", level, { honored = honored and true or false, includeKnown = preview })
|
||||
local growlPlan = {
|
||||
rows = {},
|
||||
unlearned = { count = 0, cost = 0 },
|
||||
}
|
||||
for _, entry in ipairs(plan.rows or {}) do
|
||||
if tostring(entry.row and entry.row.name or "") == "Growl" then
|
||||
table.insert(growlPlan.rows, entry)
|
||||
growlPlan.unlearned.count = growlPlan.unlearned.count + 1
|
||||
growlPlan.unlearned.cost = growlPlan.unlearned.cost + (tonumber(entry.price) or 0)
|
||||
end
|
||||
end
|
||||
return growlPlan
|
||||
end
|
||||
|
||||
local function MTH_LT_HandlePetGrowlLevel(petName, level)
|
||||
if level < 10 or level > 60 or math.mod(level, 10) ~= 0 then return end
|
||||
local rank = MTH_LT_GrowlRankForLevel(level)
|
||||
local known = type(MTH_HT_GetSpellInfo) == "function" and MTH_HT_GetSpellInfo("Growl") or nil
|
||||
if known and (tonumber(known.rankNum) or 0) >= rank then
|
||||
if type(MTH_Growl_OfferForTamedPet) == "function" then
|
||||
MTH_Growl_OfferForTamedPet(petName, level)
|
||||
end
|
||||
elseif MTH_LT_MessageEnabled("petLevelUp", true) then
|
||||
MTH:Print(petName .. " can now learn Growl Rank " .. tostring(rank) .. ". Visit a Pet Trainer to learn it.")
|
||||
end
|
||||
end
|
||||
|
||||
local function MTH_LT_PrintSpellList(plan)
|
||||
local line = ""
|
||||
local isFirstLine = true
|
||||
@@ -190,6 +227,9 @@ local function MTH_LT_AnnounceTraining(kind, level, eventKind, preview)
|
||||
if headline and headline.row and headline.row.rank and headline.row.rank ~= "" then headlineText = headlineText .. " " .. headline.row.rank end
|
||||
local isLevelCap = kind == "hunter" and level == 60
|
||||
if isLevelCap then headlineText = "The hunt is yours" end
|
||||
local isPetGrowlMilestone = kind == "pet" and level >= 10 and level <= 60 and math.mod(level, 10) == 0
|
||||
if isPetGrowlMilestone then headlineText = "Growl Rank " .. tostring(MTH_LT_GrowlRankForLevel(level)) end
|
||||
if kind == "hunter" and not isLevelCap then headlineText = nil end
|
||||
if MTH_LT_MessageEnabled(eventKind == "hunter" and "hunterLevelUp" or "petLevelUp", true) then
|
||||
if kind == "hunter" then
|
||||
MTH:Print("Congratz! You hit level " .. tostring(level) .. ".")
|
||||
@@ -198,8 +238,12 @@ local function MTH_LT_AnnounceTraining(kind, level, eventKind, preview)
|
||||
.. ", but only " .. MTH_LT_FormatCost(honored.unlearned.cost) .. " if you are Honored with the master.")
|
||||
MTH_LT_PrintSpellList(base)
|
||||
else
|
||||
MTH:Print("" .. MTH_LT_FormatRows(base))
|
||||
MTH:Print("Trainer cost: Base " .. MTH_LT_FormatCost(base.unlearned.cost) .. " | Honored " .. MTH_LT_FormatCost(honored.unlearned.cost))
|
||||
local displayPlan = isPetGrowlMilestone and MTH_LT_BuildPetGrowlPlan(level, preview) or base
|
||||
local displayHonoredPlan = isPetGrowlMilestone and MTH_LT_BuildPetGrowlPlan(level, preview, true) or honored
|
||||
if displayPlan and displayPlan.unlearned.count > 0 then
|
||||
MTH:Print(MTH_LT_FormatRows(displayPlan))
|
||||
MTH:Print("Trainer cost: Base " .. MTH_LT_FormatCost(displayPlan.unlearned.cost) .. " | Honored " .. MTH_LT_FormatCost(displayHonoredPlan.unlearned.cost))
|
||||
end
|
||||
end
|
||||
end
|
||||
local isMilestone = kind == "hunter" and (level == 10 or level == 20 or level == 30 or level == 40 or level == 50 or level == 60)
|
||||
@@ -207,9 +251,10 @@ local function MTH_LT_AnnounceTraining(kind, level, eventKind, preview)
|
||||
if type(MTH_FX_IsEnabled) == "function" and MTH_FX_IsEnabled(flag) and type(MTH_Celebrate) == "function" then
|
||||
local subtitle = kind == "hunter" and (MTH_LT_HunterLines[level] or "New training is available.") or "New pet training is available. The trainer wants coin."
|
||||
if isMilestone and type(MTH_CelebrateBlackHole) == "function" then
|
||||
MTH_CelebrateBlackHole("Level " .. tostring(level) .. " - " .. headlineText, subtitle)
|
||||
MTH_CelebrateBlackHole(isLevelCap and headlineText or "Level " .. tostring(level), subtitle)
|
||||
else
|
||||
MTH_Celebrate("Level " .. tostring(level) .. " - " .. headlineText, subtitle, "fanfare", 4.8)
|
||||
local title = headlineText and ("Level " .. tostring(level) .. " - " .. headlineText) or "Level " .. tostring(level)
|
||||
MTH_Celebrate(title, subtitle, "fanfare", 5)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -248,10 +293,10 @@ local function MTH_LT_HandlePetState()
|
||||
local line = MTH_LT_NextLine(store, "petLine", MTH_LT_PetLines)
|
||||
if MTH_LT_MessageEnabled("petLevelUp", true) then MTH:Print(state.name .. " reached level " .. state.level .. ". " .. line) end
|
||||
MTH_LT_AnnounceTraining("pet", state.level, "pet")
|
||||
MTH_LT_HandlePetGrowlLevel(state.name, state.level)
|
||||
end
|
||||
if state.loyalty and state.loyalty > (tonumber(pet.loyalty) or 0) then
|
||||
local line = MTH_LT_NextLine(store, "loyaltyLine", MTH_LT_LoyaltyLines)
|
||||
if state.loyalty == 6 then line = "is your Best Friend. Against all evidence, it trusts you completely." end
|
||||
if state.loyalty and state.loyalty > 1 and state.loyalty > (tonumber(pet.loyalty) or 0) then
|
||||
local line = MTH_LT_LoyaltyLines[state.loyalty] or "has gained a loyalty level. The food arrangement appears to be working."
|
||||
if MTH_LT_MessageEnabled("petLoyaltyUp", true) then MTH:Print(state.name .. " reached Loyalty Level " .. state.loyalty .. ". " .. line) end
|
||||
if type(MTH_FX_IsEnabled) == "function" and MTH_FX_IsEnabled("level.loyalty") and type(MTH_Celebrate) == "function" then
|
||||
MTH_Celebrate(state.name .. " - Loyalty " .. state.loyalty, line, state.loyalty == 6 and "victory" or "fanfare")
|
||||
@@ -283,9 +328,12 @@ function MTH_LevelTracker_Test(kind, level)
|
||||
if kind == "loyalty" then
|
||||
local state = MTH_LT_GetPetState()
|
||||
local loyalty = tonumber(level) or (state and state.loyalty) or 1
|
||||
if loyalty <= 1 then
|
||||
MTH:Print("Pet Loyalty starts at level 1 when you tame a pet. Test levels 2 through 6.")
|
||||
return false
|
||||
end
|
||||
local petName = state and state.name or "Your pet"
|
||||
local line = loyalty == 6 and "is your Best Friend. Against all evidence, it trusts you completely."
|
||||
or MTH_LT_LoyaltyLines[1]
|
||||
local line = MTH_LT_LoyaltyLines[loyalty] or "has gained a loyalty level. The food arrangement appears to be working."
|
||||
MTH:Print(petName .. " reached Loyalty Level " .. tostring(loyalty) .. ". " .. line)
|
||||
if type(MTH_Celebrate) == "function" then
|
||||
MTH_Celebrate(petName .. " - Loyalty " .. tostring(loyalty), line, loyalty == 6 and "victory" or "fanfare")
|
||||
|
||||
@@ -413,7 +413,7 @@ function MTH_Celebrate(title, subtitle, style, displaySeconds)
|
||||
return
|
||||
end
|
||||
style = string.lower(tostring(style or "firework"))
|
||||
local fadeDelay = tonumber(displaySeconds) or 2.1
|
||||
local fadeDelay = tonumber(displaySeconds) or 5
|
||||
if fadeDelay < 0.5 then fadeDelay = 0.5 end
|
||||
|
||||
if style == "starfall" then
|
||||
@@ -536,7 +536,7 @@ local function MTH_FX_ShowPreviewBanner(title, subtitle, r, g, b)
|
||||
Sauce:FadeTo(MTH_FX_MsgFrame, 1, 0.18),
|
||||
Sauce:Pulse(MTH_FX_MsgFrame, 1.18, 0.45),
|
||||
}),
|
||||
Sauce:FadeOut(MTH_FX_MsgFrame, 0.55, "inQuad", { delay = 2.1 }),
|
||||
Sauce:FadeOut(MTH_FX_MsgFrame, 0.55, "inQuad", { delay = 5 }),
|
||||
})
|
||||
end
|
||||
|
||||
@@ -695,7 +695,7 @@ function MTH_CelebratePreview(style)
|
||||
table.insert(steps, Sauce:Run(function()
|
||||
MTH_CelebratePreview(previewStyle)
|
||||
end, { defer = true }))
|
||||
table.insert(steps, Sauce:Delay(3.7))
|
||||
table.insert(steps, Sauce:Delay(5.7))
|
||||
i = i + 1
|
||||
end
|
||||
Sauce:Sequence(steps)
|
||||
|
||||
Reference in New Issue
Block a user