This is an addon to the Air Kill award tutorial, this makes it to where the person must gib( explode ) when you shoot and kill them in the air to get the award, hence the name "FireWorks". Plus it makes their blood change colors via a some code. Note the reason I am using the smokePuff shader is because the images are already in grayscale so they can be morphed to other colors correctly. Open up g_combat.c and find: if ( self->s.groundEntityNum == ENTITYNUM_NONE ) { That checks to make sure the victim you kill was not on the ground. Change it to: if ( self->s.groundEntityNum == ENTITYNUM_NONE && self->health <= GIB_HEALTH) { That checks to see if you health( you being the guy that got killed ) is less than or equal to the gib health( which would mean you blew up ). If so, it awards you the medal. Now lets actually do the SFX part! AKA The cool part! Ok lets open up bg_public.h and find: // player_state->stats[] indexes typedef enum { Up under it we need to add our new stat: STAT_FIREWORKS, Now open up cg_players.c and goto this line: if ( cent->currentState.eFlags & EF_AWARD_AIRKILL ) { Below it we need to distinguish a variable( our stat ) so we can let CG_BloodTrail distinguish between if it should use the the normal red blood, or use our colored blood :), so add this below that line: cg.snap->ps.stats[STAT_FIREWORKS] = 1; Open up cg_localents.c and find this: int t; int t2; int step; vec3_t newOrigin; localEntity_t *blood; Up under those add: int c1,c2,c3,c4; Now find: blood = CG_SmokePuff( newOrigin, vec3_origin, 20, // radius 1, 1, 1, 1, // color 2000, // trailTime t, // startTime 0, // flags cgs.media.bloodTrailShader ); Replace it with: if ( cg.snap->ps.stats[STAT_FIREWORKS] == 0 ) { blood = CG_SmokePuff( newOrigin, vec3_origin, 20, // radius 1, 1, 1, 1, // color 2000, // trailTime t, // startTime 0, // flags cgs.media.bloodTrailShader ); } else if ( cg.snap->ps.stats[STAT_FIREWORKS] == 1 ) { c1 = rand()&0-1; c2 = rand()&0-1; c3 = rand()&0-1; c4 = 1; blood = CG_SmokePuff( newOrigin, vec3_origin, 20, // radius c1, c2, c3, c4, // color 2000, // trailTime t, // startTime 0, // flags cgs.media.smokePuffShader ); } Now enjoy your nice and pretty sad looking fireworks display :) If anyone feels like coding and making something that is actually pretty kewl, then e-mail it to me. Also, I know there is probably a better way to set the variable rather than making a all new stat, so if you do do it a better way e-mail me and I will update the tutorial with it. I spend my time coding and then writing these tutorials, please give credit to www.inolen.com if you use this code in your mod(s). Feel free to use this code in your mods as long as I receive credit. | |
Design Copyright inolen 2000 |