Quick Default Weapons Coding Question

  • 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.

Gnam

Member
Feb 13, 2002
515
0
16
40
Yes, please.
OK, I'm making a mutator for 2k4 that replaces the assault rifle with my modified assault rifle. I am using the DefaultWeapon property to get the new AR in there, my problem is getting the old AR out. Right now the mutator spawns the player with the shield gun, the vanilla AR, and my modded AR. Is There a simple way to just disable a default weapon? BTW, I'm new to coding so please nothing unnessesarily complicated. Thanks.
 

EvilDrWong

Every line of code elevates you
Jun 16, 2001
932
0
0
40
Inside the machine
Visit site
the mutator function GetInventoryClassOverride does exactly what youre looking for... heck, its even got instructions in its comments! :D
Code:
/* GetInventoryClassOverride()
return the string passed in, or a replacement class name string.
*/
function string GetInventoryClassOverride(string InventoryClassName)
{
    // here, in mutator subclass, change InventoryClassName if desired.  For example:    
    // if ( InventoryClassName == "Weapons.DorkyDefaultWeapon"
    //		InventoryClassName = "ModWeapons.SuperDisintegrator"

    if ( NextMutator != None )
        return NextMutator.GetInventoryClassOverride(InventoryClassName);
    return InventoryClassName;
}
So what you'd do is say something like
Code:
    if(InventoryClassName~="xWeapons.AssaultRifle")
        return "YourPackage.AssKickingAssaultRifleReplacement";

Im gonna try and use my magic powers to move this to a more proper place. Lets see how that goes.
 
Last edited:

Gnam

Member
Feb 13, 2002
515
0
16
40
Yes, please.
OK, something odd has been happening... With this code, when players die, they drop default assault rifles instead of the new ones. I stuck
Code:
	else if ( AssaultRiflePickup(Other) != None )
        {
		ReplaceWith( Other, "ProWeapons.ProAssaultRiflePickup");
                return false;
in my list of replacement code, and now players drop the new assault rifles when they die. The only thing is, the pickups don't disapear after the set time like they're supposed to. It isn't a huge problem but it is something I'd like to correct just cause its not something I planned to happen.

Also...
Is there a way to disable the akimbo feature? I was thinking I could just delete all the lines of the AR code that have to do with the akimbo stuff. I'd rather just get more ammo. Only problem is knowing what stuff to delete. I don't want to screw anything up. Thanks in advance for any help that may be given.
 
Last edited:

Postal

I apear to have lost my pin.
Nov 14, 1999
1,388
0
0
WoD.BeyondUnreal.com
Dont delete it, first just put a // in front of those lines, that way, Unreal will ignore it. When you are sure you got the right ones, then you can delete them perment like.