Jump to content

[JK:JA] How to make npcs shoot faster ?


Recommended Posts

Posted

Hi there :)

I need help in making npcs shoot faster in single player.

i moded weapons.dat for WP_BLASTER to shoot faster and it works for main character but for stormtroopers who have e-11 blaster they are  shooting one projectile at a time.

From experimentations intelligence ,altfire attributes in npc files do not have any effect (is it hard coded somewhere ?).   

Any thoughts how to solve this problem ?

Thanks in advance ! :)

 

Posted

Hi there :)

I need help in making npcs shoot faster in single player.

i moded weapons.dat for WP_BLASTER to shoot faster and it works for main character but for stormtroopers who have e-11 blaster they are  shooting one projectile at a time.

From experimentations intelligence ,altfire attributes in npc files do not have any effect (is it hard coded somewhere ?).   

Any thoughts how to solve this problem ?

Thanks in advance ! :)

As far as i know .. There is two ways. Code change or Script. To change all stormtroopers - for example to make STORMTROOPER_CLASS shoot faster You can edit the code to make them use alt fire or something.. I dont know abut coding but i know that You can make script to make them shoot faster. The down side of script is that You will chage their firing speed only when NPC WILl use this script... Making it for all stormtroopers (every that will spawn) is sadly only code way i believe :/

 

Also Welcome to the Jkhub :) ! I saw that You are a member for not a long time ^^

Posted

Hi there :)

I need help in making npcs shoot faster in single player.

i moded weapons.dat for WP_BLASTER to shoot faster and it works for main character but for stormtroopers who have e-11 blaster they are  shooting one projectile at a time.

From experimentations intelligence ,altfire attributes in npc files do not have any effect (is it hard coded somewhere ?).   

Any thoughts how to solve this problem ?

Thanks in advance ! :)

 

1: icarus script: SET_SHOOT_SPACING and you set how many millisecond between two shoots.

2: coding: npc_stats.cpp there is a shoot burst switch that set how many time pass between two shoots.

Langerd and NumberWan like this
Posted

Ty for the fast response ! :)

Yes i new to JK hub (you can expect some noobish questions :) , some examples below :)  )

 

1) Is there tutorial for icarus scripting and how to apply it in single player ?

this is what i found https://github.com/JACoders/OpenJK/wiki/ICARUS-Scripting

 

2) Coding in c++ is not a problem but how to apply it just on single player ?

 

So far found some sdks for both sp an mp 

 

there is jedi academy sdk ( i read its buggy )

https://jkhub.org/files/file/1137-jedi-academy-sdk/

 

and jedi academy fixed

https://jkhub.org/files/file/1180-jedi-academy-sdk-fixed/

Langerd likes this
Posted

And on my tutorial about adding new weapons into single player, there is a field that explain how edit Npc_stats.cpp for define the shooting rate of NPC with a weapons. you can use this also as example for change shooting rating of the default weapons, you need just to change into the code some numeric value. :)

 

Edit. sorry, i have the memory of a red fish >.<

you need to edit NPC_combat.cpp, not NPC_stats.cpp

 

 

 
 
case WP_BLASTER_PISTOL:
            ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;
            if ( ent->weaponModel[1] > 0 )
            {//commando
                  ent->NPC->aiFlags |= NPCAI_BURST_WEAPON;
                  ent->NPC->burstMin = 4;
                  ent->NPC->burstMax = 12;
                  if ( g_spskill->integer == 0 )
                        ent->NPC->burstSpacing = 600;//attack debounce
                  else if ( g_spskill->integer == 1 )
                        ent->NPC->burstSpacing = 400;//attack debounce
                  else
                        ent->NPC->burstSpacing = 250;//attack debounce
            }
            else if ( ent->client->NPC_class == CLASS_SABOTEUR )
            {
                  if ( g_spskill->integer == 0 )
                        ent->NPC->burstSpacing = 900;//attack debounce
                  else if ( g_spskill->integer == 1 )
                        ent->NPC->burstSpacing = 600;//attack debounce
                  else
                        ent->NPC->burstSpacing = 400;//attack debounce
            }
            else
            {
            //      ent->NPC->burstSpacing = 1000;//attackdebounce
                  if ( g_spskill->integer == 0 )
                        ent->NPC->burstSpacing = 1000;//attack debounce
                  else if ( g_spskill->integer == 1 )
                        ent->NPC->burstSpacing = 750;//attack debounce
                  else
                        ent->NPC->burstSpacing = 500;//attack debounce
            }
            break;
 

 

here you can change the shoot spacing time of all weapons on SP client.

this is an exaple how i edited that on my code.

Langerd likes this
  • 3 years later...
Posted

------------------------------

THEORY PART

------------------------------

Every time you or NPC fire a weapon it creates new entity. Due to 32bit engine limitations there can be only X(idk exact number) amount of projectiles on the screen .

If there is X+n entities on the screen game will crash !

G_spawn no free entities

How to fix this ?

  1. One way is to Increase the projectile speed (so entities can be destroyed faster) 
  2. Reduce the burst size or burst spacing ( keep it less then 9000 ? )
  3. Reduce weapon range ( if missiles are slow aka matrix mode , ignore this ? )
  4. Write 64bit engine port ?

Where do i change projectile speed ?

Look in file g_weapon.cpp for your weapon projectile velocity

Example for BLASTER

#define BLASTER_VELOCITY			7000

 

------------------------------

PRACTICAL PART

------------------------------

In file NPC_combat.cpp find and edit these lines

Example 1.

Increasing the number of bolts per burst from 3 to 5

NPC->burstMin = bigger the value , longer the burst 
case WP_BLASTER:
		if ( ent->NPC->scriptFlags & SCF_ALT_FIRE )
		{
			ent->NPC->aiFlags |= NPCAI_BURST_WEAPON;
			ent->NPC->burstMin = 5;
			ent->NPC->burstMean = 5;
			ent->NPC->burstMax = 5;
			if ( g_spskill->integer == 0 )
				ent->NPC->burstSpacing = 250;//attack debounce
			else if ( g_spskill->integer == 1 )
				ent->NPC->burstSpacing = 250;//attack debounce
			else
				ent->NPC->burstSpacing = 250;//attack debounce
		}

Example 2.

And another example is pistol:

NPC->burstSpacing = some low value 
case WP_BLASTER_PISTOL:
		ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;


	//	ent->NPC->burstSpacing = 1000;//attackdebounce
		if ( g_spskill->integer == 0 )
			ent->NPC->burstSpacing = 70;//attack debounce
		else if ( g_spskill->integer == 1 )
			ent->NPC->burstSpacing = 55;//attack debounce
		else
			ent->NPC->burstSpacing = 50;//attack debounce
		break;

 

 

 

 

 

Asgarath83 likes this
  • 4 weeks later...
Posted
On 11/23/2019 at 7:09 PM, elementhttp said:

------------------------------

THEORY PART

------------------------------

Every time you or NPC fire a weapon it creates new entity. Due to 32bit engine limitations there can be only X(idk exact number) amount of projectiles on the screen .

If there is X+n entities on the screen game will crash !


G_spawn no free entities

How to fix this ?

  1. One way is to Increase the projectile speed (so entities can be destroyed faster) 
  2. Reduce the burst size or burst spacing ( keep it less then 9000 ? )
  3. Reduce weapon range ( if missiles are slow aka matrix mode , ignore this ? )
  4. Write 64bit engine port ?

Where do i change projectile speed ?

Look in file g_weapon.cpp for your weapon projectile velocity

Example for BLASTER


#define BLASTER_VELOCITY			7000

 

------------------------------

PRACTICAL PART

------------------------------

In file NPC_combat.cpp find and edit these lines

Example 1.

Increasing the number of bolts per burst from 3 to 5


NPC->burstMin = bigger the value , longer the burst 

case WP_BLASTER:
		if ( ent->NPC->scriptFlags & SCF_ALT_FIRE )
		{
			ent->NPC->aiFlags |= NPCAI_BURST_WEAPON;
			ent->NPC->burstMin = 5;
			ent->NPC->burstMean = 5;
			ent->NPC->burstMax = 5;
			if ( g_spskill->integer == 0 )
				ent->NPC->burstSpacing = 250;//attack debounce
			else if ( g_spskill->integer == 1 )
				ent->NPC->burstSpacing = 250;//attack debounce
			else
				ent->NPC->burstSpacing = 250;//attack debounce
		}

Example 2.

And another example is pistol:


NPC->burstSpacing = some low value 

case WP_BLASTER_PISTOL:
		ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON;


	//	ent->NPC->burstSpacing = 1000;//attackdebounce
		if ( g_spskill->integer == 0 )
			ent->NPC->burstSpacing = 70;//attack debounce
		else if ( g_spskill->integer == 1 )
			ent->NPC->burstSpacing = 55;//attack debounce
		else
			ent->NPC->burstSpacing = 50;//attack debounce
		break;

 

 

 

On 11/23/2019 at 7:09 PM, elementhttp said:

 

I Didnt knew about this limit and that workarounds! thanks for sharing the advide, bro! :D

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...