aboutsummaryrefslogtreecommitdiff
path: root/gamemode/shared
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-08-27 17:08:46 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-08-27 17:08:46 -0400
commit9adcb3c73a8d0e7ecfe66b30da630c6c2e67f03a (patch)
treed65b57e144317e5b49ccdd549b2f97c61d54bd1d /gamemode/shared
parentd4f197a35c207c9891d3f4dc5e9708af48c935de (diff)
downloadartery-9adcb3c73a8d0e7ecfe66b30da630c6c2e67f03a.tar.gz
artery-9adcb3c73a8d0e7ecfe66b30da630c6c2e67f03a.tar.bz2
artery-9adcb3c73a8d0e7ecfe66b30da630c6c2e67f03a.zip
Moved prayers to their own system
Diffstat (limited to 'gamemode/shared')
-rw-r--r--gamemode/shared/animations/swing_knife.lua51
-rw-r--r--gamemode/shared/inventory.lua168
-rw-r--r--gamemode/shared/itemsystem/armor/balaclava.lua81
-rw-r--r--gamemode/shared/itemsystem/quest/rougebook.lua61
-rw-r--r--gamemode/shared/itemsystem/utility/flashlight.lua (renamed from gamemode/shared/itemsystem/prayers/ninelives.lua)59
-rw-r--r--gamemode/shared/itemsystem/weapons/knuckledclaw.lua18
-rw-r--r--gamemode/shared/itemsystem/weapons/seratedknife.lua13
-rw-r--r--gamemode/shared/itemsystem/weapons_common.lua12
-rw-r--r--gamemode/shared/loaditems.lua3
-rw-r--r--gamemode/shared/loadprayers.lua120
-rw-r--r--gamemode/shared/npc_editor.lua10
-rw-r--r--gamemode/shared/prayersystem/prayers/lesserevasion.lua64
-rw-r--r--gamemode/shared/prayersystem/prayers/ninelives.lua51
-rw-r--r--gamemode/shared/prayersystem/prayers/notdarkrp.lua77
-rw-r--r--gamemode/shared/prayersystem/prayers/preditorinstinct.lua (renamed from gamemode/shared/itemsystem/prayers/preditorinstinct.lua)51
-rw-r--r--gamemode/shared/prayersystem/prayers/thickskin.lua (renamed from gamemode/shared/itemsystem/prayers/thickskin.lua)39
16 files changed, 678 insertions, 200 deletions
diff --git a/gamemode/shared/animations/swing_knife.lua b/gamemode/shared/animations/swing_knife.lua
index 7dc9520..f0bdec1 100644
--- a/gamemode/shared/animations/swing_knife.lua
+++ b/gamemode/shared/animations/swing_knife.lua
@@ -90,50 +90,39 @@ RegisterLuaAnimation('knife_swing_down', {
Type = TYPE_GESTURE
})
-RegisterLuaAnimation('swing_hammer_left', {
+RegisterLuaAnimation('knife_swing_left', {
FrameData = {
{
BoneInfo = {
['ValveBiped.Bip01_R_UpperArm'] = {
- RU = -85.901,
- RR = -26.4874,
- RF = -25.791
+ RU = -40.5,
+ RR = 35.8237,
+ RF = -2.4531
},
- ['ValveBiped.Bip01_R_Hand'] = {
- },
- ['ValveBiped.Bip01_L_Clavicle'] = {
- RR = 87.4193
- },
- ['ValveBiped.Bip01_R_Clavicle'] = {
+ ['ValveBiped.Bip01_L_Forearm'] = {
},
['ValveBiped.Bip01_R_Forearm'] = {
- RU = 63.6936,
- RR = -12.6269,
- RF = -50.5597
+ RU = 48.9612,
+ RR = -3.439,
+ RF = 113.0487
}
},
- FrameRate = 1
+ FrameRate = 2
},
{
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
+ RU = -90.2023,
+ RR = -13.4254,
+ RF = -0.9856
},
- ['ValveBiped.Bip01_L_Clavicle'] = {
- RR = -0.2696
+ ['ValveBiped.Bip01_L_Forearm'] = {
+ RU = 27.1628
},
['ValveBiped.Bip01_R_Forearm'] = {
- RU = 99.5046,
- RR = 8.5341,
- RF = -60.8322
+ RU = 21.9228,
+ RR = -47.3655,
+ RF = 118.0344
}
},
FrameRate = 3
@@ -142,11 +131,7 @@ RegisterLuaAnimation('swing_hammer_left', {
BoneInfo = {
['ValveBiped.Bip01_R_UpperArm'] = {
},
- ['ValveBiped.Bip01_R_Hand'] = {
- },
- ['ValveBiped.Bip01_L_Clavicle'] = {
- },
- ['ValveBiped.Bip01_R_Clavicle'] = {
+ ['ValveBiped.Bip01_L_Forearm'] = {
},
['ValveBiped.Bip01_R_Forearm'] = {
}
diff --git a/gamemode/shared/inventory.lua b/gamemode/shared/inventory.lua
index 9cc8fca..382ebd5 100644
--- a/gamemode/shared/inventory.lua
+++ b/gamemode/shared/inventory.lua
@@ -10,8 +10,11 @@ local invfuncs = include("inventory_common.lua")
--A 2d array of the inventory.
pmeta.Inventory = pmeta.Inventory or {}
+--Money
+pmeta.Inventory.Credits = pmeta.Inventory.Credits or 0
--each backpack has 1:a tbl containing items or false, 2: a tbl {width,height} and 3:name
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 or {}
local equipedslots = {
@@ -21,6 +24,38 @@ for _,v in pairs(equipedslots) do
pmeta.Inventory.Equiped[v] = pmeta.Inventory.Equiped[v] or false
end
+if SERVER then
+ --- Gets a player's credits.
+ -- Gets the number of credits a player has
+ -- @return The number of credits for this player
+ function pmeta:GetCredits()
+ return self.Inventory.Credits
+ end
+
+ util.AddNetworkString( "art_synch_credits" )
+ local function SynchCredits(ply)
+ net.Start("art_synch_credits")
+ net.WriteUInt(ply.Inventory.Credits,32)
+ net.Send(ply)
+ end
+
+ --- Sets a player's credits.
+ -- Sets the number of credits this player has. Credits are synchronized after every set
+ -- @param num The number of credits to set on the player
+ function pmeta:SetCredits(num)
+ self.Inventory.Credits = num
+ SynchCredits(self)
+ end
+
+end
+
+if CLIENT then
+ net.Receive("art_synch_credits",function()
+ ART.Credits = net.ReadUInt(32)
+ print("I updated my credits! now:", ART.Credits)
+ end)
+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
@@ -50,14 +85,28 @@ function pmeta:FindSpotForItem(item)
end
end
---- Checks if the player has an item by name
---
-function pmeta:HasItem(itemname)
+local function DefaultCompare(item, itemname)
+ return item.Name == itemname
+end
+
+--- Checks if the player has an item.
+-- Check to see if the player has an item. Supply the name of the item, or supply a function that takes 2 items, and returns true if they are equial. If any of the returns are nil, then all the the returns will be nil, and the item could not be found.
+-- @param nameorcomparitor The item name as a string, or a function that returns true when given an item that you want.
+-- @return row The row the items was found in
+-- @return col The column the item was found in
+-- @return n The backpack number the item was found in.
+function pmeta:HasItem(nameorcomparitor)
+ local comparitor
+ if type(param) == "String" then
+ comparitor = function(t) return t.Name == nameorcomparitor end
+ else
+ comparitor = nameorcomparitor
+ end
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
+ if itemin ~= false and comparitor(itemin) then
return row,col,n
end
end
@@ -65,6 +114,11 @@ function pmeta:HasItem(itemname)
end
end
+--- Removes an item.
+-- Remoes an item in the backpack of the player
+-- @param backpack The backpack to remove the item from
+-- @param row The row in the backpack the item is located at
+-- @param col The column in the backpack the item is located at
function pmeta:RemoveItemAt(backpack,row,col)
local item = self.Inventory.Backpacks[backpack][1][row][col]
for k = 1,#item.Shape do
@@ -75,12 +129,21 @@ function pmeta:RemoveItemAt(backpack,row,col)
self:SynchronizeInventory()
end
+--- Gives an item to a player.
+-- Gives an item to the player in the next avaliable slot the item can fit in
+-- @param item The item to give the player
function pmeta:GiveItem(item)
local x,y,b = self:FindSpotForItem(item)
self:PutInvItem(b,x,y,item)
self:SynchronizeInventory()
end
+--- Check if an item can fit in a position in a backpack
+-- Check if an item can fit in a specific position in a specific backpack
+-- @param backpack The backpack to try to fit the item in
+-- @param x The row to try to fit the item in
+-- @param y The column to try to fit the item in
+-- @return bool If the item can fit in the backpack
function pmeta:CanFitInBackpack(backpack,x,y,item)
return invfuncs.CanFitInBackpack(backpack,x,y,item)
end
@@ -92,50 +155,71 @@ if SERVER then
util.AddNetworkString("unequipitem")
end
-net.Receive("unequipitem",function(len,ply)
- local itemslot = net.ReadString()
- local tobackpack = net.ReadUInt(16)
- local topos = {}
- topos[1] = net.ReadUInt(16)
- topos[2] = net.ReadUInt(16)
- local item = ply.Inventory.Equiped[itemslot]
- if ply:CanFitInBackpack(
- ply.Inventory.Backpacks[tobackpack],
- topos[1],
- topos[2],
+--- Unequips an item.
+-- Unequips an item, and puts it in the specified backpack (makes sure that it's possible first)
+-- @param equipslot The equipment slot the item is in right now
+-- @param backpack The destination backpack to put the item into
+-- @param row The row in the backpack to put the item
+-- @param col The column in the backpack to put the item
+function pmeta:UnEquip(equipslot, backpack, row, col)
+ local item = self.Inventory.Equiped[equipslot]
+ if self:CanFitInBackpack(
+ self.Inventory.Backpacks[backpack],
+ row,
+ col,
item
) then
- ply.Inventory.Equiped[itemslot] = false
- ply:PutInvItem(tobackpack,topos[1],topos[2],item)
+ self.Inventory.Equiped[equipslot] = false
+ self:PutInvItem(tobackpack,row,col,item)
if item.onUnEquip ~= nil then
- item:onUnEquip(ply)
+ item:onUnEquip(self)
end
- ply:SynchronizeInventory()
+ self:SynchronizeInventory()
+ else
+ error("Could not fit item in backpack, client might be de-synchronized")
end
+end
+
+net.Receive("unequipitem",function(len,ply)
+ local itemslot = net.ReadString()
+ local tobackpack = net.ReadUInt(16)
+ local row = net.ReadUInt(16)
+ local col = net.ReadUInt(16)
+
+ ply:UnEquip(itemslot,tobackpack,row,col)
end)
-net.Receive("equipitem",function(len,ply)
- local backpacknum = net.ReadUInt(16)
- local frompos = {}
- frompos[1] = net.ReadUInt(16)
- frompos[2] = net.ReadUInt(16)
- local equippos = net.ReadString()
- local item = ply.Inventory.Backpacks[backpacknum][1][frompos[1]][frompos[2]]
- if item.Equipable ~= nil and item.Equipable == equippos then
+--- Equips an item
+-- Moves an item from a backpack to an equiped slot, makes sure the item can be equiped in that slot first
+-- @param frombackpack The backpack to take the item from
+-- @param fromrow The row to take the item from
+-- @param fromcol The column to take the item from
+-- @param toslo The equipment slot to put the item into
+function pmeta:EquipItem(frombackpack, fromrow, fromcol, toslot)
+ local item = self.Inventory.Backpacks[frombackpack][1][fromrow[1]][fromcol[2]]
+ if item.Equipable ~= nil and item.Equipable == toslot then
--Remove from the backpack
for k = 1,#item.Shape do
- for i = 1,#(item.Shape[k]) do
+ for i = 1,#item.Shape[k] do
if k == 1 and i == 1 then continue end
- ply.Inventory.Backpacks[backpacknum][1][frompos[1] + k - 1][frompos[2] + i - 1] = false
+ self.Inventory.Backpacks[frombackpack][1][fromrow + k - 1][fromcol + i - 1] = false
end
end
- ply.Inventory.Backpacks[backpacknum][1][frompos[1]][frompos[2]] = false
- ply.Inventory.Equiped[equippos] = item
+ self.Inventory.Backpacks[frombackpack][1][fromrow][fromcol] = false
+ self.Inventory.Equiped[toslot] = item
if item.onEquip ~= nil then
- item:onEquip(ply)
+ item:onEquip(self)
end
- ply:SynchronizeInventory()
+ self:SynchronizeInventory()
end
+end
+
+net.Receive("equipitem",function(len,ply)
+ local backpacknum = net.ReadUInt(16)
+ local fromrow = net.ReadUInt(16)
+ local fromcol = net.ReadUInt(16)
+ local equippos = net.ReadString()
+ ply:EquipItem(backpacknum,fromrow,fromcol,equippos)
end)
net.Receive("moveitem",function(len,ply)
@@ -172,6 +256,8 @@ net.Receive("moveitem",function(len,ply)
toent:SynchronizeInventory()
end)
+--- Loads a player's inventory
+-- @param json The JSON string to create the player's inventory from
function pmeta:LoadInventory(json)
local reinv = util.JSONToTable(json)
for k,v in pairs(reinv) do
@@ -180,6 +266,8 @@ function pmeta:LoadInventory(json)
self:SynchronizeInventory()
end
+--- Networks a player's inventory
+-- Makes sure the client's version of the inventory matches up to the server's version, this should be called after manipulateing the client's inventory in any way.
function pmeta:SynchronizeInventory()
net.Start("synchinventory")
net.WriteEntity(self)
@@ -228,19 +316,7 @@ if CLIENT then
what.Inventory.Equiped[v] = false
end
end
- local discopy = LocalPlayer().invdisplays
- LocalPlayer().invdisplays = {}
- for k,ptbl in pairs(discopy) do
- if not ptbl.panel:IsValid() then continue end
- if ptbl.panel.Close ~= nil then
- ptbl.panel:Close()
- else
- print(ptbl.panel)
- error("panel has no close method")
- ptbl.panel:Remove()
- end
- ptbl.redraw()
- end
+ ART.RefreshDisplays()
end)
end
diff --git a/gamemode/shared/itemsystem/armor/balaclava.lua b/gamemode/shared/itemsystem/armor/balaclava.lua
new file mode 100644
index 0000000..177fa93
--- /dev/null
+++ b/gamemode/shared/itemsystem/armor/balaclava.lua
@@ -0,0 +1,81 @@
+--[[
+ An example item
+]]
+local item = {}
+
+--Required, a name, all item names must be unique
+item.Name = "Balaclava"
+
+--Optional, a tooltip to display
+item.Tooltip = "Something to cover your face"
+
+--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,true},
+}
+
+--Optional, If this item can be equiped in any player slots, put them here.
+item.Equipable = "Head"
+
+--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)
+ ART.ApplyPAC(who,"balaclava")
+ end
+end
+
+--Optional, if we should do something speical on unequip(like setting animations back to normal)
+item.onUnEquip = function(self,who)
+ ART.RemovePAC(who,"balaclava")
+end
+
+print("Hello from balaclava.lua")
+--Don't forget to register the item!
+ART.RegisterItem(item)
+print("After registering balaclava, items are:")
+PrintTable(ART.Items)
diff --git a/gamemode/shared/itemsystem/quest/rougebook.lua b/gamemode/shared/itemsystem/quest/rougebook.lua
new file mode 100644
index 0000000..835b863
--- /dev/null
+++ b/gamemode/shared/itemsystem/quest/rougebook.lua
@@ -0,0 +1,61 @@
+--[[
+ A quest item for the prayer book quest
+]]
+local item = {}
+
+item.Name = "Orders of the Silent Circle"
+
+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},
+}
+
+local rougeadvice = {
+ "He who refuses to trim his beard will find himself in a hairy situation.",
+ "You'll get tired defending from a man in a vehicle",
+ "You'll get exhaused attacking a man in a vehicle.",
+ "If you eat beans before church, you will sit in your own pew.",
+ "He who seeks challenges will be puzzeled.",
+ "He who fishes in another man's well is likely to catch crabs.",
+}
+
+local lhint = 1
+
+function item.GetOptions(self)
+ local options = {}
+ options["Read"] = function()
+ local readframe = vgui.Create( "DFrame" )
+ readframe:SetPos( ScrW()/2 - 100, ScrH()/2 - 100)
+ readframe:SetSize(200,200)
+ readframe:SetTitle("Orders of the Silent Circle")
+ readframe:MakePopup()
+
+
+ local readpanel = vgui.Create( "DPanel", readframe )
+ readpanel:SetPos( 5, 30 )
+ readpanel:SetSize( 190, 170 )
+ function readpanel:Paint(w,h) end
+
+
+ local readtext = vgui.Create( "DLabel", readpanel )
+ readtext:SetPos( 40, 40 )
+ readtext:SetText(rougeadvice[lhint])
+ readtext:SetDark()
+ readtext:Dock(FILL)
+ readtext:SetWrap(true)
+ lhint = (lhint % #rougeadvice) + 1
+ end
+ return options
+end
+
+ART.RegisterItem(item)
diff --git a/gamemode/shared/itemsystem/prayers/ninelives.lua b/gamemode/shared/itemsystem/utility/flashlight.lua
index e03e54c..9f2cc69 100644
--- a/gamemode/shared/itemsystem/prayers/ninelives.lua
+++ b/gamemode/shared/itemsystem/utility/flashlight.lua
@@ -4,10 +4,10 @@
local item = {}
--Required, a name, all item names must be unique
-item.Name = "Nine Lives"
+item.Name = "Flashlight"
--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."
+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)
@@ -22,31 +22,12 @@ item.DeSerialize = function(self,string)
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
+ options["test"] = function() print("You pressed test!") end
+ options["toste"] = function() print("You pressed toste!") 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)
@@ -71,7 +52,37 @@ 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 = "Left"
+
+--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
+local lastontime = {}
+item.onClick = function(self,owner)
+ if CLIENT then return end
+ if lastontime[owner] then return end
+ lastontime[owner] = true
+ timer.Simple(5,function()
+ lastontime[owner] = nil
+ end)
+ owner:Flashlight( not owner:FlashlightIsOn() )
+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)
+ if CLIENT then return end
+ who:AllowFlashlight(true)
+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)
+ if CLIENT then return end
+ who:Flashlight(false)
+ who:AllowFlashlight(false)
+end
+
+
+--Don't forget to register the item!
ART.RegisterItem(item)
diff --git a/gamemode/shared/itemsystem/weapons/knuckledclaw.lua b/gamemode/shared/itemsystem/weapons/knuckledclaw.lua
index 7f610fa..467439e 100644
--- a/gamemode/shared/itemsystem/weapons/knuckledclaw.lua
+++ b/gamemode/shared/itemsystem/weapons/knuckledclaw.lua
@@ -4,7 +4,7 @@
local item = {}
--Required, a name, all item names must be unique
-item.Name = "Scrap Hammer"
+item.Name = "Knuckled Claws"
--Optional, a tooltip to display
item.Tooltip = "Bits of scrap put togeather to resembel a hammer"
@@ -115,7 +115,7 @@ item.onClick = function(self,owner)
local movementtbl = {
["forward"] = function()
owner:SetLuaAnimation("fist_swing_up")
- timer.Simple(2.33,function()
+ timer.Simple(1.75,function()
owner:StopLuaAnimation("fist_swing_up")
end)
local hits = ART.swingarc(owner,{
@@ -134,7 +134,7 @@ item.onClick = function(self,owner)
end,
["backward"] = function()
owner:SetLuaAnimation("fist_swing_down")
- timer.Simple(2.33,function()
+ timer.Simple(1.75,function()
owner:StopLuaAnimation("fist_swing_down")
end)
local hits = ART.swingarc(owner,{
@@ -152,12 +152,9 @@ item.onClick = function(self,owner)
end)
end,
["left"] = function()
-
- end,
- ["right"] = function()
- owner:SetLuaAnimation("fist_swing_right")
- timer.Simple(2.33,function()
- owner:StopLuaAnimation("fist_swing_right")
+ owner:SetLuaAnimation("fist_swing_left")
+ timer.Simple(2,function()
+ owner:StopLuaAnimation("fist_swing_left")
end)
local hits = ART.swingarc(owner,{
0.5,0.57,0.65,0.73
@@ -173,6 +170,9 @@ item.onClick = function(self,owner)
print("Hit",tr.Entity)
end)
end,
+ ["right"] = function()
+
+ end,
}
movementtbl[ART.playermovedir(owner)]()
end
diff --git a/gamemode/shared/itemsystem/weapons/seratedknife.lua b/gamemode/shared/itemsystem/weapons/seratedknife.lua
index 8571074..a6d4c55 100644
--- a/gamemode/shared/itemsystem/weapons/seratedknife.lua
+++ b/gamemode/shared/itemsystem/weapons/seratedknife.lua
@@ -4,7 +4,7 @@
local item = {}
--Required, a name, all item names must be unique
-item.Name = "Scrap Hammer"
+item.Name = "Serated Knife"
--Optional, a tooltip to display
item.Tooltip = "Bits of scrap put togeather to resembel a hammer"
@@ -105,17 +105,18 @@ 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 = {}
+local animationtime = 1.833333
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
+ item.lastSwing[owner] = CurTime()+animationtime
local fow,rig,up = owner:GetForward(),owner:GetRight(),owner:GetUp()
local movementtbl = {
["forward"] = function()
owner:SetLuaAnimation("knife_swing_up")
- timer.Simple(2.33,function()
+ timer.Simple(animationtime,function()
owner:StopLuaAnimation("knife_swing_up")
end)
local hits = ART.swingarc(owner,{
@@ -134,7 +135,7 @@ item.onClick = function(self,owner)
end,
["backward"] = function()
owner:SetLuaAnimation("knife_swing_down")
- timer.Simple(2.33,function()
+ timer.Simple(animationtime,function()
owner:StopLuaAnimation("knife_swing_down")
end)
local hits = ART.swingarc(owner,{
@@ -153,7 +154,7 @@ item.onClick = function(self,owner)
end,
["left"] = function()
owner:SetLuaAnimation("knife_swing_left")
- timer.Simple(2.33,function()
+ timer.Simple(animationtime,function()
owner:StopLuaAnimation("knife_swing_left")
end)
local hits = ART.swingarc(owner,{
@@ -172,7 +173,7 @@ item.onClick = function(self,owner)
end,
["right"] = function()
owner:SetLuaAnimation("knife_swing_right")
- timer.Simple(2.33,function()
+ timer.Simple(animationtime,function()
owner:StopLuaAnimation("knife_swing_right")
end)
local hits = ART.swingarc(owner,{
diff --git a/gamemode/shared/itemsystem/weapons_common.lua b/gamemode/shared/itemsystem/weapons_common.lua
index 5da9b9a..6e73318 100644
--- a/gamemode/shared/itemsystem/weapons_common.lua
+++ b/gamemode/shared/itemsystem/weapons_common.lua
@@ -1,7 +1,9 @@
ART = ART or {}
-
+--- Finds the direction a player is moveing.
+-- @param player The player to find the move direction of
+-- @return The string "forward", "backward", "right", or "left"
function ART.playermovedir(player)
local vel = player:GetVelocity():GetNormalized()
vel.z = 0
@@ -17,8 +19,14 @@ function ART.playermovedir(player)
return swings[1][2]
end
-local positionset = {}
+local positionset = {}
+--- The arc swing of a weapon.
+-- Finds anything that a weapon should hit in it's swing, and calls a function on it.
+-- @param player The player that's swinging the weapon
+-- @param tiems A table of times that the trace calculations should be done at, this table needs to be the same length as the positions table
+-- @param positions The position offsets from the player that swung that should be the start/end points of the arc
+-- @param onhit A function to call on any entities that were hit in the swing of the weapon.
function ART.swingarc(player,times,positions,onhit)
local positionpoints = {}
table.insert(positionset,positionpoints)
diff --git a/gamemode/shared/loaditems.lua b/gamemode/shared/loaditems.lua
index 8dc8abf..7a4dd22 100644
--- a/gamemode/shared/loaditems.lua
+++ b/gamemode/shared/loaditems.lua
@@ -7,6 +7,9 @@ print("Hello from LoadItems.lua!")
ART.Items = {}
local requiredfields = {
"Name",
+ "Shape",
+ "Serialize",
+ "DeSerialize",
}
local defaultfields = {
["Serialize"] = function(self) return "" end,
diff --git a/gamemode/shared/loadprayers.lua b/gamemode/shared/loadprayers.lua
new file mode 100644
index 0000000..53631c2
--- /dev/null
+++ b/gamemode/shared/loadprayers.lua
@@ -0,0 +1,120 @@
+--[[
+ This file loads in all the prayers
+]]
+local concmd = include("concommands.lua")
+--local autolua = include("../autolua.lua")
+print("Hello from LoadItems.lua!")
+ART.Prayer = {}
+local requiredfields = {
+ "Name",
+ "Pray",
+}
+local defaultfields = {
+ ["Serialize"] = function(self) return "" end,
+ ["DeSerialize"] = function(self,string) return self end,
+ ["Shape"] = {{true}},
+}
+
+--- Adds the given prayer table to the global list of prayers.
+-- Make sure that you do not accidentally register the same prayer twice, all prayers MUST have unique names
+-- @param tbl The prayer to reigster
+function ART.RegisterPrayer(tbl)
+ --print("Registering item:" .. tbl.Name)
+ for k,v in pairs(requiredfields) do
+ assert(tbl[v] ~= nil, "Attempted to register an prayer without field:" .. v)
+ end
+ assert(ART.Prayer[tbl.Name] == nil, "Attempted to register 2 Prayers with the same name!")
+ for k,v in pairs(defaultfields) do
+ if tbl[k] == nil then
+ tbl[k] = v
+ end
+ end
+ ART.Prayer[tbl.Name] = tbl
+ --print("Art is now:")
+ --PrintTable(ART)
+end
+
+--autolua.AddLuaSHFolder("/shared/itemsystem")
+
+local meta = FindMetaTable("Player")
+
+
+if SERVER then
+ meta.Inventory.Prayers = {}
+
+ -- TODO:Make prayers limited or something
+ function meta:HasPrayer(prayername)
+ return self.Inventory.Prayers[prayername]
+ end
+
+ function meta:RemovePrayer(prayername)
+ self.Inventory.Prayers[prayername] = nil
+ self:SynchPrayers()
+ end
+
+ function ART.RemovePrayer(player,prayername)
+ player:RemovePrayer(prayername)
+ end
+
+ function meta:GivePrayer(prayername)
+ print("Prayers are:")
+ PrintTable(ART.Prayer)
+ assert(ART.Prayer[prayername] ~= nil, "Attempted to give a nil prayer \"" .. prayername .. "\"")
+ self.Inventory.Prayers[prayername] = true
+ self:SynchPrayers()
+ end
+
+ function ART.GivePrayer(player,prayername)
+ player:GivePrayer(prayername)
+ end
+
+ util.AddNetworkString( "art_synch_prayers" )
+ function meta:SynchPrayers()
+ print("Sending " .. table.Count(self.Inventory.Prayers) .. " prayers:")
+ PrintTable(self.Inventory.Prayers)
+ net.Start("art_synch_prayers")
+ net.WriteUInt(table.Count(self.Inventory.Prayers),16)
+ for k,v in pairs(self.Inventory.Prayers) do
+ print("Writeing " .. k)
+ net.WriteString(k)
+ end
+ net.Send(self)
+ end
+end
+
+concommand.Add("artery_giveprayer",function(ply,cmd,args)
+ if not ply:IsAdmin() then return end
+ ply:GivePrayer(args[1])
+end, concmd.AutocompleteFunction(table.GetKeys(ART.Prayer)), "Give an instance of a prayer to yourself")
+
+if CLIENT then
+ ART.MyPrayer = {}
+ net.Receive("art_synch_prayers",function()
+ ART.MyPrayer = {}
+ for k = 1,net.ReadUInt(16) do
+ local pstr = net.ReadString()
+ print("Reading prayer " .. pstr)
+ ART.MyPrayer[pstr] = true
+ end
+ print("Recived prayers:")
+ PrintTable(ART.MyPrayer)
+ ART.RefreshDisplays()
+ end)
+end
+
+function ART.GetPrayerByName(name)
+ assert(ART.Prayer[name] ~= nil,"Attempted to get a nil prayer:" .. name)
+ return ART.Prayer[name]
+end
+
+concommand.Add("artery_printprayers",function(ply,cmd,args)
+ if not ply:IsAdmin() then return end
+ print("Items table:")
+ PrintTable(ART.Prayer)
+end)
+
+concommand.Add("artery_giveprayer",function(ply,cmd,args)
+ if not ply:IsAdmin() then return end
+ print("Trying to give an prayer:" .. args[1])
+ ART.GivePrayer(ply,args[1])
+end, concmd.AutocompleteFunction(table.GetKeys(ART.Prayer)), "Give an item to the specified player, or yourself if no player is specified.")
diff --git a/gamemode/shared/npc_editor.lua b/gamemode/shared/npc_editor.lua
deleted file mode 100644
index 105ead8..0000000
--- a/gamemode/shared/npc_editor.lua
+++ /dev/null
@@ -1,10 +0,0 @@
-
-if SERVER then
- local npcnodes = {}
-
- local function spawnnpcnode()
-
- end
-
- concommand.Add("artery_makenpc",spawnnpcnode)
-end
diff --git a/gamemode/shared/prayersystem/prayers/lesserevasion.lua b/gamemode/shared/prayersystem/prayers/lesserevasion.lua
new file mode 100644
index 0000000..d4dc5f8
--- /dev/null
+++ b/gamemode/shared/prayersystem/prayers/lesserevasion.lua
@@ -0,0 +1,64 @@
+--[[
+ An example item
+]]
+print("Hello from lesser evasion.lua")
+local prayer = {}
+
+--Required, a name, all prayer names must be unique
+prayer.Name = "Lesser Evasion"
+
+--Optional, a tooltip to display when hovered over
+prayer.Tooltip = "A prayer to the rouge god to allow you to quickly dodge to the left or right"
+
+--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 = {}
+local prayedplayerstime = {}
+if SERVER then
+ util.AddNetworkString("art_prayer_lesserevasion")
+ net.Receive("art_prayer_lesserevasion",function(ln,ply)
+ if ply:HasPrayer(prayer.Name) and (prayedplayers[ply] == nil or CurTime() > prayedplayerstime[ply] + 5) then
+ prayedplayers[ply] = true
+ prayedplayerstime[ply] = CurTime()
+ end
+ end)
+end
+
+if CLIENT then
+ local lastprayer = CurTime()
+ prayer.Pray = function(self)
+ if CurTime() > lastprayer + 0 then
+ net.Start("art_prayer_lesserevasion")
+ net.SendToServer()
+ lastprayer = CurTime()
+ end
+ end
+end
+
+hook.Add( "SetupMove", "artery_prayer_lesserevasion", function( ply, mv, cmd )
+ if prayedplayers[ply] and not ply:OnGround() then
+ local mdir = ART.playermovedir(ply)
+ if mdir == "left" or mdir == "right" then
+ local noup = mv:GetVelocity()
+ noup.z = 0
+ local pow = 600 - noup:Length()
+ mv:SetVelocity((noup * pow) + Vector(0, 0, 20))
+ prayedplayers[ply] = false
+ end
+ end
+end )
+
+function prayer.DisplayHelp(panel)
+ local helptxt = vgui.Create("DLabel",panel)
+ helptxt:SetWrap(true)
+ helptxt:SetText("Your reflexes quicken, allowing you to dodge eto the left or right every 5 seconds. Start moveing left or right, then jump")
+ helptxt:SetSize(ScrW() / 4,ScrH() / 8)
+ helptxt:SetDark(true)
+end
+
+--Optional. Something run once when this item is drawn in a backpack
+function prayer.DoOnPanel(dimagebutton)
+ dimagebutton:SetImage( "prayericons/lesserevasion.png")
+end
+
+
+ART.RegisterPrayer(prayer)
diff --git a/gamemode/shared/prayersystem/prayers/ninelives.lua b/gamemode/shared/prayersystem/prayers/ninelives.lua
new file mode 100644
index 0000000..4c7a13a
--- /dev/null
+++ b/gamemode/shared/prayersystem/prayers/ninelives.lua
@@ -0,0 +1,51 @@
+--[[
+ 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."
+
+--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:HasPrayer("Nine Lives") then
+ prayedplayers[ply] = 9
+ timer.Simple(60 * 5,function()
+ prayedplayers[ply] = nil
+ end)
+ end
+ end)
+end
+
+if CLIENT then
+ local lastprayer = CurTime()
+ prayer.Pray = function(self)
+ if CurTime() > lastprayer + 0 then
+ net.Start("art_prayer_ninelives")
+ net.SendToServer()
+ lastprayer = CurTime()
+ end
+ end
+
+ hook.Add("")
+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 prayer.DoOnPanel(dimagebutton)
+ dimagebutton:SetImage( "prayericons/ninelives.png")
+end
+
+
+ART.RegisterPrayer(item)
diff --git a/gamemode/shared/prayersystem/prayers/notdarkrp.lua b/gamemode/shared/prayersystem/prayers/notdarkrp.lua
new file mode 100644
index 0000000..e62064c
--- /dev/null
+++ b/gamemode/shared/prayersystem/prayers/notdarkrp.lua
@@ -0,0 +1,77 @@
+--[[
+ A default prayer given to new players who try to press f4
+]]
+local prayer = {}
+
+--Required, a name, all prayer names must be unique
+prayer.Name = "Noob Help"
+
+--Optional, a tooltip to display when hovered over
+prayer.Tooltip = "Hello, and welcome to Artery, Enjoy your stay"
+
+--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!
+
+if CLIENT then
+ local lastpray = CurTime()
+
+ function prayer.Pray(self)
+ if CurTime() > lastpray + 5 then
+ local helppanel = vgui.Create("DFrame")
+ helppanel:SetSize(ScrW()/3,ScrH())
+ helppanel:Center()
+ helppanel:MakePopup()
+ helppanel:SetText("Help")
+
+ lastpray = CurTime()
+ end
+ end
+end
+
+if SERVER then
+ util.AddNetworkString( "art_prayer_darkrphelp" )
+
+ net.Receive( "art_prayer_darkrphelp", function(ln,ply)
+ print("Prayer received")
+ if ply:HasPrayer("Noob Help") then
+ ply:RemovePrayer("Noob Help")
+ ply:SetCredits(ply:GetCredits() + 100)
+ else
+ print("You don't have that prayer!")
+ end
+ end)
+end
+
+function prayer.DisplayHelp(panel)
+ print("Help displayed")
+ local dll = vgui.Create( "DListLayout", panel)
+ dll:Dock(FILL)
+ local helptxt = vgui.Create("DLabel")
+ helptxt:SetWrap(true)
+ helptxt:SetText("Welcome to Artery! Since you don't really need this help anymore, you can click below to redeem it for 100 credits!")
+ helptxt:SetSize(ScrW()/4,ScrH()/8)
+ helptxt:SetDark(true)
+ dll:Add(helptxt)
+ local redeembutton = vgui.Create("DButton")
+ dll:Add(redeembutton)
+ redeembutton:Dock(BOTTOM)
+ --helptxt:Dock(TOP)
+ redeembutton:SetText("Redeem")
+ redeembutton.DoClick = function(self)
+ print("You clicked redeem!")
+ net.Start("art_prayer_darkrphelp")
+ net.SendToServer()
+ end
+end
+
+--Optional. Something run once when this item is drawn in a backpack
+function prayer.DoOnPanel(dimagebutton)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe.png")
+end
+
+--Optional. Called continuously, use if you need the item to display different stuff at different tiems
+function prayer.Paint(self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+print("Hello from prayersystem/prayers/lesserevasion.lua")
+ART.RegisterPrayer(prayer)
diff --git a/gamemode/shared/itemsystem/prayers/preditorinstinct.lua b/gamemode/shared/prayersystem/prayers/preditorinstinct.lua
index 8776c26..8ba7b87 100644
--- a/gamemode/shared/itemsystem/prayers/preditorinstinct.lua
+++ b/gamemode/shared/prayersystem/prayers/preditorinstinct.lua
@@ -9,18 +9,6 @@ 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
@@ -34,13 +22,15 @@ if SERVER then
end
end)
end
-function item.GetOptions(self)
- local options = {}
- options["Pray"] = function()
- net.Start("art_prayer_preditorinstinct")
- net.SendToServer()
+if CLIENT then
+ local lastprayer = CurTime()
+ prayer.Pray = function(self)
+ if CurTime() > lastprayer + 0 then
+ net.Start("art_prayer_preditorinstinct")
+ net.SendToServer()
+ lastprayer = CurTime()
+ end
end
- return options
end
--called continuously to buff players
local buffedplayers = {}
@@ -71,28 +61,7 @@ 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))
+ dimagebutton:SetImage( "prayericons/preditorinstinct.png")
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)
+ART.RegisterPrayer(item)
diff --git a/gamemode/shared/itemsystem/prayers/thickskin.lua b/gamemode/shared/prayersystem/prayers/thickskin.lua
index 9dc77bd..41d5fb5 100644
--- a/gamemode/shared/itemsystem/prayers/thickskin.lua
+++ b/gamemode/shared/prayersystem/prayers/thickskin.lua
@@ -34,14 +34,15 @@ if SERVER then
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()
+if CLIENT then
+ local lastprayer = CurTime()
+ prayer.Pray = function(self)
+ if CurTime() > lastprayer + 0 then
+ net.Start("art_prayer_thickskin")
+ net.SendToServer()
+ lastprayer = CurTime()
+ end
end
- return options
end
hook.Add( "EntityTakeDamage" , "artery_thickskin" , function(ent,info)
if prayedplayers[ent] then
@@ -51,28 +52,8 @@ 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))
+ dimagebutton:SetImage( "prayericons/thickskin.png")
end
---Required, the shape of this item in a backpack.
-item.Shape = {
- {true},
-}
-ART.RegisterItem(item)
+ART.RegisterPrayer(item)