Skip to content

VoiceSet Documentation & Tutorial

Vuthakral edited this page Oct 17, 2022 · 5 revisions

Overview

VoiceSets is a simplistic to use system for adding Counter-Strike / Team Fortress style of voice command menu to Garry's Mod. In the gamemode Sandbox players are capable of freely picking a VoiceSet to use, however in other gamemodes this is restricted, and depends on gamemode authors / server hosts to write code to assign a VoiceSet's ID to players.

VoiceSet Menu

Setting up your own VoiceSet

[1] Add your sounds.

Click to expand.

While you can just add sound files directly to the code given in step 2, it is HIGHLY RECOMMENDED that you use sound.Add to give your audio the proper voice channel, which helps the audio spatial effects. Copy & modify this codeblock below into an autorun script for your addon/server/etc:

sound.Add({
	name = "vs_yourthing.soundtype",
	channel = CHAN_VOICE,
	volume = 1,
	level = 75,
	pitch = { 100, 100 },
	sound = { "vo/npc/male01/pain01.wav",
	"vo/npc/male01/pain04.wav",
	"vo/npc/male01/ow01.wav",
	"",
	"",
	"",
	"vo/npc/male01/startle02.wav" }
})

This above example will have a 50/50 chance to play a random Half-Life 2 rebel male pain sound whenever vs_yourthing.soundtype is called. In order to set this up, you can add your sound files in there instead, and change the name to what you want to be called. For the sake of making your editing easier, I suggest keeping a good naming convention. For example, in the Half-Life 2 VoiceSet pack these are named in the ways such was vs_rebelmale.pain_minor, vs_rebelmale.respawn, vs_rebelmale.greeting, etc. Additionally, the blank entries are used to create a "chance of playing", whenever the sound is picked one of these sounds are picked at random by the server, and if it lands on a "" entry then it will simply do nothing.

IMPORTANT NOTE These MUST have a unique name! If they are not unique then you will overwrite or have your sound overwitten with another!

Notes:

  • You should ALWAYS use CHAN_VOICE for your sounds EXCEPT for death sounds. The engine is hard-coded to mute CHAN_VOICE audio if the entity playing the sound is dead. Set death sounds to CHAN_AUTO

[2] Set up your VoiceSet.

Click to expand.

Setting up the VoiceSet is the easier part of this whole process. Simply copy this table below into an autorun file and fill in the required bits. The command called at the end will register your VoiceSet with the Draconic Base. Read the notes at the bottom for explanation on how everything works.

local SOMETHING_UNIQUE_NO_SPACES_NUMBERS_OR_SPECIAL_CHARACTERS = {
	["ID"] = "SOMETHING_UNIQUE_NO_SPACES_NUMBERS_OR_SPECIAL_CHARACTERS_SAME_AS_TABLE_NAME",
	["Name"] = "Change to your VoiceSet's name.",
	["Pain"] = {
		["Minor"] = {""},
		["Minor_Post"] = {""},
		["Medium"] = {""},
		["Medium_Post"] = {""},
		["Major"] = {""},
		["Major_Post"] = {""},
		["Death"] = {""},
		["Death_Falling"] = {""},
		["Death_Splatter"] = {""},
		["Fire_Minor_Post"] = {""}, -- DMG_BURN, DMG_SLOWBURN
		["Fire_Medium_Post"] = {""},
		["Fire_Major_Post"] = {""},
		["Fall_Minor_Post"] = {""},
		["Fall_Medium_Post"] = {""},
		["Fall_Major_Post"] = {""},
		["Shock_Minor_Post"] = {""}, -- DMG_SHOCK
		["Shock_Medium_Post"] = {""},
		["Shock_Major_Post"] = {""},
		["Acid_Minor_Post"] = {""}, -- DMG_ACID
		["Acid_Medium_Post"] = {""},
		["Acid_Major_Post"] = {""},
		["Rad_Minor_Post"] = {""}, -- Radiation
		["Rad_Medium_Post"] = {""},
		["Rad_Major_Post"] = {""},
		["Plasma_Minor_Post"] = {""}, -- DMG_PLASMA
		["Plasma_Medium_Post"] = {""},
		["Plasma_Major_Post"] = {""},
		["npc_zombie"] = {""},
	},
	["Respawn"] = {""},
	["RequestHelp"] = {""},
	["MoveIt"] = {""},
	["Insult"] = {""},
	["Compliment"] = {""},
	["Hello"] = {""},
	["Question"] = {""},
	["Agree"] = {""},
	["Disagree"] = {""},
	["Apologize"] = {""},
	["Spotting"] = {
		["DeadBody"] = {""},
		["Generic_Enemy"] = {""},
		["Generic_Friendly"] = {""},
		["npc_poisonzombie"] = {""},
	},
	["Actions"] = {
		["Reload"] = {""},
		["Melee"] = {""}, -- See notes below (on github wiki)
	},
	["Reactions"] = {
		["NoAmmo"] = {""}, -- When attempting to fire a gun with an empty magazine
		["Puke"] = {""}, -- When standing under a barnacle when it dies
		["kill_postgeneric"] = {""},
		["kill_npc_zombie"] = {""},
	},
	["Responses"] = {
		["npc_zombie"] = {
			["npc/zombie/zombie_voice_idle9.wav"] = {""},
		},
	}
	["Taunts"] = {
		["Cheer"] = {""},
		["Muscle"] = {""},
		["Dance"] = {""},
		["Zombie"] = {""},
		["Robot"] = {""},
		["Pers"] = {""},
		},
	},
}
DRC:RegisterVoiceSet(SOMETHING_UNIQUE_NO_SPACES_NUMBERS_OR_SPECIAL_CHARACTERS)

Notes:

  • You can remove anything from a VoiceSet table if it is unused without worry of anything breaking.
  • DMG_ specific damage values are not required, and exist solely for developers to be able to add specific reactions instead of just having a generic one.
  • The spotting, damage, and reaction systems support adding unique lines by entity class. This means you can add a value of ["npc_zombie"] = {""} and the relevant system will pull this information to use this line when the player using your VoiceSet does something with a zombie. In the case of post-kill dialogue, you should prefix the entity's class with kill_, as seen in the example above.
  • The Melee action requires support from weapon base authors. I can confirm for certain it works with base-game weaponry, and Draconic weapons. If you want to (politely) ask another author to make their weapon base support this system, tell them they just need to have this code where the melee attack occurs: if Draconic then DRC:SpeakSentence(ply, "Actions", "Melee") end
  • The Responses section is used to make a VoiceSet have an automated response when within earshot of a given entity class emitting a certain sound. This is used to make it so your character can respond to specific world events, interactions, or etc.
  • While VoiceSets does not currently support adding custom calls, this will be added in the near future.
Clone this wiki locally