## XIDCine
Class ScriptedImpacts

source: C:\XIII\XIDCine\Classes\ScriptedImpacts.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Info
             |
             +--XIDCine.ScriptedImpacts

Direct Known Subclasses:None

class ScriptedImpacts
extends Engine.Info

Variables
`BulletTrail` | `BT` BulletTrail once spawned to handle update
`CurrentNumberOfImpacts,` | `BulletCounter` BulletTrail once spawned to handle update
`int` | `BulletTrailRate`
`BulletScorch` | `DecalProjector`
`class` | `DecalProjectorClass`
`float` | `Dispersion`
`float` | `ExtraTraceDistance`
`sound` | `HitSoundMem`
`class` | `ImpactEmitterMem`
`SImpact` | `Impacts[16]`
`CurrentTargetLocation,` | `NextTargetDeltaLocation` BulletTrail once spawned to handle update
`Sound` | `ShootSound`
`TAEmitter` | `Tatata`
`class` | `TraceClass` Class of BulletTrace to spawn
`bool` | `bDoTatata`
`bool` | `bPlayHitSound`

States
Burst

Function Summary
`void` | `Impact(vector TargetedPosition)`
`void` | `NewTarget( )`
`void` | `PlayImpactSound(vector Normal, Actor Wall)`
    /*
`void` | `PostBeginPlay()`
    /*
`void` | `ProcessTraceHitNoAmmo(Weapon W, Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)`
    //_____________________________________________________________________________
`void` | `SetUpImpactEmitter(Sound S)`
    {
        local Material M;
        local actor A;
        local vector HitLoc, HitNorm;
        local ImpactEmitter B;

        if ( Level.NetMode == NM_DedicatedServer )
          return;

        A = Trace(HitLoc, HitNorm, Location - Normal * 50, Location + Normal, false, vect(0,0,0), M);

        if ( Wall.bWorldGeometry || (Mover(Wall) != none) || (StaticMeshActor(Wall) != none) )
        {
          if ( (M != none) && (M.HitSound != none) )
            SetUpImpactEmitter(M.HitSound);
          else if ( TerrainInfo(Wall) != none )
            SetUpImpactEmitter(TerrainInfo(Wall).HitSound);
          if ( ImpactEmitterMem != none )
          {
            B = Spawn(ImpactEmitterMem,,, HitLoc+HitNorm, Rotator(HitNorm));
            if ( (B != none) && (HitSoundType >= 0) )
            {
              if ( (M != none) && (M.HitSound != none) )
                B.PlaySound(M.HitSound, HitSoundType);
              else if ( TerrainInfo(Wall) != none )
                B.PlaySound(TerrainInfo(Wall).HitSound, HitSoundType);
            }
          }
        }
    }*/

State Burst Function Summary

Source Code

    00001	class ScriptedImpacts extends Info
    00002		ShowCategories(Movement)
    00003		placeable;
    00004
    00005	//  abstract;
    00006	//
    00007	//var float ShortRange;           // Range at wich we do SRDamages (decreasing)
    00008	//var float LongRange;            // Range at wich we do LRDamages (decreasing)
    00009	//var int SRDamages, LRDamages;   // ShortRange and LongRange damages
    00010
    00011	ENUM E_TransitionType
    00012	{
    00013		TT_Cut,
    00014		TT_Smooth,
    00015	};
    00016
    00017	STRUCT SImpact
    00018	{
    00019		VAR() Actor TargetedActor;
    00020		VAR() int NumberOfImpacts;
    00021		VAR() class<ImpactEmitter> NoMoreUsed; //ImpactEmitterMem;  // Visual Impact SFX to run when impacting
    00022		VAR() class<Projector> NoMoreUsed2;  // Visual Impact to leave on geometry
    00023		VAR() float ImpactNoise;              // Noise made by the ammo when hitting something
    00024		VAR() float BulletsInterval;
    00025		VAR() float TimeBeforeNextTarget;
    00026		VAR() E_TransitionType Transition;
    00027	};
    00028
    00029	VAR() SImpact Impacts[16];
    00030	VAR() float ExtraTraceDistance;
    00031	VAR() float Dispersion;
    00032	VAR() int BulletTrailRate;
    00033	VAR() class<ImpactEmitter> ImpactEmitterMem;
    00034	VAR() class<BulletScorch> DecalProjectorClass;
    00035	VAR BulletScorch DecalProjector;
    00036	VAR() Sound ShootSound;
    00037	VAR sound HitSoundMem;
    00038	VAR bool bPlayHitSound;
    00039	VAR() bool bDoTatata;
    00040	VAR TaEmitter Tatata;
    00041
    00042	//VAR() Actor Targets[16];
    00043	//VAR() int NumberOfImpactsByTarget[16];
    00044	//VAR() float Dispersion;
    00045	//VAR() float SoftImpactNoise;          // Noise made by the ammo when hitting someone
    00046	VAR() class<BulletTrail> TraceClass;    // Class of BulletTrace to spawn
    00047
    00048	VAR BulletTrail BT;                   // BulletTrail once spawned to handle update
    00049	VAR int CurrentTarget, CurrentNumberOfImpacts, BulletCounter;
    00050	VAR vector CurrentTargetLocation, NextTargetDeltaLocation;
    00051
    00052
    00053	//_____________________________________________________________________________
    00054	/*function PostBeginPlay()
    00055	{
    00056	    Super.PostBeginPlay();
    00057	}
    00058
    00059	//_____________________________________________________________________________
    00060	function ProcessTraceHitNoAmmo(Weapon W, Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
    00061	{
    00062	    if (AmmoAmount > 0)
    00063	    {
    00064	      AmmoAmount += 1;
    00065	      ProcessTraceHit(W, Other, HitLocation, HitNormal, X, Y, Z);
    00066	    }
    00067	}*/
    00068
    00069	//_____________________________________________________________________________
    00070	EVENT Trigger(Actor Other,Pawn EventInstigator)
    00071	{
    00072		CurrentTarget=0;
    00073		BulletCounter=0;
    00074		if ( Impacts[CurrentTarget].TargetedActor==none )
    00075		{
    00076	//		DebugLog( "ScriptedImpacts::Trigger::Destroy");
    00077			Destroy();
    00078			return;
    00079		}
    00080		GotoState('Burst');
    00081	}
    00082
    00083	FUNCTION NewTarget( )
    00084	{
    00085	//	DebugLog( self@"ScriptedImpacts::NewTarget : CurrentTarget="@CurrentTarget@", TargetedActor="@Impacts[CurrentTarget].TargetedActor );
    00086		if ( CurrentTarget<8 && Impacts[CurrentTarget].TargetedActor !=none )
    00087		{
    00088			CurrentTargetLocation = Impacts[CurrentTarget].TargetedActor.Location;
    00089			if ( Impacts[CurrentTarget].Transition == TT_Smooth )
    00090			{
    00091				if ( CurrentTarget==7 || Impacts[CurrentTarget+1].TargetedActor==none || Impacts[CurrentTarget].NumberOfImpacts==0 )
    00092				{
    00093	//				Log("TRY TO SMOOTH BUT CUT : CurrentTarget="@CurrentTarget@", NextTargetedActor="@Impacts[CurrentTarget+1].TargetedActor@", NumberOfImpacts="@Impacts[CurrentTarget].NumberOfImpacts );
    00094					Impacts[CurrentTarget].Transition = TT_Cut;
    00095				}
    00096				else
    00097				{
    00098	//				Log("OK SMOOTH");
    00099					NextTargetDeltaLocation = Impacts[CurrentTarget+1].TargetedActor.Location - CurrentTargetLocation;
    00100				}
    00101
    00102			}
    00103	/*		else
    00104			{
    00105				Log("OK CUT");
    00106			}*/
    00107			CurrentNumberOfImpacts=0;
    00108		}
    00109		else
    00110		{
    00111	//		DebugLog( "ScriptedImpacts::NewTarget::GotoState('')");
    00112			if ( Tatata!=none )
    00113				Tatata.Emitters[0].RespawnDeadParticles=false;
    00114
    00115			TriggerEvent( event, self, none );
    00116			GotoState('');
    00117		}
    00118	}
    00119
    00120	STATE Burst
    00121	{
    00122		Ignores Trigger;
    00123
    00124		EVENT BeginState()
    00125		{
    00126	//		LOG(self@"BeginState");
    00127			NewTarget();
    00128			SetTimer( Impacts[CurrentTarget].BulletsInterval,true );
    00129			Timer();
    00130		}
    00131		EVENT Timer()
    00132		{
    00133			if ( CurrentNumberOfImpacts<Impacts[CurrentTarget].NumberOfImpacts )
    00134			{
    00135				if ( bDoTatata && Tatata==none )
    00136					Tatata=Spawn(class'TaEmitter');
    00137				if ( Impacts[CurrentTarget].Transition == TT_Cut )
    00138					Impact( Impacts[CurrentTarget].TargetedActor.Location );
    00139				else // TT_Smooth
    00140				{
    00141					Impact( CurrentTargetLocation +  float(CurrentNumberOfImpacts)/Impacts[CurrentTarget].NumberOfImpacts * NextTargetDeltaLocation );
    00142				}
    00143			}
    00144
    00145			CurrentNumberOfImpacts++;
    00146
    00147			if ( CurrentNumberOfImpacts>=Impacts[CurrentTarget].NumberOfImpacts )
    00148			{
    00149				if (Impacts[CurrentTarget].TimeBeforeNextTarget!=0)
    00150				{
    00151	//				Log(self@"PAUSE"@Impacts[CurrentTarget].TimeBeforeNextTarget);
    00152					SetTimer(0,false);
    00153					SetTimer2(Impacts[CurrentTarget].TimeBeforeNextTarget,false);
    00154					CurrentTarget++;
    00155					NewTarget();
    00156					if ( Tatata!=none )
    00157						Tatata.Emitters[0].RespawnDeadParticles=false;
    00158				}
    00159				else
    00160				{
    00161	//				Log(self@"PAS DE PAUSE");
    00162					CurrentTarget++;
    00163					NewTarget();
    00164				}
    00165			}
    00166		}
    00167		EVENT Timer2()
    00168		{
    00169	//		LOG(self@"TIMER2"@Impacts[CurrentTarget].BulletsInterval);
    00170			Tatata.Emitters[0].RespawnDeadParticles=true;
    00171			SetTimer( Impacts[CurrentTarget].BulletsInterval,true );
    00172	//		Timer();
    00173		}
    00174	}
    00175
    00176	FUNCTION Impact( vector TargetedPosition )
    00177	{
    00178		LOCAL ImpactEmitter B;
    00179
    00180		local vector HitLocation, HitNormal, StartTrace, EndTrace, X,Y,Z;
    00181		local material HitMat;
    00182		local actor HitPawn, Target;
    00183		LOCAL int i;
    00184		LOCAL vector u,v,w;
    00185
    00186
    00187		if ( Tatata!=none )
    00188		{
    00189			Tatata.SetLocation( Location+170*Normal(TargetedPosition-Location) );
    00190		}
    00191
    00192		if ( ShootSound!=none)
    00193			PlaySound( ShootSound );
    00194	//	Log(" IMPACT "@TargetedPosition );
    00195	//	Log("*** IMPACT IMPACT IMPACT IMPACT IMPACT IMPACT IMPACT ***");
    00196	//	for (i=0;i<16;i++)
    00197	//	{
    00198			u=Normal( TargetedPosition - Location );
    00199			v=Normal(u cross vect(0,0,1));
    00200			w=v cross u;
    00201			EndTrace= TargetedPosition + v*Dispersion*(frand()*2-1)+w*Dispersion*(frand()*2-1)+ExtraTraceDistance*u;
    00202	//		Target=Targets[CurrentBullet];
    00203	//		if ( Target==none)
    00204	//			return;
    00205	//		EndTrace=Target.Location+ Normal(Target.Location-Location)*100;
    00206			HitPawn = Trace(HitLocation,HitNormal,EndTrace,Location,True,vect(0,0,0),HitMat,TRACETYPE_DiscardIfCanShootThroughWithRayCastingWeapon);
    00207
    00208			if ( HitPawn!=none)
    00209			{
    00210				if ( HitPawn.IsA('BreakableMover' ) )
    00211					HitPawn.Trigger( self, none );
    00212				if ( HitPawn.IsA('InteractiveCan' ) )
    00213					HitPawn.TakeDamage( 0, none, HitLocation, 3000*Normal(HitLocation-Location), Class'XIII.DTGunned' );
    00214				if ( Pawn(HitPawn)!=none )
    00215				{
    00216					ImpactEmitterMem=class'BloodShotEmitter';
    00217	//			  Spawn(class'BloodShotEmitter',Other,, HitLocation+HitNormal, Rotator(-X));
    00218				}
    00219			}
    00220	//		Log (HitPawn);
    00221			if ( HitMat!=none )
    00222			{
    00223				HitSoundMem=HitMat.Hitsound;
    00224				SetUpImpactEmitter( HitSoundMem );
    00225				bPlayHitSound=true;
    00226	//			DebugLog( "_______SI::HitMaterial :"@HitMat@"=>"@HitSoundMem);
    00227			}
    00228			else
    00229			{
    00230				bPlayHitSound=false;
    00231	//			DebugLog( "_______SI::NoMaterialHit !!");
    00232			}
    00233
    00234			if ( BT == none && TraceClass!=none )
    00235			{
    00236				BT = Spawn( TraceClass,self, , Location, Rotation );
    00237				BT.Instigator = Instigator;
    00238				BT.bOwnerNoSee = true;
    00239				//        BT.ActorOffset = MuzzleOffset - (Instigator.Weapon.ThirdPersonRelativeLocation << Instigator.Weapon.ThirdPersonRelativeRotation);
    00240				BT.RibbonColor = BT.default.RibbonColor;// * fRand();
    00241
BT.Init(); 00242 // Log("SPAWN TRAIL"@BT@"for"@self); 00243 } 00244 if ( BT != none ) 00245 { 00246 // Log("TRAIL Update after fire"); 00247 BT.Reset( ); 00248 // Add sections to draw bullet traces 00249 if ( BulletCounter==0 ) 00250 { 00251 BT.AddSection( HitLocation ); //Target.Location /*+ vector(Rotation)*3000*/); 00252 BT.AddSection( Location ); 00253 } 00254 BulletCounter++; 00255 if ( BulletCounter>=BulletTrailRate) 00256 BulletCounter=0; 00257 00258 } 00259 00260 if ( /*Impacts[CurrentTarget].*/ImpactEmitterMem != none ) 00261 { 00262 B = Spawn(/*Impacts[CurrentTarget].*/ImpactEmitterMem, , , HitLocation+HitNormal, Rotator(HitNormal) ); 00263 if (B!=none) 00264 { 00265 B.NoiseMake( XIIIPawn(Owner), Impacts[CurrentTarget].ImpactNoise ); 00266 if ( bPlayHitSound ) 00267 { 00268 bPlayHitSound = false; 00269 B.PlaySound(HitSoundMem, 0/*, HitSoundType*/); 00270 } 00271 } 00272 } 00273 if ( ( /*Impacts[CurrentTarget].*/DecalProjectorClass != None) /*&& (!Target.bNoImpact)*/ ) 00274 // ClientSpawnDecal(HitLocation, X); 00275 { 00276 if ( DecalProjector == none ) 00277 { 00278 DecalProjector = Spawn(/*Impacts[CurrentTarget].*/DecalProjectorClass,self,,HitLocation + HitNormal, rotator(-HitNormal)); 00279 } 00280 else 00281 { 00282 DecalProjector.SetLocation( HitLocation + HitNormal ); 00283 DecalProjector.SetRotation( rotator(-HitNormal) ); 00284 DecalProjector.UpdateScorch(); 00285 } 00286 } 00287 // } 00288 } 00289 00290 // bDrawTracingBullets=true 00291 // TBTexture=texture'XIIIMenu.SFX.TraceBullet1' 00292 // fTraceFrequency=0.33333 00293 // HitSoundType=0 00294 // Tracetype=16384 00295 /* 00296 function PlayImpactSound(vector Normal, actor Wall) 00297 { 00298 local Material M; 00299 local actor A; 00300 local vector HitLoc, HitNorm; 00301 local ImpactEmitter B; 00302 00303 if ( Level.NetMode == NM_DedicatedServer ) 00304 return; 00305 00306 A = Trace(HitLoc, HitNorm, Location - Normal * 50, Location + Normal, false, vect(0,0,0), M); 00307 00308 if ( Wall.bWorldGeometry || (Mover(Wall) != none) || (StaticMeshActor(Wall) != none) ) 00309 { 00310 if ( (M != none) && (M.HitSound != none) ) 00311 SetUpImpactEmitter(M.HitSound); 00312 else if ( TerrainInfo(Wall) != none ) 00313 SetUpImpactEmitter(TerrainInfo(Wall).HitSound); 00314 if ( ImpactEmitterMem != none ) 00315 { 00316 B = Spawn(ImpactEmitterMem,,, HitLoc+HitNorm, Rotator(HitNorm)); 00317 if ( (B != none) && (HitSoundType >= 0) ) 00318 { 00319 if ( (M != none) && (M.HitSound != none) ) 00320 B.PlaySound(M.HitSound, HitSoundType); 00321 else if ( TerrainInfo(Wall) != none ) 00322 B.PlaySound(TerrainInfo(Wall).HitSound, HitSoundType); 00323 } 00324 } 00325 } 00326 }*/ 00327 00328 function SetUpImpactEmitter(Sound S) 00329 { 00330 local string Str; 00331 local int i; 00332 00333 // First get rid of the beginning of the sound name just to keep whet is needed 00334 Str = string(S); 00335 i = InStr(S, 'hPlay'); 00336 Str = Right(Str, Len(Str) - i - 5); 00337 // Log("SetUpImpactEmitter Bullet --'"$Str$"'--"); 00338 00339 // Then switch/case the result to setup the SFX class 00340 switch (Str) 00341 { 00342 case "ImpBtE": 00343 case "ImpBtI": 00344 case "ImpCar": 00345 case "ImpMar": 00346 case "ImpTil": 00347 case "ImpPie": 00348 // Concrete type 00349 00350 if ( (DecalProjector != none) && (DecalProjector.Class != Class'XIII.BulletScorch') ) 00351 { 00352 DecalProjector.LifeSpan = 2.0+fRand(); 00353 DecalProjector = none; 00354 } 00355 DecalProjectorClass = Class'XIII.BulletScorch'; 00356 ImpactEmitterMem = class'BulletDustEmitter'; 00357 break; 00358 case "ImpGra": 00359 // Gravel type 00360 if ( (DecalProjector != none) && (DecalProjector.Class != Class'XIII.BulletScorch') ) 00361 { 00362 DecalProjector.LifeSpan = 2.0+fRand(); 00363 DecalProjector = none; 00364 } 00365 DecalProjectorClass = Class'XIII.BulletScorch'; 00366 ImpactEmitterMem = class'GravelDustEmitter'; 00367 break; 00368 case "ImpBoiC": 00369 case "ImpBoiP": 00370 case "ImpPar": 00371 case "ImpFeu": 00372 // Wood type 00373 if ( (DecalProjector != none) && (DecalProjector.Class != Class'XIII.BulletScorchWood') ) 00374 { 00375 DecalProjector.LifeSpan = 2.0+fRand(); 00376 DecalProjector = none; 00377 } 00378 DecalProjectorClass = Class'XIII.BulletScorchWood'; 00379 ImpactEmitterMem = class'WoodDustEmitter'; 00380 break; 00381 case "ImpEau": 00382 // Water type (should not happen but maybe....) 00383 if ( (DecalProjector != none) && (DecalProjector.Class != Class'XIII.BulletScorch') ) 00384 { 00385 DecalProjector.LifeSpan = 2.0+fRand(); 00386 DecalProjector = none; 00387 } 00388 DecalProjectorClass = Class'XIII.BulletScorch'; 00389 ImpactEmitterMem = class'BulletDustEmitter'; 00390 break; 00391 case "ImpGla": 00392 case "ImpVer": 00393 // Glass type 00394 if ( (DecalProjector != none) && (DecalProjector.Class != Class'XIII.BulletScorchGlass') ) 00395 { 00396 DecalProjector.LifeSpan = 2.0+fRand(); 00397 DecalProjector = none; 00398 } 00399 DecalProjectorClass = Class'XIII.BulletScorchGlass'; 00400 ImpactEmitterMem = class'GlassImpactEmitter'; 00401 break; 00402 case "ImpGri": 00403 case "ImpMet": 00404 case "ImpTol": 00405 // Metal type 00406 if ( (DecalProjector != none) && (DecalProjector.Class != Class'XIII.BulletScorchMetal') ) 00407 { 00408 DecalProjector.LifeSpan = 2.0+fRand(); 00409 DecalProjector = none; 00410 } 00411 DecalProjectorClass = Class'XIII.BulletScorchMetal'; 00412 ImpactEmitterMem = class'BulletMetalEmitter'; 00413 break; 00414 case "ImpHrb": 00415 // Grass Type 00416 if ( DecalProjector != none ) 00417 DecalProjector.LifeSpan = 2.0+fRand(); 00418 DecalProjector = none; 00419 DecalProjectorClass = none; 00420 ImpactEmitterMem = class'GrassDustEmitter'; 00421 break; 00422 case "ImpTer": 00423 // Earth type 00424 if ( (DecalProjector != none) && (DecalProjector.Class != Class'XIII.BulletScorch') ) 00425 { 00426 DecalProjector.LifeSpan = 2.0+fRand(); 00427 DecalProjector = none; 00428 } 00429 DecalProjectorClass = Class'XIII.BulletScorch'; 00430 ImpactEmitterMem = class'EarthDustEmitter'; 00431 break; 00432 case "ImpNei": 00433 // Snow 00434 if ( DecalProjector != none ) 00435 DecalProjector.LifeSpan = 2.0+fRand(); 00436 DecalProjector = none; 00437 DecalProjectorClass = none; 00438 ImpactEmitterMem = class'SnowDustEmitter'; 00439 break; 00440 case "ImpMol": 00441 case "ImpMoq": 00442 // Soft Types 00443 if ( DecalProjector != none ) 00444 DecalProjector.LifeSpan = 2.0+fRand(); 00445 DecalProjector = none; 00446 DecalProjectorClass = Class'XIII.BulletScorch'; 00447 ImpactEmitterMem = class'MoqDustEmitter'; 00448 break; 00449 case "ImpCdvr": 00450 // Body Type 00451 if ( (DecalProjector != none) && (DecalProjector.Class != Class'XIII.BulletScorchMetal') ) 00452 { 00453 DecalProjector.LifeSpan = 2.0+fRand(); 00454 DecalProjector = none; 00455 } 00456 DecalProjectorClass = Class'XIII.BulletScorchMetal'; 00457 ImpactEmitterMem = class'BloodShotEmitter'; 00458 break; 00459 case "ImpLin": 00460 default: 00461 // other types, not spawn any SFX 00462 if ( (DecalProjector != none) && (DecalProjector.Class != Class'XIII.BulletScorch') ) 00463 { 00464 DecalProjector.LifeSpan = 2.0+fRand(); 00465 DecalProjector = none; 00466 } 00467 DecalProjectorClass = Class'XIII.BulletScorch'; 00468 ImpactEmitterMem = class'BulletDustEmitter'; 00469 break; 00470 } 00471 } 00472 00473 00474 //,ImpactEmitterMem=class'BulletDustEmitter',DecalProjector=Class'XIII.BulletScorch', 00475 00476 00477 defaultproperties 00478 { 00479 Impacts(0)=(NumberOfImpacts=16,ImpactNoise=0.500000,BulletsInterval=0.100000) 00480 ExtraTraceDistance=100.000000 00481 Dispersion=100.000000 00482 TraceClass=Class'XIII.BulletTrail' 00483 Texture=Texture'Engine.S_Weapon' 00484 }

End Source Code