Always snap to grid

Legacy:EONSGrenadeLauncher

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Status: Finished. Feel free to use code derived from this weapon, but please provide credit to me in the comments and/or ReadMe file of your new creation.

Description: The EONS Grenade Launcher is a modification of the UT2004 ONS Grenade Launcher intended to improve the weapon's usefulness in a variety of situations.

New Features:

1. Grenades fire on primary fire at a much higher velocity. Additionally, grenades fire roughly 15% faster, but do 15% less damage and have only 90% of the original blast radius.

2. Grenades explosions create electromagnetic interference capable of temporarily disabling a vehicle and ejecting its driver (if any). Light vehicles have a 50% chance to be disabled, Medium vehicles have a 25% chance to be disabled, and Heavy vehicles have a 10% chance to be disabled.

3. The secondary fire triggering mechanism has an improved rate of fire.

//========================================================================
// EONSGrenadeLauncher
// EONS Grenade Launcher written by Wail of Suicide
// Feel free to use this content in any maps you create, but please provide credit in the readme.
// Contact: wailofsuicide@gmail.com - Comments and suggestions welcome.
//========================================================================
 
class EONSGrenadeLauncher extends ONSGrenadeLauncher;
 
defaultproperties
{
 ItemName="EONS Grenade Launcher"
 Description="The EONS Grenade Launcher fires electro-magnetic grenades at high velocity, which will attach to enemy players and vehicles. The magnetic interference caused by an exploding EONS grenade has a chance of disabling vehicles and ejecting their drivers."
 InventoryGroup=3
 GroupOffset=10
 FireModeClass(0)=class'EONS-GrenadeLauncher_BETA1.EONSGrenadeLauncherFire'
 FireModeClass(1)=class'EONS-GrenadeLauncher_BETA1.EONSGrenadeLauncherAltFire'
 PickupClass=class'EONS-GrenadeLauncher_BETA1.EONSGrenadeLauncherPickup'
}
//========================================================================
// EONSGrenadeLauncherFire
// Enhanced Grenade Launcher written by Wail of Suicide 4/8/06
//========================================================================
 
class EONSGrenadeLauncherFire extends ONSGrenadeFire;
 
defaultproperties
{
 ProjectileClass=class'EONS-GrenadeLauncher_BETA1.EONSGrenadeProjectile'
 FireRate=0.55
}
//========================================================================
// EONSGrenadeProjectile
// Enhanced Grenade Launcher written by Wail of Suicide
//========================================================================
 
class EONSGrenadeProjectile extends ONSGrenadeProjectile;
 
#exec AUDIO IMPORT FILE="Sounds\GrenadeFloor.wav" NAME="GrenadeFloor" GROUP="GrenadeLauncher"
 
//Altered Explosion VFX
simulated function Destroyed()
{
    if ( Trail != None )
        Trail.mRegen = false; // stop the emitter from regenerating
    //explosion
    if ( !bNoFX )
    {
        if ( EffectIsRelevant(Location,false) )
        {
            Spawn(class'EONSGrenadeExplosionEffect',,, Location, rotator(vect(0,0,1)));
            Spawn(ExplosionDecal,self,, Location, rotator(vect(0,0,-1)));
        }
        PlaySound(Sound'WeaponSounds.ShockRifle.ShockComboFire',,3.75*TransientSoundVolume);
    }
    if ( EONSGrenadeLauncher(Owner) != None)
        EONSGrenadeLauncher(Owner).CurrentGrenades--;
 
    if ( Beacon != None )
        Beacon.Destroy();
 
    Super(Projectile).Destroyed();
}
 
//Changed Grenade Trail
simulated function PostBeginPlay()
{
    local PlayerController PC;
 
    Super(Projectile).PostBeginPlay();
 
    if ( Level.NetMode != NM_DedicatedServer)
    {
        PC = Level.GetLocalPlayerController();
        if ( (PC.ViewTarget != None) && VSize(PC.ViewTarget.Location - Location) < 5500 )
            Trail = Spawn(class'EONS-GrenadeLauncher_BETA1.EONSGrenadeSmokeTrail', self,, Location, Rotation);
    }
 
    Velocity = Speed * Vector(Rotation);
    RandSpin(25000);
    if (PhysicsVolume.bWaterVolume)
        Velocity = 0.6*Velocity;
 
    if (Role == ROLE_Authority && Instigator != None)
        Team = Instigator.GetTeamNum();
}
 
//Modified projectile bounce SFX volume
simulated function HitWall( vector HitNormal, actor Wall )
{
    local Vector VNorm;
    local PlayerController PC;
 
    if (Vehicle(Wall) != None)
    {
        Touch(Wall);
        return;
    }
 
    // Reflect off Wall w/damping
    VNorm = (Velocity dot HitNormal) * HitNormal;
    Velocity = -VNorm * DampenFactor + (Velocity - VNorm) * DampenFactorParallel;
 
    RandSpin(100000);
    Speed = VSize(Velocity);
 
    if ( Speed < 40 )
    {
        bBounce = False;
        SetPhysics(PHYS_None);
        if ( Trail != None )
            Trail.mRegen = false; // stop the emitter from regenerating
    }
    else
    {
        if ( (Level.NetMode != NM_DedicatedServer) && (Speed > 250) )
            PlaySound(ImpactSound, SLOT_Misc,7.5*TransientSoundVolume);
        if ( !Level.bDropDetail && (Level.DetailMode != DM_Low) && (Level.TimeSeconds - LastSparkTime > 0.5) && EffectIsRelevant(Location,false) )
        {
            PC = Level.GetLocalPlayerController();
            if ( (PC.ViewTarget != None) && VSize(PC.ViewTarget.Location - Location) < 2000 )
                Spawn(HitEffectClass,,, Location, Rotator(HitNormal));
            LastSparkTime = Level.TimeSeconds;
        }
    }
}
 
 
simulated function HurtRadius( float DamageAmount, float DamageRadius, class<DamageType> DamageType, float Momentum, vector HitLocation )
{
    local actor Victims;
    local float damageScale, dist;
    local vector dir;
    local float r;
 
    if ( bHurtEntry )
        return;
 
    bHurtEntry = true;
    foreach VisibleCollidingActors( class 'Actor', Victims, DamageRadius, HitLocation )
    {
        r = FRand();
 
        // don't let blast damage affect fluid - VisibleCollisingActors doesn't really work for them - jag
        if( (Victims != self) && (Hurtwall != Victims) && (Victims.Role == ROLE_Authority) && !Victims.IsA('FluidSurfaceInfo') )
        {
            dir = Victims.Location - HitLocation;
            dist = FMax(1,VSize(dir));
            dir = dir/dist;
            damageScale = 1 - FMax(0,(dist - Victims.CollisionRadius)/DamageRadius);
            if ( Instigator == None || Instigator.Controller == None )
                Victims.SetDelayedDamageInstigatorController( InstigatorController );
            if ( Victims == LastTouched )
                LastTouched = None;
            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);
 
            if ( r > 0.50 && (Vehicle(Victims) != None)
               && (Pawn(Victims).GetTeamNum() != Instigator.Controller.GetTeamNum())
               && ( Vehicle(Victims).IsA('ONSHoverBike')
               || Vehicle(Victims).IsA('ONSAttackCraft')
               || Vehicle(Victims).IsA('ONSDualAttackCraft') ) )
                  Vehicle(Victims).EjectDriver();
            if ( r > 0.75 && (Vehicle(Victims) != None)
               && (Pawn(Victims).GetTeamNum() != Instigator.Controller.GetTeamNum())
               && ( Vehicle(Victims).IsA('ONSRV')
               || Vehicle(Victims).IsA('ONSPRV')
               || Vehicle(Victims).IsA('ONSArtillery') ) )
                  Vehicle(Victims).EjectDriver();
            if ( r > 0.90 && (Vehicle(Victims) != None)
               && (Pawn(Victims).GetTeamNum() != Instigator.Controller.GetTeamNum())
               && ( Vehicle(Victims).IsA('ONSHoverTank')
               || Vehicle(Victims).IsA('ONSShockTank')
               || Vehicle(Victims).IsA('ONSStationaryWeaponPawn')
               || Vehicle(Victims).IsA('ONSVehicle') ) )
                  Vehicle(Victims).EjectDriver();
 
        }
    }
    if ( (LastTouched != None) && (LastTouched != self) && (LastTouched.Role == ROLE_Authority) && !LastTouched.IsA('FluidSurfaceInfo') )
    {
        Victims = LastTouched;
        LastTouched = None;
        dir = Victims.Location - HitLocation;
        dist = FMax(1,VSize(dir));
        dir = dir/dist;
        damageScale = FMax(Victims.CollisionRadius/(Victims.CollisionRadius + Victims.CollisionHeight),1 - FMax(0,(dist - Victims.CollisionRadius)/DamageRadius));
        if ( Instigator == None || Instigator.Controller == None )
            Victims.SetDelayedDamageInstigatorController(InstigatorController);
        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, InstigatorController, DamageType, Momentum, HitLocation);
    }
 
    bHurtEntry = false;
}
 
simulated function BlowUp(vector HitLocation)
{
    HurtRadius(Damage,DamageRadius, MyDamageType, MomentumTransfer, HitLocation );
    if ( Role == ROLE_Authority )
        MakeNoise(1.0);
}
 
 
defaultproperties
{
 MyDamageType=class'EONS-GrenadeLauncher_BETA1.DamTypeEONSGrenadeProjectile'
 
 Damage=85.00
 DamageRadius=155.0
 Speed=1800
 MaxSpeed=4000
 
 ImpactSound=Sound'EONS-GrenadeLauncher_BETA1.GrenadeFloor'
}