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

Onslaught.ONSAVRiLAltFire


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
// AVRiL alternate fire. Slight zoom and auto-tracking of target
class ONSAVRiLAltFire extends WeaponFire;

var ONSAVRiL Gun;
var float ZoomLevel;
var bool bWaitingForRelease;
var bool bLosingLock;
var float LostLockTime;

function PostBeginPlay()
{
    Super.PostBeginPlay();

    Gun = ONSAVRiL(Weapon);
}

simulated function bool AllowFire()
{
    //return (Gun != None && Gun.bLockedOn && PlayerController(Instigator.Controller) != None);
    if (bWaitingForRelease || Gun == None || !Gun.bLockedOn || PlayerController(Instigator.Controller) == None)
    {
        bWaitingForRelease = true;
        return false;
    }
    else
        return true;

}

function StopFiring()
{
    if (PlayerController(Instigator.Controller) != None)
    {
        ZoomLevel = 0.0;
        PlayerController(Instigator.Controller).DesiredFOV = PlayerController(Instigator.Controller).DefaultFOV;
        bLosingLock = false;
    }
}

function PlayFiring() {}

function ModeTick(float deltaTime)
{
    local vector LockTrace;
    local Actor AlternateTarget;

    //Hack - force player to actually press button to start fire (so can't hold down button and sweep crosshair in the vicinity of targets)
    if (bWaitingForRelease && PlayerController(Instigator.Controller).bAltFire == 0)
        bWaitingForRelease = false;

    if (!bIsFiring)
        return;

    if (!Gun.bLockedOn || Gun.HomingTarget == None)
    {
        if (!bLosingLock)
        {
            bLosingLock = true;
            LostLockTime = Level.TimeSeconds;
            if (Instigator.IsLocallyControlled())
                Instigator.PlaySound(Sound'WeaponSounds.BSeekLost1');
        }
        else if (Level.TimeSeconds > LostLockTime + 1.5)
        {
            Gun.StopFire(1);
            return;
        }
    }
    else if (bLosingLock)
        bLosingLock = false;

    //Custom zooming because we don't want quite as much as normal sniper zoom does
    ZoomLevel += deltaTime;
    if (ZoomLevel > 0.60)
        ZoomLevel = 0.60;
    PlayerController(Instigator.Controller).DesiredFOV = FClamp(90.0 - (ZoomLevel * 88.0), 1, 170);

    if (!bLosingLock && Instigator.IsLocallyControlled())
    {
        // Are we aimed at the HomingTarget or an AlternateTarget...
        AlternateTarget = Gun.HomingTarget.AlternateTarget();
        if (AlternateTarget != None)
        {
            LockTrace = AlternateTarget.Location - (Instigator.Location + Instigator.EyePosition());

            if ((Normal(LockTrace) dot Vector(Instigator.GetViewRotation())) > Gun.LockAim && VSize(LockTrace) < Gun.MaxLockRange)
            {
                Instigator.Controller.SetRotation(rotator(AlternateTarget.Location - Instigator.Location));
                return;
            }
        }
        Instigator.Controller.SetRotation(rotator(Gun.HomingTarget.Location - Instigator.Location));
    }
}

defaultproperties
{
     bModeExclusive=False
     FireRate=0.100000
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Wed 7/2/2007 19:12:22.000 - Creation time: Wed 7/2/2007 19:16:45.937 - Created with UnCodeX