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

U2.U2Kicker


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
//=============================================================================
// U2Kicker
// Creatures will jump on hitting this trigger in direction specified
//=============================================================================
class U2Kicker extends Triggers;

#exec OBJ LOAD FILE=..\Sounds\U2A.uax

const MaxKickedClasses = 4;

enum EKickedPawnType
{
	KPT_None,
	KPT_All,
	KPT_Players,
	KPT_RealPlayers,
};

var() name KickedClasses[MaxKickedClasses]; 			// names of classes which are affected (defaults to Pawns)
var() EKickedPawnType KickedPawnTypes; 					// if Pawn, which type to allow (KPT_RealPlayers)
var() bool bKickOnJump;									// if true, kicker simply modifies Pawn's JumpZ temporarily (Pawns only)
var() bool bKillVelocity;								// (if !bKickOnJump) and true, kills affected actor's incoming velocity not just Z part
var() vector KickVelocity;								// (if !bKickOnJump) velocity (X/Y/Z) used to launch actor
var() float KickOnJumpMultiplier;						// (if bKickOnJump), amount to multiply normal JumpZ by
var() bool bRandomize;									// whether to randomize
var() bool bActive;										// if true, kicker is initially inactive (trigger it on)

// sound stuff
var() Sound KickSound;
var() ESoundSlot KickSoundSlot;
var() float KickSoundVolume;
var() bool KickSoundNoOverride;
var() float KickSoundRadius;
var() float KickSoundPitch;

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

function Trigger( Actor Other, Pawn EventInstigator, optional name EventName )
{
	bActive = !bActive;
}

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

simulated function bool IsAffected( Actor Other ) 
{ 
	local int ii; 
	local bool bResult;

	bResult = false;
	for( ii=0; ii<MaxKickedClasses; ii++ ) 
	{
		if( Other.IsA(KickedClasses[ii]) )
		{
			if( (Pawn(Other) == None) || 
				(KickedPawnTypes == KPT_All) || 
				(KickedPawnTypes == KPT_Players && Other.IsPlayer()) ||
				(KickedPawnTypes == KPT_RealPlayers && Other.IsRealPlayer()) )
			{
				bResult = true; 
			}
		}
	}

	return bResult;
} 

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

simulated event Touch( Actor Other )
{
	if( bActive && IsAffected( Other ) )
	{
		PendingTouch = Other.PendingTouch;
		Other.PendingTouch = Self;

		if( bKickOnJump && Pawn(Other) != None )
		{
			// see sound comments elsewhere
			Pawn(Other).JumpZ *= KickOnJumpMultiplier;
		}
	}
}

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

simulated event UnTouch( Actor Other ) 
{ 
	if( bActive && bKickOnJump && 
		(Pawn(Other) != None) && 
		IsAffected( Other ) && 
		(Pawn(Other).JumpZ != Pawn(Other).default.JumpZ) ) 
	{
		Pawn(Other).JumpZ = Pawn(Other).default.JumpZ; 

		// !!mdf-tbd: is this OK -- in some cases (e.g. hit by rocket, dodged) pawn won't have actually jumped
		if( (Other.Physics == PHYS_Falling) && (Other.Velocity.Z > 0) )
		{
		  	TriggerActors( Self, TriggerClass, Other, Other.Instigator, Event, bTriggerNPCs );
			if( KickSound != None )
			{
				PlaySound( KickSound, KickSoundSlot, KickSoundVolume, KickSoundNoOverride, KickSoundRadius, KickSoundPitch );
			}
		}
	}
} 

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

simulated event PostTouch( Actor Other )
{
	local vector Push;
	local float PMag;

	if( bActive && !bKickOnJump )
	{
		if ( bKillVelocity )
		{
			// kill entire incoming velocity
			Push	= -1 * Other.Velocity;
		}
		else
		{
			// only kill Z component of incoming velocity
			Push.Z	= -1 * Other.Velocity.Z;
		}

		if ( bRandomize )
		{
			PMag = VSize(KickVelocity);
			Push += PMag * Normal(KickVelocity + 0.5 * PMag * VRand());
		}
		else
		{
			Push += KickVelocity;
		}
	
		if ( Pawn(Other) != None && Pawn(Other).Controller != None )
		{
			if ( Other.Physics == PHYS_Falling )
				Pawn(Other).Controller.bSpecialJump = true;
			Pawn(Other).Controller.SetFall();
		}
	
		Other.SetPhysics( PHYS_Falling );
		Other.Velocity += Push;

	  	TriggerActors( Self, TriggerClass, Other, Other.Instigator, Event, bTriggerNPCs );

		if( KickSound != None )
		 	PlaySound( KickSound, KickSoundSlot, KickSoundVolume, KickSoundNoOverride, KickSoundRadius, KickSoundPitch );
	}
}

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

defaultproperties
{
	KickedClasses(0)='Pawn'
	KickedPawnTypes=KPT_RealPlayers
	KickVelocity=(Z=1200.000000)
	KickOnJumpMultiplier=10.000000
	bActive=true
	KickSound=Sound'U2A.Effects.Kick'
	KickSoundSlot=SLOT_Misc
	KickSoundVolume=1.000000
	KickSoundRadius=500.000000
	KickSoundPitch=1.000000
	RemoteRole=ROLE_SimulatedProxy
	bDirectional=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:42.000 - Creation time: sk 3-1-2016 10:48:42.740 - Created with UnCodeX