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

# Tyrion.AISpawnPoint

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
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166

    class AISpawnPoint extends Engine.Actor
    	placeable;

    var() class<BaseAICharacter> spawnAICharacterClass;
    var() Name aiCharacterLabel;
    var() bool bDisallowEquipmentDropOnDeath;

    var() editdisplay(displayActorLabel)
    	  editcombotype(enumTeamInfo)
    	  Gameplay.TeamInfo team;

    var() editdisplay(displayActorLabel)
    	  editcombotype(enumSquadInfo)
    	  SquadInfo squad;

    var() editinline array< class<AI_Goal> > goals;

    var int numSpawns;
    var() int maxNumSpawns "The maximum number of AIs allowed to spawn (-1 for infinite)";
    var() float deathDelay "The delay before respawning after receiving the death message";
    var() float deathDelayMax "If set, will use the deathDelay as a min and generate a random death delay between deathDelay and deathDelayMax";
    var() float spawnAttemptRate "The rate at which subsequent spawn attempts will be made if a spawn fails";
    var() private bool enabled;

    var(AI)	float SightRadius "maximum distance at which non-player characters can be seen";
    var(AI) float SightRadiusToPlayer "maximum distance at which player characters can be seen";

    function PreBeginPlay()
    {
    	super.PreBeginPlay();

    	registerMessage(class'MessageDeath', aiCharacterLabel);
    	registerMessage(class'MessageLevelStart', "GameInfo");
    }

    simulated function PrecacheSpeech(SpeechManager Manager)
    {
    	if (spawnAICharacterClass != None)
    		Manager.PrecacheAIVoiceSet(spawnAICharacterClass.default.VoiceSetPackageName);
    }

    function onMessage(Message msg)
    {
    	if (msg.IsA('MessageDeath'))
    	{
    		if (deathDelayMax != 0.0)
    			SetTimer(FRand() * (deathDelayMax - deathDelay) + deathDelay, false);
    		else if (deathDelay > 0.0)
    			SetTimer(deathDelay, false);
    		else
    			doSpawn();
    	}
    	else
    	{
    		doSpawn();
    	}
    }

    function Timer()
    {
    	doSpawn();
    }

    function enableSpawning()
    {
    	enabled = true;
    	numSpawns = 0;
    	doSpawn();
    }

    function disableSpawning()
    {
    	enabled = false;
    }

    function doSpawn()
    {
    	local BaseAICharacter c;
    	local int i;
    	local AI_Goal goal;

    	if (enabled)
    	{
    		c = Spawn(spawnAICharacterClass,,, Location, Rotation);

    		if (c != None)
    		{
    			++numSpawns;

    			c.Label = aiCharacterLabel;
    			c.bDisallowEquipmentDropOnDeath = bDisallowEquipmentDropOnDeath;

    			c.SetTeam(team);
    			c.SetSquad(squad);

    			c.SightRadius = SightRadius;
    			c.SightRadiusToPlayer = SightRadiusToPlayer;

    			// If there are any default goals with the same name as a goal in the goal list, we want
    			// the default goal to be removed so set its priority to zero so it will get removed in
    			// the resources init function
    			for (i = 0; i < goals.length; ++i)
    			{
    				goal = class'AI_Goal'.static.findGoalByName(c, goals[i].default.goalName);

    				if (goal != None)
    					goal.priority = 0;
    			}

    			// Add the goals from the goal list to the newly spawned character
    			for (i = 0; i < goals.length; i++)
    			{
    				if (goals[i] != None)
    					goals[i].static.findResource(c).assignGoal(goals[i]);
    			}

    			dispatchMessage(new class'MessageAISpawned'(Label, aiCharacterLabel));
    		}
    		else
    		{
    			SetTimer(spawnAttemptRate, false);
    		}

    		if (numSpawns == maxNumSpawns)
    			disableSpawning();
    	}
    }

    function string displayActorLabel(Actor t)
    {
    	return string(t.label);
    }

    function enumTeamInfo(Engine.LevelInfo l, out Array<TeamInfo> s)
    {
    	local TeamInfo t;

    	ForEach l.AllActors(class'TeamInfo', t)
    	{
    		s[s.Length] = t;
    	}
    }

    function enumSquadInfo(Engine.LevelInfo l, out Array<SquadInfo> s)
    {
    	local SquadInfo t;

    	ForEach l.AllActors(class'SquadInfo', t)
    	{
    		s[s.Length] = t;
    	}
    }

    defaultproperties
    {
    	bDirectional = true
    	Texture = Texture'Engine_res.S_Teleport'
    	RemoteRole = ROLE_None
    	bHidden = true
    	enabled = true
    	spawnAttemptRate = 1.0
    	maxNumSpawns = -1

    	SightRadius					= 6000.0
    	SightRadiusToPlayer			= 12000.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:54:12.000 - Creation time: st 23.5.2018 00:10:40.905 - Created with UnCodeX