Initial commit
This commit is contained in:
31
addons/mc_quests/lua/entities/mqs_npc/cl_init.lua
Normal file
31
addons/mc_quests/lua/entities/mqs_npc/cl_init.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
include("shared.lua")
|
||||
|
||||
function ENT:Initialize()
|
||||
self.MQSNPC = true
|
||||
self.names = 0
|
||||
end
|
||||
|
||||
function ENT:Draw()
|
||||
self:DrawModel()
|
||||
|
||||
if self:GetPos():DistToSqr(LocalPlayer():GetPos()) > MQS.Config.QuestEntDrawDist ^ 2 then return end
|
||||
|
||||
local Pos = self:EyePos() or self:GetPos()
|
||||
Pos = Pos + Vector(0, 0, 10)
|
||||
local Ang = self:GetAngles()
|
||||
local eyepos = EyePos()
|
||||
local planeNormal = Ang:Up()
|
||||
Ang:RotateAroundAxis(Ang:Forward(), 90)
|
||||
|
||||
local relativeEye = eyepos - Pos
|
||||
local relativeEyeOnPlane = relativeEye - planeNormal * relativeEye:Dot(planeNormal)
|
||||
local textAng = relativeEyeOnPlane:AngleEx(planeNormal)
|
||||
|
||||
textAng:RotateAroundAxis(textAng:Up(), 90)
|
||||
textAng:RotateAroundAxis(textAng:Forward(), 90)
|
||||
|
||||
cam.Start3D2D(Pos - Ang:Right() * (8 + math.sin(CurTime()) * 0.9), textAng, 0.1)
|
||||
draw.RoundedBox(8, -self.names / 2 - 10, 0, self.names + 20, 35, MSD.Theme["d"])
|
||||
self.names = draw.SimpleTextOutlined(self:GetNamer(), "MSDFont.32", 0, 0, color_white, TEXT_ALIGN_CENTER, 0, 1, color_black)
|
||||
cam.End3D2D()
|
||||
end
|
||||
25
addons/mc_quests/lua/entities/mqs_npc/init.lua
Normal file
25
addons/mc_quests/lua/entities/mqs_npc/init.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
AddCSLuaFile("cl_init.lua")
|
||||
AddCSLuaFile("shared.lua")
|
||||
include("shared.lua")
|
||||
util.AddNetworkString("MQS.OpenNPCMenu")
|
||||
|
||||
function ENT:Initialize()
|
||||
self.MQSNPC = true
|
||||
self:SetHullType(HULL_HUMAN)
|
||||
self:SetHullSizeNormal()
|
||||
self:SetNPCState(NPC_STATE_SCRIPT)
|
||||
end
|
||||
|
||||
function ENT:AcceptInput(istr, ply)
|
||||
if IsValid(ply) and (not ply.UseTimer or ply.UseTimer < CurTime()) then
|
||||
ply.UseTimer = CurTime() + 2
|
||||
net.Start("MQS.OpenNPCMenu")
|
||||
net.WriteEntity(self)
|
||||
net.Send(ply)
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Think()
|
||||
self:NextThink( CurTime() )
|
||||
return true
|
||||
end
|
||||
16
addons/mc_quests/lua/entities/mqs_npc/shared.lua
Normal file
16
addons/mc_quests/lua/entities/mqs_npc/shared.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
--leak by matveicher
|
||||
--vk group - https://vk.com/gmodffdev
|
||||
--steam - https://steamcommunity.com/profiles/76561198968457747/
|
||||
--ds server - https://discord.gg/V329W7Ce8g
|
||||
--ds - matveicher#5801
|
||||
ENT.Type = "ai"
|
||||
ENT.Base = "base_anim"
|
||||
ENT.PrintName = "MQS Quest NPC"
|
||||
ENT.Author = "Mactavish"
|
||||
ENT.Spawnable = false
|
||||
ENT.AdminSpawnable = true
|
||||
|
||||
function ENT:SetupDataTables()
|
||||
self:NetworkVar("String", 0, "Namer")
|
||||
self:NetworkVar("Int", 1, "UID")
|
||||
end
|
||||
Reference in New Issue
Block a user