-- Enables the addon's functionality at all. local CVAR_BoostQueueing = CV_RegisterVar( { name = "bq_enable", defaultvalue = "On", flags = CV_NETVAR, PossibleValue = CV_YesNo } ) local CVAR_AdditiveMTs = CV_RegisterVar( { name = "am_enable", defaultvalue = "On", flags = CV_NETVAR, PossibleValue = CV_YesNo } ) local CVAR_MTAddMult = CV_RegisterVar( { name = "am_mtaddmult", defaultvalue = "1.0", flags = CV_NETVAR|CV_FLOAT, PossibleValue = CV_Unsigned } ) local defaultTurboTimer = { blue = 20, red = 50, rainbow = 125 } local loadedHostmodExtras = false -- the most epic optimization local FRACUNIT = FRACUNIT local function boostQueueHandling(mobj) if CVAR_BoostQueueing.value == 0 and CVAR_MTAddMult.value == 0 then return end local player = mobj.player mobj.storedMT = $ or 0 mobj.oldMTValue = $ or 0 mobj.applyMTAfter = $ or false if P_PlayerInPain(player) then mobj.storedMT = 0 mobj.oldMTValue = 0 mobj.applyMTAfter = false end local sneakerTimer = player.kartstuff[k_sneakertimer] -- have to recreate this because otherwise mts while boosting get eaten if player.kartstuff[k_driftend] == 1 then local driftSpark = player.kartstuff[k_driftcharge] if driftSpark > 0 then -- afaik there is no good mathematical way of doing this so don't @ me local MTobtained = 0 local driftSparkValue = K_GetKartDriftSparkValue(player) if driftSpark >= (driftSparkValue * 4) then MTobtained = defaultTurboTimer.rainbow elseif driftSpark >= (driftSparkValue * 2) then MTobtained = defaultTurboTimer.red elseif driftSpark >= driftSparkValue then MTobtained = defaultTurboTimer.blue end if CVAR_AdditiveMTs.value == 1 and CVAR_MTAddMult.value > 0 then local addedValue = FixedInt(FixedMul(MTobtained * FRACUNIT, CVAR_MTAddMult.value)) if CVAR_BoostQueueing.value == 1 and sneakerTimer > 0 then mobj.storedMT = $ + addedValue -- print("Added drift frames: " + mobj.storedMT + "(" + addedValue + ")") else player.kartstuff[k_driftboost] = $ + addedValue -- print("Added drift frames: " + player.kartstuff[k_driftboost] + "(" + addedValue + ")") end elseif CVAR_BoostQueueing.value == 1 if sneakerTimer > 0 then if mobj.storedMT < MTobtained then mobj.storedMT = MTobtained -- print("Set drift frames: " + mobj.storedMT) end end end end end if CVAR_BoostQueueing.value == 1 then if sneakerTimer > 0 then mobj.applyMTAfter = true if mobj.oldMTValue > 0 then -- print("Caught drift frames from before boost: " + mobj.oldMTValue) mobj.storedMT = mobj.oldMTValue mobj.oldMTValue = 0 end elseif mobj.applyMTAfter == true then -- print("Final drift frames after boost: " + mobj.storedMT) player.kartstuff[k_driftboost] = mobj.storedMT mobj.storedMT = 0 mobj.applyMTAfter = false else mobj.oldMTValue = player.kartstuff[k_driftboost] end end -- print("Sneaker Timer: " + sneakerTimer) -- print("Drift Timer: " + player.kartstuff[k_driftboost]) end local function hostmodHandling(mapnum) local HMscoreBoardCVAR = CV_FindVar("hm_scoreboard") if HMscoreBoardCVAR ~= nil and loadedHostmodExtras == false then HM_Scoreboard_AddTip({msg = "With Boost Queueing, drifting into boost pads will result ".. "in the mini-turbo appearing at the end of the boost for an extra pinch of speed!", cvartrue = "bq_enable"}) HM_Scoreboard_AddTip({msg = "With Additive Miniturbos and Boost Queueing, it's possible to build up significant ".. "amounts of mini-turbos before your boosts run out, making you go faster for longer!", cvartrue = "am_enable"}) HM_Scoreboard_AddMod({disp = "Boost Queueing", var = "bq_enable"}) HM_Scoreboard_AddMod({disp = "Additive Miniturbos", var = "am_enable"}) loadedHostmodExtras = true end end addHook("MobjThinker", boostQueueHandling, MT_PLAYER) addHook("MapLoad", hostmodHandling)