PAPVAFS11 Posted October 21, 2016 Share Posted October 21, 2016 I recently re-implemented junk rounds into the game and decided I'd make them more interesting by giving them a small chance to cause the weapon they're fired from to explode. I figured that the most versatile way to go about this would be to change the casing type for each junk round to a misc item with a script attached to it to handle explosion odds. Unfortunately, the script won't fire when the "casing" is added to the player's inventory. It has to be dropped and picked back up for it to start running. I tried adding an OnAdd block to the script, but that doesn't seem to fire when the "casing" is first generated. Is there any way I can inexpensively detect if the player has a casing item in their inventory and kickstart the script? Link to comment Share on other sites More sharing options...
Mktavish Posted October 21, 2016 Share Posted October 21, 2016 Have you tried the "OnFire" Begin block ? Is that to expensive ? But you would have to use a variable reference set to the current weapon equipped in order for the weapon fired to trigger an OnFire block. That or script every weapon you want to have the problem of casings exploding. The OnAdd block isn't going to be checking per round fired anyways . But yes the OnAdd block has a problem with being detected through the object creation directly into inventory. Link to comment Share on other sites More sharing options...
Mktavish Posted October 22, 2016 Share Posted October 22, 2016 (edited) Oh wait I'm stupid ... just use "IsControlPressed" in a gamemode block ... which would calculate the explode chance. But putting this script on a perk ... and how you control the perk on/off ... is in the condition , use "GetItemCount >= ? " In the Function Parameters select each item you want to check for , like 10mm rounds. Hence you need to add a condition for each item. Therefore at the end of each line ... you have to select the "OR" operator instead of the default "AND" That means that your condition will be true if this or that or the other is in inventory ... instead of this and that and the other which is cummulative. Just mentioning incase you didn't know :wink: Edited October 22, 2016 by Mktavish Link to comment Share on other sites More sharing options...
PAPVAFS11 Posted October 27, 2016 Author Share Posted October 27, 2016 I'd hoped to get away without using a GameMode block as I abuse them far too much as it is, but if that's the way it has to be, c'est la vie. Thanks for the help and sorry for the late response. Link to comment Share on other sites More sharing options...
Mktavish Posted October 28, 2016 Share Posted October 28, 2016 Well the "OnFire" block could still work if you don't want game mode checks going on. I just felt it would be more extensive to set that up vs letting a game mode block checking for "IsControlPressed"sort it out for you. Since the equipped , then fired weapon has to have an object script on it using "Begin OnFire"And not really sure if a reference can be used to trigger that block ... it's wording doesn't seem to suggest it's possible , but it's worth some testing I suppose. For the game mode block ... try to keep as little as possible checking in it. Like only 1 explode chance going on. Which means you set up multiple scripts for all the different rounds , different explode chances. And depending on what weapon gets equipped , it then turns this, that or the other specific game mode script on. Link to comment Share on other sites More sharing options...
Recommended Posts