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

Scripting.ActionSpawnActor


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
class ActionSpawnActor extends Action;

var() actionnoresolve class<Actor> spawnClass;
var() name actorLabel;
var() actionnoresolve vector actorLocation "Used as the spawn location if locationByActor is empty";
var() actionnoresolve rotator actorRotation "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 int spawnAttempts;
	local Actor newActor;

	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 = actorLocation;
		rotation = actorRotation;
	}

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

		if (newActor != None)
			break;

		Sleep(spawnInterval);
	}

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

	if (actorLabel != '')
		newActor.label = actorLabel;

	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 $ "(" $ actorLocation.x $ "," $ actorLocation.y $ "," $ actorLocation.z $ ")";
	}
	else
		s = s $ "None";
}

defaultproperties
{
	spawnInterval		= 0.0
	maxSpawnAttempts	= 1

	returnType			= class'Variable'
	actionDisplayName	= "Spawn Actor"
	actionHelp			= "Spawn an actor."
	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:42.000 - Creation time: st 23.5.2018 00:10:40.628 - Created with UnCodeX