Jump to content

Help making a weapon knock the user down when fired.


th1nk

Recommended Posts

For a weapon-based mod I'm working on, as a major part of one of the weapons I want to have it knock the user over (a la Stay Back or even just very short paralysis if that doesn't work) if their strength is too low when they fire it.

 

I've tried a lot of things you'd think would work but ran into problems - everything I do only knocks the gun out of the player's hands (the gun in most cases then shoots from the floor if you're in 3rd person and continue to fire it - which is nice for looking at firing/reload animations in more detail I guess but not very useful for what I want to do). I've got a few working in third person (spawning an invisible explosion tends to be most effective) but even those don't work if I make the firing animation/reload (as it's a single-shot weapon) as long as I'd like (as then an animation playing blocks the knockdown or whatever I assume) - and very few people play in 3rd person, and using NVSE to hit the change view key for people in 1st person doesn't do whatever is making it work fast enough to work.

 

Has anyone managed to actually do this successfully before? I've tried literally everything I can think of that produces a reasonable effect to no avail, scoured the geck wiki etc (the effect was going to be kinda a surprise for people to find out for themselves so I didn't want to mention it on-site, but between that and not having it at all, well, here we are).

Edited by th1nk
Link to comment
Share on other sites

Try using this quest script, may need adjusting to suit your needs, e.g a different knockdown spell.

 

scn YourScript

 

short WeaponAnim

 

BEGIN GameMode

 

if ( Player.GetAV Strength <= 4 )

if Player.GetEquipped YourWeapon && Player.IsWeaponOut
set WeaponAnim to Player.GetAnimAction
if ( WeaponAnim == 1 ) ;weapon anim codes here

Player.CastImmediateOnSelf LegateKnockdownSpell

endif

endif

endif

 

END

Link to comment
Share on other sites

Thanks for the reply, I gave what you said a shot and it didn't quite work out, however it did lead me right to the solution - I had overlooked animaction (I was mainly using the ONFIRE block type for my attempts). Animaction 2 interrupts the firing entirely, i.e. after clicking but before it can get to the point that stops the knockdown effect working in 1st person (which seems to be animaction 3). However it also means the weapon doesn't fire - which I immediately tried to fix by delaying the knockdown until animaction 3 and then spending hours trying everything I could think of to work around animaction 3's issues without success. Then I realised I could just fix the not-firing itself instead of delaying things until a later problem. Sticking Fireweapon in there, and seeing as even playound3d isn't making the firing sound play, using an explosion that uses the weapon's firing sound for the knockdown effect, did the trick – weapon fires, with sound, and player is knocked over. All is well.

Thank you so much for getting me on the right track and taking the time to help me out. :smile:

 

 

In case anyone else needs it, here's a generic version of the script I ended up using:

 

 

scn WeaponKnockDownObjectScript

;Object Script to knock down the player when the designated weapon is fired if their strength is too low.
;There are other methods to do the knockdown but I went with the explosion as it allowed me to simulate the sound of the weapon firing, which doesn't seem possible through the script even with playsound3d. For the explosion, weaponknockdownexplosion works as a base, change the impact dataset to NONE and Sound1 to the firing sound of the weapon.

short WeaponAnim

BEGIN GameMode
 
	if ( Player.GetAV Strength <= 6 )
		if Player.GetEquipped MyWeapon && Player.IsWeaponOut
			set WeaponAnim to Player.GetAnimAction
			if ( WeaponAnim == 2 ) ;this is the animaction number for firing
				Player.FireWeapon MyWeapon ;fires weapon as script cancels that
				Player.PlaceAtMe MyExplosion ;places explosion at the player
				Player.UnequipItem MyWeapon ;Limits script to 1 knockdown per activation
			endif
		endif
	endif

END

Could go so far as to implement stonewall stopping it which I might do eventually (pretty sure it requires scripting) but eh. It also only works on the player, there are probably ways around that but it's not a priority for me right now.

Link to comment
Share on other sites

Thank you so much for getting me on the right track and taking the time to help me out. :smile:

 

No worries, glad I could help.

 

 

Could go so far as to implement stonewall stopping it which I might do eventually (pretty sure it requires scripting) but eh. It also only works on the player, there are probably ways around that but it's not a priority for me right now.

 

To make Stonewall cancel the knockdown effect, all you need is this "if" statement before or after the Strength requirement (don't forget the corresponding "endif"):

if ( Player.HasPerk Stonewall == 0 )

 

And to make it apply to all NPCs as well, you could try replacing Player with Actor (e.g Actor.GetAV Strength <= 6) though I have never tested this myself.

Link to comment
Share on other sites

  • 4 months later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...