How to convert the .12 Gauge shotgun into a "Hand-Cannon"
Esentially, an handcannon is a
sawed-off shotgun that fires in a really random, wide
spread. It also fires a much larger load than a normal
shotgun. And, if you want to know, it's MUCH louder than a
normal .12 guage shotgun.
While lethal at close range, we want
the gun to be almost useless far away from the intended
target, so we must open up weapons.h and add our own define.
Mine were these,
#define VECTOR_CONE_SPRSPREAD Vector( 0.40000, 0.40000,
0.40000 )
#define VECTOR_CONE_DBLSPREAD Vector( 0.80000, 0.80000,
0.80000 )
Just add this code after the rest of
the VECTOR_CONE_ defines.
Then, open up shotgun.cpp and scroll
down to the primary attack function. Let's see, the
statement we want looks kinda like this.
m_pPlayer->FireBullets( 8, vecSrc,
vecAiming, VECTOR_CONE_DM_SHOTGUN, 2046,
BULLET_PLAYER_BUCKSHOT, 0 );
If the original code doesn't match perfectly to my example,
don't worry, it will work.
This is pretty simple to understand,
if you ever coded quakec for quake 1, you will recognize a
couple of things right off...
m_pPlayer-> has something to do with
the engine telling who's firing (I think...)
FireBullets is a function that is listed somewhere else, it
handles the actual firing of the shotgun pellets. (It's
mostly technical stuff, and I don't know where VALVe put it,
so you don't need to monkey around with it.)
8 determines how many pellets to shoot out.
vecSrc deals with aiming
vecAiming deals with aiming
VECTOR_CONE_DM_SHOTGUN this handles how the pellets are
spread about after they fire. This is where our new
#defines come into play...
2046 - this is the volume of the shot sound. I set it to
4096 for maximum effect.
BULLET_PLAYER_BUCKSHOT this tells the engine what type of
ammo was fired, so that it can show the proper effects, like
bullet holes and other stuff.
I'm not quite sure what the 0 at the end does. That's your
homework assignment, figure it out...
Now, let's make that line look like
this...
m_pPlayer->FireBullets( 24, vecSrc,
vecAiming, VECTOR_CONE_SPRSPREAD, 4096,
BULLET_PLAYER_BUCKSHOT, 0 );
This fires as many pellets as a real
double barrel shotgun would (on average), it's just as loud,
and it uses the new #define we wrote.
The #define that we tinkered with contains the spread "cone"
that the pellets are allowed to travel in. With our new
one, it's alloted a much larger spread, and thus the pellets
are scattered out more at longer ranges.
Now, let's scroll down to the secondary attack function. It
should resemble the primary, but with one noticable
difference. The VECTOR_DM_CONE should be different. Now,
we will increase the pellet count to 48 (double of the
primary) and change it's VECTOR_CONE to the new define for
DBLSPREAD, and that should do it. Now compile, and start
blasting marines with your new toy.
NOTE: you must have both .dll's in
your mod folder to play single player, or else no creatures
or "actors" show up...
What did we learn boys and girls?
1. #defines are usually in .h (header) files
2. You can make your own #defines
3. Halflife is a bit more interesting with a hand-cannon :)
Author -
Phlash[ep] |