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

KFMod.ZEDMKIIWeapon


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
//=============================================================================
// ZEDMKIIWeapon
//=============================================================================
// Inventory class for the Zed Gun Mark II Weapon
//=============================================================================
// Killing Floor Source
// Copyright (C) 2013 Tripwire Interactive LLC
// - John "Ramm-Jaeger" Gibson
//=============================================================================
class ZEDMKIIWeapon extends KFWeapon;

var float           EnemyUpdateTime;

var()   sound   AlarmSound;      // An alarm that sounds when big guys get near
var     float   NextAlarmTime;   // The next time this alarm goes off
var     float   LastAlarmTime;   // The last time the alarm went off
var     bool    bAlarmStatus;
var     bool    bOldAlarmStatus;

// LED lights
var() Material LedOnMaterial;
var() Material LedOffMaterial;
// References to led lights
var	string	LedOnMaterialRef;
var	string	LedOffMaterialRef;

replication
{
	reliable if(Role == ROLE_Authority)
		ClientAlarmSound;
}

static function PreloadAssets(Inventory Inv, optional bool bSkipRefCount)
{
	default.LedOnMaterial = Material(DynamicLoadObject(default.LedOnMaterialRef, class'Material', true));
	default.LedOffMaterial = Material(DynamicLoadObject(default.LedOffMaterialRef, class'Material', true));

	if ( ZEDMKIIWeapon(Inv) != none )
	{
	    ZEDMKIIWeapon(Inv).LedOnMaterial = default.LedOnMaterial;
        ZEDMKIIWeapon(Inv).LedOffMaterial = default.LedOffMaterial;
	}

	super.PreloadAssets(Inv, bSkipRefCount);
}

static function bool UnloadAssets()
{
	if ( super.UnloadAssets() )
	{
		default.LedOnMaterial = none;
		default.LedOffMaterial = none;

		return true;
	}

	return false;
}

// Overridden to handle reducing the ammo for the secondary fire
simulated function bool ConsumeAmmo( int Mode, float Load, optional bool bAmountNeededIsMax )
{
	local Inventory Inv;
	local bool bOutOfAmmo;
	local KFWeapon KFWeap;

	if ( Super(Weapon).ConsumeAmmo(Mode, Load, bAmountNeededIsMax) )
	{
		if ( Load > 0 && (Mode == 0 || bReduceMagAmmoOnSecondaryFire) )
			MagAmmoRemaining -= Load;

		NetUpdateTime = Level.TimeSeconds - 1;

		if ( FireMode[Mode].AmmoPerFire > 0 && InventoryGroup > 0 && !bMeleeWeapon && bConsumesPhysicalAmmo &&
			 (Ammo[0] == none || FireMode[0] == none || FireMode[0].AmmoPerFire <= 0 || Ammo[0].AmmoAmount < FireMode[0].AmmoPerFire) &&
			 (Ammo[1] == none || FireMode[1] == none || FireMode[1].AmmoPerFire <= 0 || Ammo[1].AmmoAmount < FireMode[1].AmmoPerFire) )
		{
			bOutOfAmmo = true;

			for ( Inv = Instigator.Inventory; Inv != none; Inv = Inv.Inventory )
			{
				KFWeap = KFWeapon(Inv);

				if ( Inv.InventoryGroup > 0 && KFWeap != none && !KFWeap.bMeleeWeapon && KFWeap.bConsumesPhysicalAmmo &&
					 ((KFWeap.Ammo[0] != none && KFWeap.FireMode[0] != none && KFWeap.FireMode[0].AmmoPerFire > 0 &&KFWeap.Ammo[0].AmmoAmount >= KFWeap.FireMode[0].AmmoPerFire) ||
					 (KFWeap.Ammo[1] != none && KFWeap.FireMode[1] != none && KFWeap.FireMode[1].AmmoPerFire > 0 && KFWeap.Ammo[1].AmmoAmount >= KFWeap.FireMode[1].AmmoPerFire)) )
				{
					bOutOfAmmo = false;
					break;
				}
			}

			if ( bOutOfAmmo )
			{
				PlayerController(Instigator.Controller).Speech('AUTO', 3, "");
			}
		}

		return true;
	}
	return false;
}

// Allow this weapon to auto reload on alt fire
simulated function AltFire(float F)
{
	if( !bIsReloading &&
		 FireMode[1].NextFireTime <= Level.TimeSeconds )
	{
		// We're dry, ask the server to autoreload
		if( MagAmmoRemaining < 1 )
		{
            ServerRequestAutoReload();
            PlayOwnedSound(FireMode[1].NoAmmoSound,SLOT_None,2.0,,,,false);
        }
        else if( MagAmmoRemaining < FireMode[1].AmmoPerFire )
        {
        	PlayOwnedSound(FireMode[1].NoAmmoSound,SLOT_None,2.0,,,,false);
        }
	}

	super.AltFire(F);
}


simulated function WeaponTick(float dt)
{
	local int TeamIndex, i;
	local Pawn EnemyPawn;
	local KFPlayerController KFPC;
	local float MaxThreat, HighestThreatDist;
	local float UsedAlarmTime;

	super.WeaponTick(dt);

	// Update the motion tracker screen
    if ( ROLE == ROLE_Authority && Instigator != none )
	{
		if( EnemyUpdateTime <= 0 )
		{
            EnemyUpdateTime = 0.2;

            TeamIndex = Instigator.GetTeamNum();

        	KFPC = KFPlayerController(Instigator.Controller);
        	if ( KFPC != none  )
            {
        		foreach Instigator.CollidingActors(class'Pawn', EnemyPawn, 1875)
        		{
        			if ( EnemyPawn.Health > 0 && EnemyPawn.GetTeamNum() != TeamIndex )
        			{
                        if( KFMonster(EnemyPawn) != none )
        				{

        				    if( KFMonster(EnemyPawn).MotionDetectorThreat > MaxThreat ||
                                (KFMonster(EnemyPawn).MotionDetectorThreat >= 3.0 && (VSize(EnemyPawn.Location - Instigator.Location) < HighestThreatDist)) )
        				    {
        				        HighestThreatDist = VSize( EnemyPawn.Location - Instigator.Location );
                                MaxThreat = KFMonster(EnemyPawn).MotionDetectorThreat;

        				    }
        				}
        				i+=1;
        			}
        		}

                if( MaxThreat >= 3.0 )
                {
            		UsedAlarmTime = Level.TimeSeconds - NextAlarmTime;

                    if( UsedAlarmTime >= 0 )
            		{
                        if( HighestThreatDist < 500 )
                        {
                            if( MaxThreat >= 5.0 )
                            {
                                NextAlarmTime = Level.TimeSeconds + 0.5;
                            }
                            else
                            {
                                NextAlarmTime = Level.TimeSeconds + 1.0;
                            }
                        }
                        else
                        {
                            NextAlarmTime = Level.TimeSeconds + 2.0;
                        }

                        if( Level.NetMode == NM_DedicatedServer )
                        {
                            ClientAlarmSound();
                        }
                        PlayOwnedSound(AlarmSound,SLOT_None,2.0,,TransientSoundRadius,,false);

                        if( Instigator.IsLocallyControlled() && Level.NetMode != NM_DedicatedServer )
                        {
                            LastAlarmTime = Level.TimeSeconds;
                            bAlarmStatus = true;
                            Skins[1] = LedOnMaterial;
                        }
                    }
                }
    		}
		}
		else
		{
            EnemyUpdateTime -= dt;
		}
	}

	if( bAlarmStatus != bOldAlarmStatus && Instigator.IsLocallyControlled()
        && Level.NetMode != NM_DedicatedServer)
    {
        if( bAlarmStatus && ((Level.TimeSeconds - LastAlarmTime) > 0.2) )
        {
            bAlarmStatus = false;
            bOldAlarmStatus = bAlarmStatus;
            Skins[1] = LedOffMaterial;
        }

    }
}

simulated function ClientAlarmSound()
{
    PlayOwnedSound(AlarmSound,SLOT_None,2.0,,TransientSoundRadius,,false);

    LastAlarmTime = Level.TimeSeconds;
    bAlarmStatus = true;
    Skins[1] = LedOnMaterial;
}

defaultproperties
{
     AlarmSound=Sound'KF_FY_ZEDV2SND.foley.WEP_ZEDV2_Alert'
     LedOnMaterialRef="KF_IJC_Halloween_Weapons2.ZEDV2.ZED_V2_LED_ON_SHDR"
     LedOffMaterialRef="'KF_IJC_Halloween_Weapons2.ZEDV2.ZEDV2_LED"
     MagCapacity=30
     ReloadRate=1.900000
     ReloadAnim="Reload"
     ReloadAnimRate=1.000000
     WeaponReloadAnim="Reload_IJC_ZEDV2"
     Weight=6.000000
     bHasAimingMode=True
     IdleAimAnim="Idle_Iron"
     StandardDisplayFOV=65.000000
     bModeZeroCanDryFire=True
     SleeveNum=3
     TraderInfoTexture=Texture'KF_IJC_HUD.Trader_Weapon_Icons.Trader_ZEDV2'
     bIsTier2Weapon=True
     MeshRef="KF_IJC_Halloween_Weps_2.ZEDV2"
     SkinRefs(0)="KF_IJC_Halloween_Weapons2.ZEDV2.ZEDV2_SHDR"
     SkinRefs(1)="KF_IJC_Halloween_Weapons2.ZEDV2.ZEDV2_LED"
     SkinRefs(2)="KF_IJC_Halloween_Weapons2.ZEDV2.ZEDV2_Sight_SHDR"
     SelectSoundRef="KF_FY_ZEDV2SND.WEP_ZEDV2_Foley_Select"
     HudImageRef="KF_IJC_HUD.WeaponSelect.ZEDV2_unselected"
     SelectedHudImageRef="KF_IJC_HUD.WeaponSelect.ZEDV2"
     AppID=258751
     PlayerIronSightFOV=80.000000
     ZoomedDisplayFOV=45.000000
     FireModeClass(0)=Class'KFMod.ZEDMKIIFire'
     FireModeClass(1)=Class'KFMod.ZEDMKIIAltFire'
     PutDownAnim="PutDown"
     SelectForce="SwitchToAssaultRifle"
     AIRating=0.550000
     CurrentRating=0.550000
     bShowChargingBar=True
     Description="The second revision of the ZED gun. Smaller and more light weight, but not quite as powerful as the original."
     EffectOffset=(X=100.000000,Y=25.000000,Z=-10.000000)
     DisplayFOV=65.000000
     Priority=132
     InventoryGroup=3
     GroupOffset=23
     PickupClass=Class'KFMod.ZEDMKIIPickup'
     PlayerViewOffset=(X=25.000000,Y=20.000000,Z=-2.000000)
     BobDamping=6.000000
     AttachmentClass=Class'KFMod.ZEDMKIIAttachment'
     IconCoords=(X1=245,Y1=39,X2=329,Y2=79)
     ItemName="ZED GUN MKII"
     TransientSoundVolume=1.250000
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fri 13-10-2023 03:17:28.000 - Creation time: Fri 13-10-2023 03:19:11.169 - Created with UnCodeX