summaryrefslogtreecommitdiff
path: root/gamemode/cl_various
diff options
context:
space:
mode:
authorApickx <Apickx@cogarr.org>2015-12-28 19:18:30 -0500
committerApickx <Apickx@cogarr.org>2015-12-28 19:18:30 -0500
commit868e729d68b5913716bfe5ddb512f4099851e9a2 (patch)
tree6441108754145dfd68a6e23bea382b5cb1ab63d5 /gamemode/cl_various
downloadgearfox-master.tar.gz
gearfox-master.tar.bz2
gearfox-master.zip
Initial commitHEADmaster
Diffstat (limited to 'gamemode/cl_various')
-rw-r--r--gamemode/cl_various/calcview.lua172
-rw-r--r--gamemode/cl_various/colors.lua17
-rw-r--r--gamemode/cl_various/fonts.lua11
-rw-r--r--gamemode/cl_various/hooks.lua14
-rw-r--r--gamemode/cl_various/input.lua27
-rw-r--r--gamemode/cl_various/material.lua18
-rw-r--r--gamemode/cl_various/motd.lua34
-rw-r--r--gamemode/cl_various/paperdoll.lua27
-rw-r--r--gamemode/cl_various/rendersunflare.lua62
9 files changed, 382 insertions, 0 deletions
diff --git a/gamemode/cl_various/calcview.lua b/gamemode/cl_various/calcview.lua
new file mode 100644
index 0000000..2530025
--- /dev/null
+++ b/gamemode/cl_various/calcview.lua
@@ -0,0 +1,172 @@
+
+local Camdist = 60 --Dont change this
+local Camcdist = 60 --Dont change this
+local CamMin = 20
+local CamMax = 200
+local Campos = Vector( 0 , 0 , 0 )
+local Aimpos = Vector( 0 , 0 , 0 )
+local AimVect = Vector( 0 , 0 , 0 )
+local RPos = Campos
+local CamEnt = NULL
+local DefDCam = nil
+local EnabledFT = true
+local CamZNear = 1
+local CamZFar = nil
+local CamKey = KEY_C
+local CamHeight = 0
+local NewFunc = nil
+
+--I was wondering if I should use the vgui functions or the bindpress. The advantage is that the vgui one works even when your mouse is out.
+--However, it might get annoying when you are trying to scroll a scrollbar. ;P
+vgui.GetWorldPanel():SetWorldClicker(false)
+
+hook.Add("PlayerBindPress","CameraScroll",function(ply,bind,pressed)
+ self = GM or GAMEMODE
+
+ if (EnabledFT and (!CamKey or input.IsKeyDown(CamKey))) then
+ if (bind == "invnext") then
+ self:AddCameraDistance(10)
+ return true
+ end
+
+ if (bind == "invprev") then
+ self:AddCameraDistance(-10)
+ return true
+ end
+ end
+end)
+
+function GM:SetCameraKey(KEY)
+ CamKey = KEY
+end
+
+function GM:SetCameraDistance(dist)
+ if (dist > CamMax) then dist = CamMax end
+ if (dist < CamMin) then dist = CamMin end
+
+ if (Camdist != dist and LocalPlayer():Alive()) then
+ if (dist == CamMin) then OnCameraModeSwitch(true)
+ elseif (Camdist == CamMin) then OnCameraModeSwitch(false) end
+ end
+
+ Camdist = dist
+end
+
+function GM:AddCameraDistance(add)
+ local dist = Camdist + add
+ if (dist > CamMax) then dist = CamMax end
+ if (dist < CamMin) then dist = CamMin end
+
+ if (Camdist != dist and LocalPlayer():Alive()) then
+ if (dist == CamMin) then self:OnCameraModeSwitch(true)
+ elseif (Camdist == CamMin) then self:OnCameraModeSwitch(false) end
+ end
+
+ Camdist = dist
+end
+
+function GM:SetEnableThirdPerson(bool)
+ EnabledFT = bool
+end
+
+function IsFirstPerson()
+ return (Camdist <= CamMin or !EnabledFT)
+end
+
+function GM:OnCameraModeSwitch(bFirstPerson)
+end
+
+function GetCameraPos()
+ return RPos
+end
+
+function SetCameraObject(Ent)
+ CamEnt = Ent
+end
+
+function SetDefaultDeathPos(Pos)
+ DefDCam = Pos
+end
+
+function SetCameraMinDistance(Dist)
+ CamMin = Dist
+end
+
+function SetCameraMaxDistance(Dist)
+ CamMax = Dist
+end
+
+function SetCameraZNear(Near)
+ CamZNear = Near
+end
+
+function SetCameraZFar(Far)
+ CamZFar = Far
+end
+
+function SetCameraOffsetHeight(H)
+ CamHeight=H
+end
+
+function OverrideDefaultGFCamera(Fun)
+ NewFunc = Fun
+end
+
+hook.Add("CalcView","View",function(ply, origin, angles, fov)
+ if (NewFunc) then
+ local Cal = NewFunc(ply, origin, angles, fov)
+
+ if (Cal) then return Cal end
+ end
+
+ local view = {}
+
+ AimPos = ply:GetAimVector()
+ AimVect = AimVect + (AimPos-AimVect)/2
+
+ view.znear = CamZNear
+ view.zfar = CamZFar
+
+ view.origin = origin
+
+ if (!ply:Alive()) then
+ if (DefDCam) then origin = DefDCam end
+
+ view.origin = origin + AimPos * -80
+ RPos = view.origin
+ return view
+ end
+
+ if (!EnabledFT) then return view end
+
+ if (Camdist > CamMin or IsValid(CamEnt)) then
+ Camcdist = Camcdist + (Camdist-Camcdist)/16
+ local Distance = Camcdist
+
+ Campos = ply:GetShootPos()
+ Campos.z = Campos.z
+
+ if (IsValid(CamEnt)) then Campos = CamEnt:GetPos() end
+
+ local Aimer = AimVect
+ local data = {}
+
+ data.start = Campos
+ data.endpos = Campos - Aimer * Distance
+ data.filter = ply
+ data.mask = MASK_SOLID_BRUSHONLY
+ data.mins = ply:OBBMaxs()/3*-1
+ data.maxs = ply:OBBMaxs()/3
+
+ local trace = util.TraceHull( data )
+
+ view.origin = trace.HitPos
+ view.angles = Aimer:Angle()
+ end
+
+ view.origin.z = view.origin.z + CamHeight
+
+ RPos = view.origin or origin
+
+ return view
+end) \ No newline at end of file
diff --git a/gamemode/cl_various/colors.lua b/gamemode/cl_various/colors.lua
new file mode 100644
index 0000000..07f2965
--- /dev/null
+++ b/gamemode/cl_various/colors.lua
@@ -0,0 +1,17 @@
+//Global Colors!
+
+MAIN_COLORD2 = Color( 40, 55, 70, 200 )
+MAIN_COLORD = Color( 40, 55, 70, 100 )
+MAIN_COLOR = Color( 60, 90, 120, 200 )
+MAIN_COLOR2 = Color( 80, 130, 180, 200 )
+MAIN_TEXTCOLOR = Color( 200, 200, 200, 250 )
+MAIN_BLACKCOLOR = Color( 20, 20, 20, 250 )
+MAIN_NOCOLOR = Color( 0, 0, 0, 0 )
+MAIN_GREENCOLOR = Color( 100, 200, 100, 200 )
+MAIN_YELLOWCOLOR = Color( 250, 250, 50, 200 )
+MAIN_REDCOLOR = Color( 250, 50, 50, 250 )
+MAIN_BLUECOLOR = Color( 50, 50, 250, 250 )
+MAIN_WHITECOLOR = Color( 255, 255, 255, 255 )
+MAIN_GREYCOLOR = Color( 155, 155, 155, 255 )
+MAIN_WHITECOLORT = Color( 255, 255, 255, 100 )
+
diff --git a/gamemode/cl_various/fonts.lua b/gamemode/cl_various/fonts.lua
new file mode 100644
index 0000000..ba62ff5
--- /dev/null
+++ b/gamemode/cl_various/fonts.lua
@@ -0,0 +1,11 @@
+//Fonts
+
+surface.CreateFont( "ScoreboardFont", {size = 64, weight = 400, font = "coolvetica"} )
+surface.CreateFont( "MBDefaultFont", {size = 16, weight = 500} )
+surface.CreateFont( "MBDefaultFontMedium", {size = 24, weight = 500} )
+surface.CreateFont( "MBDefaultFontLarge", {size = 32, weight = 500} )
+surface.CreateFont( "MBDefaultFontVeryLarge", {size = 48, weight = 500} )
+surface.CreateFont( "MBDefaultFontSuperLarge", {size = 64, weight = 500} )
+surface.CreateFont( "MBChatFont", {size = 16, weight = 900, shadow = true} )
+surface.CreateFont( "MBChatFont_Tag", {size = 18, weight = 700, antialias = false, font = "Akbar", shadow = true} )
+surface.CreateFont( "MBPlayerNameFont", {size = 30, weight = 900, shadow = true} ) \ No newline at end of file
diff --git a/gamemode/cl_various/hooks.lua b/gamemode/cl_various/hooks.lua
new file mode 100644
index 0000000..636025c
--- /dev/null
+++ b/gamemode/cl_various/hooks.lua
@@ -0,0 +1,14 @@
+
+
+hook.Add("Initialize","GearFoxInit",function()
+ self = GM or GAMEMODE
+
+ if (self.UseMawBlockCHud) then
+ self:AddBlockCHud("CHudWeaponSelection")
+ self:AddBlockCHud("CHudHealth")
+ self:AddBlockCHud("CHudBattery")
+ self:AddBlockCHud("CHudDamageIndicator")
+ self:AddBlockCHud("CHudAmmo")
+ self:AddBlockCHud("CHudSecondaryAmmo")
+ end
+end)
diff --git a/gamemode/cl_various/input.lua b/gamemode/cl_various/input.lua
new file mode 100644
index 0000000..519dbaf
--- /dev/null
+++ b/gamemode/cl_various/input.lua
@@ -0,0 +1,27 @@
+local B = {}
+local A = {}
+
+function input.IsMouseInBox( x , y , w , h )
+ local mx, my = gui.MousePos()
+ return (mx > x and mx < x+w and my > y and my < y+h)
+end
+
+function input.IsInBox( x2 , y2 , x , y , w , h )
+ return (x2 > x and x2 < x+w and y2 > y and y2 < y+h)
+end
+
+function input.KeyPress(KEY,ID)
+ ID = ID or ""
+ if (input.IsKeyDown(KEY) and !IsChatOpen()) then
+ if (!A[KEY..ID]) then A[KEY..ID] = true return true
+ else return false end
+ elseif (A[KEY..ID]) then A[KEY..ID] = false end
+end
+
+function input.MousePress(MOUSE,ID)
+ ID = ID or ""
+ if (input.IsMouseDown(MOUSE)) then
+ if (!B[MOUSE..ID]) then B[MOUSE..ID] = true return true
+ else return false end
+ elseif (B[MOUSE..ID]) then B[MOUSE..ID] = false end
+end
diff --git a/gamemode/cl_various/material.lua b/gamemode/cl_various/material.lua
new file mode 100644
index 0000000..bd48612
--- /dev/null
+++ b/gamemode/cl_various/material.lua
@@ -0,0 +1,18 @@
+
+local SourceSkyname = GetConVar("sv_skyname"):GetString() --We need the source of the maps original skybox texture so we can manipulate it.
+local SourceSkyPre = {"lf","ft","rt","bk","dn","up",}
+local SourceSkyMat = {
+ Material("skybox/"..SourceSkyname.."lf"),
+ Material("skybox/"..SourceSkyname.."ft"),
+ Material("skybox/"..SourceSkyname.."rt"),
+ Material("skybox/"..SourceSkyname.."bk"),
+ Material("skybox/"..SourceSkyname.."dn"),
+ Material("skybox/"..SourceSkyname.."up"),
+}
+
+function ChangeSkybox(skyboxname)
+ for i = 1,6 do
+ local D = Material("skybox/"..skyboxname..SourceSkyPre[i]):GetTexture("$basetexture")
+ SourceSkyMat[i]:SetTexture("$basetexture",D)
+ end
+end \ No newline at end of file
diff --git a/gamemode/cl_various/motd.lua b/gamemode/cl_various/motd.lua
new file mode 100644
index 0000000..7602c30
--- /dev/null
+++ b/gamemode/cl_various/motd.lua
@@ -0,0 +1,34 @@
+
+local MOTD_URL = "www.google.com" --Change URL here.
+local MOTD_ENABLE = true
+
+function GM:SetMOTD(url)
+ MOTD_URL = url
+end
+
+function GM:EnableMOTD(boolean)
+ MOTD_ENABLE = boolean
+end
+
+function GM:ReloadMOTD()
+ if (!MOTD_ENABLE) then return end
+
+ if (GM.MOTD) then
+ GM.MOTD:OpenURL(MOTD_URL)
+ GM.MOTD:SetVisible(true)
+ end
+end
+
+
+hook.Add("InitPostEntity","GearFox_MOTD",function()
+ if (!MOTD_ENABLE) then return end
+
+ GM = GM or GAMEMODE
+
+ GM.MOTD = vgui.Create("MBBrowser")
+ GM.MOTD:SetTitle("Message of the Day")
+ GM.MOTD:SetPos(100,100)
+ GM.MOTD:SetSize(ScrW()-200,ScrH()-200)
+ GM.MOTD:OpenURL(MOTD_URL)
+ GM.MOTD:MakePopup()
+end) \ No newline at end of file
diff --git a/gamemode/cl_various/paperdoll.lua b/gamemode/cl_various/paperdoll.lua
new file mode 100644
index 0000000..4bc9841
--- /dev/null
+++ b/gamemode/cl_various/paperdoll.lua
@@ -0,0 +1,27 @@
+local meta = FindMetaTable("Player")
+
+function meta:AttachModel(ID,BoneID,offpos,offang,scale,Model)
+ if (!self._AM) then self._AM = {} end
+ if (self._AM[ID] and IsValid(self._AM[ID].CEnt)) then self._AM[ID].CEnt:Remove() end
+
+ self._AM[ID] = {CEnt = ClientsideModel(Model), BID = BoneID,}
+ self._AM[ID].CEnt:SetModelScale(scale)
+ self._AM[ID].CEnt:FollowBone(self,BoneID)
+ self._AM[ID].CEnt:SetLocalPos(offpos)
+ self._AM[ID].CEnt:SetLocalAngles(offang)
+end
+
+function meta:DetachModel(ID)
+ if (!self._AM) then return end
+ if (self._AM[ID] and IsValid(self._AM[ID].CEnt)) then self._AM[ID].CEnt:Remove() end
+ self._AM[ID] = nil
+end
+
+function meta:GetModelByID(ID)
+ if (!self._AM) then return NULL end
+ return self._AM[ID]
+end
+
+function meta:GetModels()
+ return self._AM or {}
+end
diff --git a/gamemode/cl_various/rendersunflare.lua b/gamemode/cl_various/rendersunflare.lua
new file mode 100644
index 0000000..0383639
--- /dev/null
+++ b/gamemode/cl_various/rendersunflare.lua
@@ -0,0 +1,62 @@
+
+local SunFlares = {
+ surface.GetTextureID("mawbase/sunflares/flare1"),
+ surface.GetTextureID("mawbase/sunflares/flare2"),
+ surface.GetTextureID("mawbase/sunflares/s1"),
+ surface.GetTextureID("mawbase/sunflares/s2"),
+ surface.GetTextureID("mawbase/sunflares/s3"),
+ surface.GetTextureID("mawbase/sunflares/s4"),
+}
+
+local SunGlow = surface.GetTextureID("sun/overlay")
+
+MAIN_MAWSUNCOLOR = Color(255,255,255,255)
+
+hook.Add("HUDPaint","RenderMawSunflare",function()
+ GM = GM or GAMEMODE
+ if (!GM.UseMawSun) then return end
+
+ local Sun = GM:GetGlobalSHVar("SunPos")
+
+ if (type(Sun):lower() != "vector") then return end
+
+ local LPo = GetCameraPos()
+ local SPos = LPo+Sun
+ local T = {
+ start = LPo,
+ endpos = LPo+(Sun:GetNormal()*10000),
+ filter = LocalPlayer(),
+ }
+
+ T = util.TraceLine(T)
+
+ if (T.Hit and !T.HitSky) then return end
+
+ local Pos = SPos:ToScreen()
+ local Dot = math.Clamp((LocalPlayer():GetAimVector():DotProduct( (SPos - LPo):GetNormal() )-0.5)*2,0,1)
+
+ if (Dot <= 0) then return end
+
+ local Size = 400+100*Dot
+
+ local Cx = ScrW()/2
+ local Cy = ScrH()/2
+
+ local Gx = Pos.x-Cx
+ local Gy = Pos.y-Cy
+
+ local Col = MAIN_MAWSUNCOLOR
+ Col.a = 250*Dot
+
+ DrawTexturedRectRotated(Pos.x,Pos.y,Size*0.6,Size*0.6,Col,SunFlares[1],0)
+ DrawTexturedRectRotated(Pos.x,Pos.y,Size,Size,Col,SunFlares[2],0)
+
+ DrawTexturedRectRotated(Cx,Cy,64,64,Col,SunFlares[5],0)
+ DrawTexturedRectRotated(Cx+Gx*0.5,Cy+Gy*0.5,140,140,Col,SunFlares[6],0)
+ DrawTexturedRectRotated(Cx+Gx*0.2,Cy+Gy*0.2,50,50,Col,SunFlares[5],0)
+ DrawTexturedRectRotated(Cx+Gx*0.30,Cy+Gy*0.30,53,53,Col,SunFlares[5],0)
+ DrawTexturedRectRotated(Cx+Gx*0.25,Cy+Gy*0.25,90,90,Col,SunFlares[6],0)
+ DrawTexturedRectRotated(Cx-Gx*0.12,Cy-Gy*0.12,90,90,Col,SunFlares[4],0)
+ DrawTexturedRectRotated(Cx-Gx*0.2,Cy-Gy*0.2,210,210,Col,SunFlares[3],0)
+
+end) \ No newline at end of file