Guest User

Untitled

a guest
Aug 9th, 2015
12
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. AddCSLuaFile()
  3.  
  4. /* -------------------------------------------------- Lightsaber effects -------------------------------------------------- */
  5.  
  6. game.AddDecal( "LSScorch", "effects/rb655_scorch" ) -- Why doesn't it work?
  7.  
  8. function rb655_DrawHit( pos, dir )
  9. local effectdata = EffectData()
  10. effectdata:SetOrigin( pos )
  11. effectdata:SetNormal( dir )
  12. util.Effect( "StunstickImpact", effectdata, true, true )
  13.  
  14. //util.Decal( "LSScorch", pos + dir, pos - dir )
  15. util.Decal( "FadingScorch", pos + dir, pos - dir )
  16. end
  17.  
  18. if ( CLIENT ) then return end
  19.  
  20. /* -------------------------------------------------- Prevent +use pickup some users were reporting -------------------------------------------------- */
  21.  
  22. hook.Add( "AllowPlayerPickup", "rb655_lightsaber_prevent_use_pickup", function( ply, ent )
  23. if ( ent:GetClass() == "ent_lightsaber" ) then return false end
  24. end )
  25.  
  26. /* -------------------------------------------------- "Slice" or kill sounds -------------------------------------------------- */
  27.  
  28. local function DoSliceSound( victim, inflictor )
  29. if ( !IsValid( victim ) || !IsValid( inflictor ) ) then return end
  30. if ( string.find( inflictor:GetClass(), "_lightsaber" ) ) then
  31. victim:EmitSound( "lightsaber/SaberHitLaser" .. math.random( 1, 5 ) .. ".wav" )
  32. end
  33. end
  34.  
  35. hook.Add( "EntityTakeDamage", "rb655_lightsaber_kill_snd", function( ent, dmg )
  36. if ( !IsValid( ent ) || !dmg || ent:IsNPC() || ent:IsPlayer() ) then return end
  37. if ( ent:Health() > 0 && ent:Health() - dmg:GetDamage() <= 0 ) then
  38. DoSliceSound( ent, dmg:GetInflictor() )
  39. end
  40. end )
  41.  
  42. hook.Add( "PlayerDeath", "rb655_lightsaber_kill_snd_ply", function( victim, inflictor, attacker )
  43. DoSliceSound( victim, inflictor )
  44. end )
  45.  
  46. hook.Add( "OnNPCKilled", "rb655_lightsaber_kill_snd_npc", function( victim, attacker, inflictor )
  47. DoSliceSound( victim, inflictor )
  48. end )
  49.  
  50. /* -------------------------------------------------- Lightsaber Damage -------------------------------------------------- */
  51.  
  52. -- A list of entities that we should not even try to deal damage to, due to them not taking dealt damage
  53. local rb655_ls_nodamage = {
  54. npc_rollermine = true, -- Sigh, Lua could use arrays
  55. npc_turret_floor = true,
  56. npc_combinedropship = true,
  57. npc_helicopter = true,
  58. monster_tentacle = true,
  59. monster_bigmomma = true,
  60. }
  61. function rb655_LS_DoDamage( tr, wep, ply )
  62. local ent = tr.Entity
  63. if ( !IsValid( ent ) || ( ent:Health() <= 0 && ent:GetClass() != "prop_ragdoll" ) || rb655_ls_nodamage[ ent:GetClass() ] ) then return end
  64.  
  65. local dmginfo = DamageInfo()
  66. dmginfo:SetDamage( 25 )
  67. if ( ent:IsNPC() || !wep:IsWeapon() ) then dmginfo:SetDamage( 100 ) end
  68. dmginfo:SetDamageForce( tr.HitNormal * -13.37 )
  69. dmginfo:SetInflictor( wep )
  70. if ( ent:GetClass() == "npc_zombie" || ent:GetClass() == "npc_fastzombie" ) then
  71. dmginfo:SetDamageType( bit.bor( DMG_SLASH, DMG_CRUSH ) )
  72. end
  73. if ( !IsValid( wep.Owner ) ) then
  74. dmginfo:SetAttacker( wep )
  75. else
  76. dmginfo:SetAttacker( wep.Owner )
  77. end
  78.  
  79. ent:TakeDamageInfo( dmginfo )
  80. end
RAW Paste Data