Newbie making a weapons mod-need coding help! -1 reply

  • 1
  • 2

Please wait...

Guest

I didn't make it!

0 XP

 
#1 10 years ago

Hi again! I have just gotten started with coding with help from Nizwiz (I think that's his name), and I decided to make a fairly simple but extreme weapon mod.

If all goes similar to plans, the mod will have these new weapons:

Replace the lightsaber, with, or add chaos models, like a machette, crowbar, bat, sledgehammer, axe, ect... This will possibly take away the weapon deflective ablitlities, making it easier to kill Jedi.

A revolver that is slow yet deadly

A Russian PPSH (a very fast, inaccurate Russian Submachine gun)

A new, possibly faster sniper rifle

A medium rate of fire assault rifle with a grenade launcher

A regular 12 gauge shotgun with explosive bullets as secondary fire :naughty:

A Minigun with an amazing rate of fire :lolpoint:

An AA12 full auto hybrid shotgun (no grenade bullets because of unbalanced game play.

some kind of missile launcher, possibly a stinger or RPG?

A extreme powered laser gun similar to the Halo 3 Spartan gun (anti-everything gun)

Extremely explosive thermal detonators

Grenades

Landmines/detpacks will remain the same

I do not currently have the skill to do ALL of the above weapons, that is why I am asking for help with coding.

I am currently working on the mini-gun, which replaces the heavy repeater. I have primary fire down ok, and I tried to copy it to secondary fire for a more accurate, slower rate of fire, and it almost worked, but there is a little problem: Primary fire is about 25% accurate, but secondary is 100% accurate. I need to figure out how to make secondary fire less accurate, any help? Besides that, I also was wondering if it was best to change the effects and sounds outside of the source code, or inside of it. I think I made the mistake of changing as much sound as I could inside of it and now it is buggy. (2 sounds play upon firing) Because I am so new to this (I don't know a thing about C code),

I am not up for suggestions or improvements unless it will makes things easier or more convenient. If anyone could help, that would be great! Thanks!




TFOpanda

Modder

50 XP

29th January 2006

0 Uploads

128 Posts

0 Threads

#2 10 years ago

Look in bg_weapons.c for the rate of fire of weapons. There's lots of other things you can do too, Which ammo it uses, how much ammo it uses per shot. g_weapon.c Is practically everything to do with weapons, good place to start.




Deathspike

Freelance Programmer

50 XP

2nd May 2004

0 Uploads

129 Posts

0 Threads

#3 10 years ago

Take a glare at FireWeapon in g_weapon.c and follow it down the road. You'll notice each weapon define using a different function and setting an altFire tag. To make things less accurate just take a look at the secondary of E-11 fire. Speeds are always called in CreateMissile, if you were to change that one function you can make a single function change which includes all weapons damage, speeds, etc. Easier, imho.




Guest

I didn't make it!

0 XP

 
#4 10 years ago

I believe this is the line I need, but I don't know how to use it to change alt fire because it looks like it is already changing alt fire.

Should there be 2 of the entries below, with similar patterns or what?

I added some extra stuff below in the thread that is not in the compiled version, shown by a <.

[COLOR=DarkRed]//--------------------------------------------------------- static void WP_FireRepeater( gentity_t *ent, qboolean altFire ) //[/COLOR]--------------------------------------------------------- [COLOR=DarkOrange]{ vec3_t dir, angs;




N-7

... and a nice big Cip-Quad

50 XP

21st September 2007

0 Uploads

579 Posts

0 Threads

#5 10 years ago

Ok, I would do it like that:

// somewhere at the top of the file, near the def. of REPEATER_SPREAD #define REPEATER_ALT_SPREAD 0.7f // or whatever number you like

[...]

// Replace the beginning of WP_RepeaterAltFire with this:

static void WP_RepeaterAltFire( gentity_t *ent, vec3_t dir )

//--------------------------------------------------------- { int damage = REPEATER_ALT_DAMAGE;

gentity_t *missile = CreateMissile(muzzle, dir, REPEATER_ALT_VELOCITY, 10000, ent, qtrue);

// remainder goes like the vanilla WP_RepeaterAltFire

[...]

//--------------------------------------------------------- static void WP_FireRepeater( gentity_t *ent, qboolean altFire ) //--------------------------------------------------------- { vec3_t dir, angs;

vectoangles( forward, angs );

// add some slop to the alt-fire direction angs[PITCH] += crandom() * (altFire ? REPEATER_ALT_SPREAD : REPEATER_SPREAD); angs[YAW] += crandom() * (altFire ? REPEATER_ALT_SPREAD : REPEATER_SPREAD);

AngleVectors( angs, dir, NULL, NULL );

if ( altFire ) { WP_RepeaterAltFire( ent, dir ); } else { WP_RepeaterMainFire( ent, dir ); } }

Well, in newbie-speak (:D): I just made the beginning of WP_RepeaterAltFire resemble WP_RepeaterMainFire with regard to the paramter "dir", which is calculated in WP_FireRepeater roughly as "forward" plus sloppyness, so to speak. So if you're replacing "forward" in that CreateMissile call in WP_RepeaterAltFire with "dir" (just like in WP_RepeaterMainFire) and passing that "dir" as an argument, it should do the trick.

But I'm not quite sure if sloppyness is really what you'd want for the ALT fire, since in contrast to the primary fire, it is a single shot (and not a salvo of shots), so if that one shot isn't accurate, you'd be pretty pissed and stop using it at all after a while, wouldn't you? Well, at least you'd have to keep REPEATER_ALT_SPREAD sufficiently small.




Guest

I didn't make it!

0 XP

 
#6 10 years ago

I figured out that basically, what you just said is what I needed to do, and it worked. Not only did I not want to double post, I wanted to see what kind of solution you came up with. I think mine was a little different, but that's ok, because it works with no warnings. About the sloppiness, well, the mini gun is going to be tons faster than the regular repeater, with a medium amount of damage. The primary fire is going to be many bullets per second, and secondary fire is going to use 2-4 bullets per shot, be about 1/4th of the speed, 2-4 times deadlier, and twice as accurate for long range. Even with the inaccuracy, I am worried about unbalanced game play... but after starting the full-auto shotgun, it is extremely powerful too.

Another question though: when I fire the secondary fire, the gun and screen vibrate insanely. This may be good, but where is the code for the vibration found so I can reduce and duplicate it?




N-7

... and a nice big Cip-Quad

50 XP

21st September 2007

0 Uploads

579 Posts

0 Threads

#7 10 years ago
seancsnm;4361798... Another question though: when I fire the secondary fire, the gun and screen vibrate insanely. This may be good, but where is the code for the vibration found so I can reduce and duplicate it?

It's in cgame/cg_weapons.c, around line 630: else if ( val > 1.0f ) { val = 1.0f; if (ps && cent->currentState.number == ps->clientNum) { CGCam_Shake( /*0.1f*/0.2f, 100 ); } } else { if (ps && cent->currentState.number == ps->clientNum) { CGCam_Shake( val * val * /*0.3f*/0.6f, 100 ); } }While this is the place where it's actually executed, you have to look at the context, since there are some calculations above that piece of code that affect it (search for a comment line saying "// Do special charge bits" - that's where it starts).

Note, though, that this code is shared by most of the weapons, so you have to be careful if you only want to change the effects of one.

BTW: I don't know if you're familiar with Visual Studio, but I'll just give you a hint: if you want to jump to the implementation of a function which is called somewhere in the code (like the CGCam_Shake above), you can do it quickly by placing the cursor on the function name and selecting "Go To Definition" from the context menu.




Guest

I didn't make it!

0 XP

 
#8 10 years ago

Is it basically the same for changing the lifting of the gun when you fire the concussion rifle primary fire? Also, I want to change the effects of the concussion rifle primary fire to the disruptor effects. Got any Idea how I can do that?




Guest

I didn't make it!

0 XP

 
#9 10 years ago

I have another question: Where in the world did the concussion rifle fx go? There is effects in the source for about every other weapon, but not the concussion rifle!

edit: Ok, found the concussion effects, what are they doing in the bryar pistol file anyway? Meh, careless Raven coders...




Makrin

Dude, fireflies!

50 XP

25th March 2008

0 Uploads

1,257 Posts

0 Threads

#10 10 years ago

Agreed. Now, is this gonna be just personal use, or are you going to release it?




  • 1
  • 2