Jump to content

How to make Dual Pistols in SP


Recommended Posts

Hi, I'm working on adding weapons to the single player, and I would like to ask is there any possibility of creating two guns for the player, the file cg_players.cpp, I found references associated with two pistols for the NPC, I would like, however, that it was also possible for the player, very please help. Thanks in advance.

 
Link to comment

There are totally different methods depending on how you want to handle it.

 

1) Can the player dual-wield two different types of weapons?

2) Can the player can dual-wield two of the same weapon?

3) Can the player single-wield or dual-wield at will? (i.e. drop second weapon, pick it up again)

4) Should primary fire shoot both weapons? Alternate which weapon to fire? Should alternate fire shoot the right weapon and primary fire shoot the left weapon?

 

It can get considerably complex when dealing with different weapon types, firing rates, if you plan on adding reloading/clips.

When you fire a weapon, a timer is set based on the weapon you're holding. You can't fire until that timer counts down - you're going to have to rework that into two separate timers, one for each weapon.

You'll also want to disallow certain combinations of weapons if you allow wielding different weapon types. That will also mean removing the alt-fire capabilities of the weapons, including zooming which is handled differently to firing.

 

In short, you're going to have to really think about what you want before attempting it. It's not as easy as it sounds.

 

The easiest way is a purely visual change - can only dual-wield two of the same weapon, primary fire will alternate between which weapon to shoot...which behaves the exact same as just having a single weapon with regards to damage output, ammo count, etc.

Link to comment

I want it to be a visual change, guns in both hands, the operation of weapons the same, just that the second gun, shoot the same way as the first, so that only the changes, not at the same time, two missiles, one of one, then the other. . And if you can, to exclude alt-fire.

Link to comment

Try the saber dual coding. is already for player, should be work,

or, as eezstreet told me for unlokc NPC weapons for player. try to check the code of force mindtrick 4 possesion for see how work the pilot of npc. cultistcommando can be possesed with this power and shot with 2 blasters. :)

maybe yu can do an hybric function between the two code, but is HARD to work.

Link to comment

mmmm, there is another thing you can check: tavion_scepter is a NPC that use the lightsaber in right hand, and the WP_SCEPTER in the left hand, yu need to look the AI_JEDI.cpp (i suppose are in that's) or NPC_combats.cpp or NPC_stats.CPP, i suppose that tavion scepter function can be in one of that's files... and here yu can find the code for how to create two weapons carried.

really you need to change the WP_SABER and tje WP_SCEPTER with WP_BLASTER_PISTOL

not easy, but maybe Tavion can be the key. :)

Link to comment

mmm, Eez, i have the same problem with your istruction. The code is very big and great. is ... well, 10 mega and more... is very large. very large. searching something is not much easy. 

When yu tell how to modify a thing, can yu indicate the name of the file container of istruction? or the command line?

please. ^_^ thanks.  :)

i ask also because with your tutorial of create new MP weapon when i try to make a new rocket launceher weapon in JAMP game, just for try and learn, i was become little crazy to find the command line of every modification, LOL. :D

Link to comment

Find all "weaponModel[1]", Subfolders, Find Results 1, Entire Solution, ""
  G:\Projects\OpenJK\code\cgame\cg_players.cpp(1085):					int modelIndex = cent->gent->weaponModel[1];
  G:\Projects\OpenJK\code\cgame\cg_players.cpp(7676):					&& cent->gent->weaponModel[1] )//one in each hand
  G:\Projects\OpenJK\code\game\AI_Jedi.cpp(323):		|| NPC->weaponModel[1] <= 0 )
  G:\Projects\OpenJK\code\game\AI_Jedi.cpp(339):			gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->weaponModel[1], 
  G:\Projects\OpenJK\code\game\AI_Jedi.cpp(398):		|| NPC->weaponModel[1] <= 0 )
  G:\Projects\OpenJK\code\game\AI_Jedi.cpp(403):	int	boltIndex = gi.G2API_AddBolt(&NPC->ghoul2[NPC->weaponModel[1]], "*weapon");
  G:\Projects\OpenJK\code\game\AI_Jedi.cpp(417):		gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->weaponModel[1], 
  G:\Projects\OpenJK\code\game\AI_Jedi.cpp(518):	G_PlayEffect( G_EffectIndex( "scepter/beam_warmup.efx" ), NPC->weaponModel[1], NPC->genericBolt1, NPC->s.number, NPC->currentOrigin, 0, qtrue );
  G:\Projects\OpenJK\code\game\AI_Jedi.cpp(532):	G_PlayEffect( G_EffectIndex( "scepter/slam_warmup.efx" ), NPC->weaponModel[1], NPC->genericBolt1, NPC->s.number, NPC->currentOrigin, 0, qtrue );
  G:\Projects\OpenJK\code\game\AI_Jedi.cpp(7307):			G_PlayEffect( G_EffectIndex( "scepter/beam.efx" ), NPC->weaponModel[1], NPC->genericBolt1, NPC->s.number, NPC->currentOrigin, 10000, qtrue );
  G:\Projects\OpenJK\code\game\AI_Jedi.cpp(7332):			G_StopEffect( G_EffectIndex( "scepter/beam.efx" ), NPC->weaponModel[1], NPC->genericBolt1, NPC->s.number );
  G:\Projects\OpenJK\code\game\bg_panimate.cpp(4473):		&& gent->weaponModel[1] )
  G:\Projects\OpenJK\code\game\bg_panimate.cpp(5907):						&& pm->gent->weaponModel[1] > 0 )
  G:\Projects\OpenJK\code\game\bg_panimate.cpp(6208):						&& pm->gent->weaponModel[1] > 0 )
  G:\Projects\OpenJK\code\game\bg_pmove.cpp(11891):		&& pm->gent->weaponModel[1] )
  G:\Projects\OpenJK\code\game\bg_pmove.cpp(13421):					&& pm->gent->weaponModel[1] > 0 )
  G:\Projects\OpenJK\code\game\bg_pmove.cpp(13596):				if ( pm->gent && pm->gent->weaponModel[1] > 0 )
  G:\Projects\OpenJK\code\game\g_client.cpp(1860):		if ( ent->weaponModel[1] > 0 )
  G:\Projects\OpenJK\code\game\g_client.cpp(1862):			gi.G2API_RemoveGhoul2Model( ent->ghoul2, ent->weaponModel[1] );
  G:\Projects\OpenJK\code\game\g_client.cpp(1863):			ent->weaponModel[1] = -1;
  G:\Projects\OpenJK\code\game\g_client.cpp(2454):			if ( (ent->weaponModel[0] <= 0 || (ent->weaponModel[1]<=0&&ent->client->ps.dualSabers)) //one or both of the saber models is not initialized
  G:\Projects\OpenJK\code\game\g_cmds.cpp(1340):		&& ent->weaponModel[1] <= 0 )
  G:\Projects\OpenJK\code\game\g_combat.cpp(158):			if ( self->weaponModel[1] >= 0 )
  G:\Projects\OpenJK\code\game\g_combat.cpp(3911):			G_StopEffect( G_EffectIndex( "scepter/beam_warmup.efx" ), self->weaponModel[1], self->genericBolt1, self->s.number );
  G:\Projects\OpenJK\code\game\g_combat.cpp(3912):			G_StopEffect( G_EffectIndex( "scepter/beam.efx" ), self->weaponModel[1], self->genericBolt1, self->s.number );
  G:\Projects\OpenJK\code\game\g_combat.cpp(3913):			G_StopEffect( G_EffectIndex( "scepter/slam_warmup.efx" ), self->weaponModel[1], self->genericBolt1, self->s.number );
  G:\Projects\OpenJK\code\game\NPC_combat.cpp(701):		if ( ent->weaponModel[1] > 0 )
  G:\Projects\OpenJK\code\game\NPC_spawn.cpp(660):		if ( !ent->weaponModel[1] )
  G:\Projects\OpenJK\code\game\NPC_spawn.cpp(664):		ent->genericBolt1 = gi.G2API_AddBolt(&ent->ghoul2[ent->weaponModel[1]], "*flash");
  G:\Projects\OpenJK\code\game\wp_blaster_pistol.cpp(120):	if ( ent->weaponModel[1] > 0 )
  G:\Projects\OpenJK\code\game\wp_saber.cpp(375):		ent->weaponModel[0] = ent->weaponModel[1] = -1;
  G:\Projects\OpenJK\code\game\wp_saberLoad.cpp(2514):		if ( ent->weaponModel[1] == -1 )
  G:\Projects\OpenJK\codemp\game\NPC_AI_Jedi.c(6184):			G_StopEffect( G_EffectIndex( "scepter/beam.efx" ), NPC->weaponModel[1], NPC->genericBolt1, NPC->s.number );
  Matching lines: 33    Matching files: 13    Total files searched: 1077
That's why we use IDEs like Visual Studio, to do the searching for us.

The rendering will be done in /code/cgame/cg_players.cpp, and it will be set somewhere in /code/game/*.cpp

Process of elimination.

Asgarath83 and eezstreet like this
Link to comment

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...