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

Difference between revisions of "UE3:UT GR Info (UT3)"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
m (Functions)
m (cleaned up some)
Line 51: Line 51:
 
// Class: UT_GR_Info
 
// Class: UT_GR_Info
 
// Creation date: 12/12/2008 19:35
 
// Creation date: 12/12/2008 19:35
// Last updated: 22/11/2009 04:56
+
// Last updated: 11/04/2010 13:10
 
// Contributors: 00zX
 
// Contributors: 00zX
 
//---------------------------------------------------
 
//---------------------------------------------------
Line 85: Line 85:
 
var int ModifiedDamage; //ConversionRatio>??
 
var int ModifiedDamage; //ConversionRatio>??
 
var class<DamageType> DamageType;
 
var class<DamageType> DamageType;
 +
 +
structdefaultproperties
 +
{
 +
bIsBot=false
 +
bIsFriendly=false
 +
Damage=0
 +
ModifiedDamage=0
 +
DamageType=class'DmgType_Suicided'
 +
}
 
};
 
};
  
var UTMutator GameExp;
+
var UT_MDB_GameExp GameExp;
var private UT_MDB_GameRules FirstGR;
+
var private UT_MDB_GameRules BaseGameRules;
  
/*event PreBeginPlay()
 
{
 
// `logdfunc('GameRules');
 
  
if(GD == None)
+
/** wtf why am I grey? */
return;
+
function SetBaseGameRules()
 
+
if(GD.GRList != none)
+
FirstGR = UT_MDB_GameRules(GD.GRList.GetFirst());
+
}*/
+
 
+
/**wtf why am I grey?*/
+
function SetFirstGR()
+
 
{
 
{
if(UT_MDB_GameExp(GameExp) == None)
+
if(GameExp == None)
 
return;
 
return;
  
 
`logd("GameRules Info Controller Initalized!",,'GameRulesInfo');
 
`logd("GameRules Info Controller Initalized!",,'GameRulesInfo');
if(UT_MDB_GameExp(GameExp).GRList != none)
 
FirstGR = UT_MDB_GameRules(UT_MDB_GameExp(GameExp).GRList.GetFirst());
 
  
`logd("FirstGR:"$FirstGR,,'GameRulesInfo');
+
BaseGameRules = GameExp.GetBaseGameRules();
 +
`logd("BaseGameRules:"$BaseGameRules,,'GameRulesInfo');
 
}
 
}
  
 
function bool OverridePickupQuery(Pawn Other, class<Inventory> ItemClass, Actor Pickup, out byte bAllowPickup)
 
function bool OverridePickupQuery(Pawn Other, class<Inventory> ItemClass, Actor Pickup, out byte bAllowPickup)
 
{
 
{
//Only Pawns have inventory managers?
+
if(GameExp == None || BaseGameRules == None)
//InvMgr = UTInventoryManager(Other.InvManager);
+
 
+
if(GameExp == None)
+
return false;
+
 
+
if(UT_MDB_GameExp(GameExp).GRList.isEmpty())
+
 
return false;
 
return false;
  
 
if(Pickup != None && UTPawn(Other) != None)
 
if(Pickup != None && UTPawn(Other) != None)
if((FirstGR != None) && FirstGR.OverridePickupQuery(UTPawn(Other), ItemClass, Pickup))
+
if((BaseGameRules != None) && BaseGameRules.PickupQuery(UTPawn(Other), ItemClass, Pickup))
 
return true;
 
return true;
 
return false;
 
return false;
Line 135: Line 127:
 
function NetDamage(int OriginalDamage, out int Damage, pawn injured, Controller instigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType)
 
function NetDamage(int OriginalDamage, out int Damage, pawn injured, Controller instigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType)
 
{
 
{
local EnemyInfo Enemy; ///New Branch
+
local EnemyInfo Enemy;
// local EnemyInfo Injured;
+
// local UT_MDB_GameRules fGR;
+
  
/// InjuredPRI = injured.PlayerReplicationInfo;
+
if(GameExp == None || BaseGameRules == None)
// `logd("Master: NetDamage",,'GameRules');
+
 
+
// if (injured == None || instigatedBy == None || injured.Controller == None || instigatedBy.Controller == None)
+
// return Super.NetDamage(OriginalDamage, Damage, injured, instigatedBy, HitLocation, Momentum, DamageType);
+
 
+
if(GameExp == None)
+
 
return;
 
return;
 
if(UT_MDB_GameExp(GameExp).GRList.isEmpty())
 
return;
 
 
// `logd("Master: GameData: "$GD,,'GameRules');
 
  
 
if(!WorldInfo.Game.IsInState('MatchInProgress') ||
 
if(!WorldInfo.Game.IsInState('MatchInProgress') ||
Line 159: Line 138:
 
return;
 
return;
 
}
 
}
 
if(UT_MDB_GameExp(GameExp).GRList.isEmpty())
 
Super.NetDamage(OriginalDamage, Damage, injured, instigatedBy, HitLocation, Momentum, DamageType);
 
 
// fGR = UT_MDB_GameRules(GD.GRList.GetFirst());
 
// `logd("Master: ObjList: FirstRules: "$PathName(fGR),,'GameRules');
 
  
 
if(instigatedBy != None && instigatedBy.Pawn != None)
 
if(instigatedBy != None && instigatedBy.Pawn != None)
 
{
 
{
//`logd("NetDamage::UT_GR_Info:(instigatedBy != None && instigatedBy.Pawn != None)",,'GameRulesInfo');
 
 
Enemy.Pawn = InstigatedBy.Pawn;
 
Enemy.Pawn = InstigatedBy.Pawn;
 
Enemy.Damage = OriginalDamage;
 
Enemy.Damage = OriginalDamage;
Line 174: Line 146:
 
if(ClassIsChildOf(Enemy.Pawn.class,class'UTPawn'))
 
if(ClassIsChildOf(Enemy.Pawn.class,class'UTPawn'))
 
{
 
{
//`logd("NetDamage::UT_GR_Info:(ClassIsChildOf(Enemy.Pawn.class,class'UTPawn'))",,'GameRulesInfo');
 
 
//Added Rook 2.0
 
//Added Rook 2.0
 
if(Enemy.Pawn.IsA('UTHeroPawn'))
 
if(Enemy.Pawn.IsA('UTHeroPawn'))
 
{
 
{
 
if(UTHeroPawn(InstigatedBy.Pawn).bIsHero && !UTHeroPawn(InstigatedBy.Pawn).bIsSuperHero)
 
if(UTHeroPawn(InstigatedBy.Pawn).bIsHero && !UTHeroPawn(InstigatedBy.Pawn).bIsSuperHero)
Enemy.Type=ET_Hero;//Enemy.Type=ET_Rook;
+
Enemy.Type = ET_Hero;
 
else if (!UTHeroPawn(InstigatedBy.Pawn).bIsHero && UTHeroPawn(InstigatedBy.Pawn).bIsSuperHero)
 
else if (!UTHeroPawn(InstigatedBy.Pawn).bIsHero && UTHeroPawn(InstigatedBy.Pawn).bIsSuperHero)
Enemy.Type=ET_Rook;//Enemy.Type=ET_Knight;
+
Enemy.Type = ET_Rook;
 
}
 
}
 
else
 
else
Enemy.Type=ET_Infantry;
+
Enemy.Type = ET_Infantry;
  
 
}
 
}
Line 190: Line 161:
 
{
 
{
 
if(ClassIsChildOf(InstigatedBy.Pawn.class, class'UTVehicle_TrackTurretBase'))
 
if(ClassIsChildOf(InstigatedBy.Pawn.class, class'UTVehicle_TrackTurretBase'))
Enemy.Type=ET_Turret;
+
Enemy.Type = ET_Turret;
 
else
 
else
Enemy.Type=ET_Vehicle;
+
Enemy.Type = ET_Vehicle;
 
}
 
}
 
//`logd("Enemy is of Type: "$Enemy.Type,,'GameRulesInfo');
 
  
 
//Enemy isA UTBot
 
//Enemy isA UTBot
Line 204: Line 173:
 
//Self-Damage
 
//Self-Damage
 
if(Enemy.Pawn == injured)
 
if(Enemy.Pawn == injured)
Damage = FirstGR.SelfDamage(Enemy);//Damage = FirstGR.SelfDamage(Enemy);
+
Damage = BaseGameRules.SelfDamage(Enemy);
  
 
//Damage From EnemyPawn
 
//Damage From EnemyPawn
Line 213: Line 182:
 
{
 
{
 
if(instigatedBy.GetTeamNum() != injured.GetTeamNum())
 
if(instigatedBy.GetTeamNum() != injured.GetTeamNum())
Damage = FirstGR.DamageTaken(Enemy,Injured);//Damage = FirstGR.DamageTaken(Enemy,Injured);
+
Damage = BaseGameRules.DamageTaken(Enemy, Injured);
 
else
 
else
 
Enemy.bIsFriendly = true;
 
Enemy.bIsFriendly = true;
Line 219: Line 188:
 
//FFA Damage
 
//FFA Damage
 
else
 
else
Damage = FirstGR.DamageTaken(Enemy,Injured);//Damage = FirstGR.DamageTaken(Enemy,Injured);
+
Damage = BaseGameRules.DamageTaken(Enemy, Injured);
 
+
//if((EnemyPRI != None) && (injured.PlayerReplicationInfo != None) &&
+
// ((EnemyPRI.Team == None) || (EnemyPRI.Team != injured.PlayerReplicationInfo.Team)))
+
 
}
 
}
 
}
 
}
 
}
 
}
 
//TODO: REMAP TO NEW GR OBJECTS!
 
/*
 
function NavigationPoint FindPlayerStart( Controller Player, optional byte InTeam, optional string incomingName )
 
{
 
if ( NextGameRules != None )
 
return NextGameRules.FindPlayerStart(Player,InTeam,incomingName);
 
 
return None;
 
}
 
 
function bool HandleRestartGame()
 
{
 
if ( (NextGameRules != None) && NextGameRules.HandleRestartGame() )
 
return true;
 
return false;
 
}
 
 
function bool CheckEndGame(PlayerReplicationInfo Winner, string Reason)
 
{
 
if ( NextGameRules != None )
 
return NextGameRules.CheckEndGame(Winner,Reason);
 
 
return true;
 
}
 
 
function bool PreventDeath(Pawn Killed, Controller Killer, class<DamageType> damageType, vector HitLocation)
 
{
 
if ( (NextGameRules != None) && NextGameRules.PreventDeath(Killed,Killer, damageType,HitLocation) )
 
return true;
 
return false;
 
}
 
 
function ScoreObjective(PlayerReplicationInfo Scorer, Int Score)
 
{
 
if ( NextGameRules != None )
 
NextGameRules.ScoreObjective(Scorer,Score);
 
}
 
 
function ScoreKill(Controller Killer, Controller Killed)
 
{
 
if ( NextGameRules != None )
 
NextGameRules.ScoreKill(Killer,Killed);
 
}*/
 
 
</uscript>
 
</uscript>

Revision as of 02:39, 12 April 2010

Introduction

Code

UT3 Info >> GameRules >> UT_GR_Info (custom)
Package: 
UT_GameDex

Enums

enum EnemyType
ET_Infantry,
ET_Hero,
ET_Vehicle,
ET_Rook, //Castle
ET_Knight, //Manta, Viper?
ET_Bishop, //Hero
ET_Turret

Structs

PawnInfo

Pawn Pawn 
EnemyType Type 

EnemyInfo

Extends: PawnInfo

bool bIsBot 
bool bIsFriendly 
int Damage 
int ModifiedDamage 
'class<DamageType>' DamageType 

Functions

SetFirstGR

function SetFirstGR()

OverridePickupQuery

function bool OverridePickupQuery(Pawn Other, class<Inventory> ItemClass, Actor Pickup, out byte bAllowPickup)

NetDamage

function NetDamage(int OriginalDamage, out int Damage, Pawn injured, Controller instigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType)

Script

//===================================================
//	Class: UT_GR_Info
//	Creation date: 12/12/2008 19:35
//	Last updated: 11/04/2010 13:10
//	Contributors: 00zX
//---------------------------------------------------
//	Attribution-Noncommercial-Share Alike 3.0 Unported
//	http://creativecommons.org/licenses/by-nc-sa/3.0/
//===================================================
class UT_GR_Info extends GameRules;
 
`include(MOD.uci)
 
enum EnemyType
{
	ET_Infantry,
	ET_Hero,
	ET_Vehicle,
	ET_Rook,	//Castle
	ET_Knight,	//Manta, Viper?
	ET_Bishop,	//Hero
	ET_Turret
};
 
struct PawnInfo
{
	var Pawn Pawn;
	var EnemyType Type;
};
 
struct EnemyInfo extends PawnInfo
{
	var bool bIsBot;
	var bool bIsFriendly;
	var int Damage;
	var int ModifiedDamage;	//ConversionRatio>??
	var class<DamageType> DamageType;
 
	structdefaultproperties
	{
		bIsBot=false
		bIsFriendly=false
		Damage=0
		ModifiedDamage=0
		DamageType=class'DmgType_Suicided'
	}
};
 
var UT_MDB_GameExp				GameExp;
var private UT_MDB_GameRules	BaseGameRules;
 
 
/** wtf why am I grey? */
function SetBaseGameRules()
{
	if(GameExp == None)
		return;
 
	`logd("GameRules Info Controller Initalized!",,'GameRulesInfo');
 
	BaseGameRules = GameExp.GetBaseGameRules();
	`logd("BaseGameRules:"$BaseGameRules,,'GameRulesInfo');
}
 
function bool OverridePickupQuery(Pawn Other, class<Inventory> ItemClass, Actor Pickup, out byte bAllowPickup)
{
	if(GameExp == None || BaseGameRules == None)
		return false;
 
	if(Pickup != None && UTPawn(Other) != None)
		if((BaseGameRules != None) && BaseGameRules.PickupQuery(UTPawn(Other), ItemClass, Pickup))
			return true;
	return false;
}
 
//Cumulative
//TODO: SUPPORT OTHER MUTS, USE THE LINKED LIST ONTOP OF OBJECT LIST!!~
function NetDamage(int OriginalDamage, out int Damage, pawn injured, Controller instigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType)
{
	local EnemyInfo Enemy;
 
	if(GameExp == None || BaseGameRules == None)
		return;
 
	if(!WorldInfo.Game.IsInState('MatchInProgress') ||
		(injured == None && instigatedBy == None))
	{
		Damage = 0;
		return;
	}
 
	if(instigatedBy != None && instigatedBy.Pawn != None)
	{
		Enemy.Pawn = InstigatedBy.Pawn;
		Enemy.Damage = OriginalDamage;
 
		if(ClassIsChildOf(Enemy.Pawn.class,class'UTPawn'))
		{
			//Added Rook 2.0
			if(Enemy.Pawn.IsA('UTHeroPawn'))
			{
				if(UTHeroPawn(InstigatedBy.Pawn).bIsHero && !UTHeroPawn(InstigatedBy.Pawn).bIsSuperHero)
					Enemy.Type = ET_Hero;
				else if (!UTHeroPawn(InstigatedBy.Pawn).bIsHero && UTHeroPawn(InstigatedBy.Pawn).bIsSuperHero)
					Enemy.Type = ET_Rook;
			}
			else
				Enemy.Type = ET_Infantry;
 
		}
		else if(ClassIsChildOf(InstigatedBy.Pawn.class, class'UTVehicle'))
		{
			if(ClassIsChildOf(InstigatedBy.Pawn.class, class'UTVehicle_TrackTurretBase'))
				Enemy.Type = ET_Turret;
			else
				Enemy.Type = ET_Vehicle;
		}
 
		//Enemy isA UTBot
		if(UTBot(instigatedBy) != None && UTBot(injured.controller) == None &&
			UTBot(injured.controller) != UTBot(instigatedBy))
				Enemy.bIsBot = true;
 
		//Self-Damage
		if(Enemy.Pawn == injured)
			Damage = BaseGameRules.SelfDamage(Enemy);
 
		//Damage From EnemyPawn
		else if(injured != instigatedBy)
		{
			//Team Damage
			if(WorldInfo.Game.bTeamGame)
			{
				if(instigatedBy.GetTeamNum() != injured.GetTeamNum())
					Damage = BaseGameRules.DamageTaken(Enemy, Injured);
				else
					Enemy.bIsFriendly = true;
			}
			//FFA Damage
			else
				Damage = BaseGameRules.DamageTaken(Enemy, Injured);
		}
	}
}