SHARE
TWEET

Untitled

a guest Jul 12th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if SERVER then
  2.    AddCSLuaFile("shared.lua")
  3.    CreateConVar("beeinnodamage", "15", FCVAR_NOTIFY + FCVAR_ARCHIVE)
  4.    CreateConVar("beetraitordamage", "5", FCVAR_NOTIFY + FCVAR_ARCHIVE)
  5. end
  6.  
  7. ENT.Type = "anim"
  8. ENT.Base = "ttt_basegrenade_proj"
  9.  
  10. ENT.Model = Model("models/lucian/props/stupid_bee.mdl")
  11.  
  12. --Change these values to modify damage proporties
  13. ENT.ExplosionDamage = 0
  14. ENT.ExplosionRadius = 0
  15.  
  16. Beecounter = 6
  17.  
  18.  
  19. BeeNPCClass         = "npc_manhack"
  20.  
  21. if SERVER then
  22. BeeInnocentDamage  = GetConVar("beeinnodamage"):GetInt()
  23. BeeTraitorDamage   = GetConVar("beetraitordamage"):GetInt()
  24. end
  25.  
  26. AccessorFunc( ENT, "radius", "Radius", FORCE_NUMBER )
  27. AccessorFunc( ENT, "dmg", "Dmg", FORCE_NUMBER )
  28.  
  29. function ENT:Initialize()
  30.  
  31.    if not self:GetRadius() then self:SetRadius(256) end
  32.    if not self:GetDmg() then self:SetDmg(0) end
  33.    
  34.    self.BaseClass.Initialize(self)
  35.    
  36.     local phys = self:GetPhysicsObject()
  37.     if phys:IsValid() then phys:SetMass(350) end
  38. end
  39.  
  40. local zapsound = Sound("NONOTTHEBEES.wav")
  41. function ENT:Explode(tr)
  42.  
  43.    if SERVER then
  44.    
  45. if GetConVar("beerandom"):GetInt() == 0 then
  46. Beecounter = GetConVar("beecount"):GetInt()
  47. else
  48. Beecounter = math.random(GetConVar("beerandommin"):GetInt(),GetConVar("beerandommax"):GetInt())
  49. end
  50.      
  51.       self.Entity:SetNoDraw(true)
  52.       self.Entity:SetSolid(SOLID_NONE)
  53.  
  54.       local pos = self.Entity:GetPos()
  55.      
  56.       sound.Play(zapsound, pos, 100, 100)
  57.      
  58.       -- pull out of the surface
  59.       if tr.Fraction != 1.0 then
  60.          self.Entity:SetPos(tr.HitPos + tr.HitNormal * 0.6)
  61.       end
  62.  
  63.       --[[if util.PointContents(pos) == CONTENTS_WATER then
  64.          self:Remove()
  65.          return
  66.       end]]--
  67.  
  68.       local effect = EffectData()
  69.       effect:SetStart(pos)
  70.       effect:SetOrigin(pos)
  71.       effect:SetScale(self.ExplosionRadius * 0.3)
  72.       effect:SetRadius(self.ExplosionRadius)
  73.       effect:SetMagnitude(self.ExplosionDamage)
  74.  
  75.       if tr.Fraction != 1.0 then
  76.          effect:SetNormal(tr.HitNormal)
  77.       end
  78.  
  79.       util.Effect("Explosion", effect, true, true)
  80.  
  81.       util.BlastDamage(self, self:GetThrower(), pos, self.ExplosionRadius,self.ExplosionDamage)--self.ExplosionRadius, self.ExplosionDamage)
  82.  
  83.       self:SetDetonateExact(0) 
  84.        
  85.          for i=1,Beecounter do
  86.             local spos = pos+Vector(math.random(-75,75),math.random(-75,75),math.random(0,50))
  87.             local contents = util.PointContents( spos )
  88.             local _i = 0
  89.             while i < 10 and (contents == CONTENTS_SOLID or contents == CONTENTS_PLAYERCLIP) do
  90.                 _i = 1 + i
  91.                 spos = pos+Vector(math.random(-125,125),math.random(-125,125),math.random(-50,50))
  92.                 contents = util.PointContents( spos )
  93.             end
  94.            
  95.             local headBee = SpawnNPC(self:GetThrower(),spos, BeeNPCClass)
  96.        
  97.             headBee:SetNPCState(2)
  98.  
  99.             local Bee = ents.Create("prop_dynamic")
  100.             Bee:SetModel("models/lucian/props/stupid_bee.mdl")
  101.             Bee:SetPos(spos)
  102.             Bee:SetAngles(Angle(0,0,0))
  103.             Bee:SetParent(headBee)
  104.  
  105.             --headBee:SetCollisionGroup(COLLISION_GROUP_WEAPON)
  106.            
  107.             headBee:SetNWEntity("Thrower", self:GetThrower())
  108.             --headBee:SetName(self:GetThrower():GetName())
  109.             headBee:SetNoDraw(true)
  110.             headBee:SetHealth(1000)
  111.         end
  112.      
  113.       self:Remove()
  114.    else
  115.    
  116.       local spos = self.Entity:GetPos()
  117.       local trs = util.TraceLine({start=spos + Vector(0,0,64), endpos=spos + Vector(0,0,-128), filter=self})
  118.       util.Decal("Scorch", trs.HitPos + trs.HitNormal, trs.HitPos - trs.HitNormal)      
  119.  
  120.       self:SetDetonateExact(0)
  121.    end
  122.  
  123. end
  124.  
  125. --From: gamemodes\sandbox\gamemode\commands.lua
  126. --TODO: Adjust for TTT.
  127.  
  128. function SpawnNPC( Player, Position, Class )
  129.  
  130.     local NPCList = list.Get( "NPC" )
  131.     local NPCData = NPCList[ Class ]
  132.    
  133.     -- Don't let them spawn this entity if it isn't in our NPC Spawn list.
  134.     -- We don't want them spawning any entity they like!
  135.     if ( !NPCData ) then
  136.         if ( IsValid( Player ) ) then
  137.             Player:SendLua( "Derma_Message( \"Sorry! You can't spawn that NPC!\" )" );
  138.         end
  139.     return end
  140.    
  141.     local bDropToFloor = false
  142.        
  143.     --
  144.     -- This NPC has to be spawned on a ceiling ( Barnacle )
  145.     --
  146.     if ( NPCData.OnCeiling && Vector( 0, 0, -1 ):Dot( Normal ) < 0.95 ) then
  147.         return nil
  148.     end
  149.    
  150.     if ( NPCData.NoDrop ) then bDropToFloor = false end
  151.    
  152.     --
  153.     -- Offset the position
  154.     --
  155.    
  156.    
  157.     -- Create NPC
  158.     local NPC = ents.Create( NPCData.Class )
  159.     if ( !IsValid( NPC ) ) then return end
  160.  
  161.     NPC:SetPos( Position )
  162.     --
  163.     -- This NPC has a special model we want to define
  164.     --
  165.     if ( NPCData.Model ) then
  166.         NPC:SetModel( NPCData.Model )
  167.     end
  168.    
  169.     --
  170.     -- Spawn Flags
  171.     --
  172.     local SpawnFlags = bit.bor( SF_NPC_FADE_CORPSE, SF_NPC_ALWAYSTHINK)
  173.     if ( NPCData.SpawnFlags ) then SpawnFlags = bit.bor( SpawnFlags, NPCData.SpawnFlags ) end
  174.     if ( NPCData.TotalSpawnFlags ) then SpawnFlags = NPCData.TotalSpawnFlags end
  175.     NPC:SetKeyValue( "spawnflags", SpawnFlags )
  176.    
  177.     --
  178.     -- Optional Key Values
  179.     --
  180.     if ( NPCData.KeyValues ) then
  181.         for k, v in pairs( NPCData.KeyValues ) do
  182.             NPC:SetKeyValue( k, v )
  183.         end    
  184.     end
  185.    
  186.     --
  187.     -- This NPC has a special skin we want to define
  188.     --
  189.     if ( NPCData.Skin ) then
  190.         NPC:SetSkin( NPCData.Skin )
  191.     end
  192.    
  193.     --
  194.     -- What weapon should this mother be carrying
  195.     --
  196.    
  197.     NPC:Spawn()
  198.     NPC:Activate()
  199.    
  200.     if ( bDropToFloor && !NPCData.OnCeiling ) then
  201.         NPC:DropToFloor()  
  202.     end
  203.    
  204.     return NPC
  205. end
  206.  
  207. if SERVER and GetConVarString("gamemode") == "terrortown" then
  208. function BeeNadeDamage(victim, dmg)
  209.     local attacker = dmg:GetAttacker()
  210.    
  211.         if attacker:IsValid() and attacker:IsNPC() and attacker:GetClass() == BeeNPCClass then
  212.         if victim:GetRole() ~= 1  then
  213.             dmg:SetDamage(BeeInnocentDamage)
  214.         else
  215.             dmg:SetDamage(BeeTraitorDamage)
  216.         end
  217.     end
  218.  
  219.     --Annoyingly complex check to make the headcrab ragdolls invisible
  220.     if victim:GetClass() == BeeNPCClass then
  221.         dmg:SetDamageType(DMG_REMOVENORAGDOLL)
  222.         --Odd behaviour occured when killing Bees with the 'crowbar'
  223.         --Extra steps had to be taken to reliably hide the ragdoll.
  224.         if dmg:GetInflictor():GetClass() == "weapon_zm_improvised" then
  225.             local Bee = ents.Create("prop_physics")
  226.             Bee:SetModel("models/lucian/props/stupid_bee.mdl")
  227.             Bee:SetPos(victim:GetPos())
  228.             Bee:SetAngles(victim:GetAngles() + Angle(0,-90,0))
  229.             Bee:SetColor(Color(128,128,128,255))
  230.             Bee:SetCollisionGroup(COLLISION_GROUP_WEAPON)
  231.             Bee:Spawn()
  232.             Bee:Activate()
  233.            
  234.             local phys = Bee:GetPhysicsObject()
  235.             if !(phys && IsValid(phys)) then Bee:Remove() end
  236.        
  237.             victim:SetNoDraw(false)
  238.             victim:SetColor(Color(255,2555,255,1))
  239.             --victim:SetRenderMode(RENDER_TRANSALPHA)
  240.            
  241.             victim:Remove()
  242.         end
  243.         if dmg:GetDamageType() == DMG_DROWN then
  244.             dmg:SetDamage(0)
  245.         end
  246.         if (victim:Health() - dmg:GetDamage()) < 980 then
  247.             local Bee = ents.Create("prop_physics")
  248.             Bee:SetModel("models/lucian/props/stupid_bee.mdl")
  249.             Bee:SetPos(victim:GetPos())
  250.             Bee:SetAngles(victim:GetAngles() + Angle(0,-90,0))
  251.             Bee:SetColor(Color(128,128,128,255))
  252.             Bee:SetCollisionGroup(COLLISION_GROUP_WEAPON)
  253.             Bee:Spawn()
  254.             Bee:Activate()
  255.            
  256.             local phys = Bee:GetPhysicsObject()
  257.             if !(phys && IsValid(phys)) then Bee:Remove() end
  258.            
  259.             victim:Remove()
  260.         end
  261.     end
  262. end
  263.  
  264. hook.Add("EntityTakeDamage","BeenadeDmgHandle",BeeNadeDamage)
  265. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top