local ENT = nrequire("sh_art_npc.lua") local e = nrequire("editor.lua") local col = nrequire("colortheme.lua") print("in cl_art_npc, ENT loaded from sh_art_npc is", ENT) ENT.RenderGroup = RENDERGROUP_BOTH local function get_settings_info(what) -- Settings to display next to an npc local settings = {} settings["Model"] = what:GetModel() -- Classes that this npc inherits from, in the order it inherits local sinh = {} local sinhc = 1 -- Keep going, even if we encounter nil local cursor = what sinh[sinhc] = cursor.Name while cursor do cursor = getmetatable(cursor) if type(cursor) == "table" then sinh[sinhc] = cursor.Name or "nil" else sinh[sinhc] = tostring(cursor) end sinhc = sinhc + 1 end settings["Inherits from"] = string.format("[%s]",table.concat(sinh,", ")) return settings end local settings_info = nil function ENT:Draw() if e.Enabled then --What to draw when "Editor" is enabled self:DrawModel() if settings_info == nil then settings_info = get_settings_info(self) end local pos,ang = (self:GetRight() * -32) + (self:GetUp() * 72) + self:GetPos() , self:GetAngles() cam.Start3D2D( pos, ang + Angle(0, 90, 90), 0.2 ) local line = 0 for k,v in pairs(settings_info) do draw.DrawText(string.format("%s:%s",k,tostring(v)), "Default", 0, line * 20, col.game.npcsettings ) line = line + 1 end cam.End3D2D() else self:DrawModel() end end function ENT:DrawTranslucent() -- This is here just to make it backwards compatible. -- You shouldn't really be drawing your model here unless it's translucent self:Draw() end function ENT:BuildBonePositions( NumBones, NumPhysBones ) -- You can use this section to position the bones of -- any animated model using self:SetBonePosition( BoneNum, Pos, Angle ) -- This will override any animation data and isn't meant as a -- replacement for animations. We're using this to position the limbs -- of ragdolls. end function ENT:SetRagdollBones( bIn ) -- If this is set to true then the engine will call -- DoRagdollBone (below) for each ragdoll bone. -- It will then automatically fill in the rest of the bones self.m_bRagdollSetup = bIn end function ENT:DoRagdollBone( PhysBoneNum, BoneNum ) -- self:SetBonePosition( BoneNum, Pos, Angle ) end local chatframe = nil net.Receive("art_opennpcdialog",function() if chatframe ~= nil and chatframe:IsValid() then chatframe:Remove() chatframe = nil end local width, height = ScrW(), ScrH() local who = net.ReadEntity() local chattbl = net.ReadTable() chatframe = vgui.Create( "DFrame" ) chatframe:SetPos( (width / 2) - (width / 4), height - (height / 4) ) chatframe:SetSize( width / 2, height / 4 ) chatframe:SetTitle( chattbl["Name"] ) chatframe:SetDraggable( true ) chatframe.OnClose = function() net.Start("art_closenpcdialog") net.WriteEntity(who) net.SendToServer() end local chattxt = vgui.Create( "DLabel", chatframe ) --chattxt:SetPos( 40, 40 ) chattxt:SetText(chattbl["Message"]) chattxt:Dock(TOP) for k,v in pairs(chattbl["Options"]) do local chatbutton = vgui.Create( "DButton",chatframe ) --chatbutton:SetPos( 40, 40 ) chatbutton:SetText( v ) --chatbutton:SetSize( 120, 60 ) chatbutton.DoClick = function() net.Start("art_updatenpcdialog") net.WriteEntity(who) net.WriteString(v) net.SendToServer() end chatbutton:Dock(BOTTOM) end chattxt:Dock(FILL) chatframe:MakePopup() end) scripted_ents.Register(ENT, "art_npc")