Lunarstars Posted November 4, 2013 Posted November 4, 2013 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.
Raz0r Posted November 4, 2013 Posted November 4, 2013 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.
Lunarstars Posted November 4, 2013 Author Posted November 4, 2013 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.
Asgarath83 Posted November 4, 2013 Posted November 4, 2013 Maybe you can check the code of working of cultist_commando.NPC that shot with two repeating blaster pistol, and see how to integer that code to the player.
Lunarstars Posted November 4, 2013 Author Posted November 4, 2013 Maybe you can check the code of working of cultist_commando.NPC that shot with two repeating blaster pistol, and see how to integer that code to the player. I did it at start, And It didn't work.
Asgarath83 Posted November 4, 2013 Posted November 4, 2013 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.
Lunarstars Posted November 4, 2013 Author Posted November 4, 2013 Thanks for the idea, but unfortunately it is beyond my capabilities, I'm not so much familiar with programming, barely learned to add new weapons. I need an easier way, if it exists at all ..
Asgarath83 Posted November 4, 2013 Posted November 4, 2013 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_PISTOLnot easy, but maybe Tavion can be the key.
eezstreet Posted November 4, 2013 Posted November 4, 2013 Or you could just check how weaponModel[1] is used, and set it. Both of your examples do that.
Lunarstars Posted November 5, 2013 Author Posted November 5, 2013 Check out how ps->weaponModel[1] is used.May i ask where ps->weaponModel[1] is located? i can't find it.
Asgarath83 Posted November 5, 2013 Posted November 5, 2013 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.
Raz0r Posted November 5, 2013 Posted November 5, 2013 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/*.cppProcess of elimination. eezstreet and Asgarath83 like this
Asgarath83 Posted November 5, 2013 Posted November 5, 2013 Wow... really i need to configure better my visual C. is not so accurate. Sorry for question. O.o
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now