Skip to content

Commit

Permalink
FINAL Changes (HOPEFULLY) - 2.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DrVrej committed Jan 25, 2021
1 parent 81eaa5b commit 433eb46
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 46 deletions.
5 changes: 3 additions & 2 deletions lua/autorun/vj_base_autorun.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ VJBASE_VERSION = "2.14.0"
VJBASE_GETNAME = "VJ Base"

-- Shared --
include("vj_base/globals.lua")
include("autorun/vj_menu_spawninfo.lua")
AddCSLuaFile("autorun/vj_globals.lua")
include("autorun/vj_globals.lua")
AddCSLuaFile("autorun/vj_menu_spawninfo.lua")
AddCSLuaFile("autorun/vj_base_autorun.lua")
AddCSLuaFile("autorun/vj_controls.lua")
AddCSLuaFile("autorun/vj_entities.lua")
Expand Down
4 changes: 1 addition & 3 deletions lua/vj_base/globals.lua → lua/autorun/vj_globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -534,14 +534,12 @@ end)
hook.Add("EntityEmitSound", "VJ_EntityEmitSound", function(data)
local ent = data.Entity
if IsValid(ent) then
//PrintTable(data)

-- Investigate System
if SERVER && (ent:IsPlayer() or ent:IsNPC()) && data.SoundLevel >= 75 then
//print("---------------------------")
//PrintTable(data)
local quiet = (string_StartWith(data.OriginalSoundName, "player/footsteps") and (ent:Crouching() or ent:KeyDown(IN_WALK))) or false
if quiet == false && ent.Dead != true then
if quiet != true && ent.Dead != true then
ent.VJ_LastInvestigateSd = CurTime()
ent.VJ_LastInvestigateSdLevel = (data.SoundLevel * data.Volume) + (((data.Volume <= 0.4) and 15) or 0)
end
Expand Down
3 changes: 1 addition & 2 deletions lua/entities/npc_vj_creature_base/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,7 @@ ENT.SoundTrackChance = 1
-- ====== Timer Variables ====== --
-- Randomized time between the two variables, x amount of time has to pass for the sound to play again | Counted in seconds
ENT.NextSoundTime_Breath = true -- true = Base will decide the time | VJ_Set(1, 2) = Custom time
ENT.NextSoundTime_Idle1 = 4
ENT.NextSoundTime_Idle2 = 11
ENT.NextSoundTime_Idle = VJ_Set(4, 11)
ENT.NextSoundTime_Investigate = VJ_Set(5, 5)
ENT.NextSoundTime_LostEnemy = VJ_Set(5, 6)
ENT.NextSoundTime_Alert = VJ_Set(2, 3)
Expand Down
3 changes: 1 addition & 2 deletions lua/entities/npc_vj_human_base/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,7 @@ ENT.SoundTrackChance = 1
-- ====== Timer Variables ====== --
-- Randomized time between the two variables, x amount of time has to pass for the sound to play again | Counted in seconds
ENT.NextSoundTime_Breath = true -- true = Base will decide the time | VJ_Set(1, 2) = Custom time
ENT.NextSoundTime_Idle1 = 8
ENT.NextSoundTime_Idle2 = 25
ENT.NextSoundTime_Idle = VJ_Set(8, 25)
ENT.NextSoundTime_Investigate = VJ_Set(5, 5)
ENT.NextSoundTime_LostEnemy = VJ_Set(5, 6)
ENT.NextSoundTime_Alert = VJ_Set(2, 3)
Expand Down
40 changes: 15 additions & 25 deletions lua/entities/obj_vj_projectile_base/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ ENT.IdleSoundChance = 1
ENT.OnCollideSoundChance = 1
ENT.OnRemoveSoundChance = 1
-- ====== Timer Variables ====== --
ENT.NextSoundTime_Idle1 = 0.2
ENT.NextSoundTime_Idle2 = 0.5
ENT.NextSoundTime_Idle = VJ_Set(0.2, 0.5)
-- ====== Sound Level Variables ====== --
-- The proper number are usually range from 0 to 180, though it can go as high as 511
-- More Information: https://developer.valvesoftware.com/wiki/Soundscripts#SoundLevel_Flags
Expand All @@ -80,14 +79,10 @@ ENT.IdleSoundLevel = 80
ENT.OnCollideSoundLevel = 80
ENT.OnRemoveSoundLevel = 90
-- ====== Sound Pitch Variables ====== --
ENT.StartupSoundPitch1 = 90
ENT.StartupSoundPitch2 = 100
ENT.IdleSoundPitch1 = 90
ENT.IdleSoundPitch2 = 100
ENT.OnCollideSoundPitch1 = 90
ENT.OnCollideSoundPitch2 = 100
ENT.OnRemoveSoundPitch1 = 90
ENT.OnRemoveSoundPitch2 = 100
ENT.StartupSoundPitch = VJ_Set(90, 100)
ENT.IdleSoundPitch = VJ_Set(90, 100)
ENT.OnCollideSoundPitch = VJ_Set(90, 100)
ENT.OnRemoveSoundPitch = VJ_Set(90, 100)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------ Customization Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -151,6 +146,7 @@ function ENT:Initialize()
end

if self.HasStartupSounds == true then self:StartupSoundCode() end
if self.IdleSoundPitch1 then self.IdleSoundPitch = VJ_Set(self.IdleSoundPitch1, self.IdleSoundPitch2) end -- !!!!!!!!!!!!!! DO NOT USE THIS VARIABLE !!!!!!!!!!!!!! [Backwards Compatibility!]

self:CustomOnInitialize()
end
Expand Down Expand Up @@ -278,38 +274,32 @@ end
---------------------------------------------------------------------------------------------------------------------------------------------
function ENT:StartupSoundCode()
if self.HasIdleSounds == false then return end
if CurTime() > self.NextIdleSoundT then
local randomstartupsound = math.random(1,self.StartupSoundChance)
if randomstartupsound == 1 then
self.CurrentStartupSound = VJ_CreateSound(self,self.SoundTbl_Startup,self.StartupSoundLevel,math.random(self.StartupSoundPitch1,self.StartupSoundPitch2))
end
if CurTime() > self.NextIdleSoundT && math.random(1, self.StartupSoundChance) == 1 then
self.CurrentStartupSound = VJ_CreateSound(self, self.SoundTbl_Startup, self.StartupSoundLevel, math.random(self.StartupSoundPitch.a, self.StartupSoundPitch.b))
end
end
---------------------------------------------------------------------------------------------------------------------------------------------
function ENT:IdleSoundCode()
if self.HasIdleSounds == false then return end
if CurTime() > self.NextIdleSoundT then
local randomidlesound = math.random(1,self.IdleSoundChance)
if randomidlesound == 1 /*&& self:VJ_IsPlayingSoundFromTable(self.SoundTbl_Idle) == false*/ then
self.CurrentIdleSound = VJ_CreateSound(self,self.SoundTbl_Idle,self.IdleSoundLevel,math.random(self.IdleSoundPitch1,self.IdleSoundPitch2))
if math.random(1, self.IdleSoundChance) == 1 then
self.CurrentIdleSound = VJ_CreateSound(self, self.SoundTbl_Idle, self.IdleSoundLevel, math.random(self.IdleSoundPitch.a, self.IdleSoundPitch.b))
end
self.NextIdleSoundT = CurTime() + math.Rand(self.NextSoundTime_Idle1,self.NextSoundTime_Idle2)
self.NextIdleSoundT = CurTime() + math.Rand(self.NextSoundTime_Idle.a ,self.NextSoundTime_Idle.b)
end
end
--------------------------------------------------------------------------------------------------------------------------------------------
function ENT:OnCollideSoundCode()
if self.HasOnCollideSounds == false then return end
local randomdeathsound = math.random(1,self.OnCollideSoundChance)
if randomdeathsound == 1 then
self.CurrentDeathSound = VJ_CreateSound(self,self.SoundTbl_OnCollide,self.OnCollideSoundLevel,math.random(self.OnCollideSoundPitch1,self.OnCollideSoundPitch2))
if math.random(1, self.OnCollideSoundChance) == 1 then
self.CurrentDeathSound = VJ_CreateSound(self, self.SoundTbl_OnCollide, self.OnCollideSoundLevel, math.random(self.OnCollideSoundPitch.a, self.OnCollideSoundPitch.b))
end
end
--------------------------------------------------------------------------------------------------------------------------------------------
function ENT:OnRemoveSoundCode()
if self.HasOnRemoveSounds == false then return end
local randomdeathsound = math.random(1,self.OnRemoveSoundChance)
if randomdeathsound == 1 then
self.CurrentDeathSound = VJ_CreateSound(self,self.SoundTbl_OnRemove,self.OnRemoveSoundLevel,math.random(self.OnRemoveSoundPitch1,self.OnRemoveSoundPitch2))
if math.random(1, self.OnRemoveSoundChance) == 1 then
self.CurrentDeathSound = VJ_CreateSound(self, self.SoundTbl_OnRemove, self.OnRemoveSoundLevel, math.random(self.OnRemoveSoundPitch.a, self.OnRemoveSoundPitch.b))
end
end
/*--------------------------------------------------
Expand Down
18 changes: 7 additions & 11 deletions lua/entities/obj_vj_spawner_base/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@ ENT.HasIdleSounds = true -- Does it have idle sounds?
ENT.SoundTbl_Idle = {}
ENT.IdleSoundChance = 1 -- How much chance to play the sound? 1 = always
ENT.IdleSoundLevel = 80
ENT.IdleSoundPitch1 = 80
ENT.IdleSoundPitch2 = 100
ENT.NextSoundTime_Idle1 = 0.2
ENT.NextSoundTime_Idle2 = 0.5
ENT.IdleSoundPitch = VJ_Set(80, 100)
ENT.NextSoundTime_Idle = VJ_Set(0.2, 0.5)
ENT.SoundTbl_SpawnEntity = {}
ENT.SpawnEntitySoundChance = 1 -- How much chance to play the sound? 1 = always
ENT.SpawnEntitySoundLevel = 80
ENT.SpawnEntitySoundPitch1 = 80
ENT.SpawnEntitySoundPitch2 = 100
ENT.SpawnEntitySoundPitch = VJ_Set(80, 100)
-- Independent Variables ---------------------------------------------------------------------------------------------------------------------------------------------
-- These should be left as they are
ENT.Dead = false
Expand Down Expand Up @@ -128,19 +125,18 @@ end
function ENT:IdleSoundCode()
if self.HasIdleSounds == false then return end
if CurTime() > self.NextIdleSoundT then
local randomidlesound = math.random(1,self.IdleSoundChance)
if randomidlesound == 1 /*&& self:VJ_IsPlayingSoundFromTable(self.SoundTbl_Idle) == false*/ then
self.CurrentIdleSound = VJ_CreateSound(self,self.SoundTbl_Idle,self.IdleSoundLevel,math.random(self.IdleSoundPitch1,self.IdleSoundPitch2))
if math.random(1, self.IdleSoundChance) == 1 then
self.CurrentIdleSound = VJ_CreateSound(self, self.SoundTbl_Idle, self.IdleSoundLevel, math.random(self.IdleSoundPitch.a, self.IdleSoundPitch.b))
end
self.NextIdleSoundT = CurTime() + math.Rand(self.NextSoundTime_Idle1,self.NextSoundTime_Idle2)
self.NextIdleSoundT = CurTime() + math.Rand(self.NextSoundTime_Idle.a, self.NextSoundTime_Idle.b)
end
end
---------------------------------------------------------------------------------------------------------------------------------------------
function ENT:SpawnEntitySoundCode()
if self.HasIdleSounds == false then return end
local randomidlesound = math.random(1,self.SpawnEntitySoundChance)
if randomidlesound == 1 /*&& self:VJ_IsPlayingSoundFromTable(self.SoundTbl_Idle) == false*/ then
self.CurrentSpawnEntitySound = VJ_CreateSound(self,self.SoundTbl_SpawnEntity,self.SpawnEntitySoundLevel,math.random(self.SpawnEntitySoundPitch1,self.SpawnEntitySoundPitch2))
self.CurrentSpawnEntitySound = VJ_CreateSound(self, self.SoundTbl_SpawnEntity, self.SpawnEntitySoundLevel, math.random(self.SpawnEntitySoundPitch.a, self.SpawnEntitySoundPitch.b))
end
end
---------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion lua/vj_base/npc_general.lua
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ function ENT:DoEntityRelationshipCheck()
self:VJ_TASK_FACE_X("TASK_FACE_TARGET")
end
end
//print(v.VJ_LastInvestigateSdLevel)
if v.VJ_LastInvestigateSdLevel && vDistanceToMy < (self.InvestigateSoundDistance * v.VJ_LastInvestigateSdLevel) && ((CurTime() - v.VJ_LastInvestigateSd) <= 1) && self.NextInvestigateSoundMove < CurTime() then
if self:Visible(v) then
self:StopMoving()
Expand Down Expand Up @@ -1479,7 +1480,7 @@ function ENT:IdleSoundCode(CustomTbl,Type)
end
end
if setT == true then
self.NextIdleSoundT = CurTime() + math.Rand(self.NextSoundTime_Idle1,self.NextSoundTime_Idle2)
self.NextIdleSoundT = CurTime() + math.Rand(self.NextSoundTime_Idle.a, self.NextSoundTime_Idle.b)
end
end
end
Expand Down

0 comments on commit 433eb46

Please sign in to comment.