Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

de.TBMutator


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
//=============================================================================
// TBMutator. 
// Steve Sinclair, Digital Extremes, Jan 4, 2000
// originally this was going to be a HUD mutation
// but using actual sprites worked better than overlays
// I stayed with the HUDmutator paradigm because it was the easiest
// way for me to hook this into network clients and might also
// be complimented by some more PostRender action
//=============================================================================
class TBMutator expands Mutator;

var float           mMinScale;
var float           mMaxScale;
var PlayerPawn      PlayerOwner;

// sets the sprite's texture based on team id
simulated function SetSymbol( IdentitySymbol s, byte team)
{
    switch (team)
    {
        case 0:
            s.Texture = texture'TSignR';
            break;
        case 1:
            s.Texture = texture'TSignB';
            break;
        case 2:
            s.Texture = texture'TSignG';
            break;
        case 3:
            s.Texture = texture'TSignY';
            break;
        default:
            s.Texture = texture'TSignR';
    }
}

simulated function PostRender(Canvas canvas)
{
    PlayerOwner = Canvas.Viewport.Actor;
    // call the next HUDmutator
    if ( NextMutator != None )
    {
         NextMutator.PostRender(Canvas);
    }
}

simulated function Tick(float Delta)
{
    local Pawn      P;
    local float     dist;
    local Vector    dir;
    local Vector    loc;
    local byte      team_id;
    local int       num_used;
    local int       player_id;
    local int       team_count;
    local int       symbol_count;
    local float     draw_scale;
    local float     interp;
    
    local PlayerReplicationInfo PRI;
    local IdentitySymbol s;

    if (PlayerOwner == None)// || !PlayerOwner.Level.Game.bTeamGame)
    {
        return;
    }

    // get the player's information
    team_id = PlayerOwner.PlayerReplicationInfo.Team;
    player_id = PlayerOwner.PlayerReplicationInfo.PlayerID;
    
    num_used = 0;
    team_count = 0;
    symbol_count = 0;
    // count the symbols in the client environment and set them available
    foreach AllActors (class 'IdentitySymbol', s)
    {
        symbol_count++;
        s.bHidden = True; // we use this to set the symbol as 'available' for assignment
    }

    // cycle through the Pawns and assign symbols to team mates
    // this is far from the optimal way to do it
    foreach AllActors (class'Pawn', P)
    {
        PRI = P.PlayerReplicationInfo;
        if ( PRI == None )
            continue;
        if ( team_id == PRI.Team && player_id != PRI.PlayerID)
        {
            team_count++;
            if (team_count > symbol_count)// spawn if need more
            {
                s = Spawn(class 'IdentitySymbol', P);
                s.bHidden = P.bHidden;
                s.SetOwner(P);
                symbol_count++;
            }
            else // otherwise, assign a free IdentitySymbol to someone
            {
                foreach AllActors (class 'IdentitySymbol', s)
                {
                    if (s.bHidden == True)
                    {
                        s.bHidden = P.bHidden;
                        s.SetOwner(P);
                        break;
                    }
                }
            }

            // set sprite location above their head
            loc = P.Location;
            loc.z += P.CollisionHeight * 1.75;
            // interp from min/max view distance, to scale the sprite based on distance
            dir = P.Location - PlayerOwner.Location;
            dist = VSize(Dir);
            interp = Dist/32768.0;
        
            // adjust sprite scale if zooming :kludged values:
            interp -= 0.3 * (1.0-(PlayerOwner.FOVAngle / PlayerOwner.DesiredFOV));
            // clamp
            if (interp < 0.0)
                interp = 0.0;
            if (interp > 1.0)
                interp = 1.0;
            draw_scale = Lerp( interp, mMinScale, mMaxScale); 
            s.SetLocation(loc);
            s.DrawScale = draw_scale;
            SetSymbol(s, team_id); // update the texture
        }
    }
}

defaultproperties
{
     mMinScale=0.300000
     mMaxScale=14.000000
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: So 4.5.2008 11:16:20.000 - Creation time: Fr 7.6.2013 13:16:01.389 - Created with UnCodeX