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

U2XMP.DeployableInventory


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
//=============================================================================
// $Workfile: DeployableInventory.uc $
// Created By: Mark Poesch
// Created On: 6/30/2001
// $Author: Mfox $
// $Date: 12/13/02 2:32a $
// $Revision: 29 $
//=============================================================================
class DeployableInventory extends U2XMPItem
	abstract;

#exec OBJ LOAD File=..\Sounds\U2XMPA.uax

const DeployHeight = 32;
const DeployBuffer = 1;

var class<DeployedUnit> DeployClass;
var sound DeployFailedSound;
var float MaxDeployDistance;
var travel array<int> ItemHealthArray;	// Array containing the health of all XMP components in inventory

var string XMPIcon;

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

simulated function SetCrosshair()
{
	Super.SetCrosshair();
	class'UIConsole'.static.SendEvent("XMPTrayShow");
	class'UIConsole'.static.SendEvent("XMPShow"$XMPIcon);
}

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

simulated function UnSetCrosshair()
{
	if(~Crosshair)
		class'UIConsole'.static.SendEvent("XMPTrayHide");
	Super.UnSetCrosshair();
}

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

function bool ActivateUnit( bool bAltActivate )
{
	local bool bDeploySuccess;

	if( CanDeploy() )
	{
		bDeploySuccess = Deploy( bAltActivate);
		if( bDeploySuccess )
			return true;
		else
		{
			Owner.PlaySound( DeployFailedSound, SLOT_None );
			return false;
		}
	}
	else
	{
		Owner.PlaySound( DeployFailedSound, SLOT_None );
		//DM( "&&& Deployment of " $ Self $ " FAILED" );
		return false;
	}
}

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

function TransferSpecialProperties()
{
	ItemHealthArray.Insert(0,1);
	ItemHealthArray[0] = DeployClass.default.Health;
	//DM( "*** Receiving " $ Self $ " ***" );
	//OutputItemArray();
}

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

function UpdateInventoryHealth( int Health )
{
	local int i;

	ItemHealthArray.Remove(0,1);
	i = 0;
	while( i < ItemHealthArray.Length && ItemHealthArray[ i ] > Health )
		i++;
	ItemHealthArray.Insert(i,1);
	ItemHealthArray[i] = Health;
	//DM( "*** Receiving " $ Self $ " ***" );
	//OutputItemArray();
}

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

function OutputItemArray()
{
	local int i;

	DM( "*** " $ Self $ " - ItemHealthArray.Length = " $ ItemHealthArray.Length );
	for( i=0;i<ItemHealthArray.Length;i++ )
		DM( "  *** ItemHealthArray[ " $ i $ " ] = " $ ItemHealthArray[ i ] );
}

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

function bool CanDeploy()
{
	return true;
}

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

function bool Deploy( bool bAltActivate )
{
	local rotator Rot;
	local vector X, Y, Z;
	local vector Loc, EndTrace, Extents, HitLocation, HitNormal;
	local DeployedUnit A;
	local Actor HitActor;

	Rot = Owner.Rotation;
	Rot.Pitch = 0;
	GetAxes( Rot, X, Y, Z );
	Loc = Owner.Location + ( DeployBuffer + Owner.CollisionRadius + DeployClass.default.CollisionRadius ) * X + DeployHeight * Z;
	EndTrace = Loc;
	EndTrace.Z -= Owner.CollisionHeight+DeployHeight+MaxDeployDistance;
	Extents.X = DeployClass.default.CollisionRadius;
	Extents.Y = DeployClass.default.CollisionRadius;
	Extents.Z = DeployClass.default.CollisionHeight;

	//AddArrow( Loc, EndTrace, ColorGreen() );
	//!!SBB (mdf) this is causing placing XMP items to fail if there is a carcass
	// or Pawn in the way? Ideally, carcasses shouldn't block XMP items (they are
	// non-blocking -- I'd just allow it to be dropped in the middle of the 
	// carcass). Also, it would probably be good to allow these to be dropped if
	// there is a (live) Pawn in the way, allowing the Pawn to walk out of the
	// item since this could otherwise break scripted sequences.
	HitActor = Trace( HitLocation, HitNormal, EndTrace, Loc, true, Extents, , TRACE_ProjTargets | TRACE_Hash );
	//DM( "$$$ " $ Self $ " HitActor = " $ HitActor $ " HitActor.bWorldGeometry = " $ HitActor.bWorldGeometry $ " bBlockActors = " $ HitActor.bBlockActors );
	if( HitActor != None && HitLocation.Z >= EndTrace.Z )
	{
		//DM( "  &&& " $ Self $ " UnderScriptControl = " $ U2NPCController(Pawn(Owner).Controller).UnderScriptControl() );
		if( HitActor.bWorldGeometry )
			A = Spawn( DeployClass, , , Loc, Rot );
//		else if( U2NPCController(Pawn(Owner).Controller).UnderScriptControl()&& Pawn(Owner).SameTeam( Pawn(HitActor) ) )
//			A = Spawn( DeployClass, , , Loc, Rot );
	}
	else
		return false;

	if( A == None )
	{
		//DM( "&&& " $ Self $ " could not be spawned." );
		return false;
	}
	
	// if the spawn succeeds, complete the deployment
	A.SetActive( false );
	A.SetPhysics( PHYS_Falling );
	UpdateDeployedActor( A );
	A.Initialize( bAltActivate );
	return true;
}

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

function UpdateDeployedActor( DeployedUnit A )
{
	local int i;

	assert( Pawn(Owner) != None );
	A.SetTeam( Pawn(Owner).GetTeam() );
	A.bFriendlyToPlayerTeam = Pawn(Owner).bFriendlyToPlayerTeam;
	// Apply health from list
	if( ItemHealthArray[0] != 0 )
	{
		//DM( "*** AmmoAmount = " $ AmmoType.AmmoAmount $ " HealthArray Length = " $ ItemHealthArray.Length );
		if( AmmoType.AmmoAmount != ItemHealthArray.Length 
			|| ( Level.Game.GetInfiniteAmmo() || Pawn(Owner).GetInfiniteAmmo() ) )
		{
			if( !Pawn(Owner).IsNPC() )
				log( "Cheats Active on " $ Owner $ ", XMP units will not track health." );
			A.Health = A.default.Health;
		}
		else
		{
			A.Health = ItemHealthArray[0];
			ItemHealthArray.Remove(0,1);
		}
	}
	else
		A.Health = A.default.Health;
	//DM( "*** Placing " $ Self $ " ***" );
	//OutputItemArray();
}

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

defaultproperties
{
	DeployFailedSound=Sound'U2XMPA.XMPUnit.DeployFailed'
	MaxDeployDistance=60.000000
	XMPIcon="Default"
	bActivatable=true
     GunButtSounds(0)=Sound'U2WeaponsA.GunButt.GunButt01'
     GunButtSounds(1)=Sound'U2WeaponsA.GunButt.GunButt02'
     GunButtSounds(2)=Sound'U2WeaponsA.GunButt.GunButt03'
     GunButtSounds(3)=Sound'U2WeaponsA.GunButt.GunButt04'
     TargetableTypes(0)='Pawn'
	CrosshairName="XMP_Cross"
	bMergesCopies=true
     UseReticleOnEvents(0)="UseReticleText"
     UseReticleOnEvents(1)="UseReticleCorners"
     UseReticleOnEvents(2)="UseReticleTopBars"
     ProximityReticleOnEvents(0)="ProximityReticleCorners"
     ProximityReticleOnEvents(1)="ProximityReticleTopBars"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: sk 3-1-2016 10:38:44.000 - Creation time: sk 3-1-2016 10:48:38.109 - Created with UnCodeX