Always snap to grid

UE3:UT MDB GameExp (UT3)

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 02:19, 12 April 2010 by 00zX (Talk | contribs) (removed some jaggies from my wheel)

Jump to: navigation, search

Introduction

Code

UT3 Info >> UTMutator >> UT_MDB_GameExp (custom)
Package: 
UT_GameDex
Known custom subclass:
UTM_BloodLust (UT3)

Functions

Script

//===================================================
//	Class: UT_MDB_GameExp				//%GAMEEXPANSIONCLASS%   (ClassName)
//	Creation date: 06/12/2007 08:10	//%CREATIONDATE% (Date)
//	Last updated: 11/04/2010 13:19		//%UPDATEDDATE%  (Date)
//	Contributors: 00zX					//%CONTRIBUTORS% (String)
//---------------------------------------------------
//TODO: Expanded Tag Support -
//	Can be used to auto assign groups based on what adjustments are made.
 
//Removed Redundant function calls
//Moved Info Attachments to Gamerules objects
//Killed the ObjectList and put the list functionality in this class
//Moved FactoryData and ItemReplacer functionality out to GameRules object subclasses
//Started readying things for UTM_ prefix class depreciation
 
//---------------------------------------------------
//	Attribution-Noncommercial-Share Alike 3.0 Unported
//	http://creativecommons.org/licenses/by-nc-sa/3.0/
//	http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
//===================================================
class UT_MDB_GameExp extends UTMutator
	abstract;
 
`include(MOD.uci)
 
/** Version number for this Game Expasion Mutator. */
Const MutVer = 2.68;
 
//Gametype
var() class<Gameinfo>					GClass< SEMI >
var() class<PlayerController>			PCClass< SEMI >	/// Controller for this Mutator.
var() class<UTPawn>						PClass< SEMI >		/// Pawn for this Mutator.
var() class<HUD>						HUDClass< SEMI >	/// HUD for this Mutator.
var() class<UTCheatManager>			CMClass< SEMI >
 
/** GameRules Objects - Hybrid Array/List */
var protected array<UT_MDB_GameRules>	GameRulesList;
 
var UT_MDB_GameInfo						GameData;
 
/** Logging */
//var UT_MDB_LogObj						LogObj;
 
//Gravity
var float	VehicleGravityScale;	//Could be %
var float	InfantryGravityScale;
 
//From GameInfo
var bool	bNewPlayersVsBots;
var bool	bNewCustomBots;
var bool	bNewWeaponStay;
var bool	bAllowTranslocator;
//UTGame(WorldInfo.Game).bAllowHoverboard = false;
 
////
//Utility Functions for GameRulesList
//TODO: Pull Hybrid list functions into this class
final function UT_GR_Info GetMasterGameRules()
{
	local GameRules MasterGameRules;
 
	MasterGameRules = WorldInfo.Game.GameRulesModifiers;
 
	//Spawn the Master GameRules for GameDex
	if(MasterGameRules == none)
	{
		WorldInfo.Game.AddGameRules(class'UT_GameDex.UT_GR_Info');
		MasterGameRules = WorldInfo.Game.GameRulesModifiers;
		UT_GR_Info(MasterGameRules).GameExp = self;
	}
	//TODO: Search for class if other non-GameDex mutators are used.
 
	return UT_GR_Info(MasterGameRules);
}
 
//Returns none if next is none, returns object if found.
final function UT_MDB_GameRules GetNextGameRules(UT_MDB_GameRules this)
{
	local int idx;
 
	idx = self.GameRulesList.Find(this);
	return self.GameRulesList[idx+1];
}
 
final function UT_MDB_GameRules GetBaseGameRules()
{
	return self.GameRulesList[0];
}
 
//Returns first instance of GameRules matching class
//Or creates a new instance of GameRules and returns that
final function UT_MDB_GameRules UpdateGameRules(class<UT_MDB_GameRules> GRC)
{
	local UT_MDB_GameRules GR;
 
	for(GR = GetBaseGameRules(); GR != None; GR = GetNextGameRules(GR))
	{
		if(GR.Class == GRC)
			return GR;
	}
 
	GR = new(self)GRC;
	self.GameRulesList.Additem(GR);
	GR.Init();
	return GR;
}
 
////
//Utility Functions for GroupNames
final function AddGroupName(string G)
{
	local int idx;
 
	idx = GroupNames.find(G);
	if(idx != INDEX_NONE)
		GroupNames.Additem(G);
}
 
final function RemoveGroupName(string G)
{
	local int idx;
 
	idx = GroupNames.find(G);
	if(idx != INDEX_NONE)
		GroupNames.Removeitem(G);
}
 
////
function GetServerDetails(out GameInfo.ServerResponseLine ServerState)
{
	local int i;
 
	Super.GetServerDetails(ServerState);
 
	i = ServerState.ServerInfo.Length;
 
	ServerState.ServerInfo.Length = i+1;
	ServerState.ServerInfo[i].Key = "GameDex";
	ServerState.ServerInfo[i++].Value = "v"$MutVer;
}
 
////
//TODO: Tidy everything up in this case.
event Destroyed();
 
function ModifyLogin(out string Portal, out string Options)
{
	Super.ModifyLogin(Portal, Options);
	if(NextMutator == None)
		`logd("Logged in!",,'GameExp');
}
 
////
event PreBeginPlay()
{
	`LogdFuncN()
 
/*	if(LogObj != none)
	{
		LogObj.lMuts.Additem(class.name);
	}*/
}
 
event PostBeginPlay()
{
	local UT_MDB_GameRules GR;
 
	`LogdFuncN()
 
	Super.PostBeginPlay();
 
	for(GR = GetBaseGameRules(); GR != None; GR = GetNextGameRules(GR))
	{
		GR.PostBeginPlay();
	}
}
 
function InitMutator(string Options, out string ErrorMessage)
{
	`LogdFuncN()
 
	Super.InitMutator(Options, ErrorMessage);
 
	if(NextMutator == None)
		PostInitMutator();
}
 
//Ran only once for all mutators regardless of Mutator.Next!
singular function PostInitMutator()
{
	local UT_GR_Info MasterGameRules;
	local UT_MDB_GameRules GR;
 
	`LogdFuncN()
 
	if(WorldInfo.Game != none)
	{
		UTGame(WorldInfo.Game).bAllowTranslocator = default.bAllowTranslocator;
 
		GameData.CurMap = WorldInfo.GetMapName(true);
		GameData.CurGameType = UTGame(WorldInfo.Game);
 
		if(PClass != None)		WorldInfo.Game.DefaultPawnClass = PClass< SEMI >
		if(PCClass != None)		WorldInfo.Game.PlayerControllerClass = PCClass< SEMI >
		if(HUDClass != None)	WorldInfo.Game.HUDType = HUDClass< SEMI >
 
		`logd("Pawn.Class: "$WorldInfo.Game.DefaultPawnClass,,'GameExp');
		`logd("Controller.Class: "$WorldInfo.Game.PlayerControllerClass,,'GameExp');
		`logd("HUD.Class: "$WorldInfo.Game.HUDType,,'GameExp');
 
		//TODO: Check LinkedList for UT_GR_Info, not just First in List!
		MasterGameRules = GetMasterGameRules();
		MasterGameRules.SetBaseGameRules();
		`logd("MasterGameRules: "$PathName(MasterGameRules)$" Initialized!",,'GameExp',);
 
		//Call Init for all GameRules Objects
		for(GR = GetBaseGameRules(); GR != None; GR = GetNextGameRules(GR))
		{
			GR.Init();
		}
	}
}
 
////
//Replacement
function bool CheckReplacement(Actor Other)
{
	local UTPlayerController UTPlayer;
	local UT_MDB_GameRules GR;
 
	UTPlayer = UTPlayerController(Controller(other));
	if(UTPlayer != None && CMClass != None)
		UTPlayer.CheatClass = default.CMClass< SEMI >
 
	for(GR = GetBaseGameRules(); GR != None; GR = GetNextGameRules(GR))
	{
		return GR.CheckReplacement(Other);
	}
 
	return true;
}
 
////
//Modify
function ModifyPlayer(Pawn Other)
{
	local UTPawn P;
	local UTVehicle V;
	local UT_MDB_GameRules BaseGameRules;
 
	//if(Other.IsA(class'')){}
 
	BaseGameRules = GetBaseGameRules();
	P = UTPawn(Other);
	if(P != None && BaseGameRules != None)
	{
		if(UTHeroPawn(P) != None)
		{
			if(GameData != None && UTHeroPawn(P).name != GameData.CurRook)
			{
				`logd("Rook: "$PathName(UTHeroPawn(P)),,'GameExp');
				GameData.CurRook = UTHeroPawn(P).name;
			}
			BaseGameRules.ModifyRook(UTHeroPawn(P));
		}
 
		if(GameData != None && P.name != GameData.CurPawn)
		{
			`logd("Pawn: "$PathName(P),,'GameExp');
			GameData.CurPawn = P.name;
		}
		BaseGameRules.ModifyPawn(P);
	}
 
	// TODO: Only modifys the vehicle once a player enters it or on spawn?
	V = UTVehicle(Other);
	if(V != None && BaseGameRules != None)
	{
//		ModifyKnight(V);
		if(GameData != None && V.name != GameData.CurVehicle)
		{
			`logd("Vehicle: "$PathName(V),,'GameExp');
			GameData.CurVehicle = V.name;
		}
		BaseGameRules.ModifyVehicle(V);
	}
 
	Super.ModifyPlayer(Other);
}
 
defaultproperties
{
	Begin Object Class=UT_MDB_GameInfo Name=UT_MDB_GameInfo0
	End Object
	GameData=UT_MDB_GameInfo0
 
	PClass=None
	PCClass=None
	HUDClass=None
	CMClass=None
}