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

U2.PowerUpPickup


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
class PowerUpPickup extends Pickup
	abstract;

#exec OBJ LOAD FILE=..\Sounds\U2A.uax

var() int       EnergyUnits;      // A pickup or station's number of EnergyUnits
var() int       HealthUnits;      // A pickup or station's number of HealthUnits
var() int       TransferRate;     // The rate at which the units are passed to the PowerSuit or Player
							      // in terms of x units per second.
var() bool      bIsPickup;        // True if object is a pickup
var() bool      bIsStation;       // True if object is a station
var() string    Description;	  // Popup description of this PowerUp
var() Mesh      PickupMesh;       // A pickup's mesh
var() Mesh      StationMesh;      // A station's mesh
var() Texture   PickupTexture;    // A pickup's texture

//-----------------------------------------------------------------------------
// If the bot does not have a PowerSuit he will ignore all PowerUps, otherwise,
// set desire to the difference between the maxunits and current units.

function float BotDesireability(Pawn P)
{
    local float		desire;
    local int		HealMax;
	local int		Power;
	local int		MaxPower;
	local PowerSuit	PS;

	if( HealthUnits > 0 )
	{
		HealMax = P.default.Health;
		desire = Min( HealthUnits, HealMax - P.Health );
	}
	else
	{
		// expensive call - don't do this unless needed
		PS = PowerSuit(P.FindInventoryType( class'PowerSuit' ));

		if( PS != None )
		{
			if( EnergyUnits > 0 )
			{
				MaxPower = int(PS.MaxPower);
				Power = int(PS.Power);
				desire = Min( EnergyUnits, MaxPower - Power );
			}
		}
		else
		{
			desire = -1;
		}
	}	

	// (mdf): Answer: in general the returned desireability should be between 0
	// and 1. Afaict from looking at the engine code you can return larger values 
	// if you want but you need to make sure that you set MaxDesireability to match
	// the largest value that you might return or this code may never get called.
	// But, with large values, bots will completely ignore closer inventory and
	// run all the way across a level to get to an item so its probably best to
	// limit these to 0..1 in general.
	//
	// For now I set MaxDesireability to 1 (wag) which might do the trick. This 
	// isn't an issue at this point since dm is dead -- ideally we'd spend some
	// time trying to determine a MaxDesireability that works.
	
	// Scale health depending on how badly it is needed.
    if( P.Health < 45 )
	{
		desire = FMin( 0.03 * desire, 2.2 );
	}
    else
    {
		if( desire > 6 )
		{
			desire = FMax( desire, 25 );
		}
		else
		{
			desire = FMin( 0.017 * desire, 2.0 ); 
		}
    }

	return desire;
}

//-----------------------------------------------------------------------------

function AnnouncePickup( Pawn Receiver )
{
	if( Receiver != None && Receiver.IsRealPlayer() )
		class'UIConsole'.static.BroadcastStatusMessage( Self, PickupMessage );
	Super.AnnouncePickup( Receiver );
}

//-----------------------------------------------------------------------------

function inventory SpawnCopy( pawn Other )
{
	local inventory Copy;

	if ( Inventory != None )
	{
		Copy = Inventory;
		Inventory = None;
	}
	else
		Copy = spawn(InventoryType,Other,,,rot(0,0,0));

	Copy.TransferProperties( self );
	Copy.GiveTo( Other );

	return Copy;
}

//-----------------------------------------------------------------------------

auto state Pickup
{
	function bool ValidTouch( actor Other )
	{
		if( Pawn(Other) == None || PowerSuit(class'UtilGame'.static.GetInventoryItem( Pawn(Other), class'PowerSuit' )) == None || bIsStation == true )
		{
			// You should be able to get health whether you have a PowerSuit or not
			if( HealthUnits > 0 && !bIsStation )
			{
				return Super.ValidTouch( Other );
			}
			else
				return false;
		}
		return Super.ValidTouch( Other );
	}
}

//-----------------------------------------------------------------------------

defaultproperties
{
	MaxDesireability=1.000000
	AmbientGlow=64
     UseReticleOnEvents(0)="UseReticleText"
     UseReticleOnEvents(1)="UseReticleCorners"
     UseReticleOnEvents(2)="UseReticleTopBars"
     ProximityReticleOnEvents(0)="ProximityReticleCorners"
     ProximityReticleOnEvents(1)="ProximityReticleTopBars"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: sk 3-1-2016 10:38:42.000 - Creation time: sk 3-1-2016 10:48:41.081 - Created with UnCodeX