For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Speech function is broken in Unreal 227

Report bugs, read about fixes, new features and ask questions about the Unreal 227 patch here. Place comments and commit suggestions.
Post Reply
User avatar
Masterkent
OldUnreal Member
Posts: 1469
Joined: Fri Apr 05, 2013 12:41 pm

Speech function is broken in Unreal 227

Post by Masterkent »

Code: Select all

// Send a voice message of a certain type to a certain player.
exec function Speech( int Type, int Index, int Callsign )
{
	local VoicePack V;

	if ( PlayerReplicationInfo.VoiceType == None || Level.TimeSeconds - OldMessageTime < 2.5 )
		return;
	else OldMessageTime = Level.TimeSeconds;

	V = Spawn( PlayerReplicationInfo.VoiceType, Self );
	if (V != None)
	{
		V.PlayerSpeech( Type, Index, Callsign );
		V.Destroy();
	}
}
The trouble with modifying OldMessageTime this way is that VoicePack will fail to send messages with Pawn.SendVoiceMessage

Code: Select all

function SendVoiceMessage(PlayerReplicationInfo Sender, PlayerReplicationInfo Recipient, name messagetype, byte messageID, name broadcasttype)
{
	local Pawn P;
	local bool bNoSpeak;

	if ( Level.TimeSeconds - OldMessageTime < 2.5 )
		bNoSpeak = true;
	else
		OldMessageTime = Level.TimeSeconds;

	for ( P=Level.PawnList; P!=None; P=P.NextPawn )
	{
		if ( P.IsA('PlayerPawn') )
		{
			if ( !bNoSpeak )
			{
				if ( (broadcasttype == 'GLOBAL') || !Level.Game.bTeamGame )
					P.ClientVoiceMessage(Sender, Recipient, messagetype, messageID);
				else if ( Sender.Team == P.PlayerReplicationInfo.Team )
					P.ClientVoiceMessage(Sender, Recipient, messagetype, messageID);
			}
		}
		else if ( (P.PlayerReplicationInfo == Recipient) || ((messagetype == 'ORDER') && (Recipient == None)) )
			P.BotVoiceMessage(messagetype, messageID, self);
	}
}
because the condition

if ( Level.TimeSeconds - OldMessageTime < 2.5 )

is always true here, since OldMessageTime is set to Level.TimeSeconds right before this check. So bNoSpeak forever.

It's worth noting that neither 226b nor UT have such an interesting premature assignment, so I wonder why it was added there. It should be removed or moved to the end of PlayerPawn.Speech.
User avatar
[]KAOS[]Casey
OldUnreal Member
Posts: 4497
Joined: Sun Aug 07, 2011 4:22 am
Location: over there

Re: Speech function is broken in Unreal 227

Post by []KAOS[]Casey »

looks like it got added fairly early on, must be an Asgard® change, probably to try to prevent spamming, but since I don't actually know anything that uses this, nobody ever reported this. though I have a suspicion maybe the space marine mod used it improperly which caused this "fix" to occur...
User avatar
Masterkent
OldUnreal Member
Posts: 1469
Joined: Fri Apr 05, 2013 12:41 pm

Re: Speech function is broken in Unreal 227

Post by Masterkent »

The original implementation allows sending orders to bots with any small time intervals, so a player can quickly give several orders to different bots without waiting 2.5 seconds after every command. I think, this interval check should be removed too, it doesn't give a real protection from spamming (without special mods, players can still use Say/TeamSay to flood the chat).

On the other hand, the current implementation of Speech doesn't provide means to filter voice messages that we have for Say/TeamSay. It would be good to have a possibility of handling Speech with GameRules.

Code: Select all

-var() bool bNotifyMessages; // Handle message functions (AllowBroadcast/AllowChat)
+var() bool bNotifyMessages; // Handle message functions (AllowBroadcast/AllowChat/AllowSpeech)

// Allow a player to talk a chat message
function bool AllowChat( PlayerPawn Chatting, out string Msg )
{
	Return True;
}

+function AllowSpeech( PlayerPawn Speaking, int Type, int Index, int Callsign )
+{
+	return true;
+}

Code: Select all

// Send a voice message of a certain type to a certain player.
exec function Speech( int Type, int Index, int Callsign )
{
+	local GameRules G;
	local VoicePack V;

-	if ( PlayerReplicationInfo.VoiceType == None || Level.TimeSeconds - OldMessageTime < 2.5 )
+	if ( PlayerReplicationInfo.VoiceType == None )
		return;
-	else OldMessageTime = Level.TimeSeconds;

+	for (G = Level.Game.GameRules; G != none; G = G.NextRules)
+		if (G.bNotifyMessages && !G.AllowSpeech(self, Type, Index, Callsign))
+			return;

	V = Spawn( PlayerReplicationInfo.VoiceType, Self );
	if (V != None)
	{
		V.PlayerSpeech( Type, Index, Callsign );
		V.Destroy();
	}
}
User avatar
Masterkent
OldUnreal Member
Posts: 1469
Joined: Fri Apr 05, 2013 12:41 pm

Re: Speech function is broken in Unreal 227

Post by Masterkent »

The implementation in pre-beta 11 still doesn't work well. It doesn't allow giving orders to pawns without PlayerReplicationInfo and breaks the possibility to send quick silent orders to bots without delays that was implemented by Epic on purpose - see bNoSpeak var in Pawn.SendVoiceMessage.

Also I don't quite understand why 2.5 seconds delay was considered insufficient and we have to wait even 3 seconds now. Personally, I don't feel happy with this hardcoded value increased. Why not just let modders control speech with GameRules, so they could set any delay they wish or even mute the player entirely?

Player's OldMessageTime is by design supposed to be checked in SendVoiceMessage, and I don't see any reasoning why the stock implementation of PlayerPawn.Speech should somehow bother about OldMessageTime additionally. If some weirdly coded custom voice pack happens to skip checks for OldMessageTime and this causes troubles, it does not seem to be a good reason to make all NORMALLY coded voice packs working worse.


I'm reporting all this, because I'm closely working on support of voice packs in Botpack and Operation Na Pali under 227j right now, and I had to completely replace the implementation of Speech and SendVoiceMessage in a bunch of subclasses of MaleOne, MaleTwo, NaliPlayer, SkaarjPlayer, etc within my coop game controller in order to bypass the limitations of PlayerPawn.Speech and Pawn.SendVoiceMessage. A good game patch shouldn't force mod developers doing this (as long as 226b implementation works fine). Besides, I can't fix this stuff for 3rd-party game controllers, such as JCoopZ.
Post Reply

Return to “Unreal 227”