Totem Arts Staff NodSaibot Posted April 9, 2015 Totem Arts Staff Share Posted April 9, 2015 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. Quote Link to comment Share on other sites More sharing options...
Totem Arts Staff NodSaibot Posted April 9, 2015 Author Totem Arts Staff Share Posted April 9, 2015 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 Quote Link to comment Share on other sites More sharing options...
Ninja955 Posted April 9, 2015 Share Posted April 9, 2015 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. Quote Link to comment Share on other sites More sharing options...
JeepRubi Posted April 10, 2015 Share Posted April 10, 2015 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'); Quote Link to comment Share on other sites More sharing options...
Totem Arts Staff NodSaibot Posted April 10, 2015 Author Totem Arts Staff Share Posted April 10, 2015 Thanks a ton Jeep! I will probably have more questions soon, so stay tuned! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.