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

DeusEx.HackableDevices


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
//=============================================================================
// HackableDevices.
//=============================================================================
class HackableDevices extends ElectronicDevices
    abstract;

var() bool              bHackable;              // can this device be hacked?
var() float             hackStrength;           // "toughness" of the hack on this device - 0.0 is easy, 1.0 is hard
var() float          initialhackStrength; // for multiplayer hack resets, this is the initial value
var() name              UnTriggerEvent[4];      // event to UnTrigger when hacked

var bool                   bHacking;                // a multitool is currently being used
var float               hackValue;              // how much this multitool is currently hacking
var float               hackTime;               // how much time it takes to use a single multitool
var int                 numHacks;               // how many times to reduce hack strength
var float            TicksSinceLastHack;   // num 0.1 second ticks done since last hackstrength update(includes partials)
var float            TicksPerHack;         // num 0.1 second ticks needed for a hackstrength update(includes partials)
var float            LastTickTime;         // time last tick occurred.

var DeusExPlayer        hackPlayer;             // the player that is hacking
var Multitool           curTool;                // the multitool that is being used

var float            TimeSinceReset;   // time since the hackstate was last reset.
var float            TimeToReset;      // how long between resets

var localized string    msgMultitoolSuccess;    // message when the device is hacked
var localized string    msgNotHacked;           // message when the device is not hacked
var localized string    msgHacking;             // message when the device is being hacked
var localized string    msgAlreadyHacked;       // message when the device is already hacked

// ---------------------------------------------------------------------------------------
// Networking Replication
// ---------------------------------------------------------------------------------------
replication
{
   //server to client variables
   reliable if (Role == ROLE_Authority)
      bHackable, hackStrength, hackValue;
}

function PostBeginPlay()
{
    Super.PostBeginPlay();

    // keep this within limits
    hackStrength = FClamp(hackStrength, 0.0, 1.0);

    if (!bHackable)
        hackStrength = 1.0;

   initialhackStrength = hackStrength;
   TimeSinceReset = 0.0;
}

//
// HackAction() - called when the device is successfully hacked
//
function HackAction(Actor Hacker, bool bHacked)
{
    local Actor A;
    local int i;

    if (bHacked)
    {
        for (i=0; i<ArrayCount(UnTriggerEvent); i++)
            if (UnTriggerEvent[i] != '')
                foreach AllActors(class'Actor', A, UnTriggerEvent[i])
                    A.UnTrigger(Hacker, Pawn(Hacker));   
   }
}

//
// Called every 0.1 seconds while the multitool is actually hacking
//
function Timer()
{
    if (bHacking)
    {
        curTool.PlayUseAnim();

      TicksSinceLastHack += (Level.TimeSeconds - LastTickTime) * 10;
      LastTickTime = Level.TimeSeconds;
      //TicksSinceLastHack = TicksSinceLastHack + 1;
      while (TicksSinceLastHack > TicksPerHack)
      {
         numHacks--;
         hackStrength -= 0.01;
         TicksSinceLastHack = TicksSinceLastHack - TicksPerHack;
         hackStrength = FClamp(hackStrength, 0.0, 1.0);
      }

        // did we hack it?
        if (hackStrength ~= 0.0)
        {
            hackStrength = 0.0;
            hackPlayer.ClientMessage(msgMultitoolSuccess);
         // Start reset counter from the time you finish hacking it.
         TimeSinceReset = 0;
            StopHacking();
            HackAction(hackPlayer, True);
        }

        // are we done with this tool?
        else if (numHacks <= 0)
            StopHacking();

        // check to see if we've moved too far away from the device to continue
        else if (hackPlayer.frobTarget != Self)
            StopHacking();

        // check to see if we've put the multitool away
        else if (hackPlayer.inHand != curTool)
            StopHacking();
    }
}

//
// Called to deal with resetting the device
//
function Tick(float deltaTime)
{
   TimeSinceReset = TimeSinceReset + deltaTime;
   //only reset in multiplayer, if we aren't hacking it, and if it has been completely hacked.
   if ((!bHacking) && (Level.NetMode != NM_Standalone) && (hackStrength == 0.0))
   {
      if (TimeSinceReset > TimeToReset)
      {
         hackStrength = initialHackStrength;
         TimeSinceReset = 0.0;
      }
   }
   Super.Tick(deltaTime);
}

//
// Stops the current hack-in-progress
//
function StopHacking()
{
    // alert NPCs that I'm not messing with stuff anymore
    AIEndEvent('MegaFutz', EAITYPE_Visual);
    bHacking = False;
    if (curTool != None)
    {
        curTool.StopUseAnim();
        curTool.bBeingUsed = False;
        curTool.UseOnce();
    }
    curTool = None;
    SetTimer(0.1, False);
}

//
// The main logic function for control panels
//
function Frob(Actor Frobber, Inventory frobWith)
{
    local Pawn P;
    local DeusExPlayer Player;
    local bool bHackIt, bDone;
    local string msg;
    local Vector X, Y, Z;
    local float dotp;

    P = Pawn(Frobber);
    Player = DeusExPlayer(P);
    bHackIt = False;
    bDone = False;
    msg = msgNotHacked;

    // make sure someone is trying to hack the device
    if (P == None)
        return;

    // Let any non-player pawn hack the device for now
    if (Player == None)
    {
        bHackIt = True;
        msg = "";
        bDone = True;
    }

    // If we are already trying to hack it, print a message
    if (bHacking)
    {
        msg = msgHacking;
        bDone = True;
    }

    if (!bDone)
    {
        // Get what's in the player's hand
        if (frobWith != None)
        {
            // check for the use of multitools
            if (bHackable && frobWith.IsA('Multitool') && (Player.SkillSystem != None))
            {
                if (hackStrength > 0.0)
                {
                    // alert NPCs that I'm messing with stuff
                    AIStartEvent('MegaFutz', EAITYPE_Visual);

                    hackValue = Player.SkillSystem.GetSkillLevelValue(class'SkillTech');
                    hackPlayer = Player;
                    curTool = Multitool(frobWith);
                    curTool.bBeingUsed = True;
                    curTool.PlayUseAnim();
                    bHacking = True;
               //Number of percentage points to remove
               numHacks = hackValue * 100;
               if (Level.Netmode != NM_Standalone)
                  hackTime = default.hackTime / (hackValue * hackValue);
               TicksPerHack = (hackTime * 10.0) / numHacks;
               LastTickTime = Level.TimeSeconds;
               TicksSinceLastHack = 0;
               SetTimer(0.1, True);
                    msg = msgHacking;
                }
                else
                {
                    bHackIt = True;
                    msg = msgAlreadyHacked;
                }
            }
        }
        else if (hackStrength == 0.0)
        {
            // if it's open
            bHackIt = True;
            msg = "";
        }
    }

    // give the player a message
    if ((Player != None) && (msg != ""))
        Player.ClientMessage(msg);

    // if our hands are empty, call HackAction()
    if ((Player != None) && (frobWith == None))
        HackAction(Frobber, (hackStrength == 0.0));

    // trigger the device!
    if (bHackIt)
        Super.Frob(Frobber, frobWith);
}

defaultproperties
{
     bHackable=True
     hackStrength=0.200000
     HackTime=4.000000
     TimeToReset=28.000000
     msgMultitoolSuccess="You bypassed the device"
     msgNotHacked="It's secure"
     msgHacking="Bypassing the device..."
     msgAlreadyHacked="It's already bypassed"
     Physics=PHYS_None
     bCollideWorld=False
}

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:26.714 - Created with UnCodeX