#ifdef MISSIONPACK . . . #endif
typedef enum {
.
.
.
WP_FLAME_THROWER, //tute10.1
.
.
.
} weapon_t;
|
// means of death
typedef enum {
.
.
.
MOD_FLAME_THROWER, //tute10.2
.
.
.
} meansOfDeath_t;
|
// these are just for logging, the client prints its own messages
char *modNames[] = {
.
.
.
"MOD_FLAME_THROWER", //tute10.3
.
.
.
};
|
#define INVENTORY_FLAMETHROWER 35 //tute10.4 #define MODELINDEX_FLAMETHROWER 36 //tute10.4 |
//tute10.5
/*
*QUAKED weapon_flamethrower (.3 .3 1) (-16 -16 -16) (16 16 16) suspended
*/
{
"weapon_flamethrower",
"sound/misc/w_pkup.wav",
{"models/weapons2/flamethrower/flamethrower.md3", 0, 0, 0},
/* icon */ "icons/iconw_flame",
/* pickup */ "Flame Thrower", 20,IT_WEAPON,WP_FLAME_THROWER,
/* precache */ "",
/* sounds */ ""
},
|
//tute10.6
/*
*QUAKED ammo_flame (.3 .3 1) (-16 -16 -16) (16 16 16) suspended
*/
{
"ammo_flame",
"sound/misc/am_pkup.wav",
{"models/powerups/ammo/bfgam.md3", 0, 0, 0},
/* icon */ "icons/icona_bfg",
/* pickup */ "Flame Ammo",50,IT_AMMO,WP_FLAME_THROWER,
/* precache */ "",
/* sounds */ ""
},
|
/*
==============
PM_Weapon
Generates weapon events and modifes the weapon counter
==============
*/
static void PM_Weapon( void ) {
.
.
.
switch( pm->ps->weapon )
{
default:
case WP_GAUNTLET:
addTime = 400;
break;
case WP_FLAME_THROWER: //tute10.7
addTime = 40;
.
.
.
}
.
.
.
}
|
/*
===========
ClientSpawn
Called every time a client is placed fresh in the world:
after the first ClientBegin, and after each respawn
Initializes all non-persistant parts of playerState
============
*/
void ClientSpawn(gentity_t *ent) {
.
.
.
client->ps.stats[STAT_WEAPONS] = ( 1 << WP_MACHINEGUN );
if ( g_gametype.integer == GT_TEAM )
{
client->ps.ammo[WP_MACHINEGUN] = 50;
}
else
{
client->ps.ammo[WP_MACHINEGUN] = 100;
}
//tute10.8
//Spawn player with flame thrower
client->ps.stats[STAT_WEAPONS] = ( 1 << WP_FLAME_THROWER );
client->ps.ammo[WP_FLAME_THROWER] = 999;
.
.
.
}
|
/*
==============
ClearRegisteredItems
==============
*/
void ClearRegisteredItems( void ) {
memset( itemRegistered, 0, sizeof( itemRegistered ) );
// players always start with the base weapon
RegisterItem( BG_FindItemForWeapon( WP_MACHINEGUN ) );
RegisterItem( BG_FindItemForWeapon( WP_GAUNTLET ) );
RegisterItem( BG_FindItemForWeapon( WP_FLAME_THROWER) ); //tute10.9
.
.
.
}
|
/*
=================
TossClientItems
Toss the weapon and powerups for the killed player
=================
*/
void TossClientItems( gentity_t *self ) {
.
.
.
//tute10.11
if ( weapon == WP_MACHINEGUN || weapon == WP_GRAPPLING_HOOK || weapon == WP_FLAME_THROWER)
{
if ( self->client->ps.weaponstate == WEAPON_DROPPING )
{
weapon = self->client->pers.cmd.weapon;
}
.
.
.
}
//tute10.11
if ( weapon > WP_MACHINEGUN && weapon != WP_GRAPPLING_HOOK && weapon != WP_FLAME_THROWER && self->client->ps.ammo[ weapon ] )
{
// find the item type for this weapon
item = BG_FindItemForWeapon( weapon );
// spawn the item
Drop_Item( self, item, 0 );
}
.
.
.
}
|
/*
===============
FireWeapon
===============
*/
void FireWeapon( gentity_t *ent ) {
.
.
.
// fire the specific weapon
switch( ent->s.weapon ) {
.
.
.
case WP_FLAME_THROWER :
Weapon_fire_flame( ent );
break;
.
.
.
}
.
.
.
}
|
/*
=======================================================================
FLAME_THROWER
=======================================================================
*/
void Weapon_fire_flame (gentity_t *ent )
{
gentity_t *m;
m = fire_flame(ent, muzzle, forward);
m->damage *= s_quadFactor;
m->splashDamage *= s_quadFactor;
}
|
//*tute10.14
=================
fire_flame
=================
*/
gentity_t *fire_flame (gentity_t *self, vec3_t start, vec3_t dir)
{
gentity_t*bolt;
VectorNormalize (dir);
bolt = G_Spawn();
bolt->classname = "flame";
bolt->nextthink = level.time + 1500;
bolt->think = G_ExplodeMissile;
bolt->s.eType = ET_MISSILE;
bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
bolt->s.weapon = WP_FLAME_THROWER;
bolt->r.ownerNum = self->s.number;
bolt->parent = self;
bolt->damage = 30;
bolt->splashDamage = 25;
bolt->splashRadius = 45;
bolt->methodOfDeath = MOD_FLAME_THROWER;
bolt->splashMethodOfDeath = MOD_PLASMA_SPLASH;
bolt->clipmask = MASK_SHOT;
bolt->s.pos.trType = TR_LINEAR;
bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME;// move a bit on the very first frame
VectorCopy( start, bolt->s.pos.trBase );
VectorScale( dir, 300, bolt->s.pos.trDelta );
SnapVector( bolt->s.pos.trDelta );// save net bandwidth
VectorCopy (start, bolt->r.currentOrigin);
return bolt;
}
|
|
|
|