| Home Page | Recent Changes | Preferences

Warp Zone Trace Weapons

This system is designed to let trace weapons fire through warp zones. This particular setup is for two areas with warp zones on the ceilings.

class CeilingWarpMutatorActor extends Actor
    placeable;

function PreBeginPlay()
{
    super.PreBeginPlay();
    if(Level.Game != none)
        Level.Game.AddMutator("CeilingWarp.CeilingWarpMutator");
}

DefaultProperties
{
    bHidden=true
}
class CeilingWarpMutator extends Mutator;

function ModifyPlayer(Pawn ThePawn)
{
    if(xPawn(ThePawn) != none)
        xPawn(ThePawn).RequiredEquipment[0] = "CeilingWarp.WarpAssaultRifle";
}

DefaultProperties
{
}
class CeilingWarpZoneInfo extends WarpZoneInfo;

var() vector WarpOffset;

DefaultProperties
{
}
class WarpTestActor extends Actor;

// Might not be necessary, could just use a LookTarget or some other actor.

DefaultProperties
{
    bHidden=true
}
class WarpAssaultRifle extends AssaultRifle;

var WarpTestActor TestPoint;

simulated function Destroyed()
{
    if(TestPoint != None)
        TestPoint.Destroy();
    Super.Destroyed();
}

DefaultProperties
{
    PickupClass=class'WarpAssaultRiflePickup'
    FireModeClass(0)=WarpAssaultFire
}
class WarpAssaultRiflePickup extends AssaultRiflePickup;

DefaultProperties
{
    InventoryType=class'WarpAssaultRifle'
}
class WarpAssaultFire extends AssaultFire;

function DoTrace(Vector Start, Rotator Dir)
{
    local Vector X, End, HitLocation, HitNormal, RefNormal;
    local Actor Other;
    local int Damage;
    local bool bDoReflect;

    MaxRange();

    X = Vector(Dir);
    End = Start + TraceRange * X;

    Other = Weapon.Trace(HitLocation, HitNormal, End, Start, true);

    // If there is no test point, make one.  Set the test point to the hit location.
    if(WarpAssaultRifle(Weapon).TestPoint == none)
        WarpAssaultRifle(Weapon).TestPoint = Weapon.spawn(class'WarpTestActor',Weapon,,HitLocation,rotator(HitNormal));
    else
        WarpAssaultRifle(Weapon).TestPoint.SetLocation(HitLocation);

    // If the test point is inside the warp zone, do a second trace out of the other side.
    // This section would be altered for different warp zone setups.
    if(WarpAssaultRifle(Weapon).TestPoint != none && WarpZoneInfo(WarpAssaultRifle(Weapon).TestPoint.Region.Zone) != none)
    {
        Dir.Pitch = -Dir.Pitch;
        Dir.Yaw = -Dir.Yaw;
        Start = Start + CeilingWarpZoneInfo(WarpAssaultRifle(Weapon).TestPoint.Region.Zone).WarpOffset;
        Start.Z = -Start.Z;
        Start.Y = -Start.Y;

        X = Vector(Dir);
        End = Start + TraceRange * X;

        Other = Weapon.Trace(HitLocation, HitNormal, End, Start, true);
    }

    // Normal trace stuff.
    if(Other != None && Other != Instigator)
    {
        if (bReflective && Other.IsA('xPawn') && xPawn(Other).CheckReflect(HitLocation, RefNormal, DamageMin*0.25))
        {
            bDoReflect = true;
            HitNormal = Vect(0,0,0);
        }
        else if(!Other.bWorldGeometry)
        {
            Damage = DamageMin;
            if((DamageMin != DamageMax) && (FRand() > 0.5))
                Damage += Rand(1 + DamageMax - DamageMin);
            Damage = Damage * DamageAtten;

            // Update hit effect except for pawns (blood) other than vehicles.
            if(Other.IsA('Vehicle') || (!Other.IsA('Pawn') && !Other.IsA('HitScanBlockingVolume')))
                WeaponAttachment(Weapon.ThirdPersonActor).UpdateHit(Other, HitLocation, HitNormal);

            Other.TakeDamage(Damage, Instigator, HitLocation, Momentum*X, DamageType);
            HitNormal = Vect(0,0,0);
        }
        else if(WeaponAttachment(Weapon.ThirdPersonActor) != None)
            WeaponAttachment(Weapon.ThirdPersonActor).UpdateHit(Other,HitLocation,HitNormal);
    }
    else
    {
        HitLocation = End;
        HitNormal = Vect(0,0,0);
        WeaponAttachment(Weapon.ThirdPersonActor).UpdateHit(Other,HitLocation,HitNormal);
    }

    SpawnBeamEffect(Start, Dir, HitLocation, HitNormal, 0);
}

DefaultProperties
{
}

The other trace weapons are similarly coded.

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