aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2018-03-23 20:20:40 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2018-03-23 20:20:40 -0400
commite2428796b9afe019ae6ca45e07fbe1aaa6963917 (patch)
treeb6514bbf349a99ebd3e999a3811ab6f0fa52851b
parentc132bf1fa77a0b01b18a848db91879383a8210a8 (diff)
downloadartery-e2428796b9afe019ae6ca45e07fbe1aaa6963917.tar.gz
artery-e2428796b9afe019ae6ca45e07fbe1aaa6963917.tar.bz2
artery-e2428796b9afe019ae6ca45e07fbe1aaa6963917.zip
Started working on quest inventory
-rw-r--r--gamemode/core/animation/cl_animate.lua13
-rw-r--r--gamemode/core/animation/sv_animate.lua21
-rw-r--r--gamemode/core/quests/quest.lua85
-rw-r--r--gamemode/itemsystem/quest.lua62
-rw-r--r--gamemode/questsystem/component_gather.lua25
-rw-r--r--gamemode/questsystem/component_kill.lua3
-rw-r--r--gamemode/questsystem/component_talk.lua3
7 files changed, 212 insertions, 0 deletions
diff --git a/gamemode/core/animation/cl_animate.lua b/gamemode/core/animation/cl_animate.lua
new file mode 100644
index 0000000..fd322a1
--- /dev/null
+++ b/gamemode/core/animation/cl_animate.lua
@@ -0,0 +1,13 @@
+
+net.Receive("art_start_animation",function()
+ local what = net.ReadEntity()
+ local anim = net.ReadString()
+ what:SetupBones()
+ what:SetLuaAnimation(anim)
+end)
+
+net.Receive("art_stop_animation",function()
+ local what = net.ReadEntity()
+ local anim = net.ReadString()
+ what:StopLuaAnimation(anim)
+end)
diff --git a/gamemode/core/animation/sv_animate.lua b/gamemode/core/animation/sv_animate.lua
new file mode 100644
index 0000000..24d0ed0
--- /dev/null
+++ b/gamemode/core/animation/sv_animate.lua
@@ -0,0 +1,21 @@
+
+nrequire("sh_animations.lua")
+
+local meta = FindMetaTable("Player")
+
+util.AddNetworkString("art_start_animation")
+util.AddNetworkString("art_stop_animation")
+
+function meta:StartAnimation(name)
+ net.Start("art_start_animation")
+ net.WriteEntity(self)
+ net.WriteString(name)
+ net.Broadcast()
+end
+
+function meta:StopAnimation(name)
+ net.Start("art_stop_animation")
+ net.WriteEntity(self)
+ net.WriteString(name)
+ net.Broadcast()
+end
diff --git a/gamemode/core/quests/quest.lua b/gamemode/core/quests/quest.lua
new file mode 100644
index 0000000..5560745
--- /dev/null
+++ b/gamemode/core/quests/quest.lua
@@ -0,0 +1,85 @@
+--[[
+ Ease of use functions for generating quests
+]]
+
+--[[
+ local quest = {
+ q.MakeArc("TalkArc",Entity(24),"Talk to Jared The Brutal","Rats...","I JARED THE BRUTAL. YOU THINK YOU TOUGH? GO KILL 10 RATS!!!"),
+ q.MakeArc("KillArc","Rat",10)
+ q.MakeArc("TalkArc",Entity(24),"Talk to Jared The Brutal","I kill 10 rats.","HOLY SHIT, YOU KILL 10?? GOOD. YOU BRUTAL NOW. HERE IS REWARD.")
+ }
+ local reward = function(ply)
+ for i=1,10 do
+ pcall(function()
+ ply:GiveItem("Rat Meat")
+ end,function()
+
+ end)
+ end
+ ply:AddSkill("Hunting",20)
+ end
+ local Killquest = q.GenerateQuest(quest,reward)
+]]
+
+nrequire("itemsystem/quest.lua")
+local itm = nrequire("item.lua")
+local log = nrequire("log.lua")
+
+local q = {}
+local arcs = {}
+local arc_required_fields = {
+ "Name",
+ "Init",
+ "Serialize",
+ "DeSerialize"
+}
+
+function q.RegisterArc(tbl)
+ for k,v in pairs(arc_required_fields) do
+ assert(tbl[v],"Attempted to register an arc, which didn't have a required field:" .. v)
+ end
+ if arcs[tbl.Name] ~= nil then
+ log.warn("Attempted to register and arc named " .. tbl.Name .. " when another arc by that name already exists. Overwriteing...")
+ end
+ arcs[tbl.Name] = tbl
+end
+
+function q.MakeArc(name,...)
+ assert(arcs[name] ~= nil, "Attempted to make an unknown arc type:\"" .. name .. "\". Known arc types are:" + table.concat(table.GetKeys(items),"\n\t"))
+ local arc_m = {
+ __index = arcs[name]
+ }
+ arcbase = {}
+ setmetatable(arcbase,arc_m)
+ return arcbase
+end
+
+-- Generates an item that represents a quest
+function q.GenerateQuest(questname,arcstbl,rewards)
+ local q = itm.GetItemByName("Quest")
+ q.questname = questname
+ q.Arcs = arcstbl
+ q.reward = rewards
+end
+
+concommand.Add("artery_gen_test_quest",function(ply,cmd,args)
+ print("Generating a test quest")
+ local qu = {
+ q.MakeArc("Quest Component Gather","Test item", 3)
+ }
+ local reward = function(ply)
+ print("Sucessfully finished quest for", ply)
+ end
+ local kq = q.GenerateQuest(qu,reward)
+ xpcall(function()
+ ply:GiveItem(kq)
+ end,function()
+ print("FAiled to add quest")
+ end)
+end)
+
+concommand.Add("artery_printquestarcs",function(ply,cmd,args)
+ PrintTable(arcs)
+end)
+
+return q
diff --git a/gamemode/itemsystem/quest.lua b/gamemode/itemsystem/quest.lua
new file mode 100644
index 0000000..d75c42c
--- /dev/null
+++ b/gamemode/itemsystem/quest.lua
@@ -0,0 +1,62 @@
+--[[
+ Generic item for creating quests
+]]
+
+local item = {}
+local strikethoughmap = {
+ a = "a̶",
+ b = "b̶",
+ c = "c̶",
+ d = "d̶",
+ e = "e̶",
+ f = "f̶",
+ g = "g̶",
+ h = "h̶",
+ i = "i̶",
+ j = "j̶",
+ k = "k̶",
+ l = "l̶",
+ m = "m̶",
+ n = "n̶",
+ o = "o̶",
+ p = "p̶",
+ q = "q̶",
+ r = "r̶",
+ s = "s̶",
+ t = "t̶",
+ u = "u̶",
+ v = "v̶",
+ w = "w̶",
+ x = "x̶",
+ y = "y̶",
+ z = "z̶"
+}
+
+item.Name = "Quest"
+
+item.Tooltip = "The quest item"
+
+item.Arcs = {}
+item.ArcsCompleted = 0
+
+function item:GetText()
+ local text = {}
+ for i=1,self.ArcsCompleted do
+ local thisarctxt = self.Arcs[i]:GetText()
+ for k,v in pairs(strikethoughmap) do
+ print("Trying to strike though:",v)
+ end
+ end
+
+end
+
+function item:Serialize()
+
+end
+
+function item:DeSerialize()
+
+end
+
+local itm = nrequire("item.lua")
+itm.RegisterItem(item)
diff --git a/gamemode/questsystem/component_gather.lua b/gamemode/questsystem/component_gather.lua
new file mode 100644
index 0000000..fccb32a
--- /dev/null
+++ b/gamemode/questsystem/component_gather.lua
@@ -0,0 +1,25 @@
+local comp = {}
+
+comp.Name = "Quest Component Gather"
+
+
+function comp:Init(itemname,itemnumber)
+ self.itemname = itemname
+ self.itemnumber = itemnumber
+end
+
+function comp:GetText()
+ return string.format("Gather %s %s",self.itemnumber,self.itiemname)
+end
+
+function comp:Serialize()
+ return util.TableToJSON({itemname,itemnumber})
+end
+
+function comp:DeSerialize(data)
+ local tbl = util.JSONToTable(data)
+ self.itemname = tbl[1]
+ self.itemnumber = tbl[2]
+end
+
+nrequire("core/quests/quest.lua").RegisterArc(comp)
diff --git a/gamemode/questsystem/component_kill.lua b/gamemode/questsystem/component_kill.lua
new file mode 100644
index 0000000..3925a12
--- /dev/null
+++ b/gamemode/questsystem/component_kill.lua
@@ -0,0 +1,3 @@
+--[[
+Something to stop gmod from freaking out
+]]
diff --git a/gamemode/questsystem/component_talk.lua b/gamemode/questsystem/component_talk.lua
new file mode 100644
index 0000000..3925a12
--- /dev/null
+++ b/gamemode/questsystem/component_talk.lua
@@ -0,0 +1,3 @@
+--[[
+Something to stop gmod from freaking out
+]]