I search for solutions in this order: Past Code, Unreal Source, Wiki, BUF, groups.yahoo, google, screaming at monitor. – RegularX

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

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
 
Line 1: Line 1:
 
{{Infobox class
 
{{Infobox class
 
| package = UT_GameDex
 
| package = UT_GameDex
| class  = UT_MDB_GR_DmgConversion
+
| class  = UT_MDB_GR_DamageConversion
 
| game    = UT3
 
| game    = UT3
 
| engine  = UE3
 
| engine  = UE3
Line 7: Line 7:
 
| parent1 = UT_MDB_GameRules
 
| parent1 = UT_MDB_GameRules
 
| parent2 = UT_MDB
 
| parent2 = UT_MDB
 +
| parent3 = Object
 
}}
 
}}
  
Line 12: Line 13:
 
<uscript>
 
<uscript>
 
//===================================================
 
//===================================================
// Class: UT_MDB_GR_DmgConversion
+
// Class: UT_MDB_GR_DamageConversion
 
// Creation date: 20/08/2009 14:46
 
// Creation date: 20/08/2009 14:46
// Last Updated: 17/11/2009 09:34
+
// Last Updated: 14/04/2010 06:58
 
// Contributors: 00zX
 
// Contributors: 00zX
 
//---------------------------------------------------
 
//---------------------------------------------------
Line 25: Line 26:
 
//-TODO: Vampire/EnergyLeech, Falloff based on distance/view of target
 
//-TODO: Vampire/EnergyLeech, Falloff based on distance/view of target
 
//===================================================
 
//===================================================
class UT_MDB_GR_DmgConversion extends UT_MDB_GameRules
+
class UT_MDB_GR_DamageConversion extends UT_MDB_GameRules
config(Newtators);
+
implements(MDIB_GR_ModifyDamage)
 +
config(GameDex);
  
`include(MOD.uci)
+
var config bool bUseSuperHealth,
 +
bUseForVehicles, //Infantry Vs Vehicle || Vehicle Vs Vehicle Damage!
 +
bUseForKnights,
 +
bUseForRooks; //Castles cant have vampire :S
  
/** Conversion of damage to armour, varies depending on armour type.
+
/** Conversion of damage to armour or damage to health, varies depending on armour.
Armour is based on the amount of damage it blocks. */
+
 
+
/** Conversion of damage to health, varies depending on armour.
+
 
Armour is based on the amount of damage it blocks. */
 
Armour is based on the amount of damage it blocks. */
 
var float ConversionRatio;
 
var float ConversionRatio;
Line 58: Line 60:
 
var array<DmgFalloff> Falloff;*/
 
var array<DmgFalloff> Falloff;*/
  
//Global GameDex: Self Damage Scaling
+
function int ModifyDamageTaken(UT_GR_Info.EnemyInfo Enemy, optional pawn Injured)
/*function int SelfDamage(UT_GR_Info.EnemyInfo Enemy)
+
{
+
Enemy.Damage = Enemy.Damage * UT_MDB_GameExp(UT_GR_Info(MasterGR).GameExp).SelfDmgMultiplier;
+
return Super.SelfDamage(Enemy);
+
}*/
+
 
+
//Global GameDex: Bot Damage Scaling, Vehicle Damage Scaling
+
function int DamageTaken(UT_GR_Info.EnemyInfo Enemy, optional pawn Injured)
+
 
{
 
{
 
local float FalloffPercent;
 
local float FalloffPercent;
 
/* if(Enemy.bIsBot)
 
Enemy.Damage = Enemy.Damage * UT_MDB_GameExp(UT_GR_Info(MasterGR).GameExp).BotDmgMultiplier;
 
 
if(Enemy.Type == ET_Vehicle){
 
// if(Enemy.Pawn == Vehicle(Enemy.Pawn)){
 
//TODO: Get value from GameDex, Default 1.0
 
Enemy.Damage = Enemy.Damage * UT_MDB_GameExp(UT_GR_Info(MasterGR).GameExp).VehicleDmgMultiplier;
 
// }
 
}*/
 
  
 
//Rule_Variation: This is a Percentage Variation on the Damage by +/- 25%
 
//Rule_Variation: This is a Percentage Variation on the Damage by +/- 25%
Enemy.ModifiedDamage=bUsePercentageReward ? int(fRandPercent(Enemy.Damage, 0.25)) : Enemy.Damage;
+
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.
 
//Rule_Variation: Falloff based on Players Distance to the enemy.
if(bUseFalloff){
+
if(bUseFalloff)
FalloffPercent=1-(DistToEnemy(Enemy, Injured)-Falloff.Min)/Falloff.Max-Falloff.Min;
+
{
ConversionRatio=ConversionRatio*FalloffPercent;
+
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("Enemy.Damage = "$Enemy.Damage$"; FalloffPercent = "$FalloffPercent$";  ConversionRatio = "$ConversionRatio,, 'DmgConvert');
 +
//`Logd("DamageConversion: Distance to Enemy:"$VSize(Enemy.Pawn.Location-Injured.Location),, 'DmgConvert');
 
}
 
}
  
return Super.DamageTaken(Enemy,Injured);
+
return super.ModifyDamageTaken(Enemy,Injured);
 
}
 
}
  
Line 101: Line 88:
 
}
 
}
  
static final function float fRandBetween(float Bottom, float Top)
+
static final function float fRandBetween(float Min, float Max)
 
{
 
{
return FRand()* (Top-Bottom) + Bottom;// return FClamp(FRand(), Bottom, Top);
+
return FRand() * (Max - Min) + Min;
 
}
 
}
  
Line 114: Line 101:
 
}
 
}
  
final function float fRandPercent(float A, float Pcnt)
+
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*Rand(Percent) : A-A*Rand(Percent);
// return (Rand(2)>0) ? A+A*FClamp(FRand(), A*Percent, A) : A-A*FClamp(FRand(), A*Percent, A);
+
return (Rand(2)>0) ? A+A*fRandBetween(0, Percent) : A-A*fRandBetween(0, Percent);
return (Rand(2)>0) ? A+A*fRandBetween(0,Pcnt) : A-A*fRandBetween(0,Pcnt);
+
 
}
 
}
  
Line 135: Line 121:
 
}*/
 
}*/
  
 
+
/*function CausePainTo(Actor Other)
//TODO: Vampire/EnergyLeech, Falloff based on distance/view of target
+
final function float DistToEnemy(UT_GR_Info.EnemyInfo Enemy, pawn Injured)
+
 
{
 
{
local float Dist;
+
if (DamagePerSec > 0)
 
+
{
Dist = VSize(Enemy.Pawn.Location-Injured.Location);
+
if ( WorldInfo.bSoftKillZ && (Other.Physics != PHYS_Walking) )
`Logd("DamageConversion: Distance to Enemy:"$Dist,, 'DmgConvert');
+
return;
return Dist;
+
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
 
defaultproperties
Line 153: Line 144:
 
RewardDelay=0.4
 
RewardDelay=0.4
  
bUseFalloff=True
+
bUseFalloff=False
 
Falloff=(Min=200, Max=1300)
 
Falloff=(Min=200, Max=1300)
 
}
 
}
 
</uscript>
 
</uscript>

Latest revision as of 07:13, 21 April 2010

UT3 Object >> UT_MDB >> UT_MDB_GameRules >> UT_MDB_GR_DamageConversion (custom)

Contents

Package: 
UT_GameDex
Known custom subclass:
UT_MDB_GR_GlobalDamage (UT3)

Code[edit]

//===================================================
//	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
	implements(MDIB_GR_ModifyDamage)
	config(GameDex);
 
var config bool			bUseSuperHealth,
						bUseForVehicles,	//Infantry Vs Vehicle || Vehicle Vs Vehicle Damage!
						bUseForKnights,
						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)
}