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

DeusEx.NetworkTerminal


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
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
//=============================================================================
// NetworkTerminal.
//=============================================================================
class NetworkTerminal extends DeusExBaseWindow
    abstract;

var ComputerUIWindow           winComputer;     // Currently active computer screen
var ComputerScreenHack         winHack;         // Ice Breaker Hack Window
var ShadowWindow               winHackShadow;
var ComputerScreenHackAccounts winHackAccounts; // Hack Accounts Window, used for email
var ShadowWindow               winHackAccountsShadow;
var ElectronicDevices          compOwner;       // what computer owns this window?

var Class<ComputerUIWindow> FirstScreen;    // First screen to push

// Hacking related variables
var float loginTime;            // time that the user logged in
var float detectionTime;        // total time a user may be logged on
var int   kickTimerID;          // timer ID for kicking the user off
var int   skillLevel;           // player's computer skill level (0-3)
var bool  bHacked;              // this computer has been hacked
var bool  bNoHack;              // this computer has been purposely not hacked
var bool  bUsesHackWindow;      // True if Hack Window created by default.

// Login related variables
var string userName;
var int    userIndex;

// Shadow stuff
var int shadowOffsetX;
var int shadowOffsetY;

// ----------------------------------------------------------------------
// InitWindow()
//
// Initialize the Window
// ----------------------------------------------------------------------

event InitWindow()
{
    Super.InitWindow();

    SetWindowAlignments(HALIGN_Full, VALIGN_Full);

    // Draw a black background for now
    SetBackgroundStyle(DSTY_Normal);
    SetBackground(Texture'Solid');
    SetTileColorRGB(0, 0, 0);

    SetMouseFocusMode(MFOCUS_Click);

    root.ShowHUD(False);

    CreateHackWindow();

    bTickEnabled = True;
}

// ----------------------------------------------------------------------
// DestroyWindow()
//
// Destroys the Window
// ----------------------------------------------------------------------

event DestroyWindow()
{
    if ((compOwner.IsA('Computers')) && (compOwner != None))
    {
      if (Player != Player.GetPlayerPawn())
      {
         log("==============>Player mismatch!!!!");
      }
        // Keep track of the last time this computer was hacked
      else if (player.ActiveComputer == CompOwner)
      {
         if (bHacked)
            player.SetComputerHackTime(Computers(compOwner),player.level.TimeSeconds, player.level.TimeSeconds);
         player.CloseComputerScreen(Computers(compOwner));
         player.ActiveComputer = None;
      }

        Computers(compOwner).termWindow = None;
    }
    else if (compOwner.IsA('ATM'))
    {
        // Keep track of the last time this computer was hacked
        if (bHacked)
            ATM(compOwner).lastHackTime = player.Level.TimeSeconds;

        ATM(compOwner).atmWindow = None;
    }

    // Show the HUD again
    root.ShowHUD(True);

    // Now finish destroy us.
    Super.DestroyWindow();
}

// ----------------------------------------------------------------------
// Tick()
//
// Checks to see if the player has died, and if so, gets us the 
// hell out of this screen!!
// ----------------------------------------------------------------------

function Tick(float deltaTime)
{
    if ((player != None) && (player.IsInState('Dying')))
    {
        bTickEnabled = False;
        CloseScreen("EXIT");    
   }
   else
   {
      // DEUS_EX AMSD Put this in an else.  Don't do this if you are dead and have
      // closed the screen!
      // Update the hack bar detection time
      UpdateHackDetectionTime();
   }
}

// ----------------------------------------------------------------------
// ConfigurationChanged()
//
// Used to Manually place the computer screen if the Hack window 
// is visible and the computer screen's position would overlap
// the hack window.
// ----------------------------------------------------------------------

function ConfigurationChanged()
{
    local float hackWidth, hackHeight;
    local float hackAccountsWidth, hackAccountsHeight;
    local float compWidth, compHeight;
    local float compX;

    // First look for the hack window.  If it's not visible, then
    // our work here is done!

    if (winHack != None)
    {
        winHack.QueryPreferredSize(hackWidth, hackHeight);

        // Shove in upper-right hand corner
        winHack.ConfigureChild(
            width - hackWidth, 0, 
            hackWidth, hackHeight);

        // Place shadow
        winHackShadow.ConfigureChild(
            width - hackWidth + winHack.backgroundPosX - shadowOffsetX, 
            winHack.backgroundPosY - shadowOffsetY, 
            winHack.backgroundWidth + (shadowOffsetX * 2), 
            winHack.backgroundHeight + (shadowOffsetY * 2));
    }

    // Check for the Hack Accounts window, which is displayed
    // underneath the Hack window.  Position under the Hack Window

    if (winHackAccounts != None)
    {
        winHackAccounts.QueryPreferredSize(hackAccountsWidth, hackAccountsHeight);
        winHackAccounts.ConfigureChild(
            width - hackAccountsWidth, hackHeight + 20, 
            hackAccountsWidth, hackAccountsHeight);

        // Place shadow
        winHackAccountsShadow.ConfigureChild(
            width - hackAccountsWidth + winHackAccounts.backgroundPosX - shadowOffsetX, 
            hackHeight + 20 + winHackAccounts.backgroundPosY - shadowOffsetY, 
            winHackAccounts.backgroundWidth + (shadowOffsetX * 2), 
            winHackAccounts.backgroundHeight + (shadowOffsetY * 2));
    }

    // Now check to see if we have a computer screen.  If so,
    // center it in relation to the hack window.  Don't force
    // position if the window has been dragged somewhere else
    // by the user.

    if ((winComputer != None) && (!winComputer.bWindowDragged))
    {
        winComputer.QueryPreferredSize(compWidth, compHeight);

        // Center the window, but move it left if the height of the 
        // hack window would infringe on the window (unless the 
        // "bAlwaysCenter" flag is set)

        if (((hackHeight + hackAccountsHeight + 20) > ((height / 2) - (compHeight / 2))) &&
            (!winComputer.bAlwaysCenter))
        {
            compX = (width - hackWidth) / 2 - (compWidth / 2);
        }
        else
        {
            compX = (width / 2) - (compWidth / 2);
        }

        winComputer.ConfigureChild(
            compX, (height / 2) - (compHeight / 2), 
            compWidth, compHeight);
    }
}

// ----------------------------------------------------------------------------------
// VirtualKeyPressed
// ----------------------------------------------------------------------------------

event bool VirtualKeyPressed(EInputKey key, bool bRepeat)
{
    local String KeyName, Alias;
    local bool bKeyHandled;

    bKeyHandled = False;

    if ( Player.Level.NetMode != NM_Standalone )
    {
        // Let them send chat messages while hacking
        KeyName = player.ConsoleCommand("KEYNAME "$key );
        Alias =     player.ConsoleCommand( "KEYBINDING "$KeyName );

        if ( Alias ~= "Talk" )
        {
            log("===>trying to talk..." );
            Player.Player.Console.Talk();
            bKeyHandled = True;
        }
        else if ( Alias ~= "TeamTalk" )
        {
            log("===>trying to teamtalk..." );
            Player.Player.Console.TeamTalk();
            bKeyHandled = True;
        }
    }

    if ( bKeyHandled )
        return True;
    else
        return Super.VirtualKeyPressed(key, bRepeat);
}


// ----------------------------------------------------------------------
// ShowFirstScreen()
// ----------------------------------------------------------------------

function ShowFirstScreen()
{
    ShowScreen(FirstScreen);
}

// ----------------------------------------------------------------------
// ShowScreen()
// ----------------------------------------------------------------------

function ShowScreen(Class<ComputerUIWindow> newScreen)
{
    // First close any existing screen
    if (winComputer != None)
    {
        winComputer.Destroy();
        winComputer = None;
    }

    // Now invoke the new screen
    if (newScreen != None)
    {
        winComputer = ComputerUIWindow(NewChild(newScreen));
        winComputer.SetWindowAlignments(HALIGN_Center, VALIGN_Center);
        winComputer.SetNetworkTerminal(Self);   
        winComputer.SetCompOwner(compOwner);
        winComputer.Lower();
    }
}

// ----------------------------------------------------------------------
// CloseScreen()
// ----------------------------------------------------------------------

function CloseScreen(String action)
{
    // First destroy the current screen
    if (winComputer != None)
    {
        winComputer.Destroy();
        winComputer = None;
    }

    // Based on the action, proceed!
    
    if (action == "EXIT")
    {
        if (Computers(compOwner) != None)   
            player.CloseComputerScreen(Computers(compOwner));
        root.PopWindow();
        return;
    }

    // If the user is logging in and bypassing the Hack screen,
    // then destroy the Hack window

    if ((action == "LOGIN") && (winHack != None) && (!bHacked))
    {
        CloseHackWindow();
        bNoHack = True;
    }
}

// ----------------------------------------------------------------------
// CloseHackWindow()
// ----------------------------------------------------------------------

function CloseHackWindow()
{
    if (winHack != None)
    {
        winHack.Destroy();
        winHack = None;

        winHackShadow.Destroy();
        winHackShadow = None;
    }
}

// ----------------------------------------------------------------------
// ForceCloseScreen()
// ----------------------------------------------------------------------

function ForceCloseScreen()
{
    // If a screen is active, tell it to exit
    if (winComputer != None)
        winComputer.CloseScreen(winComputer.escapeAction);
}

// ----------------------------------------------------------------------
// CreateHackWindow()
// ----------------------------------------------------------------------

function CreateHackWindow()
{
    local Float hackTime;
    local Float skillLevelValue;

    skillLevelValue = player.SkillSystem.GetSkillLevelValue(class'SkillComputer');
    skillLevel      = player.SkillSystem.GetSkillLevel(class'SkillComputer');

    // Check to see if the player is skilled in Hacking before 
    // creating the window
    if ((skillLevel > 0) && (bUsesHackWindow))
    {
        // Base the detection and hack time on the skill level
        hackTime       = detectionTime / (skillLevelValue * 1.5);
        detectionTime *= skillLevelValue;

        // First create the shadow window
        winHackShadow = ShadowWindow(NewChild(Class'ShadowWindow'));

        winHack = ComputerScreenHack(NewChild(Class'ComputerScreenHack'));
        winHack.SetNetworkTerminal(Self);
        winHack.SetDetectionTime(detectionTime, hackTime);
    }
}

// ----------------------------------------------------------------------
// CreateHackAccountsWindow()
//
// Create the window used to hack email accounts, but only create it if
// the player hacked into the computer *and* there's more than one 
// account to display
// ----------------------------------------------------------------------

function CreateHackAccountsWindow()
{
    if ((bHacked) && (winHackAccounts == None) && (Computers(compOwner).NumUsers() > 1))
    {
        // First create the shadow window
        winHackAccountsShadow = ShadowWindow(NewChild(Class'ShadowWindow'));

        winHackAccounts = ComputerScreenHackAccounts(NewChild(Class'ComputerScreenHackAccounts'));
        winHackAccounts.SetNetworkTerminal(Self);
        winHackAccounts.SetCompOwner(compOwner);
        winHackAccounts.AskParentForReconfigure();
    }
}

// ----------------------------------------------------------------------
// CloseHackAccountsWindow()
// ----------------------------------------------------------------------

function CloseHackAccountsWindow()
{
    if (winHackAccounts != None)
    {
        winHackAccounts.Destroy();
        winHackAccounts = None;

        winHackAccountsShadow.Destroy();
        winHackAccountsShadow = None;
    }
}

// ----------------------------------------------------------------------
// SetHackButtonToReturn()
// ----------------------------------------------------------------------

function SetHackButtonToReturn()
{
    if ((bHacked) && (winHack != None))
        winHack.SetHackButtonToReturn();
}

// ----------------------------------------------------------------------
// SetCompOwner()
// ----------------------------------------------------------------------

function SetCompOwner(ElectronicDevices newCompOwner)
{
    compOwner = newCompOwner;

    if (winComputer != None)
        winComputer.SetCompOwner(compOwner);

    // Update the hack bar detection time
    UpdateHackDetectionTime();
}

// ----------------------------------------------------------------------
// UpdateHackDetectionTime()
// ----------------------------------------------------------------------

function UpdateHackDetectionTime()
{
    local Float diff;
    local Float detectionTime;

    // If the hack window is active, then we need to update 
    // the detection time
    if ((winHack != None) && (!winhack.bHacking) && (compOwner != None) && (!bHacked))
    {
        detectionTime = winHack.GetSaveDetectionTime();

        if (compOwner.IsA('Computers')) 
      {
            diff = player.Level.TimeSeconds - Computers(compOwner).lastHackTime;
      }
        else
            diff = player.Level.TimeSeconds - ATM(compOwner).lastHackTime;

        if (diff < detectionTime)
            winHack.UpdateDetectionTime(diff + 0.5);
    }
}

// ----------------------------------------------------------------------
// SetLoginInfo()
// ----------------------------------------------------------------------

function SetLoginInfo(String newUserName, Int newUserIndex)
{
    userName  = newUserName;
    userIndex = newUserIndex;
}

// ----------------------------------------------------------------------
// ChangeAccount()
// ----------------------------------------------------------------------

function ChangeAccount(int newUserIndex)
{
    userIndex = newUserIndex;

    if (compOwner != None)
        userName  = Computers(compOwner).GetUserName(userIndex);

    // Notify the computer window
    if (winComputer != None)
        winComputer.ChangeAccount();
}

// ----------------------------------------------------------------------
// GetUserName()
// ----------------------------------------------------------------------

function String GetUserName()
{
    return userName;
}

// ----------------------------------------------------------------------
// GetUserIndex()
// ----------------------------------------------------------------------

function int GetUserIndex()
{
    return userIndex;
}

// ----------------------------------------------------------------------
// SetSkillLevel()
// ----------------------------------------------------------------------

function SetSkillLevel(int newSkillLevel)
{
    skillLevel = newSkillLevel;
}

// ----------------------------------------------------------------------
// GetSkillLevel()
// ----------------------------------------------------------------------

function int GetSkillLevel()
{
    return skillLevel;
}

// ----------------------------------------------------------------------
// ComputerHacked()
//
// Computer was hacked, allow user to login
// ----------------------------------------------------------------------

function ComputerHacked()
{
    bHacked = True;

    // Use the first login
    userIndex = 0;
    
    if (compOwner.IsA('Computers'))
        userName  = Computers(compOwner).GetUserName(userIndex);
    
    CloseScreen("LOGIN");
}

// ----------------------------------------------------------------------
// HackDetected()
// ----------------------------------------------------------------------

function HackDetected(optional bool bDamageOnly)
{
    if (compOwner.IsA('Computers'))
    {
        Computers(compOwner).bLockedOut = True;
        Computers(compOwner).lockoutTime = player.Level.TimeSeconds;
    }
    else
    {
        ATM(compOwner).bLockedOut = True;
        ATM(compOwner).lockoutTime = player.Level.TimeSeconds;
    }

    // Shock the crap out of the player (drain BE and play a sound)
    // Highly skilled players take less damage
   // DEUS_EX AMSD In multiplayer, don't damage.  
   if (Player.Level.NetMode == NM_Standalone)
   {
      player.TakeDamage(200 - 50 * skillLevel, None, vect(0,0,0), vect(0,0,0), 'EMP');  
      PlaySound(sound'ProdFire');
   }
   else
   {
      player.PunishDetection(200 - 50 * skillLevel);
      PlaySound(sound'ProdFire');
   }

    if (!bDamageOnly)
        CloseScreen("EXIT");
}

// ----------------------------------------------------------------------
// AreSpecialOptionsAvailable()
// ----------------------------------------------------------------------

function bool AreSpecialOptionsAvailable(optional bool bCheckActivated)
{
    local int i;
    local bool bOK;

    bOK = False;
    for (i=0; i<ArrayCount(Computers(compOwner).specialOptions); i++)
    {
        if (Computers(compOwner).specialOptions[i].Text != "")
        {
            if ((Computers(compOwner).specialOptions[i].userName == "") || (Caps(Computers(compOwner).specialOptions[i].userName) == userName))
            {
                // Also check if the "bCheckActivated" bool is set, in which case we also 
                // want to make sure the item hasn't already been triggered.

                if (!((bCheckActivated) && (Computers(compOwner).specialOptions[i].bAlreadyTriggered)))
                {
                    bOK = True;
                    break;
                }
            }
        }
    }

    return bOK;
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

defaultproperties
{
     detectionTime=15.000000
     kickTimerID=-1
     bUsesHackWindow=True
     shadowOffsetX=15
     shadowOffsetY=15
     ScreenType=ST_Computer
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mon 8/11/2021 16:22:50.000 - Creation time: Mon 8/11/2021 16:31:30.040 - Created with UnCodeX