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

Gameplay.ActionSpawnRook


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
class ActionSpawnRook extends Scripting.Action;

var() actionnoresolve class<Rook> spawnClass;
var() name rookLabel;
var() name teamLabel;
var() name squadLabel;
var() actionnoresolve vector rookLocation "Used as the spawn location if locationByActor is empty";
var() actionnoresolve rotator rookRotation "Used as the spawn rotation if locationByActor is empty";
var() name locationByActor "Spawn at the location and with the rotation of the specified actor";
var() float spawnInterval;
var() int maxSpawnAttempts;

// execute
latent function Variable execute()
{
	local VariableBool result;
	local Actor locationActor;
	local Vector location;
	local Rotator rotation;
	local Rook newRook;
	local TeamInfo rooksTeam;
	local SquadInfo rooksSquad;
	local int spawnAttempts;

	super.execute();

	result = VariableBool(newTemporaryVariable(class'VariableBool', "false"));

	// Determine spawn location
	if (locationByActor != '')
	{
		locationActor = findStaticByLabel(class'Actor', locationByActor);

		if (locationActor != None)
		{
			location = locationActor.Location;
			rotation = locationActor.Rotation;
		}
		else
		{
			SLog("Failed to find actor " $ locationByActor);
			return result;
		}
	}
	else
	{
		location = rookLocation;
		rotation = rookRotation;
	}

	for (spawnAttempts = 0; spawnAttempts < maxSpawnAttempts; ++spawnAttempts)
	{
		newRook = parentScript.Spawn(spawnClass,,, location, rotation);

		if (newRook != None)
			break;

		Sleep(spawnInterval);
	}

	if (newRook == None)
	{
		logError("Failed to spawn a new " $ spawnClass.name);
		return result;
	}

	if (rookLabel != '')
		newRook.label = rookLabel;

	if (teamLabel != '')
	{
		rooksTeam = TeamInfo(findByLabel(class'TeamInfo', teamLabel));

		if (rooksTeam != None)
			newRook.setTeam(rooksTeam);
		else
			SLog("Couldn't find team " $ teamLabel);
	}

	if (squadLabel != '')
	{
		rooksSquad = SquadInfo(findByLabel(class'SquadInfo', squadLabel));

		if (rooksSquad != None)
			newRook.setSquad(rooksSquad);
		else
			SLog("Couldn't find squad " $ squadLabel);
	}

	result.value = true;

	return result;
}

// editorDisplayString
function editorDisplayString(out string s)
{
	s = "Spawn ";

	if (spawnClass != None)
	{
		s = s $ spawnClass.name $ " at ";

		if (locationByActor != '')
			s = s $ propertyDisplayString('locationByActor');
		else
			s = s $ "(" $ rookLocation.x $ "," $ rookLocation.y $ "," $ rookLocation.z $ ")";

		if (teamLabel != '')
			s = s $ ", on team " $ propertyDisplayString('teamLabel');

		if (squadLabel != '')
			s = s $ ", in squad " $ propertyDisplayString('squadLabel');
	}
	else
		s = s $ "None";
}

defaultproperties
{
	spawnInterval		= 0.0
	maxSpawnAttempts	= 1

	returnType			= class'Variable'
	actionDisplayName	= "Spawn Rook"
	actionHelp			= "Spawn an actor derived from Rook."
	category			= "Actor"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 15:53:24.000 - Creation time: st 23.5.2018 00:10:40.635 - Created with UnCodeX