Deploy Regen Point (U2XMP)

  1. Introduction
  2. Code source
  3. Explication du code

Créé le 17/12/2003
Dernière mise à jour le 17/12/2003

1) Introduction

Deploy Regen Point est un mutator pour l'extention XMP d'Unreal 2, qui régénérera tous les membres d'une équipe à proximité d'un point de déploiment que cette équipe contrôle.

Top

2) Code source

Mutator:

//============================================
// Deploy Regen Point v1.00
//
// created by Crokx @ 17/12/2003 (dd/mm/yyyy)
//============================================
class DeployRegenPoint extends Mutator config(RegenPoint);


//===========
// variables
//===========
var() config int RegenAmount;
var() config int RegenRate;
var private array<DeploymentPoint> DeployPointList;


//===============
// Mutator Begin
//===============
function PostBeginPlay()
{
    PreCacheDeployPointList();

    Super.PostBeginPlay();

    SetTimer(RegenRate, TRUE);
}


//===============
// Mutator loop
//===============
function Timer()
{
    local int i;
    local U2Pawn P;

    for(i=0; i<DeployPointList.Length; i++)
    {
        if(DeployPointList[i].Team != 255) // ignore neutral point
        {
            foreach DeployPointList[i].CollidingActors(class'U2Pawn', P, 224) // Radius = 224 * DeployPointList[i].DrawScale
            {
                if((P != None)
                && (P.Health > 0)
                && (P.PlayerReplicationInfo != None)
                && (P.PlayerReplicationInfo.Team != None)
                && (P.PlayerReplicationInfo.Team.TeamIndex == DeployPointList[i].Team)
                && (P.Health < P.default.Health))
                {
                    P.Health = FMin(P.Health+RegenAmount, P.default.Health);
                    P.PlaySound(Sound'U2A.PowerUps.HealthPowerUp', SLOT_Misc, 2);
                }
            }
        }
    }
}


//===========================
// PreCache DeployPointList
//===========================
function PreCacheDeployPointList()
{
    local DeploymentPoint NextDP;

    foreach AllActors(class'DeploymentPoint', NextDP)
    {
        if(NextDP != None)
        {
            DeployPointList.Length = DeployPointList.Length+1;
            DeployPointList[DeployPointList.Length-1] = NextDP;
        }
    }

    log("DeployRegenPoint mutator: "$DeployPointList.Length$" DeploymentPoint found in "$Level.Title);
}


//=====================
// Default Properties
//=====================
defaultproperties
{
    RegenAmount=5
    RegenRate=2
}

Fichier INT:

[Public]
(Object=(Class=Class, MetaClass=Engine.Mutator, Name=DeployRegenPoint.DeployRegenPoint, Description="The DeployPoint regenerate his owned team members nearness of this point.")

Fichier INI:

[DeployRegenPoint.DeployRegenPoint]
RegenAmount=5
RegenRate=2

Top

3) Explication du code

Mutator:

Top