• Stalker Weapon sound problem
    0 replies, posted
Any one have idea why I don't hear the sound when I am hitting player / wall ? Its creating the decal (and also damages the entity if its player) but its not playing the sound... [CODE]AddCSLuaFile(); if (SERVER) then resource.AddFile("materials/vgui/entities/swep_stalker_beam.vmt") resource.AddFile("materials/vgui/killicons/stalker_beam.vmt") end if ( CLIENT ) then local laser = CreateMaterial("sprites/laserbeamnew", "UnlitGeneric",{ ['$basetexture' ] = "sprites/laser", [ '$additive' ] = "1", [ '$vertexcolor' ] = "1", [ '$vertexalpha' ] = "1", } ) local colbeam={Color(255, 0, 0,255),Color(255, 50, 0,255),Color(255, 150, 0,255)} local sprite={ CreateMaterial("sprites/redglow1stalker", "UnlitGeneric", { ['$basetexture' ] = "sprites/redglow1", [ '$additive' ] = "1", [ '$vertexcolor' ] = "1", [ '$vertexalpha' ] = "1", } ), CreateMaterial("sprites/orangeglow1stalker", "UnlitGeneric",{ ['$basetexture' ] = "sprites/orangeglow1", [ '$additive' ] = "1", [ '$vertexcolor' ] = "1", [ '$vertexalpha' ] = "1", } ), CreateMaterial("sprites/yellowglow1stalker", "UnlitGeneric",{ ['$basetexture' ] = "sprites/yellowglow1", [ '$additive' ] = "1", [ '$vertexcolor' ] = "1", [ '$vertexalpha' ] = "1", } )} function SWEP:ViewModelDrawn( ) if !self.dt.attacking then return end local Owner = self:GetOwner() if ( !ValidEntity( Owner ) ) then return; end local traceres=util.QuickTrace(Owner:EyePos(),Owner:GetAimVector()*(3600*12),Owner) local StartPos = Owner:EyePos()+Vector(0,0,3) render.SetMaterial( laser ) render.DrawBeam( StartPos,traceres.HitPos, 2, 0, 0, colbeam[5] ) render.SetMaterial( sprite[self.dt.power] ) render.DrawSprite( StartPos,76.8, 76.8, Color(255, 200, 200, 255) ) render.DrawSprite( traceres.HitPos,10,10, Color(255, 255, 255, 255) ) self:CreateLight(StartPos,100,0); self:CreateLight(traceres.HitPos,50,1); end function SWEP:DrawWorldModelTranslucent() if !self.dt.attacking then return end local Owner = self:GetOwner(); if ( !ValidEntity( Owner ) ) then return; end local traceres=util.QuickTrace(Owner:EyePos(),Owner:GetAimVector()*(3600*12),Owner) local StartPos = Owner:GetAttachment(Owner:LookupAttachment("eyes")).Pos+Vector(0,0,3) render.SetMaterial( laser ) render.DrawBeam( StartPos,traceres.HitPos, 2, 0, 0, colbeam[self.dt.power] ) render.SetMaterial( sprite[self.dt.power] ) render.DrawSprite( StartPos,76.8, 76.8, Color(255, 200, 200, 255) ) render.DrawSprite( StartPos,16,16, Color(255, 200, 200, 255) ) render.DrawSprite( traceres.HitPos,10,10, Color(255, 255, 255, 255) ) self:CreateLight(Owner:EyePos(),100,0) self:CreateLight(traceres.HitPos,50,1); end function SWEP:CreateLight(pos,size,numb) local dlight = DynamicLight( self:EntIndex()+numb) if ( dlight ) then dlight.r = colbeam[self.dt.power].r dlight.g = colbeam[self.dt.power].g dlight.b = colbeam[self.dt.power].b dlight.Pos = pos dlight.Brightness = 4 dlight.Size = size dlight.Decay = size dlight.DieTime = CurTime() + 0.1 end end function SWEP:DrawWorldModel() end end SWEP.Base = "weapon_cc_base"; SWEP.PrintName = "Stalker"; SWEP.DrawCrosshair = true SWEP.Slot = 1; SWEP.SlotPos = 1; SWEP.RenderGroup = RENDERGROUP_TRANSLUCENT SWEP.UseHands = false; SWEP.ViewModel = ""; SWEP.WorldModel = ""; SWEP.MinRange = 64*12 SWEP.Range = 3600*12//because it's in feet,we convert it. SWEP.BeamDamage={1,3,10} SWEP.DamageDelay = 0.1 SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Ammo = false SWEP.Primary.Automatic = true SWEP.HoldType = "normal"; SWEP.HoldTypeHolster = "normal"; SWEP.Holsterable = false; SWEP.InfoText = [[Secondary: Scream.]]; function SWEP:Initialize() self.AttackTime = CurTime(); self:SetWeaponHoldType( self.HoldType ); self:SetWeaponHoldTypeHolster( self.HoldTypeHolster ); self.dt.power = 1 self.dt.attacking = false if CLIENT then killicon.Add(self:GetClass(),"VGUI/killicons/stalker_beam",Color(255,255,255)); end end function SWEP:SetupDataTables() self:NetworkVar( "Bool", 0, "attacking" ) self:NetworkVar( "Int", 0, "power" ) end function SWEP:Shoot() if( CLIENT ) then return end //so you can't just snipe with the long range of 16384 game units local traceres; if IsValid(self.BeamEnd) then traceres=util.QuickTrace(self.Owner:EyePos(),self.Owner:GetAimVector()*self.Range,{self.Owner,self.BeamEnd}) else traceres=util.QuickTrace(self.Owner:EyePos(),self.Owner:GetAimVector()*self.Range,self.Owner) end /*if traceres.HitWorld && !traceres.HitSky then local Pos1 = traceres.HitPos + traceres.HitNormal local Pos2 = traceres.HitPos - traceres.HitNormal util.Decal("FadingScorch" ,Pos1,Pos2) util.Decal("RedGlowFade",Pos1,Pos2) end*/ local blockmul = 1; if( traceres.Entity:IsPlayer() ) then if( traceres.Entity:GetActiveWeapon() and traceres.Entity:GetActiveWeapon():IsValid() ) then if( traceres.Entity:GetActiveWeapon().IsBlocking and traceres.Entity:GetActiveWeapon():IsBlocking() ) then blockmul = traceres.Entity:GetActiveWeapon().BlockMul; end end end if traceres.Entity:IsValid() then local dmg = DamageInfo() dmg:SetDamageType(DMG_SHOCK) dmg:SetDamage(5 * blockmul) dmg:SetAttacker(self.Owner) dmg:SetInflictor(self) dmg:SetDamagePosition(traceres.HitPos) dmg:SetDamageForce(self.Owner:GetAimVector()*(10000)) traceres.Entity:TakeDamageInfo(dmg) end end function SWEP:OnRemove() if !SERVER then return end self:DestroyEndPos() end function SWEP:Beam(bool) if bool != self.dt.attacking then self.dt.attacking=bool end end function SWEP:CreateEndPos() if (!self.BeamEnd || !IsValid(self.BeamEnd)) && SERVER then self.BeamEnd=ents.Create("base_anim") self.BeamEnd:SetModel(self.WorldModel) self.BeamEnd:SetNoDraw(true) self.BeamEnd:SetPos(Vector(0,0,0)) self.BeamEnd:Spawn() self:CreateSounds(self.BeamEnd) end end function SWEP:DestroyEndPos() if self.BeamEnd && IsValid(self.BeamEnd) then self.BeamEnd.WallSound:Stop() self.BeamEnd.FleshSound:Stop() self.BeamEnd:Remove() self.BeamEnd=NULL; end end function SWEP:CreateSounds(ent) if !ent.WallSound then ent.WallSound = CreateSound( ent, "npc/stalker/laser_burn.wav" ); end if !ent.FleshSound then ent.FleshSound = CreateSound( ent, "npc/stalker/laser_flesh.wav" ); end end function SWEP:UpdateSoundPos() self:CreateEndPos() if SERVER then local traceres=util.QuickTrace(self.Owner:EyePos(),self.Owner:GetAimVector()*self.Range,{self.Owner,self.BeamEnd}) self.BeamEnd:SetPos(traceres.HitPos) if traceres.HitWorld then if !self.BeamEnd.PlayWallSound then self.BeamEnd.WallSound:Play() self.BeamEnd.PlayWallSound = true; end if self.BeamEnd.PlayFleshSound then self.BeamEnd.FleshSound:Stop() self.BeamEnd.PlayFleshSound = false; end if self.BeamEnd.PlayWallSound then self.BeamEnd.WallSound:ChangePitch(100+(10*(self.dt.power-1))) end else if !self.BeamEnd.PlayFleshSound then self.BeamEnd.FleshSound:Play() print("test2") self.BeamEnd.PlayFleshSound = true; end if self.BeamEnd.PlayWallSound then self.BeamEnd.WallSound:Stop() self.BeamEnd.PlayWallSound = false; end end end end function SWEP:BeamDecal() local pPlayer = self.Owner if !pPlayer then return end //so you can't just snipe with the long range of 16384 game units local traceres; if IsValid(self.BeamEnd)
Sorry, you need to Log In to post a reply to this thread.