aboutsummaryrefslogtreecommitdiff
path: root/gamemode/shared/prayersystem/prayers/thickskin.lua
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/prayersystem/prayers/thickskin.lua
parentd4f197a35c207c9891d3f4dc5e9708af48c935de (diff)
downloadartery-9adcb3c73a8d0e7ecfe66b30da630c6c2e67f03a.tar.gz
artery-9adcb3c73a8d0e7ecfe66b30da630c6c2e67f03a.tar.bz2
artery-9adcb3c73a8d0e7ecfe66b30da630c6c2e67f03a.zip
Moved prayers to their own system
Diffstat (limited to 'gamemode/shared/prayersystem/prayers/thickskin.lua')
-rw-r--r--gamemode/shared/prayersystem/prayers/thickskin.lua59
1 files changed, 59 insertions, 0 deletions
diff --git a/gamemode/shared/prayersystem/prayers/thickskin.lua b/gamemode/shared/prayersystem/prayers/thickskin.lua
new file mode 100644
index 0000000..41d5fb5
--- /dev/null
+++ b/gamemode/shared/prayersystem/prayers/thickskin.lua
@@ -0,0 +1,59 @@
+--[[
+ 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
+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
+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( "prayericons/thickskin.png")
+end
+
+
+ART.RegisterPrayer(item)