Skip to content

Commit

Permalink
Added an entirely new messaging system.
Browse files Browse the repository at this point in the history
Added rendering support for groups. Each group member has now a box around it with the group's name and its own randomed color.
Added auto-group joining upon first-time joining.
Fixed some messages.
Fixed several silent bugs.
Reduced amount of messages spam by categorizing them in different parts of the screen depending on the kind of message.
Added replication for groups, so that clients can now render such data.
Added configurable classes for Messages and other classes to allow more advanced per-map-modding.

8 hours of work ;D
  • Loading branch information
EliotVU committed Jan 11, 2014
1 parent b10bbf5 commit 4355b09
Show file tree
Hide file tree
Showing 18 changed files with 772 additions and 116 deletions.
46 changes: 29 additions & 17 deletions Classes/GroupCounter.uc
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/*==============================================================================
TrialGroup
Copyright (C) 2010 Eliot Van Uytfanghe
Copyright (C) 2010 - 2014 Eliot Van Uytfanghe
This program is free software; you can redistribute and/or modify
it under the terms of the Open Unreal Mod License version 1.1.
==============================================================================*/
class GroupCounter extends Info
notplaceable
hidedropdown
transient;

var editconst array<Controller> Members;
var editconst int Counts;
var private editconst int index, loop;
var GroupManager Manager;
var protected int GroupIndex;
var protected int _TicksCount;
var private int _TickIndex;

var() localized string CountMessage;
var() localized string GoMessage;

// Operator from ServerBTimes.u
static final operator(101) string $( coerce string A, Color B )
Expand All @@ -26,27 +28,37 @@ static final operator(102) string $( Color B, coerce string A )
return (Chr( 0x1B ) $ (Chr( Max( B.R, 1 ) ) $ Chr( Max( B.G, 1 ) ) $ Chr( Max( B.B, 1 ) ))) $ A;
}

function Start()
event PreBeginPlay()
{
super.PreBeginPlay();
Manager = GroupManager(Owner);
}

function Start( int groupIndex, int ticks )
{
_TicksCount = ticks;
GroupIndex = groupIndex;
GotoState( 'CountDown' );
}

state CountDown
{
function BeginState();

Begin:
Sleep( 0.5f );
for( loop = 0; loop < Counts; ++ loop )
Sleep( 0.25f );
for( _TickIndex = 0; _TickIndex < _TicksCount; ++ _TickIndex )
{
for( index = 0; index < Members.Length; ++ index )
{
PlayerController(Members[index]).ClientMessage( Class'GroupManager'.Default.GroupColor $ "CountDown: " $ Counts - loop $ "..." );
}
Manager.GroupSendMessage( GroupIndex, Repl(CountMessage, "%i", _TicksCount - _TickIndex) );
Sleep( 1.f );
}
for( index = 0; index < Members.Length; ++ index )
{
PlayerController(Members[index]).ClientMessage( Class'GroupManager'.Default.GroupColor $ "CountDown: " $ Class'HUD'.Default.RedColor $ "GO!" );
}

Manager.GroupSendMessage( GroupIndex, class'HUD'.default.RedColor $ GoMessage );
Destroy();
}

defaultproperties
{
CountMessage="%i..."
GoMessage="GO!"
}
63 changes: 63 additions & 0 deletions Classes/GroupInstance.uc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*==============================================================================
TrialGroup
Copyright (C) 2014 Eliot Van Uytfanghe
This program is free software; you can redistribute and/or modify
it under the terms of the Open Unreal Mod License version 1.1.
==============================================================================*/
class GroupInstance extends ReplicationInfo;

var GroupManager Manager;
var int GroupId;
var string GroupName;
var Color GroupColor;

var GroupPlayerLinkedReplicationInfo Commander;
var private string QueueMessage;

replication
{
reliable if( IsRelevantToGroup( Level.ReplicationViewTarget ) )
QueueMessage;

reliable if( bNetDirty )
Commander;

reliable if( bNetInitial )
GroupName, GroupColor;
}

event PreBeginPlay()
{
super.PreBeginPlay();
Manager = GroupManager(Owner);
GroupColor.A = 255;
GroupColor.R = Rand( 255 );
GroupColor.G = Rand( 255 );
GroupColor.B = Rand( 255 );
}

final function bool IsRelevantToGroup( /**xPawn*/Actor target )
{
local int groupIndex;

if( Pawn(target) == none || Pawn(target).Controller == none )
{
// Log( "Invalid target!" @ target );
return false;
}

groupIndex = Manager.GetGroupIndexByPlayer( Pawn(target).Controller );
return groupIndex != -1 && Manager.Groups[groupIndex].Instance == self;
}

final simulated function SetQueueMessage( string message )
{
QueueMessage = message;
NetUpdateTime = Level.TimeSeconds - 1;
}

final simulated function string GetQueueMessage()
{
return QueueMessage;
}
102 changes: 101 additions & 1 deletion Classes/GroupInteraction.uc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,107 @@ exec function GroupSlow()
GroupCountDown( 3 );
}

function PostRender( Canvas C )
{
local GroupPlayerLinkedReplicationInfo LRI, myLRI;
local HUD hud;
local vector av;
// local vector bv;
local float dist, xl, yl;
// local float x, y;
local string s;
local PlayerController target;
local Pawn pawn;
// local Pawn b;
local vector camLoc, dir, aX, aY, aZ;
local rotator camRot;
local GroupInstance group;

if( ViewportOwner.Actor.myHUD.bShowScoreBoard || ViewportOwner.Actor.myHUD.bHideHUD || ViewportOwner.Actor.PlayerReplicationInfo == None )
return;

// C.SetPos( 600, 0 );
// C.DrawText( ViewportOwner.Actor.ViewTarget @ ViewportOwner.Actor.RealViewTarget );
if( Pawn(ViewportOwner.Actor.ViewTarget) != none )
{
target = PlayerController(Pawn(ViewportOwner.Actor.ViewTarget).Controller);
}
else
{
target = ViewportOwner.Actor;
}

myLRI = class'GroupManager'.static.GetGroupPlayerReplicationInfo( target );
if( myLRI == none )
{
return;
}

hud = ViewportOwner.Actor.myHUD;
foreach target.DynamicActors( class'GroupInstance', group )
{
for( LRI = group.Commander; LRI != none; LRI = LRI.NextMember )
{
// C.SetPos( 0, y );
// C.DrawText( LRI );
// y += 20;

pawn = LRI.Pawn;
if( pawn == none || ViewportOwner.Actor.ViewTarget == none )
{
continue;
}

if( pawn.bHidden || pawn.bDeleteMe )
{
continue;
}

C.GetCameraLocation( camLoc, camRot );
dir = pawn.Location - camLoc;
dist = VSize( dir );
if( dist > ViewportOwner.Actor.TeamBeaconMaxDist || !ViewportOwner.Actor.FastTrace( pawn.Location, camLoc ) )
{
continue;
}

GetAxes( ViewportOwner.Actor.ViewTarget.Rotation, aX, aY, aZ );
dir /= dist;
if( !((dir dot aX) > 0.6) )
{
continue;
}

if( dist < ViewportOwner.Actor.TeamBeaconPlayerInfoMaxDist*0.4f )
{
if( LRI != myLRI )
{
av = C.WorldToScreen( pawn.Location );
C.DrawColor = LRI.PlayerGroup.GroupColor;
if( group == myLRI.PlayerGroup )
{
C.DrawColor.A = 120;
class'HUD_Assault'.static.Draw_2DCollisionBox( C, pawn, av, LRI.PlayerGroup.GroupName, pawn.DrawScale, true );

s = ":" $ dist / 128 $ "m";
C.TextSize( s, xl, yl );
C.SetPos( av.x - xl*0.5, av.y );
C.DrawColor.A = 100;
C.DrawTextClipped( s );
}
else
{
C.DrawColor.A = 60;
class'HUD_Assault'.static.Draw_2DCollisionBox( C, pawn, av, LRI.PlayerGroup.GroupName, pawn.DrawScale, true );
}
}
}
}
}
}

defaultproperties
{
bRequiresTick=True
bVisible=true
bRequiresTick=true
}
57 changes: 57 additions & 0 deletions Classes/GroupLocalMessage.uc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*==============================================================================
TrialGroup
Copyright (C) 2014 Eliot Van Uytfanghe
This program is free software; you can redistribute and/or modify
it under the terms of the Open Unreal Mod License version 1.1.
==============================================================================*/
class GroupLocalMessage extends LocalMessage;

static function string GetString( optional int Switch,
optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2,
optional Object Source )
{
if( GroupInstance(Source) != none )
{
return GroupInstance(Source).GetQueueMessage();
}
return GroupPlayerLinkedReplicationInfo(Source).ClientMessage;
}

/**static function RenderComplexMessage(
Canvas C,
out float XL,
out float YL,
optional String MessageString,
optional int Switch,
optional PlayerReplicationInfo RelatedPRI_1,
optional PlayerReplicationInfo RelatedPRI_2,
optional Object OptionalObject
)
{
local bool pForceAlpha;
local byte pStyle;
pForceAlpha = C.bForceAlpha;
C.bForceAlpha = true;
C.ForcedAlpha = 1.0 - C.DrawColor.A/255;
pStyle = C.Style;
C.Style = ERenderStyle.STY_Alpha;
C.DrawTextClipped( MessageString, false );
C.bForceAlpha = pForceAlpha;
C.Style = pStyle;
}*/

defaultproperties
{
bIsConsoleMessage=false
bFadeMessage=true
// bComplexString=true

PosX=0.5
PosY=0.15
LifeTime=2
FontSize=-2

StackMode=SM_Down
}
Loading

0 comments on commit 4355b09

Please sign in to comment.