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

DruidsRPGcvs.AbilityVehicleEject


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
class AbilityVehicleEject extends RPGDeathAbility
    abstract
    config(UT2004RPG);

var config int BigSeconds;

static simulated function int Cost(RPGPlayerDataObject Data, int CurrentLevel)
{
    local int x;
    local bool engineer;

    if(CurrentLevel == 0)
        return super.Cost(Data, CurrentLevel);
    else
    {
        for (x = 0; x < Data.Abilities.length && !engineer; x++)
            if (Data.Abilities[x] == class'ClassEngineer')
                engineer = true;
                
        if(engineer)
            return super.Cost(Data, CurrentLevel);
        else
            return 0;
    }
}

static function bool PrePreventDeath(Pawn Killed, Controller Killer, class<DamageType> DamageType, vector HitLocation, int AbilityLevel)
{
    Local Pawn Driver;
    Local Vehicle Vehicle;
    Local EjectedInv ejected;
    Local bool DestroyVehicle;
    Local bool SavedPlayer;
    
    destroyVehicle = false;

    Vehicle = Vehicle(Killed);
    if(Vehicle == None)
    {
        //Ok, so if they actually died in a vehicle, we're going to kick them out with one health and save them -- Dru
        if (Killed.DrivenVehicle != None)
        {
            Driver = Killed;
            Vehicle = Killed.DrivenVehicle;
            //now blow up the vehicle in a moment, since it's taking the fall for the player
            DestroyVehicle = true;
            //this is the only case where we actually save the player from death.
            SavedPlayer = true;
            
            //continue execution as normal.
        }       
        else
            return false;
    }
    else    
        Driver = Vehicle.Driver;

    if(Driver == None)
        return false; //no driver <shrug>
        
    //here we go.
    ejected =  EjectedInv(Driver.FindInventoryType(class'EjectedInv'));
    if(ejected != None)
        return false; //still active ejection
        
    if(Driver.Health <= 0)
        Driver.Health = 1; //The player was about to die, so they need some health

    if(Vehicle.EjectMomentum <= 0) //make sure the vehicle has some eject momentum.
        Vehicle.EjectMomentum = class'ONSHoverBike'.default.EjectMomentum;

    Vehicle.EjectDriver(); //they're out! Yeehaw!!
    
    ejected = Driver.spawn(class'EjectedInv', Driver,,, rot(0,0,0));
    ejected.lifespan = default.BigSeconds/AbilityLevel;
    ejected.GiveTo(Driver);
                    
    if(SavedPlayer)
        return true;
    else
        return false; //I know this sounds strange, but we aren't preventing the death of the vehicle. We just ejected the driver instead.
}

defaultproperties
{
    BigSeconds=120
    AbilityName="Vehicle Ejector Button"
    Description="You will be automatically ejected from a destroyed vehicle. Depending upon your level of this skill, it will activate once every 120, 60, 40, or 30 seconds.|(Max Level: 1, Max Engineer Level: 4)|Cost (per level): 5,10,15,20"
    MaxLevel=4
    StartingCost=5
    CostAddPerLevel=5
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Wed 1/11/2006 15:32:48.000 - Creation time: Wed 7/2/2007 19:16:32.312 - Created with UnCodeX