• Make an Snpc Chase A Player
    1 replies, posted
Hello there! I want that my snpc chase the player that is anywhere in the map, obviously using nodes that the map already have Is a custom snpc addon Here is his init.lua [CODE]AddCSLuaFile("shared.lua") include('shared.lua') /*----------------------------------------------- *** Copyright (c) 2012-2016 by DrVrej, All rights reserved. *** No parts of this code or any of its contents may be reproduced, copied, modified or adapted, without the prior written consent of the author, unless otherwise indicated for stand-alone materials. -----------------------------------------------*/ ENT.Model = {"models/VJ_UNITEDSTATES/ranger1.mdl"} -- The game will pick a random model from the table when the SNPC is spawned | Add as many as you want ENT.StartHealth = GetConVarNumber("vj_mili_ranger_h") ENT.MoveType = MOVETYPE_STEP ENT.HullType = HULL_HUMAN ENT.HullSizeNormal = false -- set to false to cancel out the self:SetHullSizeNormal() --------------------------------------------------------------------------------------------------------------------------------------------- ENT.VJ_NPC_Class = {"CLASS_UNITED_STATES"} -- NPCs with the same class will be friendly to each other | Combine: CLASS_COMBINE, Zombie: CLASS_ZOMBIE, Antlions = CLASS_ANTLION ENT.BloodParticle = {"blood_impact_red_01"} -- Particle that the SNPC spawns when it's damaged ENT.BloodDecal = {"Blood"} -- Leave blank for none | Commonly used: Red = Blood, Yellow Blood = YellowBlood ENT.HasMeleeAttack = true -- Should the SNPC have a melee attack? ENT.AnimTbl_MeleeAttack = {ACT_MELEE_ATTACK1} -- Melee Attack Animations ENT.MeleeAttackDistance = 30 -- How close does it have to be until it attacks? ENT.MeleeAttackDamageDistance = 70 -- How far does the damage go? ENT.TimeUntilMeleeAttackDamage = 0.5 -- This counted in seconds | This calculates the time until it hits something ENT.NextAnyAttackTime_Melee = 0.1 -- How much time until it can use a attack again? | Counted in Seconds ENT.MeleeAttackDamage = GetConVarNumber("vj_mili_ranger_d") ENT.FootStepTimeRun = 0.4 -- Next foot step sound when it is running ENT.FootStepTimeWalk = 0.5 -- Next foot step sound when it is walking ENT.SquadName = "unitedstates_ranger" -- Squad name, console error will happen if two groups that are enemy and try to squad! ENT.HasGrenadeAttack = true -- Should the SNPC have a grenade attack? -- ====== Flinching Code ====== -- ENT.Flinches = 1 -- 0 = No Flinch | 1 = Flinches at any damage | 2 = Flinches only from certain damages ENT.FlinchingChance = 12 -- chance of it flinching from 1 to x | 1 will make it always flinch ENT.FlinchingSchedules = {SCHED_FLINCH_PHYSICS} -- If self.FlinchUseACT is false the it uses this | Common: SCHED_BIG_FLINCH, SCHED_SMALL_FLINCH, SCHED_FLINCH_PHYSICS -- ====== Sound File Paths ====== -- -- Leave blank if you don't want any sounds to play ENT.SoundTbl_FootStep = {"npc/metropolice/gear1.wav","npc/metropolice/gear2.wav","npc/metropolice/gear3.wav","npc/metropolice/gear4.wav","npc/metropolice/gear5.wav","npc/metropolice/gear6.wav"} ENT.SoundTbl_Idle = {"mili_us1/idle1.wav","mili_us1/idle2.wav","mili_us1/idle3.wav","mili_us1/idle4.wav","mili_us1/idle5.wav","mili_us1/idle6.wav","mili_us1/idle7.wav","mili_us1/idle8.wav","mili_us1/idle9.wav","mili_us1/idle10.wav","mili_us1/idle11.wav","mili_us1/idle12.wav"} ENT.SoundTbl_MedicBeforeHeal = {"mili_us1/medic1.wav","mili_us1/medic2.wav","mili_us1/medic3.wav","mili_us1/medic4.wav","mili_us1/medic5.wav","mili_us1/medic6.wav","mili_us1/medic7.wav"} ENT.SoundTbl_Alert = {"mili_us1/alert1.wav","mili_us1/alert2.wav","mili_us1/alert3.wav","mili_us1/alert4.wav","mili_us1/alert5.wav","mili_us1/alert6.wav"} ENT.SoundTbl_CombatIdle = {"mili_us1/attack1.wav","mili_us1/attack2.wav","mili_us1/attack3.wav","mili_us1/attack4.wav","mili_us1/attack5.wav","mili_us1/attack6.wav","mili_us1/attack7.wav","mili_us1/attack8.wav","mili_us1/attack9.wav","mili_us1/attack10.wav","mili_us1/attack11.wav","mili_us1/attack12.wav"} ENT.SoundTbl_WeaponReload = {"mili_us1/reloading1.wav","mili_us1/reloading2.wav","mili_us1/reloading3.wav","mili_us1/reloading4.wav","mili_us1/reloading5.wav","mili_us1/reloading6.wav"} ENT.SoundTbl_GrenadeAttack = {"mili_us1/throwgrenade1.wav","mili_us1/throwgrenade2.wav","mili_us1/throwgrenade3.wav","mili_us1/throwgrenade4.wav","mili_us1/throwgrenade5.wav","mili_us1/throwgrenade6.wav","mili_us1/throwgrenade7.wav","mili_us1/throwgrenade8.wav","mili_us1/throwgrenade9.wav"} ENT.SoundTbl_OnGrenadeSight = {"mili_us1/grenade1.wav","mili_us1/grenade2.wav","mili_us1/grenade3.wav","mili_us1/grenade4.wav","mili_us1/grenade5.wav","mili_us1/grenade6.wav"} ENT.SoundTbl_Pain = {"mili_us1/pain1.wav","mili_us1/pain2.wav","mili_us1/pain3.wav","mili_us1/pain4.wav","mili_us1/pain5.wav","mili_us1/pain6.wav"} ENT.SoundTbl_Death = {"mili_us1/death1.wav","mili_us1/death2.wav","mili_us1/death3.wav","mili_us1/death4.wav","mili_us1/death5.wav","mili_us1/death6.wav"} --------------------------------------------------------------------------------------------------------------------------------------------- function ENT:CustomOnInitialize() if math.random(1,5) == 1 then self.IsMedicSNPC = true end local randomstartbg_head = math.random(1,5) if randomstartbg_head == 1 then self:SetBodygroup( 1,0 ) else if randomstartbg_head == 2 then self:SetBodygroup( 1,1 ) end if randomstartbg_head == 3 then self:SetBodygroup( 1,2 ) end if randomstartbg_head == 4 then self:SetBodygroup( 1,3 ) end if randomstartbg_head == 5 then self:SetBodygroup( 1,4 ) end end local randomstartbg_body = math.random(1,2) if randomstartbg_body == 1 then self:SetBodygroup( 2,0 ) else if randomstartbg_body == 2 then self:SetBodygroup( 2,1 ) end end local randomstartbg_gear = math.random(1,5) if randomstartbg_gear == 1 then self:SetBodygroup( 3,0 ) else if randomstartbg_gear == 2 then self:SetBodygroup( 3,1 ) end if randomstartbg_gear == 3 then self:SetBodygroup( 3,2 ) end if randomstartbg_gear == 4 then self:SetBodygroup( 3,3 ) end if randomstartbg_gear == 5 then self:SetBodygroup( 3,4 ) end end local randomstartbg_eyewear = math.random(1,3) if randomstartbg_eyewear == 1 then self:SetBodygroup( 4,0 ) else if randomstartbg_eyewear == 2 then self:SetBodygroup( 4,1 ) end if randomstartbg_eyewear == 3 then self:SetBodygroup( 4,2 ) end end local randomstartbg_mask = math.random(1,2) if randomstartbg_mask == 1 then self:SetBodygroup( 5,0 ) else if randomstartbg_mask == 2 then self:SetBodygroup( 5,1 ) end end //print(self:GetBodygroupCount(5)) local randomstartskin = math.random(1,10) -- Skins if randomstartskin == 1 then self:SetSkin( 0 ) else if randomstartskin == 2 then self:SetSkin( 1 ) end if randomstartskin == 3 then self:SetSkin( 2 ) end if randomstartskin == 4 then self:SetSkin( 3 ) end if randomstartskin == 5 then self:SetSkin( 4 ) end if randomstartskin == 6 then self:SetSkin( 5 ) end if randomstartskin == 7 then self:SetSkin( 6 ) end if randomstartskin == 8 then self:SetSkin( 7 ) end if randomstartskin == 9 then self:SetSkin( 8 ) end if randomstartskin == 10 then self:SetSkin( 9 ) end if randomstartskin == 11 then self:SetSkin( 10 ) end end end /*----------------------------------------------- *** Copyright (c) 2012-2016 by DrVrej, All rights reserved. *** No parts of this code or any of its contents may be reproduced, copied, modified or adapted, without the prior written consent of the author, unless otherwise indicated for stand-alone materials. -----------------------------------------------*/[/CODE] and here is his shared.lua [CODE]ENT.Base = "npc_vj_human_base" ENT.Type = "ai" ENT.PrintName = "Enemy United States Ranger" ENT.Author = "DrVrej" ENT.Contact = "http://steamcommunity.com/groups/vrejgaming" ENT.Purpose = "Spawn it and fight with it!" ENT.Instructions = "Click on the spawnicon to spawn it." ENT.Category = "United States Army" if (CLIENT) then local Name = "Enemy United States Ranger" local LangName = "npc_vj_mili_ranger" language.Add(LangName, Name) killicon.Add(LangName,"HUD/killicons/default",Color(255,80,0,255)) la
If this is Vrej's code, contact Vrej before doing anything else.
Sorry, you need to Log In to post a reply to this thread.