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

From Unreal Wiki, The Unreal Engine Documentation Site
00zX (talk | contribs)
00zX (talk | contribs)
 
(8 intermediate revisions by the same user not shown)
Line 13: Line 13:
}}
}}
==Enums==
==Enums==
enum EnemyType<br>
'''ET_Infantry,'''<br>
'''ET_Hero,'''<br>
'''ET_Vehicle,'''<br>
'''ET_Rook,'''<br>
'''ET_Knight,'''<br>
'''ET_Bishop,'''<br>
'''ET_Turret'''<br>
==Structs==
==Structs==


Line 30: Line 39:


==Functions==
==Functions==
===SetFirstGR===
====SetFirstGR====
function SetFirstGR()
function SetFirstGR()
===OverridePickupQuery===
====OverridePickupQuery====
function [[bool]] OverridePickupQuery([[UE3:Pawn_(UT3)|Pawn]] Other, class<Inventory> ItemClass, [[UE3:Actor_(UT3)|Actor]] Pickup, out [[byte]] bAllowPickup)
function [[bool]] OverridePickupQuery([[UE3:Pawn_(UT3)|Pawn]] Other, class<Inventory> ItemClass, [[UE3:Actor_(UT3)|Actor]] Pickup, out [[byte]] bAllowPickup)
===NetDamage===
====NetDamage====
function NetDamage([[int]] OriginalDamage, out [[int]] Damage, [[UE3:Pawn_(UT3)|Pawn]] injured, [[UE3:Controller_(UT3)|Controller]] instigatedBy, [[UE3:Object_(UT3)_Struct#vector\vector]] HitLocation, out [[UE3:Object_(UT3)_Struct#vector\vector]] Momentum, class<DamageType> DamageType)
function NetDamage([[int]] OriginalDamage, out [[int]] Damage, [[UE3:Pawn_(UT3)|Pawn]] injured, [[UE3:Controller_(UT3)|Controller]] instigatedBy, [[UE3:Object_structs_(UT3)#Vector|vector]] HitLocation, out [[UE3:Object_structs_(UT3)#Vector|vector]] Momentum, class<DamageType> DamageType)
 
==Script==
==Script==
<uscript>
<uscript>
Line 41: 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 51: Line 61:
`include(MOD.uci)
`include(MOD.uci)


enum EnemyType
enum PawnType
{
{
ET_Infantry,
ET_Infantry,
Line 65: Line 75:
{
{
var Pawn Pawn;
var Pawn Pawn;
var EnemyType Type;
var PawnType Type;
};
};


Line 75: 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()
/** wtf why am I grey? */
function SetBaseGameRules()
{
{
// `logdfunc('GameRules');
if(GameExp == None)
 
if(GD == None)
return;
return;


if(GD.GRList != none)
`logd("GameRules Info Controller Initalized!",,'GameRulesInfo');
FirstGR = UT_MDB_GameRules(GD.GRList.GetFirst());
}*/


/**wtf why am I grey?*/
BaseGameRules = GameExp.GetBaseGameRules();
function SetFirstGR()
`logd("BaseGameRules:"$BaseGameRules,,'GameRulesInfo');
}
 
static function PawnType GetPawnType(Pawn Pawn)
{
{
if(UT_MDB_GameExp(GameExp) == None)
local PawnType PType;
return;
if(ClassIsChildOf(Pawn.class,class'UTPawn'))
{
//Added Rook 2.0
if(Pawn.IsA('UTHeroPawn'))
{
if(UTHeroPawn(Pawn).bIsHero && !UTHeroPawn(Pawn).bIsSuperHero)
PType = ET_Hero;
else if (!UTHeroPawn(Pawn).bIsHero && UTHeroPawn(Pawn).bIsSuperHero)
PType = ET_Rook;
}
else
PType = ET_Infantry;


`logd("GameRules Info Controller Initalized!",,'GameRulesInfo');
}
if(UT_MDB_GameExp(GameExp).GRList != none)
//isA UTVehicle
FirstGR = UT_MDB_GameRules(UT_MDB_GameExp(GameExp).GRList.GetFirst());
else if(ClassIsChildOf(Pawn.class, class'UTVehicle'))
{
if(ClassIsChildOf(Pawn.class, class'UTVehicle_TrackTurretBase'))
PType = ET_Turret;
else
PType = ET_Vehicle;
}
return PType;
}


`logd("FirstGR:"$FirstGR,,'GameRulesInfo');
function bool HandleRestartGame()
{
if((NextGameRules != None) && NextGameRules.HandleRestartGame())
return true;
return false;
}
}


function bool OverridePickupQuery(Pawn Other, class<Inventory> ItemClass, Actor Pickup, out byte bAllowPickup)
function bool CheckEndGame(PlayerReplicationInfo Winner, string Reason)
{
{
//Only Pawns have inventory managers?
if(NextGameRules != None)
//InvMgr = UTInventoryManager(Other.InvManager);
return NextGameRules.CheckEndGame(Winner,Reason);


if(GameExp == None)
return true;
return false;
}


if(UT_MDB_GameExp(GameExp).GRList.isEmpty())
function bool OverridePickupQuery(Pawn Other, class<Inventory> ItemClass, Actor Pickup, out byte bAllowPickup)
{
if(GameExp == None || BaseGameRules == None)
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;
}
function ScoreObjective(PlayerReplicationInfo Scorer, Int Score)
{
/* local UT_MDB_EventNotifier.NotifyMode HandleNotify;
local int idx;
HandleNotify = (EventName = ET_OnExit, NotifyName = NT_Vehicle);
for(GR = BaseGameRules; GR != None; GR = GetNextGameRules(GR))
{
idx = GR.EventNotifier.Notifies.find(HandleNotify);
if(idx != Index_None)
GR.ScoreObjective(Scorer,Score);
}*/
}
function ScoreKill(Controller Killer, Controller Killed)
{
/* local UT_MDB_EventNotifier.NotifyMode HandleNotify;
local int idx;
HandleNotify = (EventName = ET_OnExit, NotifyName = NT_Vehicle);
for(GR = BaseGameRules; GR != None; GR = GetNextGameRules(GR))
{
idx = GR.EventNotifier.Notifies.find(HandleNotify);
if(idx != Index_None)
GR.ScoreKill(Killer,Killed);
}*/
}
}


Line 125: Line 199:
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;
// `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)
if(GameExp == None || BaseGameRules == None)
return;
return;


if(UT_MDB_GameExp(GameExp).GRList.isEmpty())
if(!WorldInfo.Game.IsInState('MatchInProgress') || (injured == None && instigatedBy == None))
return;
 
// `logd("Master: GameData: "$GD,,'GameRules');
 
if(!WorldInfo.Game.IsInState('MatchInProgress') ||
(injured == None && instigatedBy == None))
{
{
Damage = 0;
Damage = 0;
return;
return;
}
}
 
if(UT_MDB_GameExp(GameExp).GRList.isEmpty())
//GameInfo.ReduceDamage // then check if carrying items that can reduce damage
Super.NetDamage(OriginalDamage, Damage, injured, instigatedBy, HitLocation, Momentum, DamageType);
// if((damage > 0) && (injured.InvManager != None))
 
// injured.InvManager.ModifyDamage(Damage, 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;
Enemy.Type = GetPawnType(Enemy.Pawn);


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;


}
}
//Enemy isA UTVehicle
else if(ClassIsChildOf(InstigatedBy.Pawn.class, class'UTVehicle'))
else if(ClassIsChildOf(InstigatedBy.Pawn.class, class'UTVehicle'))
{
{
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 194: Line 250:
//Self-Damage
//Self-Damage
if(Enemy.Pawn == injured)
if(Enemy.Pawn == injured)
Damage = FirstGR.SelfDamage(Enemy);//Damage = FirstGR.SelfDamage(Enemy);
Damage = BaseGameRules.ModifySelfDamage(Enemy);


//Damage From EnemyPawn
//Damage From EnemyPawn
Line 203: Line 259:
{
{
if(instigatedBy.GetTeamNum() != injured.GetTeamNum())
if(instigatedBy.GetTeamNum() != injured.GetTeamNum())
Damage = FirstGR.DamageTaken(Enemy,Injured);//Damage = FirstGR.DamageTaken(Enemy,Injured);
Damage = BaseGameRules.ModifyDamageTaken(Enemy, Injured);
else
else
Enemy.bIsFriendly = true;
Enemy.bIsFriendly = true;
Line 209: Line 265:
//FFA Damage
//FFA Damage
else
else
Damage = FirstGR.DamageTaken(Enemy,Injured);//Damage = FirstGR.DamageTaken(Enemy,Injured);
Damage = BaseGameRules.ModifyDamageTaken(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>

Latest revision as of 10:31, 15 February 2011

Introduction

Code

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

Enums

enum EnemyType
ET_Infantry,
ET_Hero,
ET_Vehicle,
ET_Rook,
ET_Knight,
ET_Bishop,
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

<uscript> //=================================================== // 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 PawnType { ET_Infantry, ET_Hero, ET_Vehicle, ET_Rook, //Castle ET_Knight, //Manta, Viper? ET_Bishop, //Hero ET_Turret };

struct PawnInfo { var Pawn Pawn; var PawnType 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'); }

static function PawnType GetPawnType(Pawn Pawn) { local PawnType PType;

if(ClassIsChildOf(Pawn.class,class'UTPawn')) { //Added Rook 2.0 if(Pawn.IsA('UTHeroPawn')) { if(UTHeroPawn(Pawn).bIsHero && !UTHeroPawn(Pawn).bIsSuperHero) PType = ET_Hero; else if (!UTHeroPawn(Pawn).bIsHero && UTHeroPawn(Pawn).bIsSuperHero) PType = ET_Rook; } else PType = ET_Infantry;

} //isA UTVehicle else if(ClassIsChildOf(Pawn.class, class'UTVehicle')) { if(ClassIsChildOf(Pawn.class, class'UTVehicle_TrackTurretBase')) PType = ET_Turret; else PType = ET_Vehicle; }

return PType; }

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 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; }

function ScoreObjective(PlayerReplicationInfo Scorer, Int Score) { /* local UT_MDB_EventNotifier.NotifyMode HandleNotify; local int idx;

HandleNotify = (EventName = ET_OnExit, NotifyName = NT_Vehicle); for(GR = BaseGameRules; GR != None; GR = GetNextGameRules(GR)) { idx = GR.EventNotifier.Notifies.find(HandleNotify); if(idx != Index_None) GR.ScoreObjective(Scorer,Score); }*/ }

function ScoreKill(Controller Killer, Controller Killed) { /* local UT_MDB_EventNotifier.NotifyMode HandleNotify; local int idx;

HandleNotify = (EventName = ET_OnExit, NotifyName = NT_Vehicle); for(GR = BaseGameRules; GR != None; GR = GetNextGameRules(GR)) { idx = GR.EventNotifier.Notifies.find(HandleNotify); if(idx != Index_None) GR.ScoreKill(Killer,Killed); }*/ }

//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; }

//GameInfo.ReduceDamage // then check if carrying items that can reduce damage // if((damage > 0) && (injured.InvManager != None)) // injured.InvManager.ModifyDamage(Damage, instigatedBy, HitLocation, Momentum, DamageType);

if(instigatedBy != None && instigatedBy.Pawn != None) { Enemy.Pawn = InstigatedBy.Pawn; Enemy.Damage = OriginalDamage; Enemy.Type = GetPawnType(Enemy.Pawn);

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

} //Enemy isA UTVehicle 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.ModifySelfDamage(Enemy);

//Damage From EnemyPawn else if(injured != instigatedBy) { //Team Damage if(WorldInfo.Game.bTeamGame) { if(instigatedBy.GetTeamNum() != injured.GetTeamNum()) Damage = BaseGameRules.ModifyDamageTaken(Enemy, Injured); else Enemy.bIsFriendly = true; } //FFA Damage else Damage = BaseGameRules.ModifyDamageTaken(Enemy, Injured); } } } </uscript>