| Home Page | Recent Changes | Preferences

VampireGameRules

UT2003 :: Actor >> Info >> GameRules >> VampireGameRules (Package: XGame)

The VampireGameRules augments the damage dealing process in the game allowing for the damage you deal to another Pawn (that is not on your team) to be transfered to your life total (at a certain ratio).

Properties

ConversionRatio = 0.500000

Variables

ConversionRatio

Methods

int NetDamage( int OriginalDamage, int Damage, pawn injured, pawn instigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType )
Augments the damage dealing process by giving health back to the Pawn that has damaged another valid pawn.

Known Subclases

None

Code Walkthrough.

I thought that these would be useful examples to further demonstrate writing a GameRules for your game.

I've broken the code into two parts. Lets take a look at the NetDamage function first.

class VampireGameRules extends GameRules;

var() float ConversionRatio;
        
function int NetDamage( int OriginalDamage, int Damage, pawn injured, pawn instigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType )
{
    if ( NextGameRules != None )
        return NextGameRules.NetDamage( OriginalDamage,Damage,injured,instigatedBy,HitLocation,Momentum,DamageType );
    if ( (InstigatedBy != Injured) && (InstigatedBy != None) && (InstigatedBy.Health > 0) 
        && (InstigatedBy.PlayerReplicationInfo != None) && (Injured.PlayerReplicationInfo != None) 
        && ((InstigatedBy.PlayerReplicationInfo.Team == None) || (InstigatedBy.PlayerReplicationInfo.Team != Injured.PlayerReplicationInfo.Team)) )
        InstigatedBy.Health = Min( InstigatedBy.Health+Damage*ConversionRatio, Max(InstigatedBy.Health,InstigatedBy.HealthMax) );
    return Damage;
}

The block of code handles two things: Allows the other GameRules modifiers to go first; Calculates the amount of damage that the Instagator recieves back as health.

This GameRules allows all other GameRules to affect the NetDamage before it augments the damage in play. If you neglect giving the other GameRules a chance to augment NetDamage, then all other GameRules loaded after this GameRules will not have a chance to augment play.

The logic is long but not too complicated. I'll briefly explain it.

If the pawn instigating the damage didn't hurt themselves, does exists, is still alive, has PlayerReplicationInfo, his target has it as well, and is not on a team or hit someone not on his team, then calculate the health returned.

InstigatedBy.Health = Min( InstigatedBy.Health+Damage*ConversionRatio, Max(InstigatedBy.Health,InstigatedBy.HealthMax) );

This health increase is the smallest value of either the Instigator's Health plus damange, at the conversion ratio, or the maximum value of either the Instigator's Health or MaxHealth.

//
// server querying
//
function GetServerDetails( out GameInfo.ServerResponseLine ServerState )
{
    // append the gamerules name- only used if mutator adds me and deletes itself.
    local int i;
    i = ServerState.ServerInfo.Length;
    ServerState.ServerInfo.Length = i+1;
    ServerState.ServerInfo[i].Key = "Mutator";
    ServerState.ServerInfo[i].Value = GetHumanReadableName();
}

defaultproperties
{
     ConversionRatio=0.500000
}

This increases the array that stores the ServerInfo by one and appends the key Mutator and the name of the Mutator. This is in the event that the Vampire Mutator was used to load this GameRule and then has deleted itself.


Burtlo: Thought I would use the subclasses as a great oppurtunity to show how GameRules work.

Category Class (UT2003)

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In