securitywyrm Posted July 29, 2017 Share Posted July 29, 2017 I want to add a script to certain receivers for a certain weapon that runs when the weapon is fired. For simplicity sake, I want to run a debug message every third shot. I've drilled down to the receiver properties for the weapon, but where would I go to attach the script? Link to comment Share on other sites More sharing options...
Reneer Posted July 29, 2017 Share Posted July 29, 2017 (edited) The only reliable way I've found to determine if a weapon is fired would be to check the player's inventory for the amount of ammo they have for the gun. Animations tend to be tricky to get working, or so I've seen based on the multiple topics related to checking if a weapon is fired. Edited July 29, 2017 by Reneer Link to comment Share on other sites More sharing options...
securitywyrm Posted July 29, 2017 Author Share Posted July 29, 2017 The only reliable way I've found to determine if a weapon is fired would be to check the player's inventory for the amount of ammo they have for the gun. Animations tend to be tricky to get working, or so I've seen based on the multiple topics related to checking if a weapon is fired.That might be tricky, because the mod would be modifying remaining ammo. That also seems like it's running a constant "while" script, which isn't that reliable if a gun is rapid-fire.I'll keep digging. Link to comment Share on other sites More sharing options...
Reneer Posted July 29, 2017 Share Posted July 29, 2017 That might be tricky, because the mod would be modifying remaining ammo. That also seems like it's running a constant "while" script, which isn't that reliable if a gun is rapid-fire. I'll keep digging.The script could easily be written to compensate for rapid-fire. Just saying. And the only other working method is to use weapon animations. Link to comment Share on other sites More sharing options...
securitywyrm Posted July 29, 2017 Author Share Posted July 29, 2017 That might be tricky, because the mod would be modifying remaining ammo. That also seems like it's running a constant "while" script, which isn't that reliable if a gun is rapid-fire.I'll keep digging.The script could easily be written to compensate for rapid-fire. Just saying. And the only other working method is to use weapon animations. Well, what triggers the weapon firing sound? Perhaps I could piggyback on that. Link to comment Share on other sites More sharing options...
Reneer Posted July 29, 2017 Share Posted July 29, 2017 (edited) Well, what triggers the weapon firing sound? Perhaps I could piggyback on that.Good thought, but there is no way to check to see if a particular sound is playing or not. Edit: Sorry, I knew I had been in this discussion before, but it's late and I couldn't remember the easy solution, which is here. Edited July 29, 2017 by Reneer Link to comment Share on other sites More sharing options...
DeathMotif Posted July 29, 2017 Share Posted July 29, 2017 I suppose you could try attaching the script to the weapon itself, check for the desired receiver mods, and use a recycling counter to increment every time the weapon is fired. I haven't done enough scripting to know if papyrus supports modulus arithmetic. If it does, then you can use counter mod 3. Whenever it equals 0, you'd trigger your debug. The problem with this being the eventuality that you overflow the variable (unlikely, depending on the refire rate of the weapon). The safe way to do it is to reset your counter variable after triggering your debug. Link to comment Share on other sites More sharing options...
DeathMotif Posted July 29, 2017 Share Posted July 29, 2017 I also found this: https://forums.nexusmods.com/index.php?/topic/4586285-papyrus-f4-detecting-when-the-player-fires-a-weapon/ Link to comment Share on other sites More sharing options...
Recommended Posts