--Lua to expand NVJR Hostmod awards. --for the coffee shop server network --SUPER thanks to RetroStation for help --attn future mocha: --frontrun, curse of the final lap, offroad, out of control, --spinout distance, bananas, hazards, personal space --are all in NVJR Hostmod script - check that if looking for them --if i miss a close-paren and don't find out until the testing --netgame again i officially quit lua rawset(_G, "hq_awards" , CV_RegisterVar({ name = "hq_awards", defaultvalue = "Off", --TURN THIS ON IN YOUR SERVER CONFIG flags = CV_NETVAR, PossibleValue = CV_OnOff })) local function hqa_awardinit(p) if p and p.valid and not p.hqawinit --p.hmfrontruntime = 0 defined in hostmod p.hqawar = 0 p.hqaboom = 0 p.hqawall = 0 p.hqabig = 0 p.hqastar = 0 p.hqabestlap = 0 --best lap p.hqalapmarker = 0 --best lap p.hqaairtime = 0 --airtime p.hqasnipes = 0 --banana snipes p.hqawinit = true --print("Award variables set.") end end local function HQA_ItemPlay(p, inf, source) if not (hq_awards) return end if not (HOSTMOD and CV_FindVar("hm_intermission")) return end if not (source and source.player) then return end if not (p.mo and p.mo.valid) then return end local s = source.player if inf and inf.valid if (s == p) s.hqawar = $ + 0 else s.hqawar = $ + 1 end if ((inf.type == MT_SSMINE) or (inf.type == MT_SSMINE_SHIELD) or (inf.type == MT_MINEEXPLOSION) or (inf.type == MT_SPBEXPLOSION) or (inf.type == MT_SPBEXPLOSION and inf.extravalue1)) if (s == p) s.hqaboom = $ + 0 else s.hqaboom = $ + 1 end end if s.kartstuff[k_invincibilitytimer] s.hqastar = $ + 1 end if not (inf.type == MT_BANANA_SHIELD) and (inf.type == MT_BANANA) and inf.health > 1 --According to Hitfeed, this is how banana snipes happen. What the fuck if s == p s.hqasnipes = $+0 else s.hqasnipes = $+1 end end end end local function HQA_laprecord(p) --ported from KartVR, thanks RetroStation! if p.laps == nil then p.laps = 0 end if p.laps >= 1 if p.laps > p.lastlaps p.hqalap = p.realtime - p.hqalapmarker if (p.hqalap < p.hqabestlap or p.hqabestlap == 0) p.hqabestlap = p.hqalap end p.hqalapmarker = p.realtime end end p.lastlaps = p.laps end addHook("PlayerSpin", HQA_ItemPlay) addHook("PlayerExplode", HQA_ItemPlay) addHook("PlayerSquish", function(p, inflictor, source) if not (hq_awards) return end if not (HOSTMOD and CV_FindVar("hm_intermission")) return end if not (source and source.player) then return end if not (p.mo and p.mo.valid) then return end local s = source.player if (s == p) s = nil else s.hqabig = $+1 end end) local function K_Wallflower(p) if not p.mo or not p.mo.valid return end local mo = p.mo if mo.eflags & MFE_JUSTBOUNCEDWALL p.hqawall = $ + 1 end end local function buildTimeString(x) if x == nil or x == 99999999 then return "N/A" end return (""..string.format("%02d", G_TicsToMinutes(x)).."'"..string.format("%02d", G_TicsToSeconds(x)).."\34"..string.format("%02d", G_TicsToCentiseconds(x))) end addHook("MapLoad", function() if not (hq_awards) return end if not (HOSTMOD and CV_FindVar("hm_intermission")) return end for p in players.iterate if p and p.valid p.hqawinit = false hqa_awardinit(p) end end end) addHook("ThinkFrame", function() if not (hq_awards) return end if not (HOSTMOD and CV_FindVar("hm_intermission")) return end for p in players.iterate if not p.hqawinit hqa_awardinit(p) end K_Wallflower(p) HQA_laprecord(p) if (p.mo and p.mo.valid) if not P_IsObjectOnGround(p.mo) --airtime check p.hqaairtime = $+1 end end end if hm_intermissioncalc() then local demohits = {} local squishers = {} local starpower = {} local wallflowers = {} local warmongers = {} local speedsters = {} --best lap local racers = {} --photo finish local milehighclub = {} --airtime local snipers = {} --banana snipes for p in players.iterate if p and p.valid if p.hqaboom ~= nil then table.insert(demohits, p) end if p.hqabig ~= nil then table.insert(squishers, p) end if p.hqastar ~= nil then table.insert(starpower, p) end if p.hqawall ~= nil then table.insert(wallflowers, p) end if p.hqawar ~= nil then table.insert(warmongers, p) end if p.hqabestlap ~= nil then table.insert(speedsters, p) end --best lap if (p.exiting or (p.pflags & PF_TIMEOVER)) then table.insert(racers, p) end --photo finish if p.hqaairtime ~= nil then table.insert(milehighclub, p) end --airtime if p.hqasnipes ~= nil then table.insert(snipers, p) end --banana snipes end end table.sort(demohits, function(a, b) return a.hqaboom > b.hqaboom end) table.sort(squishers, function(a, b) return a.hqabig > b.hqabig end) table.sort(starpower, function(a, b) return a.hqastar > b.hqastar end) table.sort(wallflowers, function(a, b) return a.hqawall > b.hqawall end) table.sort(warmongers, function(a, b) return a.hqawar> b.hqawar end) table.sort(speedsters, function(a, b) --best lap return a.hqabestlap < b.hqabestlap end) table.sort(racers, function(a, b) --photo finish return a.realtime < b.realtime end) table.sort(milehighclub, function(a, b) --airtime return a.hqaairtime > b.hqaairtime end) table.sort(snipers, function(a, b) --banana snipes return a.hqasnipes > b.hqasnipes end) if demohits[1].hqaboom >= 3 local randquote = "demo" if leveltime %3 == 2 then randquote = "HAE AT 'EM, LADS!" elseif leveltime %3 == 1 then randquote = "How's that feel, ya blockheads!?" elseif leveltime %3 == 0 then randquote = "You're doin' good, lad!" end HM_AddAward("\133DEMOMAN TAKES SKILL","Scored \133"..demohits[1].hqaboom.." hits \128with explosives during this race. "..randquote,demohits[1],15*demohits[1].hqaboom) end if squishers[1].hqabig >= 3 HM_AddAward("\132DOMINATING!","Flattened \132"..squishers[1].hqabig.." other players \128during this race with Grow. Some people are into that, you know.",squishers[1],15*squishers[1].hqabig) end if starpower[1].hqastar >= 3 HM_AddAward("\130RAMMING SPEED!","Rammed \130"..starpower[1].hqastar.." other players \128during this race with Invincibility. You were already going to pass them, why would you do that?",starpower[1],15*starpower[1].hqastar) end if wallflowers[1].hqawall >= 60 HM_AddAward("\139DOOR STUCK", "Bumped into walls \139"..wallflowers[1].hqawall.." times \128this race. Did you get stuck?",wallflowers[1],6*wallflowers[1].hqawall) elseif wallflowers[1].hqawall >= 15 local randtitle = "WALLFLOWER" if leveltime%2 then randtitle = "100! EASY LEFT! NO!!" else randtitle = "SONIC WALL RIDERS" end HM_AddAward("\139"..randtitle,"Bumped into walls \139"..wallflowers[1].hqawall.." times \128this race. Eyes on the road!",wallflowers[1],6*wallflowers[1].hqawall) end if warmongers[1].hqawar >= 5 local randquote = "heavy" if leveltime %3 == 2 then randquote = "HOROSHO!" elseif leveltime %3 == 1 then randquote = "They are dead - not big surprise." elseif leveltime %3 == 0 then randquote = "Do you remember vodka? Sandwich." end HM_AddAward("\133CRY SOME MORE","Scored \133"..warmongers[1].hqawar.." hits \128with attack items this race. "..randquote,warmongers[1],5*warmongers[1].hqawar) end if speedsters[1].hqabestlap > 1 then local lap = buildTimeString(speedsters[1].hqabestlap) local time = speedsters[1].hqabestlap/TICRATE local randtitle = "BEST LAP" if leveltime%3 == 2 then randtitle = "\136WOW! INCREDIBLE!" elseif leveltime%3 == 1 then randtitle = "\136TRACK DAY BRO" elseif leveltime%3 == 0 randtitle = "\136TIME ATTACK" end HM_AddAward(randtitle,"Best lap of the race! \136"..lap, speedsters[1], 5*(time/2)) end if #racers > 1 then local randtitle = "HE DID IT! HE GOT THE CHECKERED FLAG!" if racers[2].realtime - racers[1].realtime == 1 if racers[2].hmfrontruntime > 80*TICRATE local scolor = racers[2].skincolor randtitle = "\133" HM_AddAward(randtitle, "Stole the win from "..hm_color[scolor]..racers[2].name.." \128at the last moment!", racers[1], 200) else randtitle = "\133PHOTO FINISH" HM_AddAward(randtitle, "Claimed victory by one single game tic!", racers[1], 200) end elseif (racers[1].realtime == racers[2].realtime and not (racers[1].pflags & PF_TIMEOVER or racers[2].pflags & PF_TIMEOVER)) then randtitle = "WE HAVE A TIE!" local scolor = racers[2].skincolor HM_AddAward(randtitle, "Tied with "..hm_color[scolor]..racers[2].name.." \128for 1st place!", racers[1], 300) end end if milehighclub[1].hqaairtime > 20*TICRATE then local time = milehighclub[1].hqaairtime/TICRATE local randtitle = "\132RALLY FINLAND" if leveltime%2 then randtitle = "\132I WANNA FLY SKY HIGH" end HM_AddAward(randtitle,"Spent \132"..time.." seconds \128in the air during this race.", milehighclub[1], time*5) end if snipers[1].hqasnipes >= 1 then local snipes = snipers[1].hqasnipes local randquote = "sniper" if leveltime %3 == 2 then randquote = "God save the Queen!" elseif leveltime %3 == 1 then randquote = "Aces!" elseif leveltime %3 == 0 then randquote = "Good on ya!" end HM_AddAward("\130SNIPIN'S A GOOD JOB, MATE", "Landed \130"..snipes.." direct hit(s) \128with bananas this race. "..randquote, snipers[1], 60*snipes) end end end)