Left 4 Dead 2

Left 4 Dead 2

Speedrunner Tools
 Denne tråd er blevet fastgjort, så den er sikkert vigtig
シェイディ♑  [udvikler] 14. apr. 2024 kl. 10:40
Extra HUD
Setting the additional HUD elements on the screen (near with timer or somehow else) can be useful for tests and debugging. Let's try to display Tank's current health.
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=3222607508
Push this code to the bottom of your vs_st_speedrun.nut script.
//new HUD g_STLib.Vars.HUD.Fields.my_hud <- {slot = HUD_SCORE_1, datafunc = @() g_STLib.Funcs.Think(), flags = HUD_FLAG_ALIGN_CENTER}; HUDPlace(HUD_SCORE_1, 0.435, 0.06, 0.14, 0.035); Think <- function() { local text = "Tank's health: "; local ent; if ((ent = Entities.FindByModel(null, "models/infected/hulk.mdl")) && !ent.IsIncapacitated() && !ent.IsDying() && !ent.IsDead()) { return text + ent.GetHealth(); } return text + "N/A"; }

Campaign time + map time
We can also make something more complicated, like add the map time in conjunction with a total campaign time.

Even more potentially free empty HUD slots are listed below. They aren't used by ST and its related plugins, therefore may be borrowed. In our example there we are going to use HUD_SCORE_* slots.
  • HUD_SCORE_* (up to 4?)
  • HUD_FAR_RIGHT
  • HUD_SCORE_TITLE
  • HUD_TICKER
Note: For monitors with 2K resolution, use 1440p code variant respectively.
//campaign time HUDLoad(15.0); //new HUD elements g_STLib.Vars.HUD.Fields.timer2_sec <- {slot = HUD_SCORE_1, datafunc = @() g_STLib.Funcs.Think(1), flags = HUD_FLAG_NOBG | HUD_FLAG_AS_TIME | HUD_FLAG_ALIGN_RIGHT}; g_STLib.Vars.HUD.Fields.timer2_ms <- {slot = HUD_SCORE_2, datafunc = @() g_STLib.Funcs.Think(2), flags = HUD_FLAG_NOBG | HUD_FLAG_ALIGN_LEFT}; g_STLib.Vars.HUD.Fields.timer2_bg <- {slot = HUD_SCORE_3, dataval = ""}; //1080p HUDPlace(HUD_SCORE_1, 0.371, 0.051, 0.14, 0.035); HUDPlace(HUD_SCORE_2, 0.511, 0.055, 0.14, 0.035); HUDPlace(HUD_SCORE_3, 0.453, 0.055, 0.0935, 0.027); //1440p // HUDPlace(HUD_SCORE_1, 0.371, 0.0485, 0.14, 0.035); // HUDPlace(HUD_SCORE_2, 0.511, 0.05, 0.14, 0.035); // HUDPlace(HUD_SCORE_3, 0.4705, 0.055, 0.0645, 0.021); //HUD data update (map time, so) Think <- function(value) { local time = 0.0; if (g_STLib.Vars.started) { time = CPGetTime() - g_STLib.Vars.time_desired; } if (value == 1) return time; if (value == 2) return "," + split(format("%.03f", time), ".")[1]; }

Additional helpful info: Valve->EMS->Appendix:_HUD
Sidst redigeret af シェイディ♑; 8. mar. kl. 14:45