//trying to make a custom intermission scoreboard by basing it off the neo scoreboard.lua --freeman#7626 //thank you snu and tyron because without your existing work I probably would have never figured this out //WHAT YOU NEED TO KNOW FOR INTEROPERABILITY IS THE FOLLOWING: //this script will hold everyone in statis when it thinks the round ends //and will effectively avoid doing intermisison at all until its done //this means INTERMISSION THINKERS WONT RUN BEFORE THIS AND THEY CANT //handle whatever you need to before intermission. These are the rawsets to do it: //hm_intermissioncalc - Returns true the tic that this custom intermission starts //use it to make a final calculation of all of your awards you want to add //hm_addaward(title, description, player, weight, bonuspoints) //Adds an award to the table of awards to be picked from. Awards are picked //at random using weight as a factor of how likely it is to be picked. I highly //suggest your awards calculate their weight based on how standout the number is. //Title, Description can both use color codes. Descriptions are auto wrapped. //Player is the player getting it. Using hm_addaward twice adds the award to the table twice, //so don't do that unless you want it getting picked twice. //bonus points is half implemented, will add points to server score if award is given. //hm_resultsautotrigger (true/false) //This is a rawset that you can change in any other script. If you are writing //stuff for an alternative gamemode that doesn't have normal race exit conditions, //you can stop this script from trying to auto-trigger results when it thinks //everyone is done. Instead, you'll handle your own exit logic and then... //hm_forcetriggerresults //running this function forces this script to hold everyone in stasis and run //its intermission. You can use it with the above to make your own exit conditions. //notes about the award drawing at the end: //the picking function only picks 5 awards cause that's all that will fit really //the drawer will only keep drawing stuff until it gets down to about 170 pixels, //then it automatically stops trying to draw more stuff off-screen. Its not broken, //its just to stop the scoreboard from looking ugly. //if we're using this heap of shit at all local hm_intermission = CV_RegisterVar({ name = "hm_intermission", defaultvalue = "On", //TODO: HEY RETARD MAKE THIS OFF WHEN YOU ARE DONE flags = CV_NETVAR, possiblevalue = CV_OnOff}) //forcibly draws the scoreboard for layout testing local hm_intermissiondebug = CV_RegisterVar({ name = "hm_intermissiondebug", defaultvalue = "Off", //TODO: HEY RETARD MAKE THIS OFF WHEN YOU ARE DONE flags = CV_NETVAR|CV_NOSHOWHELP, possiblevalue = CV_OnOff}) local hm_inttime = CV_RegisterVar({ name = "hm_inttime", defaultvalue = 20, flags = CV_NETVAR, possiblevalue = CV_Natural}) local hm_awarddebug = CV_RegisterVar({ name = "hm_awarddebug", defaultvalue = "Off", //TODO: HEY RETARD MAKE THIS OFF SERIOUSLY flags = CV_NETVAR, possiblevalue = CV_OnOff}) local hm_awardbonuspoints = CV_RegisterVar({ name = "hm_awardbonuspoints", defaultvalue = "Off", flags = CV_NETVAR, possiblevalue = CV_OnOff}) local hm_stks = CV_RegisterVar({ name = "hm_stattrackerkartscore", defaultvalue = "On", flags = CV_NETVAR, possiblevalue = CV_OnOff}) local awards = {} local chosenawards = {} local starttime = 6*TICRATE + (3*TICRATE/4) // leveltime when race actually starts (~235) local introtime = 108+5 // leveltime when countdown, pre starttime, starts 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 //just for future reference I could not for the life of me grasp why comments below //the above line wouldn't appear in the comment font until I spaced some stuff //and it would reset every time I saved the thing and it literally drove me insane for several days //only now have I figured out that using '"' to get a double quote in the time string //was being interpreted as an open quote so nothing after it would be interpreted as a comment //using the ascii dec code of "\34" has effectively resolved this abomination --add an award title and description to be printed (include color codes if you want it colored) --description will auto-wrap when printed (may cut off color codes) --include the player who will be displayed as receiving it --if this player disappears when the award is drawn, the award will be removed --weight determines how likely the award is to appear, higher is more likely --it is probably best to base your weight off a numerical function of whatever stat you are tracking so real stand-outs show up --unless you want to give an award out multiple times, try to only award one player when you decide who to give it to rawset(_G, "HM_AddAward", function(title, desc, pl, weight, bonuspoints) if type(title) != "string" then error("HM_AddAward error: arg 1 title expected string, got "..type(title)) return end if type(desc) != "string" then error("HM_AddAward error: arg 2 desc expected string, got "..type(desc)) return end if pl == nil then return end if type(pl) != "userdata" then error("HM_AddAward error: arg 3 pl expected userdata/player, got "..type(pl)) return end if type(weight) != "number" then error("HM_AddAward error: arg 4 weight expected number, got "..type(weight)) return end if type(bonuspoints) != "number" then bonuspoints = 0 end local handled = false for i, k in pairs(awards) if awards[i].title == title then //print("HM_AddAward already has award for "..title..", overwriting...") awards[i] = {title=title, desc=desc, pl=pl, weight=weight, bonuspoints=bonuspoints} //print("HM_AddAward new value for "..title.." is: "..desc..", "..pl.name..", "..weight) handled = true end end if not handled then //print("HM_AddAward adding new award for "..title..": "..desc..", "..pl.name..", "..weight) table.insert(awards, {title=title, desc=desc, pl=pl, weight=weight}) end if bonuspoints > 0 and hm_awardbonuspoints.value then if hm_awarddebug.value then print("Adding "..bonuspoints.." extra score to "..pl.name.." for award titled "..title) end pl.score = $+bonuspoints end end) //this works off a weighted picker imitated from choose.lua //props to tyron or whomever wrote that for demonstrating a way that this can work local function chooseawards(awards, amt) //print("Attempting to pick awards: ("..amt..")") if not awards then error("chooseawards was passed without a table to choose awards from, aborting...") return elseif type(awards) != "table" then error("chooseawards wasn't provided a table, aborting...") return elseif not amt or type(amt) != "number" then error("chooseawards amount was invalid, aborting...") return end local allawards = awards if hm_awarddebug.value then print("AWARD DEBUG - CURRENT AWARDS TABLE:") print("NAME, PLAYER, WEIGHT") local tweight = 0 for i=1, #allawards print(allawards[i].title..", "..allawards[i].pl.name..", "..allawards[i].weight) tweight = $+allawards[i].weight end print("TOTAL WEIGHT: "..tweight) end if #awards <= amt then //print("Not enough awards to bother picking from, returning the whole list...") return awards end //lol local pickedawards = {} local weights = {} local totalweight = 0 local index = 0 //print("Setting up award pickertables...") while index < #allawards index = $ + 1 table.insert(weights, awards[index].weight) totalweight = $ + awards[index].weight //print("Added "..awards[index].title.." to table (wgt: "..awards[index].weight.."), total weight now "..totalweight) end //print("Finished index, total weight: "..totalweight.." for "..#weights.." total awards") while #pickedawards < amt do //print("Top of while loop, picked so far is "..#pickedawards) local target = P_RandomRange(1, totalweight) //print("Target number now "..target) //print("awards to pick from right now:") for i=1, #allawards //print(allawards[i].title) end for k, v in ipairs(weights) do if #pickedawards >= amt then return pickedawards end //print("Checking "..target.." versus weight "..weights[k]) if target <= tonumber(weights[k]) then table.insert(pickedawards, allawards[k]) totalweight = $-weights[k] table.remove(allawards, k) table.remove(weights, k) target = P_RandomRange(1, totalweight) //print("Pick valid, new total weight is "..totalweight..", new target number is "..target.." and remaining awards is "..#allawards) break end target = $ - weights[k] //print("Pick not valid, old target subtracted by "..weights[k]..", new target now "..target) //print("Reached end of for loop, exiting...") end //print("reached end of while loop, goin back") end //print("exited while loop, returning sauce") return pickedawards end //you can use this to enable/disable this script from trying to auto-detect round end //if you have specific end conditions that this script can't detect, set this to false and use force trigger rawset(_G, "HM_ResultsAutoTrigger", true) local st_enabled = CV_FindVar("st_enabled") local st_enableks = CV_FindVar("st_enableks") //a lot of this is imitated from snu's TSR checks for finish //this does a generic check for exiting players and tries to trigger results when it thinks the game is over local function hm_tryTriggerResults() if not HM_ResultsAutoTrigger then return end if server.hmfinishstate then return end local pdone, ptotal = 0, 0 for p in players.iterate if not p.spectator then ptotal = $+1 end if p.exiting and p.exiting < 8 then p.exiting = 8 end if (p.exiting and p.exiting == 8) or (p.pflags&PF_TIMEOVER) then if not p.spectator then pdone = $+1 end end end if not ptotal then return end if (pdone >= ptotal or exitcountdown == 8) and not server.hmfinishstate then local intermissiontime = hm_inttime.value*TICRATE K_SetExitCountdown(TICRATE*6000) server.hmfinishstate = true server.hmfinishtimer = intermissiontime st_enabled = CV_FindVar("st_enabled") st_enableks = CV_FindVar("st_enableks") for p in players.iterate if p and p.valid then p.exiting = 8 p.powers[pw_nocontrol] = intermissiontime end end end end //if your game mode has exit conditions this script won't readily detect, use this //to force the results to trigger after you've handled what you need to rawset(_G, "hm_forceTriggerResults", function() if not hm_intermission.value then G_ExitLevel() error("A script tried to force trigger hostmod results, but hm_intermission isn't on, running G_ExitLevel() instead...") return end local intermissiontime = hm_inttime.value*TICRATE for p in players.iterate if p and p.valid then p.exiting = 8 p.powers[pw_nocontrol] = intermissiontime end end server.hmfinishstate = true server.hmfinishtimer = intermissiontime K_SetExitCountdown(TICRATE*6000) end) local function hm_handleFinish() if not server.hmfinishstate then return end server.hmfinishtimer = $-1 K_SetExitCountdown(TICRATE*6000) -- Just keep setting this to ensure hardcode doesn't exit us if server.hmfinishtimer == 0 then G_ExitLevel() end end addHook("IntermissionThinker", function() if server.hmintermissionthinked then return end server.hmfinishstate = false server.hmfinishtimer = 0 //if server.hmstoredinttime then //COM_BufAddText(server, "inttime "..server.hmstoredinttime) //server.hmstoredinttime = nil //end awards = {} server.hmintermissionthinked = true end) local function hm_interinit(p) if p and p.valid and not p.hminit then p.hmfrontruntime = 0 //tics in position 1 p.hmoffroadtime = 0 //tics spent in offroad p.hmnocontroltime = 0 //tics spent out of control (falling, crushed, spunout, ect) p.hmspinlastx = 0 p.hmspinlasty = 0 p.hmspinlastz = 0 p.hmspinoutdist = 0 //(for comparison to current pos which will be added here) p.hmbananahits = 0 //number of bananas player hit this race p.hmtspinouts = 0 //total times spun out p.hmorbithits = 0 //times hit orbiting items p.hmoldscore = p.score or 0 //we'll use this to see how much their score goes up/down p.hmfinishpoints = 0 p.hminit = true //xelork p.xestolen = 0 p.xebump = 0 p.xesink = 0 p.xedefend = 0 p.xeoops = 0 p.xespb = 0 p.xespbwin = false p.xespblost = false p.xespbtime = 0 //Lighto p.backwardsdrive = 0 end end addHook("MapLoad",function() server.hmintermissionthinked = false server.hmfinishstate = false server.hmfinishtimer = hm_inttime.value*TICRATE hud.enable("gametypeinfo") hud.enable("minimap") hud.enable("item") hud.enable("position") hud.enable("check") hud.enable("minirankings") hud.enable("speedometer") if hpmod and not hpmod_showbar then hpmod_showbar = true end if minrankplus and not minrankplus.enabled then minrankplus.enabled = true end if not hm_intermission.value then return end //variable setup for basic awards for p in players.iterate if p and p.valid then p.hminit = false hm_interinit(p) end end end) addHook("ThinkFrame", function() if not hm_intermission.value then return end hm_tryTriggerResults() hm_handleFinish() for p in players.iterate if not p.hminit then hm_interinit(p) end end //debug shit if false then local plyr = nil for p in players.iterate if p and p.valid then plyr = p break end end if leveltime == 4*TICRATE then //debug shit HM_AddAward("Cinematic Experience","Spent\135 32%\128 of the race spun-out, crushed, falling, or respawning.",plyr,100) HM_AddAward("The fresh prince","Now this is a story all about how my life got flipped turned upside down so I'd like to take a minute just sit right there i'll tell you all about how I became the prince of Bel-Air",plyr,999) HM_AddAward("You're Gonna Go Far, Kid","Travelled a total distance of \1351269\128 frac units while spun out.",plyr,120) end end //end horrid debug shit if leveltime >= 235 and not server.hmfinishstate then for p in players.iterate if not p.spectator then if p.hmspinlastx == nil then p.hmspinlastx = 0 end if p.hmspinlasty == nil then p.hmspinlasty = 0 end if p.hmspinlastz == nil then p.hmspinlastz = 0 end if p.kartstuff[k_position] <= 1 and not p.exiting then p.hmfrontruntime = $+1 end if p.kartstuff[k_offroad] > 0 then p.hmoffroadtime = $+1 end //if p.kartstuff[k_position] == 1 and p.kartstuff[k_spinouttimer] and p.exiting then //bumped across the finish line in first place //HM_AddAward("HAND OF GOD","Despite being spun out, managed to finish in first place anyways.",p,500) //weighty award //end if (p.mo and not P_IsObjectOnGround(p.mo) and not p.kartstuff[k_pogospring]) or p.kartstuff[k_squishedtimer] or p.kartstuff[k_spinouttimer] then if not p.hmnocontroltime then p.hmnocontroltime = 1 end p.hmnocontroltime = $+1 end //print("last position x: "..p.hmspinlastx.." y: "..p.hmspinlasty.." z: "..p.hmspinlastz) if p.kartstuff[k_spinouttimer] > 0 then //print("found spinout timer for "..p.name) if (p.hmspinlastx == 0 and p.hmspinlasty == 0 and p.hmspinlastz == 0) then //print("spin out pos empty") p.hmspinlastx = p.mo.x p.hmspinlasty = p.mo.y p.hmspinlastz = p.mo.z //print("new position is x: "..p.mo.x.." y: "..p.mo.y.." z: "..p.mo.z) else //print("last position x: "..p.hmspinlastx.." y: "..p.hmspinlasty.." z: "..p.hmspinlastz) //print("new position is x: "..p.mo.x.." y: "..p.mo.y.." z: "..p.mo.z) local dist dist = 24 --lmao, pra evita erro e isso vazio if p.mo then dist = P_AproxDistance(P_AproxDistance(p.mo.x - p.hmspinlastx, p.mo.y - p.hmspinlasty),p.mo.z - p.hmspinlastz)/FRACUNIT end p.hmspinoutdist = $+dist //print("approx distance is: "..dist.." new total is "..p.hmspinoutdist.." fracs") p.hmspinlastx = p.mo.x p.hmspinlasty = p.mo.y p.hmspinlastz = p.mo.z end else p.hmspinlastx = 0 p.hmspinlasty = 0 p.hmspinlastz = 0 end //xelork if p.kartstuff[k_stolentimer] == 1 p.xestolen = $ + 1 end if p.kartstuff[k_justbumped] == 1 p.xebump = $ + 1 end //Lighto if p.cmd.forwardmove < 0 then p.backwardsdrive = $ + 1 end end end end if hm_intermissioncalc() then if hpmod_showbar then hpmod_showbar = false end //thank you callmore if minrankplus and minrankplus.enabled then minrankplus.enabled = false end //also thank you callmore //todo: this is atrocious and bloaty, find motivation to iterate it //print("thinkframe finish state detected, doing end-round award determiniation") local frontrunners = {} local offroaders = {} local nocontrollers = {} local spinouts = {} local bananaslammas = {} local spinnas = {} local orbithits = {} //xelork local stolen = {} local bump = {} local sink = {} local defend = {} local oops = {} local spb = {} //Lighto local backdrv = {} //print("building tables") for p in players.iterate if p and p.valid then //print("adding "..p.name.."to all tables") if p.hmfrontruntime ~= nil then table.insert(frontrunners, p) end if p.hmoffroadtime ~= nil then table.insert(offroaders, p) end if p.hmnocontroltime ~= nil then table.insert(nocontrollers, p) end if p.hmspinoutdist ~= nil then table.insert(spinouts, p) end if p.hmbananahits ~= nil then table.insert(bananaslammas, p) end if p.hmtspinouts ~= nil then table.insert(spinnas, p) end if p.hmorbithits ~= nil then table.insert(orbithits, p) end //xelork if p.xestolen != nil then table.insert(stolen, p) end if p.xebump != nil then table.insert(bump, p) end if p.xesink != nil then table.insert(sink, p) end if p.xedefend != nil then table.insert(defend, p) end if p.xeoops != nil then table.insert(oops, p) end if p.xespbtime != nil then table.insert(spb, p) end //Lighto if p.backwardsdrive != nil then table.insert(backdrv,p) end end end //print("sorting all tables") table.sort(frontrunners, function(a, b) return a.hmfrontruntime > b.hmfrontruntime end) table.sort(offroaders, function(a,b) return a.hmoffroadtime > b.hmoffroadtime end) table.sort(nocontrollers, function(a,b) return a.hmnocontroltime > b.hmnocontroltime end) table.sort(spinouts, function(a,b) return a.hmspinoutdist > b.hmspinoutdist end) table.sort(bananaslammas, function(a,b) return a.hmbananahits > b.hmbananahits end) table.sort(spinnas, function(a,b) return a.hmtspinouts > b.hmtspinouts end) table.sort(orbithits, function(a,b) return a.hmorbithits > b.hmorbithits end) //xelork table.sort(stolen, function(a, b) return a.xestolen > b.xestolen end) table.sort(bump, function(a, b) return a.xebump > b.xebump end) table.sort(sink, function(a, b) return a.xesink > b.xesink end) table.sort(defend, function(a, b) return a.xedefend > b.xedefend end) table.sort(oops, function(a, b) return a.xeoops > b.xeoops end) table.sort(spb, function(a, b) return a.xespbtime > b.xespbtime end) //Lighto table.sort(backdrv,function(a,b) return a.backwardsdrive > b.backwardsdrive end) //print("tables sorted, determining best in class of each award") if frontrunners[1] and frontrunners[1].hmfrontruntime > 60*TICRATE then local time = frontrunners[1].hmfrontruntime/TICRATE local randtitle = "\131SENNA, O 9-3!" if frontrunners[1].hmfrontruntime > 90*TICRATE and frontrunners[1].kartstuff[k_position] ~= 1 then if leveltime % 2 then randtitle = "\131CHAMEM O SAMU!" else randtitle = "\131NADA ACONTECE FEIJOADA" end HM_AddAward(randtitle,"Tava indo bem, derrapando certinho, mas aos \130"..time.." segundos\128 capotou o corsa e perdeu tudo.",frontrunners[1],50+time,1) else HM_AddAward(randtitle,"Manteve a dianteira por \130"..time.." segundos\128 nessa corrida. Sucessor do Crickenn!",frontrunners[1],15+time,2) end end if offroaders[1] and offroaders[1].hmoffroadtime > 10*TICRATE then local x = offroaders[1].hmoffroadtime local timestring = x/TICRATE local randtitle = "\131QUE MANE ASFALTO" if leveltime % 2 then randtitle = "\131PAPA-CAPIM" end HM_AddAward(randtitle,"Passou \130"..timestring.." segundos\128 correndo em trechos fora de estrada. Hajam Sapatos!",offroaders[1],5+((x/TICRATE)*2)) end if nocontrollers[1] and nocontrollers[1].hmnocontroltime > 20*TICRATE then local x = nocontrollers[1].hmnocontroltime local timestring = x/TICRATE HM_AddAward("\131DEVE ESTAR BEBADO!","Passou \130"..timestring.." segundos\128 capotando, sendo esmagado e cantando pneu.",nocontrollers[1],20+(x/TICRATE/2)) end if spinouts[1] and spinouts[1].hmspinoutdist >= 12500 then local randtitle = "RODA MARIA, RODA!" if leveltime % 2 then randtitle = "PIAO DA CASA PROPRIA" else randtitle = "RODA A RODA JEQUITI" end HM_AddAward("\131"..randtitle,"Rodou por \130"..spinouts[1].hmspinoutdist.." centimetros\128 nessa corrida. Vai atacar a labirintite!",spinouts[1],spinouts[1].hmspinoutdist/100) end if bananaslammas[1] and bananaslammas[1].hmbananahits >= 5 then HM_AddAward("\131IIIIHHHHH","Capotou em \130"..bananaslammas[1].hmbananahits.." bananas\128 nessa corrida. Sera que ele e?",bananaslammas[1],bananaslammas[1].hmbananahits*5) end if spinnas[1] and spinnas[1].hmtspinouts >= 5 then local randtitle = "LOGAN SARGEANT NOSSO GOAT" if leveltime % 2 then randtitle = "COMPROU A CNH" else randtitle = "XINGOU ATE A MAE" end HM_AddAward("\131"..randtitle,"Capotou em perigos de pista \130"..spinnas[1].hmtspinouts.." vezes\128. Presta atencao!",spinnas[1],5*spinnas[1].hmtspinouts) end if orbithits[1] and orbithits[1].hmorbithits >= 2 then HM_AddAward("\131APRESSADO COME CRU","Colidiu com itens ativos de oponentes \130"..orbithits[1].hmorbithits.." vezes\128. Calma guri!",orbithits[1],15*orbithits[1].hmorbithits) end //xelork if stolen[1].xestolen >= 3 then HM_AddAward('\131ROUBARAM MEU SAPATO!','Foi roubado por Fantasmas \130'..stolen[1].xestolen..' vezes\128. Bem-vindo ao Brasil!', stolen[1], stolen[1].xestolen*5) end if bump[1].xebump > 4 then HM_AddAward('\131CHICANE AMBULANTE', 'Colidiu \130'..bump[1].xebump..' vezes\128 em outros jogadores. Ta carente?', bump[1], bump[1].xebump*5) end if defend[1].xedefend >= 3 then HM_AddAward('\131TAFFAREL','Se defendeu de itens inimigos \130'..defend[1].xedefend..' vezes\128. Ganhava a copa assim!', defend[1], defend[1].xedefend*5) end if oops[1].xeoops > 4 then HM_AddAward('\131TUDO QUE VAI, VOLTA!','Capotou \130'..oops[1].xeoops..' vezes\128 em seus proprios itens. Bem feito!', oops[1], oops[1].xeoops*5) end if spb[1].xespbtime > 30*TICRATE then if spb[1].xespblost then HM_AddAward('\131TERRIVEL CONTRA OS INSETOS', 'Foi pego pelo Mata Barata apos \130'..spb[1].xespbtime/TICRATE..' segundos\128 de perseguicao. Hoje nao!', spb[1], spb[1].xespbtime) elseif spb[1].xespbwin then HM_AddAward('\131BARATA TA FORTE', 'Terminou a corrida sem ser pego pelo Mata Barata. Deve ter passado da validade...', spb[1], spb[1].xespbtime) end end //Lighto if backdrv[1].backwardsdrive > 2*TICRATE then HM_AddAward('\131PERDIDAO','Deu re por \130'..(backdrv[1].backwardsdrive / TICRATE)..' segundos\128 durante a corrida. Perdeu alguma coisa?', backdrv[1], backdrv[1].backwardsdrive*5) end local tplayers = 0 local allplayers = {} for p in players.iterate if p and p.valid then tplayers = $+1 table.insert(allplayers, p) end end if leveltime%3 == 0 then HM_AddAward("\131ABACAXONIC","Abacaxonic esta de olho em voce. Cuidado.",allplayers[leveltime%tplayers],5) end chosenawards = chooseawards(awards, 5) local rankings = {} local tplayers = 0 for p in players.iterate if (p and p.valid) and not p.spectator and not (p.pflags&PF_TIMEOVER) table.insert(rankings, p) tplayers = $+1 end end table.sort(rankings, function(a, b) return a.realtime < b.realtime end) for i=1, #rankings //assigns where they ranked so I can properly maybe assign points rankings[i].hmfinishpoints = tplayers-i end end if server.hmfinishstate and server.hmfinishtimer == (hm_inttime.value*TICRATE)-2 then -- This is one tic after hm_intermissioncalc() returns true chosenawards = chooseawards(awards, 5) local rankings = {} local tplayers = 0 for p in players.iterate if (p and p.valid) and not p.spectator and not (p.pflags&PF_TIMEOVER) table.insert(rankings, p) tplayers = $+1 end end table.sort(rankings, function(a, b) return a.realtime < b.realtime end) for i=1, #rankings //assigns where they ranked so I can properly maybe assign points rankings[i].hmfinishpoints = tplayers-i end end end) addHook("PlayerSpin", function(p, inf, source) if not hm_intermission.value then return end p.hmtspinouts = $+1 if p and p.valid and inf and inf.valid then if inf.type == MT_BANANA or inf.type == MT_BANANA_SHIELD then p.hmbananahits = $+1 end if inf.type == MT_JAWZ_SHIELD or inf.type == MT_ORBINAUT_SHIELD or inf.type == MT_BANANA_SHIELD then p.hmorbithits = $+1 end end end) local wrapped = {} -- I KNOW THERE'S A FUCKIN FUNCTION IN SOURCE FOR THIS -- WHY IS IT NOT EXPOSED TO LUA -- LAAAAAAAAAAAAAAAAAAAAAAT local function wrapString(str, width, v, flags, font) local words = {} for word in str:gmatch("%S+") do table.insert(words, word) end local retlines = {} local buffer = words[1] for i = 2, #words local fug = buffer.." "..words[i] if v.stringWidth(fug, flags, font) > width then table.insert(retlines, buffer) buffer = words[i] else buffer = fug end end table.insert(retlines, buffer) return retlines end local function doEscapeCode(str) for _, v in pairs(hm_escape) str = str:gsub(v.a, v.b) end return str end -- hacked-up TSR scoreboard, WHEEEEEEEEEEEEEEE -- thanks snu hud.add(function(v, p, c) if not hm_intermission.value or server.SPBArunning then return end if hm_intermissioncalc() then hud.disable("gametypeinfo") hud.disable("minimap") hud.disable("item") hud.disable("position") hud.disable("check") hud.disable("minirankings") hud.disable("speedometer") end if not hm_intermissiondebug.value and not server.hmfinishstate then return end v.fadeScreen(0xFF00, 16) -- fade the screen -- store highlight colour here for use in the hud throughout local hilicol if (CV_FindVar("menuhighlight").value) hilicol = CV_FindVar("menuhighlight").value elseif (modeattacking) hilicol = V_ORANGEMAP else hilicol = ((gametype == GT_RACE) and V_SKYMAP or V_REDMAP) end -- draw lap count and game speed //if not G_BattleGametype() then //v.drawString(64, 8, "LAP COUNT", 0, "center") //v.drawString(64, 16, (numlaps), hilicol, "center") //v.drawString(256, 8, "GAME SPEED", 0, "center") //v.drawString(256, 16, CV_FindVar("kartspeed").string, hilicol, "center") //end v.drawString(160, 16, "** RESULTADOS **", 0, "center") if server.hmfinishtimer then v.drawString(160,190,"A PROXIMA CORRIDA COMECA EM "..string.format("%02i",server.hmfinishtimer/TICRATE), V_SNAPTOBOTTOM|hilicol,"center") end -- draw line between gametypeinfo and teams local dupadjust = (v.width()/v.dupx()) local duptweak = (dupadjust - 320)/2 -- BASEDVIDWIDTH = 320 (based on what?) v.drawFill(1-duptweak, 26, dupadjust-2, 1, 0) -- horizontal v.drawFill(160, 26, 1, 162, 0) -- vertical //v.drawString(4, 188, hm_trim(mapheaderinfo[gamemap].lvlttl.." "..mapheaderinfo[gamemap].zonttl).." - "..mapheaderinfo[gamemap].subttl, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, "thin") v.drawString(4, 188, hm_trim(mapheaderinfo[gamemap].lvlttl.." "..mapheaderinfo[gamemap].zonttl), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, "thin") local restat = CV_FindVar("hm_restat") local hy = 28 //vertical offset local hx = 0 //horizontal offset local beeg = false local lastrank = 0 //last rank we drew (ties) local hyanim = 0 //this is so disorganized at this point, this is for sliding the ranks up or down so scores can display next local drawingscores = false //im not sure what math I did to get this to work so im just never going to touch it again: local halfwaypt = (CV_FindVar("hm_inttime").value*TICRATE)*25/40 if server.hmfinishtimer <= halfwaypt then if server.hmfinishtimer >= halfwaypt-(TICRATE) then hyanim = max(-1*(-210+(6*(server.hmfinishtimer-(halfwaypt-TICRATE)))),-210) --print("timer: "..server.hmfinishtimer.." hyanim: "..hyanim) elseif server.hmfinishtimer >= halfwaypt-(2*TICRATE+1) then hyanim = 1*(6+(6*(server.hmfinishtimer-(halfwaypt-(TICRATE*2))))) --print("TAKE IT BACK NOW timer: "..server.hmfinishtimer.." hyanim: "..hyanim) end //the above abomination smoothly slides ranks out of the way in 1 second and lingers for 0.5 seconds end if server.hmfinishtimer <= halfwaypt-TICRATE then drawingscores = true end -- draw players local rankings = {} local tplayers = 0 for p in players.iterate if (p and p.valid) and not p.spectator and not (p.pflags&PF_TIMEOVER) table.insert(rankings, p) tplayers = $+1 end end if server.hmfinishstate then table.sort(rankings, function(a, b) return a.realtime < b.realtime end) elseif not drawingscores then table.sort(rankings, function(a, b) return a.kartstuff[k_position] < b.kartstuff[k_position] end) end for p in players.iterate if not p.spectator and (p.pflags&PF_TIMEOVER) then table.insert(rankings, p) tplayers = $+1 end end for p in players.iterate if p.spectator table.insert(rankings, p) end end if drawingscores then if hm_stks.value and st_enabled and st_enabled.value and sTrack and st_enableks and st_enableks.value then -- Sort by Kartscore instead table.sort(rankings, function(a, b) return (a and sTrack.globalPlayerData[a.name] and tonumber(sTrack.getPlayerKS(a.name)) or 1500) > (b and sTrack.globalPlayerData[b.name] and tonumber(sTrack.getPlayerKS(b.name)) or 1500) end) else table.sort(rankings, function(a, b) return a.score+a.hmfinishpoints > b.score+b.hmfinishpoints end) end end if not #rankings then return end for i = 1, #rankings local p = rankings[i] if i~=1 then hy = $+10 end if beeg then //flag for bigger panes so the panes below it draw proper hy=$+4 end beeg = false local specflag = (p.spectator or p.rs_check2) and V_50TRANS or 0 -- player ping: if (p ~= server) -- the server doesnt have a ping and (netgame) -- we obviously need to be in a netgame too -- my hopes with writing this code is that it's so bad that I'm never allowed to write ping related code ever again local ping = p.ping -- thanks 1.3 -- get the ping patch we'll use local ping_gfxnum, ping_values = 1, {76, 137, 256, 500} for i = 1, #ping_values if (ping >= ping_values[i]) then ping_gfxnum = i+1 end end -- sadly p.cmd.latency caps at 11 so it cant go any higher without hacks so huge that I cant be assed v.draw(3, hy+hyanim, v.cachePatch("HMPING"..ping_gfxnum), specflag) end -- rank: if not p.spectator then if drawingscores then v.drawString(29, hy+1+hyanim, i, 0, "right") else if i > 1 and p.realtime == rankings[i-1].realtime then v.drawString(29, hy+1+hyanim, lastrank, 0, "right") else //above handles ties so they show up proper placement-wise lastrank = i v.drawString(29, hy+1+hyanim, i, 0, "right") end end end -- draw skin icon if (p.mo and p.mo.valid) then local pp = skins[p.mo.skin].facerank local ppscale = FRACUNIT/2 //8 pixels if i <= 3 or (p.realtime == rankings[i-1].realtime and lastrank <= 3) then pp = skins[p.mo.skin].facewant ppscale = 3*FRACUNIT/8 //12 pixels hx = 4 //adjust 4 right beeg = true end local cmap = v.getColormap(p.mo.skin, p.mo.color) local dieflag = 0 if p.mo.colorized then cmap = v.getColormap(TC_RAINBOW, p.mo.color) end if G_BattleGametype() and p.kartstuff[k_bumper] <= 0 then cmap = v.getColormap(TC_RAINBOW, SKINCOLOR_GREY) dieflag = V_50TRANS end v.drawScaled(30< 100 fugname = $:sub(1, -2) end //speed/weight restat v.drawString(39+hx, hy+hyanim, fugname, V_6WIDTHSPACE|V_ALLOWLOWERCASE|specflag, "thin") if (p.mo and p.mo.valid) then if restat.value then if p.HMRs then if i <= 3 or (p.realtime == rankings[i-1].realtime and lastrank <= 3) then v.drawString(29, hy+hyanim, p.HMRs, 0, "small") v.drawString(39+hx, hy+hx+6+hyanim, p.HMRw, 0, "small-right") else v.drawString(29, hy+hyanim, p.HMRs, 0, "small") v.drawString(39+hx-4, hy+hx+6+hyanim-4, p.HMRw, 0, "small-right") //god I dont even care anymore this is such a fucking mess end end end end -- points: local points = "" if not drawingscores then if p.spectator then if p.pflags & PF_WANTSTOJOIN then points = "WAIT" else points = "SPEC" end elseif p.rs_check2 then points = "RAGE" elseif p.pflags & PF_TIMEOVER then points = "NO CONTEST." elseif G_BattleGametype() then points = p.marescore elseif not p.exiting then points = "LAP "..(p.laps+1) else points = buildTimeString(p.realtime) end else if hm_stks.value and st_enabled and st_enabled.value and sTrack and st_enableks and st_enableks.value then local changeFormatted = "" if not sTrack.globalPlayerData[p.name] then points = tostring(1500) else if (tonumber(sTrack.ksChanges[p.name]) or 0) > 0 then changeFormatted = "(+"..tostring(sTrack.ksChanges[p.name])..") " elseif (tonumber(sTrack.ksChanges[p.name]) or 0) < 0 then changeFormatted = "("..tostring(sTrack.ksChanges[p.name])..") " end points = changeFormatted..tostring(sTrack.getPlayerKS(p.name)) end else //FUN FACT EVERYTHING FOR SCORE IS HANDLED DURING INTERMISSION //SO I LITERALLY JUST HAVE TO PRETEND INTERMISSION CALCULATED //NO THIS DOESN'T TAKE INTO ACCOUNT TIES FUCK YOU local scradj = p.hmfinishpoints or 0 if p.hmoldscore and p.hmoldscore < p.score+scradj then points = "(+"..p.score-p.hmoldscore+(scradj)..") "..p.score+(scradj) elseif p.hmoldscore and p.hmoldscore > p.score+scradj then points = "("..p.score-p.hmoldscore+(scradj)..") "..p.score+(scradj) else points = p.score end end end v.drawString(157, hy+hyanim, points, (p.exiting and hilicol or 0)|V_6WIDTHSPACE|specflag, "thin-right") end --RIGHT PANE DRAWING local fx = 163 v.drawString(240,28,"* PEROLAS *",0,"center") //table.sort(chosenawards, function(a,b) //return a.weight > b.weight //end) for i, k in pairs(chosenawards) //print("Checking for player...") if chosenawards[i].pl and chosenawards[i].pl.valid then continue else table.remove(chosenawards, i) //print("Removed a now non-existent player from chosenawards") end end local fy = 40 local startfy = 40 for i, pl in pairs(chosenawards) //print("new fy: "..fy) startfy = fy if fy > 175 then return end //dont draw off the screen lmao if not chosenawards[i].title then continue end //icon local plyr = chosenawards[i].pl if not (plyr and plyr.valid) then continue end if plyr.mo and plyr.mo.valid then local pp = skins[plyr.mo.skin].facewant local cmap = v.getColormap(plyr.mo.skin, plyr.mo.color) //4*FRACUNIT/5 v.drawScaled(163<