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

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

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
(Created page with '==Code== {{Infobox class | package = UT_GameDex | class = UT_MDB_GR_GlobalDamage | game = UT3 | engine = UE3 | custom = yes | parent1 = UT_MDB_GR_DmgConversion | parent2 =…')
 
Line 14: Line 14:
 
<uscript>
 
<uscript>
 
//===================================================
 
//===================================================
// Class: UT_MDB_GR_GlobalDamage
+
// Class: UT_MDB_GR_DamageConversion
// Creation date: 08/09/2009 01:40
+
// Creation date: 20/08/2009 14:46
// Last Updated: 12/09/2009 03:52
+
// Last Updated: 14/04/2010 06:58
 
// Contributors: 00zX
 
// Contributors: 00zX
 
//---------------------------------------------------
 
//---------------------------------------------------
 
// Attribution-Noncommercial-Share Alike 3.0 Unported
 
// 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/
 +
//---------------------------------------------------
 +
//-Vampire/EnergyLeech, give conversion ratio +/-25%
 +
//
 +
//-Reward Delays
 +
//-TODO: Vampire/EnergyLeech, Falloff based on distance/view of target
 
//===================================================
 
//===================================================
class UT_MDB_GR_GlobalDamage extends UT_MDB_GR_DmgConversion;
+
class UT_MDB_GR_DamageConversion extends UT_MDB_GameRules
 +
config(Newtators);
  
//Global GameExp: Self Damage Scaling
+
`include(MOD.uci)
function int SelfDamage(UT_GR_Info.EnemyInfo Enemy)
+
 
 +
var globalconfig bool bUseSuperHealth;
 +
var globalconfig bool bUseForVehicles; //Infantry Vs Vehicle || Vehicle Vs Vehicle Damage!
 +
var globalconfig bool bUseForKnights;
 +
var globalconfig bool bUseForRooks; //Castles cant have vampire :S
 +
 
 +
/** Conversion of damage to armour or damage to health, varies depending on armour.
 +
Armour is based on the amount of damage it blocks. */
 +
var float ConversionRatio;
 +
 
 +
/** The delay between taking the damage and recieving it back as health */
 +
var() bool bUseRewardDelay;
 +
var() float RewardDelay;
 +
var float PassReward;
 +
var pawn EnemyP;
 +
 
 +
var() bool bUsePercentageReward;
 +
 
 +
/** Linear falloff for damage conversion based on the distance from the target.*/
 +
//var() interp float FalloffExponent;
 +
//var() float MaxConversionDistance; //relevant only with distance falloff!
 +
var bool bUseFalloff;
 +
var fRange Falloff;
 +
 
 +
/*struct DmgFalloff
 
{
 
{
Enemy.Damage = Enemy.Damage * UT_MDB_GameExp(UT_GR_Info(MasterGR).GameExp).SelfRecievedDmgScale;
+
var float Distance;
return Super.SelfDamage(Enemy);
+
var float Percentage;
}
+
};
 +
var array<DmgFalloff> Falloff;*/
  
//Global GameExp: Bot Damage Scaling, Vehicle Damage Scaling
+
function int ModifyDamageTaken(UT_GR_Info.EnemyInfo Enemy, optional pawn Injured)
function int DamageTaken(UT_GR_Info.EnemyInfo Enemy, optional pawn Injured)
+
 
{
 
{
`logd("Enemy.Damage = "$Enemy.Damage,,'GlobalDamage');
+
local float FalloffPercent;
  
if(Enemy.bIsBot)
+
//Rule_Variation: This is a Percentage Variation on the Damage by +/- 25%
Enemy.Damage = Enemy.Damage * UT_MDB_GameExp(UT_GR_Info(MasterGR).GameExp).BotImpartedDmgScale;
+
Enemy.Damage = bUsePercentageReward ? int(fRandPercent(Enemy.Damage, 0.25)) : Enemy.Damage;
 +
//Enemy.ModifiedDamage = bUsePercentageReward ? int(fRandPercent(Enemy.Damage, 0.25)) : Enemy.Damage;
  
if(Enemy.Type == ET_Infantry)
+
//Rule_Variation: Falloff based on Players Distance to the enemy.
 +
if(bUseFalloff)
 
{
 
{
//TODO: Get value from GameExp, Default 1.0
+
FalloffPercent = ((1 - (VSize(Enemy.Pawn.Location - Injured.Location) - Falloff.Min)) / (Falloff.Max - Falloff.Min));
if(Vehicle(Injured) != none && ClassIsChildOf(Enemy.DamageType,class'UTDamageType'))
+
ConversionRatio = ConversionRatio * FalloffPercent;
Enemy.Damage = Enemy.Damage * UT_MDB_GameExp(UT_GR_Info(MasterGR).GameExp).VehicleRecievedDmgScale;
+
`Logd("Enemy.Damage = "$Enemy.Damage$"; FalloffPercent = "$FalloffPercent$";  ConversionRatio = "$ConversionRatio,, 'DmgConvert');
 +
//`Logd("DamageConversion: Distance to Enemy:"$VSize(Enemy.Pawn.Location-Injured.Location),, 'DmgConvert');
 
}
 
}
  
if(Enemy.Type == ET_Vehicle)
+
return super.ModifyDamageTaken(Enemy,Injured);
 +
}
 +
 
 +
function RewardTimer()
 +
{
 +
if(EnemyP != none && Vehicle(EnemyP) == none)
 +
EnemyP.Health = PassReward;
 +
else if(Vehicle(EnemyP) != none)
 +
Vehicle(EnemyP).HealDamage(PassReward, EnemyP.Controller, class'UTDmgType_LinkBeam'); //h4z
 +
}
 +
 
 +
static final function float fRandBetween(float Min, float Max)
 +
{
 +
return FRand() * (Max - Min) + Min;
 +
}
 +
 
 +
//static final simulated function  float RandRange( float InMin, float InMax )
 +
 
 +
//TODO: Vampire/EnergyLeech, give conversion ration +/-25% //25% of Conversion and/or damage
 +
final function float PercentConversion(float A, float Percent)
 +
{
 +
return (Rand(2)>0) ? A+A*Percent : A-A*Percent;
 +
}
 +
 
 +
final function float fRandPercent(float A, float Percent)
 +
{
 +
//return (Rand(2)>0) ? A+A*Rand(Percent) : A-A*Rand(Percent);
 +
return (Rand(2)>0) ? A+A*fRandBetween(0, Percent) : A-A*fRandBetween(0, Percent);
 +
}
 +
 
 +
//FROM: Unreal 2
 +
// Randomly modifies the given float by +/- given %.
 +
// e.g. PerturbFloatPercent( 100.0, 20.0) will return a value in 80.0..120.0
 +
/*static final function float PerturbFloatPercent(float Num, float PerturbPercent){
 +
local float Perturb;
 +
 
 +
Perturb = 2.0*PerturbPercent / 100.0;
 +
return Num + Num * ( ( Perturb * FRand() - Perturb / 2.0 ) );
 +
}*/
 +
 
 +
/*static final function int PerturbInt(int Num, int PerturbPlusMinus){
 +
return Num + Rand( 2*PerturbPlusMinus +  1 ) - PerturbPlusMinus;
 +
}*/
 +
 
 +
/*function CausePainTo(Actor Other)
 +
{
 +
if (DamagePerSec > 0)
 
{
 
{
// if(UTPawn(Injured) != none)
+
if ( WorldInfo.bSoftKillZ && (Other.Physics != PHYS_Walking) )
Enemy.Damage = Enemy.Damage * UT_MDB_GameExp(UT_GR_Info(MasterGR).GameExp).VehicleImpartedDmgScale;
+
return;
 +
if ( (DamageType == None) || (DamageType == class'DamageType') )
 +
`log("No valid damagetype specified for "$self);
 +
Other.TakeDamage(DamagePerSec, DamageInstigator, Location, vect(0,0,0), DamageType);
 
}
 
}
 +
else
 +
{
 +
Other.HealDamage(DamagePerSec, DamageInstigator, DamageType);
 +
}
 +
}*/
  
Enemy.Damage = Enemy.Damage * UT_MDB_GameExp(UT_GR_Info(MasterGR).GameExp).ImpartedDmgScale;
+
defaultproperties
 +
{
 +
bUsePercentageReward=True
  
`logd("Enemy.Damage = "$Enemy.Damage,,'GlobalDamage');
+
bUseRewardDelay=False
 +
RewardDelay=0.4
  
return Super.DamageTaken(Enemy,Injured);
+
bUseFalloff=False
 +
Falloff=(Min=200, Max=1300)
 
}
 
}
 
</uscript>
 
</uscript>

Revision as of 23:09, 18 April 2010

Code

UT3 UT_MDB >> UT_MDB_GameRules >> UT_MDB_GR_DmgConversion >> UT_MDB_GR_GlobalDamage (custom)

Contents

Package: 
UT_GameDex

Script

//===================================================
//	Class: UT_MDB_GR_DamageConversion
//	Creation date: 20/08/2009 14:46
//	Last Updated: 14/04/2010 06:58
//	Contributors: 00zX
//---------------------------------------------------
//	Attribution-Noncommercial-Share Alike 3.0 Unported
//	http://creativecommons.org/licenses/by-nc-sa/3.0/
//---------------------------------------------------
//-Vampire/EnergyLeech, give conversion ratio +/-25%
//
//-Reward Delays
//-TODO: Vampire/EnergyLeech, Falloff based on distance/view of target
//===================================================
class UT_MDB_GR_DamageConversion extends UT_MDB_GameRules
	config(Newtators);
 
`include(MOD.uci)
 
var globalconfig bool	bUseSuperHealth;
var globalconfig bool	bUseForVehicles;	//Infantry Vs Vehicle || Vehicle Vs Vehicle Damage!
var globalconfig bool	bUseForKnights;
var globalconfig bool	bUseForRooks;		//Castles cant have vampire :S
 
/** Conversion of damage to armour or damage to health, varies depending on armour.
	Armour is based on the amount of damage it blocks. */
var float				ConversionRatio;
 
/**	The delay between taking the damage and recieving it back as health */
var() bool				bUseRewardDelay;
var() float				RewardDelay;
var float				PassReward;
var pawn				EnemyP;
 
var() bool				bUsePercentageReward;
 
/** Linear falloff for damage conversion based on the distance from the target.*/
//var() interp float		FalloffExponent;
//var() float				MaxConversionDistance;	//relevant only with distance falloff!
var bool				bUseFalloff;
var fRange				Falloff;
 
/*struct DmgFalloff
{
	var float Distance;
	var float Percentage;
};
var array<DmgFalloff> Falloff;*/
 
function int ModifyDamageTaken(UT_GR_Info.EnemyInfo Enemy, optional pawn Injured)
{
	local float FalloffPercent;
 
	//Rule_Variation: This is a Percentage Variation on the Damage by +/- 25%
	Enemy.Damage = bUsePercentageReward ? int(fRandPercent(Enemy.Damage, 0.25)) : Enemy.Damage;
	//Enemy.ModifiedDamage = bUsePercentageReward ? int(fRandPercent(Enemy.Damage, 0.25)) : Enemy.Damage;
 
	//Rule_Variation: Falloff based on Players Distance to the enemy.
	if(bUseFalloff)
	{
		FalloffPercent = ((1 - (VSize(Enemy.Pawn.Location - Injured.Location) - Falloff.Min)) / (Falloff.Max - Falloff.Min));
		ConversionRatio = ConversionRatio * FalloffPercent;
		`Logd("Enemy.Damage = "$Enemy.Damage$"; FalloffPercent = "$FalloffPercent$";  ConversionRatio = "$ConversionRatio,, 'DmgConvert');
		//`Logd("DamageConversion: Distance to Enemy:"$VSize(Enemy.Pawn.Location-Injured.Location),, 'DmgConvert');
	}
 
	return super.ModifyDamageTaken(Enemy,Injured);
}
 
function RewardTimer()
{
	if(EnemyP != none && Vehicle(EnemyP) == none)
		EnemyP.Health = PassReward;
	else if(Vehicle(EnemyP) != none)
		Vehicle(EnemyP).HealDamage(PassReward, EnemyP.Controller, class'UTDmgType_LinkBeam');	//h4z
}
 
static final function float fRandBetween(float Min, float Max)
{
	return FRand() * (Max - Min) + Min;
}
 
//static final simulated function  float RandRange( float InMin, float InMax )
 
//TODO: Vampire/EnergyLeech, give conversion ration +/-25% //25% of Conversion and/or damage
final function float PercentConversion(float A, float Percent)
{
	return (Rand(2)>0) ? A+A*Percent : A-A*Percent;
}
 
final function float fRandPercent(float A, float Percent)
{
	//return (Rand(2)>0) ? A+A*Rand(Percent) : A-A*Rand(Percent);
	return (Rand(2)>0) ? A+A*fRandBetween(0, Percent) : A-A*fRandBetween(0, Percent);
}
 
//FROM: Unreal 2
// Randomly modifies the given float by +/- given %.
// e.g. PerturbFloatPercent( 100.0, 20.0) will return a value in 80.0..120.0
/*static final function float PerturbFloatPercent(float Num, float PerturbPercent){
	local float Perturb;
 
	Perturb = 2.0*PerturbPercent / 100.0;
	return Num + Num * ( ( Perturb * FRand() - Perturb / 2.0 ) );
}*/
 
/*static final function int PerturbInt(int Num, int PerturbPlusMinus){
	return Num + Rand( 2*PerturbPlusMinus +  1 ) - PerturbPlusMinus;
}*/
 
/*function CausePainTo(Actor Other)
{
	if (DamagePerSec > 0)
	{
		if ( WorldInfo.bSoftKillZ && (Other.Physics != PHYS_Walking) )
			return;
		if ( (DamageType == None) || (DamageType == class'DamageType') )
			`log("No valid damagetype specified for "$self);
		Other.TakeDamage(DamagePerSec, DamageInstigator, Location, vect(0,0,0), DamageType);
	}
	else
	{
		Other.HealDamage(DamagePerSec, DamageInstigator, DamageType);
	}
}*/
 
defaultproperties
{
	bUsePercentageReward=True
 
	bUseRewardDelay=False
	RewardDelay=0.4
 
	bUseFalloff=False
	Falloff=(Min=200, Max=1300)
}