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

XWeapons.LinkGun


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
//=============================================================================
// Link Gun
//=============================================================================
class LinkGun extends Weapon
    config(user);

#EXEC OBJ LOAD FILE=InterfaceContent.utx

var() int Links;
var() bool Linking;

replication
{
    unreliable if (Role == ROLE_Authority)
        Linking, Links;
}

simulated function UpdateLinkColor( LinkAttachment.ELinkColor Color )
{
    if ( FireMode[1] != None )
        LinkFire(FireMode[1]).UpdateLinkColor( Color );

    if ( Mesh == OldMesh )  // no support for old mesh
        return;

    switch ( Color )
    {
        case LC_Green   :   Skins[0] = material'LinkgunShader';
                            Skins[1] = material'PowerPulseShader';
                            break;
        case LC_Red     :   Skins[0] = material'LinkgunRedShader';
                            Skins[1] = material'PowerPulseShaderRed';
                            break;
        case LC_Blue    :   Skins[0] = material'LinkgunBlueShader';
                            Skins[1] = material'PowerPulseShaderBlue';
                            break;
        case LC_Gold    :   Skins[0] = material'LinkgunYellowShader';
                            Skins[1] = material'PowerPulseShaderYellow';
                            break;
    }
}

simulated function bool HasAmmo()
{
    return ( AmmoClass[0] != None && FireMode[0] != None && AmmoCharge[0] >= 1 );
}

simulated event RenderOverlays( Canvas Canvas )
{
    if ( (FireMode[1] != None) && !FireMode[1].bIsFiring && (ThirdPersonActor != None) )
    {
        if ( Links > 0 )
            LinkAttachment(ThirdPersonActor).SetLinkColor( LC_Gold );
        else
            LinkAttachment(ThirdPersonActor).SetLinkColor( LC_Green );
    }
    super.RenderOverlays( Canvas );
}

simulated function vector GetEffectStart()
{
    local Vector X,Y,Z, Offset;
    local float Extra;

    // 1st person
    if ( Instigator.IsFirstPerson() )
    {
        if ( WeaponCentered() )
            return CenteredEffectStart();

        GetViewAxes(X, Y, Z);
        if ( class'PlayerController'.Default.bSmallWeapons )
            Offset = SmallEffectOffset;
        else
            Offset = EffectOffset;

        if ( Hand == 0 )
        {
            if ( bUseOldWeaponMesh )
                Offset.Z -= 10;
            else
                Offset.Z -= 14;
            Extra = 3;
        }
        else if ( !bUseOldWeaponMesh )
            Offset.Z -= 10;

        return (Instigator.Location +
                Instigator.CalcDrawOffset(self) +
                Offset.X * X  +
                (Offset.Y * Hand + Extra) * Y +
                Offset.Z * Z);
    }
    // 3rd person
    else
    {
        return (Instigator.Location +
            Instigator.EyeHeight*Vect(0,0,0.5) +
            Vector(Instigator.Rotation) * 40.0);
    }
}

simulated function Destroyed()
{
    if (Role == ROLE_Authority)
    {
        if ( LinkFire(FireMode[1]) != None )
            LinkFire(FireMode[1]).SetLinkTo(None);
    }
    Super.Destroyed();
}

simulated function bool StartFire(int Mode)
{
    local SquadAI S;
    local Bot B;
    local vector AimDir;

    if ( (Role == ROLE_Authority) && (PlayerController(Instigator.Controller) != None) && (UnrealTeamInfo(Instigator.PlayerReplicationInfo.Team) != None))
    {
        S = UnrealTeamInfo(Instigator.PlayerReplicationInfo.Team).AI.GetSquadLedBy(Instigator.Controller);
        if ( S != None )
        {
            AimDir = vector(Instigator.Controller.Rotation);
            for ( B=S.SquadMembers; B!=None; B=B.NextSquadMember )
                if ( (HoldSpot(B.GoalScript) == None)
                    && (B.Pawn != None)
                    && (LinkGun(B.Pawn.Weapon) != None)
                    && B.Pawn.Weapon.FocusOnLeader(true)
                    && ((AimDir dot Normal(B.Pawn.Location - Instigator.Location)) < 0.9) )
                {
                    B.Focus = Instigator;
                    B.FireWeaponAt(Instigator);
                }
        }
    }
    return Super.StartFire(Mode);
}

// AI Interface
function bool FocusOnLeader(bool bLeaderFiring)
{
    local Bot B;
    local Pawn LeaderPawn;
    local Actor Other;
    local vector HitLocation, HitNormal, StartTrace;
    local Vehicle V;

    B = Bot(Instigator.Controller);
    if ( B == None )
        return false;
    if ( PlayerController(B.Squad.SquadLeader) != None )
        LeaderPawn = B.Squad.SquadLeader.Pawn;
    else
    {
        V = B.Squad.GetLinkVehicle(B);
        if ( V != None )
        {
            LeaderPawn = V;
            bLeaderFiring = (LeaderPawn.Health < LeaderPawn.HealthMax) && (V.LinkHealMult > 0)
                            && ((B.Enemy == None) || V.bKeyVehicle);
        }
    }
    if ( LeaderPawn == None )
    {
        LeaderPawn = B.Squad.SquadLeader.Pawn;
        if ( LeaderPawn == None )
            return false;
    }
    if ( !bLeaderFiring && (LeaderPawn.Weapon == None || !LeaderPawn.Weapon.IsFiring()) )
        return false;
    if ( (Vehicle(LeaderPawn) != None)
        || ((LinkGun(LeaderPawn.Weapon) != None) && ((vector(B.Squad.SquadLeader.Rotation) dot Normal(Instigator.Location - LeaderPawn.Location)) < 0.9)) )
    {
        StartTrace = Instigator.Location + Instigator.EyePosition();
        if ( VSize(LeaderPawn.Location - StartTrace) < LinkFire(FireMode[1]).TraceRange )
        {
            Other = Trace(HitLocation, HitNormal, LeaderPawn.Location, StartTrace, true);
            if ( Other == LeaderPawn )
            {
                B.Focus = Other;
                return true;
            }
        }
    }
    return false;
}

function float GetAIRating()
{
    local Bot B;
    local DestroyableObjective O;
    local Vehicle V;

    B = Bot(Instigator.Controller);
    if ( B == None )
        return AIRating;

    if ( (PlayerController(B.Squad.SquadLeader) != None)
        && (B.Squad.SquadLeader.Pawn != None)
        && (LinkGun(B.Squad.SquadLeader.Pawn.Weapon) != None) )
        return 1.2;

    V = B.Squad.GetLinkVehicle(B);
    if ( (V != None)
        && (VSize(Instigator.Location - V.Location) < 1.5 * LinkFire(FireMode[1]).TraceRange)
        && (V.Health < V.HealthMax) && (V.LinkHealMult > 0) )
        return 1.2;

    if ( Vehicle(B.RouteGoal) != None && B.Enemy == None && VSize(Instigator.Location - B.RouteGoal.Location) < 1.5 * LinkFire(FireMode[1]).TraceRange
         && Vehicle(B.RouteGoal).TeamLink(B.GetTeamNum()) )
        return 1.2;

    O = DestroyableObjective(B.Squad.SquadObjective);
    if ( O != None && B.Enemy == None && O.TeamLink(B.GetTeamNum()) && O.Health < O.DamageCapacity
         && VSize(Instigator.Location - O.Location) < 1.1 * LinkFire(FireMode[1]).TraceRange && B.LineOfSightTo(O) )
        return 1.2;

    return AIRating * FMin(Pawn(Owner).DamageScaling, 1.5);
}

/* BestMode()
choose between regular or alt-fire
*/
function byte BestMode()
{
    local float EnemyDist;
    local bot B;
    local Vehicle V;

    B = Bot(Instigator.Controller);
    if ( B == None )
        return 0;

    if ( ( (DestroyableObjective(B.Squad.SquadObjective) != None && B.Squad.SquadObjective.TeamLink(B.GetTeamNum()))
        || (B.Squad.SquadObjective == None && DestroyableObjective(B.Target) != None && B.Target.TeamLink(B.GetTeamNum())) )
         && VSize(B.Squad.SquadObjective.Location - B.Pawn.Location) < FireMode[1].MaxRange() && (B.Enemy == None || !B.EnemyVisible()) )
        return 1;
    if ( FocusOnLeader(B.Focus == B.Squad.SquadLeader.Pawn) )
        return 1;

    V = B.Squad.GetLinkVehicle(B);
    if ( V == None )
        V = Vehicle(B.MoveTarget);
    if ( V == B.Target )
        return 1;
    if ( (V != None) && (VSize(Instigator.Location - V.Location) < LinkFire(FireMode[1]).TraceRange)
        && (V.Health < V.HealthMax) && (V.LinkHealMult > 0) && B.LineOfSightTo(V) )
        return 1;
    if ( B.Enemy == None )
        return 0;
    EnemyDist = VSize(B.Enemy.Location - Instigator.Location);
    if ( EnemyDist > LinkFire(FireMode[1]).TraceRange )
        return 0;
    return 1;
}

function float SuggestAttackStyle()
{
    return 0.8;
}

function float SuggestDefenseStyle()
{
    return -0.4;
}

function bool CanHeal(Actor Other)
{
    if (DestroyableObjective(Other) != None && DestroyableObjective(Other).LinkHealMult > 0)
        return true;
    if (Vehicle(Other) != None && Vehicle(Other).LinkHealMult > 0)
        return true;

    return false;
}

// End AI Interface

function bool LinkedTo(LinkGun L)
{
    local Pawn Other;
    local LinkGun OtherWeapon, Head;
    local int sanity;

    Head = self;
    while (Head != None && Head.Linking && sanity < 20)
    {
            Other = LinkFire(Head.FireMode[1]).LockedPawn;
            if (Other == None)
                return false;
            else
            {
                OtherWeapon = LinkGun(Other.Weapon);
                if (OtherWeapon == None)
                    return false;
                else
                    Head = OtherWeapon;
            }
            if (Head == L)
                return true;

            sanity++;
        }

        return false;
}

function bool ConsumeAmmo(int Mode, float load, optional bool bAmountNeededIsMax)
{
    local Controller C;

    if (Linking && LinkFire(FireMode[1]).LockedPawn != None && Vehicle(LinkFire(FireMode[1]).LockedPawn) == None)
        return true;

    if ( mode == 0 )
        bAmountNeededIsMax = true;

    //use ammo from linking teammates
    if (Instigator != None && Instigator.PlayerReplicationInfo != None && Instigator.PlayerReplicationInfo.Team != None)
    {
        for (C = Level.ControllerList; C != None; C = C.NextController)
            if (C.Pawn != None && LinkGun(C.Pawn.Weapon) != None && LinkGun(C.Pawn.Weapon).LinkedTo(self))
                LinkGun(C.Pawn.Weapon).LinkedConsumeAmmo(Mode, load, bAmountNeededIsMax);
    }

    return Super.ConsumeAmmo(Mode, load, bAmountNeededIsMax);
}

function bool LinkedConsumeAmmo(int Mode, float load, optional bool bAmountNeededIsMax)
{
    if ( mode == 0 )
        bAmountNeededIsMax = true;

    return Super.ConsumeAmmo(Mode, load, bAmountNeededIsMax);
}

simulated function IncrementFlashCount(int mode)
{
    Super.IncrementFlashCount(mode);
    if ( LinkAttachment(ThirdPersonActor) != None )
        LinkAttachment(ThirdPersonActor).Links = Links;
}

simulated function bool PutDown()
{
    LinkFire(FireMode[1]).SetLinkTo(None);
    Links = 0;
    return Super.PutDown();
}

simulated function BringUp(optional Weapon PrevWeapon)
{
    Links = 0;
    Super.BringUp(PrevWeapon);
}

// jdf ---
simulated event WeaponTick(float dt)
{
    local PlayerController PC;
    local LinkFire LF;

    PC = PlayerController(Instigator.Controller);
    LF = LinkFire(FireMode[1]);

    if (PC != None && LF != None)
    {
        if (Links > 0 && !LF.bLinkFeedbackPlaying)
        {
            LF.bLinkFeedbackPlaying = true;
            PC.ClientPlayForceFeedback(LF.MakeLinkForce);
            if (!LF.bIsFiring)
                PC.ClientPlayForceFeedback("BLinkGunBeam1");
        }
        else if (Links <= 0 && LF.bLinkFeedbackPlaying)
        {
            LF.bLinkFeedbackPlaying = false;
            PC.StopForceFeedback("BLinkGunBeam1");
        }
    }
}
// --- jdf

defaultproperties
{
     FireModeClass(0)=Class'XWeapons.LinkAltFire'
     FireModeClass(1)=Class'XWeapons.LinkFire'
     PutDownAnim="PutDown"
     IdleAnimRate=0.030000
     SelectSound=Sound'NewWeaponSounds.NewLinkSelect'
     SelectForce="SwitchToLinkGun"
     AIRating=0.680000
     CurrentRating=0.680000
     bMatchWeapons=Wahr
     OldMesh=SkeletalMesh'Weapons.LinkGun_1st'
     OldPickup="WeaponStaticMesh.LinkGunPickup"
     OldCenteredOffsetY=-12.000000
     OldPlayerViewOffset=(X=-2.000000,Y=-2.000000,Z=-3.000000)
     OldSmallViewOffset=(X=10.000000,Y=4.000000,Z=-9.000000)
     OldPlayerViewPivot=(Yaw=500)
     OldCenteredRoll=3000
     OldCenteredYaw=-300
     Description="Riordan Dynamic Weapon Systems combines the best of weapon design in the Advanced Plasma Rifle v23, commonly known as the Link Gun.|While the primary firing mode of the Link remains the same as its plasma-firing predecessor, the secondary cutting torch has been replaced with a switchable energy matrix. Upon contacting a teammate, it converts to a harmless carrier stream, offloading energy from the onboard cells to boost the output of any targeted player also using the Link.|It should be noted that while players are boosting a teammate, they are unable to defend themselves from attack."
     EffectOffset=(X=100.000000,Y=25.000000,Z=-3.000000)
     DisplayFOV=60.000000
     Priority=7
     HudColor=(B=128,R=128)
     SmallViewOffset=(X=2.000000,Z=-1.500000)
     CenteredOffsetY=-5.000000
     CenteredRoll=3000
     CenteredYaw=-1000
     CustomCrosshair=10
     CustomCrossHairColor=(B=128,R=128)
     CustomCrossHairTextureName="Crosshairs.Hud.Crosshair_Bracket1"
     InventoryGroup=5
     PickupClass=Class'XWeapons.LinkGunPickup'
     PlayerViewOffset=(X=-5.000000,Y=-3.000000)
     PlayerViewPivot=(Yaw=500)
     BobDamping=1.575000
     AttachmentClass=Class'XWeapons.LinkAttachment'
     IconMaterial=Texture'HUDContent.Generic.HUD'
     IconCoords=(X1=169,Y1=78,X2=244,Y2=124)
     ItemName="Link Gun"
     Mesh=SkeletalMesh'NewWeapons2004.FatLinkGun'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fr 30.3.2007 08:43:44.000 - Creation time: Mo 16.4.2007 11:20:49.437 - Created with UnCodeX