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

U2.PowerSuit


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
//=============================================================================
// PowerSuit.uc
//=============================================================================

class PowerSuit extends Armor;

#exec OBJ LOAD File=..\System\ParticleRes\Impact_Metal_AR.u //!SBB: Placeholder until we get real powersuit effects
#exec OBJ LOAD FILE=..\Sounds\U2A.uax

var() class<DamageFilter> DamageFilterClass;

var() float MaxPower;						// The Maximum level of the PowerSuit energy holding capacity
var() travel float Power;					// The current energy level of the PowerSuit
var() ParticleGenerator ParticleEffect;		// The effect to spawn when an impact happens
var   travel float DamageResidue;			// Holds the fractional damage not dealt to the player immediately
var bool bProhibitPickups;					// if true powersuit can't be replaced by another one (pickup)
var() Sound	PowerSuitHitSound;

var float PowerSuitHitVolume;

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

event Replication()
{
	Super.Replication();
	DOREP('Power');
}

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

event PreBeginPlay()
{
	local class<PowerSuitPickup> PSPClass;

	Super.PreBeginPlay();
	
	PSPClass = class<PowerSuitPickup>(PickupClass);

	if( PSPClass != None )
	{
		MaxPower = class<PowerSuitPickup>(PickupClass).default.MaxPower;
		Power = class<PowerSuitPickup>(PickupClass).default.Power;
	}
}

//-----------------------------------------------------------------------------
// Now that the player has lost the PowerSuit, reset UnderWaterTime back to default.

event Destroyed()
{
	// if PowerSuit is not held, there will be no owner to reset
	if( Pawn(Owner) != None )
		Pawn(Owner).UnderWaterTime = Pawn(Owner).default.UnderWaterTime;
//	DM( "UnderWaterTime="$Pawn(Owner).UnderWaterTime );

	Super.Destroyed();
}

//-----------------------------------------------------------------------------
// Checks to see if the player already has one of these items in his
// inventory, if he does, the new item is only picked up if it is a better
// PowerSuit (higher MaxPower).

// FYI: False means good to pickup, true means do not pickup

function bool HandlePickupQuery( Pickup item )
{
	//!!mdf-tbd: ClassIsChildOf( class, class'PowerSuit' ) is always going to be true no?
	//if( ClassIsChildOf( item.InventoryType, class'PowerSuit' ) && ClassIsChildOf( class, class'PowerSuit' ) )
	if( ClassIsChildOf( item.InventoryType, class'PowerSuit' ) )
	{
		// NOTE (mb) currently unused. Commented out to remove dependency on jump pack assets
		//if( U2JumpPackPickup(item) != None )
		//	return false;

		if( bProhibitPickups )
			return true;
			
		if( PowerSuitPickup(item).MaxPower > MaxPower )
		{
			Destroy();
			return false;
		}
		
		return true;
	}
	else
	{
		if( Inventory == None )
		{
			return false;
		}
	}
	return Inventory.HandlePickupQuery( item );
}

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

function TransferProperties( Pickup PickedUpItem )
{
	local PowerSuitPickup P;

	P = PowerSuitPickup(PickedUpItem);

	MaxPower    = P.MaxPower;
	Power		= P.Power;
}

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

function TransferPropertiesTo( Pickup PickedUpItem )
{
	local PowerSuitPickup P;

	P = PowerSuitPickup(PickedUpItem);

	P.MaxPower  = MaxPower;
	P.Power		= Power;
}

//-----------------------------------------------------------------------------
// Could be used for HUD indicators.
// I am not real sure if health indicators should be handled here since this is
// the PowerSuit, not the Pawn.
// ARL/SBB: I'm not sure if this will be the place to handle PowerSuit effects, so it's here in case.

function DisplayDamageTaken( int PSDamage, int HealthDamage, vector Location )
{
	local ParticleGenerator Particles;

	// Visual hit effect
	// PWC 2002.08.20 Commenting this out because damage effects should really be displayed by impact handlers.  
	//                The way it is implemented here was also leaving active particle generators unattached to the Pawn
/*	if( PSDamage > 0 && ParticleEffect != None )
	{
		Particles = class'ParticleGenerator'.static.CreateNew( Owner, ParticleEffect, Location );
//		Particles.SetRotation( rotator(Hit.Normal) );
		Particles.Trigger( Owner, Owner.Instigator );
		Particles.ParticleLifeSpan = Particles.GetMaxLifeSpan() + Particles.TimerDuration;
	}
*/
	if( PSDamage > 0 && Pawn(Owner)? && Pawn(Owner).IsRealPlayer() )
	{
		class'UIConsole'.static.SendEvent("ShieldFlash");
		Pawn(Owner).PlaySound( PowerSuitHitSound, SLOT_None, PowerSuitHitVolume );
	}

	// HUD indicators
	/*
	if( HealthDamage > 0 )
	{
	}
	*/
}

/*-----------------------------------------------------------------------------
Determines the amount of damage to be dealt to the PowerSuit, applies that
damage and returns all carryover damage and health damage.

NOTE (mdf): the current design has the current power level of the suit applying
to the *entire* amount of damage that comes in. This means that if you have a
suit at 100%, all damage will go to the power suit (up to the MaxPower for the
suit) whereas if you take the same amount of damage across multiple calls to
this function (possibly in the same tick), less, possibly much less damage will 
go to the suit.

We may not change this design, but if we decide this is confusing / strange, 2
possible solutions:

1: track damage over, say, 0.25 secs and have the suit able to absorb a certain
amount of damage over that time. If that level is exceeeded, the "overflow" goes
to the Pawn.

2: determine a function for applying damage continuously instead of discretely
so that for a call to this function with Damage > 1, the power suit will be
increasingly degraded for each unit of damage.

I haven't nailed this down, but the basic idea is that, if the suit is currently
at Power = X, and N units of damage come in, the damage to the suit is

	X/MaxPower + (X-(X/MaxPower))/MaxPower  + (X-(X-(X/MaxPower))/MaxPower)/MaxPower etc.
	
=

	X/MaxPower + (X-(X/MaxPower))/MaxPower  + (X-(X-(X/MaxPower))/MaxPower)/MaxPower etc.

=

	SUM(1..N) (X - Damage(i-1)) / MaxPower
	
(get out calculus text...)
*/

// DamageType specific ratios:
// 0=all health, 0.25=armor piercing, 0.5=normal armor calculation(default), 1=armor only(emp).

function int ArmorAbsorbDamage( int DamageInt, class<DamageType> DamageType, vector HitLocation )
{
	local float ReturnedDamage;
	local float ReturnedDamageInt;
	local float Pct,D;
	local vector Momentum; // used as stub for DamageFilter.ApplyFilter() momentum parameter

	local float OldPower;
	local int ArmorDamageInt;
	local float ArmorDamage;
	local float OldArmorDamage;
	local float Damage;

	OldPower = Power;
	Damage = DamageInt; //made Damage a float for greater precision
	//PWC 2002.10.22 Some particle effects were coming in with no damage type, so we now check for that
	// and if that's the case give it the default DamageType
	if (DamageType == None) DamageType=class'DamageType';
	// Pre-damage for armor.
	if( DamageType.default.ArmorHealthRatio>0.5 )
	{
		D = Damage * (DamageType.default.ArmorHealthRatio-0.5)*2.0;
		Damage -= D;
		Power -= D;
	}

	// Get damage to EnergyShield
	if( Power>0 )
	{
		Pct = Power / MaxPower;
		Power -= Damage * Pct;
		ReturnedDamage = Damage * (1-Pct);
	}
	else			
	{
		Pct = 0;
		ReturnedDamage = Damage;
	}

	// Post-damage for health.
	if( DamageType.default.ArmorHealthRatio<0.5 )
	{
		D = (Damage * Pct) * (((DamageType.default.ArmorHealthRatio*2.0)*-1.0)+1.0);
		Power += D;
		ReturnedDamage += D;
	}

	ArmorDamage		= OldPower-Power;
	OldArmorDamage	= ArmorDamage;
	//PWC 7/15/2002 Changed DamageFilter to support an optional float damage paramenter
	//              In order to avoid nasty mult/div 100 hack
	ArmorDamageInt	= int (ArmorDamage);
	DamageFilterClass.static.ApplyFilter( ArmorDamageInt, Momentum, DamageType, ArmorDamage );
	Power = OldPower - ArmorDamage;
	if( Power < 0 )
	{
		ReturnedDamage -= (Power * (OldArmorDamage / ArmorDamage)); //leftover health should have the powersuit damagefilter eliminated
		Power = 0;
	}
	
	ReturnedDamageInt = int(ReturnedDamage);
	DamageResidue += ReturnedDamage - ReturnedDamageInt;

	if( DamageResidue > 1 )
	{
		DamageResidue -= 1;
		ReturnedDamage += 1;
	}

	// Display HUD indicators PowerSuit visual hit effect
	DisplayDamageTaken( (int(OldPower) - int(Power)), ReturnedDamage, HitLocation );
	return ReturnedDamage;
}

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

function armor PrioritizeArmor( int Damage, class<DamageType> DamageType, vector HitLocation )
{
	return Self;
}

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

function bool PreventDeath( int Damage, Pawn Instigator, class<DamageType> DamageType, vector HitLocation )
{ 
	return false;
}

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

defaultproperties
{
	DamageFilterClass=Class'U2.DamageFilterPowerSuit'
	ParticleEffect=ParticleSalamander'Impact_Metal_AR.ParticleSalamander0'
	PowerSuitHitSound=Sound'U2A.Suits.PowerSuitHit'
	PowerSuitHitVolume=0.250000
	ItemName="Power Suit"
     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:42.000 - Creation time: sk 3-1-2016 10:48:40.998 - Created with UnCodeX