Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

# Gameplay.EmergencyStationAccess

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

    ///////////////////////////////////////////////////////////////////////////////
    //
    // Emergency Station Access point
    //
    class EmergencyStationAccess extends UseableObject;

    var() localized String AlreadyHavePackPrompt;

    var private EmergencyStation emergencyStation;

    function initialise(EmergencyStation station)
    {
    	emergencyStation = station;
    }

    //
    // Called to check if the UseableObject can be used
    // by a specific actor.
    //
    function bool CanBeUsedBy(Pawn user)
    {
    	local RepairPack repairPack;

    	if(user.IsA('Character') && emergencyStation.isOnCharactersTeam(Character(user)) && emergencyStation.isRepairPackAvailable())
    	{
    		repairPack = RepairPack(Character(user).nextEquipment(None, class'Pack'));
    		if(repairPack == None)
    			return true;
    	}

    	return false;
    }

    function byte GetPromptIndex(Character PotentialUser)
    {
    	local RepairPack repairPack;

    	if(CanBeUsedBy(PotentialUser))
    		return 0;		// standard use message
    	else
    	{
    		repairPack = RepairPack(PotentialUser.nextEquipment(None, class'Pack'));
    		if(repairPack != None)
    			return 1;	// "already have pack" message
    	}

    	return 255;
    }

    // returns a prompt string based on the prompt index
    static function string GetPrompt(byte PromptIndex, class<Actor> dataClass)
    {
    	switch(promptIndex)
    	{
    	case 0:
    		return default.prompt;
    	case 1:
    		return default.AlreadyHavePackPrompt;
    	}

    	return "";
    }

    // Called on server when user presses use key in vicinity of emergency station.
    function UsedBy(Pawn user)
    {
    	local Character characterUser;
    	local Pack pack;
    	local Vector DropLocation, xAxis, zAxis;

    	characterUser = Character(user);

    	// do nothing if used by non-character
    	if(characterUser == None)
    		return;

    	// if an enemy do nothing
    	if(! emergencyStation.isOnCharactersTeam(characterUser))
    	{
    		log("Attempted To Use Enemy Emergency Station");
    		return;
    	}

    	//
    	// Give the user an emergency repair pack. We need to force them to drop
    	// an existing pack if they have no space for one
    	//
    	pack = Pack(characterUser.nextEquipment(None, class'Pack'));
    	if(pack != None)
    	{
    		if(pack.IsA('RepairPack'))
    			return;
    		else
    		{
    			emergencyStation.GetAxes(rotation, xAxis, DropLocation, zAxis);
    			DropLocation *= 260;
    			DropLocation += emergencyStation.Location;
    			pack.GotoState('Dropped');
    			pack.Move(DropLocation - pack.Location);
    			characterUser.removeEquipment(pack);
    		}
    	}
    	//
    	// Let emergency station know.
    	//
    	emergencyStation.repairPackTaken();

    	if(emergencyStation.repairPackClass != None)
    	{
    		characterUser.newPack(emergencyStation.repairPackClass);
    		characterUser.pack.setCharged();
    	}
    	else
    		log("WARNING: Repair pack class is none for "$emergencyStation);

    	// we do the super.usedby last so that the useable indicator will update properly
    	super.UsedBy(user);
    }

    defaultproperties
    {
    	RemoteRole = ROLE_None

    	prompt = "Press '%1' to use the Emergency Station"
    	AlreadyHavePackPrompt = "You already have a Repair Pack"
    	markerOffset = (X=0,Y=-40,Z=0)
    }

Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

Class file time: ne 5.9.2004 15:53:20.000 - Creation time: st 23.5.2018 00:10:43.242 - Created with UnCodeX