Legacy:Defx - Unreal Wiki

# Legacy:Defx

### From Unreal Wiki, The Unreal Engine Documentation Site

### Who am i

       Noob coder with minor experience in scripting and map making

### Projects

       my goal is to make a gundam seed mod for ut2004 i know thats gonna take a while so im
       actually learning how first

#### Extended Shock Rifle (needs better name)

      This is a mutator for the Shock Rifle (duh), it is supposed to change the shock ball properties
      according to the amount of time you hold the button, better features in the future

modified classes

xShockRifle

    class xShockrifle extends ShockRifle;

    defaultproperties
    {
    FireModeClass(0)=ShockBeamFire
    FireModeClass(1)=xShockProjFire
    PickupClass=class'xShockRiflePickup'
    }

xShockRiflePickup

    class xShockRiflePickup extends ShockRiflePickup;

    defaultproperties
    {
        PickupMessage="You got the EXT Shock Rifle."
        InventoryType=class'xShockRifle'
    }

xShockProjectile

    class xShockProjectile extends ShockProjectile;

    var int ProjSpeed;

    defaultproperties
    {
        Speed=900
        MaxSpeed=900
        Damage=75
        DamageRadius=150
        MomentumTransfer=70000
        ComboDamage=500
        ComboRadius=350
        ComboMomentumTransfer=200000
        LifeSpan=20.0'
        DrawScale=1.5
        CollisionRadius=15
        CollisionHeight=15
        AmbientSound=Sound'WeaponSounds.ShockRifle.ShockRifleProjectile'
        ComboAmmoCost=5
    }
    <uscript>
    </+>
    <+>xShockProjFire
    <uscript>
    class xShockProjFire extends ShockProjFire;

    var() float         mSpeedMin;
    var() float         mSpeedMax;
    var() float         mHoldSpeedMin;
    var() float         mHoldSpeedMax;
    var() float         mHoldSpeedGainPerSec;
    var() float         mHoldClampMax;
    var float ClickTime;

    function projectile SpawnProjectile(Vector Start, Rotator Dir) //taken from AssaultGrenade
    {
        local xShockProjectile g;
        local vector X, Y, Z;

        g = Weapon.Spawn(class'xShockProjectile', instigator,, Start, Dir);
        if (g != None)
        {
            Weapon.GetViewAxes(X,Y,Z);

                    if ( Bot(Instigator.Controller) != None )
                            g.Speed = mHoldSpeedMax;
                    else
                            g.Speed = mHoldSpeedMax - HoldTime*mHoldSpeedGainPerSec;
                    g.Speed = FClamp(g.Speed, mHoldSpeedMin, mHoldSpeedMax);
            g.Velocity = g.Speed * Vector(Dir);

            g.Damage *= DamageAtten;
        }
        return g;
    }

    defaultproperties
    {
        ProjectileClass=class'xShockRifle.xShockProjectile'
        bFireOnRelease=true
        mHoldSpeedMin=850
        mHoldSpeedMax=1600
        mHoldSpeedGainPerSec=750
    }

MUTxShockRifle

    class MutxShockRifle extends Mutator //taken from [[Weapon Mutator Tuorial]]
        config(user);

    //=============================================================================
    function bool CheckReplacement( Actor Other, out byte bSuperRelevant )
    {
        local int i;
        local WeaponLocker L;

        bSuperRelevant = 0;

        if ( xWeaponBase(Other) != None )
        {
            if ( string( xWeaponBase(Other).WeaponType ) ~= "XWeapons.ShockRifle" )
            {
                xWeaponBase(Other).WeaponType = class'xShockRifle';
                return false;
            }
        }
        else if ( WeaponPickup(Other) != None )
        {
            if ( string(Other.Class) ~= "XWeapons.ShockRiflePickup" )
            {
                ReplaceWith( Other, "xShockRiflePickup" );
                return false;
            }
        }
        else if ( WeaponLocker(Other) != None )
        {
            L = WeaponLocker(Other);

            for (i = 0; i < L.Weapons.Length; i++)
            {
                if ( string( L.Weapons[i].WeaponClass ) ~= "XWeapons.ShockRifle" )
                    L.Weapons[i].WeaponClass = class'xShockRifle';
            }
        }

        return true;
    }

    //=============================================================================
    defaultproperties
    {
         GroupName="EXT ShockRifle"
         FriendlyName="EXT ShockRifle"
         Description="Gives the shockrifle extra combo power."
    }

#### Seed Mode

       its supposed to give the pawn some special
       abilities once the controller reaches 100 adrenaline

this is the current code

help would be greatly appreciated, if you want you can check my thread at BUFHere

0.2 - current (using state method, having problems with locals inside states)

    //-----------------------------------------------------------
    //       Seed mode mutator
    //-----------------------------------------------------------
    class MutSEEDmode extends Mutator;

    var int AdrenalineDecrease;

    // Don't call Actor PreBeginPlay() for Mutator
    event PreBeginPlay()
    {
            SetTimer(1.0,true);
    }

    auto state Idle
    {
        function Timer()
        {
                local Controller C;

                for (C = Level.ControllerList; C != None; C = C.NextController)
                {
                        If(C.Adrenaline == C.AdrenalineMax)
                        {
                              Gotostate('Start');
                        }

                        //if (C.Pawn != None && C.Adrenaline <= C.AdrenalineMax )
                        //{
                        //         C.Adrenaline = Min( C.Adrenaline-AdrenalineDecrease, C.AdrenalineMax );
                        //}
                }
        }
    }

    state Start
    {
            local Controller C;

            for (C = Level.ControllerList; C != None; C = C.NextController)
            {
                  if (C.Pawn != None && C.Adrenaline == 100)
                  {
                          PlayerController(C).ClientMessage("Seed Mode activated");
                          C.Pawn.Health = 199;
                          C.Pawn.GroundSpeed = 700;
                          Gotostate('Running')
                  }
            }
    }

    state Runnning
    {
            local Controller C;

            for (C = Level.ControllerList; C != None; C = C.NextController)
            {
                if (C.Pawn != None && C.Adrenaline > 0)
                {
                        C.Adrenaline -= -1;
                        Sleep(1.0);
                        Gotostate('Running')
                }
                else
                {
                        Gotostate('End')
                }
            }
    }

    state End
    {

    local Controller C;

            for (C = Level.ControllerList; C != None; C = C.NextController)
            {
                 PlayerController(C).ClientMessage("Seed Mode deactivated");
                          C.Pawn.Health = 100;
                          C.Pawn.GroundSpeed = 450;
                          Gotostate('Idle')
            }
    }

    defaultproperties
    {
           AdrenalineDecrease=1
           IconMaterialName="MutatorArt.nosym"
           ConfigMenuClassName=""
           GroupName="SEED"
           FriendlyName="SEED mode"
           Description="Seed mode is activated upon reaching 100 adrenaline."
    }

0.15 function Seedmode is being called by Timer as i have set timer to repeat every second

    //-----------------------------------------------------------
    //      SEED mode
    //-----------------------------------------------------------
    class SeedMode extends Mutator;

    var int AdrenalineDecrease;

    // Don't call Actor PreBeginPlay() for Mutator
    event PreBeginPlay()
    {
        SetTimer(1.0,true);
    }

    function Timer()
    {
            local Controller C;

            for (C = Level.ControllerList; C != None; C = C.NextController)
            {
                    If(C.Adrenaline == C.AdrenalineMax)
                    {
                             SeedMode();
                    }

                    if (C.Pawn != None && C.Adrenaline < C.AdrenalineMax )
                    {
                             C.Adrenaline = Min( C.Adrenaline-AdrenalineDecrease, C.AdrenalineMax );
                    }
            }
    }

    function SeedMode()
    {
         local Controller C;

        for (C = Level.ControllerList; C != None; C = C.NextController)
        {
             if (C.Pawn != None && C.Adrenaline == 100)
             {
                PlayerController(C).ClientMessage("Seed Mode (well mot yet =D)");
             }
        }
    }

    defaultproperties
    {
        AdrenalineDecrease=1
        IconMaterialName="MutatorArt.nosym"
        ConfigMenuClassName=""
        GroupName="SEED"
        FriendlyName="SEED mode"
        Description="Seed mode is activated upon reaching 100 adrenaline."
    }

0.1 - did not work at all

    //-----------------------------------------------------------
    //      SEED mode
    //-----------------------------------------------------------
    class SeedMode extends Mutator;

    var int AdrenalineDecrease;

    // Don't call Actor PreBeginPlay() for Mutator
    event PreBeginPlay()
    {
        SetTimer(1.0,true);
    }

    function Timer()
    {
        local Controller C;

        for (C = Level.ControllerList; C != None; C = C.NextController)
        {
                    if (C.Pawn != None && C.Adrenaline < C.AdrenalineMax )
            {
                C.Adrenaline = Min( C.Adrenaline-AdrenalineDecrease, C.AdrenalineMax );
            }
        }
    }

    function SeedMode()
    {
         local Controller C;

        for (C = Level.ControllerList; C != None; C = C.NextController)
        {
             if (C.Pawn != None && C.Adrenaline == 100)
             {
                PlayerController(C).ClientMessage("Seed Mode (well mot yet =D)");
             }
        }
    }

    defaultproperties
    {
        AdrenalineDecrease=1
        IconMaterialName="MutatorArt.nosym"
        ConfigMenuClassName=""
        GroupName="SEED"
        FriendlyName="SEED mode"
        Description="Seed mode is activated upon reaching 100 adrenaline."
    }

## Comments

MythOpus: Tip from one unreal scripter to another... Take small steps first. They really help in the long run.

Defx: Dont worry, i am ^^

Sweavo: Howdy. A tip from someone who's just spent 8 hours learning the hard way: do just about everything on the server, and test with a network game!

Guest: do just about everything on the server? what do you mean? =]

Sweavo: Check out Replication for a brain-bender. In network play, you need to be aware of what is present on the server and what is present on the client, and of the stuff that's on the client, you need to be aware of what's getting run and what isn't. In standalone mode none of that matters much. So you can get something working great in standalone mode but have to throw heaps of it away to get to network play. If your mod doesn't work in net play then it's not going to get on the public server, and won't get you chicks*.

- I can pretty much guarantee it won't get you chicks.

Category: Legacy Personal Page

##### Views

- Legacy
- Discussion
- Current revision

##### Search