Skip to content

Commit

Permalink
Addressed comments from The Stig regarding HUD and sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
dhkatz committed Feb 5, 2024
1 parent 3095ee9 commit 28dade5
Show file tree
Hide file tree
Showing 6 changed files with 486 additions and 139 deletions.
30 changes: 29 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.1.0]

### Fixed
- Fixed sound networking so that sounds should now play appropriately on only the owner or all clients
- Fixed the classic HUD not drawing on TTT2 when the `ttt_deadringer_hud_classic` setting is active

### Added
- Added many new settings for adjusting what sounds are played and who hears them
- Settings
- `ttt_deadringer_sound_recharge`
- `ttt_deadringer_sound_uncloak`
- `ttt_deadringer_sound_activate`
- `ttt_deadringer_sound_deactivate`
- You can also suffix these settings with `_local` to change if they are only played to the owner or everyone
- Ex: `ttt_deadringer_sound_uncloak_local 0` will make it so only the owner hears the uncloak sound
- Added `ttt_deadringer_hud_classic`
- Want to use the classic Dead Ringer HUD even in TTT2? Now you can!
- Added `ttt_deadringer_hud_persist`
- If you are using the classic HUD, this will make the HUD persist on even if the Dead Ringer isn't active
- Added `ttt_deadringer_cloak_reactivate`
- When this setting is enabled the Dead Ringer will automatically reactivate when charged


### Changed
- Changed the classic HUD to only draw when the Dead Ringer is activated, cloaked, or on cooldown.
- You can change this with the new `ttt_deadringer_hud_persist` setting

## [3.0.1]

### Fixed
Expand Down Expand Up @@ -92,7 +119,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed addon settings not being set correctly for TTT2 (#1)

[Unreleased]: https://github.com/gmod-workshop/ttt-deadringer/compare/3.0.1...HEAD
[Unreleased]: https://github.com/gmod-workshop/ttt-deadringer/compare/3.1.0...HEAD
[3.1.0]: https://github.com/gmod-workshop/ttt-deadringer/compare/3.0.1...3.1.0
[3.0.1]: https://github.com/gmod-workshop/ttt-deadringer/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/gmod-workshop/ttt-deadringer/compare/2.2.0...3.0.0
[2.2.0]: https://github.com/gmod-workshop/ttt-deadringer/compare/2.1.1...2.2.0
Expand Down
82 changes: 14 additions & 68 deletions lua/autorun/ttt_deadringer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CreateConVar('ttt_deadringer_cloak_duration', '7', flags, 'Time that the Dead Ri
CreateConVar('ttt_deadringer_cloak_reuse', '0', flags, 'Whether or not the Dead Ringer will convert unused cloak time into charge time.')
CreateConVar('ttt_deadringer_cloak_transparency', '0.0', flags, 'Transparency of the Dead Ringer cloak. (0.0 = invisible, 1.0 = visible)')
CreateConVar('ttt_deadringer_cloak_targetid', '0', flags, 'Whether or not the Dead Ringer will show the target ID while cloaked.')
CreateConVar('ttt_deadringer_cloak_reactivate', '0', flags, 'Whether or not the Dead Ringer will automatically reactivate after recharging.')

CreateConVar('ttt_deadringer_damage_threshold', '2', flags, 'Threshold to trigger the Dead Ringer. The threshold is a flat value, not a percentage')
CreateConVar('ttt_deadringer_damage_reduction', '0.65', flags, 'Damage reduction while cloaked.')
Expand All @@ -56,74 +57,19 @@ CreateConVar('ttt_deadringer_damage_reduction_initial', '0.75', flags, 'Percenta
CreateConVar('ttt_deadringer_corpse_mode', '0', flags, 'Whether or not the Dead Ringer will show the real role of the player on the corpse. (0 = fake, 1 = real, 2 = innocent)')
CreateConVar('ttt_deadringer_corpse_confirm', '0', flags, 'Whether or not the Dead Ringer will confirm the death of the player on the corpse. (Not recommended for TTT2)')

-- Sandbox Compatibility

hook.Add('AddToolMenuCategories', 'DeadringerAddToolMenuCategories', function()
spawnmenu.AddToolCategory('Utilities', 'Dead Ringer', 'Dead Ringer')
end)

local DEADRINGER_DEFAULTS = {
ttt_deadringer_cloak_cooldown = 20,
ttt_deadringer_cloak_duration = 7,
ttt_deadringer_cloak_reuse = 0,
ttt_deadringer_cloak_transparency = 0,
ttt_deadringer_cloak_targetid = 0,
ttt_deadringer_damage_reduction = 0.65,
ttt_deadringer_damage_reduction_time = 3,
ttt_deadringer_damage_reduction_initial = 0.75,
ttt_deadringer_damage_threshold = 2,
ttt_deadringer_corpse_mode = 0,
ttt_deadringer_corpse_confirm = 0
}

hook.Add('PopulateToolMenu', 'DeadringerPopulateToolMenu', function()
spawnmenu.AddToolMenuOption('Utilities', 'Dead Ringer', 'dead_ringer', 'Settings', '', '', function(panel)
panel:Help('Dead Ringer Settings')

panel:ToolPresets('ttt_deadringer_presets', DEADRINGER_DEFAULTS)

panel:Help('General Settings')

panel:NumSlider('Charge Time', 'ttt_deadringer_cloak_cooldown', 1, 60, 0)
panel:ControlHelp('Time it takes to recharge the Dead Ringer.')

panel:Help('Cloak Settings')

panel:NumSlider('Cloak Time', 'ttt_deadringer_cloak_duration', 1, 60, 0)
panel:ControlHelp('Time that the Dead Ringer will cloak you for.')

panel:CheckBox('Cloak Time Reuse', 'ttt_deadringer_cloak_reuse')
panel:ControlHelp('Whether or not the Dead Ringer will convert unused cloak time into charge time.')

panel:NumSlider('Cloak Transparency', 'ttt_deadringer_cloak_transparency', 0, 1, 2)
panel:ControlHelp('Transparency of the Dead Ringer cloak. (0.0 = invisible, 1.0 = visible)')

panel:CheckBox('Cloak Target ID', 'ttt_deadringer_cloak_targetid')
panel:ControlHelp('Whether or not the Dead Ringer will show the target ID while cloaked.')

panel:Help('Damage Reduction Settings')

panel:NumSlider('Damage Threshold', 'ttt_deadringer_damage_threshold', 0, 100, 0)
panel:ControlHelp('The threshold is a flat value, not a percentage')

panel:NumSlider('Damage Reduction', 'ttt_deadringer_damage_reduction', 0, 1, 2)
panel:ControlHelp('Damage reduction while cloaked.')

panel:NumSlider('Damage Reduction Time', 'ttt_deadringer_damage_reduction_time', 0, 60, 2)
panel:ControlHelp('Damage reduction time while cloaked. (1.0 = 1 second of damage reduction)')

panel:NumSlider('Damage Reduction Initial', 'ttt_deadringer_damage_reduction_initial', 0, 1, 2)
panel:ControlHelp('Percentage of damage reduction for the initial hit which triggers the Dead Ringer. (0.75 = 75%)')

panel:Help('Corpse Settings')

panel:NumSlider('Role Mode', 'ttt_deadringer_corpse_mode', 0, 2, 0)
panel:ControlHelp('Whether or not the Dead Ringer will show the real role of the player on the corpse. (0 = fake, 1 = real, 2 = innocent)')

panel:CheckBox('Confirm Death', 'ttt_deadringer_corpse_confirm')
panel:ControlHelp('Whether or not the Dead Ringer will confirm the death of the player on the corpse. (Not recommended for TTT2)')
end)
end)
CreateConVar('ttt_deadringer_hud_persist', '0', flags, 'Whether or not the Dead Ringer HUD will persist even while it is not activated.')
CreateConVar('ttt_deadringer_hud_classic', '0', flags, 'Whether or not the Dead Ringer HUD will use the classic style. (TTT2 only)')

CreateConVar('ttt_deadringer_sound_cloak', '0', flags, 'Whether or not the Dead Ringer will play a sound when cloaking.')
CreateConVar('ttt_deadringer_sound_cloak_local', '0', flags, ' Where or not the cloaking sound is played locally only.')
CreateConVar('ttt_deadringer_sound_uncloak', '1', flags, 'Whether or not the Dead Ringer will play a sound when uncloaking.')
CreateConVar('ttt_deadringer_sound_uncloak_local', '0', flags, 'Where or not the uncloaking sound is played locally only.')
CreateConVar('ttt_deadringer_sound_recharge', '1', flags, 'Whether or not the Dead Ringer will play a sound when recharged.')
CreateConVar('ttt_deadringer_sound_recharge_local', '1', flags, 'Where or not the recharging sound is played locally only.')
CreateConVar('ttt_deadringer_sound_activate', '1', flags, 'Whether or not the Dead Ringer will play a sound when activated.')
CreateConVar('ttt_deadringer_sound_activate_local', '1', flags, 'Where or not the activating sound is played locally only.')
CreateConVar('ttt_deadringer_sound_deactivate', '1', flags, 'Whether or not the Dead Ringer will play a sound when deactivated.')
CreateConVar('ttt_deadringer_sound_deactivate_local', '1', flags, 'Where or not the deactivating sound is played locally only.')

hook.Add('Initialize', 'DeadringerInitialize', function()
-- TTT2 Compatibility
Expand Down
124 changes: 124 additions & 0 deletions lua/autorun/ttt_deadringer_sandbox.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
AddCSLuaFile()

hook.Add('AddToolMenuCategories', 'DeadringerAddToolMenuCategories', function()
spawnmenu.AddToolCategory('Utilities', 'Dead Ringer', 'Dead Ringer')
end)

local DEADRINGER_DEFAULTS = {
ttt_deadringer_cloak_cooldown = 20,
ttt_deadringer_cloak_duration = 7,
ttt_deadringer_cloak_reuse = 0,
ttt_deadringer_cloak_transparency = 0,
ttt_deadringer_cloak_targetid = 0,

ttt_deadringer_damage_reduction = 0.65,
ttt_deadringer_damage_reduction_time = 3,
ttt_deadringer_damage_reduction_initial = 0.75,
ttt_deadringer_damage_threshold = 2,

ttt_deadringer_corpse_mode = 0,
ttt_deadringer_corpse_confirm = 0,

ttt_deadringer_hud_persist = 0,
ttt_deadringer_hud_classic = 0,

ttt_deadringer_sound_cloak = 0,
ttt_deadringer_sound_cloak_local = 0,
ttt_deadringer_sound_uncloak = 1,
ttt_deadringer_sound_uncloak_local = 0,
ttt_deadringer_sound_recharge = 1,
ttt_deadringer_sound_recharge_local = 1,
ttt_deadringer_sound_activate = 1,
ttt_deadringer_sound_activate_local = 1,
ttt_deadringer_sound_deactivate = 1,
ttt_deadringer_sound_deactivate_local = 1
}

hook.Add('PopulateToolMenu', 'DeadringerPopulateToolMenu', function()
spawnmenu.AddToolMenuOption('Utilities', 'Dead Ringer', 'dead_ringer', 'Settings', '', '', function(panel)
panel:Help('Dead Ringer Settings')

panel:ToolPresets('ttt_deadringer_presets', DEADRINGER_DEFAULTS)

panel:Help('General Settings')

panel:NumSlider('Charge Time', 'ttt_deadringer_cloak_cooldown', 1, 60, 0)
panel:ControlHelp('Time it takes to recharge the Dead Ringer.')

panel:Help('Cloak Settings')

panel:NumSlider('Cloak Time', 'ttt_deadringer_cloak_duration', 1, 60, 0)
panel:ControlHelp('Time that the Dead Ringer will cloak you for.')

panel:CheckBox('Cloak Time Reuse', 'ttt_deadringer_cloak_reuse')
panel:ControlHelp('Whether or not the Dead Ringer will convert unused cloak time into charge time.')

panel:NumSlider('Cloak Transparency', 'ttt_deadringer_cloak_transparency', 0, 1, 2)
panel:ControlHelp('Transparency of the Dead Ringer cloak. (0.0 = invisible, 1.0 = visible)')

panel:CheckBox('Cloak Target ID', 'ttt_deadringer_cloak_targetid')
panel:ControlHelp('Whether or not the Dead Ringer will show the target ID while cloaked.')

panel:Help('Damage Reduction Settings')

panel:NumSlider('Damage Threshold', 'ttt_deadringer_damage_threshold', 0, 100, 0)
panel:ControlHelp('The threshold is a flat value, not a percentage')

panel:NumSlider('Damage Reduction', 'ttt_deadringer_damage_reduction', 0, 1, 2)
panel:ControlHelp('Damage reduction while cloaked.')

panel:NumSlider('Damage Reduction Time', 'ttt_deadringer_damage_reduction_time', 0, 60, 2)
panel:ControlHelp('Damage reduction time while cloaked. (1.0 = 1 second of damage reduction)')

panel:NumSlider('Damage Reduction Initial', 'ttt_deadringer_damage_reduction_initial', 0, 1, 2)
panel:ControlHelp('Percentage of damage reduction for the initial hit which triggers the Dead Ringer. (0.75 = 75%)')

panel:Help('Corpse Settings')

panel:NumSlider('Role Mode', 'ttt_deadringer_corpse_mode', 0, 2, 0)
panel:ControlHelp('Whether or not the Dead Ringer will show the real role of the player on the corpse. (0 = fake, 1 = real, 2 = innocent)')

panel:CheckBox('Confirm Death', 'ttt_deadringer_corpse_confirm')
panel:ControlHelp('Whether or not the Dead Ringer will confirm the death of the player on the corpse. (Not recommended for TTT2)')

panel:Help('HUD Settings')

panel:CheckBox('Persist HUD', 'ttt_deadringer_hud_persist')
panel:ControlHelp('Whether or not the Dead Ringer HUD will persist even while it is not activated.')

panel:CheckBox('Classic HUD', 'ttt_deadringer_hud_classic')
panel:ControlHelp('Whether or not the Dead Ringer HUD will use the classic style. (TTT2 only)')

panel:Help('Sound Settings')

panel:CheckBox('Cloak Sound', 'ttt_deadringer_sound_cloak')
panel:ControlHelp('Whether or not the Dead Ringer will play a sound when cloaking.')

panel:CheckBox('Cloak Sound Local', 'ttt_deadringer_sound_cloak_local')
panel:ControlHelp('Where or not the cloaking sound is played locally only.')

panel:CheckBox('Uncloak Sound', 'ttt_deadringer_sound_uncloak')
panel:ControlHelp('Whether or not the Dead Ringer will play a sound when uncloaking.')

panel:CheckBox('Uncloak Sound Local', 'ttt_deadringer_sound_uncloak_local')
panel:ControlHelp('Where or not the uncloaking sound is played locally only.')

panel:CheckBox('Recharge Sound', 'ttt_deadringer_sound_recharge')
panel:ControlHelp('Whether or not the Dead Ringer will play a sound when recharged.')

panel:CheckBox('Recharge Sound Local', 'ttt_deadringer_sound_recharge_local')
panel:ControlHelp('Where or not the recharging sound is played locally only.')

panel:CheckBox('Activate Sound', 'ttt_deadringer_sound_activate')
panel:ControlHelp('Whether or not the Dead Ringer will play a sound when activated.')

panel:CheckBox('Activate Sound Local', 'ttt_deadringer_sound_activate_local')
panel:ControlHelp('Where or not the activating sound is played locally only.')

panel:CheckBox('Deactivate Sound', 'ttt_deadringer_sound_deactivate')
panel:ControlHelp('Whether or not the Dead Ringer will play a sound when deactivated.')

panel:CheckBox('Deactivate Sound Local', 'ttt_deadringer_sound_deactivate_local')
panel:ControlHelp('Where or not the deactivating sound is played locally only.')
end)
end)
19 changes: 19 additions & 0 deletions lua/autorun/ttt_deadringer_sound.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
AddCSLuaFile()

sound.Add({
name = 'deadringer_activate',
channel = CHAN_WEAPON,
volume = 1.0,
level = 75,
pitch = 100,
sound = 'buttons/blip1.wav'
})

sound.Add({
name = 'deadringer_deactivate',
channel = CHAN_WEAPON,
volume = 1.0,
level = 75,
pitch = 73,
sound = 'buttons/blip1.wav'
})
36 changes: 36 additions & 0 deletions lua/terrortown/lang/en/deadringer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,39 @@ L.help_deadringer_corpse_mode = 'Whether or not the Dead Ringer will show the re

L.label_deadringer_corpse_confirm = 'Corpse Confirm'
L.help_deadringer_corpse_confirm = 'Whether or not the Dead Ringer will confirm the death of the player on the corpse.'

L.label_deadringer_hud_persist = 'HUD Persist'
L.help_deadringer_hud_persist = 'Whether or not the Dead Ringer HUD will persist even while it is not activated.'

L.label_deadringer_hud_classic = 'Classic HUD'
L.help_deadringer_hud_classic = 'Whether or not the Dead Ringer HUD will use the classic style.'

L.label_deadringer_sound_cloak = 'Cloak Sound'
L.help_deadringer_sound_cloak = 'Whether or not the Dead Ringer will play a sound when cloaking.'

L.label_deadringer_sound_cloak_local = 'Cloak Sound Local'
L.help_deadringer_sound_cloak_local = 'Whether or not the cloaking sound is played locally only.'

L.label_deadringer_sound_uncloak = 'Uncloak Sound'
L.help_deadringer_sound_uncloak = 'Whether or not the Dead Ringer will play a sound when uncloaking.'

L.label_deadringer_sound_uncloak_local = 'Uncloak Sound Local'
L.help_deadringer_sound_uncloak_local = 'Whether or not the uncloaking sound is played locally only.'

L.label_deadringer_sound_recharge = 'Recharge Sound'
L.help_deadringer_sound_recharge = 'Whether or not the Dead Ringer will play a sound when recharged.'

L.label_deadringer_sound_recharge_local = 'Recharge Sound Local'
L.help_deadringer_sound_recharge_local = 'Whether or not the recharging sound is played locally only.'

L.label_deadringer_sound_activate = 'Activate Sound'
L.help_deadringer_sound_activate = 'Whether or not the Dead Ringer will play a sound when activated.'

L.label_deadringer_sound_activate_local = 'Activate Sound Local'
L.help_deadringer_sound_activate_local = 'Whether or not the activating sound is played locally only.'

L.label_deadringer_sound_deactivate = 'Deactivate Sound'
L.help_deadringer_sound_deactivate = 'Whether or not the Dead Ringer will play a sound when deactivated.'

L.label_deadringer_sound_deactivate_local = 'Deactivate Sound Local'
L.help_deadringer_sound_deactivate_local = 'Whether or not the deactivating sound is played locally only.'
Loading

0 comments on commit 28dade5

Please sign in to comment.