Author Topic: CUSTOM QUICKMESSAGES (VOICE COMANDS) & TOKENS  (Read 1479 times)

Offline Aquarius

  • Rank: Private
  • *
  • Posts: 3
CUSTOM QUICKMESSAGES (VOICE COMANDS) & TOKENS
« on: January 17, 2008, 04:52:32 pm »
To whom it may concern

How about being able to use custom voice commands by pressing "@ (voice cmd with text) or & (voice cmd without text) followed by a number", like they did with a MOD for Soldier Of Fortune 2 double helix gold edition:

For example: Press @1 as chat message and the text "Affermative" will show up with the sound...like a quickmessage of COD4.

// This file (voicecmds.cfg) contains voice commands
//
// Options:
//   <command number> sound "path of sound file"
//   <command number> text "Text to display"
//   <command number> notext "display note"
//   <command number> adminonly
//
//
// Editing the Standard voice commands is not recommended, as it could confuse
// existing players who have their binds set.


// Headshot notification ------------

a sound "sound/misc/headshot.mp3"
a text "^1Headshot!"

l text "^3* 5 Minutes Left *"
l sound "sound/misc/menus/click.wav"

m text "^3* 3 Minutes Left *"
m sound "sound/misc/menus/click.wav"

n text "^3* 1 Minutes Left *"
n sound "sound/misc/menus/click.wav"

// Standard voice commands ------------

1 sound "sound/radio/male/affirm.mp3"
1 text "^3Affirmative!^2"

2 sound "sound/radio/male/neg.mp3"
2 text "^3Negative!^2"

3 sound "sound/npc/col10/scientist06/01yessir.mp3"
3 text "^3Yes, sir?^2"

4 sound "sound/npc/col10/guard/02yessir.mp3"
4 text "^3Yes sir^2"

5 sound "sound/npc/col3/blakely/02yessir.mp3"
5 text "^3Yes sir!^2"

6 sound "sound/npc/col8/washington/02yessir.mp3"
6 text "^3Yes sir!^2"

7 sound "sound/radio/male/yes_sir.mp3"
7 text "^3Yes sir!^2"

8 sound "sound/npc/col8/blakely/yeah.mp3"
8 text "^3Yeah!^2"

9 sound "sound/npc/col8/peterson/yeah.mp3"
9 text "^3Yeah!^2"

10 sound "sound/npc/col10/scientist02/02laugh.mp3"
10 text "^3lol^2"

11 sound "sound/npc/air1/guard02/laughs.mp3"
11 text "^3lol!^2"

12 sound "sound/npc/civ/english/male/hello.mp3"
12 text "^3Hello^2"

13 sound "sound/npc/civ/english/male/good_day.mp3"
13 text "^3Good day^2"

14 sound "sound/npc/civ/english/male/goodday_sir.mp3"
14 text "^3Good day, sir^2"

15 sound "sound/npc/civ/english/male/help.mp3"
15 text "^3Help!^2"

16 sound "sound/npc/col8/blakely/niceshot.mp3"
16 text "^3Nice shot!^2"

17 sound "sound/npc/col8/peterson/niceshot.mp3"
17 text "^3Nice shot!^2"

18 sound "sound/npc/col8/washington/niceshot.mp3"
18 text "^3Nice shot!^2"

19 sound "sound/npc/col9/pilot/greatshot.mp3"
19 text "^3Ha! Great shot!^2"

20 sound "sound/npc/mullins/air4/15dammit.mp3"
20 text "^3Dammit!^2"

21 sound "sound/npc/mullins/various/damn.mp3"
21 text "^3Damn!^2"

22 sound "sound/npc/mullins/pra6/brb.mp3"
22 text "^3I'll be right back^2"

23 sound "sound/npc/mullins/hos1/07thankyou.mp3"
23 text "^3Thank you^2"

24 sound "sound/npc/mullins/shop3/01yeahthanks.mp3"
24 text "^3Yeah, thanks^2"

25 sound "sound/npc/mullins/tut1/01thanks.mp3"
25 text "^3Thanks^2"

etc. etc.




Or being able to use Tokens (see below):

Player text tokens
==================
These tokens may be used by players in chat messages.

#n,#N  - Your name
#h,#H  - Your health, numeric value
#a,#A  - Your armor, numeric value
#b     - Your armor, in bar format
#B     - Your health, in bar format
#d     - The name of the person that last hurt you
#D     - The name of the person that last killed you
#t     - The name of the person you last hurt
#T     - The name of the person you last killed
#r     - Name of the last weapon used to hurt you (short)
#R     - Name of the last weapon used to hurt you (long)
#l,#L  - Your current location
#f,#F  - The name of your nearest teammate
#p     - Name of your primary weapon (short)
#P     - Name of your primary weapon (long)
#s     - Name of your secondary weapon (short)
#S     - Name of your secondary weapon (long)
#i     - Name of your pistol (short)
#I     - Name of your pistol (long)
#g     - Name of your grenade (short)
#G     - Name of your grenade (long)
#e,#E  - Name of your equipment (Armor, NV goggles, Thermal goggles)
#w     - Name of the weapon you are currently holding (short)
#W     - Name of the weapon you are currently holding (long)
#u,#U  - Body location where the last person hit you
#v,#V  - Body location on the person you last killed
#x     - Your location when you were last hurt
#X     - Your location when you were last killed
#y     - Your location when you last hurt someone
#Y     - Your location when you last killed someone
#z,#Z  - The name of the last player to join the game
#nn    - The name of the player with the specified client id (i.e. #13)
#c     - The name of your teammate currently carrying the flag/briefcase
#C     - The name of your enemy currently carrying the flag/briefcase
#o     - Your team's score (or total number for non-team game)
#O     - The enemy team's score (or total number for non-team game)
#k     - Red team's score (or total number for non-team game)
#K     - Blue team's score (or total number for non-team game)


Server messaging tokens
=======================
These tokens are used in automated server messages.

#z,#Z  - The name of the last player to join the game
#c     - The name of the player on the red team carrying the flag
#C     - The name of the player on the blue team carrying the flag
#s     - The red team's score (or total score for non-team game)
#S     - The blue team's score (or total score for non-team game)
#p     - The number of players on the red team (or total number for non-team game)
#P     - The number of players on the blue team (or total number for non-team game)


Command ID tokens
=================
These tokens may be used in place of player IDs in admin commands.

#n,#N  - Your ID
#d     - The ID of the person that last hurt you
#D     - The ID of the person that last killed you
#t     - The ID of the person you last hurt
#T     - The ID of the person you last killed
#f,#F  - The ID of your nearest teammate
#z,#Z  - The ID of the last player to join the game
#c     - The ID of the player on your team carrying the flag/briefcase
#C     - The ID of the player on the enemy team carrying the flag/briefcase
#x     - The IDs of all players who have been tagged
#X     - The IDs of all players who have been tagged (clears tags after use)




I have got the full source of this mod. Somehow I have not been able to intergrate this in COD4 by using GSC files.
I do not have enough knowledge to accomplish this I am afraid.



Here is some source code:

==================
G_ParseVoiceCommands
==================
*/
void G_ParseVoiceCommands ( gentity_t *ent, const char *chatText, char *text, int textlen, char *sound )
{
   int len;
   int num;
   char *message;
   const char *src;
   const char *pos;
   char c;
   qboolean dotext;

   dotext = qtrue;
   len = textlen;
   src = chatText;

   while ( *src != '\0' && len )
   {
      if ( *src != '@' && *src != '&' )
      {
         *text++ = *src++;
         len--;
         continue;
      }

      if ( *src == '&' )
      {
         dotext = qfalse;
      }

      src++;

      if ( (*src == '@' && dotext) || (*src == '&' && !dotext) )
      {
         *text++ = *src++;
         len--;
         continue;
      }

      pos = src;
      num = 0;
      c = *src;
      while ( c >= '0' && c <= '9' && len )
      {
         c -= '0';
         num = num * 10 + c;
         src++;
         len--;
         c = *src;
      }

      if (num <= 0 || num > voicecmds.voiceCommandCount || !voicecmds.voiceCommandSound[num][0] )
      {
         *text++ = dotext?'@':'&';
         src = pos;
         continue;
      }

      if ( ent != NULL && ent->client->sess.modData->adminref < 2 && ent->client->sess.modData->adminref != -1 && voicecmds.voiceCommandFlag[num] == VOICE_ADMIN_ONLY )
      {
         *text++ = dotext?'@':'&';
         src = pos;
         continue;
      }
      if ( ent != NULL && !ent->client->sess.modData->clan && voicecmds.voiceCommandFlag[num] == VOICE_CLAN_ONLY )
      {
         *text++ = dotext?'@':'&';
         src = pos;
         continue;
      }
      if ( ent != NULL && ent->client->sess.modData->adminref < 3 && ent->client->sess.modData->adminref > -2 && voicecmds.voiceCommandFlag[num] == VOICE_SYSOP_ONLY )
      {
         *text++ = dotext?'@':'&';
         src = pos;
         continue;
      }
      if ( ent != NULL && ent->client->sess.modData->adminref < 1 && ent->client->sess.modData->adminref > -1 && voicecmds.voiceCommandFlag[num] == VOICE_REFEREE_ONLY )
      {
         *text++ = dotext?'@':'&';
         src = pos;
         continue;
      }

      strcpy( sound, voicecmds.voiceCommandSound[num] );
      message = voicecmds.voiceCommandText[num];

      if ( dotext )
      {
         while (*message != '\0' && len )
         {
            *text++ = *message++;
            len--;
         }
      }
   }
   *text = '\0';
}

/*



// Voice command data
//
#define   MAX_VOICE_BUFFER      65536
#define   MAX_VOICE_COMMANDS      1024
#define VOICE_ADMIN_ONLY      1
#define VOICE_CLAN_ONLY         2
#define VOICE_SYSOP_ONLY      3
#define VOICE_REFEREE_ONLY      4

#define   MAX_VOICE_PROMPTS      26

typedef struct {
   int            voiceCommandCount;
   char         *voiceCommandText[MAX_VOICE_COMMANDS];
   char         *voiceCommandSound[MAX_VOICE_COMMANDS];
   int            voiceCommandFlag[MAX_VOICE_COMMANDS];
   char         *voicePromptText[MAX_VOICE_PROMPTS];
   char         *voicePromptSound[MAX_VOICE_PROMPTS];
   char         voiceCommandBuffer[MAX_VOICE_BUFFER];
} voiceCommands_t;




On request; I am able to send to complete source code.

Thank you in advance

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
CUSTOM QUICKMESSAGES (VOICE COMANDS) & TOKENS
« Reply #1 on: January 17, 2008, 05:13:25 pm »
That´s not GSC script code. It´s C++ code, which needs to be compiled into the executable.

The suggestion is feasible, but not acceptable. In order to make this happen, we would need to hijack key bindings. In 2.3 we did this for the optional switch zoom-scope function (SR/LR rifle switcher on key "m"), but we simply can´t keep doing this without overriding existing bindings at some point in time.

Offline Aquarius

  • Rank: Private
  • *
  • Posts: 3
CUSTOM QUICKMESSAGES (VOICE COMANDS) & TOKENS
« Reply #2 on: January 17, 2008, 05:32:59 pm »
Do we need to change the existing bindings?

How about that @ sign we put before a number to define a voice command.

The @ sign differs from all the existing bindings and wont interfear.

See the source in yellow (above) how they did it.

Or maybe we are able to change / extend the quickmessages menu using bindings or commands like vsay. For example: vsay "nice shot" and it will show on screen and as sound. So vsay is a new command slightly different then quickmessage.

Anyways it worked with SOF2 eventhough that game had tons of bindings.

Hopefully someone will be able to crack this.

There are a lot of COD4 players/fans out there waiting for this feature.

EDIT:

In a other SOF2 MOD they used words instead of numbers:

sound
{
   token "gw"
   path "sound/npc/shop4/technician/17goodwork"
   text "Good work"
   group 1
}
sound
{
   token "drill"
   path   "sound\npc\mullins\shop4\01drill"
   text   "I know the Drill"
   group   1
}
sound
{
   token "hello"
   path "sound/npc/civ/english/male/hello"
   text "hello"
   group 1
}
sound
{
   token "ns"
   path "sound/npc/col8/peterson/niceshot"
   text "nice shot"
   group 1
}
sound
{
   token "ty"
   path "sound/npc/shop1/npc06/02thanks"
   text "Thanks, I appreciate it"
   group 1
}