Where does an NPC go?

I have an NPC. The Shared.lua, init.lua, and cl_init.lua are all in the folder called “NPC”. Where does this folder go? lua/entities? I can’t figure it out :frowning:

Does anybody know? (Yes this is a bump…I’m sorry)

Yes, Lua/entities.

[editline]11:46PM[/editline]

Also, if the NPC works good for you can you post the code? I’ve been wanting to make an NPC but not from scratch.

I learned what I know off of the garrysmod wiki, that’s where I learned most of the NPC actions and such. It’s too bad my NPC doesn’t work…

Ah, sorry mate :frown:

It’s ok, it was the sloppiest code ever, and I have a friend doing it for me. He’s a great coder, and he’s getting credit for it in the movie I’m using it for.

Hah, I made a simple npc entity thing once. It was Kleiner holding an AK47.
He didn’t do anything but look scarie :open_mouth:

:open_mouth:

We’re keeping this useless thread alive.

Lua for my scary kleiner NPC:
[lua]
–Cl_init

include(‘shared.lua’)

ENT.RenderGroup = RENDERGROUP_BOTH

/---------------------------------------------------------
Name: Draw
Desc: Draw it!
---------------------------------------------------------
/
function ENT:Draw()
self.Entity:DrawModel()
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
[/lua]

[lua]
–init

AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “shared.lua” )

include(‘shared.lua’)

local schdChase = ai_schedule.New( “AIFighter Chase” ) //creates the schedule used for this npc

// Run away randomly (first objective in task)
schdChase:EngTask( "TASK_GET_PATH_TO_RANDOM_NODE", 	128 )
schdChase:EngTask( "TASK_RUN_PATH", 				0 )
schdChase:EngTask( "TASK_WAIT_FOR_MOVEMENT", 	0 )
schdChase:AddTask( "PlaySequence", 				{ Name = "cheer1", Speed = 1 } )

// Find an enemy and run to it (second objectives in task)
schdChase:AddTask( "FindEnemy", 		{ Class = "player", Radius = 2000 } )
schdChase:EngTask( "TASK_GET_PATH_TO_RANGE_ENEMY_LKP_LOS", 	0 )
schdChase:EngTask( "TASK_RUN_PATH", 				0 )
schdChase:EngTask( "TASK_WAIT_FOR_MOVEMENT", 	0 )

// Shoot it (third objective in task)
schdChase:EngTask( "TASK_STOP_MOVING", 			0 )
schdChase:EngTask( "TASK_FACE_ENEMY", 			0 )
schdChase:EngTask( "TASK_ANNOUNCE_ATTACK", 		0 )
schdChase:EngTask( "TASK_RANGE_ATTACK1", 		0 )
schdChase:EngTask( "TASK_RELOAD", 				0 )
//schedule is looped till you give it a different schedule

function ENT:Initialize()

self.Entity:SetModel("models/kleiner.mdl")

self:SetHullType( HULL_HUMAN );
self:SetHullSizeNormal();

self:SetSolid( SOLID_BBOX )
self:SetMoveType( MOVETYPE_STEP )

self:CapabilitiesAdd( CAP_MOVE_GROUND | CAP_OPEN_DOORS | CAP_ANIMATEDFACE | CAP_TURN_HEAD | CAP_USE_SHOT_REGULATOR | CAP_AIM_GUN )

self:SetMaxYawSpeed( 5000 )

//don't touch stuff above here
self:SetHealth(100)
self:Give( "weapon_zpsak47" ) //Can be given sweps.

end

function ENT:OnTakeDamage(dmg)
self:SetHealth(self:Health() - dmg:GetDamage())
if self:Health() <= 0 then //run on death
self:SetSchedule( SCHED_FALL_TO_GROUND ) //because it’s given a new schedule, the old one will end.
self:EmitSound(“magic/removed.wav”)
end
end

/---------------------------------------------------------
Name: SelectSchedule
---------------------------------------------------------
/
function ENT:SelectSchedule()

self:StartSchedule( schdChase ) //run the schedule we created earlier

end
[/lua]

[lua]
–shared

ENT.Base = “base_ai”
ENT.Type = “ai”

ENT.PrintName = “Killer Kleiner”
ENT.Author = “Mat”
ENT.Contact = “Don’t” //fill in these if you want it to be in the spawn menu
ENT.Purpose = “To kill YOU”
ENT.Instructions = “Pwnpwnpwn”

ENT.AutomaticFrameAdvance = true

/---------------------------------------------------------
Name: OnRemove
Desc: Called just before entity is deleted
---------------------------------------------------------
/
function ENT:OnRemove()
end

/---------------------------------------------------------
Name: PhysicsCollide
Desc: Called when physics collides. The table contains
data on the collision
---------------------------------------------------------
/
function ENT:PhysicsCollide( data, physobj )
end

/---------------------------------------------------------
Name: PhysicsUpdate
Desc: Called to update the physics … or something.
---------------------------------------------------------
/
function ENT:PhysicsUpdate( physobj )
end

/---------------------------------------------------------
Name: SetAutomaticFrameAdvance
Desc: If you’re not using animation you should turn this
off - it will save lots of bandwidth.
---------------------------------------------------------
/
function ENT:SetAutomaticFrameAdvance( bUsingAnim )

self.AutomaticFrameAdvance = bUsingAnim

end
[/lua]

You can use that if you want.

I see used Garry’s template. I tried that, too, no luck.