TribesReplay/base/scripts/voiceChat.cs

345 lines
9.7 KiB
C#
Raw Normal View History

2017-07-18 02:51:48 +00:00
$voiceLines = 8;
$voiceLineTimeout = 7 * 1000;
$numTalking = 0;
//------------------------------------------------------------------------------
function clientCmdPlayerStartTalking(%client, %success)
{
// if more people are talking than we can handle, don't bother with names
if($numTalking > $voiceLines)
return;
%openLine = -1;
for(%i = 0; %i < $voiceLines; %i++)
{
if($voiceComm[%i] <= 0)
{
%openLine = %i;
break;
}
}
if(%openLine != -1)
{
$voiceComm[%openLine] = %client;
if(%success)
addGreenVoiceLine(%client, %openLine);
else
addRedVoiceLine(%client, %openLine);
$numTalking++;
resizeVoiceCommWindow();
if(!(voiceCommHud.isVisible()))
voiceCommHud.setVisible(true);
}
}
//------------------------------------------------------------------------------
function clientCmdPlayerStoppedTalking(%client, %success)
{
%doneLine = -1;
for(%i = 0; %i < $voiceLines; %i++) {
if($voiceComm[%i] == %client) {
%doneLine = %i;
break;
}
}
if(%doneLine != -1)
%rmSuccess = removeVoiceLine(%doneLine);
}
//------------------------------------------------------------------------------
function addGreenVoiceLine(%client, %line)
{
%name = "Unknown client";
%player = $PlayerList[%client];
if(%player)
%name = %player.name;
%speakLine = new GuiControl("VCH"@%line) {
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "2 " @ (%line + 1) * 15;
extent = "160 15";
visible = true;
new GuiBitmapCtrl() {
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
bitmap = "gui/hud_chat_button_on.png";
position = "0 0";
extent = "15 15";
visible = true;
};
new GuiTextCtrl() {
profile = "GuiVoiceGreenProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "20 0";
extent = "140 15";
text = %name;
visible = true;
};
};
voiceCommHud.add(%speakLine);
schedule($voiceLineTimeout, 0, "removeVoiceLine", %line);
}
//------------------------------------------------------------------------------
function addRedVoiceLine(%client, %line)
{
%name = "Unknown client";
%player = $PlayerList[%client];
if(%player)
%name = %player.name;
%speakLine = new GuiControl("VCH"@%line) {
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "3 " @ (%line + 1) * 15;
extent = "150 15";
visible = true;
new GuiBitmapCtrl() {
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
bitmap = "gui/hud_chat_button_off.png";
position = "0 0";
extent = "15 15";
visible = true;
};
new GuiTextCtrl() {
profile = "GuiVoiceGreenProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "20 0";
extent = "125 15";
text = %name;
visible = true;
};
};
voiceCommHud.add(%speakLine);
schedule($voiceLineTimeout, 0, "removeVoiceLine", %line);
}
//------------------------------------------------------------------------------
function removeVoiceLine(%line)
{
%killIt = nameToID("VCH" @ %line);
$voiceComm[%line] = 0;
if(%killIt == -1) {
//error("Could not find control VCH" @ %line @ " !!!!");
return 0;
}
else {
//error("Removing voice line " @ %line);
%killIt.delete();
$voiceComm[%line] = 0;
$numTalking--;
if($numTalking < 1)
voiceCommHud.setVisible(false);
resizeVoiceCommWindow();
return 1;
}
}
function resizeVoiceCommWindow()
{
%lastLine = -1;
for(%i = 0; %i < $voiceLines; %i++)
{
if($voiceComm[%i] > 0)
%lastLine = %i;
}
%yExt = ((%lastLine + 1) * 15) + 18;
%xExt = firstWord(voiceCommHud.extent);
voiceCommHud.extent = %xExt SPC %yExt;
}
//------------------------------------------------------------------------------
// SERVER command functions:
//------------------------------------------------------------------------------
function serverCmdListenTo(%client, %who, %boolean)
{
if ( %client == %who )
return;
%client.listenTo( %who, %boolean );
if ( %echo )
{
if ( %boolean )
messageClient( %client, 'MsgVoiceEnable', 'You will now listen to %3.', %boolean, %who, %who.name );
else
messageClient( %client, 'MsgVoiceEnable', 'You will no longer listen to %3.', %boolean, %who, %who.name );
}
else
messageClient( %client, 'MsgVoiceEnable', "", %boolean, %who );
messageClient( %who, 'MsgListenState', "", %boolean, %client );
}
//------------------------------------------------------------------------------
function serverCmdListenToAll(%client)
{
%client.listenToAll();
for ( %i = 0; %i < ClientGroup.getCount(); %i++ )
{
%cl = ClientGroup.getObject( %i );
if ( %cl && %cl != %client && !%cl.isAIControlled() )
messageClient( %client, 'MsgVoiceEnable', "", true, %cl );
}
messageAllExcept( %client, 'MsgListenState', "", true, %client );
}
//------------------------------------------------------------------------------
function serverCmdListenToNone(%client)
{
%client.listenToNone();
for ( %i = 0; %i < ClientGroup.getCount(); %i++ )
{
%cl = ClientGroup.getObject( %i );
if ( %cl && %cl != %client && !%cl.isAIControlled() )
messageClient( %client, 'MsgVoiceEnable', "", false, %cl );
}
messageAllExcept( %client, 'MsgListenState', "", false, %client );
}
//------------------------------------------------------------------------------
2017-07-18 02:55:25 +00:00
// Client bind functions:
//------------------------------------------------------------------------------
function voiceCapStart()
{
$voiceCaptureStarted = true;
// client can send voice? (dont bother recording.. server will reject it anyway)
if(($Audio::serverChannels == 0) || ($Audio::serverEncodingLevel < $pref::Audio::encodingLevel))
{
if($Audio::serverChannels == 0)
addMessageHudLine("\c2System:\cr server has disabled voice communication.");
else
{
switch($Audio::serverEncodingLevel)
{
v22337 (04/13/01): **SIEGE GAMEPLAY CHANGE**: When attacking a base, you will see red waypoints on the generators. When those generators are destroyed, the waypoints will change to green. If the generators are repaired thereafter, they will return to red. If you are on the defender team, these colors are reversed (green normally, red if destroyed, green if repaired again). This will help teams coordinate attack and defense more easily. **FLARE GREANDE GAMEPLAY CHANGE**: Each flare will only attract ONE missile now. When the missile hits the flare, the flare will be destroyed. Only the first missile fired after the flare is thrown will be fooled by that flare. Other missiles must be attracted by other flares in order to be avoided. *There was a problem where emails were getting cloned multiple times for some folks. This is fixed now and no longer occurs. *There was an issue where the single player game type was not being properly cleared for folks when they left single player and went to other games. This is fixed now. *A stray underground generator was removed from Caldera. *The name column will no longer jump to the top when folks leave and join a room, thus making it easier to stay focused on a particular player's name. *If you steal a vehicle, the vehicle's sensor radius will not switch to the stealing player's team. In otherwords, the sensor of the vehicle will still report to the original team's sensor net...not the team that stole the vehicle. That's as design and is one of the drawbacks of using a stolen vehicle. *Bounty & Hunter: The player icons on the command maps are now the correct colors. *More items have correct names and tags on the command map and in the HUD. There were instances like "East Generator Generator". Those have been eliminated. *The last patch accidentally eliminated the "PlayerXXX joined YYYY game. Click here to join." links from the CHAT. This has been resolved and is now available again. *Players are no longer able to squeeze in under the tires of vehicles and play Superman by lifting them off the ground. ; ) *Bots were getting stuck in Riverdance when the fell in the water near the bridge. This has been fixed. *Added more filtering options so that the filters for the server query (JOIN) screen are more powerful and flexible. *Added a Linux indicator so users can tell whether they are joining a Win32 or Linux server. (Shouldn't make any difference to game play, but we felt you'd like to know.) *Fixed a small texture leak on 3Space objects. *Added an underwater satchel charge effect. Slightly increased the delay time between activating the satchel and the time that it actually explodes (this was as designed...a minor bug was causing it to explode too soon).
2017-07-18 03:07:50 +00:00
case 0: %level = "Codec .v12";
case 1: %level = "Codec .v24";
v23115 (05/30/01): - (bug fix) Fixed an authentication hole that allowed arbitrary IP connections to a LAN server. The policy now is: LAN servers will disallow any connections from IP addresses that do not match the Class B network address of the server (or match one of them, in a multihomed server). So if your server's address is 12.13.14.15, clients from 12.13.*.* will be considered, but clients from 12.12.*.* will be immediately rejected. In addition, a LAN server will only allow 4 unique Class C ids at any one time. This should be sufficiently lenient for even the largest LAN parties, but should eliminate the auth hole. - (bug fix) Fixed a server crash on mission change when the last human player leaves the game in mid cycle. - (bug fix) Fixed a bug that could reset your Shape Detail setting to max - (bug fix) Client join message name correction - (bug fix) All known in-game Chat HUD bugs are fixed (partial lines from paging up/down and resize issues, etc.). - (bug fix) Infinite missile lock-on sound bug is fixed. Dead. Finito. No more. Pushing up the daisies. - (bug fix) Stitched up a hole associated with one of the base shapes. Small fry compared to the memory leaks. - (bug fix) Found a particle crash issue and plugged it up good. - (bug fix) Fixed a shield impact internal compile error that was crunching frame rate. - (bug fix) Turns out we tweaked it so inventory stations were counting as turrets for turret placement purposes. D'oh. Fixed. - (bug fix) A rare crash that occurred with the Radeon VE card has been resolved. - (bug fix) Fixed a crash that could occur when a flare grenade was released when inside a force field. - (bug fix) Deployable turrets (spider and spike) and Deployable inv stations now do damage in their explosion when they are destroyed. - (optimization) The following missions were refined in order to optimize framerate: Alcatraz Caldera Flashpoint Gauntlet IceBound Insalubria Overreach Respite Sirocco - (optimization) Adjusted the LOD of the logo projectors found in CnH missions. - (optimization) Changed object shield shapes from the form-fitting forcefields into a less poly-intensive dome effect. Also gave shields a lower memory profile. - (optimization) Changed the way the clouds' planes are clipped. Sky's the limit, right? - (optimization) Missile sound script calls moved from script into code for faster processing. - (memory leak) Fixed a large memory leak. This plus the other leaks mentioned here should finally put the nail in the coffin on the "degrading server performance" issue. - (memory leak) Fixed a memory leak associated with the pretty lightning effects on maps like Casern Cavite.memory leaks: - (memory leak) Fixed a memory leak in our fancy text list control and the gui text list. - (memory leak) Fixed a memory leak involving memory use and resource allocation. - (improvement) Targeting laser prediction should be better now. - (improvement) You can specify a server's IP address manually at the join screen - (improvement) You can now specify "-password <pw>" on the command line to join a server that requires a password. - (improvement) Heavy armors are tougher against snipers. You now require four headshots or five body shots to kill a Juggernaut with a laser rifle. - (improvement) Footspeed of all armors increased slightly, as well as a minor boost to jetpack performance. Some improvements made to air resistance for mediums and heavy armors (very subtle). - (improvement) The jetpack effect was reverted back to the old effect (by popular demand). - (improvement) A Chat HUD message has been added that is displayed whenever you try to deploy a mine, but your team's maximum number of mines has already been deployed. Previously, the mine would just blow up and not explain why it detonated. Now, it still blows up, but tells you why it happened. - (improvement) Polished up the health meter on the HUD so when you're still alive, it displays a visible sliver of positive health. - (improvement) Made framerate and gameplay changes to Caldera. The attackers' base has been moved farther from the defenders, and the switch has been put in one of the upper chambers, while the stations are located separately from the generators. The changes should fix a serious defensive advantage. - (improvement) After you buy a vehicle, you now fade into the driver's seat if your armor and pack make you an eligible pilot/driver. - (improvement) Added a "rogue" mine message so that if you are killed by a mine laid by someone who has left the building, the death message is more accurate. - (improvement) Increased speed of belly turret projectiles so that it is more effective in general (especially for air defense). - (improvement) Modified name tags of vehicles when you place your reticle over them. Names are now more consistent and descriptive. - (improvement) Missile and AA turrets now have a longer maximum range (you'll still need to deploy sensors to get this added range, but they can fire farther if you do). They also react more quickly to available targets. - (community) The "compose email", "forum post", and "news submission" windows are now resizable and movable.
2017-07-18 03:20:27 +00:00
default: %level = "Codec .v29";
2017-07-18 02:55:25 +00:00
}
addMessageHudLine("\c2System:\cr server has voice level capped at [\c1" @ %level @ "\cr].");
}
$voiceCaptureStarted = false;
return;
}
vcRecordingHud.setVisible(true);
voiceCommHud.setVisible(true);
resizeVoiceCommWindow();
alxCaptureStart();
}
function voiceCapStop()
{
if(!$voiceCaptureStarted)
return;
vcRecordingHud.setVisible(false);
if($numTalking < 1)
voiceCommHud.setVisible(false);
alxCaptureStop();
}
//------------------------------------------------------------------------------
function serverCmdSetVoiceInfo(%client, %channels, %decodingMask, %encodingLevel)
2017-07-18 02:51:48 +00:00
{
%wasEnabled = %client.listenEnabled();
2017-07-18 02:55:25 +00:00
// server has voice comm turned off?
if($Audio::maxVoiceChannels == 0)
%decodingMask = 0;
else
%decodingMask &= (1 << ($Audio::maxEncodingLevel + 1)) - 1;
if($Audio::maxEncodingLevel < %encodingLevel)
%encodingLevel = $Audio::maxEncodingLevel;
if($Audio::maxVoiceChannels < %channels)
%channels = $Audio::maxVoiceChannels;
%client.setVoiceChannels(%channels);
%client.setVoiceDecodingMask(%decodingMask);
%client.setVoiceEncodingLevel(%encodingLevel);
commandToClient(%client, 'SetVoiceInfo', %channels, %decodingMask, %encodingLevel);
if ( %wasEnabled != ( %channels > 0 ) )
2017-07-18 02:51:48 +00:00
updateCanListenState( %client );
}
//------------------------------------------------------------------------------
// SERVER side update function:
//------------------------------------------------------------------------------
function updateCanListenState( %client )
{
// These can never listen, so they don't need to be updated:
if ( %client.isAIControlled() || !%client.listenEnabled() )
return;
for ( %i = 0; %i < ClientGroup.getCount(); %i++ )
{
%cl = ClientGroup.getObject( %i );
if ( %cl && %cl != %client && !%cl.isAIControlled() )
{
messageClient( %cl, 'MsgCanListen', "", %client.canListenTo( %cl ), %client );
messageClient( %client, 'MsgCanListen', "", %cl.canListenTo( %client ), %cl );
}
}
}
//------------------------------------------------------------------------------
// CLIENT side handler functions:
//------------------------------------------------------------------------------
addMessageCallback( 'MsgVoiceEnable', handleVoiceEnableMessage );
function handleVoiceEnableMessage( %msgType, %msgString, %enabled, %who )
{
if ( isObject( $PlayerList[%who] ) )
{
$PlayerList[%who].voiceEnabled = %enabled;
lobbyUpdatePlayer( %who );
}
}
//------------------------------------------------------------------------------
addMessageCallback( 'MsgCanListen', handleCanListenMessage );
function handleCanListenMessage( %msgType, %msgString, %canListen, %who )
{
if ( isObject( $PlayerList[%who] ) )
{
$PlayerList[%who].canListen = %canListen;
lobbyUpdatePlayer( %who );
}
}
//------------------------------------------------------------------------------
addMessageCallback( 'MsgListenState', handleListenStateMessage );
function handleListenStateMessage( %msgType, %msgString, %isListening, %who )
{
if ( isObject( $PlayerList[%who] ) )
{
$PlayerList[%who].isListening = %isListening;
lobbyUpdatePlayer( %who );
}
}