Advertisement
Guest User

Untitled

a guest
Dec 21st, 2019
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 57.63 KB | None | 0 0
  1. AddCSLuaFile( "cl_init.lua" )
  2. AddCSLuaFile("shared.lua")
  3. include('shared.lua')
  4. /*-----------------------------------------------
  5. *** Copyright (c) 2012-2018 by DrVrej, All rights reserved. ***
  6. No parts of this code or any of its contents may be reproduced, copied, modified or adapted,
  7. without the prior written consent of the author, unless otherwise indicated for stand-alone materials.
  8. -----------------------------------------------*/
  9. ENT.HullType = HULL_MEDIUM
  10. ENT.HasHull = true -- Set to false to disable HULL
  11. ENT.HullSizeNormal = true -- set to false to cancel out the self:SetHullSizeNormal()
  12. ENT.MovementType = VJ_MOVETYPE_AERIAL -- How does the SNPC move?
  13. ENT.VJ_NPC_Class = {"CLASS_SENTINEL", "CLASS_PLAYER_ALLY", "CLASS_HUMAN_PASSIVE", "CLASS_EARTH_FAUNA"} -- NPCs with the same class with be allied to each other
  14. ENT.SoundTbl_Breath = {}
  15. ENT.Aerial_AnimTbl_Calm = {"idleRelaxed"} -- Animations it plays when it's wandering around while idle
  16. ENT.Aerial_AnimTbl_Alerted = {"idleCombat"} -- Animations it plays when it's moving while alerted
  17. ENT.CanFlinch = 1 -- 0 = Don't flinch | 1 = Flinch at any damage | 2 = Flinch only from certain damages
  18. ENT.FlinchChance = 1 -- Chance of it flinching from 1 to x | 1 will make it always flinch
  19. ENT.NextMoveAfterFlinchTime = 0
  20. ENT.NextFlinchTime = 0.5 -- How much time until it can flinch again?
  21. ENT.AnimTbl_CallForHelp = {} -- Call For Help Animations
  22. ENT.AnimTbl_Flinch = {"hurt01", "hurt02", "hurt03"}
  23. --Fly Variables
  24. ENT.flyRadius = 150 //weird but necessary variable. Both controls at what range the sentinel will flee from target, and how much they can move around above their target
  25. ENT.maintainHeight = Vector(0, 0, 350 + ENT.flyRadius) //How far above should we aim to be above the target
  26. ENT.maxPitch = 25
  27. ENT.maxRoll = 25
  28. ENT.enableAI=true
  29. --Damaged
  30. ENT.Bleeds = false -- Does the SNPC bleed? (Blood decal, particle, etc.)
  31. ENT.GibOnDeathDamagesTable = {"All"} -- Damages that it gibs from | "UseDefault" = Uses default damage types | "All" = Gib from any damage
  32. ENT.BloodColor = "Oil"
  33. ENT.HasGibDeathParticles = false -- Does it spawn particles on death or when it gibs? | Mostly used for the settings menu
  34. ENT.HasDeathRagdoll = true -- If set to false, it will not spawn the regular ragdoll of the SNPC
  35. ENT.DeathCorpseModel = {""} -- The corpse model that it will spawn when it dies | Leave empty to use the NPC's model | Put as many models as desired, the base will pick a random one.
  36. ENT.BecomeEnemyToPlayer = true
  37. ENT.BecomeEnemyToPlayerLevel = 4 -- How many times does the player have to hit the SNPC for it to become enemy?
  38. ENT.SoundTbl_Death = {"npc_vj_sent_sentinel/sentinel_death/quick1.wav", "npc_vj_sent_sentinel/sentinel_death/quick2.wav", "npc_vj_sent_sentinel/sentinel_death/quick3.wav", "npc_vj_sent_sentinel/sentinel_death/quick4.wav"}
  39. ENT.HasItemDropsOnDeath = true -- Should it drop items on death?
  40. ENT.ItemDropsOnDeathChance = 1
  41. ENT.ItemDropsOnDeath_EntityList = {"weapon_vj_sent_sentinelbeam"}
  42. ENT.AnimTbl_Death = {""}
  43. ENT.HasDeathAnimation = true
  44. ENT.DeathAnimationTime = 0
  45. --Vision--
  46. ENT.NoChaseAfterCertainRange = true -- Should the SNPC not be able to chase when it's between number x and y?
  47. ENT.SightDistance = 10000 -- How far it can see
  48. ENT.SightAngle = 240 -- The sight angle | Example: 180 would make the it see all around it | Measured in degrees and then converted to radians
  49. ENT.ConstantlyFaceEnemy = true
  50. ENT.ConstantlyFaceEnemy_IfAttacking = true -- Should it face the enemy when attacking?
  51. ENT.NoChaseAfterCertainRange_FarDistance = ENT.maintainHeight.z - ENT.flyRadius -- How far until it can chase again?
  52. ENT.NoChaseAfterCertainRange_CloseDistance = 0
  53. --Movement--
  54. ENT.Aerial_FlyingSpeed_Calm = 160 -- The speed it should fly with, when it's wandering, moving slowly, etc. | Basically walking campared to ground SNPCs
  55. ENT.Aerial_FlyingSpeed_Alerted = 160 --
  56. ENT.TurningSpeed = 15 -- How fast it can turn
  57. ENT.AA_ConstantlyMove = true
  58. ENT.PoseParameterLooking_TurningSpeed = 1 -- How fast does the parameter turn?
  59. --Ranged Attack--
  60. ENT.HasMeleeAttack = false -- Should the SNPC have a melee attack?
  61. ENT.HasRangeAttack = true -- Should the SNPC have a range attack?
  62. ENT.AnimTbl_RangeAttack = {}
  63. ENT.RangeDistance = 1500
  64. ENT.damage = 30 --How much damage is dealt
  65. ENT.beamDuration = 2
  66. ENT.beamTickRate = 0.1 --How often (in seconds) the damage is dealt
  67. ENT.TimeUntilRangeAttackProjectileRelease = ENT.beamTickRate -- How much time until the projectile code is ran?
  68. ENT.RangeAttackReps = (ENT.beamDuration/ENT.beamTickRate)
  69. ENT.NextRangeAttackTime = 4 -- How much time until it can use a range attack?
  70. ENT.NextRangeAttackTime_DoRand = false -- False = Don't use random time | Number = Picks a random number between the regular timer and this timer
  71. ENT.RangeAttackExtraTimers = {}
  72. ENT.RangeAttackAnimationFaceEnemy = false
  73. ENT.DisableRangeAttackAnimation = true -- if true, it will disable the animation code
  74. ENT.DisableDefaultRangeAttackCode = true -- When true, it won't spawn the range attack entity, allowing you to make your own
  75. ENT.RangeAttackAnimationStopMovement = false -- Should it stop moving when performing a range attack?
  76. ENT.AnimTbl_RangeAttack = {} -- Range Attack Animations
  77. ENT.RangeToMeleeDistance = 0 -- How close does it have to be until it uses melee?
  78. --Death Variables
  79. ENT.dead = false
  80. ENT.fall = false
  81. ENT.gib = false
  82. ENT.timeDeath = false
  83. ENT.ignite = false
  84. ENT.randomFire = false
  85. ENT.uniqueId = ""
  86. --Variant Code--
  87. ENT.Model = {"models/sentinels/sentinel_agressor.mdl"} -- The game will pick a random model from the table when the SNPC is spawned | Add as many as you want
  88. ENT.hullMaxHealth = 10
  89. ENT.hullHealth = ENT.hullMaxHealth
  90. ENT.shieldMaxHealth = 30
  91. ENT.shieldHealth = ENT.shieldMaxHealth
  92. ENT.shieldRegenAmount = 1
  93. ENT.shieldRegenSpeed = .1
  94. ENT.shieldRegenDelay = 5
  95. ENT.shieldRegen = false
  96. ENT.modelColor = Color(255, 255, 255, 255)
  97. ENT.trailColor = Color(100,170,225,150)
  98. ENT.shieldColor = Color(255, 255, 255, 255)
  99. ENT.corpseColor = Color(100, 100, 100, 255)
  100. ENT.StartHealth = ENT.hullMaxHealth + ENT.shieldMaxHealth//GetConVarNumber("vj_dum_dummy_h")
  101. ENT.soundTable = {
  102. engineSound = "npc_vj_sent_sentinel/sent_eng1loop.wav",
  103. enginePitch = 100,
  104. engineVolume = 0.4,
  105. firingSound = "npc_vj_sent_sentinel/sentinel_gun/sentGunLoop1.wav",
  106. firingPitch = 100,
  107. firingVolume = 1,
  108. }
  109. ENT.gibTable = {
  110. "models/sentinels/sentinel_a_fuselage.mdl",
  111. "models/sentinels/sentinel_a_head.mdl",
  112. "models/sentinels/sentinel_a_arm.mdl",
  113. "models/sentinels/sentinel_a_arm.mdl",
  114. "models/gibs/metal_gib5.mdl",
  115. "models/gibs/metal_gib5.mdl",
  116. "models/gibs/metal_gib5.mdl",
  117. "models/gibs/metal_gib5.mdl",
  118. "models/combine_helicopter/bomb_debris_3.mdl",
  119. "models/combine_helicopter/bomb_debris_3.mdl",
  120. "models/combine_helicopter/bomb_debris_3.mdl"
  121. }
  122. ENT.engineSound = "npc_vj_sent_sentinel/sent_eng1loop.wav"
  123. ENT.engine = ""
  124. ENT.sentRepeat = ""
  125. ENT.spriteTrail = ""
  126. ENT.corpseModel = ""
  127.  
  128. local attacker = ""
  129. local spawnParticles = true
  130.  
  131. function ENT:CustomOnInitialize()
  132. self.uniqueId = tostring(self:GetCreationID()) //convenient unique identifier for timers
  133. timer.Create("randomChase"..self.uniqueId, 5, 0, function() if (IsValid(self)) then self.maintainHeight = Vector(math.random(-700, 700),math.random(-700, 700), 150 + math.random(-100, 300) + self.flyRadius) end end)
  134. self.engine = CreateSound(self, self.engineSound)
  135. self.corpseModel = self:GetModel()
  136. self.damage = self.damage * GetConVarNumber("vj_sent_sentinelDamageModifier")
  137. self:UseConvars()
  138. self:SpawnLights()
  139. self:TypeOfDeath()
  140. self:InitializeSound()
  141. self:SetColor(self.modelColor)
  142. self:SetCollisionBounds(Vector(33, 33, 26), Vector(-33, -33, -30))
  143. self.spriteTrail = util.SpriteTrail(self, 0,self.trailColor,true,50,10,2,20,"trails/smoke")
  144. end
  145.  
  146. function ENT:InitializeSound()
  147. self.sentRepeat = CreateSound(self, self.soundTable["firingSound"])
  148. self.engine = CreateSound(self, self.soundTable["engineSound"])
  149. self.engine:Play()
  150. self.engine:ChangePitch(self.soundTable["enginePitch"])
  151. self.engine:ChangeVolume(self.soundTable["engineVolume"])
  152. end
  153.  
  154. function ENT:CustomOnAlert(argent)
  155. //self:SetSequence("idleToCombat")
  156. //timer.Simple(1, function() self:SetSequence("idleCombat") end)
  157. end
  158.  
  159. function ENT:TypeOfDeath()
  160. if (math.random(0, 100)) <= GetConVar("vj_sent_chanceFall"):GetInt() then self.fall=true end
  161. if (math.random(0, 100)) <= GetConVar("vj_sent_chanceGib"):GetInt() then self.gib=true end
  162. if (math.random(0, 100)) <= GetConVar("vj_sent_chanceTimedDeath"):GetInt() then self.timeDeath=true end
  163. if (math.random(0, 100)) <= GetConVar("vj_sent_chanceRandomFire"):GetInt() then self.randomFire=true end
  164. if (math.random(0, 100)) <= GetConVar("vj_sent_chanceFire"):GetInt() then self.ignite=true end
  165. end
  166.  
  167. ENT.vAlive = 0
  168. function ENT:CustomOnTakeDamage_BeforeDamage(dmginfo,hitgroup)
  169. self.vAlive = self:GetVelocity() * 2.5
  170. attacker = dmginfo:GetAttacker()
  171. self.shieldRegen = false //disable any current active shield regen
  172. if (self.shieldHealth <= dmginfo:GetDamage() && self.shieldHealth > 0) then
  173. if (spawnParticles == true) then
  174. local effect = EffectData()
  175. effect:SetOrigin(self:GetPos())
  176. self:SphereEffect(true)
  177. timer.Simple(0.1, function()
  178. if (IsValid(self)) then
  179. self:SphereEffect(false)
  180. util.Effect("shieldBreakFX", effect)
  181. end
  182. end)
  183.  
  184. end
  185. end
  186. if (self.shieldHealth > 0) then
  187. self.shieldHealth = math.Clamp(self.shieldHealth - dmginfo:GetDamage(), 0, self.shieldMaxHealth)
  188. elseif (self.shieldHealth <= 0 or self:Health() < dmginfo:GetDamage()) then
  189. self.hullHealth = self.hullHealth - dmginfo:GetDamage()
  190. end
  191. if (self.hullHealth + self.shieldHealth < dmginfo:GetDamage() && !self.dead && self.fall) then
  192. self:FallDeath()
  193. elseif (self.shieldHealth > 0 && self.shieldHealth > dmginfo:GetDamage() && !self.dead) then
  194. self:SphereEffect(true)
  195. end
  196. if (timer.Exists("regendelay"..self.uniqueId)) then
  197. timer.Destroy("regendelay"..self.uniqueId)
  198. end
  199. timer.Create("regendelay"..self.uniqueId, self.shieldRegenDelay,0, function() if(IsValid(self)) then self:RegenShield() end end)
  200. end
  201.  
  202. function ENT:RegenShield() //Regenerate the shield
  203. self.shieldRegen = true
  204. timer.Create("regen"..self.uniqueId, self.shieldRegenSpeed, (self.shieldMaxHealth - self.shieldHealth)/self.shieldRegenAmount , function()
  205. if (self.shieldRegen && !self.dead && (self.shieldHealth < self.shieldMaxHealth)) then
  206. self.shieldHealth = self.shieldHealth + self.shieldRegenAmount
  207. self:SetHealth(self:Health() + self.shieldRegenAmount)
  208. self:SphereEffect(true)
  209. end
  210. end)
  211. end
  212. /* //copy-paste used to test certain variables
  213. PrintMessage(3, "-------------------")
  214. PrintMessage(3, "[var]: "..tostring([var]))
  215. PrintMessage(3, "-------------------")
  216. */
  217. function ENT:FallDeath() //Make NPC limp and fall to their death
  218. self.enableAI=false
  219. self:AddCallback("PhysicsCollide", function()
  220. if (self.dead && !self.timeDeath) then
  221. self:TakeDamage(99999, attacker)
  222. util.ScreenShake( self:GetPos(), 50, 500, 1.2, 500 )
  223. elseif (self.dead && self.timeDeath) then
  224. if !(timer.Exists("destroy"..self.uniqueId)) then
  225. timer.Create("destroy"..self.uniqueId,math.random(0.5,3),1,function() if (IsValid(self)) then self:TakeDamage(99999, attacker) util.ScreenShake( self:GetPos(), 50, 500, 1.2, 500 ) end end)
  226. end
  227. end end)
  228. local effect = EffectData()
  229. self.spriteTrail:Remove()
  230. if (GetConVarNumber("vj_sent_useParticles")==1) then timer.Create("FireFallFX"..self.uniqueId, 0.05, 100, function() if (IsValid(self) && self:GetVelocity().z<-100) then effect:SetOrigin(self:GetPos()) util.Effect("fireFallFX", effect) end end) end
  231. self.RangeAttackReps = 0
  232. self.ConstantlyFaceEnemy = false
  233. self.Behavior = VJ_BEHAVIOR_PASSIVE
  234. if (self.randomFire) then self:RandomFire() end
  235. self.CanFlinch = 0
  236. self.dead = true
  237. self:SetHealth(99999)
  238. self:SetMoveType(MOVETYPE_VPHYSICS)
  239. self:PhysicsInit(SOLID_VPHYSICS)
  240. self:GetPhysicsObject():Wake()
  241. self:GetPhysicsObject():AddAngleVelocity(Vector(math.random(0, 500), math.random(0, 500), math.random(0, 500)))
  242. self:GetPhysicsObject():AddVelocity(self.vAlive)
  243. self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE)
  244. end
  245.  
  246. function ENT:UseConvars()
  247. if (GetConVar("vj_sent_sentinelsDropWeapon"):GetInt() == 1) then
  248. self.HasItemDropsOnDeath = true
  249. elseif (GetConVar("vj_sent_sentinelsDropWeapon"):GetInt() == 0) then
  250. self.HasItemDropsOnDeath = false
  251. end
  252. if (GetConVar("vj_sent_sentinelsFriendly"):GetInt() == 1) then
  253. self.PlayerFriendly = true
  254. self.FriendsWithAllPlayerAllies = true
  255. self.VJ_NPC_Class = {"CLASS_SENTINEL", "CLASS_PLAYER_ALLY", "CLASS_HUMAN_PASSIVE", "CLASS_EARTH_FAUNA"}
  256. elseif (GetConVar("vj_sent_sentinelsFriendly"):GetInt() == 0) then
  257. self.PlayerFriendly = false
  258. self.FriendsWithAllPlayerAllies = false
  259. self.VJ_NPC_Class = {"CLASS_SENTINEL", "CLASS_EARTH_FAUNA"}
  260. for _,v in pairs(ents.GetAll()) do
  261. if v:IsNPC() && (v.PlayerFriendly) then
  262. if (string.StartWith(v:GetClass(), "npc_vj_sent")) then
  263. table.insert(v.VJ_AddCertainEntityAsEnemy,self)
  264. v:VJ_DoSetEnemy(self,true,true)
  265. v:SetEnemy(self)
  266. end
  267. end
  268. //test code for making sentinels hunt each other
  269. end
  270. end
  271. if (GetConVar("vj_sent_useParticles"):GetInt() == 0) then
  272. spawnParticles = false
  273. elseif (GetConVar("vj_sent_useParticles"):GetInt() == 1) then
  274. spawnParticles = true
  275. end
  276. end
  277.  
  278. ENT.shieldFXEnt = ""
  279. ENT.shieldIsOn = false
  280.  
  281. function ENT:SphereEffect(FXOn) //Spawn a sphere around sentinel when taking damage and quickly remove it
  282. if (FXOn==true) then
  283. if (self.shieldIsOn==false) then
  284. self.shieldIsOn=true
  285. self.shieldFXEnt = ents.Create("prop_physics")
  286. self.shieldFXEnt:SetModel( "models/sentinels/sentinel_a_shield.mdl" )
  287. self.shieldFXEnt:SetMaterial("models/alyx/emptool_glow")
  288. self.shieldFXEnt.RenderGroup = RENDERGROUP_TRANSLUCENT
  289. self.shieldFXEnt:SetColor(self.shieldColor)
  290. self.shieldFXEnt:SetModelScale(1.2,0)
  291. self.shieldFXEnt:SetCollisionGroup(1) //allows NPC to see through it's shield
  292. self.shieldFXEnt:SetMoveParent(self)
  293. if (self.shieldRegen) then
  294. self.shieldFXEnt:SetMaterial("models/props_combine/portalball001_sheet")
  295. end
  296. self.shieldFXEnt:SetPos(self:GetPos())
  297. self.shieldFXEnt:Spawn()
  298. //timer.Simple(.5,function() if (IsValid(self)) then self.shieldFXEnt:Remove() end end)
  299. end
  300. if (timer.Exists("shieldFX"..self.uniqueId)) then
  301. timer.Remove("shieldFX"..self.uniqueId)
  302. timer.Create("shieldFX"..self.uniqueId, .5, 1, function()
  303. if (IsValid(self) && IsValid(self.shieldFXEnt)) then
  304. self.shieldFXEnt:Remove()
  305. self.shieldIsOn=false
  306. end
  307. end)
  308. else
  309. timer.Create("shieldFX"..self.uniqueId, .5, 1, function()
  310. if (IsValid(self) && IsValid(self.shieldFXEnt)) then
  311. self.shieldFXEnt:Remove()
  312. self.shieldIsOn=false
  313. end
  314. end)
  315. end
  316. elseif (FXOn==false) then
  317. if (IsValid(self.shieldFXEnt)) then self.shieldFXEnt:Remove() self.shieldIsOn=false end
  318. end
  319. end
  320.  
  321. function ENT:SpawnLights() //Spawn any light sprites around the sentinel
  322. local light = ents.Create("env_glow")
  323. light:SetParent(self, 1)
  324. light:SetKeyValue("rendermode", "5")
  325. light:SetKeyValue("renderamt", "150")
  326. light:SetKeyValue("model","orangecore2.vmt")
  327. light:SetKeyValue("rendercolor","0 155 255")
  328. light:SetKeyValue("scale","0.2")
  329. light:Spawn()
  330. light:Activate()
  331. light:SetPos(self:GetShootPos() + self:GetForward() * 31 + Vector(0, 0, -2))
  332. end
  333.  
  334. // Code to force the sentinel to look at the enemy (in pitch). Doesn't work while actively firing at the enemy currently and/or if the sentinel is falling.
  335. //Test for pitch, yaw when moving
  336. function ENT:CustomOn_PoseParameterLookingCode(pitch,yaw,roll) //helicopter-like movement, finally working!
  337. if (self.VJ_IsBeingControlled) then return end
  338. if (self:GetVelocity():Length() <= 0) then return end
  339. if (self:GetAimVector():Length() <= 0) then return end
  340. if (self:GetVelocity():Length() > 0) then
  341. local forwardFlat = Vector(self:GetVelocity().x, self:GetVelocity().y, 0) + Vector(1, 1, 0)
  342. local rightOrLeft = 1
  343. local aimFlat = Vector(self:GetAimVector().x, self:GetAimVector().y, 0) Vector(1.1, 1, 0) //adding something stops a nil math error, needs fixing
  344. if ((forwardFlat:Cross(aimFlat)).z > 0) then
  345. rightOrLeft = 1
  346. elseif ((forwardFlat:Cross(aimFlat)).z <= 0) then
  347. rightOrLeft = -1
  348. end
  349. local totResult = math.deg(math.acos((forwardFlat:Dot(aimFlat))/(forwardFlat:Length()*aimFlat:Length())))
  350. self:SetAngles(Angle(math.Clamp((self:GetAngles().x + self:Lerp3(totResult/180, self.maxPitch, 0, -self.maxPitch)), -self.maxPitch, self.maxPitch), self:GetAngles().y, (self:GetAngles().z + self:Lerp3((totResult)/180, 0, self.maxRoll*rightOrLeft, 0)), -self.maxRoll, self.maxRoll))
  351. end
  352. end
  353.  
  354. function ENT:CreateCustomCorpse()
  355. local corpse = ents.Create("prop_physics")
  356. corpse:SetModel(self.corpseModel)
  357. corpse:SetColor(self.corpseColor)
  358. corpse:PhysicsInit(SOLID_VPHYSICS)
  359. corpse:GetPhysicsObject():Wake()
  360. corpse:SetPos(self:GetPos())
  361. corpse:SetAngles(self:GetAngles())
  362. corpse:GetPhysicsObject():AddAngleVelocity(Vector(math.random(0, 500), math.random(0, 500), math.random(0, 500)))
  363. corpse:GetPhysicsObject():AddVelocity(self.vAlive)
  364. corpse.RenderGroup = RENDERGROUP_BOTH
  365. corpse.ignite = self.ignite
  366. local effect = EffectData()
  367. effect:SetOrigin(corpse:GetPos())
  368. timer.Create("corpse"..self.uniqueId,2.5,16,function () if (IsValid(corpse)) then effect:SetOrigin(corpse:GetPos()) if (spawnParticles == true) then util.Effect("cball_explode",effect) end corpse:EmitSound(Sound("npc_vj_sent_sentinel/sentinel_welder_impact/weld13.wav")) end end)
  369. timer.Simple(2.5,function() if (IsValid(corpse) && corpse.ignite) then corpse:Ignite() end end)
  370. timer.Simple(40, function () if (IsValid(corpse)) then corpse:Remove() end end)
  371. end
  372.  
  373. function ENT:CustomOnPriorToKilled(dmginfo,hitgroup) //spark effects messing up
  374. util.BlastDamage(self,self,self:GetPos(),50,200)
  375. if (spawnParticles == true) then
  376. local effect = EffectData()
  377. effect:SetOrigin(self:GetPos())
  378. util.Effect("deathFireFX", effect)
  379. util.Effect("cball_explode",effect)
  380. end
  381. ParticleEffect("explosion_turret_break",self:GetPos(),Angle(0,0,0),nil)
  382. if (!self.gib) then
  383. self:CreateCustomCorpse()
  384. end
  385. end
  386.  
  387. function ENT:Lerp3(t, a, b, c)
  388. if (t < 0.5) then
  389. return Lerp(t*2, a, b)
  390. elseif (t >= 0.5) then
  391. return Lerp((t-0.5)*2, b, c)
  392. end
  393. end
  394.  
  395. function ENT:SetUpGibesOnDeath(dmginfo,hitgroup) //Gib a bunch on death
  396. local ent = {}
  397. if (self.gib) then
  398. for k,v in pairs(self.gibTable) do
  399. ent[k] = self:CreateGibEntity("obj_vj_sent_gib",self.gibTable[k])
  400. ent[k]:SetColor(self.corpseColor)
  401. ent[k]:GetPhysicsObject():AddAngleVelocity(Vector(math.random(-100, 100),math.random(-100, 100), math.random(75, 250)))
  402. ent[k]:GetPhysicsObject():AddVelocity(Vector(math.random(-100, 100),math.random(-100, 100), math.random(75, 250)))
  403. local effect=EffectData()
  404. if (GetConVarNumber("vj_sent_useParticles")==1) then timer.Create("FireFallFXSmall"..self.uniqueId..k, 0.025, 300, function() if (IsValid(ent[k]) && ent[k]:GetVelocity():Length()>50) then effect:SetOrigin(ent[k]:GetPos()) util.Effect("fireFallFXSmall", effect) end end) end
  405. end
  406. if (self.ignite) then ent[1]:Ignite() end
  407. end
  408. end
  409.  
  410. function ENT:CustomRangeAttackCode()
  411. if (self.dead) then self:BeamThing(false) return end
  412. if IsValid(self:GetEnemy()) && !self:GetEnemy():Visible(self) then
  413. self:SetNWBool("firing",true)
  414. return false
  415. end
  416. self:SetNWVector("testvector",self:GetEnemy():GetPos()+self:GetEnemy():OBBCenter()) --used to draw a beam from current pos to enemy pos in cl_init.lua
  417. self:GetEnemy():TakeDamage((self.beamTickRate*self.damage/self.beamDuration),self,self)
  418. if (!timer.Exists("firing"..self.uniqueId)) then
  419. self:BeamThing(true)
  420. timer.Create("firing"..self.uniqueId, self.beamDuration,0, function() //purely visual
  421. if (IsValid(self)) then
  422. self:BeamThing(false)
  423. timer.Destroy("firing"..self.uniqueId)
  424. end
  425. end)
  426. end
  427. return false
  428. end
  429.  
  430. function ENT:RandomFire()
  431. local timesToFire = math.random(3, 12)
  432. timer.Create("RandomFireOn"..self.uniqueId, .4, timesToFire, function()
  433. if (IsValid(self)) then
  434. self:SetNWVector("testvector", self:GetShootPos() + self:GetForward()*1500)
  435. self:BeamThing(true)
  436. end
  437. end)
  438. timer.Create("RandomFireOff"..self.uniqueId, .5, timesToFire, function()
  439. if (IsValid(self)) then
  440. self:BeamThing(false)
  441. end
  442. end)
  443. end
  444.  
  445. function ENT:CustomOnRemove()
  446. self.engine:Stop()
  447. if (self.sentRepeat:IsPlaying()) then self.sentRepeat:Stop() end
  448. if (timer.Exists("FireFallFX"..self.uniqueId)) then timer.Destroy("FireFallFX"..self.uniqueId) end
  449. if (timer.Exists("regen"..self.uniqueId)) then timer.Destroy("regen"..self.uniqueId) end
  450. if (timer.Exists("regendelay"..self.uniqueId)) then timer.Destroy("regendelay"..self.uniqueId) end
  451. end
  452.  
  453. //function ENT:Construct()
  454. //end
  455.  
  456. function ENT:BeamThing(beamOn)
  457. if (beamOn) then
  458. self:SetNWBool("firing",true)
  459. self:EmitSound("npc_vj_sent_sentinel/sentinel_gun/in.wav")
  460. self.sentRepeat:Play()
  461. self.sentRepeat:ChangePitch(self.soundTable["firingPitch"])
  462. self.sentRepeat:ChangeVolume(self.soundTable["firingVolume"])
  463. elseif (!beamOn) then
  464. self:SetNWBool("firing", false)
  465. self.sentRepeat:Stop()
  466. self:EmitSound("npc_vj_sent_sentinel/sentinel_gun/out.wav")
  467. end
  468. end
  469.  
  470. ------------------------------------------------------------------------------------------------------------------------------------
  471. ------------------------------------------------------------------------------------------------------------------------------------
  472. ------------------------------------------------------------------------------------------------------------------------------------
  473. ------------------------------------------------------------------------------------------------------------------------------------
  474. ------------------------------------------------------------------------------------------------------------------------------------
  475. ------------------------------------------------------------------------------------------------------------------------------------
  476. ------------------------------------------------------------------------------------------------------------------------------------
  477. ------------------------------------------------------------------------------------------------------------------------------------
  478. ------------------------------------------------------------------------------------------------------------------------------------
  479. ------------------------------------------------------------------------------------------------------------------------------------
  480. -------------------------------------------Modified Existing Functions-------------------------------------------------------------------------
  481.  
  482. function ENT:CreateGibEntity(Ent,Models,Tbl_Features,CustomCode)
  483. // self:CreateGibEntity("prop_ragdoll","",{Pos=self:LocalToWorld(Vector(0,3,0)),Ang=self:GetAngles(),Vel=})
  484. if self.AllowedToGib == false then return end
  485. Ent = Ent or "prop_ragdoll"
  486. if Models == "UseAlien_Small" then Models = {"models/gibs/xenians/sgib_01.mdl","models/gibs/xenians/sgib_02.mdl","models/gibs/xenians/sgib_03.mdl"} end
  487. if Models == "UseAlien_Big" then Models = {"models/gibs/xenians/mgib_01.mdl","models/gibs/xenians/mgib_02.mdl","models/gibs/xenians/mgib_03.mdl","models/gibs/xenians/mgib_04.mdl","models/gibs/xenians/mgib_05.mdl","models/gibs/xenians/mgib_06.mdl","models/gibs/xenians/mgib_07.mdl"} end
  488. if Models == "UseHuman_Small" then Models = {"models/gibs/humans/sgib_01.mdl","models/gibs/humans/sgib_02.mdl","models/gibs/humans/sgib_03.mdl"} end
  489. if Models == "UseHuman_Big" then Models = {"models/gibs/humans/mgib_01.mdl","models/gibs/humans/mgib_02.mdl","models/gibs/humans/mgib_03.mdl","models/gibs/humans/mgib_04.mdl","models/gibs/humans/mgib_05.mdl","models/gibs/humans/mgib_06.mdl","models/gibs/humans/mgib_07.mdl"} end
  490. Models = VJ_PICKRANDOMTABLE(Models)
  491. local vTbl_BloodType = "Red"
  492. if VJ_HasValue({"models/gibs/xenians/sgib_01.mdl","models/gibs/xenians/sgib_02.mdl","models/gibs/xenians/sgib_03.mdl","models/gibs/xenians/mgib_01.mdl","models/gibs/xenians/mgib_02.mdl","models/gibs/xenians/mgib_03.mdl","models/gibs/xenians/mgib_04.mdl","models/gibs/xenians/mgib_05.mdl","models/gibs/xenians/mgib_06.mdl","models/gibs/xenians/mgib_07.mdl"},Models) then
  493. vTbl_BloodType = "Yellow"
  494. end
  495. vTbl_Features = Tbl_Features or {}
  496. vTbl_Position = vTbl_Features.Pos or self:GetPos() +self:OBBCenter()
  497. vTbl_Angle = vTbl_Features.Ang or Angle(math.Rand(-180,180),math.Rand(-180,180),math.Rand(-180,180)) //self:GetAngles()
  498. vTbl_Velocity_NoDamageForce = vTbl_Features.Vel_NoDmgForce or false -- If set to true, it won't add the damage force to the given velocity
  499. vTbl_Velocity = vTbl_Features.Vel or Vector(math.Rand(-100,100),math.Rand(-100,100),math.Rand(150,250)) -- Used to set the velocity | "UseDamageForce" = To use the damage's force only
  500. if self.LatestDmgInfo != nil then
  501. local dmgforce = self.LatestDmgInfo:GetDamageForce()/70
  502. if vTbl_Velocity_NoDamageForce == false && vTbl_Features.Vel != "UseDamageForce" then
  503. vTbl_Velocity = vTbl_Velocity + dmgforce
  504. end
  505. if vTbl_Features.Vel == "UseDamageForce" then
  506. vTbl_Velocity = dmgforce
  507. end
  508. end
  509. vTbl_AngleVelocity = vTbl_Features.AngVel or Vector(math.Rand(-200,200),math.Rand(-200,200),math.Rand(-200,200)) -- Angle velocity, how fast it rotates as it's flying
  510. vTbl_BloodType = vTbl_Features.BloodType or vTbl_BloodType -- Certain entities such as the VJ Gib entity, you can use this to set its gib type
  511. vTbl_BloodDecal = vTbl_Features.BloodDecal or "Default" -- The decal it spawns when it collides with something, leave empty to let the base decide
  512. vTbl_NoFade = vTbl_Features.NoFade or false -- Should it fade away and delete?
  513. vTbl_RemoveOnCorpseDelete = vTbl_Features.RemoveOnCorpseDelete or false -- Should the entity get removed if the corpse is removed?
  514. local gib = ents.Create(Ent)
  515. gib:SetModel(Models)
  516. gib:SetPos(vTbl_Position)
  517. gib:SetAngles(vTbl_Angle)
  518. if gib:GetClass() == "obj_vj_gib" then
  519. gib.BloodType = vTbl_BloodType
  520. gib.Collide_Decal = vTbl_BloodDecal
  521. end
  522. gib:Spawn()
  523. gib:Activate()
  524. gib.IsVJBase_Gib = true
  525. gib.RemoveOnCorpseDelete = vTbl_RemoveOnCorpseDelete
  526. if GetConVarNumber("vj_npc_gibcollidable") == 0 then gib:SetCollisionGroup(1) end
  527. local phys = gib:GetPhysicsObject()
  528. if IsValid(phys) then
  529. //phys:SetMass(60)
  530. phys:AddVelocity(vTbl_Velocity)
  531. phys:AddAngleVelocity(vTbl_AngleVelocity)
  532. end
  533. cleanup.ReplaceEntity(gib)
  534. if GetConVarNumber("vj_npc_fadegibs") == 1 && vTbl_NoFade == false then
  535. if gib:GetClass() == "prop_ragdoll" then gib:Fire("FadeAndRemove","",GetConVarNumber("vj_npc_fadegibstime")) end
  536. if gib:GetClass() == "prop_physics" then gib:Fire("kill","",GetConVarNumber("vj_npc_fadegibstime")) end
  537. end
  538. if vTbl_RemoveOnCorpseDelete == true then//self.Corpse:DeleteOnRemove(extraent)
  539. self.ExtraCorpsesToRemove_Transition[#self.ExtraCorpsesToRemove_Transition+1] = gib
  540. end
  541. if (CustomCode) then CustomCode(gib) end
  542. return gib
  543. end
  544.  
  545.  
  546. ---------------------------------------------------------------------------------------------------------------------
  547.  
  548. //this function needs fixing or deleting for hovering capability
  549. function ENT:AAMove_ChaseEnemy(ShouldPlayAnim,UseCalmVariables)
  550. if self.Dead == true or (self.NextChaseTime > CurTime()) or !IsValid(self:GetEnemy()) then return end
  551. local ShouldPlayAnim = ShouldPlayAnim or false
  552. local UseCalmVariables = UseCalmVariables or false
  553. local Debug = self.AA_EnableDebug
  554. local MoveSpeed = self.Aerial_FlyingSpeed_Alerted
  555. if self.MovementType == VJ_MOVETYPE_AQUATIC then
  556. if Debug == true then
  557. print("--------")
  558. print("ME WL: "..self:WaterLevel())
  559. print("ENEMY WL: "..self:GetEnemy():WaterLevel())
  560. end
  561. -- Yete chouri e YEV leman marmine chourin mech-e che, ere vor gena yev kharen kal e
  562. if self:WaterLevel() <= 2 && self:GetVelocity():Length() > 0 then return end
  563. if self:WaterLevel() <= 1 && self:GetVelocity():Length() > 0 then self:AAMove_Wander(true,true) return end
  564. if self:GetEnemy():WaterLevel() == 0 then self:DoIdleAnimation(1) return end -- Yete teshnamin chouren tours e, getsour
  565. if self:GetEnemy():WaterLevel() <= 1 then -- Yete 0-en ver e, ere vor nayi yete gerna teshanmi-in gerna hasnil
  566. local trene = util.TraceLine({
  567. start = self:GetEnemy():GetPos() + self:OBBCenter(),
  568. endpos = (self:GetEnemy():GetPos() + self:OBBCenter()) + self:GetEnemy():GetUp()*-20,
  569. filter = self,
  570. mins = self:OBBMins(),
  571. maxs = self:OBBMaxs()
  572. })
  573. //PrintTable(trene)
  574. //VJ_CreateTestObject(trene.HitPos,self:GetAngles(),Color(0,255,0),5)
  575. if trene.Hit == true then return end
  576. end
  577. MoveSpeed = self.Aquatic_SwimmingSpeed_Alerted
  578. end
  579.  
  580. if UseCalmVariables == true then
  581. if self.MovementType == VJ_MOVETYPE_AQUATIC then
  582. MoveSpeed = self.Aquatic_SwimmingSpeed_Calm
  583. else
  584. MoveSpeed = self.Aerial_FlyingSpeed_Calm
  585. end
  586. end
  587. self:FaceCertainEntity(self:GetEnemy(),true)
  588.  
  589. if ShouldPlayAnim == true && self.NextChaseTime < CurTime() then
  590. self.AA_CanPlayMoveAnimation = true
  591. if UseCalmVariables == true then
  592. self.AA_CurrentMoveAnimationType = "Calm"
  593. else
  594. self.AA_CurrentMoveAnimationType = "Alert"
  595. end
  596. else
  597. self.AA_CanPlayMoveAnimation = false
  598. end
  599.  
  600. -- Main Calculations
  601. local vel_for = 1
  602. local vel_stop = false
  603. local nearpos = self:VJ_GetNearestPointToEntity(self:GetEnemy())
  604. local startpos = nearpos.MyPosition // self:GetPos()
  605. local endpos = nearpos.EnemyPosition // self:GetEnemy():GetPos()+self:GetEnemy():OBBCenter()
  606. local tr = util.TraceHull({
  607. start = startpos,
  608. endpos = endpos,
  609. filter = self,
  610. mins = self:OBBMins(),
  611. maxs = self:OBBMaxs()
  612. })
  613. local tr_hitpos = tr.HitPos
  614. local dist_selfhit = startpos:Distance(tr_hitpos)
  615. if Debug == true then util.ParticleTracerEx("Weapon_Combine_Ion_Cannon_Beam",tr.StartPos,tr_hitpos,false,self:EntIndex(),0) end //vortigaunt_beam
  616. if dist_selfhit <= 16 && tr.HitWorld == true then
  617. if Debug == true then print("AA: Forward Blocked! [CHASE]") end
  618. vel_for = 1
  619. //vel_for = -200
  620. //vel_stop = true
  621. end
  622. local enepos = self:GetEnemy():GetPos()+self:GetEnemy():OBBCenter() + self.maintainHeight
  623. if self.MovementType == VJ_MOVETYPE_AQUATIC && self:GetEnemy():WaterLevel() < 3 then
  624. enepos = self:GetEnemy():GetPos()
  625. end
  626.  
  627. -- X Calculations
  628. -- Coming soon!
  629.  
  630. -- Z Calculations
  631. local vel_up = MoveSpeed
  632. local dist_selfhit_z = enepos.z - startpos.z -- Get the distance between the hit position and the start position
  633. if dist_selfhit_z > 0 then -- Yete 0-en ver e, ere vor 20-en minchev sahmani tive hasni
  634. if Debug == true then print("AA: GOING UP [CHASE]") end
  635. vel_up = math.Clamp(dist_selfhit_z, 20, MoveSpeed)
  636. elseif dist_selfhit_z < 0 then -- Yete 0-en var e, ere vor nevaz 20-en minchev nevaz sahmani tive hasni
  637. if Debug == true then print("AA: GOING DOWN [CHASE]") end
  638. vel_up = -math.Clamp(math.abs(dist_selfhit_z), 20, MoveSpeed)
  639. else
  640. vel_up = 0
  641. end
  642.  
  643. if dist_selfhit < 100 then -- Yete 100-en var e tive, esel e vor modig e, ere vor gamatsna
  644. MoveSpeed = math.Clamp(dist_selfhit, 100, MoveSpeed)
  645. end
  646. -- Final velocity
  647. if vel_stop == false then
  648. self.CurrentTurningAngle = false
  649. local vel_set = ((enepos + self.maintainHeight) - (self:GetPos() + self:OBBCenter())):GetNormal()*MoveSpeed + self:GetUp()*vel_up + self:GetForward()*vel_for
  650. //local vel_set_yaw = vel_set:Angle().y
  651. self:SetLocalVelocity(vel_set)
  652. local vel_len = CurTime() + (dist_selfhit / vel_set:Length())
  653. self.AA_MoveLength_Wander = 0
  654. if vel_len == vel_len then -- Check for NaN
  655. self.AA_MoveLength_Chase = vel_len
  656. self.NextIdleTime = vel_len
  657. end
  658. if Debug == true then ParticleEffect("vj_impact1_centaurspit", enepos, Angle(0,0,0), self) end
  659. else
  660. self:AAMove_Stop()
  661. end
  662. //self.NextChaseTime = CurTime() + 0.1
  663. end
  664.  
  665. function ENT:Think()
  666. if (self.enableAI==true) then
  667. //self:SetPoseParameter("move_yaw",180)
  668. //print(self:GetBlockingEntity())// end
  669. // if self:IsUnreachable(self:GetEnemy()) && enemy noclipping then...
  670.  
  671. //if self.AA_TargetPos.x == self:GetPos().x then
  672. -- to be coded..
  673. //end
  674.  
  675. //print(self:GetPos())
  676. //print("-------------------------------")
  677. //if self.CurrentSchedule != nil then PrintTable(self.CurrentSchedule) end
  678. //if self.CurrentTask != nil then PrintTable(self.CurrentTask) end
  679. if self:GetVelocity():Length() <= 0 && self.MovementType == VJ_MOVETYPE_GROUND /*&& CurSched.IsMovingTask == true*/ then self:DropToFloor() end
  680.  
  681. local CurSched = self.CurrentSchedule
  682. if CurSched != nil then
  683. if self:IsMoving() then
  684. if CurSched.IsMovingTask_Walk == true && !VJ_HasValue(self.AnimTbl_Walk,self:GetMovementActivity()) then
  685. self:SetMovementActivity(VJ_PICK(self.AnimTbl_Walk))
  686. end
  687. if CurSched.IsMovingTask_Run == true && !VJ_HasValue(self.AnimTbl_Run,self:GetMovementActivity()) then
  688. self:SetMovementActivity(VJ_PICK(self.AnimTbl_Run))
  689. end
  690. end
  691. if CurSched.StopScheduleIfNotMoving == true && (!self:IsMoving() or (self:GetBlockingEntity() != nil && self:GetBlockingEntity():IsNPC())) then // (self:GetGroundSpeedVelocity():Length() <= 0) == true
  692. self:ScheduleFinished(CurSched)
  693. //self:SetCondition(35)
  694. //self:StopMoving()
  695. end
  696. if self:HasCondition(35) && CurSched.AlreadyRanCode_OnFail == false then
  697. if self:DoRunCode_OnFail(CurSched) == true then
  698. self:ClearCondition(35)
  699. end
  700. end
  701. if CurSched.ResetOnFail == true && self:HasCondition(35) == true then
  702. self:StopMoving()
  703. //self:SelectSchedule()
  704. self:ClearCondition(35)
  705. //print("VJ Base: Task Failed Condition Identified! "..self:GetName())
  706. end
  707. end
  708. /*if CurTime() > self.TestT then
  709. self:AddLayeredSequence(self:SelectWeightedSequence(ACT_IDLE),1)
  710. self:SetLayerPlaybackRate(1,0.1)
  711. self:SetLayerLooping(1,true)
  712. timer.Simple(0.5,function() print(self:IsValidLayer(1)) end)
  713. self.TestT = CurTime() + 2 end*/
  714. //self:SetPlaybackRate(1)
  715. //self:AddGesture(ACT_IDLE)
  716. //print(self:IsPlayingGesture(ACT_IDLE))
  717. //print(self:GetArrivalActivity())
  718. //self:SetArrivalActivity(ACT_MELEE_ATTACK1)
  719.  
  720. /*if CurTime() > self.OldMeleeTimer then
  721. for _, backwards in ipairs({"_as_*", "_dmvj_", "_eye_", "_zss_", "_nmrih_"}) do
  722. if string.find(self:GetClass(), backwards) then
  723. self.IsUsingOldMeleeAttackSystem = true
  724. print("found string") else
  725. if self.IsUsingOldMeleeAttackSystem == false then
  726. print("didn't find string")
  727. self.IsUsingOldMeleeAttackSystem = false end
  728. end end
  729. self.OldMeleeTimer = CurTime() + 999999999999999999 *999999999999999999 +999999999999999 *99
  730. end*/
  731.  
  732. //print(self.CurrentTask)
  733. //self:GetBonePosition(self:LookupBone("Bip01 R Hand")
  734. //print(#util.VJ_GetSNPCsWithActiveSoundTracks())
  735. //util.ParticleTracerEx( "vortigaunt_beam", self:GetPos(), lpos, false, self:EntIndex(), 2)
  736. //self:SetColor(Color(0,0,0))
  737. //self:ConvarsOnThink()
  738. self:CustomOnThink()
  739.  
  740. if self.HasSounds == false or self.Dead == true then VJ_STOPSOUND(self.CurrentBreathSound) end
  741. if self.Dead == false && self.HasBreathSound == true && self.HasSounds == true then
  742. if CurTime() > self.NextBreathSoundT then
  743. local brsd = VJ_PICK(self.SoundTbl_Breath)
  744. local dur = math.Rand(self.NextSoundTime_Breath1,self.NextSoundTime_Breath2)
  745. if brsd != false then
  746. VJ_STOPSOUND(self.CurrentBreathSound)
  747. if self.NextSoundTime_Breath_BaseDecide == true then
  748. dur = SoundDuration(brsd)
  749. end
  750. self.CurrentBreathSound = VJ_CreateSound(self,brsd,self.BreathSoundLevel,self:VJ_DecideSoundPitch(self.BreathSoundPitch1,self.BreathSoundPitch2))
  751. end
  752. self.NextBreathSoundT = CurTime() + dur
  753. end
  754. end
  755. --=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
  756. if GetConVarNumber("ai_disabled") == 0 then
  757. if self:GetArrivalActivity() == -1 then
  758. self:SetArrivalActivity(self.CurrentAnim_IdleStand)
  759. end
  760. //if !self:IsOnGround() then self:ClearGoal() end
  761. self:CustomOnThink_AIEnabled()
  762. if self.MovementType == VJ_MOVETYPE_AERIAL or self.MovementType == VJ_MOVETYPE_AQUATIC then -- Yete terogh gam chouri SNPC ene...
  763. -- Yete chouri e YEV leman marmine chourin mech-e che, ere vor gena yev kharen kal e
  764. if self.MovementType == VJ_MOVETYPE_AQUATIC && self:WaterLevel() <= 2 && self:GetVelocity():Length() > 0 then self:AAMove_Wander(true,true) end
  765. if self.AA_CanPlayMoveAnimation == true && self:GetVelocity():Length() > 0 then
  766. self:AAMove_Animation()
  767. //elseif self:GetSequence() != 0 && self.PlayingAttackAnimation == false then
  768. //self:VJ_ACT_PLAYACTIVITY(ACT_IDLE,false,0,false,0,{AlwaysUseSequence=true,SequenceDuration=false})
  769. end
  770. end
  771. //self:DoCustomIdleAnimation()
  772. //if !IsValid(self:GetEnemy()) then self.Alerted = false end
  773. if self.VJDEBUG_SNPC_ENABLED == true then
  774. if GetConVarNumber("vj_npc_printcurenemy") == 1 then print(self:GetClass().."'s Enemy: ",self:GetEnemy()," Alerted? ",self.Alerted) end
  775. if GetConVarNumber("vj_npc_printalerted") == 1 then if self.Alerted == true then print(self:GetClass().." Is Alerted!") else print(self:GetClass().." Is Not Alerted!") end end
  776. if GetConVarNumber("vj_npc_printtakingcover") == 1 then if CurTime() > self.TakingCoverT == true then print(self:GetClass().." Is Not Taking Cover") else print(self:GetClass().." Is Taking Cover ("..self.TakingCoverT-CurTime()..")") end end
  777. if GetConVarNumber("vj_npc_printlastseenenemy") == 1 then PrintMessage(HUD_PRINTTALK, self.LastSeenEnemyTime.." ("..self:GetName()..")") end
  778. end
  779.  
  780. self:IdleSoundCode()
  781. if self.DisableFootStepSoundTimer == false then self:FootStepSoundCode() end
  782. self:WorldShakeOnMoveCode()
  783.  
  784. if self.FollowingPlayer == true then
  785. //print(self:GetTarget())
  786. //print(self.FollowPlayer_Entity)
  787. if GetConVarNumber("ai_ignoreplayers") == 0 then
  788. if !IsValid(self.FollowPlayer_Entity) or !self.FollowPlayer_Entity:Alive() or self:Disposition(self.FollowPlayer_Entity) != D_LI then self:FollowPlayerReset() end
  789. if CurTime() > self.NextFollowPlayerT && IsValid(self.FollowPlayer_Entity) && self.FollowPlayer_Entity:Alive() && self.AlreadyBeingHealedByMedic == false then
  790. local DistanceToPly = self:GetPos():Distance(self.FollowPlayer_Entity:GetPos())
  791. local busy = self:BusyWithActivity()
  792. local abletomove = true
  793. self:SetTarget(self.FollowPlayer_Entity)
  794. if busy == true && DistanceToPly < (self.FollowPlayerCloseDistance * 4) then
  795. abletomove = false
  796. end
  797. if DistanceToPly > self.FollowPlayerCloseDistance then
  798. if abletomove == true then
  799. self.FollowPlayer_GoingAfter = true
  800. self.AlreadyDone_RunSelectSchedule_FollowPlayer = false
  801. if busy == false then
  802. local movetype = "TASK_RUN_PATH"
  803. if DistanceToPly < 220 then
  804. movetype = "TASK_WALK_PATH"
  805. end
  806. self:VJ_TASK_GOTO_TARGET(movetype,function(x)
  807. x.CanShootWhenMoving = true
  808. if self:VJ_HasActiveWeapon() == true then
  809. x.ConstantlyFaceEnemyVisible = true
  810. end
  811. end)
  812. end
  813. end
  814. elseif self.AlreadyDone_RunSelectSchedule_FollowPlayer == false then
  815. if busy == false then
  816. self:StopMoving()
  817. self:SelectSchedule()
  818. end
  819. self.FollowPlayer_GoingAfter = false
  820. self.AlreadyDone_RunSelectSchedule_FollowPlayer = true
  821. end
  822. self.NextFollowPlayerT = CurTime() + self.NextFollowPlayerTime
  823. end
  824. else
  825. self:FollowPlayerReset()
  826. end
  827. end
  828.  
  829. /*
  830. //if CurTime() > self.TestT then
  831. //if type(vACT_Name) != "string" && self:SelectWeightedSequence(vACT_Name) == -1 && self:GetSequenceName(self:SelectWeightedSequence(vACT_Name)) == "Not Found!" then
  832. //print(self:GetSequenceName(self:GetSequence()))
  833. //print(self:VJ_GetNPCSchedule())
  834. local idleanim = self.AnimTbl_IdleStand
  835. local ideanimrand = VJ_PICK(idleanim)
  836. if type(ideanimrand) == "number" then ideanimrand = self:GetSequenceName(self:SelectWeightedSequence(ideanimrand)) end
  837. print(ideanimrand)
  838. // self:IsCurrentSchedule(SCHED_IDLE_STAND) == true &&
  839. if !IsValid(self:GetEnemy()) && !self:IsMoving() && !self.CurrentSchedule && table.Count(idleanim) > 0 && self:GetSequenceName(self:SelectWeightedSequence(ACT_IDLE)) == self:GetSequenceName(self:GetSequence()) && self:GetSequenceName(self:GetSequence()) != ideanimrand then
  840. //print("Should Change Anim!")
  841. self:VJ_ACT_PLAYACTIVITY(ideanimrand,false,0,true,0)
  842. end
  843. //self.TestT = CurTime() + VJ_GetSequenceDuration(self,ideanimrand)
  844. //end
  845. */
  846.  
  847. /*if IsValid(self:GetEnemy()) then
  848. if self:GetEnemy():GetClass() == "player" then
  849. //if !self:GetEnemy():Alive() then
  850. self:SetEnemy(NULL)
  851. self.MyEnemy = NULL
  852. //self:AddEntityRelationship(self:GetEnemy(),4,10)
  853. print("Working")
  854. end
  855. //end
  856. end*/
  857.  
  858. //print(self:GetPathTimeToGoal())
  859. //print(self:GetPathDistanceToGoal())
  860. /*if self.PlayedResetEnemyRunSchedule == true && !self:IsCurrentSchedule(SCHED_FORCED_GO_RUN) == true && (!self.IsVJBaseSNPC_Tank) then
  861. self.PlayedResetEnemyRunSchedule = false
  862. if self.Alerted == false then
  863. //self:VJ_SetSchedule(SCHED_ALERT_SCAN)
  864. //self:VJ_ACT_PLAYACTIVITY(ACT_RANGE_ATTACK1,true,2,false)
  865. timer.Simple(5,function()
  866. if self:IsValid() && self.DisableWandering == false then
  867. self:DoIdleAnimation(1)
  868. end
  869. end)
  870. end
  871. end*/
  872.  
  873. if self.CurrentTurningAngle != false then
  874. self:SetAngles(Angle(math.ApproachAngle(self:GetAngles().p, self.CurrentTurningAngle.p, self.TurningSpeed),math.ApproachAngle(self:GetAngles().y, self.CurrentTurningAngle.y, self.TurningSpeed),math.ApproachAngle(self:GetAngles().r, self.CurrentTurningAngle.r, self.TurningSpeed)))
  875. end
  876.  
  877. local ene = self:GetEnemy()
  878. if IsValid(ene) then
  879. if self.IsDoingFaceEnemy == true /*&& self.VJ_IsBeingControlled == false*/ then self:SetAngles(self:VJ_ReturnAngle((ene:GetPos()-self:GetPos()):Angle())) end
  880. self:DoConstantlyFaceEnemyCode()
  881. if (self.CurrentSchedule != nil && ((self.CurrentSchedule.ConstantlyFaceEnemy == true) or (self.CurrentSchedule.ConstantlyFaceEnemyVisible == true && self:Visible(ene))) /*&& self.VJ_IsBeingControlled == false*/) then self:SetAngles(self:VJ_ReturnAngle((ene:GetPos()-self:GetPos()):Angle())) end
  882. self.ResetedEnemy = false
  883. self:UpdateEnemyMemory(ene,ene:GetPos())
  884. self.LatestEnemyPosition = ene:GetPos()
  885. self.LatestEnemyDistance = self:GetPos():Distance(ene:GetPos())
  886. self.LatestEnemyClass = ene
  887. self.TimeSinceLastSeenEnemy = 0
  888. self.TimeSinceSeenEnemy = self.TimeSinceSeenEnemy + 0.1
  889. if (self:GetForward():Dot((ene:GetPos() - self:GetPos()):GetNormalized()) > math.cos(math.rad(self.SightAngle))) && (self.LatestEnemyDistance < self.SightDistance) then
  890. local seentr = util.TraceLine({start = self:NearestPoint(self:GetPos() +self:OBBCenter()),endpos = ene:EyePos(),filter = function(ent) if (ent:GetClass() == self:GetClass() or self:Disposition(ent) == D_LI) then return false end end})
  891. if (ene:Visible(self) or (IsValid(seentr.Entity) && seentr.Entity:GetClass() == ene)) then
  892. self.LastSeenEnemyTime = 0
  893. self.LatestVisibleEnemyPosition = ene:GetPos()
  894. else
  895. self.LastSeenEnemyTime = self.LastSeenEnemyTime + 0.1
  896. end
  897. else
  898. self.LastSeenEnemyTime = self.LastSeenEnemyTime + 0.1
  899. end
  900.  
  901. if self.CallForHelp == true && self.Dead == false then
  902. if CurTime() > self.NextCallForHelpT then
  903. self:CallForHelpCode(self.CallForHelpDistance)
  904. self.NextCallForHelpT = CurTime() + self.NextCallForHelpTime
  905. end
  906. end
  907.  
  908. if self.NoChaseAfterCertainRange == true && ((self.NoChaseAfterCertainRange_Type == "OnlyRange" && self.HasRangeAttack == true) or (self.NoChaseAfterCertainRange_Type == "Regular")) then
  909. local fardist = self.NoChaseAfterCertainRange_FarDistance
  910. local closedist = self.NoChaseAfterCertainRange_CloseDistance
  911. if fardist == "UseRangeDistance" then fardist = self.RangeDistance end
  912. if closedist == "UseRangeDistance" then closedist = self.RangeToMeleeDistance end
  913. if (self.LatestEnemyDistance + self.maintainHeight.z < fardist) && (self.LatestEnemyDistance+self.maintainHeight.z > closedist) && ene:Visible(self) /*&& self:CanDoCertainAttack("RangeAttack") == true*/ then
  914. self.RangeAttack_DisableChasingEnemy = true
  915. if self.CurrentSchedule != nil && self.CurrentSchedule.Name == "vj_chase_enemy" then self:StopMoving() end
  916. if self.MovementType == VJ_MOVETYPE_GROUND && !self:IsMoving() then self:SetAngles(self:VJ_ReturnAngle((ene:GetPos()-self:GetPos()):Angle())) end
  917. if (self.MovementType == VJ_MOVETYPE_AERIAL or self.MovementType == VJ_MOVETYPE_AQUATIC) && CurTime() > self.AA_MoveLength_Wander /*&& ((self.AA_CurrentMoveAnimationType != "Calm") or (self.AA_CurrentMoveAnimationType == "Calm" && self:GetVelocity():Length() > 0))*/ then self:AAMove_Wander(true,false) /*self:AAMove_Stop()*/ end
  918. else
  919. self.RangeAttack_DisableChasingEnemy = false
  920. if self.CurrentSchedule != nil && self.CurrentSchedule.Name != "vj_chase_enemy" then self:DoChaseAnimation() end
  921. //if GetConVarNumber("vj_npc_nochasingenemy") == 0 then self.DisableChasingEnemy = true end else
  922. //if GetConVarNumber("vj_npc_nochasingenemy") == 0 then self.DisableChasingEnemy = false end
  923. end
  924. end
  925. end
  926.  
  927. if CurTime() > self.NextProcessT then
  928. self:DoEntityRelationshipCheck()
  929. self:DoMedicCode_FindAllies()
  930. self:DoMedicCode_HealAlly()
  931. self.NextProcessT = CurTime() + self.NextProcessTime
  932. end
  933.  
  934. if self.ResetedEnemy == false then
  935. if self.LastSeenEnemyTime > self.LastSeenEnemyTimeUntilReset && (!self.IsVJBaseSNPC_Tank) then
  936. self:LostEnemySoundCode()
  937. self.ResetedEnemy = true
  938. self:ResetEnemy(true)
  939. end
  940.  
  941. if (!IsValid(self:GetEnemy())) or (IsValid(self:GetEnemy()) && self:GetEnemy():Health() <= 0) then
  942. self.ResetedEnemy = true
  943. self:ResetEnemy(true)
  944. end
  945. end
  946.  
  947. /*if CurTime() > self.TestT then
  948. self.VJ_PlayingSequence = true
  949. self:ClearSchedule()
  950. timer.Simple(0.2,function()
  951. if self:IsValid() then
  952. self:VJ_PlaySequence("infectionrise",1,true,self:SequenceDuration(self:LookupSequence("specialidle_sleep")) +3) end end)
  953. self.TestT = CurTime() + self:SequenceDuration("specialidle_sleep") +10 end*/
  954.  
  955. --=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
  956. -- Attack Timers --
  957. if self.MovementType == VJ_MOVETYPE_AERIAL or self.MovementType == VJ_MOVETYPE_AQUATIC then self:SelectSchedule() end
  958. ene = self:GetEnemy()
  959. if IsValid(ene) then
  960. //if self.MovementType == VJ_MOVETYPE_AERIAL then self:SelectSchedule() end//self:AAMove_ChaseEnemy(true) end
  961.  
  962. //if self.VJ_IsBeingControlled == false then
  963. if self.MovementType == VJ_MOVETYPE_STATIONARY && self.CanTurnWhileStationary == true then self:FaceCertainEntity(ene,true) end
  964. if self.MeleeAttackAnimationFaceEnemy == true && self.MeleeAttack_DoingPropAttack == false && self.Dead == false && self.MeleeAttacking == true /*&& timer.Exists("timer_melee_start"..self:EntIndex()) && timer.TimeLeft("timer_melee_start"..self:EntIndex()) > 0*/ then self:FaceCertainEntity(ene,true) end
  965. if self.RangeAttackAnimationFaceEnemy == true && self.Dead == false && self.RangeAttacking == true /*&& timer.Exists("timer_range_start"..self:EntIndex()) && timer.TimeLeft("timer_range_start"..self:EntIndex()) > 0*/ then self:FaceCertainEntity(ene,true) end
  966. if self.LeapAttackAnimationFaceEnemy == true && self.Dead == false && self.LeapAttacking == true /*&& timer.Exists("timer_leap_start"..self:EntIndex()) && timer.TimeLeft("timer_leap_start"..self:EntIndex()) > 0*/ then self:FaceCertainEntity(ene,true) end
  967. //end
  968. //if self.PlayingAttackAnimation == true then self:FaceCertainEntity(ene,true) end
  969. self.ResetedEnemy = false
  970. self.NearestPointToEnemyDistance = self:VJ_GetNearestPointToEntityDistance(ene)
  971. //self:SetMovementActivity(6.5)
  972. //self:SetMovementActivity(ACT_WALK)
  973. self:CustomAttack() -- Custom attack
  974. if self.Dead == false then
  975. self:PoseParameterLookingCode()
  976. end
  977.  
  978. -- Melee Attack --------------------------------------------------------------------------------------------------------------------------------------------
  979. if self.HasMeleeAttack == true then
  980. //print(self:NearestPoint(ene:GetPos() +self:OBBCenter()):Distance(ene:NearestPoint(self:GetPos() +ene:OBBCenter())))
  981. //PrintMessage(HUD_PRINTTALK,self:VJ_GetNearestPointToEntityDistance(ene))
  982. // ene:GetPos():Distance(self:GetPos())
  983. if self:CanDoCertainAttack("MeleeAttack") == true then
  984. self:MultipleMeleeAttacks()
  985. local getproppushorattack = self:PushOrAttackPropsCode()
  986. local ispropattack = false
  987. local isnormalattack = false
  988. local isbeingcontrolled = false
  989. if self.VJ_IsBeingControlled == true then isbeingcontrolled = true end
  990. if getproppushorattack == true then ispropattack = true end
  991. if isbeingcontrolled == false && self.NearestPointToEnemyDistance < self.MeleeAttackDistance && ene:Visible(self) then ispropattack = false isnormalattack = true end
  992. if isbeingcontrolled == true && self.VJ_TheController:KeyDown(IN_ATTACK) then ispropattack = false isnormalattack = true end
  993. if (isbeingcontrolled == true && isnormalattack == true && self:CustomAttackCheck_MeleeAttack() == true) or (isbeingcontrolled == false && self:CustomAttackCheck_MeleeAttack() == true && (isnormalattack == true or (ispropattack == true && self.MeleeAttack_NoProps == false)) && (self:GetForward():Dot((ene:GetPos() -self:GetPos()):GetNormalized()) > math.cos(math.rad(self.MeleeAttackAngleRadius)))) then
  994. self.MeleeAttacking = true
  995. self.RangeAttacking = false
  996. self.AlreadyDoneMeleeAttackFirstHit = false
  997. self.IsAbleToMeleeAttack = false
  998. self.AlreadyDoneFirstMeleeAttack = false
  999. if /*self.VJ_IsBeingControlled == false &&*/ ispropattack == false then self:FaceCertainEntity(ene,true) end
  1000. self:CustomOnMeleeAttack_BeforeStartTimer()
  1001. timer.Simple(self.BeforeMeleeAttackSounds_WaitTime,function() if IsValid(self) then self:BeforeMeleeAttackSoundCode() end end)
  1002. self.NextAlertSoundT = CurTime() + 0.4
  1003. if self.DisableMeleeAttackAnimation == false then
  1004. self.CurrentAttackAnimation = VJ_PICK(self.AnimTbl_MeleeAttack)
  1005. self.CurrentAttackAnimationDuration = VJ_GetSequenceDuration(self,self.CurrentAttackAnimation) -self.MeleeAttackAnimationDecreaseLengthAmount
  1006. if self.MeleeAttackAnimationAllowOtherTasks == false then
  1007. self.PlayingAttackAnimation = true
  1008. timer.Simple(self.CurrentAttackAnimationDuration,function()
  1009. if IsValid(self) then
  1010. self.PlayingAttackAnimation = false
  1011. //if self.TimeUntilMeleeAttackDamage == false then self:StopAttacks() end
  1012. end
  1013. end)
  1014. end
  1015. self:VJ_ACT_PLAYACTIVITY(self.CurrentAttackAnimation,false,0,false,self.MeleeAttackAnimationDelay,{SequenceDuration=self.CurrentAttackAnimationDuration})
  1016. end
  1017. if ispropattack == true then self.MeleeAttack_DoingPropAttack = true else self.MeleeAttack_DoingPropAttack = false end
  1018. if self.TimeUntilMeleeAttackDamage == false then
  1019. self:MeleeAttackCode_DoFinishTimers()
  1020. else
  1021. timer.Create("timer_melee_start"..self:EntIndex(), self.TimeUntilMeleeAttackDamage, self.MeleeAttackReps, function() if ispropattack == true then self:MeleeAttackCode(true) else self:MeleeAttackCode() end end)
  1022. for tk, tv in ipairs(self.MeleeAttackExtraTimers) do
  1023. self:DoAddExtraAttackTimers("timer_melee_start_"..math.Round(CurTime())+math.random(1,99999999),tv,1,"MeleeAttack")
  1024. end
  1025. end
  1026. self:CustomOnMeleeAttack_AfterStartTimer()
  1027. end
  1028. end
  1029. end
  1030.  
  1031. -- Range Attack --------------------------------------------------------------------------------------------------------------------------------------------
  1032. if self.HasRangeAttack == true then
  1033. if self:CanDoCertainAttack("RangeAttack") == true then
  1034. self:MultipleRangeAttacks()
  1035. local isbeingcontrolled = false
  1036. local isbeingcontrolled_attack = false
  1037. if self.VJ_IsBeingControlled == true then isbeingcontrolled = true end
  1038. if isbeingcontrolled == true && self.VJ_TheController:KeyDown(IN_ATTACK2) then isbeingcontrolled_attack = true end
  1039. if (isbeingcontrolled == true && isbeingcontrolled_attack == true && self:CustomAttackCheck_RangeAttack() == true) or (isbeingcontrolled == false && self:CustomAttackCheck_RangeAttack() == true && (self.LatestEnemyDistance < self.RangeDistance) && (self.LatestEnemyDistance > self.RangeToMeleeDistance) && (self:GetForward():Dot((ene:GetPos() -self:GetPos()):GetNormalized()) > math.cos(math.rad(self.RangeAttackAngleRadius)))) then
  1040. if self.RangeAttackAnimationStopMovement == true then self:StopMoving() end
  1041. self.RangeAttacking = true
  1042. self.IsAbleToRangeAttack = false
  1043. self.AlreadyDoneRangeAttackFirstProjectile = false
  1044. self:CustomOnRangeAttack_BeforeStartTimer()
  1045. self:BeforeRangeAttackSoundCode()
  1046. if self.DisableRangeAttackAnimation == false then
  1047. if self.RangeAttackAnimationStopMovement == true then
  1048. self:ClearSchedule()
  1049. self:StopMoving()
  1050. end
  1051. self.CurrentAttackAnimation = VJ_PICK(self.AnimTbl_RangeAttack)
  1052. self.CurrentAttackAnimationDuration = VJ_GetSequenceDuration(self,self.CurrentAttackAnimation) -self.RangeAttackAnimationDecreaseLengthAmount
  1053. self.PlayingAttackAnimation = true
  1054. timer.Simple(self.CurrentAttackAnimationDuration,function()
  1055. if IsValid(self) then
  1056. self.PlayingAttackAnimation = false
  1057. //if self.RangeAttacking == true then self:VJ_SetSchedule(SCHED_CHASE_ENEMY) end
  1058. //if self.TimeUntilRangeAttackProjectileRelease == false then self:StopAttacks() end
  1059. end
  1060. end)
  1061. self:VJ_ACT_PLAYACTIVITY(self.CurrentAttackAnimation,false,0,false,self.RangeAttackAnimationDelay,{SequenceDuration=self.CurrentAttackAnimationDuration})
  1062. end
  1063. if self.TimeUntilRangeAttackProjectileRelease == false then
  1064. self:RangeAttackCode_DoFinishTimers()
  1065. else
  1066. timer.Create("timer_range_start"..self:EntIndex(), self.TimeUntilRangeAttackProjectileRelease, self.RangeAttackReps, function() self:RangeAttackCode() end)
  1067. for tk, tv in ipairs(self.RangeAttackExtraTimers) do
  1068. self:DoAddExtraAttackTimers("timer_range_start_"..math.Round(CurTime())+math.random(1,99999999),tv,1,"RangeAttack")
  1069. end
  1070. end
  1071. self:CustomOnRangeAttack_AfterStartTimer()
  1072. end
  1073. end
  1074. end
  1075.  
  1076. -- Leap Attack --------------------------------------------------------------------------------------------------------------------------------------------
  1077. if self.HasLeapAttack == true then
  1078. if self:CanDoCertainAttack("LeapAttack") == true then
  1079. self:MultipleLeapAttacks()
  1080. local isbeingcontrolled = false
  1081. local isbeingcontrolled_attack = false
  1082. if self.VJ_IsBeingControlled == true then isbeingcontrolled = true end
  1083. if isbeingcontrolled == true && self.VJ_TheController:KeyDown(IN_JUMP) then isbeingcontrolled_attack = true end
  1084. if (isbeingcontrolled == true && isbeingcontrolled_attack == true && self:CustomAttackCheck_LeapAttack() == true) or (isbeingcontrolled == false && self:CustomAttackCheck_LeapAttack() == true && (self:IsOnGround() && self.LatestEnemyDistance < self.LeapDistance) && (self.LatestEnemyDistance > self.LeapToMeleeDistance)) then
  1085. self.LeapAttacking = true
  1086. self.AlreadyDoneLeapAttackFirstHit = false
  1087. self.AlreadyDoneFirstLeapAttack = false
  1088. self.IsAbleToLeapAttack = false
  1089. self.JumpLegalLandingTime = 0
  1090. self:FaceCertainEntity(ene,true)
  1091. self:CustomOnLeapAttack_BeforeStartTimer()
  1092. self:BeforeLeapAttackSoundCode()
  1093. timer.Create( "timer_leap_start_jump"..self:EntIndex(), self.TimeUntilLeapAttackVelocity, 1, function() self:LeapAttackVelocityCode() end)
  1094. if self.DisableLeapAttackAnimation == false then
  1095. self.CurrentAttackAnimation = VJ_PICK(self.AnimTbl_LeapAttack)
  1096. self.CurrentAttackAnimationDuration = VJ_GetSequenceDuration(self,self.CurrentAttackAnimation) -self.LeapAttackAnimationDecreaseLengthAmount
  1097. self.PlayingAttackAnimation = true
  1098. timer.Simple(self.CurrentAttackAnimationDuration,function()
  1099. if IsValid(self) then
  1100. self.PlayingAttackAnimation = false
  1101. //if self.TimeUntilLeapAttackDamage == false then self:StopAttacks() end
  1102. end
  1103. end)
  1104. self:VJ_ACT_PLAYACTIVITY(self.CurrentAttackAnimation,false,0,false,self.LeapAttackAnimationDelay,{SequenceDuration=self.CurrentAttackAnimationDuration})
  1105. end
  1106. if self.TimeUntilLeapAttackDamage == false then
  1107. self:LeapAttackCode_DoFinishTimers()
  1108. else
  1109. timer.Create( "timer_leap_start"..self:EntIndex(), self.TimeUntilLeapAttackDamage, self.LeapAttackReps, function() self:LeapDamageCode() end)
  1110. for tk, tv in ipairs(self.LeapAttackExtraTimers) do
  1111. self:DoAddExtraAttackTimers("timer_leap_start_"..math.Round(CurTime())+math.random(1,99999999),tv,1,"LeapAttack")
  1112. end
  1113. end
  1114. self:CustomOnLeapAttack_AfterStartTimer()
  1115. end
  1116. end
  1117. end
  1118. else
  1119. if self.VJ_IsBeingControlled == false && self.Dead == false then
  1120. self:PoseParameterLookingCode(true)
  1121. //self:ClearPoseParameters()
  1122. end
  1123. self.TimeSinceSeenEnemy = 0
  1124. self.TimeSinceLastSeenEnemy = self.TimeSinceLastSeenEnemy + 0.1
  1125. if self.ResetedEnemy == false && (!self.IsVJBaseSNPC_Tank) then self:LostEnemySoundCode() self.ResetedEnemy = true self:ResetEnemy(true) end
  1126. //self:NextThink(CurTime()+10)
  1127. /*if CurTime() > self.NextFindEnemyT then
  1128. if self.DisableFindEnemy == false then self:FindEnemy() end
  1129. self.NextFindEnemyT = CurTime() + self.NextFindEnemyTime end*/
  1130. //self.LeapAttacking = false
  1131. //self.MeleeAttacking = false
  1132. //self.RangeAttacking = false
  1133. end
  1134. else
  1135. if self.MovementType == VJ_MOVETYPE_AERIAL or self.MovementType == VJ_MOVETYPE_AQUATIC then self:AAMove_Stop() end
  1136. //self:StopAttacks()
  1137. //self:SelectSchedule()
  1138. end
  1139. self:NextThink(CurTime()+(0.069696968793869+FrameTime()))
  1140. return true
  1141. end
  1142. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement