diff options
Diffstat (limited to 'gamemode')
112 files changed, 6691 insertions, 0 deletions
diff --git a/gamemode/cl_init.lua b/gamemode/cl_init.lua new file mode 100644 index 0000000..c07a730 --- /dev/null +++ b/gamemode/cl_init.lua @@ -0,0 +1,20 @@ +
+include( "shared.lua" )
+
+function GM:Initialize()
+ self:SetEnableMawCircle(false)
+ self:EnableMOTD(false)
+ self:SetEnableMawNameTag(false)
+ self:SetEnableMawChat(false)
+ self:SetEnableThirdPerson(false)
+
+ self.KnownRecipes = {
+ GetItemByName("Axe"),
+ GetItemByName("Campfire"),
+ GetItemByName("Pickaxe"),
+ GetItemByName("Research Table")
+ }
+end
+
+function GM:Think()
+end
diff --git a/gamemode/client/cam.lua b/gamemode/client/cam.lua new file mode 100644 index 0000000..26ff6f2 --- /dev/null +++ b/gamemode/client/cam.lua @@ -0,0 +1,32 @@ +local Off = Vector(0,0,10)
+
+OverrideDefaultGFCamera(function(ply, origin, angles, fov)
+ local Bg = ply:GetRagdollEntity()
+
+ if (IsValid(Bg)) then
+ local view = {
+ origin = Bg:GetPos()-angles:Forward()*80+Off,
+ angles = angles,
+ }
+
+ return view
+ else
+ local Pig = ply:GetPigeon()
+
+ if (IsValid(Pig)) then
+ local view = {
+ origin = Pig:GetPos()-angles:Forward()*80+Off,
+ angles = angles,
+ }
+
+ return view
+ elseif (!ply:Alive() and ply.DeathPos) then
+ local view = {
+ origin = ply.DeathPos-angles:Forward()*80+Off,
+ angles = angles,
+ }
+
+ return view
+ end
+ end
+end)
\ No newline at end of file diff --git a/gamemode/client/color.lua b/gamemode/client/color.lua new file mode 100644 index 0000000..1a0bf0e --- /dev/null +++ b/gamemode/client/color.lua @@ -0,0 +1,3 @@ +MAIN_COLOR = Color(20,20,20,200)
+MAIN_COLORD = Color(0,0,0,100)
+MAIN_TEXTCOLOR = Color(255,255,255,255)
\ No newline at end of file diff --git a/gamemode/client/render_viewmodel.lua b/gamemode/client/render_viewmodel.lua new file mode 100644 index 0000000..3ab1230 --- /dev/null +++ b/gamemode/client/render_viewmodel.lua @@ -0,0 +1,49 @@ +
+local Zero = Vector(1,1,1)
+
+function GM:PreDrawViewModel()
+ local pl = LocalPlayer()
+ local Wep = pl:GetActiveWeapon()
+
+ if (!pl:IsPigeon() and IsValid(Wep)) then return true end
+ return false
+end
+
+function GM:PostDrawOpaqueRenderables()
+ local pl = LocalPlayer()
+ local Wep = pl:GetActiveWeapon()
+
+ if (pl:IsPigeon() or !IsValid(Wep)) then return end
+ if (!pl.Weapons or !pl.Weapons[pl.Select]) then return end
+
+ local Ent = Wep.MOB
+ local item = pl.Weapons[pl.Select].Item
+
+ for k,v in pairs(item.Structure) do
+ local ID = pl:LookupBone(v.Bone)
+ local Pos,Ang = pl:GetBonePosition(ID)
+
+ local Rop = v.Pos*1
+ local Roa = Ang*1
+
+ Roa:RotateAroundAxis(Ang:Right(),v.Ang.p)
+ Roa:RotateAroundAxis(Ang:Forward(),v.Ang.r)
+ Roa:RotateAroundAxis(Ang:Up(),v.Ang.y)
+
+ Rop:Rotate(Ang)
+
+ Ent:SetModel(v.Model)
+ Ent:SetRenderOrigin(Pos+Rop)
+ Ent:SetRenderAngles(Roa)
+
+ local mat = Matrix()
+ mat:Scale( v.Size or Zero )
+
+ Ent:EnableMatrix( "RenderMultiply", mat )
+ Ent:SetupBones()
+
+ Ent:DrawModel()
+ end
+end
+
+
diff --git a/gamemode/hud/draw.lua b/gamemode/hud/draw.lua new file mode 100644 index 0000000..1d30d6a --- /dev/null +++ b/gamemode/hud/draw.lua @@ -0,0 +1,31 @@ +
+local MCO = Color(0,0,0,150)
+
+function GM:HUDPaint()
+ local CountDown = self.CountDown
+
+ if (CountDown and CountDown > CurTime()) then
+ DrawRect(5,5,100,20,MCO)
+ DrawText("Preround: "..math.ceil(CountDown-CurTime()), "Trebuchet18", 10, 6, MAIN_WHITECOLOR)
+ end
+
+ if (CountDown and CountDown < CurTime() and CountDown > CurTime()-MAIN_PVPTIMER) then
+ DrawRect(5,5,130,20,MCO)
+ DrawText("Anti PVP timer: "..math.ceil(CountDown-(CurTime()-MAIN_PVPTIMER)), "Trebuchet18", 10, 6, MAIN_WHITECOLOR)
+ end
+
+ if(#player.GetAll() == 1) then
+ local height = 20
+ local width = 65*6
+ local x = (ScrH()/2) - (height/2)
+ local y = (ScrW()/2) - (width/2)
+ DrawRect(x,y,width,height,MCO)
+ DrawText("Winter Survival requires at least 2 players to begin, Invite a friend!","Trebuchet18",x+3,y, MAIN_WHITECOLOR)
+ end
+
+ DrawAccountInventory()
+ DrawHelp()
+ DrawIndicators()
+ DrawWepSwap()
+ DrawTargets()
+end
diff --git a/gamemode/hud/draw_account.lua b/gamemode/hud/draw_account.lua new file mode 100644 index 0000000..861445c --- /dev/null +++ b/gamemode/hud/draw_account.lua @@ -0,0 +1,136 @@ +
+local SCO = Color(0,0,0,250)
+local MCO = Color(0,0,0,150)
+local x,y = ScrW()-200,30
+
+local AccountMenu = nil
+local Info = nil
+
+hook.Add("Tick","AccountInventory",function()
+ if (input.KeyPress(KEY_F2)) then
+ if IsAccountMenuOpen() then
+ AccountMenu:SetVisible(false)
+ else
+ OpenAccountMenu()
+ end
+ end
+end)
+
+
+function ReloadAccountMenu()
+ if (!IsAccountMenuOpen()) then return end
+ AccountMenu.List:Clear()
+
+ for k,v in pairs(LocalPlayer():GetAccountInventory()) do
+ local a = AccountMenu.List:Add("DPanel")
+ a:SetSize(64,64)
+ a.Item = GetItemByName(v.Name)
+ a.Quantity = v.Quantity
+ a:Droppable("ACCOUNT")
+ a.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+ DrawMaterialRect(0,0,w,h,MAIN_WHITECOLOR,s.Item.Icon)
+
+ DrawText("x"..v.Quantity,"ChatFont",1,h-18,MAIN_TEXTCOLOR)
+ end
+
+ a.OnCursorEntered = function(s)
+ if (!Info) then
+ Info = vgui.Create("DPanel")
+ Info:SetPos(x-410,60)
+ Info:SetSize(195,100)
+ Info.Paint = function(s,w,h) DrawRect(0,0,w,h,SCO) end
+
+ Info.Label = vgui.Create("DLabel",Info)
+ Info.Label:SetPos(5,5)
+ Info.Label:SetSize(185,20)
+
+ Info.LabelDesc = vgui.Create("DLabel",Info)
+ Info.LabelDesc:SetPos(5,30)
+ Info.LabelDesc:SetSize(185,65)
+ Info.LabelDesc:SetWrap(true)
+ Info.LabelDesc:SetAutoStretchVertical(true)
+ end
+
+ Info.Label:SetText(v.Name)
+ Info.LabelDesc:SetText(s.Item.Desc)
+
+ Info:SetVisible(true)
+ end
+
+ a.OnCursorExited = function(s)
+ Info:SetVisible(false)
+ end
+
+ a.OnStopDragging = function(s,a,b,c)
+ end
+
+
+ local Ab = a.OnMousePressed
+ a.OnMousePressed = function(s,m)
+ if (m == MOUSE_RIGHT) then
+ local X,Y = gui.MousePos()
+
+ local menu = DermaMenu()
+ menu.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+ menu:AddOption( "Use", function() if (s.Item) then RequestUseItem(s.Item.Name,true) end end ):SetColor(MAIN_TEXTCOLOR)
+ menu:AddOption( "Destroy", function() if (s.Item) then RequestDropItem(s.Item.Name,true) end end ):SetColor(MAIN_TEXTCOLOR)
+
+ menu:Open()
+ menu:SetPos(X,Y)
+ end
+
+ Ab(s,m)
+ end
+ end
+end
+
+function OpenAccountMenu()
+ if (IsAccountMenuOpen()) then return end
+
+ surface.PlaySound("wintersurvival2/hud/itemopen.wav")
+
+ if (!AccountMenu) then
+ --Inventory
+ AccountMenu = vgui.Create("MBFrame")
+ AccountMenu:SetPos(x-205,y+25)
+ AccountMenu:SetSize(400,400)
+ AccountMenu:SetTitle("Account")
+ AccountMenu:SetDeleteOnClose(false)
+ AccountMenu:MakePopup()
+ AccountMenu.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+ DrawRect(5,20,w-10,20,MCO)
+
+ DrawText("Time spent: "..math.SecondsToTime(LocalPlayer():GetTimeSpent()),"Trebuchet18",8,21,MAIN_WHITECOLOR)
+ end
+ AccountMenu.OnClose = function(s) surface.PlaySound("wintersurvival2/hud/itemequip.wav") end
+
+ local Pane = vgui.Create( "DScrollPanel", AccountMenu )
+ Pane:SetPos(5,45)
+ Pane:SetSize(AccountMenu:GetWide()-10,AccountMenu:GetTall()-50)
+ Pane.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ local l = vgui.Create("DIconLayout",Pane)
+ l:SetSize(Pane:GetWide()-10,Pane:GetTall()-10)
+ l:SetPos(5,5)
+ l:SetSpaceY(5)
+ l:SetSpaceX(5)
+
+ AccountMenu.List = l
+ AccountMenu:ShowCloseButton(false)
+ end
+
+ AccountMenu:SetVisible(true)
+
+ ReloadAccountMenu()
+end
+
+function IsAccountMenuOpen()
+ return (IsValid(AccountMenu) and AccountMenu:IsVisible())
+end
+
+function DrawAccountInventory()
+ DrawRect(x,y,200,20,MCO)
+ DrawText("F2 - Account","Trebuchet18",x+4,y+2,MAIN_TEXTCOLOR)
+end
diff --git a/gamemode/hud/draw_circle.lua b/gamemode/hud/draw_circle.lua new file mode 100644 index 0000000..9620a3d --- /dev/null +++ b/gamemode/hud/draw_circle.lua @@ -0,0 +1,48 @@ +local rad = math.rad
+local cos = math.cos
+local sin = math.sin
+local abs = math.abs
+
+function DrawOutlinedCircle(x,y,r,s,ang,dang,iter,color)
+ ang = rad(ang)
+ dang = rad(dang)
+ iter = iter or 8
+
+ local step = abs(dang)/iter
+
+ surface.SetDrawColor(color.r,color.g,color.b,color.a)
+
+ for i = 0, iter-1 do
+ local r2 = r + s
+ local Time1 = step*i+ang
+ local Time2 = Time1+step
+ local dat = {
+ {
+ x=cos(Time2)*r+x,
+ y=-sin(Time2)*r+y,
+ u=0,
+ v=0,
+ },
+ {
+ x=cos(Time2)*r2+x,
+ y=-sin(Time2)*r2+y,
+ u=1,
+ v=0,
+ },
+ {
+ x=cos(Time1)*r2+x,
+ y=-sin(Time1)*r2+y,
+ u=1,
+ v=1,
+ },
+ {
+ x=cos(Time1)*r+x,
+ y=-sin(Time1)*r+y,
+ u=0,
+ v=1,
+ },
+ }
+
+ surface.DrawPoly(dat)
+ end
+end
\ No newline at end of file diff --git a/gamemode/hud/draw_editor.lua b/gamemode/hud/draw_editor.lua new file mode 100644 index 0000000..9a058c4 --- /dev/null +++ b/gamemode/hud/draw_editor.lua @@ -0,0 +1,746 @@ +
+local Icons = {}
+local Folders = {
+ "wintersurvival2/hud/ws2_icons",
+ "wintersurvival2/hud/ws1_icons",
+ "settlement",
+}
+
+local insert = table.insert
+local cos = math.cos
+local sin = math.sin
+
+local Editor = nil
+local x,y = ScrW()/2,ScrH()/2
+local MCO = Color(0,0,0,150)
+local BCO = Color(0,50,100,150)
+local GCO = Color(0,100,0,150)
+local HCO = Color(30,30,30,150)
+
+local LimitS = 60
+local LimitScale = 5
+
+local ValidBones = {
+ "ValveBiped.Bip01_R_Hand",
+ "ValveBiped.Bip01_L_Hand",
+}
+
+local ValidModels = {
+ "models/props_junk/Rock001a.mdl",
+ "models/props_debris/wood_board02a.mdl",
+ "models/props_combine/breenlight.mdl",
+}
+
+local ValidHoldTypes = {
+ "normal",
+ "melee",
+ "melee2",
+ "fist",
+ "knife",
+ "smg",
+ "ar2",
+ "pistol",
+ "rpg",
+ "physgun",
+ "grenade",
+ "shotgun",
+ "crossbow",
+ "slam",
+ "passive",
+}
+
+
+hook.Add("Initialize","AddEditorIcons",function()
+ for k,v in pairs(Folders) do
+ local F = file.Find("materials/"..v.."/*","GAME")
+
+ for a,icon in pairs(F) do
+ if (!icon:find(".vtf")) then
+ if (icon:find(".vmt")) then icon = icon:gsub(".vmt","") end
+
+ local IM,loadtime = Material(v.."/"..icon)
+ insert(Icons,{Icon = IM,Path = v.."/"..icon,})
+ end
+ end
+ end
+end)
+
+function GetItemIcons()
+ return Icons
+end
+
+
+
+--Now the actual HUD
+
+local Offset = Vector(0,0,50)
+local Zero = Vector(0,0,0)
+local AngZ = Angle(0,0,0)
+local OneV = Vector(1,1,1)
+
+local function ReloadIcons()
+ if (!Editor or !Editor:IsVisible()) then return end
+ Editor.List:Clear()
+
+ for k,v in pairs(Icons) do
+ local a = Editor.List:Add("MBButton")
+ a:SetSize(64,64)
+ a.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h,HCO)
+ else DrawRect(0,0,w,h,MCO) end
+
+ DrawMaterialRect(0,0,w,h,MAIN_WHITECOLOR,v.Icon)
+ end
+ a.DoClick = function(s)
+ Editor.Icon = v.Path
+ Editor.IconEntry:SetText("Icon: "..Editor.Icon)
+ end
+ end
+end
+
+local function ReloadModelList()
+ if (!Editor or !Editor:IsVisible()) then return end
+ Editor.ModelList:Clear()
+
+ for k,v in pairs(Editor.ModelManager.Items) do
+ local a = Editor.ModelList:Add("MBButton")
+ a:SetText("Model "..k)
+ a:SetSize(Editor.ModelList:GetWide()-5,23)
+ a.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h,HCO)
+ else DrawRect(0,0,w,h,MCO) end
+
+ DrawText(s.Text,"Trebuchet18",w/2,h/2,MAIN_TEXTCOLOR,1)
+ end
+ a.DoClick = function(s)
+ local X,Y = gui.MousePos()
+ local menu = DermaMenu()
+ menu.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ local Bones,op = menu:AddSubMenu( "Set bone" )
+ op:SetColor(MAIN_TEXTCOLOR)
+ Bones.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ for d,b in pairs(ValidBones) do
+ Bones:AddOption( b, function() if (v.Bone) then v.Bone = b end end ):SetColor(MAIN_TEXTCOLOR)
+ end
+
+ local Bones,op = menu:AddSubMenu( "Set model" )
+ op:SetColor(MAIN_TEXTCOLOR)
+ Bones.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ for d,b in pairs(ValidModels) do
+ Bones:AddOption( b, function() if (v.Model) then v.Model = b end end ):SetColor(MAIN_TEXTCOLOR)
+ end
+
+ menu:AddOption( "Select", function()
+ if (v.Bone) then
+ Editor.ModelManager.Selected = k
+
+ Editor.SliderX:SetSlideX(0.5+v.Pos.x/LimitS)
+ Editor.SliderX:TranslateValues(0.5+v.Pos.x/LimitS)
+
+ Editor.SliderY:SetSlideX(0.5+v.Pos.y/LimitS)
+ Editor.SliderY:TranslateValues(0.5+v.Pos.y/LimitS)
+
+ Editor.SliderZ:SetSlideX(0.5+v.Pos.z/LimitS)
+ Editor.SliderZ:TranslateValues(0.5+v.Pos.z/LimitS)
+
+ Editor.SliderPitch:SetSlideX(0.5+v.Ang.p/360)
+ Editor.SliderPitch:TranslateValues(0.5+v.Ang.p/360)
+
+ Editor.SliderYaw:SetSlideX(0.5+v.Ang.y/360)
+ Editor.SliderYaw:TranslateValues(0.5+v.Ang.y/360)
+
+ Editor.SliderRoll:SetSlideX(0.5+v.Ang.r/360)
+ Editor.SliderRoll:TranslateValues(0.5+v.Ang.r/360)
+
+ Editor.SliderXScale:SetSlideX(v.Size.x/LimitScale)
+ Editor.SliderXScale:TranslateValues(v.Size.x/LimitScale)
+
+ Editor.SliderYScale:SetSlideX(v.Size.y/LimitScale)
+ Editor.SliderYScale:TranslateValues(v.Size.y/LimitScale)
+
+ Editor.SliderZScale:SetSlideX(v.Size.z/LimitScale)
+ Editor.SliderZScale:TranslateValues(v.Size.z/LimitScale)
+ end
+ end):SetColor(MAIN_TEXTCOLOR)
+
+ menu:AddOption( "Delete", function() if (v.Model) then table.remove(Editor.ModelManager.Items,k) ReloadModelList() end end ):SetColor(MAIN_TEXTCOLOR)
+
+ menu:Open()
+ menu:SetPos(X,Y)
+ end
+ end
+end
+
+function OpenEditor()
+ if (!Editor) then
+ Editor = vgui.Create("MBFrame")
+ Editor:SetPos(x-400,y-300)
+ Editor:SetSize(800,600)
+ Editor:SetTitle("Editor")
+ Editor:SetDeleteOnClose(false)
+ Editor:MakePopup()
+ Editor.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) DrawRect(0,0,w,20,MCO) end
+ Editor.OnClose = function(s) surface.PlaySound("wintersurvival2/hud/itemequip.wav") end
+ Editor.Icon = "wintersurvival2/hud/ws1_icons/icon_axe"
+
+ --Icon list
+ local Pane = vgui.Create( "DScrollPanel", Editor )
+ Pane:SetPos(600,25)
+ Pane:SetSize(195,390)
+ Pane.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ local l = vgui.Create("DIconLayout",Pane)
+ l:SetSize(Pane:GetWide()-10,Pane:GetTall()-10)
+ l:SetPos(5,5)
+ l:SetSpaceY(5)
+ l:SetSpaceX(5)
+
+ Editor.List = l
+ --End
+
+
+ --Model list
+ local Pane = vgui.Create( "DScrollPanel", Editor )
+ Pane:SetPos(5,25)
+ Pane:SetSize(195,390)
+ Pane.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ local l = vgui.Create("DListLayout",Pane)
+ l:SetSize(Pane:GetWide()-10,Pane:GetTall()-10)
+ l:SetPos(5,5)
+
+ Editor.ModelList = l
+ --End
+
+
+ --Model manager
+ local l = vgui.Create("DPanel",Editor)
+ l:SetPos(205,25)
+ l:SetSize(390,390)
+
+ l.Entity = ClientsideModel("models/player/Group03/male_07.mdl")
+ l.Entity:SetNoDraw(true)
+
+ l.EntityItem = ClientsideModel("models/player/Group03/male_07.mdl")
+ l.EntityItem:SetNoDraw(true)
+
+ l.Items = {}
+
+ l.CamDis = 200
+ l.CamPos = Vector(l.CamDis,0,0)
+ l.Origin = Offset
+
+ l.Selected = 0
+
+ l.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+
+ local x, y = s:LocalToScreen( 0, 0 )
+
+ cam.Start3D( s.Origin+s.CamPos, (-s.CamPos):Angle(), 90, x, y, w, h, 1, 4096 )
+ cam.IgnoreZ( true )
+ render.SuppressEngineLighting( true )
+ s.Entity:DrawModel()
+
+ local Mod = s.Entity:GetModel()
+ local Time = CurTime()*10
+
+ for k,v in pairs(s.Items) do
+ if (v.Bone and v.Model and v.Pos and v.Ang and v.Size) then
+ local ind = s.Entity:LookupBone(v.Bone)
+ local Pos,Ang = s.Entity:GetBonePosition(ind)
+
+ if (Pos and Ang) then
+ s.EntityItem:SetModel(v.Model)
+
+ local Rop = v.Pos*1
+ local Roa = Ang*1
+
+ Roa:RotateAroundAxis(Ang:Right(),v.Ang.p)
+ Roa:RotateAroundAxis(Ang:Forward(),v.Ang.r)
+ Roa:RotateAroundAxis(Ang:Up(),v.Ang.y)
+
+ Rop:Rotate(Ang)
+
+ local Org = Pos+Rop
+ local PAng = Roa
+
+ local mat = Matrix()
+ mat:Scale( v.Size or Zero )
+
+ s.EntityItem:EnableMatrix( "RenderMultiply", mat )
+ s.EntityItem:SetRenderOrigin(Org)
+ s.EntityItem:SetRenderAngles(PAng)
+ s.EntityItem:SetupBones()
+
+ if (s.Selected == k) then
+ local A = cos(Time)+2
+ render.SetColorModulation(A,A,A)
+ s.EntityItem:DrawModel()
+ render.SetColorModulation(1,1,1)
+
+ render.DrawLine( Org, Org+PAng:Forward()*20, MAIN_BLUECOLOR, false )
+ render.DrawLine( Org, Org+PAng:Right()*20, MAIN_REDCOLOR, false )
+ render.DrawLine( Org, Org+PAng:Up()*20, MAIN_GREENCOLOR, false )
+
+ s.Origin = Org
+ else
+ s.EntityItem:DrawModel()
+ end
+ end
+ end
+ end
+
+ render.SuppressEngineLighting( false )
+ cam.IgnoreZ( false )
+ cam.End3D()
+ end
+
+ l.Think = function(s)
+ if (s.LastCamDis) then
+ local mx,my = gui.MousePos()
+ local dx,dy = mx-s.LastClickPos.x,my-s.LastClickPos.y
+
+ s.CamDis = math.Clamp(s.LastCamDis + dy,10,200)
+ s.CamPos = s.CamPos:GetNormal()*s.CamDis
+ elseif (s.LastCamPos) then
+ local mx,my = gui.MousePos()
+ local dx,dy = mx-s.LastClickPos.x,my-s.LastClickPos.y
+
+ local Ab = s.LastCamPos:Angle()
+ Ab = Ab + Angle(-dy,-dx,0)
+
+ s.CamPos = Ab:Forward()*s.CamDis
+ end
+ end
+
+ l.OnMousePressed = function(s,m)
+ if (m == MOUSE_RIGHT) then
+ if (!s.LastClickPos) then
+ local x,y = gui.MousePos()
+ s.LastClickPos = {x=x,y=y}
+ s.LastCamDis = s.CamDis*1
+ end
+ elseif (m == MOUSE_LEFT) then
+ if (!s.LastClickPos) then
+ local x,y = gui.MousePos()
+ s.LastClickPos = {x=x,y=y}
+ s.LastCamPos = s.CamPos*1
+ end
+ end
+ end
+
+ l.OnMouseReleased = function(s,m)
+ if (s.LastClickPos) then
+ s.LastClickPos = nil
+ s.LastCamPos = nil
+ s.LastCamDis = nil
+ end
+ end
+
+ Editor.ModelManager = l
+ --End
+
+ --EditorPanels
+ local l = vgui.Create("DPanel",Editor)
+ l:SetPos(5,420)
+ l:SetSize(790,175)
+ l.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ local a = vgui.Create("MBButton",l)
+ a:SetText("Add Model")
+ a:SetPos(5,5)
+ a:SetSize(185,20)
+ a.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h,HCO)
+ else DrawRect(0,0,w,h,MCO) end
+
+ DrawText(s.Text,"Trebuchet18",w/2,h/2,MAIN_TEXTCOLOR,1)
+ end
+ a.DoClick = function(s)
+ local id = insert(Editor.ModelManager.Items,{
+ Bone="ValveBiped.Bip01_R_Hand",
+ Model="models/props_debris/wood_board02a.mdl",
+ Size=Vector(1,1,1),
+ Pos=Vector(0,0,0),
+ Ang=Angle(0,0,0),
+ })
+
+ Editor.ModelManager.Selected = id
+
+ Editor.SliderX:SetSlideX(0.5)
+ Editor.SliderX:TranslateValues(0.5)
+
+ Editor.SliderY:SetSlideX(0.5)
+ Editor.SliderY:TranslateValues(0.5)
+
+ Editor.SliderZ:SetSlideX(0.5)
+ Editor.SliderZ:TranslateValues(0.5)
+
+ Editor.SliderPitch:SetSlideX(0.5)
+ Editor.SliderPitch:TranslateValues(0.5)
+
+ Editor.SliderYaw:SetSlideX(0.5)
+ Editor.SliderYaw:TranslateValues(0.5)
+
+ Editor.SliderRoll:SetSlideX(0.5)
+ Editor.SliderRoll:TranslateValues(0.5)
+
+ local S = 1/LimitScale
+
+ Editor.SliderXScale:SetSlideX(S)
+ Editor.SliderXScale:TranslateValues(S)
+
+ Editor.SliderYScale:SetSlideX(S)
+ Editor.SliderYScale:TranslateValues(S)
+
+ Editor.SliderZScale:SetSlideX(S)
+ Editor.SliderZScale:TranslateValues(S)
+
+ ReloadModelList()
+ end
+
+ local Title = vgui.Create("DTextEntry",l)
+ Title:SetText("Item Name")
+ Title:SetPos(5,55)
+ Title:SetSize(185,20)
+
+ local Icon = vgui.Create("DTextEntry",l)
+ Icon:SetText("Icon: "..Editor.Icon)
+ Icon:SetPos(205,145)
+ Icon:SetSize(380,20)
+ Icon:SetEditable(false)
+
+ local Desc = vgui.Create("DTextEntry",l)
+ Desc:SetText("Description")
+ Desc:SetPos(5,80)
+ Desc:SetSize(185,60)
+ Desc:SetMultiline(true)
+
+ local ModelP = vgui.Create("DComboBox",l)
+ ModelP:SetPos(5,145)
+ ModelP:SetSize(185,20)
+
+ for k,v in pairs(ValidModels) do
+ if (k==1) then ModelP:AddChoice(v,nil,true)
+ else ModelP:AddChoice(v) end
+ end
+
+ local HoldType = vgui.Create("DComboBox",l)
+ HoldType:SetPos(600,145)
+ HoldType:SetSize(185,20)
+
+ for k,v in pairs(ValidHoldTypes) do
+ if (k==1) then HoldType:AddChoice(v,nil,true)
+ else HoldType:AddChoice(v) end
+ end
+
+ Editor.IconEntry = Icon
+
+ --OffsetSliders... Gawd why does VGUI has to be so LOOONG!!!!
+ --SlideX
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(405,5)
+ B:SetText("x offset")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(490,5)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(410,25)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil((x*LimitS-LimitS/2)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Pos.x = V
+ end
+ return x, y
+ end
+
+ Editor.SliderX = SlideOffset
+ --End
+
+ --SlideY
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(405,50)
+ B:SetText("y offset")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(490,50)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(410,70)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil((x*LimitS-LimitS/2)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Pos.y = V
+ end
+ return x, y
+ end
+
+ Editor.SliderY = SlideOffset
+ --End
+
+ --SlideZ
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(405,95)
+ B:SetText("z offset")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(490,95)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(410,115)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil((x*LimitS-LimitS/2)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Pos.z = V
+ end
+ return x, y
+ end
+
+ Editor.SliderZ = SlideOffset
+ --End
+ --End
+
+ --OffsetSliders Angles
+ --SlidePitch
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(605,5)
+ B:SetText("Pitch")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(690,5)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(610,25)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil((x*360-180)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Ang.p = V
+ end
+ return x, y
+ end
+
+ Editor.SliderPitch = SlideOffset
+ --End
+
+ --SlideYaw
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(605,50)
+ B:SetText("Yaw")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(690,50)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(610,70)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil((x*360-180)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Ang.y = V
+ end
+ return x, y
+ end
+
+ Editor.SliderYaw = SlideOffset
+ --End
+
+ --SlideRoll
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(605,95)
+ B:SetText("Roll")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(690,95)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(610,115)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil((x*360-180)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Ang.r = V
+ end
+ return x, y
+ end
+
+ Editor.SliderRoll = SlideOffset
+ --End
+ --End
+
+ --OffsetScale
+ --SlideX
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(205,5)
+ B:SetText("x offset")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(290,5)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(210,25)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil(math.max(0.01,x*LimitScale)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Size.x = V
+ end
+ return x, y
+ end
+
+ Editor.SliderXScale = SlideOffset
+ --End
+
+ --SlideY
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(205,50)
+ B:SetText("y offset")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(290,50)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(210,70)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil(math.max(0.01,x*LimitScale)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Size.y = V
+ end
+ return x, y
+ end
+
+ Editor.SliderYScale = SlideOffset
+ --End
+
+ --SlideZ
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(205,95)
+ B:SetText("z offset")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(290,95)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(210,115)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil(math.max(0.01,x*LimitScale)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Size.z = V
+ end
+ return x, y
+ end
+
+ Editor.SliderZScale = SlideOffset
+ --End
+ --End
+
+ local Compile = vgui.Create("MBButton",l)
+ Compile:SetText("Compile")
+ Compile:SetPos(5,30)
+ Compile:SetSize(185,20)
+ Compile.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h,HCO)
+ else DrawRect(0,0,w,h,MCO) end
+
+ DrawText(s.Text,"Trebuchet18",w/2,h/2,MAIN_TEXTCOLOR,1)
+ end
+ Compile.DoClick = function(s)
+ local Text = ""
+
+ Text = Text.."ITEM.Name\t= [["..Title:GetValue().."]]\n"
+ Text = Text.."ITEM.Desc\t= [["..Desc:GetValue().."]]\n"
+ Text = Text.."ITEM.Model\t= [["..ModelP:GetValue().."]]\n"
+ Text = Text.."ITEM.Icon\t= Material([["..Editor.Icon.."]])\n"
+ Text = Text.."ITEM.HoldType\t= [["..HoldType:GetValue().."]]\n"
+ Text = Text.."ITEM.Structure\t= {\n"
+
+ for k,v in pairs(Editor.ModelManager.Items) do
+ Text = Text.."\t{\n"
+ Text = Text.."\t\tBone\t= \""..v.Bone.."\",\n"
+ Text = Text.."\t\tModel\t= \""..v.Model.."\",\n"
+ Text = Text.."\t\tSize\t= Vector("..v.Size.x..","..v.Size.y..","..v.Size.z.."),\n"
+ Text = Text.."\t\tPos \t= Vector("..v.Pos.x..","..v.Pos.y..","..v.Pos.z.."),\n"
+ Text = Text.."\t\tAng \t= Angle("..v.Ang.p..","..v.Ang.y..","..v.Ang.r.."),\n"
+ Text = Text.."\t},\n"
+ end
+
+ Text = Text.."}\n"
+
+ if (!file.Exists("wsitems","DATA")) then file.CreateDir("wsitems") end
+ file.Write("wsitems/"..Title:GetValue()..".txt",Text)
+
+ print("Item has been compiled and is located in garrysmod/data/wsitems folder.")
+ end
+ --End
+ end
+
+ Editor.ModelManager.CamDis = 200
+ Editor.ModelManager.CamPos = Vector(200,0,0)
+
+ Editor:SetVisible(true)
+
+ ReloadIcons()
+end
+
+
+
+concommand.Add("ws_openeditor",function(pl,com,arg) OpenEditor() end)
diff --git a/gamemode/hud/draw_help.lua b/gamemode/hud/draw_help.lua new file mode 100644 index 0000000..b1b9425 --- /dev/null +++ b/gamemode/hud/draw_help.lua @@ -0,0 +1,106 @@ +
+local MCO = Color(0,0,0,150)
+
+MAIN_HELP = false
+MAIN_HELP_PAGES = 5
+
+hook.Add("Tick","Help",function()
+ if (input.KeyPress(KEY_F1)) then
+ if (MAIN_HELP and MAIN_HELP < MAIN_HELP_PAGES) then
+ MAIN_HELP = MAIN_HELP + 1
+ elseif (MAIN_HELP) then MAIN_HELP = false
+ else MAIN_HELP = 1 end
+ end
+end)
+
+local function WrapString(str,width)
+ local dp = string.Explode(" ",str)
+ local dout = dp[1]
+ local curline = dout
+
+ for k,v in pairs(dp) do
+ if k ~= 1 then
+ local sz = surface.GetTextSize(curline)
+ local sza = surface.GetTextSize(" "..v)
+ if sz+sza < width then
+ dout = dout .. " " .. v
+ curline = curline .. " " .. v
+ else
+ dout = dout .. "\n" .. v
+ curline = v
+ end
+ end
+ end
+
+ return dout
+end
+
+function DrawHelp()
+ local gx,gy = 5,30
+
+ if (!MAIN_HELP) then
+ DrawRect(gx,gy,140,20,MCO)
+ DrawText("F1 - Help/Next Page","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR)
+ return
+ end
+
+ DrawRect(gx,gy,256,392,MCO)
+
+ gx = gx + 4
+ gy = gy + 4
+
+ if (MAIN_HELP == 1) then
+ draw.DrawText("Bird","Trebuchet24",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 24
+
+ draw.DrawText("Controls:\n\t[W] Fly/Move forward\n\t[Mouse] Steer the bird\n\t[Left Mouse] Taunt\n","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 72
+
+ draw.DrawText("Purpose:"..WrapString("\n You are a spectator. When you first join, you are assigned as a bird. To become a human you must wait until the round is over, which means you will have to wait til everyones dead.\n\nIn addition to this, the gamemode needs atleast 2 people in the server before the round can actually begin, invite a friend over!\n\nAlternativly, players can perform ritual resurrections to bring a player back to life.",240),"Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ elseif (MAIN_HELP == 2) then
+ draw.DrawText("Survivor","Trebuchet24",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 24
+
+ draw.DrawText("Controls:\n\t[WASD] Move around\n\t[Mouse] Aim\n\t[Left Mouse] Attack\n\t[Scroll] Select equipment\n","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 90
+
+ draw.DrawText("Halo:\n","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 18
+
+ draw.DrawText("\t[GREEN] \t- Hunger","Trebuchet18",gx+4,gy,MAIN_GREENCOLOR,0)
+ gy = gy + 18
+
+ draw.DrawText("\t[BLUE] \t- Thirst","Trebuchet18",gx+4,gy,MAIN_BLUECOLOR,0)
+ gy = gy + 18
+
+ draw.DrawText("\t[YELLOW] \t- Fatigue","Trebuchet18",gx+4,gy,MAIN_YELLOWCOLOR,0)
+ gy = gy + 18
+
+ draw.DrawText("\t[RED] \t- Heat","Trebuchet18",gx+4,gy,MAIN_REDCOLOR,0)
+ gy = gy + 18
+
+ draw.DrawText("\t[WHITE] \t- Health","Trebuchet18",gx+4,gy,MAIN_WHITECOLOR,0)
+ elseif (MAIN_HELP == 3) then
+ draw.DrawText("Inventory","Trebuchet24",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 24
+
+ draw.DrawText("While hovering:\n\t[Right Click] Open drop-down menu\n\t[Left Click] Start dragging item\n\t[Hover] Item info\n","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 72
+
+ draw.DrawText("While dragging:\n\tDrop in a slot to equip\n\tDrop outside inventory to drop it\n","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 54
+
+ draw.DrawText("Drop-down menu:\n\t[Drop] Drops the item\n\t[Use] Use/Eat the item\n","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ elseif (MAIN_HELP == 4) then
+ draw.DrawText("Recipes:","Trebuchet24",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 24
+
+ surface.SetFont("Trebuchet18")
+ draw.DrawText(WrapString("Combining:\n To create an item, you drag and drop an item into the bottom of your recipes menu and then press combine. If there is a recipe corresponding to the items you placed, then a recipe will be discovered and you can select it from your recipes list to create the item.",240),"Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ elseif (MAIN_HELP == 5) then
+ draw.DrawText("Credits:","Trebuchet24",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 24
+
+ draw.DrawText("The Maw\nThirteen (Notes textures)\nApickx","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ end
+end
diff --git a/gamemode/hud/draw_indicators.lua b/gamemode/hud/draw_indicators.lua new file mode 100644 index 0000000..2daf925 --- /dev/null +++ b/gamemode/hud/draw_indicators.lua @@ -0,0 +1,60 @@ +
+local x,y = ScrW()-140,ScrH()-140
+local cos = math.cos
+
+function DrawIndicators()
+ local pl = LocalPlayer()
+ if (pl:IsPigeon()) then return end
+
+ local HP = pl:Health()
+ local HP_c = 1-math.max(0,HP/100)
+ local A = MAIN_WHITECOLOR.a*1
+
+ --1 == Hunger
+ --2 == Thirst
+ --3 == Heat
+ --4 == Fatigue
+
+ local Cur = UnPredictedCurTime()*0.1%1*360
+ local Time = (cos(Cur)+1)/2
+ local CUR = (cos(UnPredictedCurTime())+1)/2
+
+ for i = 1,4 do
+ local Col = MAIN_GREENCOLOR
+ local Siz = 4
+
+ if (i == 1) then Col = MAIN_GREENCOLOR Siz=Siz+30*math.Clamp(pl:GetHunger()/100,0,1)
+ elseif (i == 2) then Col = MAIN_BLUECOLOR Siz=Siz+30*math.Clamp(pl:GetWater()/100,0,1)
+ elseif (i == 3) then Col = MAIN_REDCOLOR Siz=Siz+30*math.Clamp(pl:GetHeat()/100,0,1)
+ else Col = MAIN_YELLOWCOLOR Siz=Siz+30*math.Clamp(pl:GetFatigue()/100,0,1)
+ end
+
+ local AB = Col.a*1
+ Col.a = 200+50*CUR
+
+ DrawOutlinedCircle(x,y,Siz,8,Cur+90*i,90,8,Col)
+
+ Col.a = AB
+ end
+
+ --HP
+ local Time = 255-(255*HP_c)*(cos(UnPredictedCurTime()*(1+10*HP_c))+1)/2
+ MAIN_WHITECOLOR.r = Time
+ MAIN_WHITECOLOR.g = Time
+ MAIN_WHITECOLOR.b = Time
+
+ DrawOutlinedCircle(x,y,40,8,Cur,360,32,MAIN_WHITECOLOR)
+
+ MAIN_WHITECOLOR.r = 255
+ MAIN_WHITECOLOR.g = 255
+ MAIN_WHITECOLOR.b = 255
+
+ local Time2 = (cos(UnPredictedCurTime()*2*(1+3*HP_c))+1)/2
+ local Alpha = math.max(0,50-90*Time2)
+
+ MAIN_WHITECOLOR.a = Alpha
+
+ DrawOutlinedCircle(x,y,40+200*Time2,8,Cur*30,360,32,MAIN_WHITECOLOR)
+
+ MAIN_WHITECOLOR.a = 255
+end
diff --git a/gamemode/hud/draw_lootventory.lua b/gamemode/hud/draw_lootventory.lua new file mode 100644 index 0000000..fc62280 --- /dev/null +++ b/gamemode/hud/draw_lootventory.lua @@ -0,0 +1,77 @@ +local Ventory = nil
+local MCO = Color(0,0,0,150)
+
+function ReloadLootventory()
+ if (!IsValid(Ventory)) then return end
+
+ Ventory.List:Clear()
+
+ for k,v in pairs(Ventory.DATA) do
+ local a = Ventory.List:Add("DPanel")
+ a:SetSize(64,64)
+ a.Item = GetItemByName(v.Name)
+ a.Par = Ventory
+ a.Quantity = v.Quantity
+ a:Droppable("LOOTVENTORY")
+ a.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+ if (s.Item) then DrawMaterialRect(0,0,w,h,MAIN_WHITECOLOR,s.Item.Icon) end
+
+ DrawText("x"..v.Quantity,"ChatFont",1,h-18,MAIN_TEXTCOLOR)
+ end
+ end
+end
+
+function IsLootventoryOpen()
+ return (Ventory and Ventory:IsVisible())
+end
+
+function CloseLootventory()
+ if (!IsLootventoryOpen()) then return end
+
+ Ventory:SetVisible(false)
+end
+
+function MakeLootventory(dat,ent)
+ if (!dat) then return end
+
+ if (!Ventory) then
+ Ventory = vgui.Create("MBFrame")
+ Ventory:SetPos(690,ScrH()-480)
+ Ventory:SetSize(200,200)
+ Ventory:SetTitle("Lootventory")
+ Ventory:SetDeleteOnClose(false)
+ --Ventory:MakePopup()
+ Ventory:ShowCloseButton(false)
+ Ventory.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+ Ventory.OnClose = function(s) surface.PlaySound("wintersurvival2/hud/itemequip.wav") end
+
+ local Pane = vgui.Create( "DScrollPanel", Ventory )
+ Pane:SetPos(5,25)
+ Pane:SetSize(Ventory:GetWide()-10,Ventory:GetTall()-30)
+ Pane.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+ Pane:Receiver("INVENTORY", function(s,a,b,c)
+ local p = a[1]
+
+ if (p.Item and IsValid(Ventory.Entity) and b) then
+ TransferItems(p.Item.Name,p.Quantity,Ventory.Entity)
+ DemandLootventoryUpdate(Ventory.Entity)
+ end
+ end)
+
+ local l = vgui.Create("DIconLayout",Pane)
+ l:SetSize(Pane:GetWide()-10,Pane:GetTall()-10)
+ l:SetPos(5,5)
+ l:SetSpaceY(5)
+ l:SetSpaceX(5)
+
+ Ventory.List = l
+ end
+
+ Ventory:SetVisible(true)
+
+ Ventory.Entity = ent
+ Ventory.DATA = dat
+
+ ReloadLootventory()
+end
diff --git a/gamemode/hud/draw_qmenu.lua b/gamemode/hud/draw_qmenu.lua new file mode 100644 index 0000000..1466704 --- /dev/null +++ b/gamemode/hud/draw_qmenu.lua @@ -0,0 +1,346 @@ +local Inventory = nil
+local RecipeMenu = nil
+local MCO = Color(0,0,0,150)
+local BCO = Color(0,50,100,150)
+local GCO = Color(0,100,0,150)
+local HCO = Color(30,30,30,150)
+
+--Garry... for the love of god, this fucking function is spamming the console with debug information.
+--I decided to override it so it shuts up!
+dragndrop.HandleDroppedInGame = function() end
+
+function ReloadInventory()
+ if (!IsInventoryOpen()) then return end
+ Inventory.List:Clear()
+
+ ReloadRecipes()
+
+ for k,v in pairs(LocalPlayer():GetInventory()) do
+ local a = Inventory.List:Add("DPanel")
+ a:SetSize(64,64)
+ a.Item = GetItemByName(v.Name)
+ a.Quantity = v.Quantity
+ a:Droppable("INVENTORY")
+ a.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+ DrawMaterialRect(0,0,w,h,MAIN_WHITECOLOR,s.Item.Icon)
+
+ DrawText("x"..v.Quantity,"ChatFont",1,h-18,MAIN_TEXTCOLOR)
+ end
+
+ a.OnStopDragging = function(s,a,b,c)
+ local ID = IsMouseInSlot()
+
+ if (!ID) then return end
+
+ RequestEquip(ID,s.Item.Name)
+ end
+
+ local Ab = a.OnMousePressed
+ a.OnMousePressed = function(s,m)
+ if (m == MOUSE_RIGHT) then
+ local X,Y = gui.MousePos()
+
+ local menu = DermaMenu()
+ menu.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+ menu:AddOption( "Use", function() if (s.Item) then RequestUseItem(s.Item.Name) end end ):SetColor(MAIN_TEXTCOLOR)
+ menu:AddOption( "Drop", function() if (s.Item) then RequestDropItem(s.Item.Name) end end ):SetColor(MAIN_TEXTCOLOR)
+
+ menu:Open()
+ menu:SetPos(X,Y)
+ end
+
+ Ab(s,m)
+ end
+
+ a.OnCursorEntered = function(s)
+ Inventory.Desc:SetVisible(true)
+ Inventory.Desc:SetText(s.Item.Name.."\n\n"..s.Item.Desc)
+ Inventory.CraftingButton:SetVisible(false)
+
+ s.Hover = true
+ end
+
+ a.OnCursorExited = function(s)
+ Inventory.Desc:SetVisible(false)
+
+ if (RecipeMenu.SelectedRecipe) then
+ Inventory.CraftingButton:SetVisible(true)
+ end
+
+ s.Hover = false
+ end
+ end
+end
+
+function ReloadRecipes()
+ if (!IsInventoryOpen()) then return end
+ RecipeMenu.List:Clear()
+ RecipeMenu.Combine.Items = {}
+
+ for k,v in pairs(GAMEMODE.KnownRecipes) do
+ local a = RecipeMenu.List:Add("MBButton")
+ a:SetText(v.Name)
+ a:SetSize(RecipeMenu.List:GetWide()-5,23)
+ a.Item = v
+ a.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h-3,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h-3,HCO)
+ else DrawRect(0,0,w,h-3,MCO) end
+
+ DrawText(s.Item.Name,"Trebuchet18",4,0,MAIN_TEXTCOLOR)
+ end
+ a.DoClick = function(s)
+ if (RecipeMenu.SelectedRecipe == a.Item) then RecipeMenu.SelectedRecipe = nil Inventory.CraftingButton:SetVisible(false)
+ else RecipeMenu.SelectedRecipe = a.Item Inventory.CraftingButton:SetVisible(true) end
+ end
+ end
+end
+
+function GM:OnSpawnMenuOpen()
+ if (LocalPlayer():IsPigeon()) then return end
+ if (IsInventoryOpen()) then return end
+
+ surface.PlaySound("wintersurvival2/hud/itemopen.wav")
+
+ if (!Inventory) then
+ --Recipes
+ RecipeMenu = vgui.Create("MBFrame")
+ RecipeMenu:SetPos(485,ScrH()-480)
+ RecipeMenu:SetSize(200,400)
+ RecipeMenu:SetTitle("Recipes")
+ RecipeMenu:ShowCloseButton(false)
+ RecipeMenu.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+ RecipeMenu.SelectedRecipe = nil
+
+ local Pane = vgui.Create( "DScrollPanel", RecipeMenu )
+ Pane:SetPos(5,25)
+ Pane:SetSize(RecipeMenu:GetWide()-10,RecipeMenu:GetTall()-150)
+ Pane.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ local l = vgui.Create("DListLayout",Pane)
+ l:SetSize(Pane:GetWide()-10,Pane:GetTall()-10)
+ l:SetPos(5,5)
+
+ RecipeMenu.List = l
+
+ local c = vgui.Create( "MBFrame", RecipeMenu )
+ c:SetPos(5,RecipeMenu:GetTall()-120)
+ c:SetSize(RecipeMenu:GetWide()-10,115)
+ c:SetTitle("")
+ c:ShowCloseButton(false)
+ c.Items = {}
+ c.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+
+ local Press = input.MousePress(MOUSE_LEFT,"MenuPress")
+
+ if (table.Count(s.Items) < 1) then
+ DrawText("Draw items here!","Trebuchet24",w/2,h/2-3,MAIN_WHITECOLOR,1)
+ else
+ for i = 1,4 do
+ local v = s.Items[i]
+
+ if (v and v.Name) then
+ local Item = GetItemByName(v.Name)
+ local y = -15+20*i
+ local x = 5
+
+ local X,Y = s:GetParent():GetPos()
+ local SX,SY = s:GetPos()
+ X = X+SX
+ Y = Y+SY
+
+ if (!input.IsMouseInBox(X+x,Y+y,w-10,18)) then DrawRect(x,y,w-10,18,MCO)
+ else
+ DrawRect(x,y,w-10,18,GCO)
+
+ if (Press) then
+ s.Items[i] = nil
+ break
+ end
+ end
+
+ if (Item.Icon) then
+ DrawMaterialRect(x+1,y+1,16,16,MAIN_WHITECOLOR,Item.Icon)
+ end
+
+ DrawText("x "..v.Quantity.." "..v.Name,"Trebuchet18",23,y,MAIN_WHITECOLOR)
+ end
+ end
+ end
+ end
+ c:Receiver("INVENTORY", function(s,a,b,c)
+ local p = a[1]
+
+ if (p.Item and b) then
+ local Find = false
+
+ for i = 1,4 do
+ if (s.Items[i] and s.Items[i].Name == p.Item.Name) then
+ if (LocalPlayer():HasItem(s.Items[i].Name,s.Items[i].Quantity+1)) then
+ s.Items[i].Quantity = s.Items[i].Quantity + 1
+ end
+
+ Find = true
+ break
+ end
+ end
+
+ if (!Find) then
+ for i = 1,4 do
+ if (!s.Items[i]) then
+ s.Items[i] = {Name = p.Item.Name,Quantity = 1}
+ break
+ end
+ end
+ end
+ end
+ end)
+
+ local B = vgui.Create("MBButton",c)
+ B:SetPos(5,c:GetTall()-25)
+ B:SetSize(c:GetWide()-10,20)
+ B:SetVisible(true)
+ B.DoClick = function(s)
+ local Items = RecipeMenu.Combine.Items
+
+ if (Items and table.Count(Items) > 0) then
+ DiscoverItems(Items)
+ end
+ end
+ B.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h-3,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h-3,HCO)
+ else DrawRect(0,0,w,h-3,MCO) end
+
+ DrawText("Combine","Trebuchet18",w/2,h/2,MAIN_TEXTCOLOR,1)
+ end
+
+ RecipeMenu.Combine = c
+
+ --Inventory
+ Inventory = vgui.Create("MBFrame")
+ Inventory:SetPos(80,ScrH()-480)
+ Inventory:SetSize(400,400)
+ Inventory:SetTitle("Inventory")
+ Inventory:SetDeleteOnClose(false)
+ Inventory:MakePopup()
+ Inventory:SetVisible(false)
+ Inventory:ShowCloseButton(false)
+ Inventory.OnKeyCodePressed = function(panel, key)
+ if(key == 27 or key == 15) then
+ if(Inventory and Inventory:IsVisible())then
+ Inventory:SetVisible(false)
+ RecipeMenu:SetVisible(false)
+ CloseLootventory()
+ surface.PlaySound("wintersurvival2/hud/itemequip.wav")
+ else
+ Inventory:SetVisible(true)
+ RecipeMenu:SetVisible(true)
+ end
+ end
+ end
+ Inventory.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+
+ local X,Y,W,H = 5,h-120,w-10,115
+ DrawRect(X,Y,W,H,MCO)
+
+ local Rec = RecipeMenu.SelectedRecipe
+
+ if (Rec and Inventory.CraftingButton:IsVisible()) then
+ local Recipe = Rec.Recipe
+ local pl = LocalPlayer()
+ local C = 0
+ local Step = W/3
+
+ DrawText("Products:","Trebuchet18",X+5,Y,MAIN_TEXTCOLOR)
+ DrawText("Reagents:","Trebuchet18",X+Step+5,Y,MAIN_TEXTCOLOR)
+ DrawText("Tools:","Trebuchet18",X+Step*2+5,Y,MAIN_TEXTCOLOR)
+
+ for k,v in pairs(Recipe.Resources) do
+ C = C+1
+ if (pl:HasItem(k,v)) then DrawText(v.." x "..k,"Trebuchet18",X+Step+5,Y+16*C,MAIN_GREENCOLOR)
+ else DrawText(v.." x "..k,"Trebuchet18",X+Step+5,Y+16*C,MAIN_REDCOLOR) end
+ end
+
+ C = 0
+ for k,v in pairs(Recipe.Tools) do
+ C = C+1
+ if (pl:HasItem(k,v)) then DrawText(v.."x "..k,"Trebuchet18",X+5+Step*2,Y+16*C,MAIN_GREENCOLOR)
+ else DrawText(v.."x "..k,"Trebuchet18",X+5+Step*2,Y+16*C,MAIN_REDCOLOR) end
+ end
+
+ DrawText("1 x "..Rec.Name,"Trebuchet18",X+5,Y+16,MAIN_GREENCOLOR)
+ end
+ end
+ Inventory.OnClose = function(s) CloseLootventory() RecipeMenu:SetVisible(false) surface.PlaySound("wintersurvival2/hud/itemequip.wav") end
+
+ local Pane = vgui.Create( "DScrollPanel", Inventory )
+ Pane:SetPos(5,25)
+ Pane:SetSize(Inventory:GetWide()-10,Inventory:GetTall()-150)
+ Pane.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+ Pane:Receiver("LOOTVENTORY", function(s,a,b,c)
+ local p = a[1]
+
+ if (p.Item and IsValid(p.Par.Entity) and b) then
+ DemandItems(p.Item.Name,p.Quantity,p.Par.Entity)
+ DemandLootventoryUpdate(p.Par.Entity)
+ end
+ end)
+
+ local l = vgui.Create("DIconLayout",Pane)
+ l:SetSize(Pane:GetWide()-10,Pane:GetTall()-10)
+ l:SetPos(5,5)
+ l:SetSpaceY(5)
+ l:SetSpaceX(5)
+
+ Inventory.List = l
+
+ local B = vgui.Create("MBButton",Inventory)
+ B:SetPos(Inventory:GetWide()-110,Inventory:GetTall()-25)
+ B:SetSize(100,20)
+ B:SetVisible(false)
+ B.DoClick = function(s)
+ if (RecipeMenu.SelectedRecipe) then RequestCreateRecipe(RecipeMenu.SelectedRecipe.Name) end
+ end
+ B.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h-3,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h-3,HCO)
+ else DrawRect(0,0,w,h-3,MCO) end
+
+ DrawText("Craft!","Trebuchet18",w/2,h/2,MAIN_TEXTCOLOR,1)
+ end
+
+ Inventory.CraftingButton = B
+
+ local a = vgui.Create("DLabel",Inventory)
+ a:SetPos(10,Inventory:GetTall()-120)
+ a:SetSize(Inventory:GetWide()-2,1)
+ a:SetText("")
+ a:SetWrap(true)
+ a:SetVisible(false)
+ a:SetTextColor(MAIN_TEXTCOLOR)
+ a:SetFont("Trebuchet18")
+ a:SetAutoStretchVertical(true)
+
+ Inventory.Desc = a
+ end
+
+ --RecipeMenu:SetVisible(true)
+ --Inventory:SetVisible(true)
+ if(Inventory and Inventory:IsVisible())then
+ Inventory:SetVisible(false)
+ RecipeMenu:SetVisible(false)
+ else
+ Inventory:SetVisible(true)
+ RecipeMenu:SetVisible(true)
+ end
+
+ ReloadInventory()
+end
+
+function IsInventoryOpen()
+ return (Inventory and Inventory:IsVisible())
+end
diff --git a/gamemode/hud/draw_scoreboard.lua b/gamemode/hud/draw_scoreboard.lua new file mode 100644 index 0000000..8062c56 --- /dev/null +++ b/gamemode/hud/draw_scoreboard.lua @@ -0,0 +1,40 @@ +local SCOREBOARD_FADE = Color(20,20,20,70)
+
+local SCOREBOARD_OFF = 101
+local SCOREBOARD_WIDTH = 700
+local SCOREBOARD_X = ScrW() / 2 - SCOREBOARD_WIDTH / 2
+
+function GM:ScoreboardShow()
+ self.ShowSB = true
+end
+
+function GM:ScoreboardHide()
+ self.ShowSB = false
+end
+
+function GM:HUDDrawScoreBoard()
+ if (!self.ShowSB) then return end
+
+ local NPly = #player.GetAll()
+ local Tall = SCOREBOARD_OFF + 20 * NPly
+ local y = ScrH() / 2 - Tall / 2
+ local by = y + SCOREBOARD_OFF
+
+ DrawRect(SCOREBOARD_X, y, SCOREBOARD_WIDTH, Tall, MAIN_COLOR)
+ DrawRect(SCOREBOARD_X, by, SCOREBOARD_WIDTH, NPly*20, MAIN_COLORD)
+
+ DrawText(self.Name, "ScoreboardFont", ScrW()/2, y + 50, MAIN_TEXTCOLOR,1)
+ DrawText("By The Maw", "Trebuchet18", ScrW()/2-150, y + 80, MAIN_TEXTCOLOR,1)
+
+ for k,v in pairs( player.GetAll() ) do
+ local Y = by + 20 * (k-1)
+
+ if (v:IsPigeon()) then
+ DrawText(v:Nick(), "Trebuchet18", SCOREBOARD_X + 2, Y, MAIN_GREYCOLOR)
+ DrawText(v:Ping(), "Trebuchet18", SCOREBOARD_X + SCOREBOARD_WIDTH - 30, Y, MAIN_GREYCOLOR)
+ else
+ DrawText(v:Nick(), "Trebuchet18", SCOREBOARD_X + 2, Y, MAIN_TEXTCOLOR)
+ DrawText(v:Ping(), "Trebuchet18", SCOREBOARD_X + SCOREBOARD_WIDTH - 30, Y, MAIN_TEXTCOLOR)
+ end
+ end
+end
diff --git a/gamemode/hud/draw_targets.lua b/gamemode/hud/draw_targets.lua new file mode 100644 index 0000000..b5eadac --- /dev/null +++ b/gamemode/hud/draw_targets.lua @@ -0,0 +1,11 @@ +function DrawTargets()
+ local pl = LocalPlayer()
+
+ if (pl:IsPigeon()) then return end
+
+ local tr = pl:GetEyeTrace()
+
+ if (IsValid(tr.Entity) and tr.Entity:IsPlayer()) then
+ DrawText(tr.Entity:Nick(),"ChatFont",ScrW()/2,ScrH()/2,MAIN_YELLOWCOLOR,1)
+ end
+end
\ No newline at end of file diff --git a/gamemode/hud/draw_voicechat.lua b/gamemode/hud/draw_voicechat.lua new file mode 100644 index 0000000..f0c63c8 --- /dev/null +++ b/gamemode/hud/draw_voicechat.lua @@ -0,0 +1,33 @@ +local VoiceEna = true
+local VOCOL = table.Copy(MAIN_COLOR)
+local x,y = ScrW(),ScrH()
+
+function GM:PlayerStartVoice( ply )
+ ply.Talking = true
+end
+
+function GM:PlayerEndVoice( ply )
+ ply.Talking = nil
+end
+
+hook.Add("HUDPaint","_VoiceChatDraw",function()
+ local D = 0
+
+ for k,v in pairs( player.GetAll() ) do
+ if (v.Talking) then
+ local H = 45*D
+ D = D+1
+
+ local V = v:VoiceVolume()
+ local D = MAIN_COLOR
+
+ VOCOL.r = math.Clamp(D.r-100*V,0,255)
+ VOCOL.g = math.Clamp(D.g+200*V,0,255)
+ VOCOL.b = math.Clamp(D.b-100*V,0,255)
+
+ DrawRect( x-250, y-170-H, 200, 40, VOCOL )
+ DrawRect( x-246, y-166-H, 32, 32, MAIN_WHITECOLOR )
+ DrawText( v:Nick(), "Trebuchet18", x-206, y-159-H, MAIN_TEXTCOLOR )
+ end
+ end
+end)
\ No newline at end of file diff --git a/gamemode/hud/draw_wepswap.lua b/gamemode/hud/draw_wepswap.lua new file mode 100644 index 0000000..40c2310 --- /dev/null +++ b/gamemode/hud/draw_wepswap.lua @@ -0,0 +1,64 @@ +local Num = 0
+local MCO = Color(0,0,0,150)
+
+local max = math.max
+local min = math.min
+local cos = math.cos
+local sin = math.sin
+local rad = math.rad
+
+local h = ScrH()
+local s = 65
+local B = s+5
+
+function DrawWepSwap()
+ local pl = LocalPlayer()
+ if (pl:IsPigeon()) then return end
+ if (GetRecentSwapTime() < CurTime()-3 and !IsInventoryOpen()) then return end
+
+ local Slot = GetWeaponSlot()
+
+ Num = Num+math.Clamp((Slot-Num)/6,-1,1)
+
+ if (!IsInventoryOpen()) then MCO.a = 150*min(1,GetRecentSwapTime()-(CurTime()-3))
+ else MCO.a = 150 end
+
+ local Ib = input.MousePress(MOUSE_LEFT,"Unequip")
+
+ for i = 0,9 do
+ local r = Num-i
+ local x = max(0,B*r)
+ local y = max(0,B*-r)
+
+ if (Slot == i) then MCO.b = 150
+ else MCO.b = 0 end
+
+ DrawRect(x+10,h-s-y-10,s,s,MCO)
+
+ if (pl.Weapons and pl.Weapons[i]) then
+ if (pl.Weapons[i].Item.Icon) then DrawMaterialRect(x+10,h-s-y-10,s,s,MAIN_WHITECOLOR,pl.Weapons[i].Item.Icon) end
+
+ if (input.IsMouseInBox(x+10,h-s-y-10,s,s) and Ib) then
+ RequestUnEquip(i)
+ timer.Simple(0.05,function() ReloadInventory() end)
+ end
+ end
+ end
+end
+
+function IsMouseInSlot()
+ local mx,my = gui.MousePos()
+
+ for i = 0,9 do
+ local r = Num-i
+ local x = max(0,B*r)
+ local y = max(0,B*-r)
+
+ if (input.IsMouseInBox(x+10,h-s-y-10,s,s)) then
+ return i
+ end
+ end
+
+ return false
+end
+
\ No newline at end of file diff --git a/gamemode/init.lua b/gamemode/init.lua new file mode 100644 index 0000000..717a65c --- /dev/null +++ b/gamemode/init.lua @@ -0,0 +1,120 @@ +
+AddCSLuaFile( "cl_init.lua" )
+AddCSLuaFile( "shared.lua" )
+
+include( "shared.lua" )
+
+hook.Remove("Initialize","LoadGearFox")
+
+local models = {
+ "models/player/Group03/female_01.mdl",
+ "models/player/Group03/female_02.mdl",
+ "models/player/Group03/female_03.mdl",
+ "models/player/Group03/female_04.mdl",
+ "models/player/Group03/male_01.mdl",
+ "models/player/Group03/male_02.mdl",
+ "models/player/Group03/male_03.mdl",
+ "models/player/Group03/male_04.mdl",
+ "models/player/Group03/male_05.mdl",
+ "models/player/Group03/male_06.mdl",
+ "models/player/Group03/male_07.mdl",
+ "models/player/Group03/male_08.mdl",
+ "models/player/Group03/male_09.mdl",
+}
+
+function GM:Initialize()
+ resource.AddDir("sound/wintersurvival2")
+ resource.AddDir("materials/wintersurvival2")
+ resource.AddDir("materials/settlement")
+ resource.AddDir("materials/mixerman3d")
+ resource.AddDir("materials/lam")
+
+ resource.AddDir("models/mixerman3d")
+
+ resource.AddDir("materials/gearfox")
+ resource.AddDir("materials/mawbase")
+ resource.AddDir("models/gearfox")
+ resource.AddDir("sound/mawbase")
+
+ resource.AddFile("models/weapons/w_archersword/w_archersword.mdl")
+ resource.AddFile("materials/models/weapons/archersword.vmt")
+end
+
+function GM:PlayerAuthed(pl)
+ pl:UpdateHumans()
+ pl:UpdatePigeons()
+ pl:UpdateRoundTimer()
+end
+
+function GM:PlayerInitialSpawn(pl)
+ if (!self.CountDown and #player.GetAll() > 1) then self:StartCountDown() end
+ pl:SetHuman(false)
+end
+
+function GM:PlayerSpawn(pl)
+ pl:SetHeat(0)
+ pl:SetHunger(0)
+ pl:SetFatigue(0)
+ pl:SetWater(0)
+
+ if (pl:IsPigeon()) then
+ pl:SetNoDraw(true)
+ pl:SetNotSolid(true)
+ pl:SetMoveType(MOVETYPE_NONE)
+
+ pl:SpawnPigeon()
+ else
+ --hook.Call("PlayerSetModel",self,pl)
+
+ pl:SetModel(Model(models[math.random(#models)]))
+ pl:Give("hands")
+ pl:SelectWeapon("hands")
+ end
+end
+
+function GM:PlayerCanHearPlayersVoice()
+ return true
+end
+
+function GM:Think()
+end
+
+local Up = Vector(0,0,20)
+
+function GM:DoPlayerDeath( pl, attacker, dmginfo )
+ if (!pl:IsPigeon()) then
+ if (#player.GetAllHumans() > 1) then
+ local a = ents.Create("ws_grave")
+ a:SetPos(pl:GetPos()+Up)
+ a:SetAngles(Angle(0,math.random(0,360),0))
+ a:Spawn()
+ a:Activate()
+ a:AddItem("Meat",math.random(8,10))
+
+ for k,v in pairs(pl:GetInventory()) do
+ a:AddItem(v.Name,v.Quantity)
+ end
+ end
+
+ pl:CreateRagdoll()
+ pl:SetHuman(false)
+ pl:ResetKnownRecipes()
+ end
+
+end
+
+function GM:PlayerDeathSound()
+ return true
+end
+
+function GM:PlayerShouldTakeDamage( pl, inf )
+ if (inf:IsPlayer() and pl:IsPlayer() and !pl:IsPigeon()) then
+ if (self.CountDown > CurTime()-MAIN_PVPTIMER) then
+ return false
+ end
+ end
+
+ return true
+end
+
+
diff --git a/gamemode/itemsystem/items/alter.lua b/gamemode/itemsystem/items/alter.lua new file mode 100644 index 0000000..31d1b4f --- /dev/null +++ b/gamemode/itemsystem/items/alter.lua @@ -0,0 +1,66 @@ +
+ITEM.Name = "Alter"
+ITEM.Class = "structure"
+ITEM.Desc = "This allows you to sacrifice your soul for a player."
+ITEM.Model = "models/props_c17/gravestone003a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_crow.png")
+ITEM.Recipe = {
+ Resources = {
+ ["Ancient Log"] = 20,
+ ["Plank"] = 16,
+ ["Rope"] = 16,
+ ["Sap"] = 30,
+ },
+ Tools = {
+ ["Diamond Hammer"] = 1,
+ },
+}
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Ghost = {
+ {
+ Model = "models/props_c17/gravestone003a.mdl",
+ Size = Vector(8,1,1),
+ Pos = Vector(22,0,0),
+ Ang = Angle(90,0,0),
+ },
+ {
+ Model = "models/props_c17/gravestone003a.mdl",
+ Size = Vector(8,1,1),
+ Pos = Vector(-22,0,0),
+ Ang = Angle(-90,0,0),
+ },
+}
+
+ITEM.Range = 200
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (!pl:CanPlaceStructure(tr)) then pl:GhostStructure(self.Name) return end
+
+ if (tr.Hit) then
+ local drop = ents.Create("ws_alter")
+ drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,0))
+ drop:SetPos(tr.HitPos)
+ drop:Spawn()
+ drop:Activate()
+
+ if (pl:HasItem(self.Name)) then pl:RemoveItem(self.Name,1)
+ else pl:UnEquipWeaponSlot(pl.Select,true) end
+
+ pl:GhostRemove()
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/ancientlog.lua b/gamemode/itemsystem/items/ancientlog.lua new file mode 100644 index 0000000..2948d08 --- /dev/null +++ b/gamemode/itemsystem/items/ancientlog.lua @@ -0,0 +1,17 @@ +
+ITEM.Name = "Ancient Log"
+ITEM.Class = "resource"
+ITEM.Desc = "Powerful wood."
+ITEM.Model = "models/props_junk/Rock001a.mdl"
+ITEM.Icon = Material("settlement/icon_log")
+
+ITEM.Recipe = {
+ Resources = {
+ ["Vine"] = 1,
+ ["Sap"] = 1,
+ ["Ancient Wood"] = 3,
+ },
+ Tools = {
+ ["Crystal Hammer"] = 1,
+ },
+}
diff --git a/gamemode/itemsystem/items/ancientwood.lua b/gamemode/itemsystem/items/ancientwood.lua new file mode 100644 index 0000000..8f38c17 --- /dev/null +++ b/gamemode/itemsystem/items/ancientwood.lua @@ -0,0 +1,60 @@ +
+ITEM.Name = "Ancient Wood"
+ITEM.Class = "weapon"
+ITEM.Desc = "A stronger type of wood.\nUsed for advanced equipment."
+ITEM.Model = "models/gibs/furniture_gibs/furniturewooddrawer003a_chunk04.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_ancientwood.png")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/gibs/furniture_gibs/furniturewooddrawer003a_chunk04.mdl",
+ Size = Vector(.5,.5,.5),
+ Pos = Vector(3,-1.5,-12),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Damage = 5
+ITEM.Range = 60
+ITEM.CD = 0.6
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:GetModel():find("tree")) then
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
+
+function ITEM:OnSecondary(pl,tr)
+ if (CLIENT) then return end
+ if (!pl:HasItem(self.Name)) then return end
+
+ local drop = SpawnWSItem(self.Name,pl:GetShootPos()+pl:GetAimVector()*20)
+ drop:GetPhysicsObject():ApplyForceCenter(pl:GetAimVector() * 200)
+
+ pl:RemoveItem(self.Name,1)
+
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(40,60))
+end
+
+
diff --git a/gamemode/itemsystem/items/arrow.lua b/gamemode/itemsystem/items/arrow.lua new file mode 100644 index 0000000..30047d8 --- /dev/null +++ b/gamemode/itemsystem/items/arrow.lua @@ -0,0 +1,25 @@ +
+ITEM.Name = "Arrow"
+ITEM.Class = "ammo"
+ITEM.Desc = "An arrow, used for bows."
+ITEM.Model = "models/mixerman3d/other/arrow.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_arrow")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/mixerman3d/other/arrow.mdl",
+ Pos = Vector(1,-1,-2.5),
+ Ang = Angle(0,90,180),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Rock"] = 1,
+ ["Flint"] = 1,
+ ["Sap"] = 1,
+ ["Wood"] = 1,
+ },
+ Tools = {},
+}
diff --git a/gamemode/itemsystem/items/axe.lua b/gamemode/itemsystem/items/axe.lua new file mode 100644 index 0000000..b5d2063 --- /dev/null +++ b/gamemode/itemsystem/items/axe.lua @@ -0,0 +1,66 @@ +
+ITEM.Name = "Axe"
+ITEM.Class = "weapon"
+ITEM.Desc = "A primitive axe held together with sap."
+ITEM.Model = "models/props_debris/wood_board02a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_axe")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.1,0.5,1),
+ Pos = Vector(3,-4,-27),
+ Ang = Angle(0,0,0),
+ },
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(3,-1.5,-12),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Wood"] = 1,
+ ["Rock"] = 1,
+ ["Sap"] = 1,
+ },
+ Tools = {},
+}
+
+
+
+ITEM.Damage = 30
+ITEM.Range = 64
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:IsTree()) then
+ if (math.random(1,35)/10 < 1) then pl:AddItem("Wood",1) end
+
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/barrel.lua b/gamemode/itemsystem/items/barrel.lua new file mode 100644 index 0000000..6f99d7e --- /dev/null +++ b/gamemode/itemsystem/items/barrel.lua @@ -0,0 +1,58 @@ +
+ITEM.Name = "Barrel"
+ITEM.Class = "structure"
+ITEM.Desc = "Barrel for storage of items."
+ITEM.Model = "models/props_c17/oildrum001.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_fence")
+ITEM.Recipe = {
+ Resources = {
+ ["Plank"] = 3,
+ ["Sap"] = 2,
+ },
+ Tools = {
+ ["Crystal"] = 1,
+ },
+}
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Ghost = {
+ {
+ Model = "models/props_c17/oildrum001.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,0,0),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Range = 200
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (!pl:CanPlaceStructure(tr)) then pl:GhostStructure(self.Name) return end
+
+ if (tr.Hit) then
+ local drop = ents.Create("ws_barrel")
+ drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,0))
+ drop:SetPos(tr.HitPos)
+ drop:Spawn()
+ drop:Activate()
+
+ if (pl:HasItem(self.Name)) then pl:RemoveItem(self.Name,1)
+ else pl:UnEquipWeaponSlot(pl.Select,true) end
+
+ pl:GhostRemove()
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/base.lua b/gamemode/itemsystem/items/base.lua new file mode 100644 index 0000000..a3b6b31 --- /dev/null +++ b/gamemode/itemsystem/items/base.lua @@ -0,0 +1,37 @@ +ITEM.Name = "Winter Survival 2 Base Item"
+ITEM.Desc = "Why the hell did I write this? No one will read it anyways!!"
+ITEM.Class = "Other"
+ITEM.Model = "models/props_combine/breenlight.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_rock")
+ITEM.Burnable = false
+ITEM.CD = 0.3
+ITEM.Range = 120
+ITEM.HoldType = "melee"
+
+ITEM.Structure = {}
+ITEM.Recipe = nil
+ITEM.Tools = nil
+ITEM.CookCD = 1
+ITEM.CookProduct = nil
+ITEM.Ghost = nil
+
+--These are just here to tell the editors/develoeprs what functions are available.. dont un-comment them out, as this could affect all the items.
+/*
+function ITEM:OnPrimary(user,tr)
+end
+
+function ITEM:OnSecondary(user,tr)
+end
+
+function ITEM:OnUse(user)
+end
+
+function ITEM:OnCooked(campfire)
+end
+
+function ITEM:OnEnchanted(enchanttalbe, nearbyrunes)
+end
+
+function ITEM:OnCraft(player)
+end
+*/
diff --git a/gamemode/itemsystem/items/battleaxe.lua b/gamemode/itemsystem/items/battleaxe.lua new file mode 100644 index 0000000..96b3cf6 --- /dev/null +++ b/gamemode/itemsystem/items/battleaxe.lua @@ -0,0 +1,65 @@ +ITEM.Name = [[Battle Axe]] +ITEM.Desc = [[The vikings once used these]] +ITEM.Model = [[models/props_junk/Rock001a.mdl]] +ITEM.Icon = Material([[wintersurvival2/hud/ws1_icons/icon_axe]]) +ITEM.Structure = { + { + Bone="ValveBiped.Bip01_R_Hand", + Model="models/props_debris/wood_board02a.mdl", + Size=Vector(0.5,0.5,0.5), + Pos=Vector(3.182,-1.76,-11.64), + Ang=Angle(0,86.83,0), + }, + { + Bone="ValveBiped.Bip01_R_Hand", + Model="models/props_junk/Rock001a.mdl", + Size=Vector(1.18,0.06,1), + Pos=Vector(6,-1.76,-22.94), + Ang=Angle(0,0,0), + }, + { + Bone="ValveBiped.Bip01_R_Hand", + Model="models/props_junk/Rock001a.mdl", + Size=Vector(0.74,0.06,0.62), + Pos=Vector(4.24,-1.75,-14.82), + Ang=Angle(0,0,-180), + }, +} + +ITEM.Recipe = { + Resources = { + ["Plank"] = 2, + ["Flint"] = 1, + ["Sap"] = 1, + }, + Tools = {}, +} + +ITEM.HoldType = "melee2" +ITEM.Damage = 70 +ITEM.Range = 80 +ITEM.CD = 0.9 + +function ITEM:OnPrimary(pl,tr) + if (CLIENT) then return end + + if (tr.Hit) then + if (IsValid(tr.Entity)) then + local ent = tr.Entity + local class = ent:GetClass() + + if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then + ent:TakeDamage(self.Damage,pl) + + if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110)) + else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end + else + pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110)) + end + else + pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110)) + end + else + pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(60,80)) + end +end
\ No newline at end of file diff --git a/gamemode/itemsystem/items/berry.lua b/gamemode/itemsystem/items/berry.lua new file mode 100644 index 0000000..90ec4c4 --- /dev/null +++ b/gamemode/itemsystem/items/berry.lua @@ -0,0 +1,24 @@ +
+ITEM.Name = "Berry"
+ITEM.Class = "food"
+ITEM.Desc = "Berries..."
+ITEM.Model = "models/Weapons/w_bugbait.mdl"
+ITEM.Icon = Material("settlement/icon_berries")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/Weapons/w_bugbait.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+function ITEM:OnUse(user)
+ if (CLIENT) then return end
+
+ user:SetHealth(math.min(100,user:Health()+5))
+ user:AddHunger(-25)
+ user:RemoveItem(self.Name,1)
+end
\ No newline at end of file diff --git a/gamemode/itemsystem/items/bow.lua b/gamemode/itemsystem/items/bow.lua new file mode 100644 index 0000000..8ecee8e --- /dev/null +++ b/gamemode/itemsystem/items/bow.lua @@ -0,0 +1,59 @@ +
+ITEM.Name = "Bow"
+ITEM.Class = "weapon"
+ITEM.Desc = "A primitive bow made from vine, sap, and wood."
+ITEM.Model = "models/props_debris/wood_board02a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_bow")
+ITEM.HoldType = "smg"
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_L_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(.5,.5,.35),
+ Pos = Vector(-1,-6,9),
+ Ang = Angle(-30,-65,180),
+ },
+ {
+ Bone = "ValveBiped.Bip01_L_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(.5,.5,.35),
+ Pos = Vector(-1,-6,-9),
+ Ang = Angle(30,-65,180),
+ },
+ {
+ Bone = "ValveBiped.Bip01_L_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(.05,.05,.51),
+ Pos = Vector(-3.3,-9.5,0),
+ Ang = Angle(0,-65,180),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Plank"] = 2,
+ ["Rope"] = 1,
+ ["Sap"] = 1,
+ },
+ Tools = {},
+}
+
+ITEM.CD = 1
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+ if (!pl:HasItem("Arrow",1)) then return end
+
+ local aim = pl:GetAimVector()
+
+ local D = ents.Create("ws_arrow")
+ D:SetPos(pl:GetShootPos()+aim*20)
+ D:SetOwner(pl)
+ D:SetAngles(aim:Angle())
+ D:Spawn()
+ pl:EmitSound(Sound("physics/flesh/flesh_impact_hard.wav"),100,math.random(90,110))
+ D:GetPhysicsObject():ApplyForceCenter(aim * 10000)
+
+ pl:RemoveItem("Arrow",1)
+end
diff --git a/gamemode/itemsystem/items/campfire.lua b/gamemode/itemsystem/items/campfire.lua new file mode 100644 index 0000000..5cc4987 --- /dev/null +++ b/gamemode/itemsystem/items/campfire.lua @@ -0,0 +1,82 @@ +
+ITEM.Name = "Campfire"
+ITEM.Class = "structure"
+ITEM.Desc = "Ready to be lit. Some assembly required."
+ITEM.Model = "models/props_debris/wood_board07a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_campfire")
+ITEM.Recipe = {
+ Resources = {
+ ["Wood"] = 4,
+ ["Rock"] = 1,
+ },
+ Tools = {
+ ["Crystal"] = 1,
+ },
+}
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Ghost = {
+ {
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,0,0),
+ Ang = Angle(0,0,0),
+ },
+ {
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,10,0),
+ Ang = Angle(-45,90,0),
+ },
+ {
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(-10,0,0),
+ Ang = Angle(-45,180,0),
+ },
+ {
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,-10,0),
+ Ang = Angle(-45,-90,0),
+ },
+ {
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(10,0,0),
+ Ang = Angle(-45,0,0),
+ },
+}
+
+ITEM.Range = 200
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (!pl:CanPlaceStructure(tr)) then pl:GhostStructure(self.Name) return end
+
+ if (tr.Hit and tr.HitWorld) then
+ local drop = ents.Create("ws_campfire")
+ drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,0))
+ drop:SetPos(tr.HitPos)
+ drop:Spawn()
+ drop:Activate()
+
+ if (pl:HasItem(self.Name)) then pl:RemoveItem(self.Name,1)
+ else pl:UnEquipWeaponSlot(pl.Select,true) end
+
+ pl:GhostRemove()
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/charcoal.lua b/gamemode/itemsystem/items/charcoal.lua new file mode 100644 index 0000000..ed5e900 --- /dev/null +++ b/gamemode/itemsystem/items/charcoal.lua @@ -0,0 +1,10 @@ +ITEM.Name = "Charcoal"
+ITEM.Class = "resource"
+ITEM.Desc = "A hunk of carbon"
+ITEM.Model = "models/props_junk/Rock001a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_coal.png")
+
+
+function ITEM:OnCooked(campfire)
+ campfire:Ignite(1000)
+end
diff --git a/gamemode/itemsystem/items/cookedmeat.lua b/gamemode/itemsystem/items/cookedmeat.lua new file mode 100644 index 0000000..b8b1999 --- /dev/null +++ b/gamemode/itemsystem/items/cookedmeat.lua @@ -0,0 +1,24 @@ +
+ITEM.Name = "Cooked Meat"
+ITEM.Class = "food"
+ITEM.Desc = "Delicious... and prepared!"
+ITEM.Model = "models/Weapons/w_bugbait.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_meat.png")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/Weapons/w_bugbait.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+function ITEM:OnUse(user)
+ if (CLIENT) then return end
+
+ user:SetHealth(math.min(100,user:Health()+40))
+ user:AddHunger(-90)
+ user:RemoveItem(self.Name,1)
+end
diff --git a/gamemode/itemsystem/items/crystal.lua b/gamemode/itemsystem/items/crystal.lua new file mode 100644 index 0000000..ef9c12e --- /dev/null +++ b/gamemode/itemsystem/items/crystal.lua @@ -0,0 +1,17 @@ +
+ITEM.Name = "Crystal"
+ITEM.Class = "resource"
+ITEM.Desc = "A noteworthy stone."
+ITEM.Model = "models/props_combine/breenlight.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_crystal")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_combine/breenlight.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
diff --git a/gamemode/itemsystem/items/crystalaxe.lua b/gamemode/itemsystem/items/crystalaxe.lua new file mode 100644 index 0000000..c9acf71 --- /dev/null +++ b/gamemode/itemsystem/items/crystalaxe.lua @@ -0,0 +1,70 @@ +
+ITEM.Name = "Crystal Axe"
+ITEM.Class = "weapon"
+ITEM.Desc = "A more advanced axe made from crystals."
+ITEM.Model = "models/props_debris/wood_board02a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_axe")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_combine/breenlight.mdl",
+ Size = Vector(0.1,0.5,1),
+ Pos = Vector(3,-4,-27),
+ Ang = Angle(0,0,0),
+ },
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(3,-1.5,-12),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Log"] = 1,
+ ["Crystal"] = 1,
+ ["Rope"] = 1,
+ ["Vine"] = 1,
+ },
+ Tools = {
+ ["Crystal Hammer"] = 1,
+ },
+}
+
+
+
+ITEM.Damage = 30
+ITEM.Range = 64
+ITEM.CD = 0.4
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:IsTree()) then
+ if (math.random(1,35)/10 < 2) then pl:AddItem("Wood",1) end
+ if (math.random(1,90)/10 < 1) then pl:AddItem("Ancient Wood",1) end
+
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/crystalhammer.lua b/gamemode/itemsystem/items/crystalhammer.lua new file mode 100644 index 0000000..4348d0f --- /dev/null +++ b/gamemode/itemsystem/items/crystalhammer.lua @@ -0,0 +1,24 @@ +
+ITEM.Name = "Crystal Hammer"
+ITEM.Class = "resource"
+ITEM.Desc = "A tool used for crystal equipment"
+ITEM.Model = "models/props_combine/breenlight.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_crystal")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_combine/breenlight.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Crystal"] = 8,
+ ["Sap"] = 4,
+ },
+ Tools = {},
+}
diff --git a/gamemode/itemsystem/items/crystalpickaxe.lua b/gamemode/itemsystem/items/crystalpickaxe.lua new file mode 100644 index 0000000..8c981e1 --- /dev/null +++ b/gamemode/itemsystem/items/crystalpickaxe.lua @@ -0,0 +1,72 @@ +
+ITEM.Name = "Crystal Pickaxe"
+ITEM.Class = "weapon"
+ITEM.Desc = "An advanced crystal pickaxe. More efficient than an ordinary pickaxe."
+ITEM.Model = "models/props_debris/wood_board02a.mdl"
+ITEM.Icon = Material("settlement/icon_pickaxe")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_combine/breenlight.mdl",
+ Size = Vector(0.1,1,0.4),
+ Pos = Vector(3,-1,-27),
+ Ang = Angle(0,0,0),
+ },
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(3,-1.5,-12),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Log"] = 1,
+ ["Crystal"] = 2,
+ ["Rope"] = 1,
+ ["Vine"] = 1,
+ },
+ Tools = {
+ ["Crystal Hammer"] = 1,
+ },
+}
+
+
+
+ITEM.Damage = 30
+ITEM.Range = 64
+ITEM.CD = 0.4
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:IsRock()) then
+ if (math.random(1,35)/10 < 2) then pl:AddItem("Rock",1) end
+ if (math.random(1,55)/10 < 2) then pl:AddItem("Crystal",1) end
+ if (math.random(1,90)/10 < 1) then pl:AddItem("Diamond",1) end
+ if (math.random(1,90)/10 < 2) then pl:AddItem("Flint",1) end
+
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/crystalsickle.lua b/gamemode/itemsystem/items/crystalsickle.lua new file mode 100644 index 0000000..1753a2a --- /dev/null +++ b/gamemode/itemsystem/items/crystalsickle.lua @@ -0,0 +1,70 @@ +
+ITEM.Name = "Crystal Sickle"
+ITEM.Class = "weapon"
+ITEM.Desc = "A sickle. Used for bushes for vines and berries"
+ITEM.Model = "models/props_debris/wood_board02a.mdl"
+ITEM.Icon = Material("settlement/icon_sickle")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_combine/breenlight.mdl",
+ Size = Vector(0.5,0.1,0.2),
+ Pos = Vector(3,-4,-22),
+ Ang = Angle(0,0,0),
+ },
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(.5,.5,.1),
+ Pos = Vector(3,-1.5,-6),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Log"] = 1,
+ ["Crystal"] = 2,
+ ["Rope"] = 1,
+ ["Vine"] = 1,
+ },
+ Tools = {
+ ["Crystal Hammer"] = 1,
+ },
+}
+
+
+
+ITEM.Damage = 10
+ITEM.Range = 64
+ITEM.CD = 0.4
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:IsPlant()) then
+ if (math.random(1,35)/10 < 2) then pl:AddItem("Vine",1) end
+ if (math.random(1,35)/10 < 2) then pl:AddItem("Berry",1) end
+
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/cup.lua b/gamemode/itemsystem/items/cup.lua new file mode 100644 index 0000000..5c8e27d --- /dev/null +++ b/gamemode/itemsystem/items/cup.lua @@ -0,0 +1,20 @@ +
+ITEM.Name = "Cup"
+ITEM.Class = "resource"
+ITEM.Desc = "It could hold some liquid"
+ITEM.Model = "models/props_junk/Rock001a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_cupempty.png")
+
+ITEM.Recipe = {
+ Resources = {
+ ["Log"] = 1,
+ ["Sap"] = 1,
+ },
+ Tools = {
+ ["Knife"] = 1,
+ },
+}
+
+function ITEM:OnPrimary()
+
+end
diff --git a/gamemode/itemsystem/items/diamond.lua b/gamemode/itemsystem/items/diamond.lua new file mode 100644 index 0000000..d491638 --- /dev/null +++ b/gamemode/itemsystem/items/diamond.lua @@ -0,0 +1,17 @@ +
+ITEM.Name = "Diamond"
+ITEM.Class = "resource"
+ITEM.Desc = "A very powerful resource for use with more advanced equipment."
+ITEM.Model = "models/props_junk/Rock001a.mdl"
+ITEM.Icon = Material("settlement/icon_diamond")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
diff --git a/gamemode/itemsystem/items/diamondaxe.lua b/gamemode/itemsystem/items/diamondaxe.lua new file mode 100644 index 0000000..9edc6e4 --- /dev/null +++ b/gamemode/itemsystem/items/diamondaxe.lua @@ -0,0 +1,70 @@ +
+ITEM.Name = "Diamond Axe"
+ITEM.Class = "weapon"
+ITEM.Desc = "An axe made from diamonds and ancient wood."
+ITEM.Model = "models/props_debris/wood_board02a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_axe")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_combine/breenlight.mdl",
+ Size = Vector(0.1,0.5,1),
+ Pos = Vector(3,-4,-27),
+ Ang = Angle(0,0,0),
+ },
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(3,-1.5,-12),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Ancient Log"] = 1,
+ ["Diamond"] = 1,
+ ["Rope"] = 1,
+ ["Vine"] = 1,
+ },
+ Tools = {
+ ["Diamond Hammer"] = 1,
+ },
+}
+
+
+
+ITEM.Damage = 30
+ITEM.Range = 64
+ITEM.CD = 0.3
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:IsTree()) then
+ if (math.random(1,100) < 90) then pl:AddItem("Wood",1) end
+ if (math.random(1,100) < 20) then pl:AddItem("Ancient Wood",1) end
+
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/diamondhammer.lua b/gamemode/itemsystem/items/diamondhammer.lua new file mode 100644 index 0000000..56cab21 --- /dev/null +++ b/gamemode/itemsystem/items/diamondhammer.lua @@ -0,0 +1,28 @@ +
+ITEM.Name = "Diamond Hammer"
+ITEM.Class = "resource"
+ITEM.Desc = "A tool used for diamond equipment"
+ITEM.Model = "models/props_combine/breenlight.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_crystal")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_combine/breenlight.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Diamond"] = 8,
+ ["Ancient Wood"] = 8,
+ ["Rope"] = 4,
+ ["Sap"] = 6,
+ },
+ Tools = {
+ ["Crystal Hammer"] = 1,
+ },
+}
diff --git a/gamemode/itemsystem/items/diamondpickaxe.lua b/gamemode/itemsystem/items/diamondpickaxe.lua new file mode 100644 index 0000000..f0599a3 --- /dev/null +++ b/gamemode/itemsystem/items/diamondpickaxe.lua @@ -0,0 +1,72 @@ +
+ITEM.Name = "Diamond Pickaxe"
+ITEM.Class = "weapon"
+ITEM.Desc = "An advanced pickaxe. Made from ancient wood and diamonds."
+ITEM.Model = "models/props_debris/wood_board02a.mdl"
+ITEM.Icon = Material("settlement/icon_pickaxe")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_combine/breenlight.mdl",
+ Size = Vector(0.1,1,0.4),
+ Pos = Vector(3,-1,-27),
+ Ang = Angle(0,0,0),
+ },
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(3,-1.5,-12),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Ancient Log"] = 1,
+ ["Diamond"] = 2,
+ ["Rope"] = 1,
+ ["Vine"] = 1,
+ },
+ Tools = {
+ ["Diamond Hammer"] = 1,
+ },
+}
+
+
+
+ITEM.Damage = 30
+ITEM.Range = 64
+ITEM.CD = 0.3
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:IsRock()) then
+ if (math.random(1,35)/10 < 3) then pl:AddItem("Rock",1) end
+ if (math.random(1,55)/10 < 3) then pl:AddItem("Crystal",1) end
+ if (math.random(1,90)/10 < 2) then pl:AddItem("Diamond",1) end
+ if (math.random(1,90)/10 < 3) then pl:AddItem("Flint",1) end
+
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/diamondsickle.lua b/gamemode/itemsystem/items/diamondsickle.lua new file mode 100644 index 0000000..0fd2688 --- /dev/null +++ b/gamemode/itemsystem/items/diamondsickle.lua @@ -0,0 +1,70 @@ +
+ITEM.Name = "Diamond Sickle"
+ITEM.Class = "weapon"
+ITEM.Desc = "A sickle made from ancient wood and diamonds"
+ITEM.Model = "models/props_debris/wood_board02a.mdl"
+ITEM.Icon = Material("settlement/icon_sickle")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_combine/breenlight.mdl",
+ Size = Vector(0.5,0.1,0.2),
+ Pos = Vector(3,-4,-22),
+ Ang = Angle(0,0,0),
+ },
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(.5,.5,.1),
+ Pos = Vector(3,-1.5,-6),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Ancient Log"] = 1,
+ ["Diamond"] = 2,
+ ["Rope"] = 1,
+ ["Vine"] = 1,
+ },
+ Tools = {
+ ["Diamond Hammer"] = 1,
+ },
+}
+
+
+
+ITEM.Damage = 10
+ITEM.Range = 64
+ITEM.CD = 0.3
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:IsPlant()) then
+ if (math.random(1,35)/10 < 3) then pl:AddItem("Vine",1) end
+ if (math.random(1,35)/10 < 3) then pl:AddItem("Berry",1) end
+
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/feather.lua b/gamemode/itemsystem/items/feather.lua new file mode 100644 index 0000000..d53acc8 --- /dev/null +++ b/gamemode/itemsystem/items/feather.lua @@ -0,0 +1,6 @@ +
+ITEM.Name = "Feather"
+ITEM.Class = "resource"
+ITEM.Desc = "Material used for making arrows"
+ITEM.Model = "models/Gibs/HGIBS_scapula.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_feather.png")
diff --git a/gamemode/itemsystem/items/fence.lua b/gamemode/itemsystem/items/fence.lua new file mode 100644 index 0000000..e4a8217 --- /dev/null +++ b/gamemode/itemsystem/items/fence.lua @@ -0,0 +1,59 @@ +
+ITEM.Name = "Fence"
+ITEM.Class = "structure"
+ITEM.Desc = "Some basic wood structure for setting up camps."
+ITEM.Model = "models/props_debris/wood_board07a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_fence")
+ITEM.Recipe = {
+ Resources = {
+ ["Plank"] = 2,
+ ["Sap"] = 1,
+ },
+ Tools = {
+ ["Crystal"] = 1,
+ },
+}
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Ghost = {
+ {
+ Model = "models/props_wasteland/wood_fence02a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,0,0),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Range = 200
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (!pl:CanPlaceStructure(tr)) then pl:GhostStructure(self.Name) return end
+
+ if (tr.Hit) then
+ local drop = ents.Create("ws_prop")
+ drop:SetModel("models/props_wasteland/wood_fence02a.mdl")
+ drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,0))
+ drop:SetPos(tr.HitPos)
+ drop:Spawn()
+ drop:Activate()
+
+ if (pl:HasItem(self.Name)) then pl:RemoveItem(self.Name,1)
+ else pl:UnEquipWeaponSlot(pl.Select,true) end
+
+ pl:GhostRemove()
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/flint.lua b/gamemode/itemsystem/items/flint.lua new file mode 100644 index 0000000..63fd085 --- /dev/null +++ b/gamemode/itemsystem/items/flint.lua @@ -0,0 +1,6 @@ +
+ITEM.Name = "Flint"
+ITEM.Class = "resource"
+ITEM.Desc = "Sharp stone"
+ITEM.Model = "models/props_junk/Rock001a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_flint.png")
diff --git a/gamemode/itemsystem/items/floor.lua b/gamemode/itemsystem/items/floor.lua new file mode 100644 index 0000000..c02815b --- /dev/null +++ b/gamemode/itemsystem/items/floor.lua @@ -0,0 +1,60 @@ +
+ITEM.Name = "Floor"
+ITEM.Class = "structure"
+ITEM.Desc = "Some basic wood structure for setting up camps."
+ITEM.Model = "models/props_debris/wood_board07a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_fence")
+ITEM.Recipe = {
+ Resources = {
+ ["Plank"] = 2,
+ ["Wood"] = 3,
+ ["Sap"] = 1,
+ },
+ Tools = {
+ ["Crystal"] = 1,
+ },
+}
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Ghost = {
+ {
+ Model = "models/props_wasteland/wood_fence02a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,0,0),
+ Ang = Angle(0,0,90),
+ },
+}
+
+ITEM.Range = 200
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (!pl:CanPlaceStructure(tr)) then pl:GhostStructure(self.Name) return end
+
+ if (tr.Hit) then
+ local drop = ents.Create("ws_prop")
+ drop:SetModel("models/props_wasteland/wood_fence02a.mdl")
+ drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,90))
+ drop:SetPos(tr.HitPos)
+ drop:Spawn()
+ drop:Activate()
+
+ if (pl:HasItem(self.Name)) then pl:RemoveItem(self.Name,1)
+ else pl:UnEquipWeaponSlot(pl.Select,true) end
+
+ pl:GhostRemove()
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/infuser.lua b/gamemode/itemsystem/items/infuser.lua new file mode 100644 index 0000000..d2f72ad --- /dev/null +++ b/gamemode/itemsystem/items/infuser.lua @@ -0,0 +1,57 @@ +ITEM.Name = "Infuser"
+ITEM.Class = "structure"
+ITEM.Desc = "Cast enchantments\nPlace runes nearby to boost magical power and have different effects"
+ITEM.Model = "models/props_junk/wood_crate002a.mdl"
+ITEM.Icon = Material("settlement/icon_researchtable")
+ITEM.Recipe = {
+ Resources = {
+ ["Log"] = 5,
+ ["Sap"] = 5,
+ },
+ Tools = {
+ ["Crystal Hammer"] = 1,
+ },
+}
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/wood_crate002a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Ghost = {
+ {
+ Model = "models/props_junk/wood_crate002a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,0,0),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Range = 200
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (!pl:CanPlaceStructure(tr)) then pl:GhostStructure(self.Name) return end
+
+ if (tr.Hit) then
+ local drop = ents.Create("ws_infuser")
+ drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,0))
+ drop:SetPos(tr.HitPos)
+ drop:Spawn()
+ drop:Activate()
+
+ if (pl:HasItem(self.Name)) then pl:RemoveItem(self.Name,1)
+ else pl:UnEquipWeaponSlot(pl.Select,true) end
+
+ pl:GhostRemove()
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/juice.lua b/gamemode/itemsystem/items/juice.lua new file mode 100644 index 0000000..ff24b84 --- /dev/null +++ b/gamemode/itemsystem/items/juice.lua @@ -0,0 +1,21 @@ +
+ITEM.Name = "Juice"
+ITEM.Class = "food"
+ITEM.Desc = "Restores some thirst."
+ITEM.Model = "models/props_junk/Rock001a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_beer")
+
+ITEM.Recipe = {
+ Resources = {
+ ["Berry"] = 3,
+ ["Cup"] = 1,
+ },
+ Tools = {},
+}
+
+function ITEM:OnUse(user)
+ if (CLIENT) then return end
+
+ user:SetWater(0)
+ user:RemoveItem(self.Name,1)
+end
diff --git a/gamemode/itemsystem/items/knife.lua b/gamemode/itemsystem/items/knife.lua new file mode 100644 index 0000000..63959ce --- /dev/null +++ b/gamemode/itemsystem/items/knife.lua @@ -0,0 +1,60 @@ +
+ITEM.Name = "Knife"
+ITEM.Class = "weapon"
+ITEM.Desc = "A knife, what do u expect?"
+ITEM.Model = "models/props_combine/breenlight.mdl"
+ITEM.Icon = Material("settlement/icon_knife")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_combine/breenlight.mdl",
+ Size = Vector(.1,.5,.5),
+ Pos = Vector(3,-1.6,0.5),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Rock"] = 1,
+ ["Sap"] = 1,
+ ["Wood"] = 1,
+ ["Crystal"] = 1,
+ },
+ Tools = {},
+}
+
+
+
+ITEM.Damage = 1
+ITEM.Range = 64
+ITEM.CD = 0.1
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:IsTree()) then
+ if (math.random(1,35)/10 < 1) then pl:AddItem("Sap",1) end
+
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/log.lua b/gamemode/itemsystem/items/log.lua new file mode 100644 index 0000000..07b8352 --- /dev/null +++ b/gamemode/itemsystem/items/log.lua @@ -0,0 +1,15 @@ +
+ITEM.Name = "Log"
+ITEM.Class = "resource"
+ITEM.Desc = "Bigger wood."
+ITEM.Model = "models/props_junk/Rock001a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_log.png")
+
+ITEM.Recipe = {
+ Resources = {
+ ["Vine"] = 1,
+ ["Sap"] = 1,
+ ["Wood"] = 3,
+ },
+ Tools = {},
+}
diff --git a/gamemode/itemsystem/items/magicwood.lua b/gamemode/itemsystem/items/magicwood.lua new file mode 100644 index 0000000..00c1605 --- /dev/null +++ b/gamemode/itemsystem/items/magicwood.lua @@ -0,0 +1,58 @@ +
+ITEM.Name = "Magic Wood"
+ITEM.Class = "weapon"
+ITEM.Desc = "Some magically infused wood"
+ITEM.Model = "models/props_debris/wood_board02a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_magicwood.png")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(.5,.5,.5),
+ Pos = Vector(3,-1.5,-12),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Damage = 2
+ITEM.Range = 60
+ITEM.CD = 1.0
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:GetModel():find("tree")) then
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
+
+function ITEM:OnSecondary(pl,tr)
+ if (CLIENT) then return end
+ if (!pl:HasItem(self.Name)) then return end
+
+ local drop = SpawnWSItem(self.Name,pl:GetShootPos()+pl:GetAimVector()*20)
+ drop:GetPhysicsObject():ApplyForceCenter(pl:GetAimVector() * 200)
+
+ pl:RemoveItem(self.Name,1)
+
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(40,60))
+end
diff --git a/gamemode/itemsystem/items/maul.lua b/gamemode/itemsystem/items/maul.lua new file mode 100644 index 0000000..2189eef --- /dev/null +++ b/gamemode/itemsystem/items/maul.lua @@ -0,0 +1,58 @@ +ITEM.Name = [[Maul]] +ITEM.Desc = [[The ultimate nutcracker!]] +ITEM.Model = [[models/props_debris/wood_board02a.mdl]] +ITEM.Icon = Material([[wintersurvival2/hud/ws2_icons/icon_sword.png]]) +ITEM.HoldType = [[melee2]] +ITEM.Structure = { + { + Bone ="ValveBiped.Bip01_R_Hand", + Model ="models/props_debris/wood_board02a.mdl", + Size =Vector(0.5,0.5,0.5), + Pos =Vector(3.8900001049042,-2.1099998950958,-11.640000343323), + Ang =Angle(0,74.120002746582,0), + }, + { + Bone ="ValveBiped.Bip01_R_Hand", + Model ="models/props_debris/wood_board02a.mdl", + Size =Vector(2.2999999523163,1.7999999523163,0.15000000596046), + Pos =Vector(3.8900001049042,-2.1099998950958,-22.579999923706), + Ang =Angle(0,78.360000610352,91.059997558594), + }, +} + +ITEM.Recipe = { + Resources = { + ["Plank"] = 4, + ["Log"] = 1, + ["Sap"] = 1, + }, + Tools = {}, +} + +ITEM.Damage = 70 +ITEM.Range = 80 +ITEM.CD = 1 + +function ITEM:OnPrimary(pl,tr) + if (CLIENT) then return end + + if (tr.Hit) then + if (IsValid(tr.Entity)) then + local ent = tr.Entity + local class = ent:GetClass() + + if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then + ent:TakeDamage(self.Damage,pl) + + if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110)) + else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end + else + pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110)) + end + else + pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110)) + end + else + pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(50,60)) + end +end
\ No newline at end of file diff --git a/gamemode/itemsystem/items/meat.lua b/gamemode/itemsystem/items/meat.lua new file mode 100644 index 0000000..d26d3c1 --- /dev/null +++ b/gamemode/itemsystem/items/meat.lua @@ -0,0 +1,28 @@ +
+ITEM.Name = "Meat"
+ITEM.Class = "food"
+ITEM.Desc = "Delicious..."
+ITEM.Model = "models/Weapons/w_bugbait.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_bugbait")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/Weapons/w_bugbait.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+function ITEM:OnUse(user)
+ if (CLIENT) then return end
+
+ user:SetHealth(math.min(100,user:Health()+10))
+ user:AddHunger(-30)
+ user:RemoveItem(self.Name,1)
+end
+
+function ITEM:OnCooked(campfire)
+ campfire:AddItem("Cooked Meat",1)
+end
\ No newline at end of file diff --git a/gamemode/itemsystem/items/mortarandpestle.lua b/gamemode/itemsystem/items/mortarandpestle.lua new file mode 100644 index 0000000..42b1baa --- /dev/null +++ b/gamemode/itemsystem/items/mortarandpestle.lua @@ -0,0 +1,20 @@ +
+ITEM.Name = "Mortar and Pestle"
+ITEM.Class = "tool"
+ITEM.Desc = "Something to grind things down in"
+ITEM.Model = "models/props_junk/Rock001a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_mortarandpestle.png")
+
+ITEM.Recipe = {
+ Resources = {
+ ["Cup"] = 1,
+ ["Rock"] = 1,
+ },
+ Tools = {
+ ["Knife"] = 1,
+ },
+}
+
+function ITEM:OnPrimary()
+
+end
diff --git a/gamemode/itemsystem/items/pickaxe.lua b/gamemode/itemsystem/items/pickaxe.lua new file mode 100644 index 0000000..2032d12 --- /dev/null +++ b/gamemode/itemsystem/items/pickaxe.lua @@ -0,0 +1,68 @@ +
+ITEM.Name = "Pickaxe"
+ITEM.Class = "weapon"
+ITEM.Desc = "A primitive axe held together with sap."
+ITEM.Model = "models/props_debris/wood_board02a.mdl"
+ITEM.Icon = Material("settlement/icon_pickaxe")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.1,1,0.4),
+ Pos = Vector(3,-1,-27),
+ Ang = Angle(0,0,0),
+ },
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(3,-1.5,-12),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Wood"] = 1,
+ ["Rock"] = 2,
+ ["Sap"] = 1,
+ },
+ Tools = {},
+}
+
+
+
+ITEM.Damage = 30
+ITEM.Range = 64
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:IsRock()) then
+ if (math.random(1,35)/10 < 1) then pl:AddItem("Rock",1) end
+ if (math.random(1,55)/10 < 1) then pl:AddItem("Crystal",1) end
+ if (math.random(1,90)/10 < 1) then pl:AddItem("Flint",1) end
+
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/pitch.lua b/gamemode/itemsystem/items/pitch.lua new file mode 100644 index 0000000..40c2a57 --- /dev/null +++ b/gamemode/itemsystem/items/pitch.lua @@ -0,0 +1,25 @@ +
+ITEM.Name = "Pitch"
+ITEM.Class = "resource"
+ITEM.Desc = "A sticky stubstance, probably flamable"
+ITEM.Model = "models/props_junk/Rock001a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_pitch.png")
+
+ITEM.Recipe = {
+ Resources = {
+ ["Charcoal"] = 1,
+ ["Sap"] = 1,
+ },
+ Tools = {
+ ["Mortar and Pestle"] = 1,
+ },
+}
+
+function ITEM:OnPrimary()
+
+end
+
+
+function ITEM:OnCooked(campfire)
+ campfire:Ignite(500)
+end
diff --git a/gamemode/itemsystem/items/plank.lua b/gamemode/itemsystem/items/plank.lua new file mode 100644 index 0000000..5726434 --- /dev/null +++ b/gamemode/itemsystem/items/plank.lua @@ -0,0 +1,25 @@ +
+ITEM.Name = "Plank"
+ITEM.Class = "resource"
+ITEM.Desc = "Advanced wood material."
+ITEM.Model = "models/props_debris/wood_board06a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_plank")
+ITEM.Recipe = {
+ Resources = {
+ ["Wood"] = 2,
+ ["Sap"] = 1,
+ },
+ Tools = {
+ ["Crystal"] = 1,
+ },
+}
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
\ No newline at end of file diff --git a/gamemode/itemsystem/items/ramp.lua b/gamemode/itemsystem/items/ramp.lua new file mode 100644 index 0000000..96e6c27 --- /dev/null +++ b/gamemode/itemsystem/items/ramp.lua @@ -0,0 +1,60 @@ +
+ITEM.Name = "Ramp"
+ITEM.Class = "structure"
+ITEM.Desc = "Some basic wood structure for setting up camps."
+ITEM.Model = "models/props_debris/wood_board07a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_fence")
+ITEM.Recipe = {
+ Resources = {
+ ["Plank"] = 2,
+ ["Log"] = 1,
+ ["Sap"] = 1,
+ },
+ Tools = {
+ ["Crystal"] = 1,
+ },
+}
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Ghost = {
+ {
+ Model = "models/props_wasteland/wood_fence02a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,0,0),
+ Ang = Angle(0,0,45),
+ },
+}
+
+ITEM.Range = 200
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (!pl:CanPlaceStructure(tr)) then pl:GhostStructure(self.Name) return end
+
+ if (tr.Hit) then
+ local drop = ents.Create("ws_prop")
+ drop:SetModel("models/props_wasteland/wood_fence02a.mdl")
+ drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,45))
+ drop:SetPos(tr.HitPos)
+ drop:Spawn()
+ drop:Activate()
+
+ if (pl:HasItem(self.Name)) then pl:RemoveItem(self.Name,1)
+ else pl:UnEquipWeaponSlot(pl.Select,true) end
+
+ pl:GhostRemove()
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/recipe_battleaxe.lua b/gamemode/itemsystem/items/recipe_battleaxe.lua new file mode 100644 index 0000000..2ae7c9b --- /dev/null +++ b/gamemode/itemsystem/items/recipe_battleaxe.lua @@ -0,0 +1,27 @@ +
+ITEM.Name = "Recipe: Battle Axe"
+ITEM.Class = "account"
+ITEM.Desc = "A recipe. Use it to print it on chat!"
+ITEM.Model = "models/Weapons/w_bugbait.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_recipe.png")
+
+function ITEM:OnUse(user)
+ if (CLIENT) then return end
+
+ local rec,item = GetRecipeForItem("Battle Axe")
+ local txt = "Recipe: "
+
+ txt = txt.." RESOURCES("
+ for a,b in pairs(rec.Resources) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ txt = txt.." TOOLS("
+ for a,b in pairs(rec.Tools) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ user:ChatPrint(txt)
+end
\ No newline at end of file diff --git a/gamemode/itemsystem/items/recipe_crystalhammer.lua b/gamemode/itemsystem/items/recipe_crystalhammer.lua new file mode 100644 index 0000000..097aa1a --- /dev/null +++ b/gamemode/itemsystem/items/recipe_crystalhammer.lua @@ -0,0 +1,27 @@ +
+ITEM.Name = "Recipe: Crystal Hammer"
+ITEM.Class = "account"
+ITEM.Desc = "A recipe. Use it to print it on chat!"
+ITEM.Model = "models/Weapons/w_bugbait.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_recipe.png")
+
+function ITEM:OnUse(user)
+ if (CLIENT) then return end
+
+ local rec,item = GetRecipeForItem("Crystal Hammer")
+ local txt = "Recipe: "
+
+ txt = txt.." RESOURCES("
+ for a,b in pairs(rec.Resources) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ txt = txt.." TOOLS("
+ for a,b in pairs(rec.Tools) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ user:ChatPrint(txt)
+end
\ No newline at end of file diff --git a/gamemode/itemsystem/items/recipe_diamondhammer.lua b/gamemode/itemsystem/items/recipe_diamondhammer.lua new file mode 100644 index 0000000..aab1a74 --- /dev/null +++ b/gamemode/itemsystem/items/recipe_diamondhammer.lua @@ -0,0 +1,27 @@ +
+ITEM.Name = "Recipe: Diamond Hammer"
+ITEM.Class = "account"
+ITEM.Desc = "A recipe. Use it to print it on chat!"
+ITEM.Model = "models/Weapons/w_bugbait.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_recipe.png")
+
+function ITEM:OnUse(user)
+ if (CLIENT) then return end
+
+ local rec,item = GetRecipeForItem("Diamond Hammer")
+ local txt = "Recipe: "
+
+ txt = txt.." RESOURCES("
+ for a,b in pairs(rec.Resources) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ txt = txt.." TOOLS("
+ for a,b in pairs(rec.Tools) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ user:ChatPrint(txt)
+end
\ No newline at end of file diff --git a/gamemode/itemsystem/items/recipe_maul.lua b/gamemode/itemsystem/items/recipe_maul.lua new file mode 100644 index 0000000..04c78f1 --- /dev/null +++ b/gamemode/itemsystem/items/recipe_maul.lua @@ -0,0 +1,27 @@ +
+ITEM.Name = "Recipe: Maul"
+ITEM.Class = "account"
+ITEM.Desc = "A recipe. Use it to print it on chat!"
+ITEM.Model = "models/Weapons/w_bugbait.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_recipe.png")
+
+function ITEM:OnUse(user)
+ if (CLIENT) then return end
+
+ local rec,item = GetRecipeForItem("Maul")
+ local txt = "Recipe: "
+
+ txt = txt.." RESOURCES("
+ for a,b in pairs(rec.Resources) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ txt = txt.." TOOLS("
+ for a,b in pairs(rec.Tools) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ user:ChatPrint(txt)
+end
\ No newline at end of file diff --git a/gamemode/itemsystem/items/recipe_shack.lua b/gamemode/itemsystem/items/recipe_shack.lua new file mode 100644 index 0000000..060fccb --- /dev/null +++ b/gamemode/itemsystem/items/recipe_shack.lua @@ -0,0 +1,27 @@ +
+ITEM.Name = "Recipe: Shack"
+ITEM.Class = "account"
+ITEM.Desc = "A recipe for the shack. Use it to print it on chat!"
+ITEM.Model = "models/Weapons/w_bugbait.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_recipe.png")
+
+function ITEM:OnUse(user)
+ if (CLIENT) then return end
+
+ local rec,item = GetRecipeForItem("Shack")
+ local txt = "Recipe: "
+
+ txt = txt.." RESOURCES("
+ for a,b in pairs(rec.Resources) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ txt = txt.." TOOLS("
+ for a,b in pairs(rec.Tools) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ user:ChatPrint(txt)
+end
\ No newline at end of file diff --git a/gamemode/itemsystem/items/recipe_stoneblock.lua b/gamemode/itemsystem/items/recipe_stoneblock.lua new file mode 100644 index 0000000..ba1447d --- /dev/null +++ b/gamemode/itemsystem/items/recipe_stoneblock.lua @@ -0,0 +1,27 @@ +
+ITEM.Name = "Recipe: Stoneblock"
+ITEM.Class = "account"
+ITEM.Desc = "A recipe. Use it to print it on chat!"
+ITEM.Model = "models/Weapons/w_bugbait.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_recipe.png")
+
+function ITEM:OnUse(user)
+ if (CLIENT) then return end
+
+ local rec,item = GetRecipeForItem("Stoneblock")
+ local txt = "Recipe: "
+
+ txt = txt.." RESOURCES("
+ for a,b in pairs(rec.Resources) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ txt = txt.." TOOLS("
+ for a,b in pairs(rec.Tools) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ user:ChatPrint(txt)
+end
\ No newline at end of file diff --git a/gamemode/itemsystem/items/recipe_tent.lua b/gamemode/itemsystem/items/recipe_tent.lua new file mode 100644 index 0000000..fd810af --- /dev/null +++ b/gamemode/itemsystem/items/recipe_tent.lua @@ -0,0 +1,27 @@ +
+ITEM.Name = "Recipe: Tent"
+ITEM.Class = "account"
+ITEM.Desc = "A recipe for the tent. Use it to print it on chat!"
+ITEM.Model = "models/Weapons/w_bugbait.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_recipe.png")
+
+function ITEM:OnUse(user)
+ if (CLIENT) then return end
+
+ local rec,item = GetRecipeForItem("Tent")
+ local txt = "Recipe: "
+
+ txt = txt.." RESOURCES("
+ for a,b in pairs(rec.Resources) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ txt = txt.." TOOLS("
+ for a,b in pairs(rec.Tools) do
+ txt=txt..b.." x "..a..", "
+ end
+ txt = txt..")"
+
+ user:ChatPrint(txt)
+end
\ No newline at end of file diff --git a/gamemode/itemsystem/items/researchtable.lua b/gamemode/itemsystem/items/researchtable.lua new file mode 100644 index 0000000..4b05cf2 --- /dev/null +++ b/gamemode/itemsystem/items/researchtable.lua @@ -0,0 +1,55 @@ +ITEM.Name = "Research Table"
+ITEM.Class = "structure"
+ITEM.Desc = "A table to find recepies\nPlace 10 wood, sap, and rock in the table to discover a new recipe."
+ITEM.Model = "models/props_junk/wood_crate001a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_recipe.png")
+ITEM.Recipe = {
+ Resources = {
+ ["Wood"] = 10,
+ ["Sap"] = 5,
+ },
+ Tools = {},
+}
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/wood_crate001a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Ghost = {
+ {
+ Model = "models/props/cs_italy/it_mkt_table3.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,0,0),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Range = 200
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (!pl:CanPlaceStructure(tr)) then pl:GhostStructure(self.Name) return end
+
+ if (tr.Hit) then
+ local drop = ents.Create("ws_researchtable")
+ drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,0))
+ drop:SetPos(tr.HitPos)
+ drop:Spawn()
+ drop:Activate()
+
+ if (pl:HasItem(self.Name)) then pl:RemoveItem(self.Name,1)
+ else pl:UnEquipWeaponSlot(pl.Select,true) end
+
+ pl:GhostRemove()
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/rock.lua b/gamemode/itemsystem/items/rock.lua new file mode 100644 index 0000000..5ee7e09 --- /dev/null +++ b/gamemode/itemsystem/items/rock.lua @@ -0,0 +1,60 @@ +
+ITEM.Name = "Rock"
+ITEM.Class = "weapon"
+ITEM.Desc = "A rock.\nIt is somewhat jagged."
+ITEM.Model = "models/props_junk/Rock001a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_rock")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Damage = 6
+ITEM.Range = 60
+ITEM.CD = .4
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:IsTree()) then
+ if (math.random(1,35)/10 < 1) then pl:AddItem("Sap",1) end
+
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
+
+function ITEM:OnSecondary(pl,tr)
+ if (CLIENT) then return end
+ if (!pl:HasItem(self.Name)) then return end
+
+ local drop = SpawnWSItem(self.Name,pl:GetShootPos()+pl:GetAimVector()*20)
+ drop:GetPhysicsObject():ApplyForceCenter(pl:GetAimVector() * 200)
+
+ pl:RemoveItem(self.Name,1)
+
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(40,60))
+end
diff --git a/gamemode/itemsystem/items/rope.lua b/gamemode/itemsystem/items/rope.lua new file mode 100644 index 0000000..a9d0c53 --- /dev/null +++ b/gamemode/itemsystem/items/rope.lua @@ -0,0 +1,14 @@ +
+ITEM.Name = "Rope"
+ITEM.Class = "resource"
+ITEM.Desc = "Handy rope for more advanced structures and tools."
+ITEM.Model = "models/props_junk/Rock001a.mdl"
+ITEM.Icon = Material("settlement/icon_rope")
+
+ITEM.Recipe = {
+ Resources = {
+ ["Vine"] = 3,
+ ["Sap"] = 1,
+ },
+ Tools = {},
+}
diff --git a/gamemode/itemsystem/items/runeblank.lua b/gamemode/itemsystem/items/runeblank.lua new file mode 100644 index 0000000..2935b4e --- /dev/null +++ b/gamemode/itemsystem/items/runeblank.lua @@ -0,0 +1,34 @@ +
+ITEM.Name = "Blank Rune"
+ITEM.Class = "resource"
+ITEM.Desc = "A blank peice of stone"
+ITEM.Model = "models/props_combine/breenlight.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_rune.png")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/rock001a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(3,-1.6,0.5),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Rock"] = 3,
+ ["Sap"] = 1,
+ },
+ Tools = {},
+}
+
+
+
+ITEM.Damage = 1
+ITEM.Range = 64
+ITEM.CD = 1
+
+function ITEM:OnEnchanted(enchanttable, nearbyrunes)
+ enchanttable:AddItem("Magic Rune", 1)
+end
diff --git a/gamemode/itemsystem/items/runeenergy.lua b/gamemode/itemsystem/items/runeenergy.lua new file mode 100644 index 0000000..226344e --- /dev/null +++ b/gamemode/itemsystem/items/runeenergy.lua @@ -0,0 +1,45 @@ +
+ITEM.Name = "Energy Rune"
+ITEM.Class = "resource"
+ITEM.Desc = "A rune infused with energy!\nYou could probably run really far with one of these"
+ITEM.Model = "models/props_combine/breenlight.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_runeelectric.png")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/rock001a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(3,-1.6,0.5),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Blank Rune"] = 1,
+ ["Juice"] = 1,
+ },
+ Tools = {},
+}
+
+
+
+ITEM.Damage = 1
+ITEM.Range = 64
+ITEM.CD = 1
+
+function ITEM:OnPrimary(user)
+ user:UnEquipWeaponSlot(user:GetSelectedWeapon())
+ self:OnUse(user)
+end
+
+function ITEM:OnUse(user)
+ if(CLIENT) then return end
+ user:SetFatigue(math.max(0,user:GetFatigue()-20))
+ user:RemoveItem(self.Name,1)
+end
+
+function ITEM:OnCraft(ply)
+ ply:AddFatigue(25)
+end
diff --git a/gamemode/itemsystem/items/runefire.lua b/gamemode/itemsystem/items/runefire.lua new file mode 100644 index 0000000..419712e --- /dev/null +++ b/gamemode/itemsystem/items/runefire.lua @@ -0,0 +1,48 @@ +
+ITEM.Name = "Fire Rune"
+ITEM.Class = "resource"
+ITEM.Desc = "A perpetually warm stone"
+ITEM.Model = "models/props_combine/breenlight.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_runefire.png")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/rock001a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(3,-1.6,0.5),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Blank Rune"] = 1,
+ ["Pitch"] = 1,
+ },
+ Tools = {},
+}
+
+
+
+ITEM.Damage = 1
+ITEM.Range = 500
+ITEM.CD = 1
+
+function ITEM:OnUse(user)
+ if(CLIENT) then return end
+ user:Ignite(1)
+ user:SetHeat(0)
+ user:RemoveItem(self.Name,1)
+end
+
+function ITEM:OnPrimary(ply,tr)
+ if(CLIENT) then
+ game.AddParticles("particles/particletest.pcf")
+ else
+ if(tr.Hit && tr.Entity && tr.Entity:IsPlayer()) then
+ tr.Entity:Ignite(5)
+ end
+ end
+
+end
diff --git a/gamemode/itemsystem/items/runemagic.lua b/gamemode/itemsystem/items/runemagic.lua new file mode 100644 index 0000000..e999299 --- /dev/null +++ b/gamemode/itemsystem/items/runemagic.lua @@ -0,0 +1,21 @@ +
+ITEM.Name = "Magic Rune"
+ITEM.Class = "resource"
+ITEM.Desc = "A stone infused with magic"
+ITEM.Model = "models/props_combine/breenlight.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_runemagic.png")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/rock001a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(3,-1.6,0.5),
+ Ang = Angle(0,0,0),
+ },
+}
+
+
+ITEM.Damage = 1
+ITEM.Range = 64
+ITEM.CD = 1
diff --git a/gamemode/itemsystem/items/runenature.lua b/gamemode/itemsystem/items/runenature.lua new file mode 100644 index 0000000..286a957 --- /dev/null +++ b/gamemode/itemsystem/items/runenature.lua @@ -0,0 +1,39 @@ +
+ITEM.Name = "Nature Rune"
+ITEM.Class = "resource"
+ITEM.Desc = "A blank peice of stone"
+ITEM.Model = "models/props_combine/breenlight.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_runenature.png")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/rock001a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(3,-1.6,0.5),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Blank Rune"] = 1,
+ ["Sap"] = 1,
+ ["Berry"] = 1,
+ ["Vine"] = 1
+ },
+ Tools = {},
+}
+
+
+
+ITEM.Damage = 1
+ITEM.Range = 64
+ITEM.CD = 1
+
+function ITEM:OnUse(user)
+ if(CLIENT) then return end
+ if not user then return end
+ user:SetHealth(math.min(100,user:Health()+25))
+ user:AddFatigue(10)
+end
diff --git a/gamemode/itemsystem/items/sap.lua b/gamemode/itemsystem/items/sap.lua new file mode 100644 index 0000000..18ff486 --- /dev/null +++ b/gamemode/itemsystem/items/sap.lua @@ -0,0 +1,6 @@ +
+ITEM.Name = "Sap"
+ITEM.Class = "resource"
+ITEM.Desc = "Tree sap. Very sticky, could be used as an adhesive."
+ITEM.Model = "models/props_junk/Rock001a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_sap")
diff --git a/gamemode/itemsystem/items/shack.lua b/gamemode/itemsystem/items/shack.lua new file mode 100644 index 0000000..f66fe38 --- /dev/null +++ b/gamemode/itemsystem/items/shack.lua @@ -0,0 +1,111 @@ +
+ITEM.Name = "Shack"
+ITEM.Class = "structure"
+ITEM.Desc = "An actual building... how convenient."
+ITEM.Model = "models/props_debris/wood_board07a.mdl"
+ITEM.Icon = Material("settlement/icon_shack")
+ITEM.Recipe = {
+ Resources = {
+ ["Tent"] = 1,
+ ["Log"] = 1,
+ ["Rope"] = 1,
+ ["Stoneblock"] = 1,
+ },
+ Tools = {
+ ["Crystal Hammer"] = 1,
+ },
+}
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Ghost = {
+ {
+ Model = "models/props_wasteland/wood_fence01a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,30,130),
+ Ang = Angle(0,0,45),
+ },
+ {
+ Model = "models/props_wasteland/wood_fence01a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,-30,130),
+ Ang = Angle(0,180,45),
+ },
+ {
+ Model = "models/props_wasteland/wood_fence01a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,-55,40),
+ Ang = Angle(0,0,0),
+ },
+ {
+ Model = "models/props_wasteland/wood_fence01a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(-55,0,40),
+ Ang = Angle(0,90,0),
+ },
+ {
+ Model = "models/props_wasteland/wood_fence01a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,55,40),
+ Ang = Angle(0,180,0),
+ },
+ {
+ Model = "models/props_wasteland/wood_fence02a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(55,27,40),
+ Ang = Angle(0,270,0),
+ },
+ {
+ Model = "models/props_wasteland/wood_fence01a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,0,100),
+ Ang = Angle(0,0,90),
+ },
+}
+
+ITEM.Range = 300
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (!pl:CanPlaceStructure(tr)) then pl:GhostStructure(self.Name) return end
+
+ if (tr.Hit) then
+ local Ang = Angle(0,pl:GetAimVector():Angle().y+90,0)
+ local Pos = tr.HitPos
+
+ for k,v in pairs(self.Ghost) do
+ local Off = v.Pos*1
+ Off:Rotate(Ang)
+
+ local Roa = Ang*1
+
+ Roa:RotateAroundAxis(Ang:Right(),v.Ang.p)
+ Roa:RotateAroundAxis(Ang:Forward(),v.Ang.r)
+ Roa:RotateAroundAxis(Ang:Up(),v.Ang.y)
+
+ local drop = ents.Create("ws_prop")
+ drop:SetModel(v.Model)
+ drop:SetAngles(Roa)
+ drop:SetPos(Pos+Off)
+ drop:Spawn()
+ drop:Activate()
+ end
+
+ if (pl:HasItem(self.Name)) then pl:RemoveItem(self.Name,1)
+ else pl:UnEquipWeaponSlot(pl.Select,true) end
+
+ pl:GhostRemove()
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/sickle.lua b/gamemode/itemsystem/items/sickle.lua new file mode 100644 index 0000000..4703655 --- /dev/null +++ b/gamemode/itemsystem/items/sickle.lua @@ -0,0 +1,67 @@ +
+ITEM.Name = "Sickle"
+ITEM.Class = "weapon"
+ITEM.Desc = "A sickle. Used for bushes for vines and berries"
+ITEM.Model = "models/props_debris/wood_board02a.mdl"
+ITEM.Icon = Material("settlement/icon_sickle")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.5,0.1,0.2),
+ Pos = Vector(3,-4,-22),
+ Ang = Angle(0,0,0),
+ },
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(.5,.5,.1),
+ Pos = Vector(3,-1.5,-6),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Wood"] = 1,
+ ["Rock"] = 2,
+ ["Sap"] = 1,
+ },
+ Tools = {},
+}
+
+
+
+ITEM.Damage = 10
+ITEM.Range = 64
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:IsPlant()) then
+ if (math.random(1,35)/10 < 1) then pl:AddItem("Vine",1) end
+ if (math.random(1,35)/10 < 1) then pl:AddItem("Berry",1) end
+
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/stoneblock.lua b/gamemode/itemsystem/items/stoneblock.lua new file mode 100644 index 0000000..36f1c35 --- /dev/null +++ b/gamemode/itemsystem/items/stoneblock.lua @@ -0,0 +1,14 @@ +
+ITEM.Name = "Stoneblock"
+ITEM.Class = "resource"
+ITEM.Desc = "A useful building material."
+ITEM.Model = "models/props_junk/CinderBlock01a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_stoneblock.png")
+
+ITEM.Recipe = {
+ Resources = {
+ ["Rock"] = 4,
+ ["Sap"] = 2,
+ },
+ Tools = {},
+}
diff --git a/gamemode/itemsystem/items/sword.lua b/gamemode/itemsystem/items/sword.lua new file mode 100644 index 0000000..47388d2 --- /dev/null +++ b/gamemode/itemsystem/items/sword.lua @@ -0,0 +1,58 @@ +
+ITEM.Name = "Sword"
+ITEM.Class = "weapon"
+ITEM.Desc = "A sword for combat."
+ITEM.Model = "models/weapons/w_archersword/w_archersword.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_sword.png")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/weapons/w_archersword/w_archersword.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(3,-1,0),
+ Ang = Angle(0,0,-90),
+ },
+}
+
+ITEM.Recipe = {
+ Resources = {
+ ["Wood"] = 1,
+ ["Crystal"] = 1,
+ ["Sap"] = 1,
+ },
+ Tools = {},
+}
+
+
+
+ITEM.Damage = 60
+ITEM.Range = 64
+ITEM.CD = 0.4
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+ print("Class:")
+ print(class)
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/tent.lua b/gamemode/itemsystem/items/tent.lua new file mode 100644 index 0000000..1d5a1b5 --- /dev/null +++ b/gamemode/itemsystem/items/tent.lua @@ -0,0 +1,79 @@ +
+ITEM.Name = "Tent"
+ITEM.Class = "structure"
+ITEM.Desc = "Something to duck under."
+ITEM.Model = "models/props_debris/wood_board07a.mdl"
+ITEM.Icon = Material("settlement/icon_tent")
+ITEM.Recipe = {
+ Resources = {
+ ["Fence"] = 4,
+ ["Rope"] = 2,
+ },
+ Tools = {
+ ["Crystal"] = 1,
+ },
+}
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(0.5,0.5,0.5),
+ Pos = Vector(4,-3,-1),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Ghost = {
+ {
+ Model = "models/props_wasteland/wood_fence01a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(30,0,40),
+ Ang = Angle(0,-90,45),
+ },
+ {
+ Model = "models/props_wasteland/wood_fence01a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(-30,0,40),
+ Ang = Angle(0,90,45),
+ },
+}
+
+ITEM.Range = 300
+ITEM.CD = 0.5
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (!pl:CanPlaceStructure(tr)) then pl:GhostStructure(self.Name) return end
+
+ if (tr.Hit) then
+ local Ang = Angle(0,pl:GetAimVector():Angle().y+90,0)
+ local Pos = tr.HitPos
+
+ for k,v in pairs(self.Ghost) do
+ local Off = v.Pos*1
+ Off:Rotate(Ang)
+
+ local Roa = Ang*1
+
+ Roa:RotateAroundAxis(Ang:Right(),v.Ang.p)
+ Roa:RotateAroundAxis(Ang:Forward(),v.Ang.r)
+ Roa:RotateAroundAxis(Ang:Up(),v.Ang.y)
+
+ local drop = ents.Create("ws_prop")
+ drop:SetModel(v.Model)
+ drop:SetAngles(Roa)
+ drop:SetPos(Pos+Off)
+ drop:Spawn()
+ drop:Activate()
+ end
+
+ if (pl:HasItem(self.Name)) then pl:RemoveItem(self.Name,1)
+ else pl:UnEquipWeaponSlot(pl.Select,true) end
+
+ pl:GhostRemove()
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
diff --git a/gamemode/itemsystem/items/vine.lua b/gamemode/itemsystem/items/vine.lua new file mode 100644 index 0000000..beeb5d4 --- /dev/null +++ b/gamemode/itemsystem/items/vine.lua @@ -0,0 +1,6 @@ +
+ITEM.Name = "Vine"
+ITEM.Class = "resource"
+ITEM.Desc = "A sturdy vine."
+ITEM.Model = "models/Gibs/Antlion_gib_Large_2.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_vine")
diff --git a/gamemode/itemsystem/items/wood.lua b/gamemode/itemsystem/items/wood.lua new file mode 100644 index 0000000..9d2d976 --- /dev/null +++ b/gamemode/itemsystem/items/wood.lua @@ -0,0 +1,66 @@ +
+ITEM.Name = "Wood"
+ITEM.Class = "weapon"
+ITEM.Desc = "Lumber. Maybe timber."
+ITEM.Model = "models/props_debris/wood_board02a.mdl"
+ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_wood")
+
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_debris/wood_board02a.mdl",
+ Size = Vector(.5,.5,.5),
+ Pos = Vector(3,-1.5,-12),
+ Ang = Angle(0,0,0),
+ },
+}
+
+ITEM.Damage = 5
+ITEM.Range = 60
+ITEM.CD = 0.6
+
+function ITEM:OnPrimary(pl,tr)
+ if (CLIENT) then return end
+
+ if (tr.Hit) then
+ if (IsValid(tr.Entity)) then
+ local ent = tr.Entity
+ local class = ent:GetClass()
+
+ if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then
+ ent:TakeDamage(self.Damage,pl)
+
+ if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110))
+ else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end
+ elseif (ent:GetModel():find("tree")) then
+ pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110))
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110))
+ end
+ else
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
+ end
+end
+
+function ITEM:OnCooked(campfire)
+ campfire:AddItem("Charcoal",1)
+end
+
+function ITEM:OnSecondary(pl,tr)
+ if (CLIENT) then return end
+ if (!pl:HasItem(self.Name)) then return end
+
+ local drop = SpawnWSItem(self.Name,pl:GetShootPos()+pl:GetAimVector()*20)
+ drop:GetPhysicsObject():ApplyForceCenter(pl:GetAimVector() * 200)
+
+ pl:RemoveItem(self.Name,1)
+
+ pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(40,60))
+end
+
+function ITEM:OnEnchanted(enchanttable, runes)
+ enchanttable:AddItem("Magic Wood", 1)
+end
diff --git a/gamemode/itemsystem/loaditems.lua b/gamemode/itemsystem/loaditems.lua new file mode 100644 index 0000000..a593e0d --- /dev/null +++ b/gamemode/itemsystem/loaditems.lua @@ -0,0 +1,83 @@ +local Folder = GM.Folder:gsub("gamemodes/","").."/gamemode/itemsystem/items"
+local insert = table.insert
+
+function GM:LoadItems()
+ local Items = file.Find(Folder.."/*.lua","LUA")
+ local BaseItem = {}
+
+ GAMEMODE.Items = {}
+ GAMEMODE.Recipes = {}
+
+ ITEM = {}
+
+ AddCSLuaFile(Folder.."/base.lua")
+ include(Folder.."/base.lua")
+
+ BaseItem = table.Copy(ITEM)
+
+ for k,v in pairs(Items) do
+ if (v != "base.lua") then
+ AddCSLuaFile(Folder.."/"..v)
+ include(Folder.."/"..v)
+
+ insert(GAMEMODE.Items,ITEM)
+ if (ITEM.Recipe) then insert(GAMEMODE.Recipes,ITEM) end
+
+ ITEM = table.Copy(BaseItem)
+
+ end
+ end
+end
+
+hook.Add("Initialize","LoadItems",function()
+ local Items = file.Find(Folder.."/*.lua","LUA")
+ local BaseItem = {}
+
+ GAMEMODE.Items = {}
+ GAMEMODE.Recipes = {}
+
+ ITEM = {}
+
+ AddCSLuaFile(Folder.."/base.lua")
+ include(Folder.."/base.lua")
+
+ BaseItem = table.Copy(ITEM)
+
+ for k,v in pairs(Items) do
+ if (v != "base.lua") then
+ AddCSLuaFile(Folder.."/"..v)
+ include(Folder.."/"..v)
+
+ insert(GAMEMODE.Items,ITEM)
+ if (ITEM.Recipe) then insert(GAMEMODE.Recipes,ITEM) end
+
+ ITEM = table.Copy(BaseItem)
+
+ end
+ end
+end)
+
+function GetItemByName(name)
+ for k,v in pairs( GAMEMODE.Items ) do
+ if (v.Name == name) then return v end
+ end
+
+ return nil
+end
+
+function GetRecipeForItem(name)
+ for k,v in pairs( GAMEMODE.Recipes ) do
+ if (v.Name == name) then return v.Recipe,v end
+ end
+
+ return nil
+end
+
+function GetItemsByClass(class)
+ local Dat = {}
+ for k,v in pairs( GAMEMODE.Items ) do
+ if (v.Class == class) then table.insert(Dat,v) end
+ end
+
+ return Dat
+end
diff --git a/gamemode/npcsystem/aidirector.lua b/gamemode/npcsystem/aidirector.lua new file mode 100644 index 0000000..bcaa63b --- /dev/null +++ b/gamemode/npcsystem/aidirector.lua @@ -0,0 +1,36 @@ +--Lol i dunno, spawn some npc's or something
+
+concommand.Add("ws_spawnbird",function(ply, cmd, args)
+ SpawnNpcByName("Bird",ply:GetPos())
+ end
+)
+
+function SpawnNpcByName(name, position)
+ entdata = GetNpcByName(name)
+ ent = ents.Create("ws_npc_ambient")
+ ent:SetPos(position)
+
+
+ if(entdata.Speed) then
+ ent.Speed = entdata.Speed
+ end
+ if(entdata.Model) then
+ ent.Model = entdata.Model
+ end
+ if(entdata.vitality) then
+ ent:SetHealth(entdata.vitality)
+ end
+ if(entdata.Drops) then
+ ent.Drops = entdata.Drops
+ end
+ if(entdata.OnDammage) then
+ ent.OnDammage = entdata.OnDammage
+ end
+ if(entdata.Behave) then
+ ent.Behave = entdata.Behave
+ end
+ if(entdata.Act) then
+ ent.Act = entdata.Act
+ end
+ ent:Spawn()
+end
diff --git a/gamemode/npcsystem/loadnpcs.lua b/gamemode/npcsystem/loadnpcs.lua new file mode 100644 index 0000000..2db2aae --- /dev/null +++ b/gamemode/npcsystem/loadnpcs.lua @@ -0,0 +1,60 @@ +local Folder = GM.Folder:gsub("gamemodes/","").."/gamemode/npcsystem/npcs"
+local insert = table.insert
+
+function GM:LoadNPCS()
+ local Items = file.Find(Folder.."/*.lua","LUA")
+ local BaseItem = {}
+
+ GAMEMODE.Npcs = {}
+
+ NPC = {}
+
+ AddCSLuaFile(Folder.."/base.lua")
+ include(Folder.."/base.lua")
+
+ BaseItem = table.Copy(NPC)
+
+ for k,v in pairs(Items) do
+ if (v != "base.lua") then
+ AddCSLuaFile(Folder.."/"..v)
+ include(Folder.."/"..v)
+
+ insert(GAMEMODE.Npcs,NPC)
+
+ NPC = table.Copy(BaseItem)
+
+ end
+ end
+end
+
+hook.Add("Initialize","Loadnpcs",function()
+ GAMEMODE:LoadNPCS()
+end)
+
+function GetNpcByName(name)
+ for k,v in pairs( GAMEMODE.Npcs ) do
+ if (v.Name == name) then return v end
+ end
+
+ return nil
+end
+
+--[[
+function GetRecipeForItem(name)
+ for k,v in pairs( GAMEMODE.Recipes ) do
+ if (v.Name == name) then return v.Recipe,v end
+ end
+
+ return nil
+end
+]]--
+--[[
+function GetItemsByClass(class)
+ local Dat = {}
+ for k,v in pairs( GAMEMODE.Items ) do
+ if (v.Class == class) then table.insert(Dat,v) end
+ end
+
+ return Dat
+end
+]]--
diff --git a/gamemode/npcsystem/npcs/base.lua b/gamemode/npcsystem/npcs/base.lua new file mode 100644 index 0000000..7afb4fe --- /dev/null +++ b/gamemode/npcsystem/npcs/base.lua @@ -0,0 +1,57 @@ +NPC.Name = "Winter Survival 2 Base NPC"
+NPC.Desc = "Why the hell did I write this? No one will read it anyways!!"
+NPC.Class = "Other" --Ambient, Agressive, Boss
+NPC.Model = "models/props_combine/breenlight.mdl"
+NPC.Icon = Material("wintersurvival2/hud/ws1_icons/icon_rock")
+
+NPC.Social = "Pack" --Solo, Pack
+
+NPC.Vitality = 0
+NPC.Speed = 0
+--Drops should be formated as [index]={["item name"], percent_drop} where percent_drop is a number from 0 to 100
+NPC.Drops = nil
+
+--Attacks should be formated as [i]={function attackpriority() = function doattack()}
+NPC.Attacks = nil
+
+--A function that takes a position and returns true if this is an acceptable place to spawn
+NPC.SpawnLocations = nil
+
+--The entity that is this npc's current target, if it has one
+NPC.Target = nil
+
+--All enemies that this NPC is aware of
+NPC.AwareEnemies = nil
+
+--These are just here to tell the editors/develoeprs what functions are available.. dont un-comment them out, as this could affect all the items.
+/*
+--What to replace the ENT:BehaveAct with
+function NPC:Act()
+end
+
+--What to replace RunBehaviour with
+function NPC:Behaviour()
+end
+
+function NPC:OnSpawn()
+end
+
+--If we need to do more than just reduce health on dammage
+function NPC:OnDammage(ammount)
+end
+
+--If we need to do more than just drop items on death
+function NPC:OnDeath()
+end
+
+--A particular spell was cast on this npc by player
+function NPC:OnSpell(spell, player)
+end
+
+function NPC:OnFindEnemy(enemy)
+end
+
+--Called when the npc is attacking anything with any attack
+function NPC:OnAttack(target)
+end
+*/
diff --git a/gamemode/npcsystem/npcs/bird.lua b/gamemode/npcsystem/npcs/bird.lua new file mode 100644 index 0000000..d5cd1e0 --- /dev/null +++ b/gamemode/npcsystem/npcs/bird.lua @@ -0,0 +1,101 @@ +NPC.Name = "Bird"
+NPC.Desc = "A flappy little guy"
+NPC.Class = "Ambient" --Ambient, Agressive, Boss
+NPC.Model = "models/pigeon.mdl"
+NPC.Icon = Material("wintersurvival2/hud/ws1_icons/icon_rock")
+
+NPC.Social = "Pack" --Solo, Pack
+
+NPC.Vitality = 10
+NPC.Speed = 100
+--Drops should be formated as [index]={["item name"], percent_drop} where percent_drop is a number from 0 to 100
+NPC.Drops = {
+ [0] = {"Meat",100},--Birds will drop at least 1 meat, and have a 50% chance of dropping 2
+ [1] = {"Meat",50},
+ [2] = {"Feather",50},
+}
+
+--Attacks should be formated as [i]={function attackpriority() = function doattack()}
+NPC.Attacks = nil
+
+--A function that takes a position and returns true if this is an acceptable place to spawn
+NPC.SpawnLocations = nil
+
+--The entity that is this npc's current target, if it has one. Nil otherwise
+NPC.Target = nil
+
+--All enemies that this NPC is aware of
+NPC.AwareEnemies = nil
+
+--What to replace the ENT:BehaveAct with
+function NPC:Act()
+end
+
+--What to replace ENT:RunBehaviour with
+function NPC:Behave()
+ print("Going into bird's custom behaviour")
+ while ( true ) do
+ self:StartActivity( ACT_FLY ) -- walk anims
+ self.loco:SetDesiredSpeed( 100 ) -- walk speeds
+ self:MoveToPos( self:GetPos() + Vector( math.Rand( -1, 1 ), math.Rand( -1, 1 ), 0 ) * 200 ) -- walk to a random place within about 200 units (yielding)
+
+
+ self:StartActivity( ACT_IDLE ) -- revert to idle activity
+
+
+ self:PlaySequenceAndWait( "Idle01" ) -- Sit on the floor
+ --Check if there are any players nearby
+ local players = ents.FindByClass("Player")
+ for k,v in pairs(players) do
+ print(k)
+ print(v)
+ end
+ --self:SetSequence( "sit_ground" ) -- Stay sitting
+ --coroutine.wait( self:PlayScene( "scenes/eli_lab/mo_gowithalyx01.vcd" ) ) -- play a scene and wait for it to finish before progressing
+ self:PlaySequenceAndWait( "Fly01" ) -- Get up
+
+
+ -- find the furthest away hiding spot
+ local pos = self:FindSpot( "random", { type = 'hiding', radius = 5000 } )
+
+
+ -- if the position is valid
+ if ( pos ) then
+ self:StartActivity( ACT_RUN ) -- run anim
+ self.loco:SetDesiredSpeed( 200 ) -- run speed
+ self:PlayScene( "scenes/npc/female01/watchout.vcd" ) -- shout something while we run just for a laugh
+ self:MoveToPos( pos ) -- move to position (yielding)
+ self:PlaySequenceAndWait( "fear_reaction" ) -- play a fear animation
+ self:StartActivity( ACT_IDLE ) -- when we finished, go into the idle anim
+ else
+ --print("Bird could not find anywhere to fly to")
+ -- some activity to signify that we didn't find shit
+ end
+ end
+ coroutine.yield()
+end
+
+--These are just here to tell the editors/develoeprs what functions are available.. dont un-comment them out, as this could affect all the items.
+/*
+function NPC:OnSpawn()
+end
+
+--If we need to do more than just reduce health on dammage
+function NPC:OnDammage(ammount)
+end
+
+--If we need to do more than just drop items on death
+function NPC:OnDeath()
+end
+
+--A particular spell was cast on this npc by player
+function NPC:OnSpell(spell, player)
+end
+
+function NPC:OnFindEnemy(enemy)
+end
+
+--Called when the npc is attacking anything with any attack
+function NPC:OnAttack(target)
+end
+*/
diff --git a/gamemode/npcsystem/npcs/zombie.lua b/gamemode/npcsystem/npcs/zombie.lua new file mode 100644 index 0000000..0980cdc --- /dev/null +++ b/gamemode/npcsystem/npcs/zombie.lua @@ -0,0 +1,47 @@ +NPC.Name = "Zombie"
+NPC.Desc = "Ahh! The Undead!!"
+NPC.Class = "Other" --Ambient, Agressive, Boss
+NPC.Model = "models/props_combine/breenlight.mdl"
+NPC.Icon = Material("wintersurvival2/hud/ws1_icons/icon_rock")
+
+NPC.Vitality = 100
+NPC.Speed = 100
+--Drops should be formated as [index]={["item name"], percent_drop} where percent_drop is a number from 0 to 100
+NPC.Drops = nil
+
+--Attacks should be formated as [range]={index = function doattack(target)}
+--Where range is the range of the target, and doattack(target) is the function called to attack
+NPC.Attacks = nil
+
+--A function that takes a position and returns true if this is an acceptable place to spawn
+NPC.SpawnLocations = function(pos) return true end
+
+--The entity that is this npc's current target, if it has one
+NPC.Target = nil
+
+--All enemies that this NPC is aware of
+NPC.AwareEnemies = nil
+--These are just here to tell the editors/develoeprs what functions are available.. dont un-comment them out, as this could affect all the items.
+/*
+function NPC:OnSpawn()
+end
+
+--If we need to do more than just reduce health on dammage
+function NPC:OnDammage(ammount)
+end
+
+--If we need to do more than just drop items on death
+function NPC:OnDeath()
+end
+
+--A particular spell was cast on this npc by player
+function NPC:OnSpell(spell, player)
+end
+
+function NPC:OnFindEnemy(enemy)
+end
+
+--Called when the npc is attacking anything with any attack
+function NPC:OnAttack(target)
+end
+*/
diff --git a/gamemode/server/concommands.lua b/gamemode/server/concommands.lua new file mode 100644 index 0000000..a6c891c --- /dev/null +++ b/gamemode/server/concommands.lua @@ -0,0 +1,66 @@ +concommand.Add("ws_giveitem",function(pl,com,args)
+ if (!IsValid(pl)) then return end
+ if (!pl:IsAdmin()) then return end
+ if (!args[1]) then return end
+
+ pl:AddItem(args[1],tonumber(args[2] or 1))
+end)
+
+concommand.Add("ws_revive",function(pl,com,args)
+ if (IsValid(pl) and !pl:IsAdmin()) then return end
+ if (!args[1]) then return end
+
+ for k,v in pairs(player.GetAll()) do
+ if (v:Nick():lower():find(args[1]) and v:IsPigeon()) then
+ v:ChatPrint("You have been resurrected from the dead by an admin!")
+ v:SetHuman(true)
+ v:KillSilent()
+ v:EmitSound("wintersurvival2/ritual/wololo.mp3")
+ end
+ end
+end)
+
+--Manual generate a proprain, for debugging
+concommand.Add("ws_proprain",function(ply,cmd,args)
+ if (IsValid(pl) and !pl:IsAdmin()) then return end
+ GAMEMODE:GeneratePropRain()
+end)
+
+--Manual reload of items + recepies, usefull for testing
+concommand.Add("ws_reloaditems",function(ply,cmd,args)
+ if (IsValid(pl) and !pl:IsAdmin()) then return end
+ GAMEMODE:LoadItems()
+end)
+
+--Manual reload of npc's, usefull for testing
+concommand.Add("ws_reloadnpcs",function(ply,cmd,args)
+ if (IsValid(pl) and !pl:IsAdmin()) then return end
+ GAMEMODE:LoadNPCS()
+end)
+
+--Generate a nice HTML representation of all the recepies.
+concommand.Add("ws_generaterecipes",function(pl,com,args)
+ if (IsValid(pl) and !pl:IsAdmin()) then return end
+ local filename = "ws_recipedata.txt"
+ for k,v in pairs(GAMEMODE.Recipes) do
+ if not v.Recipe then continue end
+ if not v.Name then continue end
+ file.Append(filename,"<li>\n\t<label>\n\t\t<input type='checkbox'>\n\t\t" .. v.Name)
+ for i,j in pairs(v.Recipe) do
+ if(i == "Resources") then
+ file.Append(filename,"\n\t<ul type='circle'>")
+ for p,q in pairs(j) do
+ file.Append(filename,"\n\t\t<li>" .. p .. " x " .. q .. "</li>")
+ end
+ file.Append(filename,"\n\t</ul>")
+ elseif(i == "Tools") then
+ file.Append(filename,"\n\t<ul type='square'>")
+ for p,q in pairs(j) do
+ file.Append(filename,"\n\t\t<li>" .. p .. " x " .. q .. "</li>")
+ end
+ file.Append(filename,"\n\t</ul>")
+ end
+ end
+ file.Append(filename,"\n\t</label>\n</li>\n")
+ end
+end)
diff --git a/gamemode/server/spawnitem.lua b/gamemode/server/spawnitem.lua new file mode 100644 index 0000000..ef13104 --- /dev/null +++ b/gamemode/server/spawnitem.lua @@ -0,0 +1,12 @@ +
+function SpawnWSItem(Item,pos)
+ local IT = GetItemByName(Item)
+
+ local drop = ents.Create("ws_item")
+ drop.Item = IT
+ drop:SetModel(drop.Item.Model)
+ drop:SetPos(pos)
+ drop:Spawn()
+
+ return drop
+end
\ No newline at end of file diff --git a/gamemode/server/world.lua b/gamemode/server/world.lua new file mode 100644 index 0000000..9d23c7b --- /dev/null +++ b/gamemode/server/world.lua @@ -0,0 +1,60 @@ +
+local random = math.random
+local traceline = util.TraceLine
+local contents = util.PointContents
+local Up = Vector(0,0,1)
+
+function GM:GeneratePropRain()
+ local Items = {
+ GetItemByName("Wood"),
+ GetItemByName("Rock"),
+ GetItemByName("Crystal"),
+ }
+
+ --THIS PIECE OF CODE IS FOR OLDER VERSIONS OF WS MAPS! ITS CRAP BUT WE HAVE TO... For WS players!
+ local areas = {}
+
+ for i,area in pairs(ents.FindByClass("info_target")) do
+ if (area:GetName() == "survival_spawn") then
+ local parent = area:GetParent()
+ if (IsValid(parent)) then
+ areas[area] = parent
+ end
+ end
+ end
+
+ for pAe,pBe in pairs(areas) do
+ local pA,pB = pAe:GetPos(),pBe:GetPos()
+ local Dis = pA:Distance(pB)
+
+ for i = 1,40+math.ceil(Dis/70) do
+ local V = Vector(random(pB.x,pA.x),random(pB.y,pA.y),random(pB.z,pA.z))
+ local Tr = traceline({start=V,endpos=V-Up*40000})
+ local Pos = Tr.HitPos+Up*20
+ local C = contents(Pos)
+
+ if (C != CONTENTS_WATER and C != CONTENTS_WATER+CONTENTS_TRANSLUCENT) then
+ local drop = ents.Create("ws_item")
+ drop.Item = Items[random(1,3)]
+ drop:SetModel(drop.Item.Model)
+ drop:SetPos(Pos)
+ drop:Spawn()
+ drop:GetPhysicsObject():Sleep()
+ end
+ end
+
+ --Shop spawn
+ local V = Vector(random(pB.x,pA.x),random(pB.y,pA.y),random(pB.z,pA.z))
+ local Tr = traceline({start=V,endpos=V-Up*40000})
+ local Pos = Tr.HitPos+Up*20
+ local C = contents(Pos)
+
+ if (C != CONTENTS_WATER and C != CONTENTS_WATER+CONTENTS_TRANSLUCENT) then
+ local drop = ents.Create("ws_shop")
+ drop:SetPos(Pos)
+ drop:Spawn()
+ drop:Activate()
+ end
+ end
+ --END... Newer versions of maps should use a brush entity instead.
+end
diff --git a/gamemode/shared.lua b/gamemode/shared.lua new file mode 100644 index 0000000..031025e --- /dev/null +++ b/gamemode/shared.lua @@ -0,0 +1,21 @@ +DeriveGamemode( "gearfox" )
+
+AddLuaCSFolder("hud")
+AddLuaCSFolder("client")
+
+AddLuaSHFolder("shared")
+AddLuaSHFolder("itemsystem")
+AddLuaSHFolder("npcsystem")
+
+AddLuaSVFolder("server")
+
+GM.Name = "Winter Survival 2 - Anarchy"
+GM.Author = "Apickx"
+GM.Email = "admin@cogarr.org"
+GM.Website = "www.cogarr.org"
+
+local Zero = Vector(0,0,0)
+
+function GM:Move(ply,mv)
+ if (ply:IsPigeon() or !ply:Alive()) then mv:SetVelocity(-ply:GetVelocity()) return mv end
+end
diff --git a/gamemode/shared/accounts.lua b/gamemode/shared/accounts.lua new file mode 100644 index 0000000..06cc296 --- /dev/null +++ b/gamemode/shared/accounts.lua @@ -0,0 +1,153 @@ + +--Not sure if i should make this MySQLoo, textbased or SQLites + +local meta = FindMetaTable("Player") + +if (SERVER) then + util.AddNetworkString("UpdatePlayerDB") + + concommand.Add("ws_printallaccounts",function(pl) + if (!IsValid(pl) or !pl:IsAdmin()) then return end + + local dat = sql.Query("SELECT * FROM WS2Accounts") + + pl:ChatPrint(table.Count(dat) .. " accounts registered!") + end) + + concommand.Add("ws_setrank",function(pl,com,arg) + if (!IsValid(pl) or !pl:IsAdmin()) then return end + if (!arg[2]) then return end + + local name = arg[1]:lower() + local rank = tonumber(arg[2]) + + for k,v in pairs(player.GetAll()) do + if (v:Nick():find(name)) then + v.Rank = rank + v:ChatPrint("Your rank has been set to "..rank) + + if (rank == 1) then v:SetUserGroup("admin") end + + MsgN("Player "..v:Nick().." has been set to "..rank) + break + end + end + end) + + + hook.Add("Initialize","InitSQLiteDB",function() + if (!sql.TableExists("WS2Accounts")) then + local Dat = { + "id INT UNSIGNED NOT NULL PRIMARY KEY", + "inventory MEDIUMTEXT", + "equipped MEDIUMTEXT", + "rank TINYINT", + "timespent INT UNSIGNED", + } + + Msg("Table not found. Creating new table for accounts!\n") + sql.Query("CREATE TABLE IF NOT EXISTS WS2Accounts ("..table.concat(Dat,",")..");") + end + end) + + hook.Add("PlayerAuthed","InitSQLitePlayer",function(pl) + pl:LoadPlayer() + end) + + hook.Add("EntityRemoved","UpdatePlayer",function(ent) + if (ent:IsPlayer()) then + local f,err = pcall(ent.UpdateSQLite,ent) + end + end) + + hook.Add("Tick","UpdatePlayerDB",function() + for k,v in pairs(player.GetAll()) do + if (v.UpdateTime and v.UpdateTime < CurTime()) then + v.UpdateTime = CurTime()+30 + v:UpdateSQLite() + end + end + end) + + function meta:LoadPlayer() + local ID = self:SteamID64() + + if (!ID) then + Msg("Retrying loading player "..self:Nick().."\n") + timer.Simple(1,function() if (IsValid(self)) then self:LoadPlayer() end end) + return + end + + local data = sql.Query("SELECT * FROM WS2Accounts WHERE id="..ID) + + self.UpdateTime = CurTime()+30 + self.LastJoined = CurTime() + self.AccountInv = {} + self.Equipped = {} + self.Rank = 0 + + self.StoredID = ID + + if (!data) then + Msg("Player "..self:Nick().." was not found. Creating new account!\n") + + local dat = { + self.StoredID, + "''", + "''", + 0, + 0, + } + + sql.Query("INSERT INTO WS2Accounts(id,inventory,equipped,rank,timespent) VALUES ("..table.concat(dat,",")..");") + else + self.LastJoined = CurTime()-tonumber(data[1].timespent) + self.Rank = tonumber(data[1].rank) + + for k,v in pairs(string.Explode("\n",data[1].inventory)) do + local Ab = string.Explode("æ",v) + if (Ab[2]) then self:AddAccountItem(Ab[1],tonumber(Ab[2])) end + end + + if (self.Rank == 1) then self:SetUserGroup("admin") self:ChatPrint("You are an admin on this server!") end + + net.Start("UpdatePlayerDB") + net.WriteUInt(tonumber(data[1].timespent),32) + net.WriteUInt(self.Rank,4) + net.Send(self) + end + end + + function meta:UpdateSQLite() + if (!self.StoredID) then self:Kick("Your ID seems to be invailed. Reconnect please!") return end + + local Inventory = "" + + for k,v in pairs(self:GetAccountInventory()) do + Inventory = Inventory..v.Name.."æ"..v.Quantity.."\n" + end + + local dat = { + "timespent="..math.ceil(CurTime()-self.LastJoined), + "rank="..self.Rank, + "inventory="..SQLStr(Inventory) + } + + sql.Query("UPDATE WS2Accounts SET "..table.concat(dat,",").." WHERE id="..self.StoredID..";") + end +else + net.Receive("UpdatePlayerDB",function() + local pl = LocalPlayer() + + pl.LastJoined = CurTime()-net.ReadUInt(32) + pl.Rank = net.ReadUInt(4) + end) +end + +function meta:GetRank() + return self.Rank or 0 +end + +function meta:GetTimeSpent() + return ((self.LastJoined and CurTime() - self.LastJoined) or 0) +end
\ No newline at end of file diff --git a/gamemode/shared/entity_ext.lua b/gamemode/shared/entity_ext.lua new file mode 100644 index 0000000..c0e1b34 --- /dev/null +++ b/gamemode/shared/entity_ext.lua @@ -0,0 +1,19 @@ +local meta = FindMetaTable("Entity")
+
+function meta:IsTree()
+ local model = self:GetModel()
+ local class = self:GetClass()
+ return ((model:find("tree") or model:find("pine")) and !class:find("ws_"))
+end
+
+function meta:IsRock()
+ local model = self:GetModel()
+ local class = self:GetClass()
+ return (model:find("rock") and !class:find("ws_"))
+end
+
+function meta:IsPlant()
+ local model = self:GetModel()
+ local class = self:GetClass()
+ return (model:find("antlionhill") and !class:find("ws_"))
+end
\ No newline at end of file diff --git a/gamemode/shared/game_rounds.lua b/gamemode/shared/game_rounds.lua new file mode 100644 index 0000000..67b77c9 --- /dev/null +++ b/gamemode/shared/game_rounds.lua @@ -0,0 +1,105 @@ +local meta = FindMetaTable("Player")
+local Time = 10
+
+if (SERVER) then
+ util.AddNetworkString("RoundStart")
+
+ function GM:StartCountDown()
+ self.CountDown = CurTime()+Time+1
+
+ //items to clean up in between rounds
+ cleanup = {
+ "ws_alter",
+ "ws_arrow",
+ "ws_barrel",
+ "ws_campfire",
+ "ws_grave",
+ "ws_infuser",
+ "ws_item",
+ "ws_prop",
+ "ws_researchtable",
+ "ws_shop",
+ "ws_rune",
+ }
+ for k,v in pairs(cleanup) do
+ for i,j in pairs(ents.FindByClass(v)) do
+ j:Remove()
+ end
+ end
+
+
+
+ --Generate a completly new rain of props :D
+ self:GeneratePropRain()
+
+ net.Start("RoundStart")
+ net.WriteUInt(Time,8)
+ net.Broadcast()
+ end
+
+ function meta:UpdateRoundTimer()
+ if (!self.CountDown or self.CountDown<CurTime()) then return end
+
+ net.Start("RoundStart")
+ net.WriteUInt(math.floor(self.CountDown-CurTime()),8)
+ net.Send(self)
+ end
+ hasprinted = false
+ hook.Add("Tick","CountDowner",function()
+ if (GAMEMODE.GameOn) then
+ if (#player.GetAll() < 2) then
+ --TODO: Less than 2 players in the server
+ GAMEMODE.CountDown = nil
+ GAMEMODE.GameOn = false
+ return
+ elseif (#player.GetAllHumans() < 2) then
+ GAMEMODE.CountDown = nil
+ GAMEMODE.GameOn = false
+ for k,v in pairs(player.GetAllHumans()) do
+ v:AddAccountItem(table.Random(GetItemsByClass("account")).Name,1)
+ end
+
+ timer.Simple(Time,function() for k,v in pairs(player.GetAllHumans()) do v:Kill() end end)
+
+ GAMEMODE:StartCountDown()
+ return
+ end
+ else
+ if(!hasprinted) then
+ for k,v in pairs(player.GetAll()) do
+ v:ChatPrint("Winter survival requires 2 players or more to play")
+ v:ChatPrint("Invite a friend!")
+ end
+ hasprinted = true
+ end
+ end
+
+ if (GAMEMODE.GameOn or !GAMEMODE.CountDown) then return end
+
+ if (GAMEMODE.CountDown < CurTime()) then
+ print("Test2")
+ if (#player.GetAll() < 2) then
+ GAMEMODE.CountDown = CurTime()+Time+1
+ return
+ end
+
+ for k,v in pairs(player.GetAll()) do
+ if (v:IsPigeon()) then
+ if (IsValid(v.Pigeon)) then v.Pigeon:Remove() end
+ v:SetHuman(true)
+ v:KillSilent()
+
+ timer.Simple(1,function() if (IsValid(v) and !v:Alive()) then v:Spawn() end end)
+ end
+ end
+
+ GAMEMODE.GameOn = true
+ end
+ end)
+else
+ net.Receive("RoundStart",function() GAMEMODE.CountDown = CurTime()+net.ReadUInt(8) end)
+end
+
+function GetCountDown()
+ return GAMEMODE.CountDown
+end
diff --git a/gamemode/shared/player_accountinventory.lua b/gamemode/shared/player_accountinventory.lua new file mode 100644 index 0000000..2a1b684 --- /dev/null +++ b/gamemode/shared/player_accountinventory.lua @@ -0,0 +1,98 @@ +
+local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("UpdateAccountInventory")
+
+ function meta:UpdateAccountSlot(id)
+ if (!self.AccountInv[id]) then return end
+
+ net.Start("UpdateAccountInventory")
+ net.WriteUInt(id,5)
+ net.WriteString(self.AccountInv[id].Name)
+ net.WriteUInt(self.AccountInv[id].Quantity,32)
+ net.Send(self)
+ end
+
+ function meta:AddAccountItem(item,quantity)
+ local Item = GetItemByName(item)
+
+ if (!Item) then return end
+ if (!self.AccountInv) then self.AccountInv = {} end
+
+ --First search for existing items
+ for i = 1,MAIN_MAX_SLOTS do
+ if (self.AccountInv[i] and self.AccountInv[i].Name == item) then
+ self.AccountInv[i].Quantity = self.AccountInv[i].Quantity+quantity
+ self:UpdateAccountSlot(i)
+ return
+ end
+ end
+
+ --If it hasnt found any existing item, find an empty spot
+ for i = 1,MAIN_MAX_SLOTS do
+ if (!self.AccountInv[i]) then
+ self.AccountInv[i] = {Name = item,Quantity = quantity}
+ self:UpdateAccountSlot(i)
+ return
+ end
+ end
+ end
+
+ function meta:RemoveAccountItem(item,quantity)
+ for i = 1,MAIN_MAX_SLOTS do
+ if (self.AccountInv[i] and self.AccountInv[i].Name == item) then
+ if (self.AccountInv[i].Quantity > quantity) then
+ self.AccountInv[i].Quantity = self.AccountInv[i].Quantity-quantity
+ self:UpdateAccountSlot(i)
+ return
+ else
+ quantity = quantity - self.AccountInv[i].Quantity
+
+ self.AccountInv[i].Quantity = 0
+
+ self:UpdateAccountSlot(i)
+
+ self.AccountInv[i] = nil
+
+ if (quantity > 0) then self:RemoveAccountItem(item,quantity) return end
+ end
+ end
+ end
+ end
+else
+ net.Receive("UpdateAccountInventory",function()
+ local pl = LocalPlayer()
+
+ if (!pl.AccountInv) then pl.AccountInv = {} end
+
+ local ID = net.ReadUInt(5)
+ pl.AccountInv[ID] = {Name = net.ReadString(),Quantity = net.ReadUInt(32)}
+
+ if (pl.AccountInv[ID].Quantity <= 0) then pl.AccountInv[ID] = nil end
+
+ ReloadAccountMenu()
+ end)
+end
+
+function meta:GetAccountInventory()
+ return self.AccountInv or {}
+end
+
+function meta:HasAccountItem(name,quantity)
+ if (!self.AccountInv) then return end
+
+ quantity = quantity or 1
+
+ for k,v in pairs(self.AccountInv) do
+ if (v.Name == name and v.Quantity >= quantity) then
+ return k
+ end
+ end
+
+ return false
+end
+
+function meta:GetAccountSlot(id)
+ return (self.AccountInv and self.AccountInv[id]) or nil
+end
\ No newline at end of file diff --git a/gamemode/shared/player_dropitem.lua b/gamemode/shared/player_dropitem.lua new file mode 100644 index 0000000..717e1b5 --- /dev/null +++ b/gamemode/shared/player_dropitem.lua @@ -0,0 +1,26 @@ +
+local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("DropItemReq")
+
+ function meta:DropItem(item,bAccount)
+ if ((!bAccount and !self:HasItem(item)) or (bAccount and !self:HasAccountItem(item))) then return end
+
+ if (bAccount) then self:RemoveAccountItem(item,1) return
+ else self:RemoveItem(item,1) end
+
+ SpawnWSItem(item,self:GetShootPos()+self:GetAimVector()*20)
+ end
+
+ net.Receive("DropItemReq",function(seq,pl) pl:DropItem(net.ReadString(),util.tobool(net.ReadBit())) end)
+else
+ function RequestDropItem(item,bAccount)
+ net.Start("DropItemReq")
+ net.WriteString(item)
+ net.WriteBit(bAccount)
+ net.SendToServer()
+ end
+end
+
+
\ No newline at end of file diff --git a/gamemode/shared/player_ghost.lua b/gamemode/shared/player_ghost.lua new file mode 100644 index 0000000..049ede7 --- /dev/null +++ b/gamemode/shared/player_ghost.lua @@ -0,0 +1,97 @@ +local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("Ghost")
+ util.AddNetworkString("GhostRemove")
+
+ function meta:GhostStructure(item)
+ item = GetItemByName(item)
+
+ if (!item or !item.Ghost) then return end
+ if (!self.StructurePlace) then self.StructurePlace = true end
+
+ net.Start("Ghost")
+ net.WriteString(item.Name)
+ net.Send(self)
+ end
+
+ function meta:GhostRemove()
+ self.StructurePlace = false
+ net.Start("GhostRemove") net.Send(self)
+ end
+else
+ local Zero = Vector(0,0,0)
+ local gr = Color(0,255,0,100)
+ local Box = Vector(8,8,8)
+
+ net.Receive("Ghost",function()
+ local pl = LocalPlayer()
+ local It = GetItemByName(net.ReadString())
+
+ if (!It) then return end
+ if (!IsValid(pl.Ghost)) then pl.Ghost = ClientsideModel("error.mdl") pl.Ghost:SetNoDraw(true) end
+
+ pl.GhostItem = It
+ pl.StructurePlace = true
+ end)
+
+ net.Receive("GhostRemove",function() LocalPlayer().StructurePlace = false end)
+
+ hook.Add("PostDrawTranslucentRenderables","GhostStructure",function()
+ local pl = LocalPlayer()
+
+ if (pl:IsPigeon() or !pl.GhostItem or !pl.GhostItem.Ghost or !IsValid(pl.Ghost) or !pl.StructurePlace) then return end
+
+ local Ghost = pl.Ghost
+ local Aim = Angle(0,pl:GetAimVector():Angle().y+90,0)
+ local Pos = util.TraceHull({
+ start = pl:GetShootPos(),
+ endpos = pl:GetShootPos()+pl:GetAimVector()*pl.GhostItem.Range,
+ filter = pl,
+ mins = Box*-1,
+ maxs = Box,
+ })
+
+ local CanP = pl:CanPlaceStructure(Pos)
+ Pos = Pos.HitPos
+
+ for k,v in pairs(pl.GhostItem.Ghost) do
+ local OffPos = v.Pos*1
+ OffPos:Rotate(Aim)
+
+ Ghost:SetModel(v.Model)
+ Ghost:SetRenderOrigin(Pos+OffPos)
+ Ghost:SetRenderAngles(v.Ang+Aim)
+
+ local mat = Matrix()
+ mat:Scale( v.Size or Zero )
+
+ Ghost:EnableMatrix( "RenderMultiply", mat )
+ Ghost:SetupBones()
+
+ if (CanP) then render.SetColorModulation(0,10,0)
+ else render.SetColorModulation(10,0,0) end
+
+ render.SetBlend(0.7)
+ Ghost:DrawModel()
+ render.SetColorModulation(1,1,1)
+ render.SetBlend(1)
+ end
+
+ Ghost:SetRenderOrigin(Pos)
+ end)
+end
+
+function meta:CanPlaceStructure(Tr)
+ if (Tr and Tr.HitPos) then
+ local A = util.PointContents( Tr.HitPos )
+ local Ang = math.AngleNormalize(Tr.HitNormal:Angle())
+
+ if (A == CONTENTS_WATER or A == CONTENTS_WATER+CONTENTS_TRANSLUCENT ) then return false end
+ if (Ang.p < -120 or Ang.p > -60) then return false end
+
+ --if (!Tr.HitWorld) then return false end
+ end
+
+ return self.StructurePlace
+end
diff --git a/gamemode/shared/player_human.lua b/gamemode/shared/player_human.lua new file mode 100644 index 0000000..8fa6997 --- /dev/null +++ b/gamemode/shared/player_human.lua @@ -0,0 +1,66 @@ +
+local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("SetHuman")
+
+ function meta:SetHuman(bool)
+ self.IsHuman = bool
+ self.Inventory = {}
+ self.Weapons = {}
+
+ net.Start("SetHuman")
+ net.WriteEntity(self)
+ net.WriteBit(self.IsHuman)
+ net.Broadcast()
+ end
+
+ function meta:UpdateHumans()
+ for k,v in pairs(player.GetAll()) do
+ if (v.IsHuman) then
+ timer.Simple(math.Rand(0.1,0.2),function()
+ net.Start("SetHuman")
+ net.WriteEntity(v)
+ net.WriteBit(true)
+ net.Send(self)
+ end)
+ end
+ end
+ end
+else
+ net.Receive("SetHuman",function()
+ local pl = net.ReadEntity()
+
+ pl.IsHuman = util.tobool(net.ReadBit())
+ pl.Inventory = {}
+ pl.Weapons = {}
+ end)
+end
+
+function meta:IsPigeon()
+ return !util.tobool(self.IsHuman)
+end
+
+function player.GetAllHumans()
+ local dat = {}
+
+ for k,v in pairs(player.GetAll()) do
+ if (!v:IsPigeon()) then
+ table.insert(dat,v)
+ end
+ end
+
+ return dat
+end
+
+function player.GetAllHumansAlive()
+ local dat = {}
+
+ for k,v in pairs(player.GetAll()) do
+ if (!v:IsPigeon() and v:Alive()) then
+ table.insert(dat,v)
+ end
+ end
+
+ return dat
+end
diff --git a/gamemode/shared/player_inventory.lua b/gamemode/shared/player_inventory.lua new file mode 100644 index 0000000..8cb31ea --- /dev/null +++ b/gamemode/shared/player_inventory.lua @@ -0,0 +1,99 @@ +
+local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("UpdateInventory")
+
+ function meta:UpdateSlot(id)
+ if (!self.Inventory[id]) then return end
+
+ net.Start("UpdateInventory")
+ net.WriteUInt(id,5)
+ net.WriteString(self.Inventory[id].Name)
+ net.WriteUInt(self.Inventory[id].Quantity,32)
+ net.Send(self)
+ end
+
+ function meta:AddItem(item,quantity)
+ local Item = GetItemByName(item)
+
+ if (!Item) then return end
+ if (!self.Inventory) then self.Inventory = {} end
+
+ --First search for existing items
+ for i = 1,MAIN_MAX_SLOTS do
+ if (self.Inventory[i] and self.Inventory[i].Name == item) then
+ self.Inventory[i].Quantity = self.Inventory[i].Quantity+quantity
+ self:UpdateSlot(i)
+ return
+ end
+ end
+
+ --If it hasnt found any existing item, find an empty spot
+ for i = 1,MAIN_MAX_SLOTS do
+ if (!self.Inventory[i]) then
+ self.Inventory[i] = {Name = item,Quantity = quantity}
+ self:UpdateSlot(i)
+ return
+ end
+ end
+ end
+
+ function meta:RemoveItem(item,quantity)
+ for i = 1,MAIN_MAX_SLOTS do
+ if (self.Inventory[i] and self.Inventory[i].Name == item) then
+ if (self.Inventory[i].Quantity > quantity) then
+ self.Inventory[i].Quantity = self.Inventory[i].Quantity-quantity
+ self:UpdateSlot(i)
+ return
+ else
+ quantity = quantity - self.Inventory[i].Quantity
+
+ self.Inventory[i].Quantity = 0
+
+ self:UpdateSlot(i)
+
+ self.Inventory[i] = nil
+
+ if (quantity > 0) then self:RemoveItem(item,quantity) return end
+ end
+ end
+ end
+ end
+else
+ net.Receive("UpdateInventory",function()
+ local pl = LocalPlayer()
+
+ if (!pl.Inventory) then pl.Inventory = {} end
+
+ local ID = net.ReadUInt(5)
+ pl.Inventory[ID] = {Name = net.ReadString(),Quantity = net.ReadUInt(32)}
+
+ if (pl.Inventory[ID].Quantity <= 0) then pl.Inventory[ID] = nil end
+
+ ReloadInventory()
+ end)
+end
+
+
+function meta:GetInventory()
+ return self.Inventory or {}
+end
+
+function meta:HasItem(name,quantity)
+ if (!self.Inventory) then return end
+
+ quantity = quantity or 1
+
+ for k,v in pairs(self.Inventory) do
+ if (v.Name == name and v.Quantity >= quantity) then
+ return k
+ end
+ end
+
+ return false
+end
+
+function meta:GetSlot(id)
+ return (self.Inventory and self.Inventory[id]) or nil
+end
\ No newline at end of file diff --git a/gamemode/shared/player_lootventory.lua b/gamemode/shared/player_lootventory.lua new file mode 100644 index 0000000..b973932 --- /dev/null +++ b/gamemode/shared/player_lootventory.lua @@ -0,0 +1,53 @@ +local insert = table.insert
+
+if (SERVER) then
+ util.AddNetworkString("OpenLootventory")
+ util.AddNetworkString("DemandLootventoryUpdate")
+
+ function OpenLootventory(pl,items,entity)
+ if (!IsValid(pl) or !items) then return end
+
+ net.Start("OpenLootventory")
+ net.WriteEntity(entity)
+ for k,v in pairs(items) do
+ if (v.Name and v.Quantity) then
+ net.WriteBit(true)
+ net.WriteString(v.Name)
+ net.WriteUInt(v.Quantity,32)
+ end
+ end
+ net.Send(pl)
+ end
+
+ net.Receive("DemandLootventoryUpdate",function(siz,pl)
+ local ent = net.ReadEntity()
+
+ if (!IsValid(ent) or !ent.GetItems) then return end
+ if (pl:GetPos():Distance(ent:GetPos()) > 200) then return end
+
+ OpenLootventory(pl,ent:GetItems(),ent)
+ end)
+else
+ net.Receive("OpenLootventory",function()
+ local dat = {}
+ local ent = net.ReadEntity()
+
+ while (util.tobool(net.ReadBit())) do
+ local Ab = GetItemByName(net.ReadString())
+ local Co = net.ReadUInt(32)
+
+ if (Ab and Co > 0) then insert(dat,{Name = Ab.Name, Quantity = Co}) end
+ end
+
+ MakeLootventory(dat,ent)
+ GAMEMODE:OnSpawnMenuOpen()
+ end)
+
+ function DemandLootventoryUpdate(entity)
+ if (!IsLootventoryOpen()) then return end
+
+ net.Start("DemandLootventoryUpdate")
+ net.WriteEntity(entity)
+ net.SendToServer()
+ end
+end
\ No newline at end of file diff --git a/gamemode/shared/player_pigeon.lua b/gamemode/shared/player_pigeon.lua new file mode 100644 index 0000000..2256af0 --- /dev/null +++ b/gamemode/shared/player_pigeon.lua @@ -0,0 +1,44 @@ +local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("AssignPigeon")
+
+ function meta:SpawnPigeon()
+ if (IsValid(self.Pigeon)) then return end
+
+ self.Pigeon = ents.Create("ws_pigeon")
+ self.Pigeon:SetPos(self:GetPos())
+ self.Pigeon:SetPlayer(self)
+ self.Pigeon:Spawn()
+ self.Pigeon:Activate()
+
+ print("Spawned Pigeon: "..self:Nick())
+
+ timer.Simple(0.2,function()
+ net.Start("AssignPigeon")
+ net.WriteEntity(self)
+ net.WriteEntity(self.Pigeon)
+ net.Broadcast() end)
+ end
+
+ function meta:UpdatePigeons()
+ for k,v in pairs(player.GetAll()) do
+ if (IsValid(v.Pigeon)) then
+ timer.Simple(math.Rand(0.1,0.2),function()
+ net.Start("AssignPigeon")
+ net.WriteEntity(v)
+ net.WriteEntity(v.Pigeon)
+ net.Send(self)
+ end)
+ end
+ end
+ end
+else
+ net.Receive("AssignPigeon",function() net.ReadEntity().Pigeon = net.ReadEntity() end)
+end
+
+function meta:GetPigeon()
+ return self.Pigeon
+end
+
+
diff --git a/gamemode/shared/player_recipes.lua b/gamemode/shared/player_recipes.lua new file mode 100644 index 0000000..4a85535 --- /dev/null +++ b/gamemode/shared/player_recipes.lua @@ -0,0 +1,102 @@ +
+local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("CreateRecipe")
+ util.AddNetworkString("ResetRecipes")
+
+ function meta:CreateRecipe(item)
+ if (!self:CanCreateItem(item)) then return end
+
+ local Rec,Item = GetRecipeForItem(item)
+
+ if (!Rec) then return false end
+
+ for a,b in pairs(Rec.Resources) do
+ self:RemoveItem(a,b)
+ end
+
+ if(Item.OnCraft) then
+ Item:OnCraft(self)
+ end
+
+ self:AddItem(item,1)
+ end
+
+ function meta:ResetKnownRecipes()
+ net.Start("ResetRecipes") net.Send(self)
+ end
+
+ net.Receive("CreateRecipe",function(siz,pl) pl:CreateRecipe(net.ReadString()) end)
+else
+ function RequestCreateRecipe(item)
+ net.Start("CreateRecipe")
+ net.WriteString(item)
+ net.SendToServer()
+ end
+
+ function DiscoverItems(Combinations)
+ local Dat = {}
+
+ for k,v in pairs(GAMEMODE.Recipes) do
+ local Ab = v.Recipe.Resources
+ local Tools = v.Recipe.Tools
+ local PA = table.Count(Ab)
+
+ if (PA == table.Count(Combinations)) then
+ local Check = 0
+
+ for e,c in pairs(Combinations) do
+ for a,b in pairs(Ab) do
+ if (c.Name == a and c.Quantity == b) then Check = Check+1 break end
+ end
+ end
+
+ if (Check == PA) then table.insert(Dat,v) end
+ end
+ end
+
+ if (table.Count(Dat) > 0) then
+ for e,c in pairs(GAMEMODE.KnownRecipes) do
+ for k,v in pairs(Dat) do
+ if (v.Name == c.Name) then table.remove(Dat,k) break end
+ end
+ end
+
+ if (table.Count(Dat) > 0) then
+ for k,v in pairs(Dat) do
+ LocalPlayer():AddNote("You discovered the recipe for "..v.Name)
+ end
+
+ table.Add(GAMEMODE.KnownRecipes,Dat)
+
+ ReloadRecipes()
+ end
+ end
+ end
+
+ net.Receive("ResetRecipes",function()
+ GAMEMODE.KnownRecipes = {
+ GetItemByName("Axe"),
+ GetItemByName("Campfire"),
+ GetItemByName("Pickaxe"),
+ GetItemByName("Research Table")
+ }
+
+ ReloadRecipes()
+ end)
+end
+
+function meta:CanCreateItem(name)
+ local Rec,Item = GetRecipeForItem(name)
+
+ if (!Rec) then return false end
+
+ for k,v in pairs(Rec) do
+ for a,b in pairs(v) do
+ if (!self:HasItem(a,b)) then return false end
+ end
+ end
+
+ return true
+end
diff --git a/gamemode/shared/player_transferitem.lua b/gamemode/shared/player_transferitem.lua new file mode 100644 index 0000000..944af63 --- /dev/null +++ b/gamemode/shared/player_transferitem.lua @@ -0,0 +1,44 @@ +
+if (SERVER) then
+ util.AddNetworkString("RequestTransfer")
+ util.AddNetworkString("RequestTransferFrom")
+
+ net.Receive("RequestTransfer",function(siz,pl)
+ local item = net.ReadString()
+ local quan = net.ReadUInt(32)
+ local ent = net.ReadEntity()
+
+ if (!IsValid(ent) or !ent.AddItem) then return end
+
+ if (!pl:HasItem(item,quan)) then return end
+
+ pl:RemoveItem(item,quan)
+ ent:AddItem(item,quan)
+ end)
+
+ net.Receive("RequestTransferFrom",function(siz,pl)
+ local item = net.ReadString()
+ local quan = net.ReadUInt(32)
+ local ent = net.ReadEntity()
+
+ if (!IsValid(ent) or !ent.TakeItem) then return end
+
+ ent:TakeItem(pl,item,quan)
+ end)
+else
+ function TransferItems(item,quantity,to)
+ net.Start("RequestTransfer")
+ net.WriteString(item)
+ net.WriteUInt(quantity,32)
+ net.WriteEntity(to)
+ net.SendToServer()
+ end
+
+ function DemandItems(item,quantity,from)
+ net.Start("RequestTransferFrom")
+ net.WriteString(item)
+ net.WriteUInt(quantity,32)
+ net.WriteEntity(from)
+ net.SendToServer()
+ end
+end
\ No newline at end of file diff --git a/gamemode/shared/player_useitem.lua b/gamemode/shared/player_useitem.lua new file mode 100644 index 0000000..128146a --- /dev/null +++ b/gamemode/shared/player_useitem.lua @@ -0,0 +1,40 @@ +
+local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("UseItem")
+ util.AddNetworkString("UseItemReq")
+
+ function meta:UseItem(item,bAccount)
+ if ((!bAccount and !self:HasItem(item)) or (bAccount and !self:HasAccountItem(item))) then return end
+
+ local IT = GetItemByName(item)
+
+ if (IT.OnUse) then
+ IT:OnUse(self)
+
+ net.Start("UseItem")
+ net.WriteEntity(self)
+ net.WriteString(item)
+ net.Broadcast()
+ end
+ end
+
+ net.Receive("UseItemReq",function(seq,pl) pl:UseItem(net.ReadString(),util.tobool(net.ReadBit())) end)
+else
+ net.Receive("UseItem",function()
+ local pl = net.ReadEntity()
+ local it = GetItemByName(net.ReadString())
+
+ if (it.OnUse) then it:OnUse(pl) end
+ end)
+
+ function RequestUseItem(item,bAccount)
+ net.Start("UseItemReq")
+ net.WriteString(item)
+ net.WriteBit(bAccount)
+ net.SendToServer()
+ end
+end
+
+
\ No newline at end of file diff --git a/gamemode/shared/stream.lua b/gamemode/shared/stream.lua new file mode 100644 index 0000000..e4d45e8 --- /dev/null +++ b/gamemode/shared/stream.lua @@ -0,0 +1,125 @@ +local meta = FindMetaTable("Player") + +if (SERVER) then + util.AddNetworkString("STREAM") + util.AddNetworkString("ENDSTREAM") + + concommand.Add("StreamURL",function(pl,com,args) + if (!IsValid(pl)) then return end + + pl:StreamSong(table.concat(args," ")) + end) + + concommand.Add("EndStream",function(pl,com,args) + if (!IsValid(pl)) then return end + + pl:EndStream() + end) + + function meta:StreamSong(URL) + if (!self:IsAdmin()) then return end + + self.URL = URL + + net.Start("STREAM") + net.WriteEntity(self) + net.WriteString(URL) + net.Broadcast() + end + + function meta:EndStream() + if (!self:IsAdmin()) then return end + + self.URL = nil + + net.Start("ENDSTREAM") + net.WriteEntity(self) + net.Broadcast() + end + + function meta:UpdateStream(v) + if (v.URL) then + net.Start("STREAM") + net.WriteEntity(v) + net.WriteString(v.URL) + net.Send(self) + end + end +else + local Emitter = ParticleEmitter( Vector(0,0,0) ) + local Up = Vector(0,0,20) + local Retries = 0 + local Streams = {} + + function TryURL(url,pl) + if (!IsValid(pl)) then return end + + local ID = pl:UniqueID() + if (Streams[ID]) then Streams[ID]:Stop() Streams[ID] = nil end + + if (Retries < 4) then + sound.PlayURL( url, "3d mono noplay", function( chan ) + if (!chan) then TryURL(url,pl) Retries = Retries+1 + elseif (IsValid(pl)) then Streams[ID] = chan chan:Play() Retries = 0 end + end) + else + Retries = 0 + Msg("Couldn't play "..url.." \n") + end + end + + net.Receive("STREAM",function() + local pl = net.ReadEntity() + local URL = net.ReadString() + + if (!IsValid(pl)) then return end + + TryURL(URL,pl) + end) + + net.Receive("ENDSTREAM",function() + local pl = net.ReadEntity() + + if (!IsValid(pl)) then return end + + local ID = pl:UniqueID() + if (Streams[ID]) then Streams[ID]:Stop() Streams[ID] = nil end + end) + + hook.Add("Think","Streamer",function() + for k,st in pairs(Streams) do + if (!st) then table.remove(Streams,k) + else + local v = player.GetByUniqueID(k) + + if (!IsValid(v)) then + st:Stop() + table.remove(Streams,k) + else + local pig = v:GetPigeon() + local Pos = v:GetPos() + + if (IsValid(pig)) then Pos = pig:GetPos() end + + if (!v.PTime or v.PTime < CurTime()) then + local particle = Emitter:Add( "lam/musicnotes/note"..math.random(1,2), Pos + VectorRand()*15) + particle:SetDieTime( 1 ) + particle:SetVelocity( Up ) + + particle:SetStartAlpha( 250 ) + particle:SetEndAlpha( 0 ) + + particle:SetStartSize( 10 ) + particle:SetEndSize( 10 ) + + particle:SetColor( math.random( 0, 250 ), math.random( 0, 250 ), math.random( 0, 250 ) ) + + v.PTime = CurTime()+0.1 + end + + st:SetPos(Pos) + end + end + end + end) +end
\ No newline at end of file diff --git a/gamemode/shared/synchronize.lua b/gamemode/shared/synchronize.lua new file mode 100644 index 0000000..126c616 --- /dev/null +++ b/gamemode/shared/synchronize.lua @@ -0,0 +1,22 @@ +
+if (SERVER) then
+ util.AddNetworkString("LoadEntity_WS")
+
+ net.Receive("LoadEntity_WS",function(siz,pl)
+ local Ab = net.ReadEntity()
+
+ if (Ab:IsPlayer()) then
+ Ab:UpdateSelection(pl)
+ --pl:UpdateStream(Ab)
+ end
+ end)
+else
+ local Q = 0
+ function GM:NetworkEntityCreated(ent)
+ Q=Q+1
+ timer.Simple(math.Rand(0.1,0.2)*Q,function()
+ net.Start("LoadEntity_WS") net.WriteEntity(ent) net.SendToServer()
+ Q=Q-1
+ end)
+ end
+end
\ No newline at end of file diff --git a/gamemode/shared/system_admin.lua b/gamemode/shared/system_admin.lua new file mode 100644 index 0000000..14dfb3d --- /dev/null +++ b/gamemode/shared/system_admin.lua @@ -0,0 +1,118 @@ +
+
+local meta = FindMetaTable("Player")
+local Banlist = {}
+
+local insert = table.insert
+
+if (SERVER) then
+ hook.Add("InitPostEntity","InitBanlist",function()
+ if (!sql.TableExists("Banlist")) then
+ local Dat = {
+ "id INTEGER PRIMARY KEY",
+ "steamid TEXT",
+ "time INT",
+ "name TEXT",
+ "reason TEXT",
+ }
+
+ Msg("No banlist was found.\nCreating new banlist!\n")
+ sql.Query("CREATE TABLE IF NOT EXISTS Banlist ("..table.concat(Dat,",")..");")
+ else
+ local dat = sql.Query("SELECT * FROM Banlist")
+
+ if (dat) then
+ for k,v in pairs(dat) do insert(Banlist,v.steamid) end
+ end
+ end
+ end)
+
+ hook.Add("CheckPassword","BlockBannedPlayers",function(SteamID64,NetworkID,ServerPassword,Password,Name)
+ if (table.HasValue(Banlist,util.SteamIDFrom64(SteamID64))) then
+ print(Name.." attempted to join, but was found in the banlist. Blocking access!")
+
+ return false, "You are banned from this server!"
+ end
+ end)
+
+ concommand.Add("mas_bansteamid",function(pl,com,arg)
+ if (!IsValid(pl) or !pl:IsAdmin()) then return end
+ if (!arg[3]) then return end
+
+ local steamid = arg[1]
+ local time = tonumber(arg[2] or 0)
+ local reason = table.concat(arg," ",3)
+
+ local dat = sql.Query("SELECT * FROM Banlist WHERE steamid="..SQLStr(steamid))
+
+ if (!dat) then
+ sql.Query("INSERT INTO Banlist(steamid,time,name,reason) VALUES ("..SQLStr(steamid)..","..time..",'Unknown',"..SQLStr(reason)..")")
+ insert(Banlist,steamid)
+
+ for k,v in pairs(player.GetAll()) do
+ if (v:SteamID() == steamid) then
+ v:Kick("Banned from server: "..reason)
+ end
+
+ v:ChatPrint(pl:Nick().." has banned "..steamid)
+ end
+
+ MsgN(pl:Nick().." has banned "..steamid)
+ else
+ MsgN(steamid.." was already located in the database.")
+ end
+ end)
+
+ concommand.Add("mas_unbansteamid",function(pl,com,arg)
+ if (!IsValid(pl) or !pl:IsAdmin()) then return end
+ if (!arg[1]) then return end
+
+ local dat = sql.Query("DELETE * FROM Banlist WHERE steamid="..SQLStr(arg[1]))
+
+ if (dat) then
+ MsgN(pl:Nick().." has unbanned "..arg[1])
+
+ for k,v in pairs(Banlist) do
+ if (v == arg[1]) then
+ table.remove(Banlist,k)
+ break
+ end
+ end
+ end
+ end)
+
+ concommand.Add("mas_printbannedplayers",function(pl,com,arg)
+ if (!IsValid(pl) or !pl:IsAdmin()) then return end
+
+ local dat = sql.Query("SELECT * FROM Banlist")
+
+ if (dat) then
+ for k,v in pairs(dat) do
+ pl:ChatPrint(v.steamid.." - "..v.name)
+ end
+ end
+ end)
+
+ concommand.Add("mas_banplayer",function(pl,com,arg)
+ if (!IsValid(pl) or !pl:IsAdmin()) then return end
+ if (!arg[3]) then return end
+
+ local name = arg[1]
+ local time = tonumber(arg[2] or 0)
+ local reason = table.concat(arg," ",3)
+
+ for k,v in pairs(player.GetAll()) do
+ if (v:Nick():lower():find(name:lower())) then
+ local dat = sql.Query("SELECT * FROM Banlist WHERE steamid="..SQLStr(v:SteamID()))
+
+ if (!dat) then
+ sql.Query("INSERT INTO Banlist(steamid,time,name,reason) VALUES ("..SQLStr(v:SteamID())..","..time..","..SQLStr(v:Nick())..","..SQLStr(reason)..")")
+ insert(Banlist,v:SteamID())
+ v:Kick("Banned from server: "..reason)
+ break
+ end
+ end
+ end
+ end)
+else
+end
\ No newline at end of file diff --git a/gamemode/shared/system_fatigue.lua b/gamemode/shared/system_fatigue.lua new file mode 100644 index 0000000..9f5a413 --- /dev/null +++ b/gamemode/shared/system_fatigue.lua @@ -0,0 +1,46 @@ +
+local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("SetFatigue")
+
+ local Tick = CurTime()
+
+ function meta:SetFatigue(s)
+ if (s > 100) then self:TakeDamage(s-100) s = 100 end
+ s = math.Clamp(s,0,100)
+
+ self.Fatigue = s
+
+ net.Start("SetFatigue")
+ net.WriteUInt(s,8)
+ net.Send(self)
+ end
+
+ function meta:AddFatigue(s)
+ self:SetFatigue(self:GetFatigue()+s)
+ end
+
+ hook.Add("Tick","Fatigue",function()
+ if (Tick < CurTime()) then
+ for k,v in pairs(player.GetAllHumans()) do
+ local Fat = v.Fatigue or 0
+
+ if (Fat > 0) then Fat = Fat-2 end
+ Fat = Fat+math.ceil(v:GetVelocity():Length()/100)
+
+ v:SetFatigue(Fat)
+ end
+
+ Tick = CurTime()+0.5
+ end
+ end)
+else
+ net.Receive("SetFatigue",function()
+ LocalPlayer().Fatigue = net.ReadUInt(8)
+ end)
+end
+
+function meta:GetFatigue()
+ return self.Fatigue or 0
+end
diff --git a/gamemode/shared/system_heat.lua b/gamemode/shared/system_heat.lua new file mode 100644 index 0000000..84c9c30 --- /dev/null +++ b/gamemode/shared/system_heat.lua @@ -0,0 +1,42 @@ +
+local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("SetHeat")
+
+ local Tick = CurTime()
+
+ function meta:SetHeat(s)
+ if (s > 100) then self:TakeDamage(s-100) s = 100 end
+ s = math.Clamp(s,0,100)
+
+ self.Heat = s
+
+ net.Start("SetHeat")
+ net.WriteUInt(s,8)
+ net.Send(self)
+ end
+
+ function meta:AddHeat(s)
+ self:SetHeat(self:GetHeat()+s)
+ end
+
+ hook.Add("Tick","Heat",function()
+ if (Tick < CurTime()) then
+ for k,v in pairs(player.GetAllHumans()) do
+ v:AddHeat(1+v:WaterLevel())
+ end
+
+ Tick = CurTime()+1.5
+ end
+ end)
+else
+ net.Receive("SetHeat",function()
+ LocalPlayer().Heat = net.ReadUInt(8)
+ end)
+end
+
+function meta:GetHeat()
+ return self.Heat or 0
+end
+
\ No newline at end of file diff --git a/gamemode/shared/system_hunger.lua b/gamemode/shared/system_hunger.lua new file mode 100644 index 0000000..99128b1 --- /dev/null +++ b/gamemode/shared/system_hunger.lua @@ -0,0 +1,42 @@ +
+local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("SetHunger")
+
+ local Tick = CurTime()
+
+ function meta:SetHunger(s)
+ if (s > 100) then self:TakeDamage(s-100) s = 100 end
+ s = math.Clamp(s,0,100)
+
+ self.Hunger = s
+
+ net.Start("SetHunger")
+ net.WriteUInt(s,8)
+ net.Send(self)
+ end
+
+ function meta:AddHunger(s)
+ self:SetHunger(self:GetHunger()+s)
+ end
+
+ hook.Add("Tick","Hunger",function()
+ if (Tick < CurTime()) then
+ for k,v in pairs(player.GetAllHumans()) do
+ v:AddHunger(1)
+ end
+
+ Tick = CurTime()+10
+ end
+ end)
+else
+ net.Receive("SetHunger",function()
+ LocalPlayer().Hunger = net.ReadUInt(8)
+ end)
+end
+
+function meta:GetHunger()
+ return self.Hunger or 0
+end
+
\ No newline at end of file diff --git a/gamemode/shared/system_water.lua b/gamemode/shared/system_water.lua new file mode 100644 index 0000000..f55dd53 --- /dev/null +++ b/gamemode/shared/system_water.lua @@ -0,0 +1,53 @@ +
+local meta = FindMetaTable("Player")
+
+if (SERVER) then
+ util.AddNetworkString("SetWater")
+
+ local Tick = CurTime()
+
+ function meta:SetWater(s)
+ if (s > 100) then self:TakeDamage(s-100) s = 100 end
+ s = math.Clamp(s,0,100)
+
+ self.Water = s
+
+ net.Start("SetWater")
+ net.WriteUInt(s,8)
+ net.Send(self)
+ end
+
+ function meta:AddWater(s)
+ self:SetWater(self:GetWater()+s)
+ end
+
+ hook.Add("Tick","Water",function()
+ if (Tick < CurTime()) then
+ for k,v in pairs(player.GetAllHumans()) do
+ v:AddWater(1)
+ end
+
+ Tick = CurTime()+3.5
+ end
+ end)
+
+ hook.Add("KeyPress","FindWater",function(pl,key)
+ if (key == IN_USE) then
+ local tr = util.TraceLine({start=pl:GetShootPos(),endpos=pl:GetShootPos()+pl:GetAimVector()*200,filter=pl})
+ local A = util.PointContents( tr.HitPos )
+
+ if (A == CONTENTS_WATER or A == CONTENTS_WATER+CONTENTS_TRANSLUCENT ) then
+ pl:AddWater(-20)
+ end
+ end
+ end)
+else
+ net.Receive("SetWater",function()
+ LocalPlayer().Water = net.ReadUInt(8)
+ end)
+end
+
+function meta:GetWater()
+ return self.Water or 0
+end
+
\ No newline at end of file diff --git a/gamemode/shared/vars.lua b/gamemode/shared/vars.lua new file mode 100644 index 0000000..e605816 --- /dev/null +++ b/gamemode/shared/vars.lua @@ -0,0 +1,3 @@ +MAIN_PVPTIMER = 300
+
+MAIN_MAX_SLOTS = 30
\ No newline at end of file diff --git a/gamemode/shared/weaponswap.lua b/gamemode/shared/weaponswap.lua new file mode 100644 index 0000000..f6e0a5c --- /dev/null +++ b/gamemode/shared/weaponswap.lua @@ -0,0 +1,168 @@ +
+local meta = FindMetaTable("Player")
+
+if (CLIENT) then
+ local Num = 0
+ local STi = CurTime()
+
+ hook.Add("PlayerBindPress","SwapWeapons",function(pl,bind,pressed)
+ if (LocalPlayer():IsPigeon()) then
+ if (bind:find("invprev")) then return true
+ elseif (bind:find("invnext")) then return true end
+ end
+
+ if (pressed) then
+ local Wep = pl:GetActiveWeapon()
+
+ if (bind:find("invprev")) then
+ Num = Num+1
+ STi = CurTime()
+
+ if (Num > 9) then Num = 0 end
+
+ net.Start("Select") net.WriteUInt(Num,4) net.SendToServer()
+
+ surface.PlaySound("wintersurvival2/hud/itemequip.wav")
+
+ if (IsValid(Wep)) then
+ if (pl.Weapons and pl.Weapons[Num]) then Wep:SetWeaponHoldType(pl.Weapons[Num].Item.HoldType)
+ else Wep:SetWeaponHoldType("normal") end
+ end
+
+ return true
+ elseif (bind:find("invnext")) then
+ Num = Num-1
+ STi = CurTime()
+
+ if (Num < 0) then Num = 9 end
+
+ net.Start("Select") net.WriteUInt(Num,4) net.SendToServer()
+
+ surface.PlaySound("wintersurvival2/hud/itemequip.wav")
+
+ if (IsValid(Wep)) then
+ if (pl.Weapons and pl.Weapons[Num]) then Wep:SetWeaponHoldType(pl.Weapons[Num].Item.HoldType)
+ else Wep:SetWeaponHoldType("normal") end
+ end
+
+ return true
+ end
+ end
+ end)
+
+ function GetWeaponSlot()
+ return Num
+ end
+
+ function GetRecentSwapTime()
+ return STi
+ end
+
+ net.Receive("ReceiveSelect",function()
+ local pl = net.ReadEntity()
+ if (!IsValid(pl)) then return end
+
+ pl.Select = net.ReadUInt(4)
+ local wep = pl:GetActiveWeapon()
+
+ if (!IsValid(wep)) then return end
+
+ if (pl.Weapons and pl.Weapons[pl.Select]) then wep:SetWeaponHoldType(pl.Weapons[pl.Select].Item.HoldType)
+ else wep:SetWeaponHoldType("normal") end
+ end)
+
+ net.Receive("SetSlot",function()
+ local pl = net.ReadEntity()
+
+ if (!IsValid(pl)) then return end
+ if (!pl.Weapons) then pl.Weapons = {} end
+
+ local id = net.ReadUInt(5)
+ local na = net.ReadString()
+ local A = GetItemByName(na)
+
+ if (A) then pl.Weapons[id] = {Name = na,Item = A}
+ else pl.Weapons[id] = nil end
+
+ pl:EmitSound("wintersurvival2/hud/itemequip.wav")
+ end)
+
+ function RequestEquip(id,item)
+ net.Start("SetSlotReq")
+ net.WriteUInt(id,5)
+ net.WriteString(item)
+ net.SendToServer()
+ end
+
+ function RequestUnEquip(id)
+ net.Start("SetSlotReqUn")
+ net.WriteUInt(id,5)
+ net.SendToServer()
+ end
+
+ function EraseSlot(id)
+ net.Start("EraseSlot")
+ net.WriteUInt(id,5)
+ net.SendToServer()
+ end
+else
+ util.AddNetworkString("Select")
+ util.AddNetworkString("ReceiveSelect")
+ util.AddNetworkString("SetSlot")
+ util.AddNetworkString("SetSlotReq")
+ util.AddNetworkString("SetSlotReqUn")
+ util.AddNetworkString("EraseSlot")
+
+ net.Receive("Select",function(siz,pl) pl.Select = net.ReadUInt(4) pl:UpdateSelection() end)
+ net.Receive("SetSlotReq",function(siz,pl) pl:SetWeaponSlot(net.ReadUInt(5),net.ReadString()) end)
+ net.Receive("SetSlotReqUn",function(siz,pl) pl:UnEquipWeaponSlot(net.ReadUInt(5)) end)
+ net.Receive("EraseSlot",function(siz,pl) pl:UnEquipWeaponSlot(net.ReadUInt(5),true) end)
+
+ function meta:UpdateSelection(pl)
+ if (self.Select) then
+ net.Start("ReceiveSelect")
+ net.WriteEntity(self)
+ net.WriteUInt(self.Select,4)
+ if (IsValid(pl)) then net.Send(pl)
+ else net.Broadcast() end
+ end
+
+ if (self:CanPlaceStructure()) then self:GhostRemove() end
+ end
+
+ function meta:SetWeaponSlot(id,item)
+ if (!self:HasItem(item)) then return end
+ if (!self.Weapons) then self.Weapons = {} end
+
+ self:RemoveItem(item,1)
+
+ local A = GetItemByName(item)
+
+ if (self.Weapons[id]) then self:AddItem(self.Weapons[id].Name,1) end
+
+ self.Weapons[id] = {Name = item,Item = A}
+
+ net.Start("SetSlot")
+ net.WriteEntity(self)
+ net.WriteUInt(id,5)
+ net.WriteString(item)
+ net.Broadcast()
+ end
+
+ function meta:UnEquipWeaponSlot(id,bErase)
+ if (!self.Weapons or !self.Weapons[id]) then return end
+
+ if (!bErase) then self:AddItem(self.Weapons[id].Name,1) end
+
+ self.Weapons[id] = nil
+
+ net.Start("SetSlot")
+ net.WriteEntity(self)
+ net.WriteUInt(id,5)
+ net.Broadcast()
+ end
+end
+
+function meta:GetSelectedWeapon()
+ return self.Select or 0
+end
\ No newline at end of file |
