Part of the "Fixed" knife code - still needs tweaking, but improved nonetheless
This commit is contained in:
Victor Chow 2001-06-15 05:19:52 +00:00
parent ec9c397dad
commit 672ecad512
11 changed files with 242 additions and 94 deletions

View file

@ -771,6 +771,8 @@ void CG_BreakGlass( vec3_t playerOrigin, int glassParm ) {
count = 22 + rand() % 7;
}
CG_Printf("glassParm: %d\n", glassParm);
//Elder: check debris type and assign debris models
//Using bit-op check b/c I will be stuffing the amount in there too
if ( (glassParm & RQ3_DEBRIS_WOOD) == RQ3_DEBRIS_WOOD) {
@ -797,6 +799,18 @@ void CG_BreakGlass( vec3_t playerOrigin, int glassParm ) {
debris2 = cgs.media.paper02;
debris3 = cgs.media.paper03;
}
else if ( (glassParm & RQ3_DEBRIS_BRICK) == RQ3_DEBRIS_BRICK) {
CG_Printf("Launching brick\n");
debris1 = cgs.media.brick01;
debris2 = cgs.media.brick02;
debris3 = cgs.media.brick03;
}
else if ( (glassParm & RQ3_DEBRIS_CONCRETE) == RQ3_DEBRIS_CONCRETE) {
CG_Printf("Launching concrete\n");
debris1 = cgs.media.concrete01;
debris2 = cgs.media.concrete02;
debris3 = cgs.media.concrete03;
}
else {
//glass is default
CG_Printf("Launching glass\n");

View file

@ -244,22 +244,40 @@ static void CG_Item( centity_t *cent ) {
memset (&ent, 0, sizeof(ent));
//Elder: knife rotation code so it's always "in" the wall
if (item->giTag == WP_KNIFE && ( (es->eFlags & FL_THROWN_KNIFE) == FL_THROWN_KNIFE) ) {
VectorCopy( es->angles, cent->lerpAngles );
//Elder: nudges out a bit so it's more visible
VectorCopy( es->origin, cent->lerpOrigin );
AnglesToAxis( cent->lerpAngles, ent.axis );
}
else {
//Elder: default item orientation
VectorCopy( cg.autoAngles, cent->lerpAngles );
AxisCopy( cg.autoAxis, ent.axis );
}
// autorotate at one of two speeds
//Blaze: no rotating
// if ( item->giType == IT_HEALTH ) {
// VectorCopy( cg.autoAnglesFast, cent->lerpAngles );
// AxisCopy( cg.autoAxisFast, ent.axis );
// } else {
VectorCopy( cg.autoAngles, cent->lerpAngles );
AxisCopy( cg.autoAxis, ent.axis );
// VectorCopy( cg.autoAngles, cent->lerpAngles );
// AxisCopy( cg.autoAxis, ent.axis );
// }
wi = NULL;
// the weapons have their origin where they attatch to player
// models, so we need to offset them or they will rotate
// eccentricly
if ( item->giType == IT_WEAPON ) {
//Elder: added knife conditional
if ( item->giType == IT_WEAPON &&
!(item->giTag == WP_KNIFE && ( (es->eFlags & FL_THROWN_KNIFE) == FL_THROWN_KNIFE) ) ) {
vec3_t myvec;
//CG_Printf("Should not be in here if it's a thrown knife\n");
wi = &cg_weapons[item->giTag];
cent->lerpOrigin[0] -=
wi->weaponMidpoint[0] * ent.axis[0][0] +
@ -283,7 +301,9 @@ static void CG_Item( centity_t *cent ) {
VectorCopy(myvec, ent.axis[2]);
}
if (item->giType == IT_AMMO) cent->lerpOrigin[2]-=12;
//Elder: what the heck is this?
if (item->giType == IT_AMMO)
cent->lerpOrigin[2]-=12;
ent.hModel = cg_items[es->modelindex].models[0];

View file

@ -701,6 +701,12 @@ typedef struct {
qhandle_t paper01;
qhandle_t paper02;
qhandle_t paper03;
qhandle_t brick01;
qhandle_t brick02;
qhandle_t brick03;
qhandle_t concrete01;
qhandle_t concrete02;
qhandle_t concrete03;
//Elder: akimbo stuff - since it's valid every game
qhandle_t akimboModel;
qhandle_t akimboFlashModel;

View file

@ -964,6 +964,14 @@ static void CG_RegisterGraphics( void ) {
cgs.media.paper02 = trap_R_RegisterModel( "models/breakables/paper02.md3" );
cgs.media.paper03 = trap_R_RegisterModel( "models/breakables/paper03.md3" );
cgs.media.brick01 = trap_R_RegisterModel( "models/breakables/brick01.md3" );
cgs.media.brick02 = trap_R_RegisterModel( "models/breakables/brick02.md3" );
cgs.media.brick03 = trap_R_RegisterModel( "models/breakables/brick03.md3" );
cgs.media.concrete01 = trap_R_RegisterModel( "models/breakables/concrete01.md3" );
cgs.media.concrete02 = trap_R_RegisterModel( "models/breakables/concrete02.md3" );
cgs.media.concrete03 = trap_R_RegisterModel( "models/breakables/concrete03.md3" );
//Elder: akimbos - some of the stuff isn't in yet :p
cgs.media.akimboModel = trap_R_RegisterModel( "models/weapons2/akimbo/akimbo.md3" );
cgs.media.akimboFlashModel = trap_R_RegisterModel( "models/weapons2/akimbo/akimbo_flash.md3" );

View file

@ -45,7 +45,9 @@
#define RQ3_DEBRIS_METAL 0x00000040
#define RQ3_DEBRIS_CERAMIC 0x00000080
#define RQ3_DEBRIS_PAPER 0x00000100
#define RQ3_DEBRIS_POPCAN 0x00000200
#define RQ3_DEBRIS_BRICK 0x00000200
#define RQ3_DEBRIS_CONCRETE 0x00000400
//#define RQ3_DEBRIS_POPCAN 0x00000800
//Elder: to stop some of the hardcoding
//This is some ammo amounts per clip/item pick up
@ -121,6 +123,27 @@
#define RQ3_SOUND_KNIFEDEATH 2
#define RQ3_SOUND_LCA 3 //lights, camera, action!
//Elder: Weapon damage and spread stats
#define PISTOL_DAMAGE 90
#define MP5_DAMAGE 55
#define M4_DAMAGE 90
#define M3_DAMAGE 17
//Elder: wrong name
//#define SHOTGUN_DAMAGE 17
#define HANDCANNON_DAMAGE 20
#define SNIPER_DAMAGE 250
#define AKIMBO_DAMAGE 90
#define SLASH_DAMAGE 200 //Shashing knife damage
#define THROW_DAMAGE 250 //Throwing Knife damage
#define PISTOL_SPREAD 140
#define MP5_SPREAD 250
#define M4_SPREAD 300
#define SNIPER_SPREAD 425
#define AKIMBO_SPREAD 300
//Elder: special flag needed in both games
#define FL_THROWN_KNIFE 0x00040000 // Elder: thrown knife special case
//

View file

@ -862,13 +862,27 @@ gentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity, int xr_fla
dropped->touch = Touch_Item;
G_SetOrigin( dropped, origin );
dropped->s.pos.trType = TR_GRAVITY;
dropped->s.pos.trTime = level.time;
//Elder: should change to a constant velocity for weapons
VectorCopy( velocity, dropped->s.pos.trDelta );
//Elder: suspend thrown knives so they don't jitter
G_Printf("xr_flags: %d, condition: %d\n", xr_flags, (xr_flags & FL_THROWN_KNIFE) == FL_THROWN_KNIFE);
if (item->giTag == WP_KNIFE && ( (xr_flags & FL_THROWN_KNIFE) == FL_THROWN_KNIFE) ) {
G_SetOrigin( dropped, origin );
dropped->s.eFlags |= EF_BOUNCE_HALF;
//reset back the dropped item case
dropped->flags = FL_DROPPED_ITEM;
//dropped->s.eFlags |= EF_BOUNCE_HALF;
}
else {
G_SetOrigin( dropped, origin );
dropped->s.pos.trType = TR_GRAVITY;
dropped->s.pos.trTime = level.time;
//Elder: should change to a constant velocity for weapons
VectorCopy( velocity, dropped->s.pos.trDelta );
//Elder: moved from outside else statement
dropped->s.eFlags |= EF_BOUNCE_HALF;
}
#ifdef MISSIONPACK
if ((g_gametype.integer == GT_CTF || g_gametype.integer == GT_1FCTF) && item->giType == IT_TEAM) { // Special case for CTF flags
#else
@ -879,7 +893,7 @@ gentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity, int xr_fla
Team_CheckDroppedItem( dropped );
}
//Elder: Reaction Unique Weapons in deathmatch - respawn in 30 seconds
//Elder: Reaction Unique Weapons in deathmatch - respawn in ~60 seconds
//Don't forget to condition it when we get teamplay in
else if ( item->giType == IT_WEAPON &&
item->giTag != WP_GRENADE && item->giTag != WP_PISTOL &&
@ -903,10 +917,6 @@ gentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity, int xr_fla
dropped->physicsBounce= 0;
}
//Elder: suspend thrown knives so it doesn't jitter
//if (item->giTag == WP_KNIFE)
//dropped->spawnflags |= 1; //suspended
trap_LinkEntity (dropped);
return dropped;

View file

@ -44,6 +44,8 @@
//#define FL_THROWN_ITEM 0x00016000 // XRAY FMJ weapon throwing
#define FL_THROWN_ITEM 0x00010000 // XRAY FMJ weapon throwing
#define FL_RQ3_JUNKITEM 0x00020000 // Elder: the item we want to remove
//Elder: moved to bg_public.h
//#define FL_THROWN_KNIFE 0x00040000 // Elder: thrown knife special case
// movers are things like doors, plats, buttons, etc
typedef enum {
@ -472,7 +474,8 @@ void StartBandage(gentity_t *ent);
void ThrowWeapon( gentity_t *ent );
gentity_t *dropWeapon( gentity_t *ent, gitem_t *item, float angle, int xr_flags ); // XRAY FMJ
//Blaze Reaction knife stuff
void Rxn_SpawnKinfe( gentity_t *e);
//Elder: commented out - unused?
//void Rxn_SpawnKnife( gentity_t *e);
//
// g_spawn.c
//
@ -588,6 +591,7 @@ void TossClientCubes( gentity_t *self );
//
void G_RunMissile( gentity_t *ent );
gentity_t *fire_knife (gentity_t *self, vec3_t start, vec3_t aimdir);
gentity_t *fire_blaster (gentity_t *self, vec3_t start, vec3_t aimdir);
//Blaze: Dont need these functions
//gentity_t *fire_plasma (gentity_t *self, vec3_t start, vec3_t aimdir);
@ -631,7 +635,7 @@ qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker );
void CalcMuzzlePoint ( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint );
void SnapVectorTowards( vec3_t v, vec3_t to );
qboolean CheckGauntletAttack( gentity_t *ent );
void knife_touch (gentity_t *ent, gentity_t *other,trace_t *trace);
//void Knife_Touch (gentity_t *ent, gentity_t *other,trace_t *trace);
//Blaze: No need for these because no gauntlet
//void Weapon_HookFree (gentity_t *ent);
//void Weapon_HookThink (gentity_t *ent);

View file

@ -1697,6 +1697,7 @@ void G_RunFrame( int levelTime ) {
//Blaze: Used for droping knifes
gitem_t *xr_item;
gentity_t *xr_drop;
int temp;
int msec;
int start, end;
@ -1735,21 +1736,24 @@ start = trap_Milliseconds();
}
}
if ( ent->freeAfterEvent ) {
//Elder: moved to g_missile.c where it belongs
// tempEntities or dropped items completely go away after their event
if (!strcmp(ent->classname,"weapon_knife"))
{
//if (!strcmp(ent->classname,"weapon_knife"))
//{
/*
xr_item = BG_FindItemForWeapon( WP_KNIFE );
//Elder: removed
//xr_drop= dropWeapon( ent, xr_item, 0, FL_THROWN_ITEM );//FL_DROPPED_ITEM |
xr_drop = LaunchItem(xr_item,ent->s.pos.trBase,0,0);
xr_drop = LaunchItem(xr_item, ent->s.pos.trBase, 0, FL_THROWN_KNIFE);
G_FreeEntity(ent);
}
else
{
G_FreeEntity( ent );
}
*/
//}
//else
//{
G_FreeEntity( ent );
//}
continue;
} else if ( ent->unlinkAfterEvent ) {
// items that will respawn will hide themselves after their pickup event

View file

@ -324,7 +324,8 @@ Fires at either the target or the current direction.
2 - metal
3 - ceramics
4 - paper
5 - pop cans
5 - brick
6 - concrete
"amount" overrides the default quantity
0 - small: about 10 pieces
1 - medium: about 25 pieces
@ -347,7 +348,7 @@ void SP_func_breakable( gentity_t *ent ) {
G_SpawnInt( "debris", "0", &temp );
//Elder: hardcoded - I guess I should enum this
if (temp < 0 || temp > 3)
if (temp < 0 || temp > 6)
debris = RQ3_DEBRIS_GLASS;
else
debris = (1 << (temp + 4));
@ -360,8 +361,9 @@ void SP_func_breakable( gentity_t *ent ) {
//Elder: merge the bits
ent->s.eventParm = 0;
ent->s.eventParm |= debris;
ent->s.eventParm |= amount;
//ent->s.eventParm |= debris;
//ent->s.eventParm |= amount;
ent->s.eventParm = debris + amount;
ent->health = health;
// Let it take damage
@ -396,7 +398,7 @@ void G_BreakGlass(gentity_t *ent, vec3_t point, int mod) {
if( ent->health <= 0 ) {
//Elder: using event param to specify debris type
eParm = ent->s.eventParm;
//G_Printf("eParm: %d, original: %d\n", eParm, ent->s.eventParm);
G_Printf("eParm: %d\n", eParm);
//Elder: free it after the eventParm assignment
G_FreeEntity( ent );
// Tell the program based on the gun if it has no splash dmg, no reason to ad ones with

View file

@ -254,6 +254,10 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
vec3_t forward, impactpoint, bouncedir;
int eFlags;
#endif
//Elder: added for thrown knife condition
gitem_t *xr_item;
gentity_t *xr_drop;
other = &g_entities[trace->entityNum];
//Elder: no grenade explosion on impact
@ -309,9 +313,13 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
if ( VectorLength( velocity ) == 0 ) {
velocity[2] = 1; // stepped on a grenade
}
G_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity,
//Elder: added
if ( !(ent->s.weapon == WP_KNIFE && other->s.eType == ET_BREAKABLE) ) {
G_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity,
ent->s.origin, ent->damage,
0, ent->methodOfDeath);
}
}
}
@ -385,8 +393,8 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
G_SetOrigin( ent, v );
G_SetOrigin( nent, v );
//Blaze: Hook dosent exist any more
// ent->think = Weapon_HookThink;
//Blaze: Hook dosent exist any more
//ent->think = Weapon_HookThink;
ent->nextthink = level.time + FRAMETIME;
ent->parent->client->ps.pm_flags |= PMF_GRAPPLE_PULL;
@ -401,6 +409,8 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
// is it cheaper in bandwidth to just remove this ent and create a new
// one, rather than changing the missile into the explosion?
//Elder: I don't know but that's what we did for the knife
if ( other->takedamage && other->client ) {
G_AddEvent( ent, EV_MISSILE_HIT, DirToByte( trace->plane.normal ) );
ent->s.otherEntityNum = other->s.number;
@ -410,6 +420,65 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( trace->plane.normal ) );
}
//Elder: knife handling routines go HERE, not in g_main.c !!!
if (ent->s.weapon == WP_KNIFE) {
if ( other->takedamage && other->client) {
//hit a player - send the gurgle or embedding sound event
}
else {
vec3_t temp;
vec3_t knifeOffset;
vec3_t knifeVelocity;
//missed throw or hit func_breakable;
//spawn a knife at its trajectory end-point
xr_item = BG_FindItemForWeapon( WP_KNIFE );
if (other->s.eType == ET_BREAKABLE) {
VectorScale(trace->plane.normal, 10, knifeVelocity);
knifeVelocity[1] -= 50;
//breakable "hit"; make it fall to the ground
xr_drop = LaunchItem(xr_item, trace->endpos, knifeVelocity, FL_DROPPED_ITEM);
//but still set it as a thrown knife
//xr_drop->flags |= FL_THROWN_KNIFE;
//Elder: make the knife stick out a bit more
//and transfer into shared entityState
VectorScale(trace->plane.normal, 16, temp);
VectorAdd(trace->endpos, temp, knifeOffset);
VectorCopy(xr_drop->s.origin, temp);
VectorAdd(temp, knifeOffset, xr_drop->s.origin);
VectorCopy(xr_drop->s.origin, xr_drop->r.currentOrigin);
}
else {
//leave embedded in the wall
xr_drop = LaunchItem(xr_item, trace->endpos, 0, FL_THROWN_KNIFE);
VectorClear( xr_drop->s.pos.trDelta );
//Elder: make the knife stick out a bit more
//and transfer into shared entityState
VectorScale(trace->plane.normal, 4, temp);
VectorAdd(trace->endpos, temp, knifeOffset);
VectorCopy(xr_drop->s.origin, temp);
VectorAdd(temp, knifeOffset, xr_drop->s.origin);
}
//Elder: make the knife stick out a bit more
//and transfer into shared entityState
//VectorScale(trace->plane.normal, 4, temp);
//VectorAdd(trace->endpos, temp, knifeOffset);
//VectorCopy(xr_drop->s.origin, temp);
//VectorAdd(temp, knifeOffset, xr_drop->s.origin);
//Elder: transfer entity data into the shared entityState
//They are rotated on the client side in cg_ents.c
xr_drop->s.eFlags = xr_drop->flags;
vectoangles( trace->plane.normal, xr_drop->s.angles );
xr_drop->s.angles[0] += 270;
}
}
ent->freeAfterEvent = qtrue;
// change over to a normal entity right at the point of impact
@ -625,6 +694,39 @@ gentity_t *fire_grenade (gentity_t *self, vec3_t start, vec3_t dir) {
return bolt;
}
gentity_t *fire_knife (gentity_t *self, vec3_t start, vec3_t dir)
{
gentity_t *bolt;
VectorNormalize (dir);
bolt = G_Spawn();
bolt->classname = "weapon_knife";
bolt->nextthink = level.time + 10000;
bolt->think = G_FreeEntity;
bolt->s.eType = ET_MISSILE;
bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
bolt->s.weapon = WP_KNIFE;
bolt->r.ownerNum = self->s.number;
bolt->parent = self;
bolt->damage = THROW_DAMAGE;
bolt->splashDamage = 0;
bolt->splashRadius = 0;
bolt->methodOfDeath = MOD_KNIFE_THROWN;
bolt->clipmask = MASK_SHOT;
bolt->target_ent = NULL;
bolt->count = 1;
bolt->s.pos.trType = TR_GRAVITY;
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, 1100, bolt->s.pos.trDelta );
SnapVector( bolt->s.pos.trDelta ); // save net bandwidth
VectorCopy (start, bolt->r.currentOrigin);
return bolt;
}
//=============================================================================

View file

@ -6,24 +6,7 @@
#include "g_local.h"
//Blaze: reaction weapon damage ratings & weapon spreads
//Elder: moved to the top
#define PISTOL_DAMAGE 90
#define MP5_DAMAGE 55
#define M4_DAMAGE 90
#define M3_DAMAGE 17
//Elder: wrong name
//#define SHOTGUN_DAMAGE 17
#define HANDCANNON_DAMAGE 20
#define SNIPER_DAMAGE 250
#define AKIMBO_DAMAGE 90
#define SLASH_DAMAGE 200//Shashing knife damage
#define THROW_DAMAGE 250//Throwing Knife damage
#define PISTOL_SPREAD 140
#define MP5_SPREAD 250
#define M4_SPREAD 300
#define SNIPER_SPREAD 425
#define AKIMBO_SPREAD 300
//Elder: moved to bg_public.h with the rest of the constants
static float s_quadFactor;
@ -810,13 +793,15 @@ int Knife_Attack ( gentity_t *self, int damage)
static int knives = 0;
void knife_touch (gentity_t *ent, gentity_t *other,trace_t *trace)
//Elder: this function does not appear to be in use
void Knife_Touch (gentity_t *ent, gentity_t *other,trace_t *trace)
{
vec3_t origin;
gitem_t *xr_item;
gentity_t *xr_drop;
G_Printf("Knife Touched Something\n");
G_Printf("Knife Touched Something\n");
if (other == ent->parent)
@ -877,48 +862,17 @@ G_Printf("Knife Touched Something\n");
//Elder: todo - rotate the knife model so it's collinear with trajectory
//and eliminate the jittering
xr_item = BG_FindItemForWeapon( WP_KNIFE );
//xr_drop = dropWeapon( ent, xr_item, 0, FL_DROPPED_ITEM | FL_THROWN_ITEM );
xr_drop = dropWeapon( ent, xr_item, 0, FL_DROPPED_ITEM);
//xr_drop = dropWeapon( ent, xr_item, 0, FL_DROPPED_ITEM);
xr_drop = LaunchItem(xr_item, ent->s.pos.trBase, 0, FL_THROWN_KNIFE);
xr_drop->count = 1;
}
G_FreeEntity (ent);
}
//gentity_t *Knife_Throw (gentity_t *self,vec3_t start, vec3_t dir, int damage, int speed )
gentity_t* Knife_Throw (gentity_t *self,vec3_t start, vec3_t dir, int damage, int speed )
{
gentity_t *bolt;
VectorNormalize (dir);
bolt = G_Spawn();
bolt->classname = "weapon_knife";
bolt->nextthink = level.time + 10000;
bolt->think = G_FreeEntity;
bolt->s.eType = ET_MISSILE;
bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
bolt->s.weapon = WP_KNIFE;
bolt->r.ownerNum = self->s.number;
bolt->parent = self;
bolt->damage = 100;
bolt->methodOfDeath = MOD_KNIFE;
bolt->clipmask = MASK_SHOT;
bolt->count = 1;
bolt->s.pos.trType = TR_GRAVITY;
//bolt->s.pos.trType = TR_LINEAR;
bolt->s.pos.trTime = level.time - 50; // move a bit on the very first frame
VectorCopy( start, bolt->s.pos.trBase );
VectorScale( dir, 1100, bolt->s.pos.trDelta );
//VectorScale( dir, 50, bolt->s.pos.trDelta );
SnapVector( bolt->s.pos.trDelta ); // save net bandwidth
VectorCopy (start, bolt->r.currentOrigin);
return bolt;
}
//Elder: moved knife_throw to g_missile.c where it belongs
@ -962,10 +916,11 @@ void Weapon_Knife_Fire(gentity_t *ent)
// extra vertical velocity
forward[2] += 0.2f;
VectorNormalize( forward );
//Elder: already done in Knife_Throw
//VectorNormalize( forward );
m = Knife_Throw(ent,muzzle,forward, THROW_DAMAGE, 1200);
//m = Knife_Throw(ent, muzzle, forward, THROW_DAMAGE, 1200);
m = fire_knife(ent, muzzle, forward);
// m->damage *= s_quadFactor;
// m->splashDamage *= s_quadFactor;
// ^^^^ Homer: got quad?