Jump to content

[Mutator]Give Sniper


NodSaibot

Recommended Posts

  • Totem Arts Staff

The point of this mutator is when people type 'mutate sniper' or 'mutate SNIPER' into the command line, it will award them with a sniper. I know this has no real value, but it's just practice. There is only one problem, it won't compile due to an error in the 6th line. Apparently this has something to do with the code of Rx_InventoryManager and there is nothing I can do about it right now. Waiting for some more info from the devs.

Error	9	Bad or missing expression after '&&': 'Rx_InventoryManager'	C:\Rx_SDK\Rx_SDK_March_22_2015\Development\Src\CZ_BuySniper\Classes\CZ_BuySniper.uc	6	1	RenXMP

class CZ_BuySniper extends UTMutator;


function Mutate(string MutateString, PlayerController Sender)
{
if (Caps(MutateString) == "SNIPER" && Rx_InventoryManager(Sender.Pawn.InvManager) != none)
		Rx_InventoryManager(Sender.Pawn.InvManager).AddWeaponOfClass(class'Rx_Weapon_SniperRifle_Nod',CLASS_PRIMARY);

Super.Mutate(MutateString, Sender);

}
DefaultProperties
{
}

Link to comment
Share on other sites

Okay, I figured out what the issue was. It seems like "Rx_InventoryManager.AddWeaponOfClass" does a check to make sure you're "allowed" to have that weapon before adding it to your inventory. It does that by seeing if the class has the weapon in it's defaults, but because this is an extra weapon, it wont, so the add will fail.

Not to worry tho, we can look at the "AddWeaponOfClass" function, and just do the same behaviour, but inside of our mutator, and without the check to see if you're "allowed" to have the weapon.

That would look like this:

class Rx_Mutator_GiveSniper extends UTMutator;

function Mutate(string MutateString, PlayerController Sender)
{
local Rx_InventoryManager InvManager;
local class WeaponClass;

WeaponClass = class'Rx_Weapon_SniperRifle_Nod';
InvManager = Rx_InventoryManager(Sender.Pawn.InvManager);

   if (MutateString ~= "sniper" && InvManager != none)
   {
	if (InvManager.PrimaryWeapons.Find(WeaponClass) < 0) // Make sure it isn't in there already.
		InvManager.PrimaryWeapons.AddItem(WeaponClass);

	if(InvManager.FindInventoryType(WeaponClass) != None) 
	{
		InvManager.SetCurrentWeapon(Rx_Weapon(InvManager.FindInventoryType(WeaponClass)));
	}
	else
	{
		InvManager.SetCurrentWeapon(Rx_Weapon(InvManager.CreateInventory(WeaponClass, false)));
	}

	Rx_Pawn(Owner).RefreshBackWeapons();			
   }

   Super.Mutate(MutateString, Sender);
}

Link to comment
Share on other sites

  • Totem Arts Staff
Apparently it can't find RenX_RCam or RenX_Game in the compiled scripts area, and it's stopping the compilation.

Don't know if this is related, but I ran frontend as admin and it worked

Check your +EditPackages or +ModEditPackages. If you put your mutator before RenX's that would definitely result compiler error

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...