/* * Author: Needles * https://steamcommunity.com/profiles/76561198026257137/ * * Sorry brain, this is my idea now */ printl("*** HANDLER/TUTORIAL"); ::Tutorial <- {}; ::Tutorial.defaultTutorialList <- [ { model = "models/empty.mdl", scale = 1.0, modelOrigin = Vector(0.0, 0.0, 0.0), text = "NOTHING!", textOrigin = Vector(0.0, 0.0, 0.0), }, ]; ::Tutorial.MODEL_PATH <- "models/props_spytech/computer_low.mdl"; PrecacheModel(::Tutorial.MODEL_PATH); local TutorialConsoleHandler = class extends ::Handler.BaseHandler { ent_prop = null; ent_text = null; tutorialIndex = null; tutorialList = null; constructor() { ent_prop = null; ent_text = null; tutorialIndex = -1; tutorialList = ::Tutorial.defaultTutorialList; } function OnEvent_DamagePre(params) { if (!self || !self.IsValid() || params.const_entity != self) { return; } params.damage = 0; CycleTutorial(); } function CycleTutorial() { tutorialIndex ++; if (tutorialIndex < 0) // Should never happen, but you never know { return; } if (tutorialIndex >= tutorialList.len()) { tutorialIndex = 0; } local tutorial = tutorialList[tutorialIndex]; ent_prop.SetModel(tutorial.model); ent_prop.SetModelScale(tutorial.scale, 0.0); ent_text.SetLocalOrigin(tutorial.textOrigin); ent_prop.SetLocalOrigin(tutorial.modelOrigin); EntFireByHandle(ent_text, "SetText", tutorial.text, -1.0, null, null); } function SetTutorialList(newTutorialList) { tutorialList = newTutorialList; tutorialIndex = -1; CycleTutorial(); } } ::Handler.RegisterHandler("tutorial_console", @() TutorialConsoleHandler()); function Tutorial::BuildTutorialConsole(origin, angles, tutorialList = ::Tutorial.defaultTutorialList) { local ent_boss = SpawnEntityFromTable("base_boss", { origin = origin, angles = angles + QAngle(0.0, 90.0, 0.0), model = ::Tutorial.MODEL_PATH, health = 1, }); local ent_prop = SpawnEntityFromTable("prop_dynamic", { origin = origin + Vector(0.0, 0.0, 0.0), angles = angles, model = ::Tutorial.MODEL_PATH, }); local ent_text = SpawnEntityFromTable("point_worldtext", { origin = origin, angles = angles + QAngle(0.0, 180.0, 0.0), message = "", font = FONT.TF2_BUILD_NO_OUTLINE, textsize = 10, color = "255 255 255 255", }); EntFireByHandle(ent_prop, "SetParent", "!activator", -1.0, ent_boss, null); EntFireByHandle(ent_text, "SetParent", "!activator", -1.0, ent_boss, null); EntFireByHandle(ent_boss, "Disable", "", -1.0, null, null); // Doesn't fall to ground, won't crush players local handler_tutorialConsole = ::Handler.AddHandler(ent_boss, "tutorial_console", null, -1.0, {ent_prop = ent_prop, ent_text = ent_text, tutorialList = tutorialList}); ::Handler.AddHandler(ent_boss, "weapon_interaction", null, -1.0); handler_tutorialConsole.CycleTutorial(); return handler_tutorialConsole; }