aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-08-09 17:53:52 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-08-09 17:53:52 -0400
commitd4f197a35c207c9891d3f4dc5e9708af48c935de (patch)
treeee8fd3960c3a3fb4ecaf0f62b50d251f007ebaf3
parent2fe3c4551344870e3784733fce2d95027b5c8382 (diff)
downloadartery-d4f197a35c207c9891d3f4dc5e9708af48c935de.tar.gz
artery-d4f197a35c207c9891d3f4dc5e9708af48c935de.tar.bz2
artery-d4f197a35c207c9891d3f4dc5e9708af48c935de.zip
Added some weapons
-rw-r--r--AUTHORS2
-rw-r--r--content/data/artery/maps/rp_subterranean/chests.txt0
-rw-r--r--content/data/artery/maps/rp_subterranean/npcs.txt1
-rw-r--r--content/img-src/maplol.xcfbin0 -> 25579 bytes
-rw-r--r--content/img-src/rustyaxe.xcfbin0 -> 34558 bytes
-rw-r--r--content/materials/art_tech.pngbin0 -> 8312 bytes
-rw-r--r--content/materials/chipicons/clock1.pngbin0 -> 329 bytes
-rw-r--r--content/materials/chipicons/clock2.pngbin0 -> 342 bytes
-rw-r--r--content/materials/weapons/rustyaxe/rustyaxe.pngbin0 -> 20774 bytes
-rw-r--r--content/materials/weapons/rustyaxe/rustyaxe_eq.pngbin0 -> 23581 bytes
-rw-r--r--data/artery/maps/rp_subterranean/chests.txt0
-rw-r--r--data/artery/maps/rp_subterranean/npcs.txt1
-rw-r--r--entities/entities/art_chest/cl_init.lua3
-rw-r--r--entities/entities/art_chipmill/cl_init.lua121
-rw-r--r--entities/entities/art_chipmill/init.lua81
-rw-r--r--entities/entities/art_chipmill/shared.lua30
-rw-r--r--entities/entities/art_serverchanger/cl_init.lua66
-rw-r--r--entities/entities/art_serverchanger/init.lua39
-rw-r--r--entities/entities/art_serverchanger/shared.lua21
-rw-r--r--entities/entities/info_townienode/cl_init.lua69
-rw-r--r--entities/entities/info_townienode/init.lua16
-rw-r--r--entities/entities/info_townienode/shared.lua23
-rw-r--r--entities/entities/npc_townie/cl_init.lua68
-rw-r--r--entities/entities/npc_townie/init.lua50
-rw-r--r--entities/entities/npc_townie/shared.lua156
-rw-r--r--entities/weapons/hands.lua29
-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
-rw-r--r--notes.txt9
67 files changed, 3525 insertions, 230 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..22f7876
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Alexander "Apickx" Pickering (alexandermpickering@gmail.com) - Most of artery
+William "JetBoom" Moodhe (williammoodhe@gmail.com) - Lua Animation API
diff --git a/content/data/artery/maps/rp_subterranean/chests.txt b/content/data/artery/maps/rp_subterranean/chests.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/content/data/artery/maps/rp_subterranean/chests.txt
diff --git a/content/data/artery/maps/rp_subterranean/npcs.txt b/content/data/artery/maps/rp_subterranean/npcs.txt
new file mode 100644
index 0000000..82b595a
--- /dev/null
+++ b/content/data/artery/maps/rp_subterranean/npcs.txt
@@ -0,0 +1 @@
+{"procedures":{"SetModel":["models/player/Group02/Male_01.mdl"]}}
diff --git a/content/img-src/maplol.xcf b/content/img-src/maplol.xcf
new file mode 100644
index 0000000..bde84cb
--- /dev/null
+++ b/content/img-src/maplol.xcf
Binary files differ
diff --git a/content/img-src/rustyaxe.xcf b/content/img-src/rustyaxe.xcf
new file mode 100644
index 0000000..856fa74
--- /dev/null
+++ b/content/img-src/rustyaxe.xcf
Binary files differ
diff --git a/content/materials/art_tech.png b/content/materials/art_tech.png
new file mode 100644
index 0000000..8de42b2
--- /dev/null
+++ b/content/materials/art_tech.png
Binary files differ
diff --git a/content/materials/chipicons/clock1.png b/content/materials/chipicons/clock1.png
new file mode 100644
index 0000000..8281f94
--- /dev/null
+++ b/content/materials/chipicons/clock1.png
Binary files differ
diff --git a/content/materials/chipicons/clock2.png b/content/materials/chipicons/clock2.png
new file mode 100644
index 0000000..4ec3bf9
--- /dev/null
+++ b/content/materials/chipicons/clock2.png
Binary files differ
diff --git a/content/materials/weapons/rustyaxe/rustyaxe.png b/content/materials/weapons/rustyaxe/rustyaxe.png
new file mode 100644
index 0000000..5006963
--- /dev/null
+++ b/content/materials/weapons/rustyaxe/rustyaxe.png
Binary files differ
diff --git a/content/materials/weapons/rustyaxe/rustyaxe_eq.png b/content/materials/weapons/rustyaxe/rustyaxe_eq.png
new file mode 100644
index 0000000..3e81432
--- /dev/null
+++ b/content/materials/weapons/rustyaxe/rustyaxe_eq.png
Binary files differ
diff --git a/data/artery/maps/rp_subterranean/chests.txt b/data/artery/maps/rp_subterranean/chests.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/data/artery/maps/rp_subterranean/chests.txt
diff --git a/data/artery/maps/rp_subterranean/npcs.txt b/data/artery/maps/rp_subterranean/npcs.txt
new file mode 100644
index 0000000..82b595a
--- /dev/null
+++ b/data/artery/maps/rp_subterranean/npcs.txt
@@ -0,0 +1 @@
+{"procedures":{"SetModel":["models/player/Group02/Male_01.mdl"]}}
diff --git a/entities/entities/art_chest/cl_init.lua b/entities/entities/art_chest/cl_init.lua
index 072d421..2907968 100644
--- a/entities/entities/art_chest/cl_init.lua
+++ b/entities/entities/art_chest/cl_init.lua
@@ -1,5 +1,6 @@
include('shared.lua')
-local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
+--local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
+local invfuncs = ART.invfuncs
ENT.RenderGroup = RENDERGROUP_BOTH
diff --git a/entities/entities/art_chipmill/cl_init.lua b/entities/entities/art_chipmill/cl_init.lua
new file mode 100644
index 0000000..6eb1d1f
--- /dev/null
+++ b/entities/entities/art_chipmill/cl_init.lua
@@ -0,0 +1,121 @@
+
+ART.chips = {}
+ART.RegisterChipType = function(tbl)
+ assert(ART.chips[tbl.Name] == nil,"Trying to register a chip twice:"..tbl.Name)
+ ART.chips[tbl.Name] = tbl
+end
+include('shared.lua')
+
+ENT.RenderGroup = RENDERGROUP_BOTH
+
+function ENT:Initialize()
+end
+
+function ENT:OnRemove()
+end
+
+function ENT:Think()
+end
+
+local function drawchipsavaliable(panel, chips)
+ for k,v in pairs(chips) do
+ local chiptbl = ART.chips[k]
+ local chippanel = vgui.Create("DPanel",panel)
+ chippanel:SetSize(64,80)
+ chippanel.chip = chiptbl
+ chippanel:Droppable("chiptype")
+ local chipitem = vgui.Create( "DImage",chippanel )
+ chipitem:SetMaterial( chiptbl:GetImage() )
+ chipitem:SetSize(64,64)
+ local chipname = vgui.Create("DLabel",chippanel)
+ chipname:SetPos( 0, 64 )
+ chipname:SetText( k )
+ chipname:SetDark(true)
+ chipname:SetContentAlignment(5)
+ --chipitem:Dock(TOP)
+ panel:AddItem(chippanel)
+ end
+end
+local workspacesize = {5,5}
+local workspacegridemptys = {}
+local workspacechips = {}
+for k=1,workspacesize[2] do
+ workspacechips[k] = {}
+end
+local function drawworkgrid(panel,blocks)
+ workspacegridemptys = {}
+ local grid = vgui.Create( "DGrid", panel )
+ grid:SetPos( 0, 0 )
+ grid:SetCols( workspacesize[1] )
+ grid:SetColWide( 64 )
+ grid:SetRowHeight(64)
+
+ for i = 1, workspacesize[1] * workspacesize[2] do
+ local griditem = vgui.Create( "DPanel" )
+ griditem:SetText( i )
+ griditem:SetSize( 64, 64 )
+ grid:AddItem( griditem )
+ griditem:Receiver( "chiptype", function(receiver,
+ tableOfDroppedPanels,
+ isDropped,
+ menuIndex,
+ mouseX,
+ mouseY )
+ local chiptbl = tableOfDroppedPanels[1].chip
+ print("Chiptable was:")
+ PrintTable(chiptbl)
+ print("Receiver was:",receiver)
+ if isDropped then
+ --workspacechips[i]
+ print("The icon was dropped on me!")
+ elseif griditem.image == nil then
+ for k,v in pairs(workspacegridemptys) do
+ if v.ghostimage == nil then continue end
+ v.ghostimage:Remove()
+ v.ghostimage = nil
+ end
+ griditem.ghostimage = vgui.Create( "DImage", griditem )
+ griditem.ghostimage:SetMaterial( chiptbl:GetImage() )
+ griditem.ghostimage:SetSize(64,64)
+ end
+ print("Something was dragged and dropped!")
+ end, {} )
+ table.insert(workspacegridemptys,griditem)
+ end
+end
+
+net.Receive("openchipmill",function()
+ local width,height = ScrW(),ScrH()
+ local chipframe = vgui.Create( "DFrame" )
+ chipframe:SetPos( width / 10, height / 10 )
+ chipframe:SetSize( width / 1.25, height / 1.25 )
+ chipframe:SetTitle( "Chip mill" )
+ chipframe:SetDraggable( true )
+ chipframe:MakePopup()
+
+ local chipsavaliable = {
+ ["Clock"] = 1,
+ }
+ chipsavaliablepanel = vgui.Create( "DPanel", chipframe )
+ chipsavaliablepanel:Dock(RIGHT)
+ local chipscroll = vgui.Create( "DScrollPanel", chipsavaliablepanel )
+ chipscroll:Dock(FILL)
+ drawchipsavaliable(chipscroll,chipsavaliable)
+
+ chipworkspace = vgui.Create( "DPanel",chipframe )
+ chipworkspace:Dock(FILL)
+ drawworkgrid(chipworkspace,{})
+
+ chiptools = vgui.Create( "DPanel",chipframe )
+ chiptools:Dock(LEFT)
+
+ millfunctions = vgui.Create( "DPanel",chipframe )
+ millfunctions:Dock(BOTTOM)
+
+
+end)
+
+function ENT:Draw()
+
+ self:DrawModel()
+end
diff --git a/entities/entities/art_chipmill/init.lua b/entities/entities/art_chipmill/init.lua
new file mode 100644
index 0000000..aa1f0e7
--- /dev/null
+++ b/entities/entities/art_chipmill/init.lua
@@ -0,0 +1,81 @@
+AddCSLuaFile( "cl_init.lua" )
+AddCSLuaFile( "shared.lua" )
+
+ART.RegisterChipType = function(tbl)
+ print("Trying to register chip type!")
+end
+include("shared.lua")
+
+local mdltbl = {
+{"models/props_c17/furnituretable002a.mdl",
+Vector(2,1,-30),
+Angle(0,-90,0)},
+{"models/props_junk/meathook001a.mdl",
+Vector(22,10,2),
+Angle(-1,126,160)},
+{"models/props_interiors/pot01a.mdl",
+Vector(2,-3,-13),
+Angle(0,180,180)},
+{"models/props_junk/metal_paintcan001a.mdl",
+Vector(-4,-2,-16),
+Angle(0,-45,0)},
+{"models/props_c17/furnituretable002a.mdl",
+Vector(2,-3,-30),
+Angle(85,-90,1)},
+{"models/props_c17/tools_wrench01a.mdl",
+Vector(-23,2,-10),
+Angle(-2,-26,0)},
+{"models/props_c17/trappropeller_lever.mdl",
+Vector(21,-2,-10),
+Angle(88,-104,63)},
+{"models/props_junk/garbage_takeoutcarton001a.mdl",
+Vector(23,11,11),
+Angle(-11,39,-179)},
+{"models/props_junk/garbage_milkcarton002a.mdl",
+Vector(17,6,16),
+Angle(71,34,177)},
+{"models/props_junk/garbage_metalcan001a.mdl",
+Vector(12,2,13),
+Angle(-5,-42,-162)},
+{"models/props_junk/flare.mdl",
+Vector(8,0,10),
+Angle(-13,-89,152)},
+}
+
+function ENT:Initialize()
+ self:SetModel("models/hunter/blocks/cube2x2x1.mdl")
+ self:SetAngles(Angle(90,90,180))
+ self:PhysicsInit( SOLID_VPHYSICS )
+ self:SetMoveType( MOVETYPE_NONE )
+ self:SetSolid( SOLID_VPHYSICS )
+ self:SetCollisionGroup( COLLISION_GROUP_INTERACTIVE )
+ self:SetUseType(SIMPLE_USE)
+
+ local phys = self:GetPhysicsObject()
+ --Wait a second so that we have a valid pos, self:GetPos() will return origin without this.
+ timer.Simple(1,function()
+ self:SetPos(self:GetPos() + Vector(0,0,30))
+ self:SetColor( Color( 0, 0, 0, 0 ) )
+ self:SetRenderMode( RENDERMODE_TRANSALPHA )
+ for k,v in pairs(mdltbl) do
+ print("Createing a " .. k)
+ local part = ents.Create("prop_dynamic")
+ part:SetModel(v[1])
+ part:SetPos(self:GetPos() + v[2])
+ part:SetAngles(v[3])
+ part:Spawn()
+ end
+ end)
+
+
+ phys:EnableMotion(false)
+ phys:Sleep()
+end
+
+util.AddNetworkString("openchipmill")
+
+function ENT:Use(ply)
+ net.Start("openchipmill")
+ net.WriteEntity(self)
+ net.Send(ply)
+end
diff --git a/entities/entities/art_chipmill/shared.lua b/entities/entities/art_chipmill/shared.lua
new file mode 100644
index 0000000..82eef2c
--- /dev/null
+++ b/entities/entities/art_chipmill/shared.lua
@@ -0,0 +1,30 @@
+ENT.Type = "anim"
+ENT.Base = "base_anim"
+
+--[[
+ The different kinds of chips
+]]
+
+local clockon = Material("materials/chipicons/clock1.png")
+local clockoff = Material("materials/chipicons/clock2.png")
+local clocktype = {
+ ["Name"] = "Clock",
+ ["GetImage"] = function(self)
+ if self.A == 1 then
+ return clockon
+ else
+ return clockoff
+ end
+ end,
+ ["OnTick"] = function(self)
+ self.A = self.A == 1 and 0 or 1
+ end,
+ ["Inputs"] = {},
+ ["Outputs"] = {
+ ["A"] = function(self)
+ return self.A
+ end,
+ },
+}
+
+ART.RegisterChipType(clocktype)
diff --git a/entities/entities/art_serverchanger/cl_init.lua b/entities/entities/art_serverchanger/cl_init.lua
new file mode 100644
index 0000000..ae9d143
--- /dev/null
+++ b/entities/entities/art_serverchanger/cl_init.lua
@@ -0,0 +1,66 @@
+include('shared.lua')
+
+ENT.RenderGroup = RENDERGROUP_BOTH
+
+/*---------------------------------------------------------
+ Name: Draw
+ Desc: Draw it!
+---------------------------------------------------------*/
+function ENT:Draw()
+ self:DrawModel()
+end
+
+/*---------------------------------------------------------
+ Name: DrawTranslucent
+ Desc: Draw translucent
+---------------------------------------------------------*/
+function ENT:DrawTranslucent()
+
+ -- This is here just to make it backwards compatible.
+ -- You shouldn't really be drawing your model here unless it's translucent
+
+ self:Draw()
+
+end
+
+/*---------------------------------------------------------
+ Name: BuildBonePositions
+ Desc:
+---------------------------------------------------------*/
+function ENT:BuildBonePositions( NumBones, NumPhysBones )
+
+ -- You can use this section to position the bones of
+ -- any animated model using self:SetBonePosition( BoneNum, Pos, Angle )
+
+ -- This will override any animation data and isn't meant as a
+ -- replacement for animations. We're using this to position the limbs
+ -- of ragdolls.
+
+end
+
+
+
+/*---------------------------------------------------------
+ Name: SetRagdollBones
+ Desc:
+---------------------------------------------------------*/
+function ENT:SetRagdollBones( bIn )
+
+ -- If this is set to true then the engine will call
+ -- DoRagdollBone (below) for each ragdoll bone.
+ -- It will then automatically fill in the rest of the bones
+
+ self.m_bRagdollSetup = bIn
+
+end
+
+
+/*---------------------------------------------------------
+ Name: DoRagdollBone
+ Desc:
+---------------------------------------------------------*/
+function ENT:DoRagdollBone( PhysBoneNum, BoneNum )
+
+ -- self:SetBonePosition( BoneNum, Pos, Angle )
+
+end
diff --git a/entities/entities/art_serverchanger/init.lua b/entities/entities/art_serverchanger/init.lua
new file mode 100644
index 0000000..ebb1e54
--- /dev/null
+++ b/entities/entities/art_serverchanger/init.lua
@@ -0,0 +1,39 @@
+
+AddCSLuaFile( "cl_init.lua" )
+AddCSLuaFile( "shared.lua" )
+
+include("shared.lua")
+
+function ENT:Initialize()
+ --print("NPC spawned!")
+ --self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE)
+ --self:SetUseType(SIMPLE_USE)
+
+ if(self.Model) then self:SetModel(self.Model)
+ else print("Server changer created without model, this might be a bug!") end
+
+ if self.Pos then self:SetPos(self.Pos)
+ else print("Server changer created without a position, this might be a bug!") end
+
+ if self.OnHit then self.PhysicsCollide = self.OnHit
+ else print("Server changer created without an OnHit, this might be a bug!") end
+
+ self.talking = false
+
+ if self.Name then self:SetName(self.Name)
+ else print("NPC created without a name! They won't be able to open doors!") end
+
+ if self.OnSpawn then self.OnSpawn(self) end
+
+ self:SetMoveType(MOVETYPE_NONE)
+ self:PhysicsInit(SOLID_OBB)
+ self:SetSolid(SOLID_VPHYSICS)
+
+ constraint.Weld(self,game.GetWorld(),0,0,0,true,true)
+
+end
+
+function ENT:PhysicsCollide(coldata,obj)
+ print("Physics collide detected")
+ if self.OnHit then self.OnHit(coldata,obj) end
+end
diff --git a/entities/entities/art_serverchanger/shared.lua b/entities/entities/art_serverchanger/shared.lua
new file mode 100644
index 0000000..b7fc605
--- /dev/null
+++ b/entities/entities/art_serverchanger/shared.lua
@@ -0,0 +1,21 @@
+ENT.Base = "base_entity"
+ENT.Type = "anim"
+//WS stuff
+ENT.Drops = nil
+ENT.OnDammage = nil
+ENT.Speed = 0
+ENT.Model = nil
+
+ENT.Behave = nil
+ENT.Act = nil
+
+/*---------------------------------------------------------
+ Name: OnRemove
+ Desc: Called just before entity is deleted
+---------------------------------------------------------*/
+function ENT:OnRemove()
+end
+
+function ENT:Use()
+
+end
diff --git a/entities/entities/info_townienode/cl_init.lua b/entities/entities/info_townienode/cl_init.lua
new file mode 100644
index 0000000..53dec09
--- /dev/null
+++ b/entities/entities/info_townienode/cl_init.lua
@@ -0,0 +1,69 @@
+include('shared.lua')
+
+ENT.RenderGroup = RENDERGROUP_BOTH
+
+/*---------------------------------------------------------
+ Name: Draw
+ Desc: Draw it!
+---------------------------------------------------------*/
+function ENT:Draw()
+ --self:DrawModel()
+ render.SetColorMaterial()
+ render.DrawSphere( self:GetPos(), 10, 30, 30, Color( 0, 175, 175, 100 ) )
+
+end
+
+/*---------------------------------------------------------
+ Name: DrawTranslucent
+ Desc: Draw translucent
+---------------------------------------------------------*/
+function ENT:DrawTranslucent()
+
+ // This is here just to make it backwards compatible.
+ // You shouldn't really be drawing your model here unless it's translucent
+
+ --self:Draw()
+
+end
+
+/*---------------------------------------------------------
+ Name: BuildBonePositions
+ Desc:
+---------------------------------------------------------*/
+function ENT:BuildBonePositions( NumBones, NumPhysBones )
+
+ // You can use this section to position the bones of
+ // any animated model using self:SetBonePosition( BoneNum, Pos, Angle )
+
+ // This will override any animation data and isn't meant as a
+ // replacement for animations. We're using this to position the limbs
+ // of ragdolls.
+
+end
+
+
+
+/*---------------------------------------------------------
+ Name: SetRagdollBones
+ Desc:
+---------------------------------------------------------*/
+function ENT:SetRagdollBones( bIn )
+
+ // If this is set to true then the engine will call
+ // DoRagdollBone (below) for each ragdoll bone.
+ // It will then automatically fill in the rest of the bones
+
+ self.m_bRagdollSetup = bIn
+
+end
+
+
+/*---------------------------------------------------------
+ Name: DoRagdollBone
+ Desc:
+---------------------------------------------------------*/
+function ENT:DoRagdollBone( PhysBoneNum, BoneNum )
+
+ // self:SetBonePosition( BoneNum, Pos, Angle )
+
+end
diff --git a/entities/entities/info_townienode/init.lua b/entities/entities/info_townienode/init.lua
new file mode 100644
index 0000000..9fa7f7e
--- /dev/null
+++ b/entities/entities/info_townienode/init.lua
@@ -0,0 +1,16 @@
+--[[
+ This entity gives townies things to do
+]]
+AddCSLuaFile( "cl_init.lua" )
+AddCSLuaFile( "shared.lua" )
+
+include("shared.lua")
+
+function ENT:Initialize()
+ self:SetModel("models/error.mdl")
+ self:SetMoveType(MOVETYPE_NONE)
+ self:SetSolid(SOLID_NONE)
+ self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE)
+ --self:SetNoDraw(true)
+ self:SetPos(self.Position)
+end
diff --git a/entities/entities/info_townienode/shared.lua b/entities/entities/info_townienode/shared.lua
new file mode 100644
index 0000000..8b42e7f
--- /dev/null
+++ b/entities/entities/info_townienode/shared.lua
@@ -0,0 +1,23 @@
+ENT.Base = "base_entity"
+
+//WS stuff
+ENT.Drops = nil
+ENT.OnDammage = nil
+ENT.Speed = 0
+ENT.Model = nil
+
+ENT.Behave = nil
+ENT.Act = nil
+
+/*---------------------------------------------------------
+ Name: OnRemove
+ Desc: Called just before entity is deleted
+---------------------------------------------------------*/
+function ENT:OnRemove()
+end
+
+function ENT:DoActivity(npc)
+ if not self.onActivity() then
+ print("Node without activity, this might be an error!")
+ end
+end
diff --git a/entities/entities/npc_townie/cl_init.lua b/entities/entities/npc_townie/cl_init.lua
index f941737..a8ba643 100644
--- a/entities/entities/npc_townie/cl_init.lua
+++ b/entities/entities/npc_townie/cl_init.lua
@@ -16,8 +16,8 @@ end
---------------------------------------------------------*/
function ENT:DrawTranslucent()
- // This is here just to make it backwards compatible.
- // You shouldn't really be drawing your model here unless it's translucent
+ -- This is here just to make it backwards compatible.
+ -- You shouldn't really be drawing your model here unless it's translucent
self:Draw()
@@ -29,12 +29,12 @@ end
---------------------------------------------------------*/
function ENT:BuildBonePositions( NumBones, NumPhysBones )
- // You can use this section to position the bones of
- // any animated model using self:SetBonePosition( BoneNum, Pos, Angle )
+ -- You can use this section to position the bones of
+ -- any animated model using self:SetBonePosition( BoneNum, Pos, Angle )
- // This will override any animation data and isn't meant as a
- // replacement for animations. We're using this to position the limbs
- // of ragdolls.
+ -- This will override any animation data and isn't meant as a
+ -- replacement for animations. We're using this to position the limbs
+ -- of ragdolls.
end
@@ -46,9 +46,9 @@ end
---------------------------------------------------------*/
function ENT:SetRagdollBones( bIn )
- // If this is set to true then the engine will call
- // DoRagdollBone (below) for each ragdoll bone.
- // It will then automatically fill in the rest of the bones
+ -- If this is set to true then the engine will call
+ -- DoRagdollBone (below) for each ragdoll bone.
+ -- It will then automatically fill in the rest of the bones
self.m_bRagdollSetup = bIn
@@ -61,6 +61,52 @@ end
---------------------------------------------------------*/
function ENT:DoRagdollBone( PhysBoneNum, BoneNum )
- // self:SetBonePosition( BoneNum, Pos, Angle )
+ -- self:SetBonePosition( BoneNum, Pos, Angle )
end
+
+local chatframe = nil
+
+net.Receive("opennpcdialog",function()
+ if chatframe ~= nil and chatframe:IsValid() then
+ chatframe:Remove()
+ chatframe = nil
+ end
+ local width, height = ScrW(), ScrH()
+ local who = net.ReadEntity()
+ local chattbl = net.ReadTable()
+ chatframe = vgui.Create( "DFrame" )
+ chatframe:SetPos( (width / 2) - (width / 4), height - (height / 4) )
+ chatframe:SetSize( width / 2, height / 4 )
+ chatframe:SetTitle( chattbl["Name"] )
+ chatframe:SetDraggable( true )
+ chatframe.OnClose = function()
+ net.Start("closenpcdialog")
+ net.WriteEntity(who)
+ net.SendToServer()
+ end
+
+ local chattxt = vgui.Create( "DLabel", chatframe )
+ --chattxt:SetPos( 40, 40 )
+ chattxt:SetText(chattbl["Message"])
+ chattxt:Dock(TOP)
+
+ for k,v in pairs(chattbl["Options"]) do
+ local chatbutton = vgui.Create( "DButton",chatframe )
+ --chatbutton:SetPos( 40, 40 )
+ chatbutton:SetText( v )
+ --chatbutton:SetSize( 120, 60 )
+ chatbutton.DoClick = function()
+ net.Start("updatenpcdialog")
+ net.WriteEntity(who)
+ net.WriteString(v)
+ net.SendToServer()
+ end
+ chatbutton:Dock(BOTTOM)
+ end
+ chattxt:Dock(FILL)
+
+
+
+ chatframe:MakePopup()
+end)
diff --git a/entities/entities/npc_townie/init.lua b/entities/entities/npc_townie/init.lua
index aa0f007..66cfaf1 100644
--- a/entities/entities/npc_townie/init.lua
+++ b/entities/entities/npc_townie/init.lua
@@ -6,12 +6,48 @@ include('shared.lua')
function ENT:Initialize()
--print("NPC spawned!")
- --self:SetMoveType(MOVETYPE_STEP)
- self:SetSolid(SOLID_OBB)
- --self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE)
+ --self:SetMoveType(MOVETYPE_VPHYSICS)
+ self:SetSolid(SOLID_BBOX )
+ self:SetCollisionGroup(COLLISION_GROUP_NPC )
+
+ self:SetHealth(50)
+
+ self.loco:SetDeathDropHeight(500) //default 200
+ self.loco:SetAcceleration(400) //default 400
+ self.loco:SetDeceleration(400) //default 400
+ self.loco:SetStepHeight(18) //default 18
+ self.loco:SetJumpHeight(25) //default 58
+ self.loco:SetDesiredSpeed( 50 )
+
+ self.nodereached = false
+
+ self.lastdooropen = CurTime()
if(self.Model) then self:SetModel(self.Model)
else print("NPC created without model, this might be a bug!") end
+
+ if self.Pos then self:SetPos(self.Pos)
+ else print("NPC created without a position, this might be a bug!") end
+
+ self.talking = false
+
+ if self.Name then self:SetName(self.Name)
+ else print("NPC created without a name! They won't be able to open doors!") end
+
+ if self.OnSpawn then self.OnSpawn(self) end
+
+ self.allowedNodes = {}
+
+ for k,v in pairs(ents.FindByClass( "info_townienode" ) ) do
+ if self.NavNodes[v.Name] then
+ table.insert(self.allowedNodes,v)
+ end
+ end
+
+ self:SetUseType( SIMPLE_USE )
+
+ self.DialogCursors = {}
+ --[[
if(not self.Stats) then
print("NPC created without any stats, this is a bug!")
return
@@ -24,6 +60,7 @@ function ENT:Initialize()
if(self.Stats["Step"]) then self.loco:SetJumpHeight(self.Stats["Step"]) end
if(self.OnSpawn) then self:OnSpawn() end
--self:SetModel( "models/Humans/Group01/Female_01.mdl" )
+ ]]
--[[
self:SetHullType( HULL_HUMAN );
self:SetHullSizeNormal();
@@ -46,13 +83,6 @@ function ENT:OnInjured(dmg)
if self.OnDammage != nil then self:OnDammage(dmg) end
end
-function ENT:OnContact(ent)
- if(ent:GetClass() == "ws_arrow") then
- self:TakeDamage(30)
- ent:SetParent(self)
- end
-end
-
function ENT:OnKilled(dmg)
if(CLIENT) then return end
if not self.Drops then return end
diff --git a/entities/entities/npc_townie/shared.lua b/entities/entities/npc_townie/shared.lua
index 3662edd..437275a 100644
--- a/entities/entities/npc_townie/shared.lua
+++ b/entities/entities/npc_townie/shared.lua
@@ -104,20 +104,158 @@ function ENT:Use()
end
+function ENT:OnStuck()
+ print("I'm stuck!")
+ self.curnode = self:selectNewNode()
+ self.nodereached = false
+end
+
+function ENT:selectNewNode()
+ --print("selectNewNode called")
+ --debug.Trace()
+ --print("Selecting from nodes")
+ --PrintTable(self.allowedNodes)
+ --local nodes = ents.FindByClass("info_townienode")
+ if #self.allowedNodes == 0 then return end
+ local rnode = table.Random(self.allowedNodes)
+ return rnode
+end
+
+local removeblock = {
+ ["prop_door_rotating"] = function(bot,ent)
+ ent:Fire("OpenAwayFrom",bot:GetName())
+ --Couln't get it to open correct direction, back up and go through
+ timer.Simple(3,function()
+ ent:Fire("Close")
+ end)
+ end
+}
+
function ENT:BehaveUpdate(num)
- --print(num)
- --self:BehaveUpdate(num)
+ if not self.BehaveThread then return end
+ if self.curnode ~= nil and self.curnode:IsValid() then
+ if self.curnode:GetPos():Distance(self:GetPos()) < 5 then
+ if self.nodereached == false then
+ self.curnode.OnReached(self)
+ self.nodereached = true
+ else
+ if self.curnode.IsDone(self) then
+ print("Finished action")
+ self.curnode = self:selectNewNode()
+ self.nodereached = false
+ end
+ end
+ end
+ end
+ local trdata = {
+ ["start"] = self:GetPos() + (self:GetUp()*72),
+ ["endpos"] = self:GetPos() + (self:GetUp()*72) + (self:GetForward()*32),
+ ["filter"] = self
+ }
+ local tr = util.TraceLine(trdata)
+ if tr.Hit then
+ --print(tr.Entity)
+ if removeblock[tr.Entity:GetClass()] ~= nil then
+ removeblock[tr.Entity:GetClass()](self,tr.Entity)
+ end
+ end
+ local ok, message = coroutine.resume( self.BehaveThread )
+ if ( ok == false ) then
- if(self.BehaveUpdate) then
- self:BehaveUpdate(num)
- end
+
+ self.BehaveThread = nil
+ Msg( self, "error: ", message, "\n" );
+
+
+ end
end
function ENT:RunBehaviour()
- if(self.Behave) then
- self:Behave()
- else
- self:DefaultBehaviour()
+ while true do
+ --print("In runbehaviour")
+ local opts = { lookahead = 300,
+ tolerance = 20,
+ draw = true,
+ maxage = 1,
+ repath = 0.1 }
+ if self.curnode == nil or not self.curnode:IsValid() or self.curnode:GetPos():Distance(self:GetPos()) < 5 then
+ self.curnode = self:selectNewNode()
+ end
+ if self.curnode == nil then
+ print("Townie could not find any nodes!")
+ while true do
+ coroutine.yield()
+ end
+ end
+ if self.curnode ~= nil and self.curnode:IsValid() then
+ self:MoveToPos( self.curnode:GetPos(), opts )
+ self:StartActivity(ACT_WALK )
+ end
+ --print("Called movetopos")
+ coroutine.yield()
+ end
+end
+
+if SERVER then
+ util.AddNetworkString( "opennpcdialog" )
+ util.AddNetworkString( "closenpcdialog" )
+ util.AddNetworkString( "updatenpcdialog")
+end
+
+--Fix the dialog so we aren't sending functions
+function SendableDialog(tbl)
+ local ntbl = table.Copy(tbl)
+ ntbl["Options"] = table.GetKeys(tbl["Options"])
+ return ntbl
+end
+
+net.Receive("closenpcdialog",function(len,ply)
+ print("player closed dialog1")
+ local npc = net.ReadEntity()
+ print("player closed dialog")
+ npc.DialogCursors[ply] = nil
+ if next(npc.DialogCursors) == nil then -- no one is talking to us, resume movement
+ if npc.loco:GetMaxYawRate() == 0 and npc.loco:GetAcceleration() == 0 then
+ npc.loco:SetMaxYawRate(npc.oyaw)
+ npc.loco:SetAcceleration(npc.oacc)
+ end
end
+end)
+
+net.Receive("updatenpcdialog",function(len,ply)
+ local npc = net.ReadEntity()
+ local option = net.ReadString()
+ npc.DialogCursors[ply] = npc.DialogCursors[ply]["Options"][option](ply)
+ net.Start("opennpcdialog")
+ net.WriteEntity(npc)
+ net.WriteTable(SendableDialog(npc.DialogCursors[ply]))
+ net.Send(ply)
+end)
+
+function ENT:Use(ply)
+ self.DialogCursors[ply] = self.getDialogFor(ply)
+ --
+ if self.oyaw ~= 0 and self.oacc ~= 0 then
+ self.oyaw, self.oacc,self.onod = self.loco:GetMaxYawRate(), self.loco:GetAcceleration(), self.curnode
+ end
+ self.loco:SetAcceleration(0)
+ self.loco:SetVelocity(Vector(0,0,0))
+ self.loco:SetMaxYawRate(9999990)
+ self.loco:FaceTowards(ply:GetPos())
+ self.loco:SetMaxYawRate(0)
+ timer.Simple(0.5,function()
+ --self.loco:FaceTowards(ply:GetPos())
+
+
+ end)
+ net.Start("opennpcdialog")
+ net.WriteEntity(self)
+ net.WriteTable(SendableDialog(self.DialogCursors[ply]))
+ net.Send(ply)
+end
+
+function ENT:OnClose()
+ self.loco:SetMaxYawRate(self.oyaw)
+ self.loco:SetAcceleration(self.oacc)
end
diff --git a/entities/weapons/hands.lua b/entities/weapons/hands.lua
index 3d74aa3..c97249a 100644
--- a/entities/weapons/hands.lua
+++ b/entities/weapons/hands.lua
@@ -77,31 +77,10 @@ function SWEP:PrimaryAttack()
end
function SWEP:SecondaryAttack()
- --[[
- if (CLIENT and !IsFirstTimePredicted()) then return end
- if (!self.Owner.Weapons or !self.Owner.Weapons[self.Owner.Select]) then return end
- if (self.Owner.CD and self.Owner.CD > CurTime()) then return end
-
- local item = self.Owner.Weapons[self.Owner.Select].Item
-
- if (!item or !item.OnSecondary) then return end
-
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
-
- local Trace = {
- start = self.Owner:GetShootPos(),
- endpos = self.Owner:GetShootPos()+self.Owner:GetAimVector()*item.Range,
- filter = self.Owner,
- mins = Box*-1,
- maxs = Box,
- }
-
- local Tr = util.TraceHull(Trace)
-
- item:OnSecondary(self.Owner,Tr)
-
- self.Owner.CD = CurTime()+item.CD
- ]]
+ local rightitem = self.Owner.Inventory.Equiped["Right"]
+ if rightitem ~= false and rightitem.onClick ~= nil then
+ rightitem:onClick(self.Owner)
+ end
end
if (CLIENT) then
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
diff --git a/notes.txt b/notes.txt
new file mode 100644
index 0000000..7288be9
--- /dev/null
+++ b/notes.txt
@@ -0,0 +1,9 @@
+Bits and bobs, roughly documentation
+ Items are in gamemode/shared/itemsystem
+
+
+Quests, Inventory, and Skills might all potentially do mysql injection, be careful in their creation, and don't let users enter any fields about them!
+
+When createing new files, make sure the file has some text in it (even just a comment explaining what the file will eventually hold) include() will crash the game if called on an empty file.
+
+If your server starts breaking after a while, it's probably the fault of /gamemode/shared/sh_buff.lua, no you can't put a bandaid on it or fix it, you have to re-write it.