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

DruidsRPGcvs.ArtifactRepulsion


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
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
class ArtifactRepulsion extends RPGArtifact
        config(UT2004RPG);

var config int AdrenalineRequired;
var config float BlastRadius;
var config float MaxKnockbackTime;
var config float MaxKnockbackMomentum;
var config float MinKnockbackMomentum;

var Sound KnockbackSound;
var Material KnockbackOverlay;

function BotConsider()
{
    if (Instigator.Controller.Adrenaline < AdrenalineRequired)
        return;

    if ( !bActive && Instigator.Controller.Enemy != None
           && Instigator.Controller.CanSee(Instigator.Controller.Enemy) && NoArtifactsActive() && FRand() < 0.5 )
        Activate();
}

function PostBeginPlay()
{
    super.PostBeginPlay();
    disable('Tick');
}

function Activate()
{
    local float dist, KnockbackScale, KnockbackAmount;
    local vector dir;
    local Controller C, NextC;
    Local KnockbackInv InvKnock;
    Local Vector newLocation;
    local Vehicle V;

    if (Instigator == None)
        return;

    if(Instigator.Controller.Adrenaline < AdrenalineRequired)
    {
        Instigator.ReceiveLocalizedMessage(MessageClass, AdrenalineRequired, None, None, Class);
        bActive = false;
        GotoState('');
        return;
    }
        
    V = Vehicle(Instigator);
    if (V != None )
    {
        Instigator.ReceiveLocalizedMessage(MessageClass, 3000, None, None, Class);
        bActive = false;
        GotoState('');
        return; // can't use in a vehicle
    }

    spawn(class'RepulsionExplosion', Instigator.Controller,,Instigator.Location);
    C = Level.ControllerList;
    while (C != None)
    {
        // loop round finding strongest enemy to attack
        NextC = C.NextController;
        if ( C.Pawn != None && C.Pawn != Instigator && C.Pawn.Health > 0 && !C.SameTeamAs(Instigator.Controller)
             && VSize(C.Pawn.Location - Instigator.Location) < BlastRadius && FastTrace(C.Pawn.Location, Instigator.Location) && !C.Pawn.isA('Vehicle'))
        {
            if (class'RW_Freeze'.static.canTriggerPhysics(C.Pawn) 
                && (C.Pawn.FindInventoryType(class'NullEntropyInv') == None))
            {
                if (C.Pawn.FindInventoryType(class'KnockbackInv') == None)
                {
                    InvKnock = spawn(class'KnockbackInv', C.Pawn,,, rot(0,0,0));
                    if(InvKnock != None)
                    {
                        dir = C.Pawn.Location - Instigator.Location;
                        dist = FMax(1,VSize(dir));
                        dir = dir/dist;
                        KnockbackScale = 1 - FMax(0,dist/BlastRadius);

                        // if they're not walking, falling, or hovering, 
                        // the momentum won't affect them correctly, so make them hover.
                        // this effect will end when the KnockbackInv expires.
                        if(C.Pawn.Physics != PHYS_Walking && C.Pawn.Physics != PHYS_Falling && C.Pawn.Physics != PHYS_Hovering)
                            C.Pawn.SetPhysics(PHYS_Hovering);

                        // if they're walking, I need to bump them up 
                        // in the air a bit or they won't be knocked back 
                        // on no momentum weapons.
                        if(C.Pawn.Physics == PHYS_Walking)
                        {
                            newLocation = C.Pawn.Location;
                            newLocation.z += 10;
                            C.Pawn.SetLocation(newLocation);
                        }
                        KnockbackAmount = (KnockbackScale*(MaxKnockbackMomentum-MinKnockbackMomentum)) + MinKnockbackMomentum;
                        // set to take 1 damage for the slap in the face, and pass on momentum
                        // using takedamage also means instigator gets the points if the push kills the victim
                        C.Pawn.TakeDamage(1, Instigator, C.Pawn.Location, KnockbackAmount*dir*0.8*C.Pawn.Mass, class'Fell');

                        InvKnock.LifeSpan = (KnockbackScale*(MaxKnockbackTime-1))+1;
                        InvKnock.Modifier = 4;
                        InvKnock.GiveTo(C.Pawn);
                        C.Pawn.SetOverlayMaterial(KnockbackOverlay, 1.0, false);
                        if(PlayerController(C) != None)
                            PlayerController(C).ReceiveLocalizedMessage(class'KnockbackConditionMessage', 0);
                        C.Pawn.PlaySound(KnockbackSound,,1.5 * C.Pawn.TransientSoundVolume,,C.Pawn.TransientSoundRadius);
                    }
                }
            }
        }
        C = NextC;
    }
    Instigator.Controller.Adrenaline -= AdrenalineRequired;
    if (Instigator.Controller.Adrenaline < 0)
        Instigator.Controller.Adrenaline = 0;
}

exec function TossArtifact()
{
    //do nothing. This artifact cant be thrown
}

function DropFrom(vector StartLocation)
{
    if (bActive)
        GotoState('');
    bActive = false;

    Destroy();
    Instigator.NextItem();
}

static function string GetLocalString(optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2)
{
    if (Switch == 3000)
        return "Cannot use this artifact inside a vehicle";
    else
        return switch @ "Adrenaline is required to use this artifact";
}

defaultproperties
{
     CostPerSec=1
     MinActivationTime=0.000001
     BlastRadius=2500.000000
     MaxKnockbackMomentum=3000.0
     MinKnockbackMomentum=1000.0
     MaxKnockbackTime=5.0
     AdrenalineRequired=50
     PickupClass=Class'ArtifactRepulsionPickup'
     KnockbackSound=Sound'WeaponSounds.Misc.ballgun_launch'
     KnockbackOverlay=Shader'DruidsRPGShaders1.DomShaders.PulseRedShader'
     IconMaterial=Texture'XGame.Water.xCausticRing2'
     ItemName="Repulsion"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Sat 30/9/2006 20:30:50.000 - Creation time: Wed 7/2/2007 19:16:33.750 - Created with UnCodeX