Code: Select all
Class TakkraBeamEmitter extends XBeamEmitter
Transient;
#exec TEXTURE IMPORT NAME=FX_takkra_beam_002 FILE=MODELS\FX_takkra_beam_003.pcx GROUP=Effects
var float TraceDistance,MaxTraceDistance;
var Pawn RepOwner;
var vector RepHitLocation;
var float OldError, NewError, StartError, AimError; //used for bot aiming
var rotator AimRotation;
var transient Actor StarterEffect;
simulated function Tick(float Delta)
{
local vector Start, End;
local float BeamLengthFactor;
// Ensure TraceDistance doesn't exceed MaxTraceDistance
if (TraceDistance < MaxTraceDistance)
TraceDistance = FMin(TraceDistance + Delta * MaxTraceDistance * 8.f, MaxTraceDistance);
if (Level.NetMode == NM_Client)
{
bHidden = (RepOwner == None);
if (bHidden)
return;
Start = Instigator.Location;
End = BeamTarget[0].TargetActor.Location;
SetRotation(rotator(End - Start));
}
if (Level.NetMode == NM_DedicatedServer)
{
SetLocation(Start);
return;
}
// Calculate the distance between the start and end points
BeamLengthFactor = VSize(End - Location) / MaxTraceDistance; // Fraction of MaxTraceDistance
// Adjust BeamLengthFactor for close distances to prevent the beam from being too long
if (BeamLengthFactor < 0.2) // This will adjust the beam when it's up close
{
BeamLengthFactor = FMax(BeamLengthFactor, 0.2); // Ensure the beam doesn't shrink too much
}
// Set BoxVelocity based on the adjusted BeamLengthFactor
BoxVelocity.X.Min = BeamLengthFactor * MaxTraceDistance; // Simplified scaling
BoxVelocity.X.Max = BoxVelocity.X.Min * 0.5; // Keep Max as a smaller fraction for variation
}
defaultproperties
{
MaxTraceDistance=700.000000
Segments=1
MaxParticles=1
LifetimeRange=(Min=0.300000,Max=0.400000)
ParticleTextures(0)=Texture'U2Weapons.Effects.FX_takkra_beam_002'
FadeInTime=0.100000
FadeOutTime=0.500000
StartingScale=(Min=6.000000,Max=8.000000)
BoxVelocity=(X=(Min=0.000000,Max=0.000000))
bUseRelativeLocation=True
RemoteRole=ROLE_SimulatedProxy
bSkipActorReplication=True
//BeamTargetType=BEAM_Offset
LifeSpan=0.4
//BeamTarget(0)=(Offset=(X=0.000000,Y=0.000000,Z=0.000000))
}