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

Jailbreak.JBLocalMessage


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
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
// ============================================================================
// JBLocalMessage
// Copyright 2002 by Mychaeel <mychaeel@planetjailbreak.com>
// $Id: JBLocalMessage.uc,v 1.25 2008-03-16 11:37:35 jrubzjeknf Exp $
//
// Abstract base class for localized Jailbreak messages. Contains all
// functionality common to console and on-screen messages.
//
// The following message codes are defined:
//
//   Switch    Meaning              Info 1           Info 2           Object
//   =======   =================    ==============   ==============   ========
//   100 (B)   Team captured                                          TeamInfo
//   200 (B)   Release, jail full   Releaser                          TeamInfo
//   210       Release, jail empty  Releaser                          TeamInfo
//   220       Release, jail jammed Releaser                          TeamInfo
//   300 (B)   Stalemate
//   403 (B)   Arena countdown 3                                      Arena
//   402 (B)   Arena countdown 2                                      Arena
//   401 (B)   Arena countdown 1                                      Arena
//   400 (B)   Arena start          Red Combatant    Blue Combatant   Arena
//   410 (B)   Arena cancelled      Red Combatant    Blue Combatant   Arena
//   420 (B)   Arena tie            Red Combatant    Blue Combatant   Arena
//   430 (B)   Arena victory        Winner           Loser            Arena
//   500 (L)   Keyboard arena
//   510 (L)   Keyboard cameras
//   600 (L)   Last man (initial)
//   601 (L)   Last man (initial, cant release)
//   610 (L)   Last man (repeat)
//   611 (L)   Last man (repeat, canr release)
//   700 (B)   Last second save
//   800       Disallowed Escape
//   900 (B)   Game started
//   910 (B)   Game overtime
//   920 (B)   Game over                                              TeamInfo
//
// Switches marked with (B) are broadcasted to all players, all other messages
// are directly sent to the players in question. Messages marked with (L) are
// sent locally to a single player.
// ============================================================================


class JBLocalMessage extends LocalMessage
  notplaceable;


#exec OBJ LOAD FILE=MenuSounds.uax

// ============================================================================
// Localization
// ============================================================================

var localized string TextTeamCaptured[2];
var localized string TextTeamReleased[2];
var localized string TextTeamReleasedBy[2];
var localized string TextTeamReleasedNobody;
var localized string TextTeamReleaseJammed;
var localized string TextTeamStalemate;


// Supported placeholders in all arena messages:
//   %teammate%   Name of teammate or own name
//   %enemy%      Name of enemy
//   %winner%     Name of arena match winner
//   %loser%      Name or arena match loser

var localized string TextArenaCountdown[3];
var localized string TextArenaStartCombatant;
var localized string TextArenaStartOther;
var localized string TextArenaCancelCombatant;
var localized string TextArenaCancelOther;
var localized string TextArenaTieCombatant;
var localized string TextArenaTieOther;
var localized string TextArenaEndWinner;
var localized string TextArenaEndLoser;
var localized string TextArenaEndOther;


var           string TextKeyboardArena;
var localized string TextKeyboardArenaBound;
var localized string TextKeyboardArenaUnbound;
var           string TextKeyboardCamera;
var localized string TextKeyboardCameraBound;
var localized string TextKeyboardCameraUnbound;


var localized string TextLastMan;
var localized string TextLastManCantRelease;

var localized string TextDisallowedEscape;


// ============================================================================
// Variables
// ============================================================================

var Class<JBLocalMessage> ClassLocalMessageScreen;   // on-screen messages
var Class<JBLocalMessage> ClassLocalMessageConsole;  // console messages
var Class<JBLocalMessage> ClassLocalMessageConsoleOneSecond; // console messages of 1 second


// ============================================================================
// PlaySpeech
//
// Plays the given segmented speech sequence definition for the given player
// and returns whether playback was successfully started.
// ============================================================================

static function bool PlaySpeech(PlayerController PlayerController,
                                         string Definition0,
                                optional string Definition1,
                                optional int iDefinition)
{
  local string Tags;

  // only play for local player
  if (PlayerController == None || Viewport(PlayerController.Player) == None)
    return False;

  // check team/spectator
       if (PlayerController.PlayerReplicationInfo.bOnlySpectator)      Tags = "spectator";
  else if (PlayerController.PlayerReplicationInfo.Team.TeamIndex == 0) Tags = "red";
  else if (PlayerController.PlayerReplicationInfo.Team.TeamIndex == 1) Tags = "blue";

  switch (iDefinition) {
    case 0:  return Class'JBSpeechManager'.Static.PlayFor(PlayerController.Level, Definition0, Tags);
    case 1:  return Class'JBSpeechManager'.Static.PlayFor(PlayerController.Level, Definition1, Tags);
  }

  return False;
}


// ============================================================================
// ClientReceive
//
// Receives an event on a client. If called for the generic message class,
// replaces it by the more specific on-screen or console message, respectively.
// Otherwise plays sound and continues processing.
// ============================================================================

static function ClientReceive(PlayerController PlayerController,
                              optional int Switch,
                              optional PlayerReplicationInfo PlayerReplicationInfo1,
                              optional PlayerReplicationInfo PlayerReplicationInfo2,
                              optional Object ObjectOptional)
{
  local string Key;
  local string KeyPrev;
  local string KeyNext;
  local Class<JBLocalMessage> ClassLocalMessageReplacement;

  if (Default.Class == Class'JBLocalMessage') {
    ClassLocalMessageReplacement = Default.ClassLocalMessageScreen;

    if (Switch >= 400 && Switch <= 499 &&
       !IsLocalPlayer(PlayerReplicationInfo1, PlayerReplicationInfo2) &&
        class'JBTagPlayer'.static.FindFor(PlayerReplicationInfo1.Level.GetLocalPlayerController().PlayerReplicationInfo) != None &&
        class'JBTagPlayer'.static.FindFor(PlayerReplicationInfo1.Level.GetLocalPlayerController().PlayerReplicationInfo).IsFree()) {
      if (Switch <= 403 && Switch >= 401)
        ClassLocalMessageReplacement = Default.ClassLocalMessageConsoleOneSecond;
      else
        ClassLocalMessageReplacement = Default.ClassLocalMessageConsole;
    }

    PlayerController.ReceiveLocalizedMessage(
      ClassLocalMessageReplacement,
      Switch,
      PlayerReplicationInfo1,
      PlayerReplicationInfo2,
      ObjectOptional);
    return;
  }

  switch (Switch) {
    case 100:  PlaySpeech(PlayerController, "$TeamCapturedRed", "$TeamCapturedBlue", TeamInfo(ObjectOptional).TeamIndex);  break;
    case 200:  PlaySpeech(PlayerController, "$TeamReleasedRed", "$TeamReleasedBlue", TeamInfo(ObjectOptional).TeamIndex);  break;
    case 210:  PlaySpeech(PlayerController, "$TeamReleasedNobody");  break;
    case 220:  PlayerController.PlayBeepSound();                     break;
    case 300:  PlaySpeech(PlayerController, "$TeamCapturedBoth");    break;

    case 403:  if (IsLocalPlayer(PlayerReplicationInfo1, PlayerReplicationInfo2)) {
                 PlayerController.PlayBeepSound();
                 PlaySpeech(PlayerController, "$ArenaWarning");
                 break;
               }
    case 402:  if (IsLocalPlayer(PlayerReplicationInfo1, PlayerReplicationInfo2)) PlayerController.PlayBeepSound();  break;
    case 401:  if (IsLocalPlayer(PlayerReplicationInfo1, PlayerReplicationInfo2)) PlayerController.PlayBeepSound();  break;

    case 400:  if (IsLocalPlayer(PlayerReplicationInfo1, PlayerReplicationInfo2)) PlaySpeech(PlayerController, "$ArenaStart");       break;
    case 410:  if (IsLocalPlayer(PlayerReplicationInfo1, PlayerReplicationInfo2)) PlaySpeech(PlayerController, "$ArenaCancelled");   break;
    case 420:  if (IsLocalPlayer(PlayerReplicationInfo1, PlayerReplicationInfo2)) PlaySpeech(PlayerController, "$ArenaEndTimeout");  break;

    case 430:
           if (IsLocalPlayer(PlayerReplicationInfo1)) PlaySpeech(PlayerController, "$ArenaEndWinner");
      else if (IsLocalPlayer(PlayerReplicationInfo2)) PlaySpeech(PlayerController, "$ArenaEndLoser");
      break;

    case 600:  PlaySpeech(PlayerController, "$LastMan");          break;
    case 601:  PlaySpeech(PlayerController, "$LastMan");          break;
    case 700:  PlaySpeech(PlayerController, "$LastSecondSave");   break;

    case 800:  PlayerController.ClientPlaySound(Sound'MenuSounds.Denied1');
               PlayerController.PlayRewardAnnouncement('Denied',1, true); break;

    case 900:  PlaySpeech(PlayerController, "$GameStart");        break;
    case 910:  PlaySpeech(PlayerController, "$GameOvertime");     break;
    case 920:  PlaySpeech(PlayerController, "$GameOverWinnerRed", "$GameOverWinnerBlue", TeamInfo(ObjectOptional).TeamIndex);  break;

    case 500:
      Key = Class'JBInteractionKeys'.Static.GetKeyForCommand("ArenaCam");
      if (Key == "")
             Default.TextKeyboardArena =                   Default.TextKeyboardArenaUnbound;
        else Default.TextKeyboardArena = StaticReplaceText(Default.TextKeyboardArenaBound, "%key%", Key);
      break;

    case 510:
      KeyPrev = Class'JBInteractionKeys'.Static.GetKeyForCommand("PrevWeapon", "PrevWeapon");
      KeyNext = Class'JBInteractionKeys'.Static.GetKeyForCommand("NextWeapon", "NextWeapon");
      if (KeyPrev == "PrevWeapon" && KeyNext == "NextWeapon")
        Default.TextKeyboardCamera = Default.TextKeyboardCameraUnbound;
      else
        Default.TextKeyboardCamera = StaticReplaceText(StaticReplaceText(
          Default.TextKeyboardCameraBound,
            "%keyprev%", KeyPrev),
            "%keynext%", KeyNext);
      break;
  }

  Super.ClientReceive(PlayerController, Switch, PlayerReplicationInfo1, PlayerReplicationInfo2, ObjectOptional);
}


// ============================================================================
// StaticReplaceText
//
// Works almost like ReplaceText defined in Actor, but returns its result
// instead of employing an out parameter, and is static and can thus be called
// from other static functions.
// ============================================================================

static function string StaticReplaceText(string TextTemplate, string TextPlaceholder, string TextReplacement)
{
  local int OffsetPlaceholder;
  local string TextOutput;

  while (True) {
    OffsetPlaceholder = InStr(TextTemplate, TextPlaceholder);
    if (OffsetPlaceholder < 0)
      break;

    TextOutput = TextOutput $ Left(TextTemplate, OffsetPlaceholder);
    TextOutput = TextOutput $ TextReplacement;

    TextTemplate = Mid(TextTemplate, OffsetPlaceholder + Len(TextPlaceholder));
  }

  TextOutput = TextOutput $ TextTemplate;
  return TextOutput;
}


// ============================================================================
// ReplaceTextPlayer
//
// Replaces player name placeholder in the given template and returns the
// result.
// ============================================================================

static function string ReplaceTextPlayer(string TextTemplate, PlayerReplicationInfo PlayerReplicationInfo)
{
  return StaticReplaceText(TextTemplate, "%player%", PlayerReplicationInfo.PlayerName);
}


// ============================================================================
// ReplaceTextArena
//
// Replaces all placeholders present in the given template string by the
// information given through the two PlayerReplicationInfo actors. Assumes the
// first PlayerReplicationInfo actor to refer to the winner, the second to
// refer to the loser.
// ============================================================================

static function string ReplaceTextArena(string TextTemplate,
                                        PlayerReplicationInfo PlayerReplicationInfo1,
                                        PlayerReplicationInfo PlayerReplicationInfo2)
{
  local string PlayerNameTeammate;
  local string PlayerNameEnemy;
  local string PlayerNameWinner;
  local string PlayerNameLoser;
  local PlayerController PlayerLocal;
  local PlayerReplicationInfo PlayerReplicationInfoTeammate;
  local PlayerReplicationInfo PlayerReplicationInfoEnemy;

  if (PlayerReplicationInfo1 != None)
    PlayerLocal = PlayerReplicationInfo1.Level.GetLocalPlayerController();

  if (PlayerLocal == None ||
      PlayerLocal.PlayerReplicationInfo.Team == PlayerReplicationInfo1.Team) {
    PlayerReplicationInfoTeammate = PlayerReplicationInfo1;
    PlayerReplicationInfoEnemy    = PlayerReplicationInfo2;
  } else {
    PlayerReplicationInfoTeammate = PlayerReplicationInfo2;
    PlayerReplicationInfoEnemy    = PlayerReplicationInfo1;
  }

  PlayerNameTeammate = "???";
  PlayerNameEnemy    = "???";
  PlayerNameWinner   = "???";
  PlayerNameLoser    = "???";

  if (PlayerReplicationInfoTeammate != None) PlayerNameTeammate = PlayerReplicationInfoTeammate.PlayerName;
  if (PlayerReplicationInfoEnemy    != None) PlayerNameEnemy    = PlayerReplicationInfoEnemy   .PlayerName;
  if (PlayerReplicationInfo1        != None) PlayerNameWinner   = PlayerReplicationInfo1       .PlayerName;
  if (PlayerReplicationInfo2        != None) PlayerNameLoser    = PlayerReplicationInfo2       .PlayerName;

  TextTemplate = StaticReplaceText(TextTemplate, "%teammate%", PlayerNameTeammate);
  TextTemplate = StaticReplaceText(TextTemplate, "%enemy%",    PlayerNameEnemy);
  TextTemplate = StaticReplaceText(TextTemplate, "%winner%",   PlayerNameWinner);
  TextTemplate = StaticReplaceText(TextTemplate, "%loser%",    PlayerNameLoser);

  return TextTemplate;
}


// ============================================================================
// IsLocalPlayer
//
// Returns whether any of the given PlayerReplicationInfo actors belongs to
// the local player on this client.
// ============================================================================

static function bool IsLocalPlayer(PlayerReplicationInfo PlayerReplicationInfo1,
                          optional PlayerReplicationInfo PlayerReplicationInfo2)
{
  local PlayerController PlayerLocal;

  if (PlayerReplicationInfo1 == None)
    return False;

  PlayerLocal = PlayerReplicationInfo1.Level.GetLocalPlayerController();
  if (PlayerLocal == None)
    return False;

  return (PlayerReplicationInfo1 == PlayerLocal.PlayerReplicationInfo ||
          PlayerReplicationInfo2 == PlayerLocal.PlayerReplicationInfo);
}


// ============================================================================
// GetString
//
// Gets the localized string for the given event. See ClientReceive for an
// explanation of possible parameter values.
// ============================================================================

static function string GetString(optional int Switch,
                                 optional PlayerReplicationInfo PlayerReplicationInfo1,
                                 optional PlayerReplicationInfo PlayerReplicationInfo2,
                                 optional Object ObjectOptional)
{
  switch (Switch) {
    case 100:  return Default.TextTeamCaptured[TeamInfo(ObjectOptional).TeamIndex];
    case 300:  return Default.TextTeamStalemate;

    case 200:
      if (PlayerReplicationInfo1 != None)
        return ReplaceTextPlayer(Default.TextTeamReleasedBy[TeamInfo(ObjectOptional).TeamIndex], PlayerReplicationInfo1);
      return Default.TextTeamReleased[TeamInfo(ObjectOptional).TeamIndex];

    case 210:
      return Default.TextTeamReleasedNobody;
    case 220:
      return Default.TextTeamReleaseJammed;

    case 403:  return ReplaceTextArena(Default.TextArenaCountdown[2], PlayerReplicationInfo1, PlayerReplicationInfo2);
    case 402:  return ReplaceTextArena(Default.TextArenaCountdown[1], PlayerReplicationInfo1, PlayerReplicationInfo2);
    case 401:  return ReplaceTextArena(Default.TextArenaCountdown[0], PlayerReplicationInfo1, PlayerReplicationInfo2);

    case 400:
      if (IsLocalPlayer(PlayerReplicationInfo1, PlayerReplicationInfo2))
        return ReplaceTextArena(Default.TextArenaStartCombatant, PlayerReplicationInfo1, PlayerReplicationInfo2);
      return ReplaceTextArena(Default.TextArenaStartOther, PlayerReplicationInfo1, PlayerReplicationInfo2);

    case 410:  return ReplaceTextArena(Default.TextArenaCancelCombatant, PlayerReplicationInfo1, PlayerReplicationInfo2);

    case 420:
      if (IsLocalPlayer(PlayerReplicationInfo1, PlayerReplicationInfo2))
        return ReplaceTextArena(Default.TextArenaTieCombatant, PlayerReplicationInfo1, PlayerReplicationInfo2);
      return ReplaceTextArena(Default.TextArenaTieOther, PlayerReplicationInfo1, PlayerReplicationInfo2);

    case 430:
      if (IsLocalPlayer(PlayerReplicationInfo1))
        return ReplaceTextArena(Default.TextArenaEndWinner, PlayerReplicationInfo1, PlayerReplicationInfo2);
      if (IsLocalPlayer(PlayerReplicationInfo2))
        return ReplaceTextArena(Default.TextArenaEndLoser, PlayerReplicationInfo1, PlayerReplicationInfo2);
      return ReplaceTextArena(Default.TextArenaEndOther, PlayerReplicationInfo1, PlayerReplicationInfo2);

    case 500:  return Default.TextKeyboardArena;
    case 510:  return Default.TextKeyboardCamera;

    case 600:  return Default.TextLastMan;
    case 601:  return Default.TextLastManCantRelease;
    case 610:  return Default.TextLastMan;
    case 611:  return Default.TextLastManCantRelease;
    case 800:  return Default.TextDisallowedEscape;
  }
}


// ============================================================================
// Defaults
// ============================================================================

defaultproperties
{
  bIsConsoleMessage = False;
  bIsSpecial = False;

  TextTeamCaptured[0]       = "The red team has been captured.";
  TextTeamCaptured[1]       = "The blue team has been captured.";
  TextTeamReleased[0]       = "The red team has been released.";
  TextTeamReleased[1]       = "The blue team has been released.";
  TextTeamReleasedBy[0]     = "The red team has been released by %player%.";
  TextTeamReleasedBy[1]     = "The blue team has been released by %player%.";
  TextTeamReleasedNobody    = "This jail is empty."
  TextTeamReleaseJammed     = "This jail is jammed."
  TextTeamStalemate         = "Both teams captured, no score.";

  TextArenaCountdown[2]     = "Arena match is about to begin...3";
  TextArenaCountdown[1]     = "Arena match is about to begin...2";
  TextArenaCountdown[0]     = "Arena match is about to begin...1";
  TextArenaStartCombatant   = "Arena match has begun!";
  TextArenaStartOther       = "%teammate% is fighting %enemy% in the arena.";
  TextArenaCancelCombatant  = "Arena match has been cancelled.";
  TextArenaCancelOther      = "Arena match between %teammate% and %enemy% cancelled.";
  TextArenaTieCombatant     = "Arena match tied.";
  TextArenaTieOther         = "Arena match between %teammate% and %enemy% tied.";
  TextArenaEndWinner        = "You have won your freedom!";
  TextArenaEndLoser         = "You have lost the arena match.";
  TextArenaEndOther         = "%winner% has defeated %loser% in the arena.";

  TextKeyboardArenaBound    = "Press [%key%] to watch this arena fight!";
  TextKeyboardArenaUnbound  = "Enter 'ArenaCam' at the console to watch this arena fight!";
  TextKeyboardCameraBound   = "Press [%keyprev%] and [%keynext%] to switch cameras";
  TextKeyboardCameraUnbound = "Enter 'PrevWeapon' and 'NextWeapon' at the console to switch cameras";

  TextLastMan               = "You are the last free player. Release your team!";
  TextLastManCantRelease    = "You are the last free player. Stay alive!";

  TextDisallowedEscape      = "You're not allowed to escape from jail!";

  ClassLocalMessageScreen           = Class'JBLocalMessageScreen';
  ClassLocalMessageConsole          = Class'JBLocalMessageConsole';
  ClassLocalMessageConsoleOneSecond = Class'JBLocalMessageConsoleOneSecond';

  Role = ROLE_None // Fixes Accessed None error on client
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mo 3.1.2011 12:34:30.000 - Creation time: Do 14.8.2014 09:58:42.819 - Created with UnCodeX