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.

Trouble with simple weaon mutator

Discussion in 'Programming' started by Undertaker989, Aug 13, 2003.

  1. Undertaker989

    Undertaker989 New Member

    Joined:
    Aug 13, 2003
    Messages:
    39
    Likes Received:
    0
    Trouble with simple weaon mutator--fixed and a link

    OK, I'm making a mutator much like the HE chaingun tut does in the Wiki:
    http://wiki.beyondunreal.com/wiki/Weapon_Mutator_Tutorial

    basically, what I want to do is cause a redeemer explosion when an assaultrifle grenade is supposed to explode. I sublcassed the assaultriflegrenade class to change the projectile to a redeemer projectile and I also spawned a redeemer projectile (did this after just changing the default properties to redeemer projectile didn't work) instead of the grenade in the spawn function of the assaultriflegrenade class.

    I know all the subclassing in the world won't make the code run in the game, so I followed the tutorial's way of making the mutator to replace the weapon in the game. Everything compiled except the mutator subclass I made b/c it had a problem with the 'config(user);' part. I took it out, then compiled fine, but, no redeemer explosion in the game. I think this is the root of the problem, but I don't know how else to replace the weapon w/ the new weaponsubclass I made.

    here is the code that I have for what I'm trying to do (for some its easier than my long ass description):

    Code:
    class AssaultRifleN extends AssaultRifle;
    
    defaultproperties
    {
         FireModeClass(1)=Class'assaultrifleN.AssaultGrenadeN'
         PickupClass=Class'assaultrifleN.AssaultRiflePickupN'
    }
    
    Code:
    class AssaultRiflePickupN extends AssaultRiflePickup;
    
    defaultproperties
    {
         InventoryType=class'assaultrifleN.AssaultRifleN'
         PickupMessage="You have some good ****"
    }
    
    Code:
    class AssaultGrenadeN extends AssaultGrenade;
    
    function projectile SpawnProjectile(Vector Start, Rotator Dir)
    {
        local RedeemerProjectile g;
        local vector X, Y, Z;
        local float pawnSpeed;
    
        g = Spawn(class'RedeemerProjectile', self,, Start, Dir);
        if (g != None)
        {
            Weapon.GetViewAxes(X,Y,Z);
            pawnSpeed = X dot Instigator.Velocity;
    
    		if ( Bot(Instigator.Controller) != None )
    			g.Speed = mHoldSpeedMax;
    		else
    			g.Speed = mHoldSpeedMin + HoldTime*mHoldSpeedGainPerSec;
    		g.Speed = FClamp(g.Speed, mHoldSpeedMin, mHoldSpeedMax);
            g.Speed = pawnSpeed + g.Speed;
            //g.Speed = FClamp(g.Speed, mSpeedMin, mSpeedMax);
            g.Velocity = g.Speed * Vector(Dir);
    
            g.Damage *= DamageAtten;
        }
        return g;
    }
    
    defaultproperties
    {
         ProjectileClass=Class'XWeapons.RedeemerProjectile'
    }
    
    Code:
    class grenadearena extends Mutator
        config(user);
    
    function bool CheckReplacement( Actor Other, out byte bSuperRelevant )
    {
        bSuperRelevant = 0;
        if ( xWeaponBase(Other) != None )
        {
            if ( xWeaponBase(Other).WeaponType == class'AssaultRifle' )
                xWeaponBase(Other).WeaponType = class'AssaultRifleN';
            else
                return true;
        }
        else if ( WeaponPickup(Other) != None )
        {
            if ( string(Other.Class) ~= "xWeapons.AssaultRiflePickup" )
                ReplaceWith( Other, "assaultrifleN.AssaultRiflePickupN");
            else
                return true;
        }
        else
            return true;
    
        return false;
    }
    
    defaultproperties
    {
         GroupName="grenadearena"
         FriendlyName="grenadearena"
         Description="you got some good ****"
    }
    
    any help would be great...again..I think it is a problem w/ the mutator subclass not pointing to my weapon subclass...
     
    Last edited: Aug 15, 2003
  2. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,910
    Likes Received:
    35
    Please use
    Code:
     tags when posting code here.
    
    Add some logging to your classes to make sure they are actually used. (also see [url=http://wiki.beyondunreal.com/wiki/Debugging_Techniques]UnrealWiki: Debugging Techniques[/url])
    
    My suggestion would be thinking about what your mutator class actually does. It replaces Assault Rifle [i]pickups[/i] with your own pickups. This won't have any effect in most, if not all maps simply because there are no Assault Rifle pickups, you start with the Assault Rifle in your inventory.
     
  3. RegularX

    RegularX Master of Dagoth Lies

    Joined:
    Feb 2, 2000
    Messages:
    1,215
    Likes Received:
    0
    A few suggestions on debugging weapon mutes:

    1) Make sure you update the ItemName of the weapon class. You need to that anyway, which I don't think the MiniHE tute mentions, because it's written kinda poorly.

    2) Add a weapon entry to your mutator's package INT file. You can use xWeapons.int as an example if need be. You need to do this as well, because it's the only way to get non-specific code to recognize your weapons, and the MiniHE tute should mention this as well.

    3) With the above two things done you *should* be able to put your weapon into the game using normal arena mutators like, well, arena or WORM or SwitchArsenal or InstantWeapon. It will show up on the list with your new ItemName. This way you can test your weapon seperate from your arena mute.

    4) The class detection code in the MiniHE tute and the xpak code in general has been deemed, well, messy. There are better, more reliable methods.

    5) As Wormbo said - AR is a special case. Look at the Assault Rifle Magnum code in the xpaks (there is a link to the code off the MiniHE tute I think) - what you need to change is the default weapon instead.
     
  4. Undertaker989

    Undertaker989 New Member

    Joined:
    Aug 13, 2003
    Messages:
    39
    Likes Received:
    0
    Wormbo: sorry about the lack of tags man... I'll sure use them in the future as they come in handy.

    I've decided I got sloppy w/ my class names and that it was something I was overlooking concerning the assault rifle seeing it is the initial weapon. I think it is that I didn't change the default weapon as RegularX said.

    I decided to start over from scratch and to change the rocket launcher into a grenade launcher that has a modified redeemer explosion. SUCCESS!! I made sure I tweaked the functions in the classes as opposed to just changing the default properties. I know that changing just the default properties won't do squat in most cases, and must seem retarded, but I'm just making these weapon mutators to learn Uscript/get back into the swing of programming. It has been about 2 years since my C++ class. Learning is my main purpose for making these weapon mutators basically...

    Soooo here is a .zip of my weapon mutator so you guys can enjoy/critique if you desire.

    http://www.members.cox.net/bsimeon1/Bweapons.zip

    have fun!
     

Share This Page