aboutsummaryrefslogtreecommitdiff
path: root/entities
diff options
context:
space:
mode:
Diffstat (limited to 'entities')
-rw-r--r--entities/entities/art_droppeditem/cl_init.lua2
-rw-r--r--entities/entities/info_huntablespawn/cl_init.lua69
-rw-r--r--entities/entities/info_huntablespawn/init.lua16
-rw-r--r--entities/entities/info_huntablespawn/shared.lua23
-rw-r--r--entities/entities/npc_huntable/init.lua13
-rw-r--r--entities/entities/npc_huntable/shared.lua51
6 files changed, 160 insertions, 14 deletions
diff --git a/entities/entities/art_droppeditem/cl_init.lua b/entities/entities/art_droppeditem/cl_init.lua
index ceebc7f..83f8087 100644
--- a/entities/entities/art_droppeditem/cl_init.lua
+++ b/entities/entities/art_droppeditem/cl_init.lua
@@ -18,7 +18,7 @@ local sentrequests = {}
hook.Add("Tick","pickupitemstick",function()
lp = (lp and lp:IsValid()) and lp or LocalPlayer()
if not lp:IsValid() then return end
- local ae = ents.FindInSphere(lp:GetPos(),5)
+ local ae = ents.FindInSphere(lp:GetPos(),10)
for k,v in pairs(ae) do
local ei = v:EntIndex()
if (not sentrequests[ei]) and v.GetClass and v:GetClass() == "art_droppeditem" then
diff --git a/entities/entities/info_huntablespawn/cl_init.lua b/entities/entities/info_huntablespawn/cl_init.lua
new file mode 100644
index 0000000..f851bf9
--- /dev/null
+++ b/entities/entities/info_huntablespawn/cl_init.lua
@@ -0,0 +1,69 @@
+include('shared.lua')
+
+ENT.RenderGroup = RENDERGROUP_BOTH
+
+/*---------------------------------------------------------
+ Name: Draw
+ Desc: Draw it!
+---------------------------------------------------------*/
+function ENT:Draw()
+ --self:DrawModel()
+ render.SetColorMaterial()
+ render.DrawSphere( self:GetPos(), 10, 30, 30, Color( 255, 0, 0, 100 ) )
+
+end
+
+/*---------------------------------------------------------
+ Name: DrawTranslucent
+ Desc: Draw translucent
+---------------------------------------------------------*/
+function ENT:DrawTranslucent()
+
+ // This is here just to make it backwards compatible.
+ // You shouldn't really be drawing your model here unless it's translucent
+
+ --self:Draw()
+
+end
+
+/*---------------------------------------------------------
+ Name: BuildBonePositions
+ Desc:
+---------------------------------------------------------*/
+function ENT:BuildBonePositions( NumBones, NumPhysBones )
+
+ // You can use this section to position the bones of
+ // any animated model using self:SetBonePosition( BoneNum, Pos, Angle )
+
+ // This will override any animation data and isn't meant as a
+ // replacement for animations. We're using this to position the limbs
+ // of ragdolls.
+
+end
+
+
+
+/*---------------------------------------------------------
+ Name: SetRagdollBones
+ Desc:
+---------------------------------------------------------*/
+function ENT:SetRagdollBones( bIn )
+
+ // If this is set to true then the engine will call
+ // DoRagdollBone (below) for each ragdoll bone.
+ // It will then automatically fill in the rest of the bones
+
+ self.m_bRagdollSetup = bIn
+
+end
+
+
+/*---------------------------------------------------------
+ Name: DoRagdollBone
+ Desc:
+---------------------------------------------------------*/
+function ENT:DoRagdollBone( PhysBoneNum, BoneNum )
+
+ // self:SetBonePosition( BoneNum, Pos, Angle )
+
+end
diff --git a/entities/entities/info_huntablespawn/init.lua b/entities/entities/info_huntablespawn/init.lua
new file mode 100644
index 0000000..9fa7f7e
--- /dev/null
+++ b/entities/entities/info_huntablespawn/init.lua
@@ -0,0 +1,16 @@
+--[[
+ This entity gives townies things to do
+]]
+AddCSLuaFile( "cl_init.lua" )
+AddCSLuaFile( "shared.lua" )
+
+include("shared.lua")
+
+function ENT:Initialize()
+ self:SetModel("models/error.mdl")
+ self:SetMoveType(MOVETYPE_NONE)
+ self:SetSolid(SOLID_NONE)
+ self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE)
+ --self:SetNoDraw(true)
+ self:SetPos(self.Position)
+end
diff --git a/entities/entities/info_huntablespawn/shared.lua b/entities/entities/info_huntablespawn/shared.lua
new file mode 100644
index 0000000..8b42e7f
--- /dev/null
+++ b/entities/entities/info_huntablespawn/shared.lua
@@ -0,0 +1,23 @@
+ENT.Base = "base_entity"
+
+//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:DoActivity(npc)
+ if not self.onActivity() then
+ print("Node without activity, this might be an error!")
+ end
+end
diff --git a/entities/entities/npc_huntable/init.lua b/entities/entities/npc_huntable/init.lua
index a21e565..31d6ea8 100644
--- a/entities/entities/npc_huntable/init.lua
+++ b/entities/entities/npc_huntable/init.lua
@@ -6,7 +6,8 @@ local applyfields = {"Model", "Stats"}
function ENT:Initialize()
--print("NPC spawned!")
--self:SetMoveType(MOVETYPE_STEP)
- self:SetSolid(SOLID_OBB)
+ --self:SetSolid(SOLID_OBB)
+ self:SetCollisionGroup(COLLISION_GROUP_PUSHAWAY )
--self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE)
for _, v in pairs(applyfields) do
@@ -32,6 +33,10 @@ function ENT:Initialize()
if (self.Stats["Step"]) then
self.loco:SetJumpHeight(self.Stats["Step"])
end
+
+ if self.Stats["Speed"] then
+ self.loco:SetDesiredSpeed(self.Stats["Speed"])
+ end
if (self.OnSpawn) then
self:OnSpawn()
@@ -59,9 +64,9 @@ function ENT:OnKilled(dmg)
local heightoffset = 10
if rng < itemchance then
- local drop = ART.GetItemByName(itemname)
- print("Createing a drop of",drop)
- ART.CreateDroppedItem(drop, self:GetPos())
+ --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 279199f..4c4c535 100644
--- a/entities/entities/npc_huntable/shared.lua
+++ b/entities/entities/npc_huntable/shared.lua
@@ -6,6 +6,7 @@ ENT.Speed = 0
ENT.Model = nil
ENT.Behave = nil
ENT.Act = nil
+ENT.AutomaticFrameAdvance = true
--[[---------------------------------------------------------
Name: OnRemove
@@ -16,22 +17,44 @@ end
function ENT:DefaultBehaviour()
+ print("In default behavior")
self.lastrun = CurTime()
+
+ --Set some stuff up for navigation
+ local path = Path( "Follow" )
+ path:SetMinLookAheadDistance( self.lookahead or 300 )
+ path:SetGoalTolerance( self.goaltolarance or 100)
+ local delta = CurTime() - self.lastrun
+ self:AI(delta)
while (true) do
--print("Inside defaultbehaviour")
- local delta = CurTime() - self.lastrun
- self:AI(delta)
+
+ --Sets all the values needed for the rest of this function to do it's thing
--Main loop for ai
+
--print("Going into behavior for " .. self.Name)
--Update aware enemies
+ delta = CurTime() - self.lastrun
+ if delta > 0.1 then
+ self:AI(delta)
+ end
+
if self.TargetPos ~= nil then
- self:MoveToPos(self.TargetPos,{
- ["lookahead"] = 5,
- ["tolerance"] = 50,
- ["draw"] = true,
- ["maxage"] = 20,
- ["repath"] = 4,
- })
+ if ( !path:IsValid() ) then print("Path wasn't valid!") end
+ if ( path:GetAge() > 0.1 ) then -- Since we are following the player we have to constantly repath
+ path:Compute( self, self.TargetPos ) -- Compute the path towards the enemy's position again
+ path:Update( self ) -- This function moves the bot along the path
+ end
+
+
+ if ( true ) then path:Draw() end
+ -- If we're stuck then call the HandleStuck function and abandon
+ if ( self.loco:IsStuck() ) then
+ --self:HandleStuck()
+ --return "stuck"
+ end
+
+ --return "ok"
end
self.lastrun = CurTime()
coroutine.yield()
@@ -125,11 +148,21 @@ function ENT:AI(num)
end
end
+ --[[
+ print("Before running, behavethread was", self.BehaveThread)
+ local ok, message = coroutine.resume( self.BehaveThread )
+ if not ok then
+ self.BehaveThread = nil
+ Msg( self, "error: ", message, "\n" );
+ end
+ ]]
+
if (self.Act) then
self:Act(num)
else
print("NPC spawned without an Act function, this might be an error!")
end
+
end
function ENT:RunBehaviour()