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

UTGame.UTDeployable


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
/**
 *
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */
class UTDeployable extends UTWeapon
	abstract
	native;

/** the factory that spawned this deployable */
var UTDeployablePickupFactory Factory;

/** class of deployable actor to spawn */
var class<UTDeployedActor> DeployedActorClass;

/** Toss strength when throwing out deployable */
var float TossMag;

/** Scale for deployable when being scaled for a preview in a stealth vehicle*/
var float PreviewScale;

/** if true, factory delays respawn countdown until this deployable is used */
var bool bDelayRespawn;

/** Radius to check against for other deployables nearby*/
var() float DeployCheckRadiusSq;

var SoundCue DeployFailedSoundCue;

function bool DenyPickupQuery(class<Inventory> ItemClass, Actor Pickup)
{
	// players can only carry one deployable at a time
	return ClassIsChildOf(ItemClass, class'UTDeployable');
}

static function InitPickupMesh(PrimitiveComponent InMesh);

static function float BotDesireability(Actor PickupHolder, Pawn P, Controller C)
{
	return (UTDeployable(P.Weapon) != None) ? -1.0 : Super.BotDesireability(PickupHolder, P, C);
}

static function class<Actor> GetTeamDeployable(int TeamNum)
{
	return default.DeployedActorClass;
}

/** Recommend an objective for player carrying this deployable */
function UTGameObjective RecommendObjective(Controller C)
{
	return None;
}

simulated function vector GetPhysicalFireStartLoc(optional vector AimDir)
{
	return (Instigator != none) ? (Instigator.GetPawnViewLocation() + (FireOffset >> Instigator.GetViewRotation())) : Location;
}


//Given an actor, its position and a radius determine if we are near any deployables
static function bool DeployablesNearby(Actor MyActor, vector MyLocation, float CheckRadiusSq)
{
	local float DistSqr;
	local UTDeployedActor DeployedActor;
	local UTSlowVolume SlowVolume;

	if ( MyActor.Instigator == None )
	{
		return true;
	}

	//Check the area for deployables
	foreach MyActor.DynamicActors(class'UTDeployedActor', DeployedActor)
	{
		if ( MyActor.WorldInfo.GRI.OnSameTeam(MyActor.Instigator, DeployedActor) )
		{
			DistSqr = VSizeSq(DeployedActor.Location - MyLocation);
			if (DistSqr < CheckRadiusSq)
			{
				return TRUE;
			}
		}
	}

	//Check for slow volumes too (they don't derive from the same hierarchy)
	foreach MyActor.DynamicActors(class'UTSlowVolume', SlowVolume)
	{
		DistSqr = VSizeSq(SlowVolume.Location - MyLocation);
		if (DistSqr < CheckRadiusSq)
		{
			return TRUE;
		}
	}

	return FALSE;
}

/** attempts to deploy the item
 * @return whether or not deploying was successful
 */
function bool Deploy()
{
	local UTDeployedActor DeployedActor;
	local vector SpawnLocation;
	local rotator Aim, FlatAim;

	SpawnLocation = GetPhysicalFireStartLoc();
	Aim = GetAdjustedAim(SpawnLocation);
	FlatAim.Yaw = Aim.Yaw;

	DeployedActor = Spawn(DeployedActorClass, self,, SpawnLocation, FlatAim);
	if (DeployedActor != None)
	{
		if ( AmmoCount <= 0 )
		{
			if ( Factory != None )
			{
				DeployedActor.OnDeployableUsedUp = Factory.DeployableUsed;
			}
			bForceHidden = true;
			Mesh.SetHidden(true);
		}
		DeployedActor.Velocity = TossMag * vector(Aim);
		return true;
	}

	return false;
}

/** called when User tries to deploy us and fails for some reason */
function DeployFailed(optional bool bDeployablesAreNearby=false)
{
	// refund ammo
	AddAmmo(ShotCost[CurrentFireMode]);
	// call client version
	ClientDeployFailed(bDeployablesAreNearby);
}

/** called to notify client of deploy failure */
reliable client function ClientDeployFailed(bool bDeployablesAreNearby)
{
	if (DeployFailedSoundCue != None)
	{
		Instigator.PlaySound(DeployFailedSoundCue);
	}

	if (bDeployablesAreNearby)
	{
		//This is the message "unable to deploy due to close proximity"
		Instigator.ReceiveLocalizedMessage(class'UTStealthVehicleMessage', 2);
	}
	else
	{
		//This is the message "Can't deploy here"
		Instigator.ReceiveLocalizedMessage(class'UTDeployableMessage', 0);
	}
}

simulated function CustomFire()
{
	local bool bAreDeployablesNearby;

	//Deployable radius check here so UTSlowVolume uses it too
	if (Role == ROLE_Authority)
	{
		bAreDeployablesNearby = DeployablesNearby(self, GetPhysicalFireStartLoc(), DeployCheckRadiusSq);
		if (bAreDeployablesNearby)
		{
			DeployFailed(bAreDeployablesNearby);
		}
		else if (!Deploy())
		{
			DeployFailed();
		}
	}
}

/*
 * no crosshair for deployable
 */
simulated function DrawWeaponCrosshair( Hud HUD )
{
}

simulated event Destroyed()
{
	// make sure client finishes any in-progress switch away from this weapon
	if (Instigator != None && Instigator.Weapon == self && InvManager != None && InvManager.PendingWeapon != None)
	{
		Instigator.InvManager.ChangedWeapon();
	}

	if (Role == ROLE_Authority && AmmoCount > 0 && Factory != None)
	{
		Factory.DeployableUsed(self);
	}

	Super.Destroyed();
}

/** called from bot's decision logic while this deployable is its Weapon
 * @return whether bot should deploy us right now
 */
function bool ShouldDeploy(UTBot B)
{
	return B.IsRetreating();
}

function float GetAIRating()
{
	// force AI to switch to it like humans are
	return 10;
}

simulated function float MaxRange()
{
	return 200.0;
}

function bool CanAttack(Actor Other)
{
	if (Instigator == None || Instigator.Controller == None)
	{
		return false;
	}

	// check that target is within range
	if (VSize(Instigator.Location - Other.Location) > MaxRange())
	{
		return false;
	}

	// check that can see target
	return Instigator.Controller.LineOfSightTo(Other);
}

simulated function bool AllowSwitchTo(Weapon NewWeapon)
{
	return ( (AmmoCount <= 0 || (UTInventoryManager(InvManager) != None && UTInventoryManager(InvManager).bInfiniteAmmo))
		&& Super.AllowSwitchTo(NewWeapon) );
}

reliable client function ClientWeaponSet(bool bOptionalSet)
{
	// force switch to deployables so you can't switch away from them until they're used
	Super.ClientWeaponSet(false);
}

auto state Inactive
{
	simulated function BeginState(name PreviousStateName)
	{
		Super.BeginState(PreviousStateName);

		// destroy if we're out of ammo, so the player can pick up a different deployable
		if (Role == ROLE_Authority && !HasAnyAmmo())
		{
			Destroy();
		}
	}
}

/**
 * State WeaponEquipping
 * The Weapon is in this state while transitioning from Inactive to Active state.
 * Typically, the weapon will remain in this state while its selection animation is being played.
 * While in this state, the weapon cannot be fired.
 */
simulated state WeaponEquipping
{
	simulated function WeaponEquipped()
	{
		local UTPlayerController PC;

		super.WeaponEquipped();

		if ( Role == ROLE_Authority )
		{
			PC = UTPlayerController(Instigator.Controller);
			if ( PC != None )
			{
				 PC.CheckAutoObjective(true);
			}
		}
	}
}

defaultproperties
{
   TossMag=500.000000
   PreviewScale=1.000000
   bDelayRespawn=True
   DeployCheckRadiusSq=1440000.000000
   bExportMenuData=False
   AmmoCount=1
   IconCoordinates=(U=453.000000,V=327.000000,UL=135.000000,VL=57.000000)
   InventoryGroup=11
   NeedToPickUpAnnouncement=(AnnouncementText="Grab the deployable.")
   WeaponFireTypes(0)=EWFT_Custom
   WeaponFireTypes(1)=EWFT_None
   FireInterval(0)=0.250000
   FireInterval(1)=0.250000
   Begin Object Class=UTSkeletalMeshComponent Name=FirstPersonMesh ObjName=FirstPersonMesh Archetype=UTSkeletalMeshComponent'UTGame.Default__UTWeapon:FirstPersonMesh'
      ObjectArchetype=UTSkeletalMeshComponent'UTGame.Default__UTWeapon:FirstPersonMesh'
   End Object
   Mesh=FirstPersonMesh
   AIRating=0.600000
   Begin Object Class=SkeletalMeshComponent Name=PickupMesh ObjName=PickupMesh Archetype=SkeletalMeshComponent'UTGame.Default__UTWeapon:PickupMesh'
      ObjectArchetype=SkeletalMeshComponent'UTGame.Default__UTWeapon:PickupMesh'
   End Object
   DroppedPickupMesh=PickupMesh
   PickupFactoryMesh=PickupMesh
   Name="Default__UTDeployable"
   ObjectArchetype=UTWeapon'UTGame.Default__UTWeapon'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: tr 31-1-2018 17:18:20.000 - Creation time: sk 18-3-2018 10:01:19.562 - Created with UnCodeX