Jump to content

And then I found


NodSaibot

Recommended Posts

  • Totem Arts Staff

https://forums.epicgames.com/threads/59 ... st25189484 (Found an old RenX dev question on Unreal Forums)

Anyway, I have a question.

Say I want to add a sniper rifle to the Stealth Black Hands upon purchase.

Rx_InventoryManager_Nod_StealthBlackHand.uc

class Rx_InventoryManager_Nod_StealthBlackHand extends Rx_InventoryManager_Adv_NOD;

DefaultProperties
{
PrimaryWeapons[0] = class'Rx_Weapon_LaserRifle'	
}

Using a mutator, how would I target the specific "PrimaryWeapons[0]" value and add another one using a mutator? I know I have to add Rx_Weapon_SniperRifle_NOD, but I don't know what the code would be to add that.

Link to comment
Share on other sites

  • Totem Arts Staff

class CZ_SniperRifle extends Rx_InventoryManager_Nod_StealthBlackHand;

function InitMutator(string Options, out string ErrorMessage)

function int GetSecondaryWeaponSlots() { return 1; }
{
{
if (UTGame(WorldInfo.Game) != None)
{
UTGame(WorldInfo.Game).DefaultInventory[0] = class'CZ_SniperRifle.Rx_SniperRifle_Nod';
}

Super.PrimaryWeapons[0](Options, ErrorMessage);
}

function bool CheckReplacement(Actor Other)
{
if (Other.IsA('Rx_Weapon_Pistol') && !Other.IsA'Rx_SniperRifle_Nod'))
{
ReplaceWith(Other, "Rx_SniperRifle_Nod");
}

return true;
}

DefaultProperties
{
}
}

Is what I have now. Now, I get this error when compiling.

C:\Rx_SDK\Rx_SDK_March_22_2015\Development\Src\CZ_SniperRifle\Classes\CZ_SniperRifle.uc(5) : Error, Missing '{' in function

Link to comment
Share on other sites

For the first question, under

PrimaryWeapons[0] = class'Rx_Weapon_LaserRifle' 

add

PrimaryWeapons[1] = class'WEAPON_CLASS_NAME' 

You see how I changed the index from 0 to 1? You can change it to 2 and 3 and so on for more weapons. I don't know if this is the proper way since I'm not an UnrealScript programmer. But do try and see.

Link to comment
Share on other sites

Ninja, you would be right, if the goal was to make a mod, and modify the SBH Family info class, unfortunately making a mutator is a little different. Instead of modifying the existing code, it's extra code that gets run on-top of the game's code.

So Encrypt, you're definitely on the right track. What you want to do is modify the inventory manager as it is being created. You can use the "CheckReplacement" function to do that, as it gets called whenever an Actor is spawned into the game. So, to replace the first primary weapon with a sniper rifle, you'd do this:

class Rx_Mutator_SBHSniper extends UTMutator;

function bool CheckReplacement(Actor Other)
{
if (Other.IsA('Rx_InventoryManager_Nod_StealthBlackHand'))
{
	Rx_InventoryManager_Nod_StealthBlackHand(Other).PrimaryWeapons[0] = class'Rx_Weapon_SniperRifle_Nod';
}
return true;
}

Note: "CheckReplacement" will only be called if your class extends from either "Mutator" or "UTMutator".

If you wanted to have a sniper rifle in addition to the default primary weapon, then you do this in place of the line in the previous code block:

Rx_InventoryManager_Nod_StealthBlackHand(Other).PrimaryWeapons.AddItem(class'Rx_Weapon_SniperRifle_Nod');

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