1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Weapon Mutator Help

Discussion in 'Programming' started by yallDropDead, Aug 24, 2005.

  1. yallDropDead

    yallDropDead New Member

    Joined:
    Aug 16, 2005
    Messages:
    10
    Likes Received:
    0
    so basically i took the code from the unreal wiki Minigun Alt Fire HE tutorial, and am trying to put it into the Assault Rifle. I can see the mutator on the list, but it has no effect.

    here.

    Code:
    class ARHE extends AssaultRifle;
    
    //======================================
    defaultproperties
    {
        FireModeClass(0)=class'ARHEFire'
        PickupClass=class'ARHEPickup'
    }
    Code:
    class ARHEFire extends AssaultFire;
    
    var() class<Actor> ExplosionClass;
    var() class<Projector> ExplosionDecalClass;
    
    //=======================================
    function BlowUp(vector HitLocation)
    {
        Instigator.HurtRadius(15, 45, DamageType, 250, HitLocation );
        Instigator.MakeNoise(1.0);
    }
    
    //==========================================
    simulated function Explode(vector HitLocation, vector HitNormal)
    {
        Instigator.PlaySound(sound'WeaponSounds.BExplosion3',,2.5*TransientSoundVolume);
    
        if ( Instigator.EffectIsRelevant(HitLocation,false) )
        {
            Instigator.Spawn(ExplosionClass,,,HitLocation + HitNormal*16,rotator(HitNormal));
            Instigator.Spawn(ExplosionDecalClass,,,HitLocation, rotator(HitNormal));
        }
    
        BlowUp(HitLocation);
    }
    
    //========================================
    simulated function SpawnBeamEffect(Vector Start, Rotator Dir, Vector HitLocation, Vector HitNormal, int ReflectNum)
    {
        Super.SpawnBeamEffect( Start, Dir, HitLocation, HitNormal, ReflectNum);
        Explode( HitLocation, HitNormal );
    }
    
    //==========================================
    {
        ExplosionClass=class'NewExplosionB'
        ExplosionDecalClass=class'RocketMark'
    }
    Code:
    class ARHEPickup extends AssaultRiflePickup;
    
    //=========================================
    defaultproperties
    {
        InventoryType=class'ARHE'
        PickupMessage="You got the Assault Rifle HE."
    }
    Code:
    class MutARHE extends Mutator
        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.AssaultRifle" )
            {
                xWeaponBase(Other).WeaponType = class'ARHE';
                return false;
            }
        }
        else if ( WeaponPickup(Other) != None )
        {
            if ( string(Other.Class) ~= "XWeapons.AssaultRiflePickup" )
            {
                ReplaceWith( Other, "ARHEPickup" );
                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.AssaultRifle" )
                    L.Weapons[i].WeaponClass = class'ARHE';
            }
        }
    
        return true;
    }
    
    //==============================================
    defaultproperties
    {
         GroupName="ARHE"
         FriendlyName="ARHE"
         Description="Change Assault Rifle rounds to High Explosive rounds."
    }
     
  2. yallDropDead

    yallDropDead New Member

    Joined:
    Aug 16, 2005
    Messages:
    10
    Likes Received:
    0
    can anyone help me out? i normally wouldn't bump like this but i really think someone here can help me.
     
  3. rich_zap

    rich_zap New Member

    Joined:
    Jul 18, 2004
    Messages:
    133
    Likes Received:
    0
    Well to me the only thing that jumps out is the mutator, its a bit.... odd. You seem to be trying to replace an object with a class and i have no idea what ~= is supposed to do (although that could be a gap in my own knowledge).

    If we look at the code from another recent mutator thread it looks like this:

    Code:
    class MutUberLinkGun extends Mutator;
    
    function bool CheckReplacement( Actor Other, out byte bSuperRelevant )
    {
    
       local int i;                // for UT2004 Onslaught weapon lockers
    
       local WeaponLocker L;       // for UT2004 Onslaught weapon lockers
    
       bSuperRelevant = 0;
    
       if (XWeaponBase(Other) != None) 
       {
          if (XWeaponBase(Other).WeaponType == Class'XWeapons.LinkGun') 
             XWeaponBase(Other).WeaponType = Class'XWeapons.UberLinkGun'; 
          else 
             return true;  
       }  
       else if (WeaponPickup(Other) != None) 
       { 
       if (String(Other.Class) ~= "XWeapons.LinkGun") 
             ReplaceWith(Other, "XWeapons.UberLinkGun");
          else 
             return true; 
       }
       else if ( WeaponLocker(Other) != None )
       {
          L = WeaponLocker(Other);
          for (i = 0; i < L.Weapons.Length; i++)
             if ( string( L.Weapons[i].WeaponClass ) ~= "XWeapons.LinkGun" )
                L.Weapons[i].WeaponClass = Class'XWeapons.UberLinkGun';
    
          return true;
       }
       else 
          return true;
    
       return false;
    }
    
    defaultproperties 
    { 
       FriendlyName="UberLinkGunMutator" 
       Description="This makes the link guns fire rockets." 
    }
    Try using this instead :)
     
  4. yallDropDead

    yallDropDead New Member

    Joined:
    Aug 16, 2005
    Messages:
    10
    Likes Received:
    0
    it's still not working, but i'll keep playing around with it. please tell me what '~=' means i'm not familiar with it. i know all the rest, != is not equal, == is equal, >, <, >=, <=.
     
  5. SuperApe

    SuperApe Registered Monkey

    Joined:
    Mar 20, 2004
    Messages:
    333
    Likes Received:
    0
    I'm not sure what it would mean in this case, but...
    Perhaps it would mean, error.
     
  6. yallDropDead

    yallDropDead New Member

    Joined:
    Aug 16, 2005
    Messages:
    10
    Likes Received:
    0
    that's what i thought it was, but why would you use it to determine if the weapon is a link gun? why not just ==?

    and i don't think the problem is in MutARHE, i'm pretty sure it's in ARHEFire.uc, but then again, why don't i just get an error?.

    this just occored to me, would any problem come from the assault rifle having an atachment? (aka the dual wield option)
     
    Last edited: Aug 26, 2005
  7. SkullKrusher

    SkullKrusher New Member

    Joined:
    Sep 4, 2004
    Messages:
    25
    Likes Received:
    0
    if (String(Other.Class) ~= "XWeapons.LinkGun") ----- you posted

    prbly should be

    if (String(Other.Class) != "XWeapons.LinkGun") ---- does not Equal
     
  8. datacable

    datacable N00b coder

    Joined:
    Sep 2, 2002
    Messages:
    60
    Likes Received:
    0
    As in SuperApe's second definition of "approximately equal," when comparing strings, the ~= operator tests for "case-insensitive equality".

    Both of these expressions would evaluate to true:

    "This String" ~= "This String"
    "This String" ~= "tHiS sTrInG"


    Whereas this expression would evaluate to false:

    "This String" == "tHiS sTrInG"


    The operator is used in this case because the coder didn't want the capitalization of the class name to affect the test for equality.

    [Edit: I just changed the ~= definition slightly on the Operators page of the Wiki. "Case-insensitivity" was a little vague]
     
    Last edited: Aug 27, 2005
  9. SuperApe

    SuperApe Registered Monkey

    Joined:
    Mar 20, 2004
    Messages:
    333
    Likes Received:
    0
    That's good to know. Thanks. :D
     
  10. Jeffez

    Jeffez New Member

    Joined:
    Aug 24, 2005
    Messages:
    6
    Likes Received:
    0
    With the mutator code above in post #3 before i could get it to work, i realised that the custom weapon class isn't referenced inside XWeapons. Eg Class'XWeapons.UberLinkGun' wont work. Instead use Class'UberLinkGun'.
     

Share This Page