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

WVPersesMAS.PersesMercuryMissile


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
//=============================================================================
// MercuryMissile
// Copyright 2003-2010 by Wormbo <wormbo@online.de>
//
// High speed rocket.
//=============================================================================


class PersesMercuryMissile extends PersesProjectileBase;


//=============================================================================
// Imports
//=============================================================================

#exec audio import file=Sounds\MercPunchThrough.wav
#exec audio import file=Sounds\MercHitArmor.wav


//=============================================================================
// Properties
//=============================================================================

var float ImpactDamageAmount;

var class<DamageType> PunchThroughDamage;
var float PunchThroughSpeed, PunchThroughVelocityLossPercent;
var Sound ExplodeOnPlayerSound;
var float DopplerStrength, DopplerBaseSpeed;


/**
Adjust ambient sound to fake doppler effect.
*/
auto simulated state Flying
{
	simulated event Tick(float DeltaTime)
	{
		local PlayerController LocalPlayer;
		local float ApproachSpeed;

		if (Level.NetMode != NM_DedicatedServer && ProjEffects != None)
		{
			LocalPlayer = Level.GetLocalPlayerController();
			if (LocalPlayer != None)
			{
				ApproachSpeed = (Velocity + LocalPlayer.ViewTarget.Velocity) dot Normal(LocalPlayer.ViewTarget.Location - Location);
				ProjEffects.SoundPitch = ProjEffects.default.SoundPitch * (DopplerStrength ** (ApproachSpeed / DopplerBaseSpeed));
			}
		}
	}
}


/**
Returns how a contact with another object affects this projectile's movement.
*/
simulated function bool ShouldPenetrate(Actor Other, vector HitLocation, vector HitNormal)
{
	local vector RefNormal;
	
	return xPawn(Other) != None && !Other.IsInState('Frozen') && VSize(Velocity) - Normal(Velocity) dot Other.Velocity > PunchThroughSpeed && xPawn(Other).GetShieldStrength() == 0 && !xPawn(Other).CheckReflect(HitLocation, RefNormal, 0);
}

simulated function ProcessContact(Actor Other, vector HitLocation, vector HitNormal)
{
	if (ShouldPenetrate(Other, HitLocation, HitNormal))
	{
		Penetrate(Other, HitLocation);
	}
	else
	{
		if (UnrealPawn(Other) != None && !Other.IsInState('Frozen'))
			PlayBroadcastedSound(Other, ExplodeOnPlayerSound);
		
		ExplosionParticleSystem = GetExplosionClass(Other, HitLocation, HitNormal);
		Explode(HitLocation, HitNormal);
	}
}


simulated function Penetrate(Actor Other, vector HitLocation)
{
	local vector VDiff, Momentum;
	local float DamageAmount;
	
	VDiff = Velocity - Normal(Velocity) * (Normal(Velocity) dot Other.Velocity);
	VDiff *= PunchThroughVelocityLossPercent;
	
	if (Role == ROLE_Authority)
		MakeNoise(1.0);
	
	DamageAmount = TransferDamageAmount * 0.5 * (VSize(VDiff) + PunchThroughSpeed) + ImpactDamageAmount;
	Momentum = VDiff * MomentumTransfer;
	
	// apply UDamage factor if UDamage wore off or owner died
	if (bAmped && (Instigator == None || !Instigator.HasUDamage()))
		DamageAmount *= 2;

	if (int(DamageAmount) > 0 || VSize(Momentum) > 0)
	{
		Other.SetDelayedDamageInstigatorController(InstigatorController);
		Other.TakeDamage(DamageAmount, Instigator, HitLocation, Momentum, PunchThroughDamage);
	}

	if (Role == ROLE_Authority || Other == None || Other.Role < ROLE_Authority)
	{
		Velocity -= VDiff;
		SpawnPenetrationEffects(Other, HitLocation);
	}
}


/**
Play penetration sound and spawn a lot of blood after penetrating an unprotected player.
*/
simulated function SpawnPenetrationEffects(Actor Other, vector HitLocation)
{
	if (Other != None)
	{
		PlayBroadcastedSound(Other, ImpactSound);
		if (!class'GameInfo'.static.UseLowGore() && xPawn(Other) != None && xPawn(Other).GibGroupClass != None)
		{
			if ((HitLocation - Other.Location) dot Velocity < 0)
				HitLocation += Normal(Velocity) * Other.CollisionRadius;
			Spawn(xPawn(Other).GibGroupClass.default.BloodGibClass, Other,, HitLocation);
		}
	}
}


/**
Called from simulated functions to trick PlaySound() into broadcasting the sound instead of playing it locally.
*/
function PlayBroadcastedSound(Actor SoundOwner, Sound Sound)
{
	if (Level.NetMode != NM_Client && SoundOwner != None && Sound != None) {
		SoundOwner.PlaySound(Sound, SLOT_Misc, TransientSoundVolume, false, TransientSoundRadius);
	}
}


/**
Return an explosion effect class with dirt or snow particles if a corresponding surface was hit.
Non-simulated so effect is only spawned on server.
*/
simulated function class<PersesMercuryExplosion> GetExplosionClass(Actor HitActor, vector HitLocation, vector HitNormal)
{
	local Material HitMaterial;
	local vector HL, HN;

	if (PhysicsVolume.bWaterVolume) {
		return class'PersesMercuryExplosion';
	}

	if (HitActor == None || HitActor.bWorldGeometry) {
		HitActor = Trace(HL, HN, HitLocation - 16 * HitNormal, HitLocation + HitNormal, True,, HitMaterial);
	}
	if (HitMaterial != None) {
		switch (HitMaterial.SurfaceType) {
			case EST_Rock:
			case EST_Dirt:
			case EST_Wood:
			case EST_Plant:
				return class'PersesMercuryExplosionDirt';
			case EST_Ice:
			case EST_Snow:
				return class'PersesMercuryExplosionSnow';
		}
	}
	else if (HitActor != None) {
		switch (HitActor.SurfaceType) {
			case EST_Rock:
			case EST_Dirt:
			case EST_Wood:
			case EST_Plant:
				return class'PersesMercuryExplosionDirt';
			case EST_Ice:
			case EST_Snow:
				return class'PersesMercuryExplosionSnow';
		}
	}
	return class'PersesMercuryExplosion';
}


//=============================================================================
// Default properties
//=============================================================================

defaultproperties
{
	ProjectileName = "Mercury Missile"
	bAutoInit = True
	
	ForceType         = FT_Constant
	ForceRadius       =   100.0
	ForceScale        =     5.0
	Mass              =     3.0
	LifeSpan          =     6.0
	Speed             =  8000.0
	MaxSpeed          = 30000.0
	AccelRate         = 12000.0
	PunchThroughSpeed = 10000.0
	PunchThroughVelocityLossPercent = 0.4

	ImpactSound          = Sound'MercPunchThrough'
	ExplodeOnPlayerSound = Sound'MercHitArmor'

	DopplerBaseSpeed = 3000.0
	DopplerStrength  = 1.5

	TransientSoundRadius = 500.0
	TransientSoundVolume =   1.0

	Damage               =    30.0
	DamageRadius         =   150.0
	SplashMomentum       = 10000.0
	ImpactDamageAmount   =    50.0
	TransferDamageAmount =     0.003
	MomentumTransfer     =     4.0
	ExplosionDecal       = Class'PersesMercuryImpactMark'

	SplashDamageType = Class'DamTypePersesMercurySplashDamage'
	MyDamageType = Class'DamTypePersesMercuryDirectHit'
	PunchThroughDamage = Class'DamTypePersesMercuryPunchThrough'

	LightType       = LT_Steady
	LightEffect     = LE_QuadraticNonIncidence
	LightBrightness = 255.0
	LightRadius     =   5.0
	LightHue        =  20
	bDynamicLight   = True
	
	FlightParticleSystem = class'PersesMercuryMissileFlightEffects'
	FlightParticleSystemBlue = class'PersesMercuryMissileFlightEffectsBlue'

	bReplicateInstigator = True
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Do 12.6.2014 21:31:20.000 - Creation time: Do 14.8.2014 09:58:48.378 - Created with UnCodeX