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

WVHoverTankV3.NekomataSecondaryTurret


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
/******************************************************************************
NekomataSecondaryTurret

Creation date: 2012-10-24 12:09
Last change: $Id$
Copyright © 2012, Wormbo
Website: http://www.koehler-homepage.de/Wormbo/
Feel free to reuse this code. Send me a note if you found it helpful or want
to report bugs/provide improvements.
Please ask for permission first, if you intend to make money off reused code.
******************************************************************************/

class NekomataSecondaryTurret extends ONSTankSecondaryTurret;


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

#exec audio import file=Sounds\humveegun1.wav name=GaussFire group=Nekomata


var() float DamageRadius;
var() float FireRecoilAmount;


function TraceFire(vector Start, rotator Dir)
{
	local vector X, End, HitLocation, HitNormal;
	local Actor Other;
	local ONSWeaponPawn WeaponPawn;
	local Vehicle VehicleInstigator;

	MaxRange();

	if (bDoOffsetTrace) {
		WeaponPawn = ONSWeaponPawn(Owner);
		if (WeaponPawn != None && WeaponPawn.VehicleBase != None) {
			if (!WeaponPawn.VehicleBase.TraceThisActor(HitLocation, HitNormal, Start, Start + vector(Dir) * (WeaponPawn.VehicleBase.CollisionRadius * 1.5)))
				Start = HitLocation;
		}
		else if (!Owner.TraceThisActor(HitLocation, HitNormal, Start, Start + vector(Dir) * (Owner.CollisionRadius * 1.5)))
			Start = HitLocation;
	}

	X = vector(Dir);
	End = Start + TraceRange * X;

	//skip past vehicle driver
	VehicleInstigator = Vehicle(Instigator);
	if (VehicleInstigator != None && VehicleInstigator.Driver != None) {
		VehicleInstigator.Driver.bBlockZeroExtentTraces = false;
		Other = Trace(HitLocation, HitNormal, End, Start, true);
		VehicleInstigator.Driver.bBlockZeroExtentTraces = true;
	}
	else
		Other = Trace(HitLocation, HitNormal, End, Start, True);

	if (Other != None && Other != Instigator) {
		ExtendedHurtRadius(HitLocation, X, Other);
		HitCount++;
		LastHitLocation = HitLocation;
		SpawnHitEffects(Other, HitLocation, HitNormal);
	}
	else {
		HitLocation = End;
		HitNormal = vect(0,0,0);
		HitCount++;
		LastHitLocation = HitLocation;
	}

	SpawnBeamEffect(Start, Dir, HitLocation, HitNormal, 0);

	if (Instigator != None)
	{
		if (Instigator.GetVehicleBase() != None)
			Instigator.GetVehicleBase().KAddImpulse(-FireRecoilAmount * vector(Dir), Start);
		else
			Instigator.KAddImpulse(-FireRecoilAmount * vector(Dir), Start);
	}
	NetUpdateTime = Level.TimeSeconds - 1;
}


state InstantFireMode
{
	simulated function SpawnHitEffects(Actor HitActor, vector HitLocation, vector HitNormal)
	{
		local PlayerController PC;

		if (Pawn(HitActor) == None || Vehicle(HitActor) != None)
			Super.SpawnHitEffects(HitActor, HitLocation, HitNormal);

		PC = Level.GetLocalPlayerController();
		if (PC != None && (Instigator != None && Instigator.Controller == PC || VSize(PC.ViewTarget.Location - HitLocation) < 10000))
			Spawn(class'GaussExplosionEffect',,, HitLocation + 10 * HitNormal);
	}
}


function ExtendedHurtRadius(vector HitLocation, vector AimDir, Actor HitActor)
{
	local Actor Victims;
	local float damageScale, dist, damageAmount;
	local vector dir, HL, HN;

	DamageAmount = RandRange(DamageMin, DamageMax);
	if (HitActor != None && HitActor != ONSWeaponPawn(Instigator).VehicleBase) {
		// first damage the hit actor
		dir = Normal(HitActor.Location - HitLocation);
		dir = Normal(dir + AimDir);
		HitActor.TakeDamage(DamageAmount, Instigator, HitActor.Location - 0.5 * (HitActor.CollisionHeight + HitActor.CollisionRadius) * dir, Momentum * dir, DamageType);
		if (Vehicle(HitActor) != None && Vehicle(HitActor).Health > 0)
			Vehicle(HitActor).DriverRadiusDamage(DamageAmount, DamageRadius, Instigator.Controller, DamageType, Momentum, HitLocation);
	}

	// now look for other nearby actors to damage
	foreach VisibleCollidingActors(class'Actor', Victims, DamageRadius + 500, HitLocation) {
		if (Victims != self && Victims != HitActor && Victims.Role == ROLE_Authority && !Victims.IsA('FluidSurfaceInfo')) {
			if (!Victims.TraceThisActor(HL, HN, DamageRadius * Normal(Victims.Location - HitLocation), HitLocation, vect(1,1,1) * Sqrt(DamageRadius)))
				HL = Victims.Location;
			dist = VSize(HL - HitLocation);
			if (dist > DamageRadius)
				continue;
			dir = Normal(Victims.Location - HitLocation);
			damageScale = 1 - FMax(0, dist / DamageRadius);
			Victims.TakeDamage(damageScale * DamageAmount, Instigator, Victims.Location - 0.5 * (Victims.CollisionHeight + Victims.CollisionRadius) * dir, damageScale * Momentum * dir, DamageType);
			if (Vehicle(Victims) != None && Vehicle(Victims).Health > 0)
				Vehicle(Victims).DriverRadiusDamage(DamageAmount, DamageRadius, Instigator.Controller, DamageType, Momentum, HitLocation);
		}
	}
}


simulated function Tick(float DeltaTime)
{
	if (Instigator != None && Instigator.PlayerReplicationInfo != None)
	{
		bForceCenterAim = False;
	}
	else if (!bActive && CurrentAim != rot(0,0,0))
	{
		bForceCenterAim = True;
		bActive = True;
	}
	else if (bActive && CurrentAim == rot(0,0,0))
	{
		bActive = False;
	}
}


//=============================================================================
// Default values
//=============================================================================

defaultproperties
{
	RedSkin  = None
	BlueSkin = None
	Skins[0] = Shader'EnergyTankShaderRed'
	RepSkin  = Shader'EnergyTankShaderRed'
	Mesh     = Mesh'AS_VehiclesFull_M.IonTankMachineGun'

	bAmbientFireSound = False
	Begin Object Class=ProceduralSound Name=GaussFireSound
		BaseSound = Sound'GaussFire'
		PitchModification = -3.0
		PitchVariance     =  6.0
	End Object
	FireSoundClass    = Sound'GaussFireSound'

	AmbientEffectEmitterClass = None
	EffectEmitterClass        = class'GaussFireEffect'
	WeaponFireAttachmentBone  = Object02
	WeaponFireOffset = 72.0
	DualFireOffset   =  8.5
	DrawScale        =  1.2

	DamageType   = class'DamTypeNekomataMinigun'
	DamageRadius = 35.0
	DamageMin    = 29
	DamageMax    = 31
	Spread       = 0.005
	FireInterval = 0.2
	Momentum     = 5000.0

	bInstantRotation   = False
	RotationsPerSecond = 1.0
	FireRecoilAmount   = 1000.0
	bDoOffsetTrace     = True
	PitchDownLimit     = 61000

	AIInfo[0] = (bTrySplash=True)
}


Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mo 2.12.2013 00:56:38.000 - Creation time: Do 14.8.2014 09:58:45.332 - Created with UnCodeX