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

Engine.Projectile


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
//=============================================================================
// Projectile.
//
// A delayed-hit projectile moves around for some time after it is created.
// An instant-hit projectile acts immediately.
//=============================================================================
class Projectile extends Actor
		abstract
			native;

#exec Texture Import File=Textures\S_Camera.pcx Name=S_Camera Mips=Off Flags=2

//-----------------------------------------------------------------------------
// Projectile variables.

// Motion information.
var() float    Speed;               // Initial speed of projectile.
var() float    MaxSpeed;            // Limit on speed of projectile (0 means no limit)

// Damage attributes.
var() float    Damage;
var() int	   MomentumTransfer; // Momentum imparted by impacting projectile.
var() name	   MyDamageType;

// Projectile sound effects
var() sound    SpawnSound;		// Sound made when projectile is spawned.
var() sound	   ImpactSound;		// Sound made when projectile hits something.
var() sound    MiscSound;		// Miscellaneous Sound.

var() float		ExploWallOut;	// distance to move explosions out from wall

// explosion decal
var() class<Decal> ExplosionDecal;

var Actor LastHitActor;

//==============
// Encroachment
function bool EncroachingOn( actor Other )
{
	if ( (Other.Brush != None) || (Brush(Other) != None) )
		return true;

	return false;
}

//==============
// Touching
simulated singular function Touch(Actor Other)
{
	local vector HitNormal,HitLocation;

	if ( Other.bWorldGeometry || Other.IsA('BlockAll') )
	{
		LastHitActor = Other;
		if( Other.TraceThisActor(Location,OldLocation,HitLocation,HitNormal,GetExtent()) )
		{
			SetLocation(HitLocation);
			HitWall( HitNormal, Other);
		}
		else HitWall( Normal(Location - Other.Location), Other);
		LastHitActor = None;
		return;
	}
	if ( Other.bProjTarget || (Other.bBlockActors && Other.bBlockPlayers) )
	{
		//get exact hitlocation
		if( Other.TraceThisActor(Location+Velocity,OldLocation,HitLocation,,GetExtent()) )
		{
			if ( Other.bIsPawn && !Pawn(Other).AdjustHitLocation(HitLocation, Velocity) )
				return;
			LastHitActor = Other;
			ProcessTouch(Other, HitLocation);
		}
		else
		{
			LastHitActor = Other;
			ProcessTouch(Other, Other.Location + Other.CollisionRadius * Normal(Location - Other.Location));
		}
		LastHitActor = None;
	}
}

simulated function ProcessTouch(Actor Other, Vector HitLocation)
{
	//should be implemented in subclass
}

simulated function HitWall (vector HitNormal, actor Wall)
{
	LastHitActor = Wall;
	if ( Role == ROLE_Authority )
	{
		if ( (Mover(Wall) != None) && Mover(Wall).bDamageTriggered )
			Wall.TakeDamage( Damage, instigator, Location, MomentumTransfer * Normal(Velocity), '');

		MakeNoise(1.0);
	}
	Explode(Location + ExploWallOut * HitNormal, HitNormal);
	if ( (ExplosionDecal!=None) && EffectIsRelevant(Location) )
		Spawn(ExplosionDecal,self,,Location, rotator(HitNormal));
}

simulated function Explode(vector HitLocation, vector HitNormal)
{
	Destroy();
}

simulated final function RandSpin(float spinRate)
{
	DesiredRotation = RotRand();
	RotationRate.Yaw = spinRate * 2 *FRand() - spinRate;
	RotationRate.Pitch = spinRate * 2 *FRand() - spinRate;
	RotationRate.Roll = spinRate * 2 *FRand() - spinRate;
}

// Additional 227g functions:
// Hurt actors within the radius.
simulated final function HurtRadiusProj( float DamageAmount, float DamageRadius, name DamageName, float Momentum, vector HitLocation )
{
	local actor Victims;
	local float damageScale, dist;
	local vector dir;

	if ( bHurtEntry )
		return;

	bHurtEntry = true;
	foreach VisibleCollidingActors( class 'Actor', Victims, DamageRadius, HitLocation )
	{
		if( Victims!=self && Victims!=LastHitActor )
		{
			dir = Victims.Location - HitLocation;
			dist = FMax(1,VSize(dir));
			dir = dir/dist;
			damageScale = 1 - FMax(0,(dist - Victims.CollisionRadius)/DamageRadius);
			Victims.TakeDamage
			(
				damageScale * DamageAmount,
				Instigator,
				Victims.Location - 0.5 * (Victims.CollisionHeight + Victims.CollisionRadius) * dir,
				(damageScale * Momentum * dir),
				DamageName
			);
		}
	}
	if( LastHitActor!=None )
	{
		dir = LastHitActor.Location - HitLocation;
		dist = FMax(1,VSize(dir));
		dir = dir/dist;
		damageScale = FMin(FMax(LastHitActor.CollisionRadius/(LastHitActor.CollisionRadius + LastHitActor.CollisionHeight),
			1 - FMax(0,(dist - LastHitActor.CollisionRadius)/DamageRadius)),1.f);
		LastHitActor.TakeDamage
		(
			damageScale * DamageAmount,
			Instigator,
			LastHitActor.Location - 0.5 * (LastHitActor.CollisionHeight + LastHitActor.CollisionRadius) * dir,
			(damageScale * Momentum * dir),
			DamageName
		);
	}
	bHurtEntry = false;
}
simulated final function bool EffectIsRelevant( vector SpawnLocation, optional bool bForceDedicated )
{
	local PlayerPawn P;
	local bool bResult;

	if ( Level.NetMode == NM_DedicatedServer )
		return bForceDedicated;
	if ( Level.NetMode != NM_Client )
		bResult = true;
	else if ( PlayerPawn(Instigator)!=None && Viewport(PlayerPawn(Instigator).Player)!=None )
		return true;
	else if ( SpawnLocation == Location )
		bResult = (Level.TimeSeconds-LastRenderedTime < 3);
	else if ( (Instigator != None) && (Level.TimeSeconds-Instigator.LastRenderedTime < 3) )
		bResult = true;
	if ( bResult )
	{
		P = Level.GetLocalPlayerPawn();
		if ( P == None )
			bResult = false;
		else if ( (Vector(P.CalcCameraRotation) Dot (SpawnLocation - P.CalcCameraLocation)) < 0.0 )
			bResult = (VSize(P.CalcCameraLocation - SpawnLocation) < 1000);
	}
	return bResult;
}
simulated final function Texture GetHitTexture() // Get the impact texture on HitWall
{
	local vector Dir;
	local Texture T;
	local int F;

	Dir = Normal(Velocity);
	if( !TraceSurfHitInfo(Location-Dir*5.f,Location+Dir*50.f,,,T,F) || (F & PF_FakeBackdrop)!=0 ) // Did not hit or did hit skybox texture.
		return None;
	return T;
}

defaultproperties
{
				MaxSpeed=2000.000000
				bNetTemporary=True
				bReplicateInstigator=True
				Physics=PHYS_Projectile
				LifeSpan=140.000000
				bDirectional=True
				DrawType=DT_Mesh
				Texture=Texture'Engine.S_Camera'
				bGameRelevant=True
				SoundVolume=0
				CollisionRadius=0.000000
				CollisionHeight=0.000000
				bCollideActors=True
				bCollideWorld=True
				NetPriority=6.000000
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: zo 11-11-2012 21:10:26.000 - Creation time: zo 11-11-2012 21:14:19.787 - Created with UnCodeX