aboutsummaryrefslogtreecommitdiff
path: root/gamemode
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode')
-rw-r--r--gamemode/autolua.lua30
-rw-r--r--gamemode/client/cl_inventory.lua238
-rw-r--r--gamemode/client/cl_npcmap.lua24
-rw-r--r--gamemode/client/cl_pac.lua2
-rw-r--r--gamemode/client/healthbar.lua107
-rw-r--r--gamemode/init.lua2
-rw-r--r--gamemode/server/sv_config.lua10
-rw-r--r--gamemode/server/sv_database.lua22
-rw-r--r--gamemode/server/sv_loadplayer.lua20
-rw-r--r--gamemode/server/sv_mapchange.lua111
-rw-r--r--gamemode/server/sv_mapconfig.lua71
-rw-r--r--gamemode/server/sv_pac.lua21
-rw-r--r--gamemode/shared.lua2
-rw-r--r--gamemode/shared/aes.lua2
-rw-r--r--gamemode/shared/animations/swing_axe.lua141
-rw-r--r--gamemode/shared/animations/swing_fists.lua176
-rw-r--r--gamemode/shared/animations/swing_hammer.lua221
-rw-r--r--gamemode/shared/animations/swing_knife.lua208
-rw-r--r--gamemode/shared/inventory.lua73
-rw-r--r--gamemode/shared/inventory_common.lua17
-rw-r--r--gamemode/shared/itemcommon/common_inventory.lua7
-rw-r--r--gamemode/shared/itemsystem/exampleitem.lua55
-rw-r--r--gamemode/shared/itemsystem/prayers/ninelives.lua77
-rw-r--r--gamemode/shared/itemsystem/prayers/preditorinstinct.lua98
-rw-r--r--gamemode/shared/itemsystem/prayers/thickskin.lua78
-rw-r--r--gamemode/shared/itemsystem/quest/togglechip.lua24
-rw-r--r--gamemode/shared/itemsystem/weapons/knuckledclaw.lua202
-rw-r--r--gamemode/shared/itemsystem/weapons/rustyaxe.lua197
-rw-r--r--gamemode/shared/itemsystem/weapons/scraphammer.lua204
-rw-r--r--gamemode/shared/itemsystem/weapons/seratedknife.lua217
-rw-r--r--gamemode/shared/itemsystem/weapons_common.lua59
-rw-r--r--gamemode/shared/loaditems.lua6
-rw-r--r--gamemode/shared/lockbox/array.lua1
-rw-r--r--gamemode/shared/npc_editor.lua10
-rw-r--r--gamemode/shared/questsystem/examplequest.lua13
-rw-r--r--gamemode/shared/questsystem/subterr_generator.lua24
-rw-r--r--gamemode/shared/sh_buff.lua31
-rw-r--r--gamemode/shared/sh_npcmap.lua27
-rw-r--r--gamemode/shared/sh_pac.lua107
-rw-r--r--gamemode/shared/sh_quests.lua35
40 files changed, 2796 insertions, 174 deletions
diff --git a/gamemode/autolua.lua b/gamemode/autolua.lua
index 3f7d07a..12e1d97 100644
--- a/gamemode/autolua.lua
+++ b/gamemode/autolua.lua
@@ -1,9 +1,12 @@
--[[
A few functions to make it easier to include files and folders
+ Thanks to TheMaw for this idea, this entire file is basically ripped form GearFox
]]
+-- @module autolua
local auto = {}
local function ExecuteOnFolder(dir, recursive, func)
+ recursive = recursive ~= nil and recursive or false
local path = GM.Folder:gsub("gamemodes/","") .. "/gamemode/"
local fpath = table.concat({path,dir,"/*"})
local files, directories = file.Find(fpath,"LUA")
@@ -20,6 +23,10 @@ local function ExecuteOnFolder(dir, recursive, func)
end
end
+--- Adds files client side.
+-- Calls AddCSLuaFile on all files under a folder server side, and include() client side, if the recursive flag is checked, calls all files under all folders as well.
+-- @string dir The directory relative to /gamemode/ to add client side
+-- @param recursive boolean value that when true includes all sub-folders recursively.
auto.AddLuaCSFolder = function(dir,recursive)
ExecuteOnFolder(dir,recursive,function(f)
if SERVER then AddCSLuaFile(f)
@@ -27,6 +34,10 @@ auto.AddLuaCSFolder = function(dir,recursive)
end)
end
+--- Adds files server side.
+-- Calls include() on all files under a folder, if the recursive flag is checked, calls all files under all folders as well.
+-- @string dir The directory relative to /gamemode/ to add client side
+-- @param recursive boolean value that when true includes all sub-folders recursively.
auto.AddLuaSVFolder = function(dir,recursive)
if CLIENT then return end
ExecuteOnFolder(dir,recursive,function(f)
@@ -34,6 +45,10 @@ auto.AddLuaSVFolder = function(dir,recursive)
end)
end
+--- Adds files server side.
+-- Calls include() and AddCSLuaFile() on all files under a folder server side, and include() client side, if the recursive flag is checked, calls all files under all folders as well.
+-- @string dir The directory relative to /gamemode/ to add client side
+-- @param recursive boolean value that when true includes all sub-folders recursively.
auto.AddLuaSHFolder = function(dir,recursive)
ExecuteOnFolder(dir,recursive,function(f)
if SERVER then AddCSLuaFile(f) end
@@ -41,4 +56,19 @@ auto.AddLuaSHFolder = function(dir,recursive)
end)
end
+--- Adds resources for the client to download
+-- Calls resource.AddFile() on all files under a directory, recursive.
+-- @param the path to add all files under, relative to the /content/ directory.
+auto.AddContentFolder = function(dir)
+ local path = string.format("gamemodes/artery/content/%s/",dir)
+ local files, directories = file.Find(path .. "*","MOD")
+ for k,v in pairs(files) do
+ resource.AddFile(path .. v)
+ end
+ for k,v in pairs(directories) do
+ local npath = table.concat({dir,"/",v})
+ auto.AddContentFolder(npath)
+ end
+end
+
return auto
diff --git a/gamemode/client/cl_inventory.lua b/gamemode/client/cl_inventory.lua
index 6db72dd..837f7a1 100644
--- a/gamemode/client/cl_inventory.lua
+++ b/gamemode/client/cl_inventory.lua
@@ -2,11 +2,127 @@
Displays the inventory, for more information see /gamemode/shared/inventory.lua
]]
print("Hello from cl_inventory.lua")
-local invfuncs = include("../shared/inventory_common.lua")
+--debug.Trace()
+local invfuncs
+invfuncs = ART.invfuncs
+--invfuncs = include("../gamemodes/artery/gamemode/shared/inventory_common.lua")
+--invfuncs = include("../shared/inventory_common.lua")
+assert(invfuncs ~= nil, "Dependency failed")
local plyisininventory = false
+--Displays a dropdown of options under the players mouse, if the option is clicked, does the function
+--Requires a table of strings to functions, or strings to tables of strings to functions.
+--Be careful not to make this a recursive table.
+local function createMenuFor(menu, tbl)
+ for k,v in pairs(tbl) do
+ if(isfunction(v)) then --This is a dead-end, add the menu
+ local thisoption = menu:AddOption(k,v)
+ else --Otherwise it should be a table, recursively call to create
+ local submenu = menu:AddSubMenu(k)
+ createMenuFor(submenu,v)
+ end
+ end
+end
+
+local function DrawBackpackOnDPanel(dp, backpack, backpacknum, tent)
+ local width = ScrW()
+ local height = ScrH()
+ local slotsize = math.Round(width / 32)
+ local backgrid = vgui.Create( "DGrid", dp )
+ backgrid:SetPos( 10, 30 )
+ backgrid:SetCols( backpack[2][1] )
+ backgrid:SetColWide( backpack[2][2] )
+ backgrid:Dock(FILL)
+ for i = 1,#(backpack[1]) do
+ for j = 1,#(backpack[1][i]) do
+ local item = backpack[1][j][i]
+ if type(backpack[1][j][i]) == "table" then
+ local itemwidth = 0
+ for _,l in pairs(item.Shape) do
+ itemwidth = math.Max(itemwidth,#l)
+ end
+ local itemheight = #item.Shape
+ local invicon = vgui.Create( "DImageButton", dp )
+ invicon:SetSize(slotsize * itemwidth, slotsize * itemheight)
+ invicon:SetPos(slotsize * (i - 1), slotsize * (j - 1))
+ invicon:SetText(item.Name)
+ if item.Tooltip then
+ invicon:SetTooltip(item.Tooltip)
+ end
+ if item.Paint then
+ invicon.Paint = item.Paint
+ end
+ if item.DoOnPanel then
+ item.DoOnPanel(invicon)
+ end
+ --invicon.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,100,0)) end
+ invicon.DoClick = function()
+ if not item.GetOptions then return end
+ local menu = vgui.Create("DMenu")
+ createMenuFor(menu,item:GetOptions())
+ menu:Open()
+ end
+ invicon.Item = item
+ invicon.invpos = {j,i}
+ invicon.ent = tent
+ invicon.backpacknum = backpacknum
+ invicon:Droppable("Inventory")
+ elseif not backpack[1][j][i] then
+ local emptyslot = vgui.Create("DPanel", dp)
+ emptyslot:SetSize(slotsize,slotsize)
+ emptyslot:SetPos(slotsize * (i - 1), slotsize * (j - 1))
+ --emptyslot.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,0,100)) end
+ emptyslot:Receiver( "Inventory", function( receiver, tableOfDroppedPanels, isDropped, menuIndex, mouseX, mouseY )
+ if not isDropped then return end
+ local icon = tableOfDroppedPanels[1]
+ local item = icon.Item
+ local curpos = icon.invpos
+ --Set the shape it was at to false
+ if not icon.wasequiped and icon.ent == tent then
+ assert(curpos ~= nil, "print curpos was nil when not equiped")
+ for k = 1,#item.Shape do
+ for l = 1,#(item.Shape[k]) do
+ if k == 1 and l == 1 then continue end
+ backpack[1][curpos[1] + k - 1][curpos[2] + l - 1] = false
+ end
+ end
+ backpack[1][curpos[1]][curpos[2]] = false
+ end
+ if invfuncs.CanFitInBackpack(backpack,j,i,item) then
+ local fromtbl = icon.invpos
+ local wasequiped = icon.wasequiped
+ if wasequiped then
+ net.Start("unequipitem")
+ net.WriteString(wasequiped)
+ net.WriteUInt(backpacknum,16)
+ net.WriteUInt(i,16)
+ net.WriteUInt(j,16)
+ net.SendToServer()
+ else
+ net.Start("moveitem")
+ net.WriteEntity(icon.ent) -- from ent
+ net.WriteEntity(tent) -- to ent
+ net.WriteUInt(icon.backpacknum,16) -- from backpack number
+ net.WriteUInt(backpacknum,16) -- to backpack number
+ net.WriteUInt(fromtbl[1],16) -- From position
+ net.WriteUInt(fromtbl[2],16)
+ net.WriteUInt(j,16) -- To position
+ net.WriteUInt(i,16)
+ net.SendToServer()
+ if item.onEquip ~= nil then
+ item:onEquip(LocalPlayer())
+ end
+ end
+ end
+ end, {} )
+ end
+ end
+ end
+end
+
function ShowInventory(ply,cmd,args)
if plyisininventory then return end
+ LocalPlayer().invdisplays = LocalPlayer().invdisplays or {}
plyisininventory = true
local width = ScrW()
local height = ScrH()
@@ -35,6 +151,30 @@ function ShowInventory(ply,cmd,args)
skillsheet.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 157, 160, 167 ) ) end
sheet:AddSheet( "Skills", skillsheet, "icon16/tick.png" )
+ local questsheet = vgui.Create( "DPanel", sheet)
+ questsheet.Paint = function(self,w,h) draw.RoundedBox(4,0,0,w,h,Color(157,160,167)) end
+ sheet:AddSheet( "Quests", questsheet, "icon16/house.png")
+
+ --Display quests
+ local questselector = vgui.Create( "DScrollPanel", questsheet )
+ questselector:SetSize((width / 4) - 20, (height / 2) - 40)
+ questselector:SetPos(0,0)
+ local questinfo = vgui.Create("DScrollPanel", questsheet)
+ questinfo:SetSize(width / 4, (height / 2))
+ --questinfo.Paint = function(self,w,h) draw.RoundedBox(4,0,0,w,h,Color(0,160,167)) end
+ questinfo:SetPos(0,height / 2)
+ for k,v in pairs(LocalPlayer().Quests or {}) do
+ print("Displaying quest:" .. k)
+ local questbutton = vgui.Create( "DButton" , questselector )
+ questbutton:Dock(TOP)
+ questbutton:SetText(k)
+ questbutton.DoClick = function()
+ print("At point of clicking, art is:")
+ PrintTable(ART)
+ ART.GetQuest(k).DrawQuestInfo(questinfo,v)
+ end
+ end
+
--Display gear
local slotsize = math.Round(width / 32)
local displaypos = {
@@ -74,9 +214,15 @@ function ShowInventory(ply,cmd,args)
else
print("eqslot",k,"was not false, it was")
PrintTable(v)
- local eqslot = vgui.Create("DPanel",invsheet)
+ local eqslot = vgui.Create("DImageButton",invsheet)
eqslot:SetSize(slotsize,slotsize)
eqslot:SetPos(displaypos[k][1],displaypos[k][2])
+ if v.PaintEquiped then
+ eqslot.Paint = v.PaintEquiped
+ end
+ if v.DoOnEqupPanel then
+ v.DoOnEqupPanel(eqslot)
+ end
--eqslot:SetImage( "overviews/de_inferno", "vgui/avatar_default" )
--eqslot.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(100,0,0)) end
eqslot:Droppable("Inventory")
@@ -88,93 +234,29 @@ function ShowInventory(ply,cmd,args)
local backpacksheet = vgui.Create( "DPropertySheet", invsheet )
backpacksheet:SetPos(0,slotsize * 6)
backpacksheet:SetSize((width / 4) - 25, height - (slotsize * 6) - 50)
-
+ print("Displaying backpacks:")
+ PrintTable(LocalPlayer().Inventory.Backpacks)
+ print("That was all the backpacks")
for k,v in pairs(LocalPlayer().Inventory.Backpacks) do
local tbacksheet = vgui.Create( "DPanel", backpacksheet )
tbacksheet.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 157, 160, 167 ) ) end
backpacksheet:AddSheet( v[3], tbacksheet, "icon16/cross.png" )
- invfuncs.DrawBackpackOnDPanel(tbacksheet,v,k,LocalPlayer())
-
- --[[
- local backgrid = vgui.Create( "DGrid", tbacksheet )
- backgrid:SetPos( 10, 30 )
- backgrid:SetCols( v[2][1] )
- backgrid:SetColWide( v[2][2] )
- backgrid:Dock(FILL)
-
- for i=1,#(v[1]) do
- for j=1,#(v[1][i]) do
- if type(v[1][j][i]) == "table" then
- print("Loading icon")
- local item = v[1][j][i]
- print("Item is:")
- PrintTable(item)
- local itemwidth = 0
- for _,l in pairs(item.Shape) do
- itemwidth = math.Max(itemwidth,#l)
- end
- local itemheight = #item.Shape
- local invicon = vgui.Create( "DButton", tbacksheet )
- invicon:SetSize(slotsize*itemwidth,slotsize*itemheight)
- invicon:SetPos(slotsize*(i-1),slotsize*(j-1))
- --invicon.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,100,0)) end
- invicon.Item = item
- invicon.invpos = {j,i}
- invicon.backpack = k
- invicon:Droppable("Inventory")
- elseif not v[1][j][i] then
- local emptyslot = vgui.Create("DPanel", tbacksheet)
- emptyslot:SetSize(slotsize,slotsize)
- emptyslot:SetPos(slotsize*(i-1),slotsize*(j-1))
- --emptyslot.Paint = function(self, w, h) draw.RoundedBox(4, 0,0,w,h,Color(0,0,100)) end
- emptyslot:Receiver( "Inventory", function( receiver, tableOfDroppedPanels, isDropped, menuIndex, mouseX, mouseY )
- if not isDropped then return end
- print("receiver",receiver)
- print("menuIndex",menuIndex)
- print("tableOfDroppedPanels",tableOfDroppedPanels)
- PrintTable(tableOfDroppedPanels)
- local item = tableOfDroppedPanels[1].Item
- print("Checking if item:")
- PrintTable(item)
- print("Can fit in pack:",j,i)
- if invfuncs.CanFitInBackpack(v,j,i,item) then
- local fromtbl = tableOfDroppedPanels[1].invpos
- local wasequiped = tableOfDroppedPanels[1].wasequiped
- if wasequiped then
- print("wasequiped",wasequiped)
- net.Start("unequipitem")
- net.WriteString(wasequiped)
- net.WriteUInt(k,16)
- net.WriteUInt(i,16)
- net.WriteUInt(j,16)
- net.SendToServer()
- else
- net.Start("moveitem")
- net.WriteUInt(k,16) -- Backpack number
- net.WriteUInt(fromtbl[1],16) -- From position
- net.WriteUInt(fromtbl[2],16)
- net.WriteUInt(j,16) -- To position
- net.WriteUInt(i,16)
- net.SendToServer()
- if item.onEquip ~= nil then
- item:onEquip(LocalPlayer())
- end
- end
- end
- end, {} )
- end
- end
- end
- ]]
+ DrawBackpackOnDPanel(tbacksheet,v,k,LocalPlayer())
end
end
hook.Add("OnSpawnMenuOpen","ArteryOpenInventory",ShowInventory)
hook.Add("OnSpawnMenuClose","ArteryCloseInventory",function()
- if LocalPlayer().invpanel == nil then return end
- LocalPlayer().invpanel:Remove()
+ for k,v in pairs(LocalPlayer().invdisplays) do
+ if not v.panel:IsValid() then continue end
+ PrintTable(v)
+ v.panel:Close()
+ LocalPlayer().invdisplays[k] = nil
+ end
+ --if LocalPlayer().invpanel == nil then return end
+ --LocalPlayer().invpanel:Remove()
plyisininventory = false
end)
diff --git a/gamemode/client/cl_npcmap.lua b/gamemode/client/cl_npcmap.lua
new file mode 100644
index 0000000..784ca45
--- /dev/null
+++ b/gamemode/client/cl_npcmap.lua
@@ -0,0 +1,24 @@
+
+local drawmap = false
+hook.Add( "ScoreboardShow", "ShowNPCMap", function()
+ print("Showing npc map")
+ drawmap = true
+ return true
+end )
+hook.Add( "ScoreboardHide", "ShowNPCMap", function()
+ print("Hiding npc map")
+ drawmap = false
+end )
+local white = Color( 255, 255, 255, 255 )
+
+hook.Add( "HUDPaint", "paintsprites", function()
+ if drawmap then
+ LocalPlayer().MapIcons = LocalPlayer().MapIcons or {}
+ cam.Start3D()
+ for k,v in pairs(LocalPlayer().MapIcons) do
+ render.SetMaterial( v.material )
+ render.DrawSprite( v.pos, 64, 64, white )
+ end
+ cam.End3D()
+ end
+end )
diff --git a/gamemode/client/cl_pac.lua b/gamemode/client/cl_pac.lua
deleted file mode 100644
index 6a7abed..0000000
--- a/gamemode/client/cl_pac.lua
+++ /dev/null
@@ -1,2 +0,0 @@
-
-local pmeta = FindMetaTable("Player")
diff --git a/gamemode/client/healthbar.lua b/gamemode/client/healthbar.lua
new file mode 100644
index 0000000..d9a050c
--- /dev/null
+++ b/gamemode/client/healthbar.lua
@@ -0,0 +1,107 @@
+
+hook.Add( "HUDShouldDraw", "HideHUD", function( name )
+ if name == "CHudHealth" then return false end
+end )
+
+--A function that rotates a point around another point
+local function rotatepoint(x,y,cx,cy,rot)
+ rot = math.rad(rot)
+ local cs,sn = math.cos(rot),math.sin(rot)
+ local px = x * cs - y * sn;
+ local py = x * sn + y * cs;
+ return px,py
+end
+
+--Add a function to the draw library to draw elipses for blood
+local segments = 20
+local fade = 0.5
+function draw.DrawElipse(x,y,radius,elong,rotation)
+ rotation = math.rad(rotation)
+ local cir = {}
+ table.insert( cir, { x = x, y = y, u = fade, v = fade } )
+ for i = 0, segments do
+ local a = math.rad( ( i / segments ) * -360 )
+ local xu,yu = math.sin(a),math.cos(a)
+ local xpos = xu * radius * elong
+ local ypos = yu * radius
+ local cs,sn = math.cos(rotation),math.sin(rotation)
+ xpos,ypos = xpos * cs - ypos * sn, xpos * sn + ypos * cs
+ table.insert( cir, {
+ x = x + xpos,
+ y = y + ypos,
+ u = 1,
+ v = 1 } )
+ end
+ surface.DrawPoly( cir )
+end
+
+local blobs = {}
+local lastpos = 0
+local delpoint = ScrH()
+hook.Add( "Tick", "Hudpaintbloodtick",function()
+ for k,v in pairs(blobs) do
+ if v.y > delpoint then
+ blobs[k] = nil
+ else
+ blobs[k] = {
+ ["x"] = v.x + v.xv,
+ ["y"] = v.y + v.yv,
+ ["xv"] = v.xv,
+ ["yv"] = v.yv + 1,
+ }
+ end
+ end
+end)
+
+local lasthealth
+local width,height = ScrW(),ScrH()
+local padding = height / 32
+local barheight = height / 16
+local obarlength = width / 4
+local barlength = obarlength
+local xs,ys = padding,height - padding - barheight
+hook.Add( "HUDPaint", "HUD_DrawHealth", function()
+
+ --Spawn a bunch of blobs if our health has changed
+ local health = LocalPlayer():Health()
+ if lasthealth == nil then
+ lasthealth = health
+ end
+ if health ~= lasthealth then
+ local difference = lasthealth - health
+ barlength = obarlength * (health/100)
+ for i=0,difference*3 do
+ local rtime = math.random()
+ timer.Simple(rtime,function()
+ local yvel = -20 + math.random(10)
+ local xvel = (math.random()*5)
+ local xpos = padding + xs + barlength - difference - 5
+ local ypos = ys + (math.random() * barheight)
+ table.insert(blobs,{
+ x = xpos,
+ y = ypos,
+ xv = xvel,
+ yv = yvel,
+ })
+ end)
+ end
+ lasthealth = health
+ end
+
+ --Draw the current health thing
+ surface.SetDrawColor(100,100,100,100)
+ surface.DrawRect( xs, ys, obarlength, barheight)
+ surface.SetDrawColor( 150, 0, 0, 255 )
+ surface.DrawRect( xs, ys, barlength, barheight )
+
+ --Draw the animation for blobs
+ for k,v in pairs(blobs) do
+ --Elongation is based on velocity
+ local elong = (v.yv^2 + v.xv^2)^0.5
+ elong = elong/5
+ elong = math.Clamp(elong,1,3)
+ --Rotation is also based on velcotiy
+ local rot = math.deg(math.atan(v.yv/v.xv))
+ draw.DrawElipse(v.x,v.y,10/elong,elong,rot)
+ end
+end )
diff --git a/gamemode/init.lua b/gamemode/init.lua
index 0429d01..0b311ea 100644
--- a/gamemode/init.lua
+++ b/gamemode/init.lua
@@ -1,5 +1,5 @@
AddCSLuaFile( "autolua.lua" )
-AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
+AddCSLuaFile( "cl_init.lua" )
include( "shared.lua" )
diff --git a/gamemode/server/sv_config.lua b/gamemode/server/sv_config.lua
index e4d43ab..918f196 100644
--- a/gamemode/server/sv_config.lua
+++ b/gamemode/server/sv_config.lua
@@ -4,16 +4,18 @@
ART.defaults = {}
ART.defaults.starting_inventory = '{"Backpacks":[[[[false,false,false,false,false],[false,false,false,false,false],[false,false,false,false,false],[false,false,false,false,false],[false,false,false,false,false]],[5,5],"Rucksack"]],"Equiped":{"Gloves":false,"Left":false,"Head":false,"Legs":false,"Right":false,"Body":false,"Boots":false}}'
+ART.defaults.starting_skills = "[]"
+ART.defaults.starting_quests = "[]"
-ART.defaults.starting_position = "185.690247 310.664398 515.031250"
-ART.defaults.starting_world = "0.0.0.0:0"
+ART.defaults.starting_position = "185 310 524"
+ART.defaults.starting_world = "0.0.0.0:27015"
ART.config = {}
ART.config.server_world = game.GetIPAddress()
local mysqlconfig = file.Read("artery/mysql.txt")
for _,line in pairs(string.Explode("\n",mysqlconfig,false)) do
- print(line)
+ --print(line)
local key, value = unpack(string.Explode("=",line,false))
- print("setting",key,"to",value)
+ --print("setting",key,"to",value)
ART.config[key] = value
end
diff --git a/gamemode/server/sv_database.lua b/gamemode/server/sv_database.lua
index 59b685f..357d868 100644
--- a/gamemode/server/sv_database.lua
+++ b/gamemode/server/sv_database.lua
@@ -4,9 +4,9 @@ require("mysqloo")
local createplayerquery
local createplayerprepare = [[
-INSERT INTO playerdata (`SteamID`, `PlayerName`,`Inventory`,`WorldPosition`,`World`) VALUES(?, ?, ?, ?, ?)]]
+INSERT INTO playerdata (`SteamID`, `PlayerName`,`Inventory`, `Skills`,`Quests`,`WorldPosition`,`World`) VALUES(?, ?, ?, ?, ?, ?, ?)]]
local createtablequery = [[
-create table if not exists playerdata(SteamID text, PlayerName text, Inventory json, WorldPosition text, World text)]]
+create table if not exists playerdata(SteamID bigint primary key, PlayerName text, Inventory json, Skills json, Quests json, WorldPosition text, World text)]]
local function connectToDatabase()
if ART.database ~= nil then return end
@@ -65,13 +65,15 @@ checkDatabase()
local function loadQueries()
local db = ART.database
- print("Loading queries")
+ --print("Loading queries")
createplayerquery = db:prepare(createplayerprepare)
- print("starting inventory:")
- print(ART.defaults.starting_inventory)
+ --print("starting inventory:")
+ --print(ART.defaults.starting_inventory)
createplayerquery:setString(3,ART.defaults.starting_inventory)
- createplayerquery:setString(4,ART.defaults.starting_position)
- createplayerquery:setString(5,ART.defaults.starting_world)
+ createplayerquery:setString(4,ART.defaults.starting_skills)
+ createplayerquery:setString(5,ART.defaults.starting_quests)
+ createplayerquery:setString(6,ART.defaults.starting_position)
+ createplayerquery:setString(7,ART.defaults.starting_world)
function createplayerquery:onSuccess(data)
print("Created player entry successfully!")
end
@@ -86,10 +88,10 @@ loadQueries()
function ART.loadPlayerData(ply)
assert(ART.DatabaseConnected,"Player joined while setup was not complete!")
print("Attempting to load player data")
- local steamid = ply:SteamID()
+ local steamid = ply:SteamID64()
local db = ART.database
local q = db:query([[
-select Inventory, WorldPosition, World from playerdata where SteamID="]] .. steamid .. "\"")
+select Inventory, Skills, Quests, WorldPosition, World from playerdata where SteamID="]] .. steamid .. "\"")
function q:onSuccess(data)
if #data == 0 then --Player does not have an entry, make one!
print("Player does not have entry!")
@@ -126,6 +128,8 @@ select Inventory, WorldPosition, World from playerdata where SteamID="]] .. stea
end
--Otherwise, we're in the right world, load our data
ply:LoadInventory(inv)
+ ply.Skills = util.JSONToTable(data[1].Skills)
+ ply.Quests = util.JSONToTable(data[1].Quests)
local postbl = string.Explode(" ", worldpos)
local posvec = Vector(postbl[1],postbl[2],postbl[3])
print("Setting player pos to:")
diff --git a/gamemode/server/sv_loadplayer.lua b/gamemode/server/sv_loadplayer.lua
index 397c6cb..cfbc265 100644
--- a/gamemode/server/sv_loadplayer.lua
+++ b/gamemode/server/sv_loadplayer.lua
@@ -1,13 +1,25 @@
local models = {}
-for k=1,9 do
- models[#models+1] = "models/player/Group01/male_0" .. k .. ".mdl"
- models[#models+1] = "models/player/Group02/Male_0" .. k .. ".mdl"
+for k = 1,9 do
+ models[#models + 1] = "models/player/Group01/male_0" .. k .. ".mdl"
+ models[#models + 1] = "models/player/Group02/Male_0" .. k .. ".mdl"
+end
+
+local function delayplayerload(ply)
+ if ply:Alive() then
+ ART.loadPlayerData(ply)
+ else
+ timer.Simple(1,function()
+ delayplayerload(ply)
+ end)
+ end
end
hook.Add("PlayerInitialSpawn","ArteryPlayerLoad",function(pl)
local modelnum = pl:UniqueID() % (#models)
- ART.loadPlayerData(pl)
+ timer.Simple(5,function()
+ delayplayerload(pl)
+ end)
pl:SetModel(models[modelnum])
--pl:Give("weapon_pistol")
pl:Give("hands")
diff --git a/gamemode/server/sv_mapchange.lua b/gamemode/server/sv_mapchange.lua
new file mode 100644
index 0000000..032a1bb
--- /dev/null
+++ b/gamemode/server/sv_mapchange.lua
@@ -0,0 +1,111 @@
+--[[
+ A script to move the player to a different map
+]]
+local mapname = game.GetMap()
+local mapareasstr = file.Read("artery/maps/" .. mapname .. "/mapareas.txt")
+
+hook.Add("InitPostEntity", "LoadMapChangePoints", function()
+ local transfers = string.Explode("\r?\n\r?\n",mapareasstr,true)
+ local dontupdatedisconnect = {}
+ for k,v in pairs(transfers) do
+ local parts = string.Explode("\r?\n",v,true)
+ local vectortxt = string.Explode(" ",parts[1],false)
+ local svec = Vector(vectortxt[1],vectortxt[2],vectortxt[3])
+ local name = parts[2]
+ local server = parts[3]
+ local model = parts[4]
+ local tvt = string.Explode(" ",parts[5],false)
+
+ local sch = ents.Create("art_serverchanger")
+ sch.Model = model
+ sch.Pos = svec
+ sch.OnHit = function(self, coldata,collider)
+ print("Coldata")
+ PrintTable(coldata)
+ print("collider",collider)
+ if coldata.HitEntity:IsPlayer() then
+ dontupdatedisconnect[coldata.HitEntity] = true
+ local db = ART.database
+ local qc = table.concat({[[
+ UPDATE artery.playerdata SET WorldPosition="]],
+ tvt[1]," ",
+ tvt[2]," ",
+ tvt[3]," ",
+ [[" WHERE SteamID="]],
+ coldata.HitEntity:SteamID64(),
+ '"'})
+ print("Running query:",qc)
+ local q = db:query(qc)
+ function q:onSuccess(data)
+ print("Got data from update:")
+ PrintTable(data)
+ coldata.HitEntity:ConCommand("connect " .. server)
+ end
+ function q:onError(err,sql)
+ print("Query error:")
+ print("Query",sql)
+ print("Error",err)
+ end
+ q:start()
+ end
+ end
+ sch:Spawn()
+ print("Loading mapchange area",svec)
+ end
+end)
+
+hook.Add("PlayerDisconnected","SavePlayerData",function(ply)
+ local qc
+ if dontupdatedisconnect[ply] then
+ dontupdatedisconnect[ply] = nil
+ qc = table.concat({
+ [[UPDATE artery.playerdata SET
+ Inventory="]],
+ util.TableToJSON(ply.Inventory),
+ [[",
+ Skills="]],
+ util.TableToJSON(ply.Skills),
+ [[",
+ Quests="]],
+ util.TableToJSON(ply.Quests),
+ [["
+ WHERE SteamID = "]],
+ ply:SteamID64(),
+ [[";]]
+ })
+ else
+ local pp = ply:GetPos()
+ qc = table.concat({
+ [[UPDATE artery.playerdata SET
+ Inventory="]],
+ util.TableToJSON(ply.Inventory),
+ [[",
+ Skills="]],
+ util.TableToJSON(ply.Skills),
+ [[",
+ Quests="]],
+ util.TableToJSON(ply.Quests),
+ [[",
+ WorldPosition="]],
+ pp[1]," ",pp[2]," ",pp[3],
+ [[",
+ World="]],
+ game.GetIPAddress(),
+ [["
+ WHERE SteamID = "]],
+ ply:SteamID64(),
+ [[";]]
+ })
+ end
+ local q = ART.database:query(qc)
+ function q:onSuccess(data)
+ print("Saveing player data successful")
+ PrintTable(data)
+ end
+ function q:onError(err, sql)
+ print("Saveing player data errored!")
+ print("Query",sql)
+ error(err)
+ end
+ q:start()
+end)
diff --git a/gamemode/server/sv_mapconfig.lua b/gamemode/server/sv_mapconfig.lua
index 67a20ae..b9a93b8 100644
--- a/gamemode/server/sv_mapconfig.lua
+++ b/gamemode/server/sv_mapconfig.lua
@@ -1,19 +1,66 @@
--Loads map config form a file
-local chests = file.Read("artery/maps/" .. game.GetMap() .. "/chests.txt")
-local npcs = file.Read("artery/maps/" .. game.GetMap() .. "/npcs.txt")
+function ART.CreateTownie(tbl)
+ local npcent = ents.Create("npc_townie")
+ for k,v in pairs(tbl) do
+ npcent[k] = v
+ end
+ npcent:Spawn()
+end
+
+function ART.CreateNavNode(tbl)
+ local nodeent = ents.Create("info_townienode")
+ assert(tbl ~= nil, "Tried to create a nil navnode")
+ for k,v in pairs(tbl) do
+ nodeent[k] = v
+ end
+ nodeent:Spawn()
+end
-if chests == nil then return end
-if npcs == nil then return end
+local removeents = {
+ "npc_townie",
+-- "art_chest",
+ "info_townienode",
+}
-for _,line in pairs(string.Explode("\n",chests,false)) do
- local chest = util.JSONToTable(line)
- local chestent = ents.Create("art_chest")
- for k,v in pairs(chest.data) do
- chestent[k] = v
+for k,v in pairs(removeents) do
+ local eot = ents.FindByClass(v)
+ for i,j in pairs(eot) do
+ j:Remove()
end
- for k,v in pairs(chest.procedures) do
- chestent[k](unpack(v))
+end
+
+local mapfields = {
+ "navnodes",
+ "npcs",
+-- "chests",
+}
+
+local function loadMap()
+ for k,v in ipairs(mapfields) do
+ local mapname = game.GetMap()
+ local fpath = string.format("artery/maps/%s/%s/*", mapname, v)
+ local files,dirs = file.Find(fpath,"DATA")
+ for i,j in pairs(files) do
+ if string.GetExtensionFromFilename(j) ~= "lua" then continue end
+ local itempath = string.format("artery/maps/%s/%s/%s", mapname, v, j)
+ local itemtxt = file.Read(itempath, "DATA")
+ assert(itemtxt ~= nil, "Found a file, but it looks like it can't be compiled:" .. itempath)
+ CompileString(itemtxt,itempath)()
+ end
end
- chestent:Spawn()
end
+
+hook.Add( "InitPostEntity", "artery_spawnmapnpcs", function()
+ loadMap()
+end )
+
+concommand.Add("artery_reloadmap", function()
+ for k,v in pairs(removeents) do
+ local eot = ents.FindByClass(v)
+ for i,j in pairs(eot) do
+ j:Remove()
+ end
+ end
+ loadMap()
+end)
diff --git a/gamemode/server/sv_pac.lua b/gamemode/server/sv_pac.lua
index 27b2ed9..fc436f4 100644
--- a/gamemode/server/sv_pac.lua
+++ b/gamemode/server/sv_pac.lua
@@ -5,24 +5,5 @@ hook.Add("PrePACConfigApply", "donators only", function(ply, outfit_data)
end)
hook.Add( "PrePACEditorOpen", "RestrictToSuperadmin", function( ply )
- if not ply:IsSuperAdmin( ) then
- return false
- end
+ return ply:IsSuperAdmin(), "This is accessable only to superadmins"
end )
-
-util.AddNetworkString("requestpac")
-util.AddNetworkString("responsepac")
-
---be able to stream pac data to clients on-demand
-net.Receive("requestpac",function(ln,ply)
- local name = net.ReadString()
- local pdata = file.Read(string.format("artery/pac/%s.txt",name)) --make sure to have the .txt, so dot-dot-slash attacks can't read the mysql file.
- net.Start("responsepac")
- net.WriteString(pdata)
- net.Send(ply)
-end)
-
-hook.Add("PlayerInitialSpawn", "AllowPacThings",function(ply)
- --pac.SetupENT(ply, false)
- PrintTable(pac)
-end)
diff --git a/gamemode/shared.lua b/gamemode/shared.lua
index f829a45..4826b29 100644
--- a/gamemode/shared.lua
+++ b/gamemode/shared.lua
@@ -2,8 +2,8 @@ local a = include("autolua.lua")
ART = {}
-a.AddLuaCSFolder("client",true)
a.AddLuaSHFolder("shared",true)
+a.AddLuaCSFolder("client",true)
a.AddLuaSVFolder("server",false)
GM.Name = "Artery"
diff --git a/gamemode/shared/aes.lua b/gamemode/shared/aes.lua
index 5c4072a..244dc22 100644
--- a/gamemode/shared/aes.lua
+++ b/gamemode/shared/aes.lua
@@ -1,5 +1,3 @@
-print("Hello from aes.lua!")
-
local Stream = include("lockbox/stream.lua");
local Array = include("lockbox/array.lua");
diff --git a/gamemode/shared/animations/swing_axe.lua b/gamemode/shared/animations/swing_axe.lua
new file mode 100644
index 0000000..60133b5
--- /dev/null
+++ b/gamemode/shared/animations/swing_axe.lua
@@ -0,0 +1,141 @@
+RegisterLuaAnimation('axe_swing_up', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -135.0759,
+ RR = 4.7695,
+ RF = 68.1705
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ RR = -7.0246,
+ RF = -41.0529
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = -24.6284
+ }
+ },
+ FrameRate = 1
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -134.3106,
+ RR = -111.2052,
+ RF = 58.2835
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 80
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ RU = -12.7583,
+ RR = -9.4569,
+ RF = 8.4272
+ }
+ },
+ FrameRate = 3
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ }
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
+
+RegisterLuaAnimation('axe_swing_left', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -16
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 62.502896241406,
+ RR = 19.915292262581,
+ RF = 58.999558486575
+ }
+ },
+ FrameRate = 1
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -71.048983114736,
+ RR = -118.30349058938,
+ RF = 12.994644385626
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 80.297417901061,
+ RR = -36.146186854911,
+ RF = -0.18188548377852
+ }
+ },
+ FrameRate = 3
+ },
+ {
+ BoneInfo = {
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
+
+RegisterLuaAnimation('axe_swing_right', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -64,
+ RR = -118.23451384787
+ },
+ ['ValveBiped.Bip01_Spine4'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RR = -51.895180109443,
+ RF = 4.9449765561345
+ },
+ ['ValveBiped.Bip01_Spine2'] = {
+ RU = -18.770943776107
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ RF = -38.639462488655
+ }
+ },
+ FrameRate = 1
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RF = -80
+ },
+ ['ValveBiped.Bip01_Spine4'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 48,
+ RR = 16,
+ RF = -44.792066414109
+ },
+ ['ValveBiped.Bip01_Spine2'] = {
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ }
+ },
+ FrameRate = 3
+ },
+ {
+ BoneInfo = {
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
diff --git a/gamemode/shared/animations/swing_fists.lua b/gamemode/shared/animations/swing_fists.lua
new file mode 100644
index 0000000..b0c77b5
--- /dev/null
+++ b/gamemode/shared/animations/swing_fists.lua
@@ -0,0 +1,176 @@
+RegisterLuaAnimation('fist_swing_up', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = 37.4518,
+ RR = -3.2972
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = -35.4314
+ }
+ },
+ FrameRate = 2
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -98.94,
+ RR = 10.3338
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 105.406
+ }
+ },
+ FrameRate = 4
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ }
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
+
+RegisterLuaAnimation('fist_swing_down', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_Spine2'] = {
+ RU = 14.4867
+ },
+ ['ValveBiped.Bip01_Spine1'] = {
+ RU = 9.6677,
+ RR = -4.4861,
+ RF = -10.2001
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ RF = 96.0979
+ },
+ ['ValveBiped.Bip01_Spine4'] = {
+ RU = 21.4083
+ },
+ ['ValveBiped.Bip01_R_Clavicle'] = {
+ RR = 40.3211
+ },
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = 36.4967,
+ RR = 7.0185,
+ RF = 7.7787
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RR = 1.9723,
+ RF = -4.604
+ }
+ },
+ FrameRate = 2
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -102.8286,
+ RR = 40.5051,
+ RF = 38.9233
+ },
+ ['ValveBiped.Bip01_Spine1'] = {
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ RF = 129.8577
+ },
+ ['ValveBiped.Bip01_Spine4'] = {
+ },
+ ['ValveBiped.Bip01_R_Clavicle'] = {
+ },
+ ['ValveBiped.Bip01_Spine2'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 80.2293,
+ RR = 0.4927
+ }
+ },
+ FrameRate = 4
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_Spine2'] = {
+ },
+ ['ValveBiped.Bip01_Spine1'] = {
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ },
+ ['ValveBiped.Bip01_Spine4'] = {
+ },
+ ['ValveBiped.Bip01_R_Clavicle'] = {
+ },
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ }
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
+
+RegisterLuaAnimation('fist_swing_left', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = 30.8726,
+ RR = 3.9566,
+ RF = 26.1338
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = -7.1148,
+ RR = 21.3712,
+ RF = 32
+ }
+ },
+ FrameRate = 2
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -0.7137,
+ RR = 44.1989,
+ RF = 1.6231
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 44.8816,
+ RR = 12.0781
+ }
+ },
+ FrameRate = 4
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -97.4486,
+ RR = 2.4404
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 108.0151,
+ RR = -23.9043
+ }
+ },
+ FrameRate = 4
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ }
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
diff --git a/gamemode/shared/animations/swing_hammer.lua b/gamemode/shared/animations/swing_hammer.lua
new file mode 100644
index 0000000..efb8e34
--- /dev/null
+++ b/gamemode/shared/animations/swing_hammer.lua
@@ -0,0 +1,221 @@
+RegisterLuaAnimation('hammer_swing_up', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -121.3723,
+ RR = 39.4933,
+ RF = -31.0527
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 16,
+ RR = 31.0061,
+ RF = -19.6651
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ RU = -0.7222,
+ RR = -14.516
+ },
+ ['ValveBiped.Bip01_L_UpperArm'] = {
+ RR = -43.4468
+ },
+ ['ValveBiped.Bip01_L_Forearm'] = {
+ RU = 4.4867,
+ RR = -5.5554,
+ RF = 0.3176
+ }
+ },
+ FrameRate = 1
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -33,
+ RR = -33,
+ RF = -59
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ RR = -37
+ },
+ ['ValveBiped.Bip01_L_Forearm'] = {
+ },
+ ['ValveBiped.Bip01_L_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 84,
+ RR = 10.0054,
+ RF = 35
+ }
+ },
+ FrameRate = 3
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ },
+ ['ValveBiped.Bip01_L_Forearm'] = {
+ },
+ ['ValveBiped.Bip01_L_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ }
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
+
+RegisterLuaAnimation('hammer_swing_left', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -85.901,
+ RR = -26.4874,
+ RF = -25.791
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ },
+ ['ValveBiped.Bip01_L_Clavicle'] = {
+ RR = 87.4193
+ },
+ ['ValveBiped.Bip01_R_Clavicle'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 63.6936,
+ RR = -12.6269,
+ RF = -50.5597
+ }
+ },
+ FrameRate = 1
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -14.9409,
+ RR = 45.7766
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ RR = -24.354
+ },
+ ['ValveBiped.Bip01_R_Clavicle'] = {
+ RR = 10.3959,
+ RF = -5.5748
+ },
+ ['ValveBiped.Bip01_L_Clavicle'] = {
+ RR = -0.2696
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 99.5046,
+ RR = 8.5341,
+ RF = -60.8322
+ }
+ },
+ FrameRate = 3
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ },
+ ['ValveBiped.Bip01_L_Clavicle'] = {
+ },
+ ['ValveBiped.Bip01_R_Clavicle'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ }
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
+
+RegisterLuaAnimation('hammer_swing_right', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = 12.3003,
+ MF = 2.0589,
+ RR = -42.3116,
+ RF = 23.9329
+ },
+ ['ValveBiped.Bip01_L_Hand'] = {
+ },
+ ['ValveBiped.Bip01_R_Clavicle'] = {
+ },
+ ['ValveBiped.Bip01_L_Clavicle'] = {
+ },
+ ['ValveBiped.Bip01_Spine'] = {
+ RF = -40.6827
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 2.8485,
+ RR = 10.1856,
+ RF = 7.6391
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ }
+ },
+ FrameRate = 1
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -83.615,
+ MF = 5.9653,
+ RR = -25.4493,
+ RF = 24.3507
+ },
+ ['ValveBiped.Bip01_L_Hand'] = {
+ RR = 1.5291
+ },
+ ['ValveBiped.Bip01_R_Clavicle'] = {
+ RR = 47.1609
+ },
+ ['ValveBiped.Bip01_L_Clavicle'] = {
+ RR = 40.5562,
+ RF = 5.5508
+ },
+ ['ValveBiped.Bip01_Spine'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 105.2417,
+ RR = -9.705,
+ RF = -16
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ RU = -17.7827,
+ RR = -39.3452,
+ RF = 12.2479
+ }
+ },
+ FrameRate = 3
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_L_Hand'] = {
+ },
+ ['ValveBiped.Bip01_R_Clavicle'] = {
+ },
+ ['ValveBiped.Bip01_L_Clavicle'] = {
+ },
+ ['ValveBiped.Bip01_Spine'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ }
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
diff --git a/gamemode/shared/animations/swing_knife.lua b/gamemode/shared/animations/swing_knife.lua
new file mode 100644
index 0000000..7dc9520
--- /dev/null
+++ b/gamemode/shared/animations/swing_knife.lua
@@ -0,0 +1,208 @@
+RegisterLuaAnimation('knife_swing_up', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -119.0702,
+ RR = 35.7771,
+ RF = 21.6572
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ }
+ },
+ FrameRate = 2
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -24.2641,
+ RR = -24.1204,
+ RF = -2.919
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 64.2667,
+ RR = 5.0335
+ }
+ },
+ FrameRate = 3
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ }
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
+
+RegisterLuaAnimation('knife_swing_down', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = 74.1135,
+ RR = 12.868,
+ RF = -31.8524
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = -6.8706
+ }
+ },
+ FrameRate = 2
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -69.5085,
+ RR = -8.3118,
+ RF = -32
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ RU = -3.0004,
+ RR = -38.9819
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 76.5184,
+ RR = 3.7464,
+ RF = 58.2735
+ }
+ },
+ FrameRate = 3
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ }
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
+
+RegisterLuaAnimation('swing_hammer_left', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -85.901,
+ RR = -26.4874,
+ RF = -25.791
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ },
+ ['ValveBiped.Bip01_L_Clavicle'] = {
+ RR = 87.4193
+ },
+ ['ValveBiped.Bip01_R_Clavicle'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 63.6936,
+ RR = -12.6269,
+ RF = -50.5597
+ }
+ },
+ FrameRate = 1
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -14.9409,
+ RR = 45.7766
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ RR = -24.354
+ },
+ ['ValveBiped.Bip01_R_Clavicle'] = {
+ RR = 10.3959,
+ RF = -5.5748
+ },
+ ['ValveBiped.Bip01_L_Clavicle'] = {
+ RR = -0.2696
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 99.5046,
+ RR = 8.5341,
+ RF = -60.8322
+ }
+ },
+ FrameRate = 3
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_R_Hand'] = {
+ },
+ ['ValveBiped.Bip01_L_Clavicle'] = {
+ },
+ ['ValveBiped.Bip01_R_Clavicle'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ }
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
+
+RegisterLuaAnimation('knife_swing_right', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = -89.3623,
+ RR = -18.4313,
+ RF = 2.3038
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 23.57,
+ RR = 3.4175,
+ RF = -64.0124
+ },
+ ['ValveBiped.Bip01_L_Forearm'] = {
+ }
+ },
+ FrameRate = 2
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ RU = 4.0091,
+ RR = 53.1032,
+ RF = 1.0142
+ },
+ ['ValveBiped.Bip01_L_Forearm'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ RU = 66.3027,
+ RR = -0.9315
+ }
+ },
+ FrameRate = 3
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_R_UpperArm'] = {
+ },
+ ['ValveBiped.Bip01_R_Forearm'] = {
+ },
+ ['ValveBiped.Bip01_L_Forearm'] = {
+ }
+ },
+ FrameRate = 1
+ }
+ },
+ Type = TYPE_GESTURE
+})
diff --git a/gamemode/shared/inventory.lua b/gamemode/shared/inventory.lua
index 42f4516..9cc8fca 100644
--- a/gamemode/shared/inventory.lua
+++ b/gamemode/shared/inventory.lua
@@ -1,27 +1,43 @@
-
-print("Hello from inventory.lua!")
+--[[
+ Various functions to work with inventories
+]]
+--- Various functions to deal with inventories.
+-- @module Player
local pmeta = FindMetaTable("Player")
local emeta = FindMetaTable("Entity")
local invfuncs = include("inventory_common.lua")
--A 2d array of the inventory.
-pmeta.Inventory = {}
+pmeta.Inventory = pmeta.Inventory or {}
--each backpack has 1:a tbl containing items or false, 2: a tbl {width,height} and 3:name
-pmeta.Inventory.Backpacks = {}
+pmeta.Inventory.Backpacks = pmeta.Inventory.Backpacks or {}
--Eqiped stuff at base, player has 1=Head, 2=Body, 3=Legs, 4=Boots, 5=Gloves, 6=Left Hand, 7=Right Hand
-pmeta.Inventory.Equiped = {}
+pmeta.Inventory.Equiped = pmeta.Inventory.Equiped or {}
local equipedslots = {
"Head","Body","Legs","Boots","Gloves","Left","Right"
}
for _,v in pairs(equipedslots) do
- pmeta.Inventory.Equiped[v] = false
+ pmeta.Inventory.Equiped[v] = pmeta.Inventory.Equiped[v] or false
end
+--- Puts an item in the inventory.
+-- Puts an item in an inventory, overwriteing all other items it might be overlapping, you should check to make sure you're not over writeing something first.
+-- @param backpack the backpack number this item should be placed in
+-- @param x the column in the backpack this item should be placed in
+-- @param y the row in the backpack this item should be placed in
+-- @param item the item to place in the backpack.
+-- @see Player.FindSpotForItem
function pmeta:PutInvItem(backpack,x,y,item)
invfuncs.PutItemInBackpack(self.Inventory.Backpacks[backpack],x,y,item)
end
+--- Finds a spot for an item.
+-- Finds a backpack, row, and column for an item in a player's inventory.
+-- @param item The item to try and fit into the backpack.
+-- @return row The row where a spot was found
+-- @return col The column where a spot was found
+-- @return n The backpack number where a spot was found
function pmeta:FindSpotForItem(item)
for n,v in pairs(self.Inventory.Backpacks) do
for row = 1,v[2][2] do
@@ -34,6 +50,31 @@ function pmeta:FindSpotForItem(item)
end
end
+--- Checks if the player has an item by name
+--
+function pmeta:HasItem(itemname)
+ for n,v in pairs(self.Inventory.Backpacks) do
+ for row = 1,v[2][2] do
+ for col = 1,v[2][1] do
+ local itemin = v[1][row][col]
+ if itemin ~= false and itemin.Name == itemname then
+ return row,col,n
+ end
+ end
+ end
+ end
+end
+
+function pmeta:RemoveItemAt(backpack,row,col)
+ local item = self.Inventory.Backpacks[backpack][1][row][col]
+ for k = 1,#item.Shape do
+ for i = 1,#(item.Shape[k]) do
+ self.Inventory.Backpacks[backpack][1][row + k - 1][col + i - 1] = false
+ end
+ end
+ self:SynchronizeInventory()
+end
+
function pmeta:GiveItem(item)
local x,y,b = self:FindSpotForItem(item)
self:PutInvItem(b,x,y,item)
@@ -64,9 +105,12 @@ net.Receive("unequipitem",function(len,ply)
topos[2],
item
) then
- ply.Inventory.Equiped[itemslot] = false
- ply:PutInvItem(tobackpack,topos[1],topos[2],item)
- ply:SynchronizeInventory()
+ ply.Inventory.Equiped[itemslot] = false
+ ply:PutInvItem(tobackpack,topos[1],topos[2],item)
+ if item.onUnEquip ~= nil then
+ item:onUnEquip(ply)
+ end
+ ply:SynchronizeInventory()
end
end)
@@ -104,13 +148,10 @@ net.Receive("moveitem",function(len,ply)
local frompos = {net.ReadUInt(16),net.ReadUInt(16)}
local topos = {net.ReadUInt(16),net.ReadUInt(16)}
- print("Moveing from ",frompos[1],frompos[2],"to",topos[1],topos[2])
-
if froment:IsPlayer() and toent:IsPlayer() and (froment ~= toent) then--Just don't allow stealing between players, anything else is fine
ply:PrintMessage( HUD_PRINTCENTER, "You can't steal from this person!" )
return
end
- print("Passed the stealing check")
local item = froment.Inventory.Backpacks[frombackpack][1][frompos[1]][frompos[2]]
--Set the shape it was at to false
@@ -121,10 +162,8 @@ net.Receive("moveitem",function(len,ply)
end
end
froment.Inventory.Backpacks[frombackpack][1][frompos[1]][frompos[2]] = false
- print("Set shape to false")
--now check if it can fit in the backpack
if invfuncs.CanFitInBackpack(toent.Inventory.Backpacks[tobackpack],topos[1],topos[2],item) then
- print("It can fit there")
invfuncs.PutItemInBackpack(toent.Inventory.Backpacks[tobackpack],topos[1],topos[2],item)
else
invfuncs.PutItemInBackpack(froment.Inventory.Backpacks[frombackpack],frompos[1],frompos[2],item)
@@ -142,7 +181,6 @@ function pmeta:LoadInventory(json)
end
function pmeta:SynchronizeInventory()
- print("Player synchronize called")
net.Start("synchinventory")
net.WriteEntity(self)
net.WriteFloat(#self.Inventory.Backpacks)
@@ -192,7 +230,6 @@ if CLIENT then
end
local discopy = LocalPlayer().invdisplays
LocalPlayer().invdisplays = {}
- PrintTable(discopy)
for k,ptbl in pairs(discopy) do
if not ptbl.panel:IsValid() then continue end
if ptbl.panel.Close ~= nil then
@@ -211,3 +248,7 @@ concommand.Add("artery_showinventory",function(ply,cmd,args)
PrintTable(ply.Inventory)
PrintTable(ply.ClientInventory)
end)
+
+hook.Add( "PlayerSpawn", "artery_disable_sprint", function(ply)
+ ply:SetRunSpeed(ply:GetWalkSpeed())
+end )
diff --git a/gamemode/shared/inventory_common.lua b/gamemode/shared/inventory_common.lua
index e86d0a6..aaf6afb 100644
--- a/gamemode/shared/inventory_common.lua
+++ b/gamemode/shared/inventory_common.lua
@@ -1,6 +1,7 @@
--[[
Some functions that are needed multiple places in the code, to deal with player inventories.
]]
+print("Hello from inventory_common.lua")
local invfuncs = {}
--Forcibly put an item in a backpack, you should check to make sure there's room first
@@ -97,20 +98,6 @@ invfuncs.CreateBackpack = function(name,width,height)
return backpack
end
---Displays a dropdown of options under the players mouse, if the option is clicked, does the function
---Requires a table of strings to functions, or strings to tables of strings to functions.
---Be careful not to make this a recursive table.
-local function createMenuFor(menu, tbl)
- for k,v in pairs(tbl) do
- if(isfunction(v)) then --This is a dead-end, add the menu
- local thisoption = menu:AddOption(k,v)
- else --Otherwise it should be a table, recursively call to create
- local submenu = menu:AddSubMenu(k)
- createMenuFor(submenu,v)
- end
- end
-end
-
--Draws a backpack on the dpanel, client side only
invfuncs.DrawBackpackOnDPanel = function(dp, backpack, backpacknum, tent)
local width = ScrW()
@@ -201,5 +188,5 @@ invfuncs.DrawBackpackOnDPanel = function(dp, backpack, backpacknum, tent)
end
end
end
-
+ART.invfuncs = invfuncs
return invfuncs
diff --git a/gamemode/shared/itemcommon/common_inventory.lua b/gamemode/shared/itemcommon/common_inventory.lua
index 3f5fb3a..f541ecc 100644
--- a/gamemode/shared/itemcommon/common_inventory.lua
+++ b/gamemode/shared/itemcommon/common_inventory.lua
@@ -1,9 +1,4 @@
--[[
- Stores some common functions related to inventories
+ Stores some common functions related to items
]]
local common = {}
-
---Must have Serialize and Deseralize created before calling.
-function MakeInventoryable(item,shape,width,height,xpos,ypos)
-
-end
diff --git a/gamemode/shared/itemsystem/exampleitem.lua b/gamemode/shared/itemsystem/exampleitem.lua
index f39a979..d2d6ed8 100644
--- a/gamemode/shared/itemsystem/exampleitem.lua
+++ b/gamemode/shared/itemsystem/exampleitem.lua
@@ -3,23 +3,78 @@
]]
local item = {}
+--Required, a name, all item names must be unique
item.Name = "Test item"
+--Optional, a tooltip to display when hovered over
+item.Tooltip = "An old axe, probably good for fighting."
+
+--Required Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network
item.Serialize = function(self)
print("Trying to serailize!")
return ""
end
+--Required, Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set.
item.DeSerialize = function(self,string)
print("Trying to deserialize!")
return self
end
+--Optional, when the player clicks this item, a menu will show up, if the menu item is clicked, the function is ran. This is all run client side, so if you want it to do something server side, you'll need to use the net library. Remember that items are in the shared domain, so you can define what it does in the same file!
+function item.GetOptions(self)
+ local options = {}
+ options["test"] = function() print("You pressed test!") end
+ options["toste"] = function() print("You pressed toste!") end
+ return options
+end
+
+--Optional. Something run once when this item is drawn in a backpack
+function item.DoOnPanel(dimagebutton)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe.png")
+end
+
+--Optional. Something run once when this item is drawn in an equiped slot
+function item.DoOnEqupPanel(dimagebutton)
+ print("called with panel:",panel)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe_eq.png")
+end
+
+--Optional. Called continuously, use if you need the item to display different stuff at different tiems in the backpack.
+function item.Paint(self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+--Optional. Called continuously, use if you need the item to display different stuff at different tiems when equiped.
+function item.PaintEquiped(self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+--Required, the shape of this item in a backpack.
item.Shape = {
{true},
{true},
{true},
}
+--Optional, If this item can be equiped in any player slots, put them here.
+item.Equipable = "Right"
+
+--Optional, what to do when the player clicks, and this item is in the slot in inventory. only works for items equipable in left and right
+item.onClick = function(self,owner)
+ print("pew pew!")
+end
+
+--Optional, if we should do something special on equip(like draw the PAC for this weapon). See ART.ApplyPAC in /gamemode/shared/sh_pac.lua
+item.onEquip = function(self,who)
+ print("Oh boy! I'm getting used!")
+end
+
+--Optional, if we should do something speical on unequip(like setting PAC back to normal). Sett ART.RemovePAC in /gamemode/shared/sh_pac.lua
+item.onUnEquip = function(self,who)
+ print("Aw, I'm being stored :(")
+end
+
print("Hello from exampleitem.lua")
+--Don't forget to register the item!
ART.RegisterItem(item)
diff --git a/gamemode/shared/itemsystem/prayers/ninelives.lua b/gamemode/shared/itemsystem/prayers/ninelives.lua
new file mode 100644
index 0000000..e03e54c
--- /dev/null
+++ b/gamemode/shared/itemsystem/prayers/ninelives.lua
@@ -0,0 +1,77 @@
+--[[
+ An example item
+]]
+local item = {}
+
+--Required, a name, all item names must be unique
+item.Name = "Nine Lives"
+
+--Optional, a tooltip to display when hovered over
+item.Tooltip = "A prayer to the rouge god to prevent fall dammage for the next 9 falls that you would have taken dammage, or for 5 minutes, whichever comes first."
+
+--Required Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network
+item.Serialize = function(self)
+ print("Trying to serailize!")
+ return ""
+end
+
+--Required, Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set.
+item.DeSerialize = function(self,string)
+ print("Trying to deserialize!")
+ return self
+end
+
+--Optional, when the player clicks this item, a menu will show up, if the menu item is clicked, the function is ran. This is all run client side, so if you want it to do something server side, you'll need to use the net library. Remember that items are in the shared domain, so you can define what it does in the same file!
+local prayedplayers = {}
+if SERVER then
+ util.AddNetworkString("art_prayer_ninelives")
+ net.Receive("art_prayer_ninelives",function(ln,ply)
+ if ply:HasItem("Nine Lives") then
+ prayedplayers[ply] = 9
+ timer.Simple(60 * 5,function()
+ prayedplayers[ply] = nil
+ end)
+ end
+ end)
+end
+function item.GetOptions(self)
+ local options = {}
+ options["Pray"] = function()
+ net.Start("art_prayer_ninelives")
+ net.SendToServer()
+ end
+ return options
+end
+hook.Add( "EntityTakeDamage" , "artery_ninelives" , function(ent,info)
+ if info:GetDamageType() == DMG_FALL and prayedplayers[ent] ~= nil and prayedplayers[ent] > 0 then
+ info:SetDamage(0)
+ end
+end)
+
+--Optional. Something run once when this item is drawn in a backpack
+function item.DoOnPanel(dimagebutton)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe.png")
+end
+
+--Optional. Something run once when this item is drawn in an equiped slot
+function item.DoOnEqupPanel(dimagebutton)
+ print("called with panel:",panel)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe_eq.png")
+end
+
+--Optional. Called continuously, use if you need the item to display different stuff at different tiems in the backpack.
+function item.Paint(self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+--Optional. Called continuously, use if you need the item to display different stuff at different tiems when equiped.
+function item.PaintEquiped(self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+--Required, the shape of this item in a backpack.
+item.Shape = {
+ {true},
+}
+
+ART.RegisterItem(item)
diff --git a/gamemode/shared/itemsystem/prayers/preditorinstinct.lua b/gamemode/shared/itemsystem/prayers/preditorinstinct.lua
new file mode 100644
index 0000000..8776c26
--- /dev/null
+++ b/gamemode/shared/itemsystem/prayers/preditorinstinct.lua
@@ -0,0 +1,98 @@
+--[[
+ An example item
+]]
+local item = {}
+
+--Required, a name, all item names must be unique
+item.Name = "Preditor Instinct"
+
+--Optional, a tooltip to display when hovered over
+item.Tooltip = "A prayer to the rouge god to grant you 30% movement when chaseing a wounded target"
+
+--Required Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network
+item.Serialize = function(self)
+ print("Trying to serailize!")
+ return ""
+end
+
+--Required, Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set.
+item.DeSerialize = function(self,string)
+ print("Trying to deserialize!")
+ return self
+end
+
+--Optional, when the player clicks this item, a menu will show up, if the menu item is clicked, the function is ran. This is all run client side, so if you want it to do something server side, you'll need to use the net library. Remember that items are in the shared domain, so you can define what it does in the same file!
+local prayedplayers = {}
+if SERVER then
+ util.AddNetworkString("art_prayer_preditorinstinct")
+ net.Receive("art_prayer_preditorinstinct",function(ln,ply)
+ if ply:HasItem(item.Name) then
+ prayedplayers[ply] = true
+ timer.Simple(60,function()
+ prayedplayers[ply] = nil
+ end)
+ end
+ end)
+end
+function item.GetOptions(self)
+ local options = {}
+ options["Pray"] = function()
+ net.Start("art_prayer_preditorinstinct")
+ net.SendToServer()
+ end
+ return options
+end
+--called continuously to buff players
+local buffedplayers = {}
+local function buffplayers()
+ for k,v in pairs(prayedplayers) do
+ if buffedplayers[k] ~= nil then continue end
+ --Find nearby wounded players or npcs
+ print("Checking if ", k, "should be buffed")
+ local wents = ents.FindInSphere(k:GetPos()+Vector(0,0,64),500)
+ for i,j in pairs(wents) do
+ print("Checking if ",j, "has taken dammage")
+ if k ~= j and j:Health() < j:GetMaxHealth() then
+ print("I buffed a player",k, "because ", j ,"has taken dammage")
+ k:SetWalkSpeed(k:GetWalkSpeed()*1.3)
+ buffedplayers[k] = true
+ timer.Simple(60,function()
+ k:SetWalkSpeed(k:GetWalkSpeed()*(1/1.3))
+ buffedplayers[k] = nil
+ end)
+ goto nextply
+ end
+ end
+ ::nextply::
+ end
+ timer.Simple(2,buffplayers)
+end
+buffplayers()
+
+--Optional. Something run once when this item is drawn in a backpack
+function item.DoOnPanel(dimagebutton)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe.png")
+end
+
+--Optional. Something run once when this item is drawn in an equiped slot
+function item.DoOnEqupPanel(dimagebutton)
+ print("called with panel:",panel)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe_eq.png")
+end
+
+--Optional. Called continuously, use if you need the item to display different stuff at different tiems in the backpack.
+function item.Paint(self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+--Optional. Called continuously, use if you need the item to display different stuff at different tiems when equiped.
+function item.PaintEquiped(self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+--Required, the shape of this item in a backpack.
+item.Shape = {
+ {true},
+}
+
+ART.RegisterItem(item)
diff --git a/gamemode/shared/itemsystem/prayers/thickskin.lua b/gamemode/shared/itemsystem/prayers/thickskin.lua
new file mode 100644
index 0000000..9dc77bd
--- /dev/null
+++ b/gamemode/shared/itemsystem/prayers/thickskin.lua
@@ -0,0 +1,78 @@
+--[[
+ An example item
+]]
+local item = {}
+
+--Required, a name, all item names must be unique
+item.Name = "Thick Skin"
+
+--Optional, a tooltip to display when hovered over
+item.Tooltip = "A prayer to the warrior god to grant you 20% resistance to all dammage"
+
+--Required Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network
+item.Serialize = function(self)
+ print("Trying to serailize!")
+ return ""
+end
+
+--Required, Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set.
+item.DeSerialize = function(self,string)
+ print("Trying to deserialize!")
+ return self
+end
+
+--Optional, when the player clicks this item, a menu will show up, if the menu item is clicked, the function is ran. This is all run client side, so if you want it to do something server side, you'll need to use the net library. Remember that items are in the shared domain, so you can define what it does in the same file!
+local prayedplayers = {}
+if SERVER then
+ util.AddNetworkString("art_prayer_thickskin")
+ net.Receive("art_prayer_thickskin",function(ln,ply)
+ if ply:HasItem("Thick Skin") then
+ prayedplayers[ply] = true
+ timer.Simple(120,function()
+ prayedplayers[ply] = nil
+ end)
+ end
+ end)
+end
+function item.GetOptions(self)
+ local options = {}
+ options["Pray"] = function()
+ print("I want to pray for thick skin!")
+ net.Start("art_prayer_thickskin")
+ net.SendToServer()
+ end
+ return options
+end
+hook.Add( "EntityTakeDamage" , "artery_thickskin" , function(ent,info)
+ if prayedplayers[ent] then
+ info:SetDamage(info:GetDamage()*0.8)
+ end
+end)
+
+--Optional. Something run once when this item is drawn in a backpack
+function item.DoOnPanel(dimagebutton)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe.png")
+end
+
+--Optional. Something run once when this item is drawn in an equiped slot
+function item.DoOnEqupPanel(dimagebutton)
+ print("called with panel:",panel)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe_eq.png")
+end
+
+--Optional. Called continuously, use if you need the item to display different stuff at different tiems in the backpack.
+function item.Paint(self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+--Optional. Called continuously, use if you need the item to display different stuff at different tiems when equiped.
+function item.PaintEquiped(self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+--Required, the shape of this item in a backpack.
+item.Shape = {
+ {true},
+}
+
+ART.RegisterItem(item)
diff --git a/gamemode/shared/itemsystem/quest/togglechip.lua b/gamemode/shared/itemsystem/quest/togglechip.lua
new file mode 100644
index 0000000..7b8ee04
--- /dev/null
+++ b/gamemode/shared/itemsystem/quest/togglechip.lua
@@ -0,0 +1,24 @@
+--[[
+ A toggle chip (quest item) for subterr_generator quest
+]]
+local item = {}
+
+item.Name = "Toggle Chip"
+
+item.Serialize = function(self)
+ print("Trying to serailize!")
+ return ""
+end
+
+item.DeSerialize = function(self,string)
+ print("Trying to deserialize!")
+ return self
+end
+
+item.Shape = {
+ {true,true},
+ {true,true},
+}
+
+print("Hello from togglechip.lua")
+ART.RegisterItem(item)
diff --git a/gamemode/shared/itemsystem/weapons/knuckledclaw.lua b/gamemode/shared/itemsystem/weapons/knuckledclaw.lua
new file mode 100644
index 0000000..7f610fa
--- /dev/null
+++ b/gamemode/shared/itemsystem/weapons/knuckledclaw.lua
@@ -0,0 +1,202 @@
+--[[
+ An example item
+]]
+local item = {}
+
+--Required, a name, all item names must be unique
+item.Name = "Scrap Hammer"
+
+--Optional, a tooltip to display
+item.Tooltip = "Bits of scrap put togeather to resembel a hammer"
+
+--Required Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network
+item.Serialize = function(self)
+ print("Trying to serailize!")
+ return ""
+end
+
+--Required, Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set.
+item.DeSerialize = function(self,string)
+ print("Trying to deserialize!")
+ return self
+end
+
+--Optional, when the player clicks this item, a menu will show up, if the menu item is clicked, the function is ran. This is all run client side, so if you want it to do something, you'll need to use the net library.
+function item.GetOptions(self)
+ local options = {}
+ options["test"] = function() print("You pressed test!") end
+ options["toste"] = function() print("You pressed toste!") end
+ return options
+end
+
+function item.DoOnPanel(dimagebutton)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe.png")
+end
+
+function item.DoOnEqupPanel(dimagebutton)
+ print("called with panel:",panel)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe_eq.png")
+end
+
+--[[
+function item.Paint(self,width,height)
+ --print("painting with values",self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+function item.PaintEquiped(self,width,height)
+ --print("painting with values",self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+]]
+
+--Required, the shape of this item.
+item.Shape = {
+ {true,true},
+}
+
+--Optional, If this item can be equiped in any player slots, put them here.
+item.Equipable = "Right"
+
+--[[ returns the direction the player swung]]
+local function playermovedir(player)
+ local vel = player:GetVelocity():GetNormalized()
+ vel.z = 0
+ local swings = {
+ {player:GetForward(),"forward"},
+ {-player:GetForward(),"backward"},
+ {player:GetRight(),"right"},
+ {-player:GetRight(),"left"}
+ }
+ table.sort(swings,function(a,b)
+ return vel:Dot(a[1]) > vel:Dot(b[1])
+ end)
+ return swings[1][2]
+end
+
+local positionset = {}
+
+local function swingarc(player,times,positions,onhit)
+ local positionpoints = {}
+ table.insert(positionset,positionpoints)
+ local hitents = {}
+ for k,v in ipairs(times) do
+ timer.Simple(v,function()
+ local weaponpos = positions[k] + player:GetPos()
+ table.insert(positionpoints,weaponpos)
+ if #positionpoints > 1 then
+ local tr = util.TraceLine({
+ start = positionpoints[#positionpoints-1],
+ endpos = positionpoints[#positionpoints],
+ })
+ if tr.Hit then
+ onhit(tr)
+ end
+ end
+ end)
+ end
+ timer.Simple(times[#times],function()
+ print("Inserted swing, drawn positions are now:")
+ PrintTable(positionset)
+ end)
+end
+
+
+
+--Optional, what to do when the player clicks, and this item is in the slot in inventory. only works for items equipable in left and right
+item.lastSwing = {}
+item.onClick = function(self,owner)
+ item.lastSwing[owner] = item.lastSwing[owner] or 0
+ if item.lastSwing[owner] > CurTime() then
+ print("returning because item.lastSwing is " .. item.lastSwing[owner], "but Curtime is",CurTime())
+ return end
+ item.lastSwing[owner] = CurTime()+1.25
+ local fow,rig,up = owner:GetForward(),owner:GetRight(),owner:GetUp()
+ local movementtbl = {
+ ["forward"] = function()
+ owner:SetLuaAnimation("fist_swing_up")
+ timer.Simple(2.33,function()
+ owner:StopLuaAnimation("fist_swing_up")
+ end)
+ local hits = ART.swingarc(owner,{
+ 0.5,0.57,0.65,0.73
+ },{
+ fow*20 + up*90,
+ fow*45 + up*70,
+ fow*35 + up*45,
+ fow*20 + up*30,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(4, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ ["backward"] = function()
+ owner:SetLuaAnimation("fist_swing_down")
+ timer.Simple(2.33,function()
+ owner:StopLuaAnimation("fist_swing_down")
+ end)
+ local hits = ART.swingarc(owner,{
+ 0.5,0.57,0.65,0.73
+ },{
+ fow*15 + up*30,
+ fow*35 + up*45,
+ fow*25 + up*70,
+ fow*15 + up*90,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(4, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ ["left"] = function()
+
+ end,
+ ["right"] = function()
+ owner:SetLuaAnimation("fist_swing_right")
+ timer.Simple(2.33,function()
+ owner:StopLuaAnimation("fist_swing_right")
+ end)
+ local hits = ART.swingarc(owner,{
+ 0.5,0.57,0.65,0.73
+ },{
+ rig*-30 + up*59,
+ rig*-10 + fow*30 + up*55,
+ rig*10 + fow*30 + up*54,
+ rig*30 + up*50,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(4, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ }
+ movementtbl[ART.playermovedir(owner)]()
+end
+
+--Optional, if we should do something special on equip(like draw the PAC for this weapon)
+item.onEquip = function(self,who)
+ print("onEquip",who)
+ if CLIENT then print("onEquip client!") end
+ if SERVER then
+ PrintTable(pac)
+ who:GetActiveWeapon():SetHoldType("fist")
+ ART.ApplyPAC(who,"knuckledclaws")
+ --local outfit = pac.luadata.ReadFile("pac3/mech.txt")
+ --who:AttachPACPart(outfit)
+ --print("onEquip server!")
+ end
+end
+
+--Optional, if we should do something speical on unequip(like setting animations back to normal)
+item.onUnEquip = function(self,who)
+ who:GetActiveWeapon():SetHoldType("normal")
+ ART.RemovePAC(who,"knuckledclaws")
+end
+
+print("Hello from scrapgun.lua")
+--Don't forget to register the item!
+ART.RegisterItem(item)
diff --git a/gamemode/shared/itemsystem/weapons/rustyaxe.lua b/gamemode/shared/itemsystem/weapons/rustyaxe.lua
new file mode 100644
index 0000000..71d8603
--- /dev/null
+++ b/gamemode/shared/itemsystem/weapons/rustyaxe.lua
@@ -0,0 +1,197 @@
+--[[
+ An example item
+]]
+local item = {}
+
+--Required, a name, all item names must be unique
+item.Name = "Rusty Axe"
+
+--Optional, a tooltip to display
+item.Tooltip = "An old axe, probably good for fighting."
+
+--Required Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network
+item.Serialize = function(self)
+ print("Trying to serailize!")
+ return ""
+end
+
+--Required, Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set.
+item.DeSerialize = function(self,string)
+ print("Trying to deserialize!")
+ return self
+end
+
+--Optional, when the player clicks this item, a menu will show up, if the menu item is clicked, the function is ran. This is all run client side, so if you want it to do something, you'll need to use the net library.
+function item.GetOptions(self)
+ local options = {}
+ options["test"] = function() print("You pressed test!") end
+ options["toste"] = function() print("You pressed toste!") end
+ return options
+end
+
+function item.DoOnPanel(dimagebutton)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe.png")
+end
+
+function item.DoOnEqupPanel(dimagebutton)
+ print("called with panel:",panel)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe_eq.png")
+end
+
+--Required, the shape of this item.
+item.Shape = {
+ {true,true},
+ {true},
+ {true},
+}
+
+--Optional, If this item can be equiped in any player slots, put them here.
+item.Equipable = "Right"
+
+--[[ returns the direction the player swung]]
+local function playermovedir(player)
+ local vel = player:GetVelocity():GetNormalized()
+ vel.z = 0
+ local swings = {
+ {player:GetForward(),"forward"},
+ {-player:GetForward(),"backward"},
+ {player:GetRight(),"right"},
+ {-player:GetRight(),"left"}
+ }
+ table.sort(swings,function(a,b)
+ return vel:Dot(a[1]) > vel:Dot(b[1])
+ end)
+ return swings[1][2]
+end
+
+local positionset = {}
+
+local function swingarc(player,times,positions,onhit)
+ local positionpoints = {}
+ table.insert(positionset,positionpoints)
+ local hitents = {}
+ for k,v in ipairs(times) do
+ timer.Simple(v,function()
+ local weaponpos = positions[k] + player:GetPos()
+ table.insert(positionpoints,weaponpos)
+ if #positionpoints > 1 then
+ local tr = util.TraceLine({
+ start = positionpoints[#positionpoints-1],
+ endpos = positionpoints[#positionpoints],
+ })
+ if tr.Hit then
+ onhit(tr)
+ end
+ end
+ end)
+ end
+ timer.Simple(times[#times],function()
+ print("Inserted swing, drawn positions are now:")
+ PrintTable(positionset)
+ end)
+end
+
+hook.Add( "HUDPaint", "weaponswings", function()
+ cam.Start3D() -- Start the 3D function so we can draw onto the screen.
+ for k,v in pairs(positionset) do
+ for i = 1,#v-1 do
+ render.DrawLine( v[i], v[i+1], Color(255,0,0,255), false )
+ end
+ end
+ --render.SetMaterial( material ) -- Tell render what material we want, in this case the flash from the gravgun
+ --render.DrawSprite( pos, 16, 16, white ) -- Draw the sprite in the middle of the map, at 16x16 in it's original colour with full alpha.
+ cam.End3D()
+end )
+
+--Optional, what to do when the player clicks, and this item is in the slot in inventory. only works for items equipable in left and right
+item.lastSwing = {}
+item.onClick = function(self,owner)
+ item.lastSwing[owner] = item.lastSwing[owner] or 0
+ if item.lastSwing[owner] > CurTime() then
+ print("returning because item.lastSwing is " .. item.lastSwing[owner], "but Curtime is",CurTime())
+ return end
+ item.lastSwing[owner] = CurTime()+1.33
+ local dir = playermovedir(owner)
+ local fow,rig,up = owner:GetForward(),owner:GetRight(),owner:GetUp()
+ local movementtbl = {
+ ["forward"] = function()
+ owner:SetLuaAnimation("axe_swing_up")
+ timer.Simple(2.33,function() owner:StopLuaAnimation("axe_swing_up") end)
+ local hits = swingarc(owner,{
+ 1,1.1,1.2,1.3
+ },{
+ fow*20 + up*90,
+ fow*45 + up*70,
+ fow*35 + up*45,
+ fow*20 + up*30,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(5, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ ["backward"] = function()
+
+ end,
+ ["left"] = function()
+ owner:SetLuaAnimation("axe_swing_left")
+ timer.Simple(2.33,function() owner:StopLuaAnimation("axe_swing_left") end)
+ local hits = swingarc(owner,{
+ 1,1.1,1.2,1.3
+ },{
+ rig*30 + up*59,
+ rig*10 + fow*30 + up*55,
+ rig*-10 + fow*30 + up*54,
+ rig*-30 + up*50,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(5, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ ["right"] = function()
+ owner:SetLuaAnimation("axe_swing_right")
+ timer.Simple(2.33,function() owner:StopLuaAnimation("axe_swing_right") end)
+ local hits = swingarc(owner,{
+ 1,1.1,1.2,1.3
+ },{
+ rig*-30 + up*59,
+ rig*-10 + fow*30 + up*55,
+ rig*10 + fow*30 + up*54,
+ rig*30 + up*50,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(5, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ }
+ movementtbl[playermovedir(owner)]()
+end
+
+--Optional, if we should do something special on equip(like draw the PAC for this weapon)
+item.onEquip = function(self,who)
+ print("onEquip",who)
+ if CLIENT then print("onEquip client!") end
+ if SERVER then
+ PrintTable(pac)
+ who:GetActiveWeapon():SetHoldType("melee")
+ ART.ApplyPAC(who,"rustyaxe")
+ --local outfit = pac.luadata.ReadFile("pac3/mech.txt")
+ --who:AttachPACPart(outfit)
+ --print("onEquip server!")
+ end
+end
+
+--Optional, if we should do something speical on unequip(like setting animations back to normal)
+item.onUnEquip = function(self,who)
+ who:GetActiveWeapon():SetHoldType("normal")
+ ART.RemovePAC(who,"rustyaxe")
+end
+
+print("Hello from scrapgun.lua")
+--Don't forget to register the item!
+ART.RegisterItem(item)
diff --git a/gamemode/shared/itemsystem/weapons/scraphammer.lua b/gamemode/shared/itemsystem/weapons/scraphammer.lua
new file mode 100644
index 0000000..978fde8
--- /dev/null
+++ b/gamemode/shared/itemsystem/weapons/scraphammer.lua
@@ -0,0 +1,204 @@
+--[[
+ An example item
+]]
+local item = {}
+
+--Required, a name, all item names must be unique
+item.Name = "Scrap Hammer"
+
+--Optional, a tooltip to display
+item.Tooltip = "Bits of scrap put togeather to resembel a hammer"
+
+--Required Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network
+item.Serialize = function(self)
+ print("Trying to serailize!")
+ return ""
+end
+
+--Required, Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set.
+item.DeSerialize = function(self,string)
+ print("Trying to deserialize!")
+ return self
+end
+
+--Optional, when the player clicks this item, a menu will show up, if the menu item is clicked, the function is ran. This is all run client side, so if you want it to do something, you'll need to use the net library.
+function item.GetOptions(self)
+ local options = {}
+ options["test"] = function() print("You pressed test!") end
+ options["toste"] = function() print("You pressed toste!") end
+ return options
+end
+
+function item.DoOnPanel(dimagebutton)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe.png")
+end
+
+function item.DoOnEqupPanel(dimagebutton)
+ print("called with panel:",panel)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe_eq.png")
+end
+
+--[[
+function item.Paint(self,width,height)
+ --print("painting with values",self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+function item.PaintEquiped(self,width,height)
+ --print("painting with values",self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+]]
+
+--Required, the shape of this item.
+item.Shape = {
+ {true,true,true},
+ {false,true},
+ {false,true},
+}
+
+--Optional, If this item can be equiped in any player slots, put them here.
+item.Equipable = "Right"
+
+--[[ returns the direction the player swung]]
+local function playermovedir(player)
+ local vel = player:GetVelocity():GetNormalized()
+ vel.z = 0
+ local swings = {
+ {player:GetForward(),"forward"},
+ {-player:GetForward(),"backward"},
+ {player:GetRight(),"right"},
+ {-player:GetRight(),"left"}
+ }
+ table.sort(swings,function(a,b)
+ return vel:Dot(a[1]) > vel:Dot(b[1])
+ end)
+ return swings[1][2]
+end
+
+local positionset = {}
+
+local function swingarc(player,times,positions,onhit)
+ local positionpoints = {}
+ table.insert(positionset,positionpoints)
+ local hitents = {}
+ for k,v in ipairs(times) do
+ timer.Simple(v,function()
+ local weaponpos = positions[k] + player:GetPos()
+ table.insert(positionpoints,weaponpos)
+ if #positionpoints > 1 then
+ local tr = util.TraceLine({
+ start = positionpoints[#positionpoints-1],
+ endpos = positionpoints[#positionpoints],
+ })
+ if tr.Hit then
+ onhit(tr)
+ end
+ end
+ end)
+ end
+ timer.Simple(times[#times],function()
+ print("Inserted swing, drawn positions are now:")
+ PrintTable(positionset)
+ end)
+end
+
+
+
+--Optional, what to do when the player clicks, and this item is in the slot in inventory. only works for items equipable in left and right
+item.lastSwing = {}
+item.onClick = function(self,owner)
+ item.lastSwing[owner] = item.lastSwing[owner] or 0
+ if item.lastSwing[owner] > CurTime() then
+ print("returning because item.lastSwing is " .. item.lastSwing[owner], "but Curtime is",CurTime())
+ return end
+ item.lastSwing[owner] = CurTime()+1.33
+ local fow,rig,up = owner:GetForward(),owner:GetRight(),owner:GetUp()
+ local movementtbl = {
+ ["forward"] = function()
+ owner:SetLuaAnimation("hammer_swing_up")
+ timer.Simple(2.33,function()
+ owner:StopLuaAnimation("hammer_swing_up")
+ end)
+ local hits = ART.swingarc(owner,{
+ 1,1.1,1.2,1.3
+ },{
+ fow*20 + up*90,
+ fow*45 + up*70,
+ fow*35 + up*45,
+ fow*20 + up*30,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(5, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ ["backward"] = function()
+
+ end,
+ ["left"] = function()
+ owner:SetLuaAnimation("hammer_swing_left")
+ timer.Simple(2.33,function()
+ owner:StopLuaAnimation("hammer_swing_left")
+ end)
+ local hits = ART.swingarc(owner,{
+ 1,1.1,1.2,1.3
+ },{
+ rig*30 + up*59,
+ rig*10 + fow*30 + up*55,
+ rig*-10 + fow*30 + up*54,
+ rig*-30 + up*50,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(10, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ ["right"] = function()
+ owner:SetLuaAnimation("hammer_swing_right")
+ timer.Simple(2.33,function()
+ owner:StopLuaAnimation("hammer_swing_right")
+ end)
+ local hits = ART.swingarc(owner,{
+ 1,1.1,1.2,1.3
+ },{
+ rig*-30 + up*59,
+ rig*-10 + fow*30 + up*55,
+ rig*10 + fow*30 + up*54,
+ rig*30 + up*50,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(5, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ }
+ movementtbl[ART.playermovedir(owner)]()
+end
+
+--Optional, if we should do something special on equip(like draw the PAC for this weapon)
+item.onEquip = function(self,who)
+ print("onEquip",who)
+ if CLIENT then print("onEquip client!") end
+ if SERVER then
+ PrintTable(pac)
+ who:GetActiveWeapon():SetHoldType("melee2")
+ ART.ApplyPAC(who,"scraphammer")
+ --local outfit = pac.luadata.ReadFile("pac3/mech.txt")
+ --who:AttachPACPart(outfit)
+ --print("onEquip server!")
+ end
+end
+
+--Optional, if we should do something speical on unequip(like setting animations back to normal)
+item.onUnEquip = function(self,who)
+ who:GetActiveWeapon():SetHoldType("normal")
+ ART.RemovePAC(who,"scraphammer")
+end
+
+print("Hello from scrapgun.lua")
+--Don't forget to register the item!
+ART.RegisterItem(item)
diff --git a/gamemode/shared/itemsystem/weapons/seratedknife.lua b/gamemode/shared/itemsystem/weapons/seratedknife.lua
new file mode 100644
index 0000000..8571074
--- /dev/null
+++ b/gamemode/shared/itemsystem/weapons/seratedknife.lua
@@ -0,0 +1,217 @@
+--[[
+ An example item
+]]
+local item = {}
+
+--Required, a name, all item names must be unique
+item.Name = "Scrap Hammer"
+
+--Optional, a tooltip to display
+item.Tooltip = "Bits of scrap put togeather to resembel a hammer"
+
+--Required Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network
+item.Serialize = function(self)
+ print("Trying to serailize!")
+ return ""
+end
+
+--Required, Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set.
+item.DeSerialize = function(self,string)
+ print("Trying to deserialize!")
+ return self
+end
+
+--Optional, when the player clicks this item, a menu will show up, if the menu item is clicked, the function is ran. This is all run client side, so if you want it to do something, you'll need to use the net library.
+function item.GetOptions(self)
+ local options = {}
+ options["test"] = function() print("You pressed test!") end
+ options["toste"] = function() print("You pressed toste!") end
+ return options
+end
+
+function item.DoOnPanel(dimagebutton)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe.png")
+end
+
+function item.DoOnEqupPanel(dimagebutton)
+ print("called with panel:",panel)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe_eq.png")
+end
+
+--[[
+function item.Paint(self,width,height)
+ --print("painting with values",self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+function item.PaintEquiped(self,width,height)
+ --print("painting with values",self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+]]
+
+--Required, the shape of this item.
+item.Shape = {
+ {true,true},
+}
+
+--Optional, If this item can be equiped in any player slots, put them here.
+item.Equipable = "Right"
+
+--[[ returns the direction the player swung]]
+local function playermovedir(player)
+ local vel = player:GetVelocity():GetNormalized()
+ vel.z = 0
+ local swings = {
+ {player:GetForward(),"forward"},
+ {-player:GetForward(),"backward"},
+ {player:GetRight(),"right"},
+ {-player:GetRight(),"left"}
+ }
+ table.sort(swings,function(a,b)
+ return vel:Dot(a[1]) > vel:Dot(b[1])
+ end)
+ return swings[1][2]
+end
+
+local positionset = {}
+
+local function swingarc(player,times,positions,onhit)
+ local positionpoints = {}
+ table.insert(positionset,positionpoints)
+ local hitents = {}
+ for k,v in ipairs(times) do
+ timer.Simple(v,function()
+ local weaponpos = positions[k] + player:GetPos()
+ table.insert(positionpoints,weaponpos)
+ if #positionpoints > 1 then
+ local tr = util.TraceLine({
+ start = positionpoints[#positionpoints-1],
+ endpos = positionpoints[#positionpoints],
+ })
+ if tr.Hit then
+ onhit(tr)
+ end
+ end
+ end)
+ end
+ timer.Simple(times[#times],function()
+ print("Inserted swing, drawn positions are now:")
+ PrintTable(positionset)
+ end)
+end
+
+
+
+--Optional, what to do when the player clicks, and this item is in the slot in inventory. only works for items equipable in left and right
+item.lastSwing = {}
+item.onClick = function(self,owner)
+ item.lastSwing[owner] = item.lastSwing[owner] or 0
+ if item.lastSwing[owner] > CurTime() then
+ print("returning because item.lastSwing is " .. item.lastSwing[owner], "but Curtime is",CurTime())
+ return end
+ item.lastSwing[owner] = CurTime()+1.25
+ local fow,rig,up = owner:GetForward(),owner:GetRight(),owner:GetUp()
+ local movementtbl = {
+ ["forward"] = function()
+ owner:SetLuaAnimation("knife_swing_up")
+ timer.Simple(2.33,function()
+ owner:StopLuaAnimation("knife_swing_up")
+ end)
+ local hits = ART.swingarc(owner,{
+ 0.5,0.611,0.722,0.833
+ },{
+ fow*20 + up*90,
+ fow*45 + up*70,
+ fow*35 + up*45,
+ fow*20 + up*30,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(4, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ ["backward"] = function()
+ owner:SetLuaAnimation("knife_swing_down")
+ timer.Simple(2.33,function()
+ owner:StopLuaAnimation("knife_swing_down")
+ end)
+ local hits = ART.swingarc(owner,{
+ 0.5,0.611,0.722,0.833
+ },{
+ fow*15 + up*30,
+ fow*35 + up*45,
+ fow*25 + up*70,
+ fow*15 + up*90,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(4, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ ["left"] = function()
+ owner:SetLuaAnimation("knife_swing_left")
+ timer.Simple(2.33,function()
+ owner:StopLuaAnimation("knife_swing_left")
+ end)
+ local hits = ART.swingarc(owner,{
+ 0.5,0.611,0.722,0.833
+ },{
+ rig*30 + up*59,
+ rig*10 + fow*30 + up*55,
+ rig*-10 + fow*30 + up*54,
+ rig*-30 + up*50,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(4, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ ["right"] = function()
+ owner:SetLuaAnimation("knife_swing_right")
+ timer.Simple(2.33,function()
+ owner:StopLuaAnimation("knife_swing_right")
+ end)
+ local hits = ART.swingarc(owner,{
+ 0.5,0.611,0.722,0.833
+ },{
+ rig*-30 + up*59,
+ rig*-10 + fow*30 + up*55,
+ rig*10 + fow*30 + up*54,
+ rig*30 + up*50,
+ },function(tr)
+ if tr.Entity.TakeDamage ~= nil and tr.Entity ~= owner then
+ tr.Entity:TakeDamage(4, owner, owner:GetActiveWeapon())
+ end
+ print("Hit",tr.Entity)
+ end)
+ end,
+ }
+ movementtbl[ART.playermovedir(owner)]()
+end
+
+--Optional, if we should do something special on equip(like draw the PAC for this weapon)
+item.onEquip = function(self,who)
+ print("onEquip",who)
+ if CLIENT then print("onEquip client!") end
+ if SERVER then
+ PrintTable(pac)
+ who:GetActiveWeapon():SetHoldType("knife")
+ ART.ApplyPAC(who,"seratedknife")
+ --local outfit = pac.luadata.ReadFile("pac3/mech.txt")
+ --who:AttachPACPart(outfit)
+ --print("onEquip server!")
+ end
+end
+
+--Optional, if we should do something speical on unequip(like setting animations back to normal)
+item.onUnEquip = function(self,who)
+ who:GetActiveWeapon():SetHoldType("normal")
+ ART.RemovePAC(who,"seratedknife")
+end
+
+--Don't forget to register the item!
+ART.RegisterItem(item)
diff --git a/gamemode/shared/itemsystem/weapons_common.lua b/gamemode/shared/itemsystem/weapons_common.lua
new file mode 100644
index 0000000..5da9b9a
--- /dev/null
+++ b/gamemode/shared/itemsystem/weapons_common.lua
@@ -0,0 +1,59 @@
+
+ART = ART or {}
+
+
+function ART.playermovedir(player)
+ local vel = player:GetVelocity():GetNormalized()
+ vel.z = 0
+ local swings = {
+ {player:GetForward(),"forward"},
+ {-player:GetForward(),"backward"},
+ {player:GetRight(),"right"},
+ {-player:GetRight(),"left"}
+ }
+ table.sort(swings,function(a,b)
+ return vel:Dot(a[1]) > vel:Dot(b[1])
+ end)
+ return swings[1][2]
+end
+
+local positionset = {}
+
+function ART.swingarc(player,times,positions,onhit)
+ local positionpoints = {}
+ table.insert(positionset,positionpoints)
+ local hitents = {}
+ for k,v in ipairs(times) do
+ timer.Simple(v,function()
+ local weaponpos = positions[k] + player:GetPos()
+ table.insert(positionpoints,weaponpos)
+ if #positionpoints > 1 then
+ local tr = util.TraceLine({
+ start = positionpoints[#positionpoints-1],
+ endpos = positionpoints[#positionpoints],
+ })
+ if tr.Hit then
+ onhit(tr)
+ end
+ end
+ end)
+ end
+ timer.Simple(times[#times],function()
+ print("Inserted swing, drawn positions are now:")
+ PrintTable(positionset)
+ end)
+end
+
+hook.Add( "HUDPaint", "weaponswings", function()
+ cam.Start3D() -- Start the 3D function so we can draw onto the screen.
+ for k,v in pairs(positionset) do
+ for i = 1,#v-1 do
+ render.DrawLine( v[i], v[i+1], Color(255,0,0,255), false )
+ end
+ end
+ --render.SetMaterial( material ) -- Tell render what material we want, in this case the flash from the gravgun
+ --render.DrawSprite( pos, 16, 16, white ) -- Draw the sprite in the middle of the map, at 16x16 in it's original colour with full alpha.
+ cam.End3D()
+end )
+
+return wcommon
diff --git a/gamemode/shared/loaditems.lua b/gamemode/shared/loaditems.lua
index 18260f2..8dc8abf 100644
--- a/gamemode/shared/loaditems.lua
+++ b/gamemode/shared/loaditems.lua
@@ -14,7 +14,7 @@ local defaultfields = {
["Shape"] = {{true}},
}
function ART.RegisterItem(tbl)
- print("Registering item:" .. tbl.Name)
+ --print("Registering item:" .. tbl.Name)
for k,v in pairs(requiredfields) do
assert(tbl[v] ~= nil, "Attempted to register an item without field:" .. v)
end
@@ -25,8 +25,8 @@ function ART.RegisterItem(tbl)
end
end
ART.Items[tbl.Name] = tbl
- print("Art is now:")
- PrintTable(ART)
+ --print("Art is now:")
+ --PrintTable(ART)
end
--autolua.AddLuaSHFolder("/shared/itemsystem")
diff --git a/gamemode/shared/lockbox/array.lua b/gamemode/shared/lockbox/array.lua
index 7ae89fc..8a2fd30 100644
--- a/gamemode/shared/lockbox/array.lua
+++ b/gamemode/shared/lockbox/array.lua
@@ -1,4 +1,3 @@
-print("Hello from array.lua!")
local String = string
local Bit = include("bit.lua");
diff --git a/gamemode/shared/npc_editor.lua b/gamemode/shared/npc_editor.lua
new file mode 100644
index 0000000..105ead8
--- /dev/null
+++ b/gamemode/shared/npc_editor.lua
@@ -0,0 +1,10 @@
+
+if SERVER then
+ local npcnodes = {}
+
+ local function spawnnpcnode()
+
+ end
+
+ concommand.Add("artery_makenpc",spawnnpcnode)
+end
diff --git a/gamemode/shared/questsystem/examplequest.lua b/gamemode/shared/questsystem/examplequest.lua
new file mode 100644
index 0000000..8605ab8
--- /dev/null
+++ b/gamemode/shared/questsystem/examplequest.lua
@@ -0,0 +1,13 @@
+if SERVER then return end
+local quest = {}
+
+quest.Name = "Example Quest"
+
+--[[
+ Given a DPanel, draw some text that the player can use when going through quests.
+]]
+function quest.DrawQuestInfo(panel, status)
+
+end
+
+ART.RegisterQuest(quest)
diff --git a/gamemode/shared/questsystem/subterr_generator.lua b/gamemode/shared/questsystem/subterr_generator.lua
new file mode 100644
index 0000000..9bb90c3
--- /dev/null
+++ b/gamemode/shared/questsystem/subterr_generator.lua
@@ -0,0 +1,24 @@
+if SERVER then return end
+local quest = {}
+
+quest.Name = "Subterr_generator"
+
+local questtext = {
+ [1] = "Visit the Tinkerer to see if he has a replacement Toggle Chip",
+ [2] = "V̶i̶s̶i̶t̶ ̶t̶h̶e̶ ̶T̶i̶n̶k̶e̶r̶e̶r̶ ̶t̶o̶ ̶s̶e̶e̶ ̶i̶f̶ ̶h̶e̶ ̶h̶a̶s̶ ̶a̶ ̶r̶e̶p̶l̶a̶c̶e̶m̶e̶n̶t̶ ̶T̶o̶g̶g̶l̶e̶ ̶C̶h̶i̶p̶\n\nGet the toggle chip back to Tom",
+ [3] = "V̶i̶s̶i̶t̶ ̶t̶h̶e̶ ̶T̶i̶n̶k̶e̶r̶e̶r̶ ̶t̶o̶ ̶s̶e̶e̶ ̶i̶f̶ ̶h̶e̶ ̶h̶a̶s̶ ̶a̶ ̶r̶e̶p̶l̶a̶c̶e̶m̶e̶n̶t̶ ̶T̶o̶g̶g̶l̶e̶ ̶C̶h̶i̶p̶\nG̶e̶t̶ ̶t̶h̶e̶ ̶t̶o̶g̶g̶l̶e̶ ̶c̶h̶i̶p̶ ̶b̶a̶c̶k̶ ̶t̶o̶ ̶T̶o̶m̶\nLooks like the generator is working again!\n(QUEST COMPLETE)"
+}
+
+quest.DrawQuestInfo = function(panel,status)
+ print("Drawing quest info!")
+ local label = vgui.Create( "DLabel", panel )
+ --label:Dock(FILL)
+ --label:Dock(BOTTOM)
+ label:SetSize((ScrW() / 4) - 20,(ScrH() / 2) - 50)
+ --label.Paint = function(self,w,h) draw.RoundedBox(4,0,0,w,h,Color(0,160,167)) end
+ label:SetWrap(true)
+ label:SetText( questtext[status] )
+ label:SetDark()
+end
+
+ART.RegisterQuest(quest)
diff --git a/gamemode/shared/sh_buff.lua b/gamemode/shared/sh_buff.lua
new file mode 100644
index 0000000..ac46df9
--- /dev/null
+++ b/gamemode/shared/sh_buff.lua
@@ -0,0 +1,31 @@
+--This was probably a mistake
+do return end
+
+local pmeta = FindMetaTable("Player")
+
+pmeta.buffs = {}
+local buffid = 0
+function pmeta:ApplyBuff(buff)
+ if self.buffs[buff.type] == nil then
+ self.buffs[buff.type] = {}
+ end
+ local id = buffid
+ buffid = buffid + 1
+ self.buffs[buff.type][id] = buff
+ self.buffs[id] = buff.type
+ return id
+end
+
+function pmeta:RemoveBuff(buffid)
+ local bufftype = self.buffs[buffid]
+ self.buffs[buff.type][buffid] = nil
+ self.buffs[buffid] = nil
+end
+
+hook.Add("EntityTakeDamage","arterybuffs",function(ent,info)
+
+end)
+
+--[[
+ Add buff types here I guess
+]]
diff --git a/gamemode/shared/sh_npcmap.lua b/gamemode/shared/sh_npcmap.lua
new file mode 100644
index 0000000..5c6d93c
--- /dev/null
+++ b/gamemode/shared/sh_npcmap.lua
@@ -0,0 +1,27 @@
+
+local pmeta = FindMetaTable("Player")
+
+if SERVER then
+ util.AddNetworkString("addmapicon")
+end
+
+function pmeta:AddMapIcon(icon,position)
+ print("adding map icon")
+ net.Start("addmapicon")
+ net.WriteString(icon)
+ net.WriteVector(position)
+ net.Send(self)
+end
+
+if CLIENT then
+ net.Receive("addmapicon",function()
+ print("got recieve for map icon")
+ LocalPlayer().MapIcons = LocalPlayer().MapIcons or {}
+ local matstr = net.ReadString()
+ local matpos = net.ReadVector()
+ table.insert(LocalPlayer().MapIcons,{
+ ["material"] = Material(matstr),
+ ["pos"] = matpos,
+ })
+ end)
+end
diff --git a/gamemode/shared/sh_pac.lua b/gamemode/shared/sh_pac.lua
new file mode 100644
index 0000000..baa7f0b
--- /dev/null
+++ b/gamemode/shared/sh_pac.lua
@@ -0,0 +1,107 @@
+--[[
+ All the functions related to networking pac's
+]]
+if CLIENT then
+ local function applypac(who,pacname)
+ local pactxt = file.Read("artery/pacs/"..pacname..".txt","DATA")
+ print("got pac txt",pactxt)
+ if pactxt == nil then
+ print("requesting pac")
+ net.Start("requestpac")
+ net.WriteString(pacname)
+ net.SendToServer()
+ timer.Simple(5,function() --5 seconds is probably enough time to load a pac, right?
+ print("trying to re-apply pac")
+ applypac(who,pacname)
+ end)
+ else
+ if who.AttachPACPart == nil then
+ print("setting up ent for pac")
+ pac.SetupENT(who)
+ end
+ print("pactxt was",pactxt)
+ local pactbl = CompileString("return {"..pactxt.."}",pacname)()
+ print("pactbl is")
+ PrintTable(pactbl)
+ who:AttachPACPart(pactbl)
+ print("Pac Equiped!")
+ end
+ end
+
+ local function removepac(who,pacname)
+ local pactxt = file.Read("artery/pacs/"..pacname..".txt","DATA")
+ assert(pactxt ~= nil, "Attempted to remove a pac that dosn't exist")
+ assert(who.RemovePACPart ~= nil,"That entity isn't set up to have pacs!")
+ local pactbl = CompileString("return {" .. pactxt .. "}", pacname)()
+ who:RemovePACPart(pactbl)
+ end
+
+ net.Receive("loadpac",function()
+ local pacname = net.ReadString()
+ local pacdata = util.Decompress(net.ReadString())
+ file.Write("artery/pacs/"..pacname..".txt",pacdata)
+ end)
+
+ net.Receive("applypac",function()
+ print("apply ing pac")
+ local towho = net.ReadEntity()
+ local pacname = net.ReadString()
+ applypac(towho,pacname)
+ end)
+
+ net.Receive("removepac",function()
+ local towho = net.ReadEntity()
+ local pacname = net.ReadString()
+ removepac(towho,pacname)
+ end)
+else
+ for _,v in pairs({
+ "applypac",
+ "removepac",
+ "requestpac",
+ "loadpac",
+ })do util.AddNetworkString(v) end
+
+ net.Receive("requestpac",function(ln,ply)
+ local pacname = net.ReadString()
+ local pacdata = file.Read("artery/pacs/"..pacname..".txt","DATA")
+ assert(pacdata ~= nil,string.format("Client %q requested pac that dosn't exist %q",ply:Nick(),pacname))
+ net.Start("loadpac")
+ net.WriteString(pacname)
+ net.WriteString(util.Compress(pacdata))
+ net.Send(ply)
+ end)
+
+ local playerpacs = {}
+ ART.ApplyPAC = function(to,pacname)
+ print("Applying pac")
+ net.Start("applypac")
+ net.WriteEntity(to)
+ net.WriteString(pacname)
+ net.Broadcast()
+ playerpacs[to] = playerpacs[to] or {}
+ table.insert(playerpacs[to],pacname)
+ end
+
+ hook.Add( "PlayerInitialSpawn", "loadpacs", function(ply)
+ timer.Simple(5,function() --Wait 5 seconds, hopefully they're ok to go by then
+ for k,v in pairs(playerpacs) do
+ for i,j in pairs(v) do
+ net.Start("applypac")
+ net.WriteEntity(k)
+ net.WriteString(j)
+ net.Send(ply)
+ end
+ end
+ end)
+ end)
+
+ ART.RemovePAC = function(to,pacname)
+ net.Start("removepac")
+ net.WriteEntity(to)
+ net.WriteString(pacname)
+ net.Broadcast()
+ table.RemoveByValue(playerpacs[to], pacname)
+ end
+end
+local paclist
diff --git a/gamemode/shared/sh_quests.lua b/gamemode/shared/sh_quests.lua
new file mode 100644
index 0000000..ace050a
--- /dev/null
+++ b/gamemode/shared/sh_quests.lua
@@ -0,0 +1,35 @@
+--[[
+ Details how quests are handeled
+]]
+
+local pmeta = FindMetaTable("Player")
+
+if SERVER then
+ util.AddNetworkString("synchquest")
+end
+
+function pmeta:SynchronizeQuest(name)
+ net.Start("synchquest")
+ net.WriteString(name)
+ net.WriteUInt(self.Quests[name],16)
+ net.Send(self)
+end
+
+if CLIENT then
+ net.Receive("synchquest",function()
+ LocalPlayer().Quests = LocalPlayer().Quests or {}
+ print("Got quest status")
+ local questname,queststatus = net.ReadString(), net.ReadUInt(16)
+ LocalPlayer().Quests[questname] = queststatus
+ end)
+
+ ART.Quests = ART.Quests or {}
+ function ART.RegisterQuest(tbl)
+ assert(ART.Quests[tbl.Name] == nil,"Tried to register two quests with the same name:" .. tbl.Name)
+ ART.Quests[tbl.Name] = tbl
+ end
+
+ function ART.GetQuest(name)
+ return ART.Quests[name]
+ end
+end