| Home Page | Recent Changes | Preferences

MCloudZone

Actor >> Info (UT) >> ZoneInfo >> MCloudZone

Sorry for any mistakes by English is not my native language.

The idea for this class comes to me when i found out that creating CloudZone and VacuumZone is not so good. Beside the worst thing was that CloudZone destroys all Actors (including FlagBase, CTFFlag and RedFlag?). So I change CloudZone code and mixed it up with VacuumZone code. I hope it will be helpful for anybody.

//==========================================================
// Cloud zone is a good thing, but it destroys all actors
// that enter this zone. That's why I create this class :)
//==========================================================
// Basicly it kills all pawns instantly or like Vacuum Zone.
// Bot's are killed instantly.
//==========================================================
// CTF flag stays :)
// Projectiles are destroyed
//==========================================================
// author: Raven
// I use Vacuum Zone code.
//==========================================================
// If You want to use this script put me in Credits.
class MCloudZone extends ZoneInfo;

var int Damage;
var name DamageType;
var() bool bKillInstantly;        // Player should be killed instantly after entered this zone?
var() float  KillTime;            // How long to kill the player?
var() float  StartFlashScale;     // Fog values for client death sequence
var() Vector StartFlashFog;
var() float  EndFlashScale;
var() Vector EndFlashFog;
var() float  DieFOV;          // Field of view when dead (interpolates)
var() float  DieDrawScale;    // Drawscale when dead


function BeginPlay()
{
    Super.BeginPlay();
    Disable('Tick');
    DieFOV = FClamp( DieFOV, 1, 170 );
}


event ActorEntered( actor Other )
{

        Super.ActorEntered(Other);

    if (Other.IsA('Pawn'))
        {
             if(Other.IsA('PlayerPawn'))
             {
                  Pawn(Other).PlaySound( Pawn(Other).Die, SLOT_Talk );

                  if(bKillInstantly)
                  {
                    Pawn(Other).TakeDamage(Damage, Pawn(Other),Pawn(Other).Location, Vect(0,0,0), DamageType);
              }
              else if(!bKillInstantly)
              {
                    Enable('Tick');
              }
         }
             else
                  Pawn(Other).TakeDamage(Damage, Pawn(Other),Pawn(Other).Location, Vect(0,0,0), DamageType);
        }
    else if(Other.IsA('FlagBase'))
    {
             return;
        }
        else if(Other.IsA('CTFFlag'))
    {
             return;
        }
        else if(Other.IsA('RedFlag'))
    {
             return;
        }
        else
        {
             Other.Destroy();
        }
}

function Tick( float DeltaTime )
{
    local float         ratio, curScale;
    local vector        curFog;
    local PlayerPawn    pPawn;
    local Pawn P;
    local bool bActive;
    local int OldFatness;

    for ( P=Level.PawnList; P!=None; P=P.NextPawn )
    {
        // Ensure player hasn't been dispatched through other means already (suicide?)
        if( (P.Region.Zone == self) && (P.Health > 0) )
        {
            ratio = FMax(0.01,float(Max(P.Fatness,128) - P.Default.Fatness)/FMax(1,(255 - P.Default.Fatness)));
            ratio += DeltaTime/KillTime;
            bActive = true;
            // Fatness
            OldFatness = P.Fatness;
            P.Fatness = Max(P.Fatness,128) + Max(1, ratio * (255 - P.Default.Fatness) - (P.Fatness - P.Default.Fatness));
            if ( P.Fatness < Max(OldFatness,P.Default.Fatness) )
                P.Fatness = 255;

            // Fog & Field of view
            pPawn = PlayerPawn(P);
            if( pPawn != None )
            {
                curScale = (EndFlashScale-StartFlashScale)*ratio + StartFlashScale;
                curFog   = (EndFlashFog  -StartFlashFog  )*ratio + StartFlashFog;
                pPawn.ClientFlash( curScale, 1000 * curFog );

                pPawn.SetFOVAngle( (DieFOV-pPawn.default.FOVAngle)*ratio + pPawn.default.FOVAngle);
            }
            if ( P.Fatness > 250 )
            {   
                Level.Game.SpecialDamageString = DamageString;      
                P.TakeDamage
                (
                    10000,
                    P,
                    P.Location,
                    Vect(0,0,0),
                    DamageType              
                );
                MakeNormal(P);
            }
        }
    }   
    
    if( !bActive )
        Disable('Tick');
}

function MakeNormal(Pawn P)
{
    local PlayerPawn PPawn;
    // set the fatness back to normal
    P.Fatness = P.Default.Fatness;
    P.DrawScale = P.Default.DrawScale;
    PPawn = PlayerPawn(P);
    if( PPawn != None )
        PPawn.SetFOVAngle( PPawn.Default.FOVAngle );
}

// When an actor leaves this zone.
event ActorLeaving( actor Other )
{
    if( Other.bIsPawn )
        MakeNormal(Pawn(Other));
    Super.ActorLeaving(Other);
}

defaultproperties
{
     Damage=999999
     DamageType='Fell'
     KillTime=2.500000
     StartFlashScale=1.000000
     EndFlashScale=1.000000
     DieFOV=90.000000
     DieDrawScale=1.000000
     DamageString="%o flayed away."
     bStatic=False
     bKillInstantly=false;
}

Category Class (UT)

Category Mapping
Category Custom Class
Category Tutorial

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