Results 1 to 4 of 4

Thread: Increasing NPC's rate of fire

  1. #1

    Default Increasing NPC's rate of fire

    Hello again guys.

    I'm trying to figure out how to make a NPC shoot it's weapon faster. I intend to give them a 30cal machine gun but they are using the rate of fire of the BAR. Which is not optimal since I want the NPC to fave a sustained firing type when wielding the 30cal.

    The closest I got is the text files in the "pak0/models/human/animation" folder.

    This is something that already happens in game with the biggest example being the MP44 with it's fast fire but then it being nerfed when wielded by bots.

  2. #2

    Default

    There is also a line in the weapon .tik file that commands how NPCs will use the weapon. It will also affect the rate of fire.

    Currently the Portable Browning 30 cal. and MG42 are set for the NPCS to use them as Thompsons. The reason I started this thread is because I was testing it on a custom map and it kept crashing whenever I assigned an NPC with the portable heavy machine guns.

    After further testing I concluded that it was most likely some ill coding in the custom map since the stock maps did not crash when I assigned the custom weapons to NPCs.

    Anyways if someone stumble upon a way to increase the rate of fire in NPCs without telling it that it's a completely different weapon class; reply to this thread.

    By the way, Manon now wields a Sten Mk.2 in Mission 4 level 1.

  3. #3

    Default

    I would try changing "firedelay 0.095" first in models/weapons/mp40.tik for example to see if that works for the AI.

    The singleplayer scripts make AI shoot by running: "self exec global/aimat.scr ($player gettagposition "bip01 head" + (0 0 -25))" and then running "self exec global/shoot.scr"

    The shooting animations in anim/shoot.scr run "self setactionanim (self.weapongroup + "_shootauto") -60 60" and "self waittill upperanimdone", so only 1 animation can run at the same time.

    Hence in models/human/animation/human_mp40.tik, I think the only way to speed up AI firing is by removing some "fire" lines, or lowering the numbers under "mp40_shoot01", "mp40_shoot02", and "mp40_shootauto".

    Those numbers are frames: 0 = frame 0, 2 = 2nd frame (skipping 1st frame), 4th frame, etc, so if you write, "0 fire; 1 fire; 2 fire; 3 fire" up to "7 fire", that should increase the mp40 firing rate by 2x (although this will likely do the same for $player's weapons too).

    Code:
    mp40_shootauto				weapon_smg/smg_shoot.skc		
    {
    	server
    	{
    		0 fire
    		//2 fire
    		//4 fire
    		//6 fire
    		//8 fire
    		//10 fire
    		//12 fire
    		//14 fire
    	}
    }
    Code:
    mp40_shootauto				weapon_smg/smg_shoot.skc		
    {
    	server
    	{
    		0 fire
    		1 fire
    		2 fire
    		3 fire
    		4 fire
    		5 fire
    		6 fire
    		7 fire
    	}
    }
    Worst case scenario if none of this works: somehow attach the weapon of choice onto the AI's hands, then give the gun itself a targetname so you can do "$weapon setaimtarget $player" and "$weapon anim fire" in a while-loop, which will forcibly shoot the gun once per frame. More conditions are needed such as "distance from $player" and "cansee $player".

  4. #4

    Default

    Thank you Searingwolfe. It worked as you said.

    I applied the shoot command to all the frames (in the BAR's case it's 15 frames in total) and now the NPCs have a fast and continuous stream of bullets.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •