Once I get that upgrade to 36-hour days, I will tackle that. – Mychaeel

UE3:UT MDB GameRules (UT3)

From Unreal Wiki, The Unreal Engine Documentation Site
(Redirected from UE3:UT MDB GameRules)
Jump to: navigation, search
UT3 Object >> UT_MDB >> UT_MDB_GameRules (custom)

Contents

Package: 
UT_GameDex
Known custom subclasses:
UT_MDB_GR_DamageConversion (UT3), UT_MDB_GR_Bloodlust (UT3), UT_MDB_GR_Replacer (UT3)

Code[edit]

//====================================================
//	Class: UT_MDB_GameRules
//	Creation date: 15/01/2009 07:02
//	Last Updated: 18/04/2010 13:28
//	Contributors: 00zX
//----------------------------------------------------
 
//Added CheckReplacement support to this, wrapped spawn like timers through Master Actor
//Rewrote LinkedReplicationInfo functionality, now uses forloop and checks for none (will work for all members of list)
 
//----------------------------------------------------
//	Attribution-Noncommercial-Share Alike 3.0 Unported
//	http://creativecommons.org/licenses/by-nc-sa/3.0/
//====================================================
class UT_MDB_GameRules extends UT_MDB
	config(UT_MDB_GR);
 
var UT_GR_Info						MasterGameRules;
var UT_MDB_GameRules				NextGameRules;
var UT_MDB_EventNotifier			EventNotifier;
 
var() array<UT_MDB_GameRules>		GameRules;			//Sub-GameRules, that means these could contain Subs and so on
var() array<Info.KeyValuePair>		GameRulesInfo;
 
function GetServerDetails(out GameInfo.ServerResponseLine ServerState)
{
	local Info.KeyValuePair tPair;
	local int i;
 
	foreach GameRulesInfo(tPair)
	{
		i = ServerState.ServerInfo.Length;
		ServerState.ServerInfo.Length = i+1;
		ServerState.ServerInfo[i].Key = tPair.Key;
		ServerState.ServerInfo[i].Value = tPair.Value;
	}
}
 
//Wormbo - it's a notification, so the various rules actors shouldn't be able to break the chain
//	for (GR = GetBaseAddonRules(); GR != None; GR = GR.GetNextAddonRules())
//	{
//		GR.NotifyPlayerReleased(PRI, OldJail);
//	}
 
//00zX - there are acouple instances where the chain needs to be broken in mine but I call back to super and snap it there
//i can actually jump the chain in some instances because its well, more of a flower shape then a chain :P
 
//Wormbo - if breaking the chain makes sense, I add a return value or out parameter for modifying the iteration behavior
//	for (GR = GetBaseAddonRules(); GR != None; GR = GR.GetNextAddonRules())
//	{
//		bIsJailFightWeapon = byte(bDefaultJailFightWeapon);
//		if (GR.OverrideJailFightWeapon(WeaponClass, Player, bIsJailFightWeapon))
//			return bool(bIsJailFightWeapon);
//	}
 
////
/** Initialize Gamerules - mainly for logging */
function Init()
{
	`logd("Rules Object Initialized: "$self.name,,'GameRules');
 
	Master = MasterGameRules.GameExp;
	if(Master == None)
		`logd("Master Mutator not found!",,'GameRules');//Send Object to GC
	else
		NextGameRules = UT_MDB_GameExp(Master).GetNextGameRules(self);
}
 
event PostBeginPlay();
 
function bool PickupQuery(UTPawn Other, class<Inventory> ItemClass, Actor Pickup)
{
	return (NextGameRules != none) ? NextGameRules.PickupQuery(Other, ItemClass, Pickup) : false;
}
 
function int ModifyDamageTaken(UT_GR_Info.EnemyInfo Enemy, optional pawn injured)
{
	if(NextGameRules != None)
		return NextGameRules.ModifyDamageTaken(Enemy, injured);
/*	else
		return (Enemy.ModifiedDamage != 0 && Enemy.Damage != Enemy.ModifiedDamage) ? Enemy.ModifiedDamage : Enemy.Damage;*/
}
 
function int ModifySelfDamage(UT_GR_Info.EnemyInfo Enemy)
{
	return (NextGameRules != none) ? NextGameRules.ModifySelfDamage(Enemy) : Enemy.Damage;
}
 
//Notifications
function NotifyDamageTaken(UT_GR_Info.EnemyInfo Enemy, optional pawn injured);
function NotifySelfDamage(UT_GR_Info.EnemyInfo Enemy);
function NotifyEnteredVehicle(Pawn P);
function NotifyExitedVehicle(Pawn P);
function NotifyController(Controller PC);
 
//----
//Some of these might need access to gameinfo/worldinfo
 
simulated function ModifyPawnInfo(UT_GR_Info.PawnInfo PInfo, optional bool bRemoveBonus=false, optional int GlobalMultiplier)
{
	if(nextGameRules != none)
		nextGameRules.ModifyPawnInfo(PInfo, bRemoveBonus, GlobalMultiplier);
 
	switch (PInfo.Type)
	{
		case ET_Infantry: break;
		case ET_Hero: break;
		case ET_Vehicle: break;
		case ET_Rook: break;
		case ET_Knight: break;
		case ET_Bishop: break;
		case ET_Turret: break;
	}
}
 
//Could do this in GameInfo, call once for all controllers (and for each logged in?)
simulated function ModifyController(Controller PC, optional bool bRemoveBonus=false, optional int GlobalMultiplier);
 
//TODO: Obsolete? Depreciate!
//NOTE: This will only allow modification of defaults, might prove to be useful though being static
simulated function ModifyPawn(Pawn P, optional bool bRemoveBonus=false, optional int GlobalMultiplier);
simulated function ModifyRook(UTHeroPawn R, optional bool bRemoveBonus=false, optional int GlobalMultiplier);
simulated function ModifyVehicle(Vehicle V, optional bool bRemoveBonus=false, optional int GlobalMultiplier);
simulated function ModifyWeapon(Weapon W, optional bool bRemoveBonus=false, optional int GlobalMultiplier);
 
simulated function ModifyVehicleOnEnter(Vehicle V, optional bool bRemoveBonus=false, optional int GlobalMultiplier);
 
static function ScoreKill(Controller Killer, Controller Killed, bool bOwnedByKiller, optional int GlobalMultiplier);
 
////
//Replacement functions
function bool CheckReplacement(Actor Other)
{
	return true;
}
 
////
/** Added to allow Gametype hook to UTLinkedReplicationInfo.
Similar to Info attachment method but instead links a replication info to the PRI.*/
//NOTE: Should be called from check replacement!
final function AddReplicationInfo(Actor Other, class<UTLinkedReplicationInfo> LRIC)
{
	local UTLinkedReplicationInfo LRI;
	local UTPlayerReplicationInfo PRI;
 
	if(LRIC != None)
		return;
 
	PRI = UTPlayerReplicationInfo(Other);
	for(LRI = PRI.CustomReplicationInfo; LRI == None; LRI = LRI.NextReplicationInfo)
	{
		if(LRI.Class == LRIC)
			break;
 
		//Spawn(LRIC, Other.Owner);
		LRI = Master.Spawn(LRIC, Other.Owner);
		`logd("PRI.CustomReplicationInfo: "$LRI,,'GameExp');
	}
}