Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.63 KB | None | 0 0
  1.  
  2. AddCSLuaFile()
  3.  
  4. DEFINE_BASECLASS( "base_anim" )
  5.  
  6. ENT.Spawnable = false
  7. ENT.DisableDuplicator = true
  8.  
  9. ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
  10.  
  11. util.PrecacheSound( "npc/dog/dog_playfull4.wav" )
  12. util.PrecacheSound( "npc/dog/dog_idle4.wav" )
  13.  
  14. util.PrecacheSound( "weapons/crossbow/hit1.wav" )
  15.  
  16. util.PrecacheModel( "models/effects/hexshield.mdl" )
  17.  
  18. ENT.Hexshield_NoTarget = true
  19.  
  20. -- Inner radius is about 66.571289 (66)
  21. -- Outer radius is about 67.218887 (68)
  22. -- Width is about 0.647598 (2)
  23.  
  24. function HEXSHIELD_MYCLASS( ent )
  25.  
  26. return ent:GetClass() == "hexshield"
  27.  
  28. end
  29.  
  30. function HEXSHIELD_NOTMYCLASS( ent )
  31.  
  32. return ent:GetClass() ~= "hexshield"
  33.  
  34. end
  35.  
  36. function ENT:SetupDataTables()
  37.  
  38. self:NetworkVar( "Entity", 0, "Generator" )
  39. self:NetworkVar( "Bool", 0, "LocalMode" )
  40. self:NetworkVar( "Entity", 1, "TargetPlayer" )
  41.  
  42. self:NetworkVar( "Vector", 0, "ShieldColor" )
  43.  
  44. self:NetworkVar( "Entity", 2, "ReflectModel" )
  45.  
  46. self:NetworkVar( "Float", 0, "LightIntensity" )
  47. self:NetworkVar( "Float", 1, "LightLerp" )
  48.  
  49. end
  50.  
  51. if ( SERVER ) then
  52.  
  53. function ENT:Initialize()
  54.  
  55. self.Events = {}
  56.  
  57. self:SetModel( "models/effects/hexshield.mdl" )
  58. self:DrawShadow( false )
  59. self:PhysicsInit( SOLID_VPHYSICS )
  60. self:SetCollisionGroup( COLLISION_GROUP_IN_VEHICLE )
  61. self:SetMoveType( MOVETYPE_NONE )
  62.  
  63. self:AddEFlags( EFL_NO_DISSOLVE )
  64.  
  65. local physobj = self:GetPhysicsObject()
  66.  
  67. if ( IsValid( physobj ) ) then
  68.  
  69. physobj:SetMaterial( "glass" )
  70. physobj:EnableMotion( false )
  71. physobj:Sleep()
  72.  
  73. end
  74.  
  75. local reflect = ents.Create( "hexshield_reflect" )
  76. reflect:SetPos( self:GetPos() )
  77. reflect:SetAngles( self:GetAngles() )
  78. reflect:SetParent( self )
  79. reflect:SetTransmitWithParent( true )
  80. reflect:Spawn()
  81. self:SetReflectModel( reflect )
  82.  
  83. self:SetCustomCollisionCheck( true )
  84. self:CollisionRulesChanged()
  85.  
  86. self.InitializeTime = CurTime()
  87. self.Events[ 2 ] = self.StartCollisions
  88.  
  89. self.Events[ 4 ] = self.CheckFire
  90.  
  91. end
  92.  
  93. function ENT:CheckGenerator()
  94.  
  95. if ( not IsValid( self:GetGenerator() ) ) then
  96.  
  97. self:Expire()
  98.  
  99. self.Events[ 1 ] = nil
  100.  
  101. end
  102.  
  103. end
  104.  
  105. function ENT:CheckGenerator_Local()
  106.  
  107. if ( not IsValid( self:GetTargetPlayer() ) ) or ( not IsValid( self:GetGenerator() ) ) then
  108.  
  109. self:ExpireLocal()
  110.  
  111. self.Events[ 1 ] = nil
  112.  
  113. end
  114.  
  115. end
  116.  
  117. function ENT:StartCollisions()
  118.  
  119. if ( CurTime() <= self.InitializeTime ) then return end
  120.  
  121. self.Events[ 2 ] = nil
  122.  
  123. self:SetCollisionGroup( COLLISION_GROUP_PASSABLE_DOOR )
  124.  
  125. end
  126.  
  127. function ENT:DoFlex( reflect, i, f )
  128.  
  129. reflect:SetFlexWeight( i, f )
  130.  
  131. self:SetFlexWeight( i, f )
  132.  
  133. end
  134.  
  135. function ENT:Deploy()
  136.  
  137. self.DeployTime = CurTime()
  138.  
  139. self:EmitSound( "npc/dog/dog_playfull4.wav", 75, 50, 1.0, CHAN_STATIC )
  140. self:EmitSound( "npc/dog/dog_idle4.wav", 75, 50, 1.0, CHAN_STATIC )
  141.  
  142. local reflect = self:GetReflectModel()
  143. if ( IsValid( reflect ) ) then for i = 0, 20 do self:DoFlex( reflect, i, 1 ) end end
  144.  
  145. self:SetLightIntensity( 0 )
  146. self:SetLightLerp( 0 )
  147.  
  148. self.Events[ 3 ] = self.Event_Deploy
  149.  
  150. self.Events[ 1 ] = self.CheckGenerator
  151.  
  152. end
  153.  
  154. -- 0.75
  155. -- 0.75 / 20 = 0.0375
  156. -- 1 - 0.75 = 0.25
  157.  
  158. function ENT:Event_Deploy()
  159.  
  160. local f = ( CurTime() - self.DeployTime ) / 1.25
  161.  
  162. if ( f < 1 ) then
  163.  
  164. local reflect = self:GetReflectModel()
  165. if ( IsValid( reflect ) ) then for i = 0, 20 do self:DoFlex( reflect, i, 1 - math.Clamp( ( f - ( i * 0.0375 ) ) / 0.25, 0, 1 ) ) end end
  166.  
  167. f = f ^ 0.5
  168. self:SetLightIntensity( f )
  169. self:SetLightLerp( f )
  170.  
  171. else
  172.  
  173. local reflect = self:GetReflectModel()
  174. if ( IsValid( reflect ) ) then for i = 0, 20 do self:DoFlex( reflect, i, 0 ) end end
  175.  
  176. self:SetLightIntensity( 1 )
  177. self:SetLightLerp( 1 )
  178.  
  179. self.Events[ 3 ] = nil
  180.  
  181. end
  182.  
  183. end
  184.  
  185. function ENT:Expire()
  186.  
  187. self.ExpireTime = CurTime()
  188.  
  189. self.Events[ 3 ] = self.Event_Expire
  190.  
  191. self.Events[ 1 ] = nil
  192.  
  193. end
  194.  
  195. function ENT:Event_Expire()
  196.  
  197. local f = ( CurTime() - self.ExpireTime ) / 0.5
  198.  
  199. if ( f < 1 ) then
  200.  
  201. local reflect = self:GetReflectModel()
  202. if ( IsValid( reflect ) ) then for i = 0, 20 do self:DoFlex( reflect, i, f ) end end
  203.  
  204. f = ( 1 - f ) ^ 0.5
  205. self:SetLightIntensity( f )
  206.  
  207. else
  208.  
  209. local reflect = self:GetReflectModel()
  210. if ( IsValid( reflect ) ) then for i = 0, 20 do self:DoFlex( reflect, i, 1 ) end end
  211.  
  212. self:SetLightIntensity( 0 )
  213.  
  214. self.Events[ 3 ] = nil
  215.  
  216. self:Remove()
  217.  
  218. end
  219.  
  220. end
  221.  
  222. function ENT:StartDeployLocal()
  223.  
  224. self.DeployTime = CurTime()
  225.  
  226. self.LocalEffectCompletion = 0
  227.  
  228. self:EmitSound( "npc/dog/dog_playfull4.wav", 75, 50, 1.0, CHAN_STATIC )
  229. self:EmitSound( "npc/dog/dog_idle4.wav", 75, 50, 1.0, CHAN_STATIC )
  230.  
  231. local reflect = self:GetReflectModel()
  232. if ( IsValid( reflect ) ) then for i = 0, 20 do self:DoFlex( reflect, i, 1 ) end end
  233.  
  234. self:SetLightIntensity( 0 )
  235. self:SetLightLerp( 0 )
  236.  
  237. self.Events[ 3 ] = self.Event_DeployLocal
  238.  
  239. self.Events[ 1 ] = self.CheckGenerator_Local
  240.  
  241. end
  242.  
  243. function ENT:DeployLocal()
  244.  
  245. self.DeployTime = CurTime()
  246.  
  247. self.LocalEffectCompletion = math.Clamp( self.LocalEffectCompletion, 0, 1 )
  248.  
  249. self.Events[ 3 ] = self.Event_DeployLocal
  250.  
  251. self.Events[ 1 ] = self.CheckGenerator_Local
  252.  
  253. end
  254.  
  255. -- 0.75
  256. -- 0.75 / 20 = 0.0375
  257. -- 1 - 0.75 = 0.25
  258.  
  259. function ENT:Event_DeployLocal()
  260.  
  261. local t = CurTime()
  262. local f = self.LocalEffectCompletion + ( ( t - self.DeployTime ) / 1.25 )
  263. self.LocalEffectCompletion = f
  264. self.DeployTime = t
  265.  
  266. if ( f < 1 ) then
  267.  
  268. local reflect = self:GetReflectModel()
  269. if ( IsValid( reflect ) ) then for i = 0, 20 do self:DoFlex( reflect, i, 1 - math.Clamp( ( f - ( i * 0.0375 ) ) / 0.25, 0, 1 ) ) end end
  270.  
  271. f = f ^ 0.5
  272. self:SetLightIntensity( f )
  273. self:SetLightLerp( f )
  274.  
  275. else
  276.  
  277. local reflect = self:GetReflectModel()
  278. if ( IsValid( reflect ) ) then for i = 0, 20 do self:DoFlex( reflect, i, 0 ) end end
  279.  
  280. self:SetLightIntensity( 1 )
  281. self:SetLightLerp( 1 )
  282.  
  283. self.Events[ 3 ] = nil
  284.  
  285. end
  286.  
  287. end
  288.  
  289. function ENT:ExpireLocal()
  290.  
  291. self.ExpireTime = CurTime()
  292.  
  293. self.LocalEffectCompletion = math.Clamp( self.LocalEffectCompletion, 0, 1 )
  294.  
  295. self.Events[ 3 ] = self.Event_ExpireLocal
  296.  
  297. self.Events[ 1 ] = nil
  298.  
  299. end
  300.  
  301. function ENT:Event_ExpireLocal()
  302.  
  303. local t = CurTime()
  304. local f = self.LocalEffectCompletion - ( ( t - self.ExpireTime ) / 1.25 )
  305. self.LocalEffectCompletion = f
  306. self.ExpireTime = t
  307.  
  308. if ( f > 0 ) then
  309.  
  310. local reflect = self:GetReflectModel()
  311. if ( IsValid( reflect ) ) then for i = 0, 20 do self:DoFlex( reflect, i, 1 - math.Clamp( ( f - ( i * 0.0375 ) ) / 0.25, 0, 1 ) ) end end
  312.  
  313. f = f ^ 0.5
  314. self:SetLightIntensity( f )
  315. self:SetLightLerp( f )
  316.  
  317. else
  318.  
  319. local reflect = self:GetReflectModel()
  320. if ( IsValid( reflect ) ) then for i = 0, 20 do self:DoFlex( reflect, i, 1 ) end end
  321.  
  322. self:SetLightIntensity( 0 )
  323. self:SetLightLerp( 0 )
  324.  
  325. self.Events[ 3 ] = nil
  326.  
  327. self:Remove()
  328.  
  329. end
  330.  
  331. end
  332.  
  333. function ENT:CheckFire()
  334.  
  335. if ( self:IsOnFire() ) then self:Extinguish() end
  336.  
  337. end
  338.  
  339. function ENT:OnTick()
  340.  
  341. for k, Event in pairs( self.Events ) do Event( self ) end
  342.  
  343. end
  344.  
  345. hook.Add( "Tick", "hexshield", function()
  346.  
  347. for k, ent in pairs( ents.FindByClass( "hexshield" ) ) do ent:OnTick() end
  348.  
  349. end )
  350.  
  351. local dmg_trace = {}
  352.  
  353. util.AddNetworkString( "hexshield_hit" )
  354.  
  355. local function IsProjectile( ent )
  356.  
  357. if ( not IsValid( ent ) ) then return false end
  358. if ( ent:IsPlayer() or ent:IsWeapon() ) then return false end
  359.  
  360. return ( ent:GetSolid() == SOLID_BBOX ) and ( ent:GetMoveType() == MOVETYPE_FLYGRAVITY )
  361.  
  362. end
  363.  
  364. function ENT:OnDamaged( info )
  365.  
  366. local ent = info:GetInflictor()
  367.  
  368. if ( IsProjectile( ent ) ) then
  369.  
  370. local hitpos = info:GetDamagePosition()
  371. local hitforce = info:GetDamageForce()
  372. local hitnormal = hitforce:GetNormalized()
  373.  
  374. local dif = hitpos - self:GetPos()
  375. dif:Normalize()
  376.  
  377. util.TraceLine( { output = dmg_trace, start = hitpos + ( dif * 66.571289 ), endpos = hitpos + ( dif * -66.571289 ), ignoreworld = true, filter = HEXSHIELD_MYCLASS } )
  378. if ( dmg_trace.Hit ) then hitnormal = dmg_trace.HitNormal end
  379.  
  380. net.Start( "hexshield_hit" )
  381. net.WriteString( ent:GetClass() )
  382. net.WriteString( tostring( ent:GetPos() ) )
  383. net.WriteString( tostring( ent:GetAngles() ) )
  384. net.WriteString( tostring( hitpos ) )
  385. net.WriteString( tostring( hitforce ) )
  386. net.WriteString( tostring( hitnormal ) )
  387. net.Broadcast()
  388.  
  389. end
  390.  
  391. return true
  392.  
  393. end
  394.  
  395. local function IsExplosive( ent )
  396.  
  397. if ( not IsValid( ent ) ) then return false end
  398. if ( ent:IsPlayer() or ent:IsWeapon() ) then return false end
  399.  
  400. local collision_group = ent:GetCollisionGroup()
  401. return ( collision_group == COLLISION_GROUP_PROJECTILE ) or ( collision_group == COLLISION_GROUP_WEAPON )
  402.  
  403. end
  404.  
  405. local function FindDamagePosition( info )
  406.  
  407. local ent = info:GetInflictor()
  408.  
  409. if ( IsExplosive( ent ) ) then
  410.  
  411. local min, max = ent:GetCollisionBounds()
  412.  
  413. if ( min ~= max ) then
  414.  
  415. min:Add( max )
  416. min:Mul( 0.5 )
  417.  
  418. return ent:LocalToWorld( min )
  419.  
  420. end
  421.  
  422. end
  423.  
  424. return info:GetDamagePosition()
  425.  
  426. end
  427.  
  428. local function h_EntityTakeDamage( GMMD, ent, info )
  429.  
  430. if ( #ents.FindByClass( "hexshield" ) < 1 ) then return end
  431.  
  432. if ( HEXSHIELD_MYCLASS( ent ) ) then return ent:OnDamaged( info ) end
  433.  
  434. if ( info:GetDamageType() == DMG_FALL ) then return end
  435.  
  436. local min, max = ent:GetCollisionBounds()
  437. min:Add( max )
  438. min:Mul( 0.5 )
  439.  
  440. util.TraceLine( { output = dmg_trace, start = FindDamagePosition( info ), endpos = ent:LocalToWorld( min ), ignoreworld = true, filter = HEXSHIELD_MYCLASS } )
  441.  
  442. if ( dmg_trace.Hit ) then return true end
  443.  
  444. end
  445.  
  446. local o_EntityTakeDamage = NULL
  447.  
  448. hook.Add( "Initialize", "hexshield_EntityTakeDamage", function()
  449.  
  450. o_EntityTakeDamage = GAMEMODE.EntityTakeDamage
  451.  
  452. if ( not isfunction( o_EntityTakeDamage ) ) then GAMEMODE.EntityTakeDamage = h_EntityTakeDamage return end
  453.  
  454. GAMEMODE.EntityTakeDamage = function( GMMD, ent, info )
  455.  
  456. local h = h_EntityTakeDamage( GMMD, ent, info )
  457. local o = o_EntityTakeDamage( GMMD, ent, info )
  458.  
  459. if ( h or o ) then return true end
  460.  
  461. end
  462.  
  463. end )
  464.  
  465. end
  466.  
  467. if ( CLIENT ) then
  468.  
  469. CreateConVar( "cl_hexshieldcolor", "31 0 255", FCVAR_ARCHIVE + FCVAR_USERINFO )
  470.  
  471. function ENT:Initialize()
  472.  
  473. self:AddEFlags( EFL_NO_DISSOLVE )
  474.  
  475. self:SetCustomCollisionCheck( true )
  476. self:CollisionRulesChanged()
  477.  
  478. end
  479.  
  480. local Apex = Vector( 30.026077, -60.051880, 0.000006 )
  481.  
  482. function ENT:Think()
  483.  
  484. local dlight = DynamicLight( self:EntIndex() )
  485.  
  486. if ( not dlight ) then return end
  487.  
  488. local shield_color = self:GetShieldColor()
  489.  
  490. dlight.pos = LerpVector( self:GetLightLerp(), self:LocalToWorld( Apex ), self:GetPos() )
  491. dlight.r = shield_color.x
  492. dlight.g = shield_color.y
  493. dlight.b = shield_color.z
  494. dlight.brightness = 1
  495. dlight.decay = 640
  496. dlight.size = math.Round( self:GetLightIntensity() * 128 )
  497. dlight.dietime = CurTime() + 1
  498. dlight.nomodel = false
  499. dlight.noworld = false
  500. dlight.style = 0
  501.  
  502. end
  503.  
  504. local mat_color = Material( "models/effects/hexshield_color" )
  505. local mat_reflect = Material( "models/effects/hexshield_reflect" )
  506.  
  507. function ENT:Draw()
  508.  
  509. if ( halo.RenderedEntity() == self ) then return end
  510.  
  511. render.UpdateRefractTexture()
  512.  
  513. self:DrawModel()
  514.  
  515. local shield_color = self:GetShieldColor()
  516.  
  517. shield_color.x = shield_color.x / 255
  518. shield_color.y = shield_color.y / 255
  519. shield_color.z = shield_color.z / 255
  520. mat_color:SetVector( "$color2", shield_color )
  521.  
  522. local blend = render.GetBlend()
  523. render.SetBlend( 0.0275 )
  524.  
  525. render.MaterialOverride( mat_color )
  526. self:DrawModel()
  527. render.MaterialOverride( nil )
  528.  
  529. render.SetBlend( blend )
  530.  
  531. local reflect = self:GetReflectModel()
  532.  
  533. if ( IsValid( reflect ) ) then
  534.  
  535. shield_color.x = ( shield_color.x + 1 ) / 2
  536. shield_color.y = ( shield_color.y + 1 ) / 2
  537. shield_color.z = ( shield_color.z + 1 ) / 2
  538. mat_reflect:SetVector( "$envmaptint", shield_color )
  539.  
  540. reflect:DrawModel()
  541.  
  542. end
  543.  
  544. end
  545.  
  546. local sparkeffect = EffectData()
  547. sparkeffect:SetMagnitude( 1 )
  548. sparkeffect:SetScale( 1 )
  549. sparkeffect:SetRadius( 1 )
  550.  
  551. local projectiles = {}
  552.  
  553. net.Receive( "hexshield_hit", function( l )
  554.  
  555. local class = net.ReadString()
  556. local pos = Vector( net.ReadString() )
  557. local ang = Angle( net.ReadString() )
  558. local hitpos = Vector( net.ReadString() )
  559. local hitforce = Vector( net.ReadString() )
  560. local hitnormal = Vector( net.ReadString() )
  561.  
  562. if ( class == "crossbow_bolt" ) then
  563.  
  564. local min, max = Vector( -0.161628, -0.671804, -0.668841 ), Vector( 22.008184, 0.667681, 0.670734 )
  565.  
  566. local hitstrength = hitforce:Length()
  567. if ( hitstrength > 0 ) then
  568.  
  569. pos:Add( hitforce * ( -21.169812 / hitstrength ) )
  570.  
  571. end
  572.  
  573. local fake = ents.CreateClientProp( "models/crossbow_bolt.mdl" )
  574. fake:SetPos( pos )
  575. fake:SetAngles( ang )
  576. fake:PhysicsInitBox( min, max )
  577. fake:SetCollisionBounds( min, max )
  578. fake:SetCollisionGroup( COLLISION_GROUP_DEBRIS )
  579. fake:SetMoveType( MOVETYPE_VPHYSICS )
  580. fake:Spawn()
  581.  
  582. local physobj = fake:GetPhysicsObject()
  583.  
  584. if ( IsValid( physobj ) ) then
  585.  
  586. physobj:Wake()
  587. physobj:SetMaterial( "metal" )
  588. local r = hitforce - ( hitnormal * ( 2 * hitforce:Dot( hitnormal ) ) )
  589. r:Mul( 0.0078125 )
  590. r:Add( Vector( math.Rand( -8, 8 ), math.Rand( -8, 8 ), math.Rand( -8, 8 ) ) )
  591. physobj:ApplyForceOffset( r, hitpos )
  592.  
  593. end
  594.  
  595. local n = #projectiles
  596. if ( n > 31 ) then
  597. local data = table.remove( projectiles, 1 )
  598. n = n - 1
  599. if ( IsValid( data[ 1 ] ) ) then data[ 1 ]:Remove() end
  600. end
  601. projectiles[ n + 1 ] = { fake, CurTime() }
  602.  
  603. sound.Play( "weapons/crossbow/hit1.wav", hitpos, 75, 100, 1.0 )
  604.  
  605. elseif ( class == "hunter_flechette" ) then
  606.  
  607. local min, max = Vector( -10.234355, -1.889777, -3.071084 ), Vector( 9.826031, 1.591557, 4.202987 )
  608.  
  609. local fake = ents.CreateClientProp( "models/weapons/hunter_flechette.mdl" )
  610. fake:SetPos( pos )
  611. fake:SetAngles( ang )
  612. fake:PhysicsInitBox( min, max )
  613. fake:SetCollisionBounds( min, max )
  614. fake:SetCollisionGroup( COLLISION_GROUP_DEBRIS )
  615. fake:SetMoveType( MOVETYPE_VPHYSICS )
  616. fake:Spawn()
  617.  
  618. local physobj = fake:GetPhysicsObject()
  619.  
  620. if ( IsValid( physobj ) ) then
  621.  
  622. physobj:Wake()
  623. local r = hitforce - ( hitnormal * ( 2 * hitforce:Dot( hitnormal ) ) )
  624. r:Mul( 1.5 )
  625. r:Add( Vector( math.Rand( -8, 8 ), math.Rand( -8, 8 ), math.Rand( -8, 8 ) ) )
  626. physobj:ApplyForceOffset( r, hitpos )
  627.  
  628. end
  629.  
  630. local n = #projectiles
  631. if ( n > 31 ) then
  632. local data = table.remove( projectiles, 1 )
  633. n = n - 1
  634. if ( IsValid( data[ 1 ] ) ) then data[ 1 ]:Remove() end
  635. end
  636. projectiles[ n + 1 ] = { fake, CurTime() }
  637.  
  638. end
  639.  
  640. sparkeffect:SetOrigin( hitpos )
  641. sparkeffect:SetNormal( hitnormal )
  642. util.Effect( "cball_bounce", sparkeffect )
  643.  
  644. end )
  645.  
  646. hook.Add( "Think", "hexshield_hit_projectiles", function()
  647.  
  648. local n = #projectiles
  649. if ( n < 1 ) then return end
  650.  
  651. local t = CurTime()
  652.  
  653. local i = 1
  654. while ( i <= n ) do
  655.  
  656. local data = projectiles[ i ]
  657.  
  658. if ( not IsValid( data[ 1 ] ) ) then
  659.  
  660. table.remove( projectiles, i )
  661. n = n - 1
  662.  
  663. elseif ( ( t - data[ 2 ] ) >= 16 ) then
  664.  
  665. data[ 1 ]:Remove()
  666.  
  667. table.remove( projectiles, i )
  668. n = n - 1
  669.  
  670. else
  671.  
  672. i = i + 1
  673.  
  674. end
  675.  
  676. end
  677.  
  678. end )
  679.  
  680. function ENT:ImpactTrace( tr, damage, name )
  681.  
  682. sparkeffect:SetOrigin( tr.HitPos )
  683. sparkeffect:SetNormal( tr.HitNormal )
  684. util.Effect( "cball_bounce", sparkeffect )
  685.  
  686. end
  687.  
  688. end
  689.  
  690. function ENT:CanTool( ply, trace, name )
  691.  
  692. return false
  693.  
  694. end
  695.  
  696. function ENT:CanProperty( ply, name )
  697.  
  698. return false
  699.  
  700. end
  701.  
  702. local function h_PhysgunPickup( GMMD, ply, ent )
  703.  
  704. return HEXSHIELD_NOTMYCLASS( ent )
  705.  
  706. end
  707.  
  708. local o_PhysgunPickup = NULL
  709.  
  710. hook.Add( "Initialize", "hexshield_PhysgunPickup", function()
  711.  
  712. o_PhysgunPickup = GAMEMODE.PhysgunPickup
  713.  
  714. if ( not isfunction( o_PhysgunPickup ) ) then GAMEMODE.PhysgunPickup = h_PhysgunPickup return end
  715.  
  716. GAMEMODE.PhysgunPickup = function( GMMD, ply, ent )
  717.  
  718. local h = h_PhysgunPickup( GMMD, ply, ent )
  719. local o = o_PhysgunPickup( GMMD, ply, ent )
  720.  
  721. if ( h and o ) then return true end
  722.  
  723. end
  724.  
  725. end )
  726.  
  727. local function h_CanPlayerUnfreeze( GMMD, ply, ent, physobj )
  728.  
  729. return HEXSHIELD_NOTMYCLASS( ent )
  730.  
  731. end
  732.  
  733. local o_CanPlayerUnfreeze = NULL
  734.  
  735. hook.Add( "Initialize", "hexshield_CanPlayerUnfreeze", function()
  736.  
  737. o_CanPlayerUnfreeze = GAMEMODE.CanPlayerUnfreeze
  738.  
  739. if ( not isfunction( o_CanPlayerUnfreeze ) ) then GAMEMODE.CanPlayerUnfreeze = h_CanPlayerUnfreeze return end
  740.  
  741. GAMEMODE.CanPlayerUnfreeze = function( GMMD, ply, ent )
  742.  
  743. local h = h_CanPlayerUnfreeze( GMMD, ply, ent )
  744. local o = o_CanPlayerUnfreeze( GMMD, ply, ent )
  745.  
  746. if ( h and o ) then return true end
  747.  
  748. end
  749.  
  750. end )
  751.  
  752. local function h_EntityFireBullets( GMMD, ent, data )
  753.  
  754. local func = data.Callback
  755. if ( not isfunction( func ) ) then return end
  756. if ( not ent:IsPlayer() ) and ( not ent:IsNPC() ) then return end
  757. local wep = ent:GetActiveWeapon()
  758. if ( not IsValid( wep ) ) or ( not wep.Penetration ) then return end
  759.  
  760. data.Callback = function( attacker, tr, info )
  761.  
  762. if ( IsValid( wep ) ) and ( wep.Penetration ) then
  763.  
  764. if ( HEXSHIELD_MYCLASS( tr.Entity ) ) then
  765.  
  766. wep.Penetration = false
  767.  
  768. func( attacker, tr, info )
  769.  
  770. wep.Penetration = true
  771.  
  772. return
  773.  
  774. end
  775.  
  776. end
  777.  
  778. func( attacker, tr, info )
  779.  
  780. end
  781.  
  782. return true
  783.  
  784. end
  785.  
  786. local o_EntityFireBullets = NULL
  787.  
  788. hook.Add( "Initialize", "hexshield_EntityFireBullets", function()
  789.  
  790. o_EntityFireBullets = GAMEMODE.EntityFireBullets
  791.  
  792. if ( not isfunction( o_EntityFireBullets ) ) then GAMEMODE.EntityFireBullets = h_EntityFireBullets return end
  793.  
  794. GAMEMODE.EntityFireBullets = function( GMMD, ent, data )
  795.  
  796. local h = h_EntityFireBullets( GMMD, ent, data )
  797. local o = o_EntityFireBullets( GMMD, ent, data )
  798.  
  799. if ( h == nil ) then return o end
  800. if ( o == nil ) then return h end
  801.  
  802. return ( h and o )
  803.  
  804. end
  805.  
  806. end )
  807.  
  808. function ENT:ShouldCollide( ent )
  809.  
  810. if ( ent:IsWorld() ) then return false end
  811.  
  812. if ( HEXSHIELD_MYCLASS( ent ) ) then return false end
  813.  
  814. local generator = self:GetGenerator()
  815.  
  816. if ( IsValid( generator ) ) and ( not self:GetLocalMode() ) then
  817.  
  818. local surfaceentity = generator:GetSurfaceEntity()
  819.  
  820. if ( IsValid( surfaceentity ) ) then
  821.  
  822. if ( ent == surfaceentity ) then return false end
  823.  
  824. elseif ( surfaceentity:IsWorld() and generator:GetIsAttached() ) then
  825.  
  826. return true
  827.  
  828. end
  829.  
  830. end
  831.  
  832. if ( ent:IsNPC() or ent:IsPlayer() ) then return true end
  833. local owner = ent:GetOwner()
  834. if ( IsValid( owner ) ) and ( owner:IsNPC() or owner:IsPlayer() ) then return true end
  835. for k, child in pairs( ent:GetChildren() ) do if ( child:IsNPC() or child:IsPlayer() ) then return true end end
  836.  
  837. if ( ent:GetSolid() == SOLID_VPHYSICS ) and ( ent:GetMoveType() == MOVETYPE_VPHYSICS ) then return ( ent:GetVelocity():Length() > 120 ) end
  838.  
  839. return ( ent:GetVelocity():Length() > 0 )
  840.  
  841. end
  842.  
  843. local function h_ShouldCollide( GMMD, enta, entb )
  844.  
  845. return ( ( not isfunction( enta.ShouldCollide ) ) or enta:ShouldCollide( entb ) ) and ( ( not isfunction( entb.ShouldCollide ) ) or entb:ShouldCollide( enta ) )
  846.  
  847. end
  848.  
  849. local o_ShouldCollide = NULL
  850.  
  851. hook.Add( "Initialize", "hexshield_ShouldCollide", function()
  852.  
  853. o_ShouldCollide = GAMEMODE.ShouldCollide
  854.  
  855. if ( not isfunction( o_ShouldCollide ) ) then GAMEMODE.ShouldCollide = h_ShouldCollide return end
  856.  
  857. GAMEMODE.ShouldCollide = function( GMMD, enta, entb )
  858.  
  859. local h = h_ShouldCollide( GMMD, enta, entb )
  860. local o = o_ShouldCollide( GMMD, enta, entb )
  861.  
  862. return ( h and o )
  863.  
  864. end
  865.  
  866. end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement