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

BonusPack.MutSquadAI


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
class MutSquadAI extends DMSquad;

// This only runs on server
function bool SetEnemy( Bot B, Pawn NewEnemy )
{
	local xMutantGame mutantGame;
	local pawn mutantPawn;
	local int i;

	mutantGame = xMutantGame(Level.Game);
	
	// If no-one is a mutant (or we are), or we are the bottom feeder, do as normal DM. 
	if( mutantGame.CurrentMutant == None || mutantGame.CurrentMutant == B || mutantGame.CurrentBottomFeeder == B )
		return Super.SetEnemy(B, NewEnemy);

	mutantPawn = mutantGame.CurrentMutant.Pawn;

	// ??? If there is a mutant, remove all non-mutant enemies.
	for(i=0; i<8; i++)
	{
		if(Enemies[i] != mutantPawn)
			RemoveEnemy(Enemies[i]);
	}

	// Return false if NewEnemy != mutant.
	if( NewEnemy != mutantGame.CurrentMutant.Pawn )
		return false;

	if ( !AddEnemy(NewEnemy) )
		return false;

	return FindNewEnemyFor(B,(B.Enemy !=None) && B.LineOfSightTo(SquadMembers.Enemy));
}

function bool FindNewEnemyFor(Bot B, bool bSeeEnemy)
{
	local xMutantGame mutantGame;
	local Pawn OldEnemy, MutantPawn;

	mutantGame = xMutantGame(Level.Game);

	// If no-one is a mutant (or we are), or we are the bottom feeder, do as normal DM. 
	if( mutantGame.CurrentMutant == None || mutantGame.CurrentMutant == B || mutantGame.CurrentBottomFeeder == B )
		return Super.FindNewEnemyFor(B, bSeeEnemy);

	OldEnemy = B.Enemy;
	
	MutantPawn = mutantGame.CurrentMutant.Pawn;

	if(MutantPawn != None)
	{
		if ( VSize(MutantPawn.Location - B.Pawn.Location) < 1500 )
			bSeeEnemy = B.LineOfSightTo(MutantPawn);
		else
			bSeeEnemy = B.CanSee(MutantPawn);	// only if looking at him
	}
	B.Enemy = MutantPawn;

	if(OldEnemy != MutantPawn)
	{
		B.EnemyChanged(bSeeEnemy);
		return true;
	}

	return false;
}

function bool AssignSquadResponsibility(Bot B)
{
	local xMutantGame mutantGame;
	local pawn mutantPawn;

	mutantGame = xMutantGame(Level.Game);

	// If there is a mutant (and I'm not it)
	if(mutantGame.CurrentMutant != None && mutantGame.CurrentMutant != B)
	{
		mutantPawn = mutantGame.CurrentMutant.Pawn;

		// If I'm not the bottom feeder but i'm hunting someone, it can only be the mutant.
		if(B.Enemy != None && mutantGame.CurrentBottomFeeder != B && B.Enemy != mutantPawn)
		{
			FindNewEnemyFor(B, false);
		}
	}

	return Super.AssignSquadResponsibility(B);
}

defaultproperties
{
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: pr 5-2-2018 12:35:52.000 - Creation time: sk 18-3-2018 09:50:13.968 - Created with UnCodeX