[HELP] Checking if a weapon's been fired (Scripting)

Post » Mon May 03, 2010 3:47 am

I'm no scripting veteran when it comes to Fallout 3 or New Vegas, but I still realize this is a bit of a simple question. Simply put, I'm looking for a function in the scripting library to check if a weapon's been fired.

Fairly brief topic, I admit, but that's really all I'm after. Anyone able to help?
User avatar
Dina Boudreau
 
Posts: 3410
Joined: Thu Jan 04, 2007 10:59 pm

Post » Mon May 03, 2010 5:57 am

GetPlayerAnim or something. It was called something like that. 2 is firing a weapon.
User avatar
Danger Mouse
 
Posts: 3393
Joined: Sat Oct 07, 2006 9:55 am

Post » Sun May 02, 2010 5:51 pm

Using player.getequipped and player.isweaponout in combination with iscontrolpressed should get you in the ball park. Basically if your weapon is equipped, and it is un-holstered when the control for attack is pressed the gun has been fired, providing there was ammo for the gun.

Another way is to keep checking the players ammo count, if it goes down they fired. Just have to reset the ammo amount every time a menu is opened to prevent false positives from selling/dropping ammo.
User avatar
Pixie
 
Posts: 3430
Joined: Sat Oct 07, 2006 4:50 am

Post » Sun May 02, 2010 10:16 pm

It's generally better to use the animation functions to check as it prevents issues with the player pressing fire when staggered/knocked down, and things like the recharger rifle.
I've used the following snippet before:
ref npcshort animif(npc.GetAnimAction == 2 && anim == 0)	set anim to 1elseif(npc.getanimaction != 2 && anim == 1)	;WEAPON FIRED	set anim to 0endif

User avatar
matt
 
Posts: 3267
Joined: Wed May 30, 2007 10:17 am

Post » Mon May 03, 2010 8:15 am

Using player.getequipped and player.isweaponout in combination with iscontrolpressed should get you in the ball park. Basically if your weapon is equipped, and it is un-holstered when the control for attack is pressed the gun has been fired, providing there was ammo for the gun.

Another way is to keep checking the players ammo count, if it goes down they fired. Just have to reset the ammo amount every time a menu is opened to prevent false positives from selling/dropping ammo.


But there's a script command for checking the exact same thing, and it works. Why go through all the hoops for the same results?
User avatar
Haley Cooper
 
Posts: 3490
Joined: Wed Jun 14, 2006 11:30 am

Post » Mon May 03, 2010 4:31 am

The help is greatly appreciated. This was the main roadblock for me in getting recoil implemented into my mod.

Now, one last thing; is there a function to modify weapon spread? That's the last hurdle I need to clear before I can do the work myself.
User avatar
Emerald Dreams
 
Posts: 3376
Joined: Sun Jan 07, 2007 2:52 pm

Post » Sun May 02, 2010 4:50 pm

The help is greatly appreciated. This was the main roadblock for me in getting recoil implemented into my mod.

Now, one last thing; is there a function to modify weapon spread? That's the last hurdle I need to clear before I can do the work myself.


New Vegas Script Extender has one.
User avatar
Kira! :)))
 
Posts: 3496
Joined: Fri Mar 02, 2007 1:07 pm

Post » Mon May 03, 2010 3:52 am

The help is greatly appreciated. This was the main roadblock for me in getting recoil implemented into my mod.

Now, one last thing; is there a function to modify weapon spread? That's the last hurdle I need to clear before I can do the work myself.
Yes and no. Yes, there are NVSE functions to modify weapon spread. No, not per weapon- only for the weapon base object. As in, if the player fires a 10mm and you up the spread of the 10mm pistol in response, that will affect all 10mm pistols, wielded by player and NPC alike.
The only way of doing it per actor is by adding a perk to the player (and other actors, if desired) that alters spread based on some conditions. If you only want it to run on the player, you could have a quest containing a 'playerRecoilLevel' variable and use that. If you want it to run on NPCs too, you'd have to make the perk alter spread based on something like GetFactionRank RecoilFaction, and use AddToFaction RecoilFaction to set the level.
User avatar
saharen beauty
 
Posts: 3456
Joined: Wed Nov 22, 2006 12:54 am

Post » Sun May 02, 2010 5:23 pm

Hmm. Definitely going to make things more complicated, but I think I'll be able to figure it out. Thanks again for the help!
User avatar
W E I R D
 
Posts: 3496
Joined: Tue Mar 20, 2007 10:08 am

Post » Sun May 02, 2010 4:09 pm

I use a method similar to TalkieToasters to detect the player firing a weapon in Phalanx' followers-be-passive function. It was the only thing I could come up with which had a good chance of being reliable. Combined with isweaponinlist I was able to rule out placement of mines, which falls into the same sorts of animations.
User avatar
Heather Stewart
 
Posts: 3525
Joined: Thu Aug 10, 2006 11:04 pm


Return to Fallout: New Vegas