KF2-Server-Extension/ServerExt/Classes/ExtProj_CrackerGrenade.uc

100 lines
2.8 KiB
Ucode
Raw Permalink Normal View History

2017-10-20 02:00:49 +00:00
// Written by Marco.
class ExtProj_CrackerGrenade extends KFProj_FragGrenade
hidedropdown;
var() byte NumCrackers;
simulated function PostBeginPlay()
{
Super.PostBeginPlay();
SetTimer(FuseTime+FRand()*0.25, true, 'ExplodeTimer');
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function ExplodeTimer()
{
2020-11-28 19:53:57 +00:00
local Actor HitActor;
local vector HitLocation, HitNormal;
2017-10-20 02:00:49 +00:00
2020-11-28 20:12:58 +00:00
if (WorldInfo.NetMode!=NM_Client && InstigatorController==none)
2017-10-20 02:00:49 +00:00
{
Destroy();
return;
}
2020-11-28 19:53:57 +00:00
GetExplodeEffectLocation(HitLocation, HitNormal, HitActor);
2020-11-28 20:12:58 +00:00
if (--NumCrackers==0)
2017-10-20 02:00:49 +00:00
TriggerExplosion(HitLocation, HitNormal, HitActor);
else SmallExplosion(HitLocation, HitNormal, HitActor);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function SmallExplosion(Vector HitLocation, Vector HitNormal, Actor HitActor)
{
local vector NudgedHitLocation, ExplosionDirection;
Velocity = VRand()*(900.f*FRand());
SetPhysics(PHYS_Falling);
if (ExplosionTemplate != None)
{
// using a hitlocation slightly away from the impact point is nice for certain things
NudgedHitLocation = HitLocation + (HitNormal * 32.f);
ExplosionActor = Spawn(ExplosionActorClass, self,, NudgedHitLocation, rotator(HitNormal));
if (ExplosionActor != None)
{
ExplosionActor.RemoteRole = ROLE_None;
ExplosionActor.Instigator = Instigator;
ExplosionActor.InstigatorController = InstigatorController;
PrepareExplosionTemplate();
// If the locations are zero (probably because this exploded in the air) set defaults
2020-11-28 20:12:58 +00:00
if (IsZero(HitLocation))
2017-10-20 02:00:49 +00:00
HitLocation = Location;
2020-11-28 20:12:58 +00:00
if (IsZero(HitNormal))
2017-10-20 02:00:49 +00:00
{
HitNormal = vect(0,0,1);
}
// these are needed for the decal tracing later in GameExplosionActor.Explode()
ExplosionTemplate.HitActor = HitActor;
ExplosionTemplate.HitLocation = HitLocation;// NudgedHitLocation
ExplosionTemplate.HitNormal = HitNormal;
// If desired, attach to mover if we hit one
2020-11-28 20:12:58 +00:00
if (bAttachExplosionToHitMover && InterpActor(HitActor) != None)
2017-10-20 02:00:49 +00:00
{
ExplosionActor.Attachee = HitActor;
ExplosionTemplate.bAttachExplosionEmitterToAttachee = TRUE;
ExplosionActor.SetBase(HitActor);
}
// directional?
if (ExplosionTemplate.bDirectionalExplosion)
{
ExplosionDirection = GetExplosionDirection(HitNormal);
//DrawDebugLine(ExplosionActor.Location, ExplosionActor.Location+ExplosionDirection*64, 255, 255, 0, TRUE);
}
// @todo: make this function responsible for setting explosion instance parameters, and take instance parameters
// out of GearExplosion (e.g. Attachee)
PrepareExplosionActor(ExplosionActor);
ExplosionActor.Explode(ExplosionTemplate, ExplosionDirection); // go bewm
}
}
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function ProcessTouch(Actor Other, Vector HitLocation, Vector HitNormal)
{
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
simulated function Explode(vector HitLocation, vector HitNormal);
defaultproperties
{
bCanDisintegrate=false
FuseTime=0.35
NumCrackers=6
bNetTemporary=true
2023-05-14 02:49:12 +00:00
}