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

Betrayal.BetrayalSquadAI


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
/******************************************************************************
BetrayalSquadAI

Creation date: 2011-03-08 21:03
Last change: $Id$
Copyright © 2011, Wormbo
Website: http://www.koehler-homepage.de/Wormbo/
Feel free to reuse this code. Send me a note if you found it helpful or want
to report bugs/provide improvements.
Please ask for permission first, if you intend to make money off reused code.
******************************************************************************/

class BetrayalSquadAI extends DMSquad;


//=============================================================================
// Variables
//=============================================================================

var bool bBetrayTeam;
var BetrayalPRI PRI;
var BetrayalTeam CurrentTeam;


function AddBot(Bot B)
{
	Super.AddBot(B);
	PRI = BetrayalPRI(B.PlayerReplicationInfo);
}

function bool SetEnemy(Bot B, Pawn NewEnemy)
{
	return ValidEnemy(NewEnemy) && Super.SetEnemy(B, NewEnemy);
}

function bool FriendlyToward(Pawn Other)
{
	return !bBetrayTeam && (Level.Game.TimeLimit == 0 || DeathMatch(Level.Game) == None || DeathMatch(Level.Game).RemainingTime > 15) && CurrentTeam != None && BetrayalPRI(Other.PlayerReplicationInfo) != None && BetrayalPRI(Other.PlayerReplicationInfo).CurrentTeam == CurrentTeam;
}

function SetNewTeam(BetrayalTeam NewTeam)
{
	local int i;

	CurrentTeam = NewTeam;
	bBetrayTeam = False;

	if (CurrentTeam != None) {
		for (i = 0; i < ArrayCount(Enemies); i++) {
			if (Enemies[i] != None && BetrayalPRI(Enemies[i].PlayerReplicationInfo) != None && BetrayalPRI(Enemies[i].PlayerReplicationInfo).CurrentTeam == CurrentTeam)
				RemoveEnemy(Enemies[i]);
		}
	}
}

function NotifyNewTeammate(BetrayalPRI PRI)
{
	if (!bBetrayTeam && PRI.Pawn != None)
		RemoveEnemy(PRI.Pawn);
}

function float ModifyThreat(float current, Pawn NewThreat, bool bThreatVisible, Bot B)
{
	local BetrayalPRI ThreatPRI;

	ThreatPRI = BetrayalPRI(NewThreat.PlayerReplicationInfo);
	if (ThreatPRI != None) {
		current += 0.5 * (ThreatPRI.ScoreValueFor(PRI) - 1);
		if (bThreatVisible && ThreatPRI.bIsRogue && PRI.Betrayer == ThreatPRI)
			current += 2; // kill the traitor!
		if (bThreatVisible && PRI.bIsRogue && ThreatPRI.Betrayer == PRI)
			current += 1; // he probably won't like me
	}
	return current;
}

function bool MustKeepEnemy(Pawn E)
{
	local BetrayalPRI EnemyPRI;

	EnemyPRI = BetrayalPRI(E.PlayerReplicationInfo);
	return EnemyPRI != None && EnemyPRI.bIsRogue && PRI.Betrayer == EnemyPRI;
}


//=============================================================================
// Default values
//=============================================================================

defaultproperties
{
}


Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mi 13.7.2011 21:20:44.000 - Creation time: Do 14.8.2014 09:58:35.015 - Created with UnCodeX