PDA

View Full Version : Quick Default Weapons Coding Question


Gnam
28th Jun 2004, 03:08 AM
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
28th Jun 2004, 08:12 AM
the mutator function GetInventoryClassOverride does exactly what youre looking for... heck, its even got instructions in its comments! :D

/* 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

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.

Gnam
28th Jun 2004, 02:19 PM
Awesome! Thanks a lot! I will try it out as soon as I get home from work tonight. :D

Gnam
3rd Jul 2004, 12:12 AM
OK, something odd has been happening... With this code, when players die, they drop default assault rifles instead of the new ones. I stuck 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.

Postal
3rd Jul 2004, 08:25 AM
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.

Gnam
4th Jul 2004, 03:29 PM
Good idea, thanks.