Custom Animations and Forcing NPCs to Fire Their Weapons

Got problems with your models? Struggling with textures? Get help with your custom assets.

Custom Animations and Forcing NPCs to Fire Their Weapons

Postby CB1993 on Sat May 07, 2011 1:22 am

Is it possible to get an NPC to fire his weapon without using any default firing animations while playing a custom animation? For instance, I have the idea of having a rebel leaning against a wall, then turn his body at an angle and fire at distant enemies, then go back against the wall. He does this infinitely until the player triggers him to stop.

Also, can you have NPCs have their weapons fire at wherever the barrel of the gun is pointing, rather than have the NPC himself focus on a bullseye or something?
User avatar
CB1993
Member
Member
 
Joined: Tue May 03, 2011 3:42 am

Re: Custom Animations and Forcing NPCs to Fire Their Weapons

Postby crazycarl on Sat May 07, 2011 3:59 pm

http://developer.valvesoftware.com/wiki ... ion_Events
Add one of those events to your custom sequence. For example:

$sequence crouch_shoot_smg1 "Crouch_shootSMG1_B" fps 25 addlayer layer_Aim_all node "crouchShooting" activity ACT_RANGE_ATTACK_SMG1_LOW 1 { event 3002 0 }

That code makes the NPC fire the smg at frame 0 of the animation.
crazycarl
Been Here A While
Been Here A While
 
Joined: Tue Jan 12, 2010 9:12 pm

Re: Custom Animations and Forcing NPCs to Fire Their Weapons

Postby CB1993 on Fri May 13, 2011 5:28 pm

Excellent! Thanks for that info.

I'm unable to experiment with that in mind, however, I won't be able to so for a bit.

In the meantime, there are a few things I would like to clear up:

1. Does this force the npc to fire his weapon at a constant rate until his clip is empty, or does his AI kick in and have him use bust fire techniques?

2. How can I make them fire a single shot? This would be particularly useful for pistols and shotguns.

3. Does this sequence in the qc.file have him shoot wherever the barrel of the gun is pointing, or does he still need to focus on something like an enemy or a bullseye?

Thanks!
User avatar
CB1993
Member
Member
 
Joined: Tue May 03, 2011 3:42 am

Re: Custom Animations and Forcing NPCs to Fire Their Weapons

Postby joe_rogers_11155 on Fri May 13, 2011 10:01 pm

assuming you can even get an animation of the citizen aiming around a corner blind-firing...

you might have to fake the gunfire. ie, simluate the gunfire with ambient_generic and env_sprites for muzzle flash. it almost seems like it would be easier.
"Day breaks, but decay soon follows." - Ava Winona
Currently developing in radio silence... 99 Bolts
Here's another project of mine... Assault on Overwatch
Are you new to Source SDK? VDC
joe_rogers_11155
Veteran
Veteran
 
Joined: Wed Oct 08, 2008 11:11 pm
Location: United States

Re: Custom Animations and Forcing NPCs to Fire Their Weapons

Postby crazycarl on Mon May 16, 2011 6:04 am

CB1993 wrote:Excellent! Thanks for that info.

I'm unable to experiment with that in mind, however, I won't be able to so for a bit.

In the meantime, there are a few things I would like to clear up:

1. Does this force the npc to fire his weapon at a constant rate until his clip is empty, or does his AI kick in and have him use bust fire techniques?

2. How can I make them fire a single shot? This would be particularly useful for pistols and shotguns.

3. Does this sequence in the qc.file have him shoot wherever the barrel of the gun is pointing, or does he still need to focus on something like an enemy or a bullseye?

Thanks!

I haven't tested it myself, but this is how I understand it to work:

It will be a single shot. There are a couple other events that will do a SMG burst also.

The shot will come out the barrel of the gun no matter where it's pointing. The AI of the character has little to do with it.
Here's an example of a combine soldier doing a short AR2 burst as part of an animation:
Code: Select all
$sequence leanwall_right_exit "leanwall_right_exit" fps 30.00 {
  { event AE_NPC_MUZZLEFLASH 11 "COMBINE MUZZLE" }
  { event AE_NPC_MUZZLEFLASH 13 "COMBINE MUZZLE" }
  { event AE_NPC_MUZZLEFLASH 15 "COMBINE MUZZLE" }
  { event 3007 11 "1" }
  { event 3007 13 "1" }
  { event 3007 15 "1" }
}


I'm not sure what the "1" does. It might be something specific to that NPC.
crazycarl
Been Here A While
Been Here A While
 
Joined: Tue Jan 12, 2010 9:12 pm

Re: Custom Animations and Forcing NPCs to Fire Their Weapons

Postby CB1993 on Mon May 16, 2011 5:32 pm

So AE_NPC_MUZZLEFLASH "COMBINE MUZZLE" gives the gun the AR2 muzzle flare effect, and event 3007 tells the NPC to fire an AR2 bullet? Excellent!

Do you know if there's a command that has the NPC fire at a constant rate, instead of burst fire or a single shot? If there is, is there a command that tells the NPC to stop firing?
User avatar
CB1993
Member
Member
 
Joined: Tue May 03, 2011 3:42 am

Return to Custom Asset Help

Who is online

Users browsing this forum: No registered users