diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-08-09 17:53:52 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-08-09 17:53:52 -0400 |
| commit | d4f197a35c207c9891d3f4dc5e9708af48c935de (patch) | |
| tree | ee8fd3960c3a3fb4ecaf0f62b50d251f007ebaf3 /gamemode/shared | |
| parent | 2fe3c4551344870e3784733fce2d95027b5c8382 (diff) | |
| download | artery-d4f197a35c207c9891d3f4dc5e9708af48c935de.tar.gz artery-d4f197a35c207c9891d3f4dc5e9708af48c935de.tar.bz2 artery-d4f197a35c207c9891d3f4dc5e9708af48c935de.zip | |
Added some weapons
Diffstat (limited to 'gamemode/shared')
27 files changed, 2267 insertions, 43 deletions
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 |
