aboutsummaryrefslogtreecommitdiff
path: root/entities
diff options
context:
space:
mode:
Diffstat (limited to 'entities')
-rw-r--r--entities/entities/art_chest/cl_init.lua21
-rw-r--r--entities/entities/art_chest/init.lua22
-rw-r--r--entities/entities/art_droppeditem/cl_init.lua6
-rw-r--r--entities/entities/art_droppeditem/init.lua12
-rw-r--r--entities/entities/npc_huntable/init.lua9
-rw-r--r--entities/entities/npc_huntable/shared.lua14
-rw-r--r--entities/entities/npc_shop/cl_init.lua5
-rw-r--r--entities/entities/npc_shop/init.lua46
-rw-r--r--entities/entities/npc_shop/shared.lua2
-rw-r--r--entities/weapons/hands.lua1
10 files changed, 117 insertions, 21 deletions
diff --git a/entities/entities/art_chest/cl_init.lua b/entities/entities/art_chest/cl_init.lua
index 2907968..1ba18b4 100644
--- a/entities/entities/art_chest/cl_init.lua
+++ b/entities/entities/art_chest/cl_init.lua
@@ -19,6 +19,17 @@ function ENT:Draw()
end
local oldpanel = nil
+local namecache = {}
+
+net.Receive("informchestname",function()
+ local e = net.ReadEntity()
+ local s = net.ReadString()
+ namecache[e] = s
+ if oldpanel ~= nil then
+ oldpanel:SetTitle(s)
+ end
+end)
+
net.Receive("openchestinv",function(len,ply)
if oldpanel ~= nil then oldpanel:Remove() end
print("Opening chest inventory")
@@ -44,7 +55,15 @@ net.Receive("openchestinv",function(len,ply)
local invpanel = dat.panel
invpanel:SetPos( width - (width/4), 0 )
invpanel:SetSize( width / 4, height )
- invpanel:SetTitle( "Chest" )
+ print("Trying to get name",name)
+ if namecache[what] == nil then
+ net.Start("requestchestname")
+ net.WriteEntity(what)
+ net.SendToServer()
+ invpanel:SetTitle( "Chest" )
+ else
+ invpanel:SetTitle(namecache[what])
+ end
invpanel:SetDraggable( true )
invpanel:MakePopup()
local innerpanel = vgui.Create("DPanel",dat.panel)
diff --git a/entities/entities/art_chest/init.lua b/entities/entities/art_chest/init.lua
index 92d1371..cd39eab 100644
--- a/entities/entities/art_chest/init.lua
+++ b/entities/entities/art_chest/init.lua
@@ -24,9 +24,25 @@ function ENT:Initialize()
self.StoredItems = {}
end
-util.AddNetworkString("openchestinv")
-util.AddNetworkString("closechestinv")
-util.AddNetworkString("requestchestinv")
+local uans = {
+ "openchestinv",
+ "closechestinv",
+ "requestchestinv",
+ "requestchestname",
+ "informchestname",
+}
+for k,v in pairs(uans) do
+ util.AddNetworkString(v)
+end
+
+net.Receive("requestchestname",function(ln,ply)
+ local e = net.ReadEntity()
+ local s = e:GetName()
+ net.Start("informchestname")
+ net.WriteEntity(e)
+ net.WriteString(s)
+ net.Send(ply)
+end)
net.Receive("requestchestinv",function(ln,ply)
print("Received request for chest")
diff --git a/entities/entities/art_droppeditem/cl_init.lua b/entities/entities/art_droppeditem/cl_init.lua
index eb4b21f..eb8868d 100644
--- a/entities/entities/art_droppeditem/cl_init.lua
+++ b/entities/entities/art_droppeditem/cl_init.lua
@@ -16,10 +16,14 @@ end
local lp
local sentrequests = {}
hook.Add("Tick","pickupitemstick",function()
- lp = lp or LocalPlayer()
+ lp = (lp and lp:IsValid()) and lp or LocalPlayer()
+ if not lp:IsValid() then return end
local ae = ents.FindInSphere(lp:GetPos(),5)
for k,v in pairs(ae) do
local ei = v:EntIndex()
+ if ei ~= 1 and ei ~= -1 then
+ print("Checking if we should pick up", ei)
+ end
if (not sentrequests[ei]) and v.GetClass and v:GetClass() == "art_droppeditem" then
print("Sending request to pick up", ei)
net.Start("art_requestpickup")
diff --git a/entities/entities/art_droppeditem/init.lua b/entities/entities/art_droppeditem/init.lua
index de27e6d..491d479 100644
--- a/entities/entities/art_droppeditem/init.lua
+++ b/entities/entities/art_droppeditem/init.lua
@@ -17,10 +17,16 @@ function ENT:Initialize()
self.ItemData = self.Item.Data
if self.Item.onDropped then
self:SetColor(Color(0,0,0,0))
- timer.Simple(1,function()
- self.Item:onDropped(self)
- end)
+ local od = self.Item.onDropped
+ if od ~= nil then
+ timer.Simple(1,function()
+ if self and self.Item then
+ od(self.Item,self)
+ end
+ end)
+ end
end
+ self:DrawShadow(false)
self:SetMoveType(MOVETYPE_NONE)
self:SetSolid(SOLID_NONE)
self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE)
diff --git a/entities/entities/npc_huntable/init.lua b/entities/entities/npc_huntable/init.lua
index 3adf3e2..e5b52c8 100644
--- a/entities/entities/npc_huntable/init.lua
+++ b/entities/entities/npc_huntable/init.lua
@@ -58,12 +58,9 @@ function ENT:OnKilled(dmg)
local heightoffset = 10
if rng < itemchance then
- local drop = ents.Create("ws_item")
- drop.Item = GetItemByName(itemname)
- drop:SetModel(drop.Item.Model)
- drop:SetPos(self:GetPos() + (self:GetUp() * heightoffset))
- drop:Spawn()
- heightoffset = heightoffset + 10
+ local drop = ART.GetItemByName(itemname)
+ print("Createing a drop of",drop)
+ ART.CreateDroppedItem(drop, self:GetPos())
end
end
diff --git a/entities/entities/npc_huntable/shared.lua b/entities/entities/npc_huntable/shared.lua
index 2f34721..279199f 100644
--- a/entities/entities/npc_huntable/shared.lua
+++ b/entities/entities/npc_huntable/shared.lua
@@ -18,7 +18,7 @@ end
function ENT:DefaultBehaviour()
self.lastrun = CurTime()
while (true) do
- print("Inside defaultbehaviour")
+ --print("Inside defaultbehaviour")
local delta = CurTime() - self.lastrun
self:AI(delta)
--Main loop for ai
@@ -42,7 +42,7 @@ end
function ENT:AI(num)
- print("Inside behaveupdate")
+ --print("Inside behaveupdate")
local players = player.GetAll()
for k, v in pairs(players) do
@@ -60,8 +60,8 @@ function ENT:AI(num)
local priority = self:AttackPriority(v)
if (priority == nil) then
- print("Nill priority hit after ")
- PrintTable(self)
+ --print("Nill priority hit after ")
+ --PrintTable(self)
end
if (priority > maxpriority) then
@@ -71,13 +71,13 @@ function ENT:AI(num)
end
self.Target = maxprioritytarget
- print("My target is",self.Target)
+ --print("My target is",self.Target)
--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))
- print("Playing sequence",self.IdleSequences[randanim])
+ --print("Playing sequence",self.IdleSequences[randanim])
self:PlaySequenceAndWait(self.IdleSequences[randanim])
self:StartActivity(ACT_IDLE)
--print("Acting idle")
@@ -93,7 +93,7 @@ function ENT:AI(num)
end
if (closest > 4000) then
- print("Closes player is " .. closest .. " removeing self...")
+ --print("Closes player is " .. closest .. " removeing self...")
self:BecomeRagdoll(DamageInfo())
end
else
diff --git a/entities/entities/npc_shop/cl_init.lua b/entities/entities/npc_shop/cl_init.lua
new file mode 100644
index 0000000..4cfd132
--- /dev/null
+++ b/entities/entities/npc_shop/cl_init.lua
@@ -0,0 +1,5 @@
+include('shared.lua')
+--local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
+local invfuncs = ART.invfuncs
+
+ENT.RenderGroup = RENDERGROUP_BOTH
diff --git a/entities/entities/npc_shop/init.lua b/entities/entities/npc_shop/init.lua
new file mode 100644
index 0000000..93b5755
--- /dev/null
+++ b/entities/entities/npc_shop/init.lua
@@ -0,0 +1,46 @@
+AddCSLuaFile( "cl_init.lua" )
+AddCSLuaFile( "shared.lua" )
+
+include("shared.lua")
+local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
+
+--Some things that can be looted
+local lootables = {
+
+}
+
+function CreateRandomLoot(time)
+
+end
+
+function ENT:Initialize()
+
+ self.Openedby = {}
+
+ self:PhysicsInit( SOLID_VPHYSICS )
+ self:SetMoveType( MOVETYPE_NONE )
+ self:SetUseType(SIMPLE_USE)
+
+ self:SetSolid(SOLID_BBOX )
+ self:SetCollisionGroup(COLLISION_GROUP_NPC )
+
+ print("Initalizeing shop npc")
+ if(self.Model) then self:SetModel(self.Model)
+ else print("NPC created without model, this might be a bug!") end
+
+ if self.Pos then self:SetPos(self.Pos)
+ else print("NPC created without a position, this might be a bug!") end
+
+ self.talking = false
+
+ if self.Name then self:SetName(self.Name)
+ else print("NPC created without a name! They won't be able to open doors!") end
+
+ if self.OnSpawn then self.OnSpawn(self) end
+
+ self:SetUseType( SIMPLE_USE )
+end
+
+function ENT:Use(ply)
+ ART.OpenShop(self.shopitems,ply)
+end
diff --git a/entities/entities/npc_shop/shared.lua b/entities/entities/npc_shop/shared.lua
new file mode 100644
index 0000000..28ee2d3
--- /dev/null
+++ b/entities/entities/npc_shop/shared.lua
@@ -0,0 +1,2 @@
+ENT.Type = "nextbot"
+ENT.Base = "art_chest"
diff --git a/entities/weapons/hands.lua b/entities/weapons/hands.lua
index e0b1ae6..d55c416 100644
--- a/entities/weapons/hands.lua
+++ b/entities/weapons/hands.lua
@@ -39,6 +39,7 @@ end
local Box = Vector(8,8,8)
function SWEP:PrimaryAttack()
+ if not self.Owner.Inventory then return end
local rightitem = self.Owner.Inventory.Equiped["Left"]
if rightitem ~= false and rightitem.onClick ~= nil then
rightitem:onClick(self.Owner)