aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-10-24 12:12:19 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-10-24 12:12:19 -0400
commit74c7a160da34897ebdf18aaff02b8c9b65809949 (patch)
treedb2a084d02f4acc3d7c99ec20e573101e448aef6
parentd7f44fc24da959658b597e64d842661aa41f6515 (diff)
downloadartery-74c7a160da34897ebdf18aaff02b8c9b65809949.tar.gz
artery-74c7a160da34897ebdf18aaff02b8c9b65809949.tar.bz2
artery-74c7a160da34897ebdf18aaff02b8c9b65809949.zip
Various other updates and bugfixes
-rw-r--r--entities/entities/npc_townie/init.lua25
-rw-r--r--entities/entities/npc_townie/shared.lua116
-rw-r--r--gamemode/client/areas/loadareas.lua3
-rw-r--r--gamemode/client/cl_systems.lua4
-rw-r--r--gamemode/client/qpanels/inventory.lua11
-rw-r--r--gamemode/shared.lua42
-rw-r--r--gamemode/shared/animations/move_evade.lua75
-rw-r--r--gamemode/shared/inventory.lua2
-rw-r--r--gamemode/shared/itemcommon/common_inventory.lua4
-rw-r--r--gamemode/shared/itemsystem/armor/balaclava.lua2
-rw-r--r--gamemode/shared/itemsystem/foodstuffs/watermelon.lua51
-rw-r--r--gamemode/shared/itemsystem/quest/rougebadge.lua38
-rw-r--r--gamemode/shared/sh_buff.lua31
-rw-r--r--notes.txt13
14 files changed, 243 insertions, 174 deletions
diff --git a/entities/entities/npc_townie/init.lua b/entities/entities/npc_townie/init.lua
index 66cfaf1..a444348 100644
--- a/entities/entities/npc_townie/init.lua
+++ b/entities/entities/npc_townie/init.lua
@@ -47,31 +47,6 @@ function ENT:Initialize()
self:SetUseType( SIMPLE_USE )
self.DialogCursors = {}
- --[[
- if(not self.Stats) then
- print("NPC created without any stats, this is a bug!")
- return
- end
- if(self.Stats["Vitality"]) then
- self:SetHealth(self.Stats["Vitality"])
- else print("NPC created with no stat for vitality, this might be a bug!")end
- if(self.Stats["Accel"]) then self.loco:SetAcceleration(self.Stats["Accel"])end
- if(self.Stats["Decel"]) then self.loco:SetDeceleration(self.Stats["Decel"]) end
- if(self.Stats["Step"]) then self.loco:SetJumpHeight(self.Stats["Step"]) end
- if(self.OnSpawn) then self:OnSpawn() end
- --self:SetModel( "models/Humans/Group01/Female_01.mdl" )
- ]]
- --[[
- self:SetHullType( HULL_HUMAN );
- self:SetHullSizeNormal();
-
- self:SetSolid( SOLID_BBOX )
- self:SetMoveType( MOVETYPE_STEP )
-
- self:CapabilitiesAdd( CAP_MOVE_GROUND or CAP_OPEN_DOORS or CAP_ANIMATEDFACE or CAP_TURN_HEAD or CAP_USE_SHOT_REGULATOR or CAP_AIM_GUN )
-
- self:SetMaxYawSpeed( 5000 )
- ]]--
end
function ENT:OnInjured(dmg)
diff --git a/entities/entities/npc_townie/shared.lua b/entities/entities/npc_townie/shared.lua
index 437275a..e7f02c7 100644
--- a/entities/entities/npc_townie/shared.lua
+++ b/entities/entities/npc_townie/shared.lua
@@ -1,97 +1,8 @@
ENT.Base = "base_nextbot"
-//WS stuff
-ENT.Drops = nil
-ENT.OnDammage = nil
-ENT.Speed = 0
-ENT.Model = nil
-
-ENT.Behave = nil
-ENT.Act = nil
-
-/*---------------------------------------------------------
- Name: OnRemove
- Desc: Called just before entity is deleted
----------------------------------------------------------*/
function ENT:OnRemove()
end
---[[
-function ENT:DefaultBehaviour()
- while ( true ) do
- --Main loop for ai
- --print("Going into behavior for " .. self.Name)
- --Update aware enemies
- local players = ents.FindByClass("Player")
-
- --Find the enemy with the highest priority
- local maxpriority = -1
- local maxprioritytarget = nil
- for k,v in pairs(self.AwareEnemies) do
- local priority = self:AttackPriority(v)
- if(priority == nil) then
- print("Nill priority hit after ")
- PrintTable(self)
- end
- if(priority > maxpriority) then
- maxpriority = priority
- maxprioritytarget = v
- end
- end
- self.Target = maxprioritytarget
-
- --If we can't find anyone to attack, just stay idle
- if(self.Target == nil) then
- --print("Couldn't find anyone to attack!")
- --Play an idle sequence
- local randanim = math.Round(math.Rand(0,#self.IdleSequences))
- self:PlaySequenceAndWait( self.IdleSequences[randanim] )
- self:StartActivity( ACT_IDLE )
- --print("Acting idle")
- --If there's noone within 4000 units, just remove ourselves to save server resources
- local closest = 5000
- for k,v in pairs(player.GetAll()) do
- local thisdist = self:GetPos():Distance(v:GetPos())
- if(thisdist < closest) then
- closest = thisdist
- end
- end
- if(closest > 4000) then
- print("Closes player is " .. closest .. " removeing self...")
- self:BecomeRagdoll(DamageInfo())
- end
- else
- --We have a target to attack!
-
- --Find which attack will do the most dammage
- local maxdammage = -1
- local maxdammagefunc = nil
- for k,v in pairs(self.Attacks) do
- local dammagefunc = nil
- local attackfunc = nil
- for i,j in pairs(v) do
- dammagefunc = i
- attackfunc = j
- end
- local dammage = dammagefunc(self, self.Target)
- if(dammage > maxdammage) then
- maxdammage = dammage
- maxdammagefunc = attackfunc
- end
- end
-
- --Do that attack
- if(maxdammagefunc) then
- maxdammagefunc(self, self.Target)
- end
- end
- coroutine.yield()
- end
-
- coroutine.yield()
-end
-]]
-
function ENT:BehaveAct()
if(self.Act) then
self:Act()
@@ -111,11 +22,6 @@ function ENT:OnStuck()
end
function ENT:selectNewNode()
- --print("selectNewNode called")
- --debug.Trace()
- --print("Selecting from nodes")
- --PrintTable(self.allowedNodes)
- --local nodes = ents.FindByClass("info_townienode")
if #self.allowedNodes == 0 then return end
local rnode = table.Random(self.allowedNodes)
return rnode
@@ -124,7 +30,6 @@ end
local removeblock = {
["prop_door_rotating"] = function(bot,ent)
ent:Fire("OpenAwayFrom",bot:GetName())
- --Couln't get it to open correct direction, back up and go through
timer.Simple(3,function()
ent:Fire("Close")
end)
@@ -133,7 +38,7 @@ local removeblock = {
function ENT:BehaveUpdate(num)
if not self.BehaveThread then return end
- if self.curnode ~= nil and self.curnode:IsValid() then
+ if self.curnode and self.curnode:IsValid() then
if self.curnode:GetPos():Distance(self:GetPos()) < 5 then
if self.nodereached == false then
self.curnode.OnReached(self)
@@ -153,20 +58,19 @@ function ENT:BehaveUpdate(num)
["filter"] = self
}
local tr = util.TraceLine(trdata)
- if tr.Hit then
- --print(tr.Entity)
- if removeblock[tr.Entity:GetClass()] ~= nil then
- removeblock[tr.Entity:GetClass()](self,tr.Entity)
- end
+ local ecl
+ --print("tr",tr,"tr.entity",tr.Entity)
+ if (tr ~= nil) and (tr.Entity ~= nil) and tr.Entity:IsValid() then
+ --print("Not returning")
+ ecl = tr.Entity:GetClass()
+ end
+ if tr.Hit and removeblock[ecl] ~= nil then
+ removeblock[ecl](self,tr.Entity)
end
local ok, message = coroutine.resume( self.BehaveThread )
- if ( ok == false ) then
-
-
+ if not ok then
self.BehaveThread = nil
Msg( self, "error: ", message, "\n" );
-
-
end
end
diff --git a/gamemode/client/areas/loadareas.lua b/gamemode/client/areas/loadareas.lua
new file mode 100644
index 0000000..a8c506d
--- /dev/null
+++ b/gamemode/client/areas/loadareas.lua
@@ -0,0 +1,3 @@
+--[[
+ Loads the area names for the current map
+]]
diff --git a/gamemode/client/cl_systems.lua b/gamemode/client/cl_systems.lua
deleted file mode 100644
index 0165239..0000000
--- a/gamemode/client/cl_systems.lua
+++ /dev/null
@@ -1,4 +0,0 @@
---[[
- Something to display all the systems delt with serverside
-]]
-local systems = {}
diff --git a/gamemode/client/qpanels/inventory.lua b/gamemode/client/qpanels/inventory.lua
index f4adad6..9fec1cc 100644
--- a/gamemode/client/qpanels/inventory.lua
+++ b/gamemode/client/qpanels/inventory.lua
@@ -4,6 +4,17 @@ invfuncs = ART.invfuncs
--invfuncs = include("../shared/inventory_common.lua")
assert(invfuncs ~= nil, "Dependency failed")
+local function createMenuFor(menu, tbl)
+ for k,v in pairs(tbl) do
+ if isfunction(v) then --This is a dead-end, add the menu
+ local thisoption = menu:AddOption(k,v)
+ else --Otherwise it should be a table, recursively call to create
+ local submenu = menu:AddSubMenu(k)
+ createMenuFor(submenu,v)
+ end
+ end
+end
+
local function DrawBackpackOnDPanel(dp, backpack, backpacknum, tent)
local width = ScrW()
local height = ScrH()
diff --git a/gamemode/shared.lua b/gamemode/shared.lua
index c69113f..8f8483f 100644
--- a/gamemode/shared.lua
+++ b/gamemode/shared.lua
@@ -12,10 +12,52 @@ GM.Email = "apickx@cogarr.org"
GM.Website = "cogarr.net"
--Some global functions that are helpful
+-- printf
+-- assertf
+-- curry
+-- typecheck
+
+--printf from C
function printf(fmt, ...)
print(string.format(fmt,...))
end
+--Assert with a formated string
+function assertf(cond, fmt, ...)
+ assert(cond,string.format(fmt,...))
+end
+
+--Curry from lisp, allows you to store variables "in" a function, so you can call it with fewer arguments if you'll be repeating arguments a lot
+--Ex:
+-- >dbprint = curry(print,"[Debug]")
+-- >dbprint("Hello, world!")
+-- [Debug] Hello, world!
+-- >
+function curry(fnc, ...)
+ local oarg = {...}
+ return function(...)
+ return fnc(unpack(oarg),unpack({...}))
+ end
+end
+
+--Does type checking for functions, use by supplying a table whith the variables and the types they should be
+--Ex:
+-- >local somefunction(str, tbl, num)
+-- >>typecheck({
+-- >> str,"string",
+-- >> tbl,"table",
+-- >> num,"number"
+-- >>})
+-- >
+function typecheck(...)
+ local tbl = {...}
+ tbl = type(tbl[1]) == "table" and tbl[1] or tbl
+ for k=1,#tbl,2 do
+ local t,n = type(tbl[k]),tbl[k+1]
+ assertf(t == n, "Passed argument of wrong type, should have been %q but was %q",t,n )
+ end
+end
+
--Add a thing to report errors to a master server
--TODO:Set up a master server to collect errors for correction
local olderr = error
diff --git a/gamemode/shared/animations/move_evade.lua b/gamemode/shared/animations/move_evade.lua
new file mode 100644
index 0000000..a5595aa
--- /dev/null
+++ b/gamemode/shared/animations/move_evade.lua
@@ -0,0 +1,75 @@
+RegisterLuaAnimation('evade_left', {
+ FrameData = {
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_L_Calf'] = {
+ },
+ ['ValveBiped.Bip01_L_Thigh'] = {
+ },
+ ['ValveBiped.Bip01_R_Thigh'] = {
+ },
+ ['ValveBiped.Bip01_Pelvis'] = {
+ }
+ },
+ FrameRate = 1
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_L_Calf'] = {
+ RU = -44.9346,
+ RR = -4.9288,
+ RF = 5.1193
+ },
+ ['ValveBiped.Bip01_L_Thigh'] = {
+ RU = 49.7508,
+ RR = 11.8895,
+ RF = 74.14
+ },
+ ['ValveBiped.Bip01_R_Thigh'] = {
+ RU = 6.3191,
+ RR = 12.8315,
+ RF = -4.8611
+ },
+ ['ValveBiped.Bip01_Pelvis'] = {
+ }
+ },
+ FrameRate = 4
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_L_Calf'] = {
+ RU = -44.9346,
+ RR = -4.9288,
+ RF = 5.1193
+ },
+ ['ValveBiped.Bip01_L_Thigh'] = {
+ RU = 49.7508,
+ RR = 11.8895,
+ RF = 74.14
+ },
+ ['ValveBiped.Bip01_Pelvis'] = {
+ },
+ ['ValveBiped.Bip01_R_Thigh'] = {
+ RU = 6.3191,
+ RR = 12.8315,
+ RF = -4.8611
+ }
+ },
+ FrameRate = 4
+ },
+ {
+ BoneInfo = {
+ ['ValveBiped.Bip01_L_Calf'] = {
+ },
+ ['ValveBiped.Bip01_L_Thigh'] = {
+ },
+ ['ValveBiped.Bip01_Pelvis'] = {
+ },
+ ['ValveBiped.Bip01_R_Thigh'] = {
+ }
+ },
+ FrameRate = 2
+ }
+ },
+ Type = TYPE_STANCE
+})
diff --git a/gamemode/shared/inventory.lua b/gamemode/shared/inventory.lua
index 382ebd5..f83bb77 100644
--- a/gamemode/shared/inventory.lua
+++ b/gamemode/shared/inventory.lua
@@ -97,7 +97,7 @@ end
-- @return n The backpack number the item was found in.
function pmeta:HasItem(nameorcomparitor)
local comparitor
- if type(param) == "String" then
+ if type(nameorcomparitor) == "string" then
comparitor = function(t) return t.Name == nameorcomparitor end
else
comparitor = nameorcomparitor
diff --git a/gamemode/shared/itemcommon/common_inventory.lua b/gamemode/shared/itemcommon/common_inventory.lua
deleted file mode 100644
index f541ecc..0000000
--- a/gamemode/shared/itemcommon/common_inventory.lua
+++ /dev/null
@@ -1,4 +0,0 @@
---[[
- Stores some common functions related to items
-]]
-local common = {}
diff --git a/gamemode/shared/itemsystem/armor/balaclava.lua b/gamemode/shared/itemsystem/armor/balaclava.lua
index 177fa93..d77da61 100644
--- a/gamemode/shared/itemsystem/armor/balaclava.lua
+++ b/gamemode/shared/itemsystem/armor/balaclava.lua
@@ -77,5 +77,3 @@ 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/foodstuffs/watermelon.lua b/gamemode/shared/itemsystem/foodstuffs/watermelon.lua
new file mode 100644
index 0000000..76c0398
--- /dev/null
+++ b/gamemode/shared/itemsystem/foodstuffs/watermelon.lua
@@ -0,0 +1,51 @@
+--[[
+ An example item
+]]
+local item = {}
+
+--Required, a name, all item names must be unique
+item.Name = "Watermelon"
+
+--Optional, a tooltip to display when hovered over
+item.Tooltip = "Where do they grow these in an apocolyptic wasteland???"
+
+--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
+if SERVER then
+ util.AddNetworkString("eat_watermelon")
+ net.Receive("eat_watermelon", function(len,ply)
+ local row,col,bp = ply:HasItem("Watermelon")
+ if row and col and bp then
+ ply:RemoveItemAt(bp,row,col)
+ end
+ end)
+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!
+function item.GetOptions(self)
+ local options = {}
+ options["eat"] = function()
+ net.Start("eat_watermelon")
+ net.SendToServer()
+ end
+ return options
+end
+
+--Required, the shape of this item in a backpack.
+item.Shape = {
+ {true,true,true},
+ {true,true,true},
+ {true,true,true},
+}
+
+print("Hello from exampleitem.lua")
+--Don't forget to register the item!
+ART.RegisterItem(item)
diff --git a/gamemode/shared/itemsystem/quest/rougebadge.lua b/gamemode/shared/itemsystem/quest/rougebadge.lua
new file mode 100644
index 0000000..dad0f71
--- /dev/null
+++ b/gamemode/shared/itemsystem/quest/rougebadge.lua
@@ -0,0 +1,38 @@
+--[[
+ An example item
+]]
+local item = {}
+
+--Required, a name, all item names must be unique
+item.Name = "Rouge Newbie Badge"
+
+--Optional, a tooltip to display when hovered over
+item.Tooltip = "A tiny peice of metal, kinda looks like a dagger."
+
+--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!
+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
+
+--Required, the shape of this item in a backpack.
+item.Shape = {
+ {true}
+}
+
+
+ART.RegisterItem(item)
diff --git a/gamemode/shared/sh_buff.lua b/gamemode/shared/sh_buff.lua
deleted file mode 100644
index ac46df9..0000000
--- a/gamemode/shared/sh_buff.lua
+++ /dev/null
@@ -1,31 +0,0 @@
---This was probably a mistake
-do return end
-
-local pmeta = FindMetaTable("Player")
-
-pmeta.buffs = {}
-local buffid = 0
-function pmeta:ApplyBuff(buff)
- if self.buffs[buff.type] == nil then
- self.buffs[buff.type] = {}
- end
- local id = buffid
- buffid = buffid + 1
- self.buffs[buff.type][id] = buff
- self.buffs[id] = buff.type
- return id
-end
-
-function pmeta:RemoveBuff(buffid)
- local bufftype = self.buffs[buffid]
- self.buffs[buff.type][buffid] = nil
- self.buffs[buffid] = nil
-end
-
-hook.Add("EntityTakeDamage","arterybuffs",function(ent,info)
-
-end)
-
---[[
- Add buff types here I guess
-]]
diff --git a/notes.txt b/notes.txt
index 7288be9..24971c9 100644
--- a/notes.txt
+++ b/notes.txt
@@ -1,9 +1,20 @@
Bits and bobs, roughly documentation
Items are in gamemode/shared/itemsystem
+ Animations are in gamemode/shared/animations
+ Prayers are in gamemode/shared/prayers
+ HUD is in gamemode/client
Quests, Inventory, and Skills might all potentially do mysql injection, be careful in their creation, and don't let users enter any fields about them!
When createing new files, make sure the file has some text in it (even just a comment explaining what the file will eventually hold) include() will crash the game if called on an empty file.
-If your server starts breaking after a while, it's probably the fault of /gamemode/shared/sh_buff.lua, no you can't put a bandaid on it or fix it, you have to re-write it.
+If your server starts breaking after a while, it's probably the fault of /gamemode/shared/sh_buff.lua, no you can't put a bandaid on it to fix it, you have to re-write it.
+
+Multi-serverness is defined in /data/artery/maps/<map_name>
+
+PAC's to download on demand are in /data/artery/pacs/<pac_name>
+
+For creation:
+ Finding the player's current position
+ lua_run_cl local gp = LocalPlayer():GetPos() print(string.format("Vector(%.2d,%.2d,%.2d)",gp.x,gp.y,gp.z))