diff options
Diffstat (limited to 'gamemode/core')
| -rw-r--r-- | gamemode/core/animation/cl_animate.lua | 13 | ||||
| -rw-r--r-- | gamemode/core/animation/sv_animate.lua | 21 | ||||
| -rw-r--r-- | gamemode/core/quests/quest.lua | 85 |
3 files changed, 119 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 |
