diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-08-27 17:08:46 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-08-27 17:08:46 -0400 |
| commit | 9adcb3c73a8d0e7ecfe66b30da630c6c2e67f03a (patch) | |
| tree | d65b57e144317e5b49ccdd549b2f97c61d54bd1d /gamemode/shared/prayersystem/prayers | |
| parent | d4f197a35c207c9891d3f4dc5e9708af48c935de (diff) | |
| download | artery-9adcb3c73a8d0e7ecfe66b30da630c6c2e67f03a.tar.gz artery-9adcb3c73a8d0e7ecfe66b30da630c6c2e67f03a.tar.bz2 artery-9adcb3c73a8d0e7ecfe66b30da630c6c2e67f03a.zip | |
Moved prayers to their own system
Diffstat (limited to 'gamemode/shared/prayersystem/prayers')
5 files changed, 318 insertions, 0 deletions
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/prayersystem/prayers/preditorinstinct.lua b/gamemode/shared/prayersystem/prayers/preditorinstinct.lua new file mode 100644 index 0000000..8ba7b87 --- /dev/null +++ b/gamemode/shared/prayersystem/prayers/preditorinstinct.lua @@ -0,0 +1,67 @@ +--[[ + 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" + +--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 +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 +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( "prayericons/preditorinstinct.png") +end + +ART.RegisterPrayer(item) 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) |
