In
tutorial 5, you notice the snippet of text "...a crossbow bolt that
drops snarks...". You want that? I'll show you how you do that! I'll
assume your compiler is working right and your liblist.gam is ready.
If not, see tutorial 0. If you're ready, please read on...
Open your crossbow.cpp in mp.dll and go to
your BubbleThink function. Just before your
pev->nextthink = gpGlobals->time + 0.1; line, insert this code:
CBaseEntity *pSqueak =
CBaseEntity::Create( "monster_snark",pev->origin + pev->view_ofs +
gpGlobals->v_forward * 16, pev->v_angle, pev->owner );
float flRndSound =
RANDOM_FLOAT ( 0 , 1 );
if ( flRndSound <= 0.5 )
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1,
ATTN_NORM, 0, 105);
else
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1,
ATTN_NORM, 0, 105);
Now, a line by line explanation:
CBaseEntity *pSqueak = CBaseEntity::Create( "monster_snark",pev->origin
+ pev->view_ofs + gpGlobals->v_forward * 16, pev->v_angle, pev->owner
); -- This is what creates the snark. "monster_snark" is the
classname, make it whatever you want(ammo_gauss, anyone?).
pev->origin + pev->view_ofs + gpGlobals->v_forward * 16 is the
location of where it's created. If you placed it at pev->origin, the
bolt would kill the snark instantly :). pev->v_angle is the angle it
faces when it's created, and pev->owner is its owner.
float flRndSound = RANDOM_FLOAT ( 0 , 1 ); --
Sets flRndSound to 0 or 1.
if ( flRndSound <= 0.5 )
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1,
ATTN_NORM, 0, 105);
else
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1,
ATTN_NORM, 0, 105); -- Plays one of two snark squeak sounds
depending on if flRndSound is 0 or 1. Just for effect :).
There you have it! Your snark-dropping
crossbow. Compile and run your mp.dll, get your crossbow out and use
your new ultimate weapon of doom!
If you have any questions, E-mail me at:
smelenchuk@home.com |