Fixed my fix for doors-->spectators/players - NiceAss

This commit is contained in:
Bryce Hutchings 2001-11-11 23:59:17 +00:00
parent 05a49b6eae
commit fc52427dc8
3 changed files with 98 additions and 75 deletions

View file

@ -64,11 +64,11 @@ void P_DamageFeedback( gentity_t *player ) {
// Q3 Code
/* client->ps.damagePitch = angles[PITCH]/360.0 * 256;
client->ps.damageYaw = angles[YAW]/360.0 * 256;*/
// new RQ3 view-kick code, needs more tweaking (the 50 needs to be replaces with that below calcuation
// from the AQ2 code.
// set aiming directions
AngleVectors (client->ps.viewangles, forward, right, up);
@ -80,7 +80,7 @@ void P_DamageFeedback( gentity_t *player ) {
side = - DotProduct(v,right);
client->ps.damageYaw = 50*side*0.3;
}
/* AQ2 code pasted here for reference
@ -97,10 +97,10 @@ void P_DamageFeedback( gentity_t *player ) {
VectorSubtract (client->damage_from, player->s.origin, v);
VectorNormalize (v);
side = DotProduct (v, right);
client->v_dmg_roll = kick*side*0.3;
side = -DotProduct (v, forward);
client->v_dmg_pitch = kick*side*0.3;
@ -112,19 +112,19 @@ void P_DamageFeedback( gentity_t *player ) {
*/
/*
G_Printf("Lasthurt: %d, Head: %d, Face: %d, And-Op: %d\n",
client->lasthurt_location,
G_Printf("Lasthurt: %d, Head: %d, Face: %d, And-Op: %d\n",
client->lasthurt_location,
LOCATION_HEAD, LOCATION_FACE,
client->lasthurt_location & ~(LOCATION_BACK | LOCATION_LEFT | LOCATION_RIGHT | LOCATION_FRONT) );
*/
// play an appropriate pain sound
if ( (level.time > player->pain_debounce_time) && !(player->flags & FL_GODMODE) ) {
//player->pain_debounce_time = level.time + 700;
//Elder: reduced pain debounce time so we can have a few more sounds :)
player->pain_debounce_time = level.time + 250;
switch ( client->lasthurt_location &
switch ( client->lasthurt_location &
~(LOCATION_BACK | LOCATION_LEFT | LOCATION_RIGHT | LOCATION_FRONT) ) {
//Elder: headshot sound
case LOCATION_HEAD:
@ -132,10 +132,10 @@ void P_DamageFeedback( gentity_t *player ) {
if (client->lasthurt_mod == MOD_KNIFE || client->lasthurt_mod == MOD_KNIFE_THROWN)
G_AddEvent( player, EV_RQ3_SOUND, RQ3_SOUND_KNIFEDEATH);
//Elder: do nothing -- sound is handled in g_combat.c again
//tent = G_TempEntity2(client->ps.origin, EV_RQ3_SOUND, RQ3_SOUND_HEADSHOT);
//tent = G_TempEntity2(client->ps.origin, EV_RQ3_SOUND, RQ3_SOUND_HEADSHOT);
//Elder: takes more bandwidth but guarantees a headshot sound
//G_Sound(player, CHAN_AUTO, G_SoundIndex("sound/misc/headshot.wav"));
//G_AddEvent ( player, EV_RQ3_SOUND, RQ3_SOUND_HEADSHOT);
//G_AddEvent ( player, EV_RQ3_SOUND, RQ3_SOUND_HEADSHOT);
break;
/*
case LOCATION_CHEST:
@ -147,7 +147,7 @@ void P_DamageFeedback( gentity_t *player ) {
G_AddEvent( player, EV_PAIN, player->health );
break;
}
client->ps.damageEvent++;
}
@ -229,7 +229,7 @@ void P_WorldEffects( gentity_t *ent ) {
// don't play a normal pain sound
ent->pain_debounce_time = level.time + 200;
G_Damage (ent, NULL, NULL, NULL, NULL,
G_Damage (ent, NULL, NULL, NULL, NULL,
ent->damage, DAMAGE_NO_ARMOR, MOD_WATER);
}
}
@ -241,7 +241,7 @@ void P_WorldEffects( gentity_t *ent ) {
//
// check for sizzle damage (move to pmove?)
//
if (waterlevel &&
if (waterlevel &&
(ent->watertype&(CONTENTS_LAVA|CONTENTS_SLIME)) ) {
/*
if (ent->health > 0
@ -254,16 +254,16 @@ void P_WorldEffects( gentity_t *ent ) {
G_AddEvent( ent, EV_POWERUP_BATTLESUIT, 0 );
} else {
if (ent->watertype & CONTENTS_LAVA) {
//G_Damage (ent, NULL, NULL, NULL, NULL,
//G_Damage (ent, NULL, NULL, NULL, NULL,
//30*waterlevel, 0, MOD_LAVA);
G_Damage (ent, NULL, NULL, NULL, NULL,
G_Damage (ent, NULL, NULL, NULL, NULL,
3*waterlevel, 0, MOD_LAVA);
}
if (ent->watertype & CONTENTS_SLIME) {
//G_Damage (ent, NULL, NULL, NULL, NULL,
//G_Damage (ent, NULL, NULL, NULL, NULL,
//10*waterlevel, 0, MOD_SLIME);
G_Damage (ent, NULL, NULL, NULL, NULL,
G_Damage (ent, NULL, NULL, NULL, NULL,
waterlevel, 0, MOD_SLIME);
}
// Elder: added
@ -383,7 +383,8 @@ void G_TouchTriggers( gentity_t *ent ) {
if ( hit->s.eType != ET_TELEPORT_TRIGGER &&
// this is ugly but adding a new ET_? type will
// most likely cause network incompatibilities
hit->touch != Touch_DoorTrigger) {
// NiceAss: changed Touch_DoorTrigger to Touch_DoorTriggerSpectator
hit->touch != Touch_DoorTriggerSpectator) {
continue;
}
}
@ -474,8 +475,8 @@ qboolean ClientInactivityTimer( gclient_t *client ) {
// gameplay, everyone isn't kicked
client->inactivityTime = level.time + 60 * 1000;
client->inactivityWarning = qfalse;
} else if ( client->pers.cmd.forwardmove ||
client->pers.cmd.rightmove ||
} else if ( client->pers.cmd.forwardmove ||
client->pers.cmd.rightmove ||
client->pers.cmd.upmove ||
(client->pers.cmd.buttons & BUTTON_ATTACK) ) {
client->inactivityTime = level.time + g_inactivity.integer * 1000;
@ -706,7 +707,7 @@ void ClientEvents( gentity_t *ent, int oldEventSequence ) {
{
G_Damage (ent, NULL, NULL, NULL, NULL, damage, 0, MOD_FALLING);
}
break;
case EV_FALL_FAR_NOSOUND:
@ -732,7 +733,7 @@ void ClientEvents( gentity_t *ent, int oldEventSequence ) {
{
G_Damage (ent, NULL, NULL, NULL, NULL, damage, 0, MOD_FALLING);
}
break;
case EV_FIRE_WEAPON:
@ -925,7 +926,7 @@ int ThrowWeapon( gentity_t *ent, qboolean forceThrow )
//}
//Elder: remove zoom bits
Cmd_Unzoom(ent);
weap = 0;
if (client->uniqueWeapons > 0)
{
@ -955,21 +956,21 @@ int ThrowWeapon( gentity_t *ent, qboolean forceThrow )
}
xr_item = BG_FindItemForWeapon( weap );
//Elder: Send a server command instead of force-setting
//client->ps.weapon = WP_PISTOL;
//Elder: Don't reset the weapon ammo
//client->ps.ammo[ weap ] = 0;
client->pers.hadUniqueWeapon[weap] = qtrue;
//Elder: for immediate weapon drops
if (client->ps.weapon == weap)
{
client->ps.stats[STAT_RQ3] |= RQ3_THROWWEAPON;
trap_SendServerCommand( ent-g_entities, va("selectpistol"));
}
client->weaponCount[weap]--;
if (client->weaponCount[weap] == 0)
client->ps.stats[STAT_WEAPONS] &= ~( 1 << weap);
@ -1086,7 +1087,7 @@ void ClientThink_real( gentity_t *ent ) {
if ( ucmd->serverTime < level.time - 1000 ) {
ucmd->serverTime = level.time - 1000;
// G_Printf("serverTime >>>>>\n" );
}
}
msec = ucmd->serverTime - client->ps.commandTime;
// following others may result in bad times, but we still want
@ -1305,7 +1306,7 @@ void ClientThink_real( gentity_t *ent ) {
// touch other objects
ClientImpacts( ent, &pm );
//Elder: someone added
if ( bJumping ) JumpKick( ent );
@ -1313,7 +1314,7 @@ void ClientThink_real( gentity_t *ent ) {
switch( ent->client->ps.weapon ) {
case WP_AKIMBO:
/*
if ( ent->client->weaponfireNextTime != 0 &&
if ( ent->client->weaponfireNextTime != 0 &&
level.time >= ent->client->weaponfireNextTime) {
FireWeapon( ent );
}
@ -1327,7 +1328,7 @@ void ClientThink_real( gentity_t *ent ) {
{
G_Printf("(%i) ClientThink: attempting M3 fast-reload...\n", ent->s.clientNum);
Cmd_Reload( ent );
}
}
break;
case WP_SSG3000:
//Elder: try to do a fast reload if it's queued
@ -1337,12 +1338,12 @@ void ClientThink_real( gentity_t *ent ) {
{
G_Printf("(%i) ClientThink: attempting SSG fast-reload...\n", ent->s.clientNum);
Cmd_Reload( ent );
}
}
break;
default:
break;
}
// save results of triggers and client events
if (ent->client->ps.eventSequence != oldEventSequence) {
ent->eventTime = level.time;
@ -1358,12 +1359,12 @@ void ClientThink_real( gentity_t *ent ) {
// wait for the attack button to be pressed
if ( level.time > client->respawnTime ) {
// forcerespawn is to prevent users from waiting out powerups
if ( g_forcerespawn.integer > 0 &&
if ( g_forcerespawn.integer > 0 &&
( level.time - client->respawnTime ) > g_forcerespawn.integer * 1000 ) {
respawn( ent );
return;
}
// pressing attack or use is the normal respawn method
if ( ucmd->buttons & ( BUTTON_ATTACK | BUTTON_USE_HOLDABLE ) ) {
respawn( ent );
@ -1642,10 +1643,10 @@ void ClientEndFrame( gentity_t *ent ) {
ent->client->ps.stats[STAT_RQ3] &= ~RQ3_BANDAGE_WORK;
}
//Moved to pmove.c
//Elder: M4 ride-up/kick -- condition for non-burst and ammo only
if (ent->client->consecutiveShots &&
(ent->client->ps.ammo[WP_M4] <= 0 || ent->client->ps.weaponstate != WEAPON_FIRING))
{
@ -1667,7 +1668,7 @@ void ClientEndFrame( gentity_t *ent ) {
//Try to turn the laser on if it's off
if (ent->client->lasersight == NULL)
Laser_Gen(ent, qtrue);
}
}
//RQ3_ClientReloadStages(ent);

View file

@ -21,7 +21,7 @@
// that run non-standard server frame rates.
#define BLEED_TIME 20
// Elder: Everyone knows you lose 6 health from the moment you start bandaging
// Let's enforce that in-code because it's sometimes 7 or even 8
// Let's enforce that in-code because it's sometimes 7 or even 8
// Elder: LOL it's 3, dumb Elder!
#define BLEED_BANDAGE 3
#define BLEED_BANDAGE_TIME 5400 // 27 x 2
@ -107,13 +107,13 @@ struct gentity_s {
char *model;
char *model2;
int freetime; // level.time when the object was freed
int eventTime; // events will be cleared EVENT_VALID_MSEC after set
qboolean freeAfterEvent;
qboolean unlinkAfterEvent;
qboolean physicsObject; // if true, it can be pushed by movers and fall off edges
// all game items are physicsObjects,
// all game items are physicsObjects,
float physicsBounce; // 1.0 = continuous bounce, 0.0 = no bounce
int clipmask; // brushes with this content value will be collided against
// when moving. items and corpses do not collide against
@ -191,7 +191,7 @@ struct gentity_s {
float wait;
float random;
gitem_t *item; // for bonus items
gitem_t *item; // for bonus items
float distance; // VALKYRIE: for rotating door
};
@ -258,7 +258,7 @@ typedef struct {
// client data that stays across multiple respawns, but is cleared
// on each level change or team change at ClientBegin()
typedef struct {
clientConnected_t connected;
clientConnected_t connected;
usercmd_t cmd; // we would lose angles if not persistant
qboolean localClient; // true if "ip" info key is "localhost"
qboolean initialSpawn; // the first spawn should be at a cool location
@ -271,12 +271,12 @@ typedef struct {
int voteCount; // to prevent people from constantly calling votes
int teamVoteCount; // to prevent people from constantly calling votes
qboolean teamInfo; // send team overlay updates?
qboolean hadUniqueWeapon[MAX_WEAPONS]; //Elder: for "ammo" in last gun
int sayTime; // Elder: say validation stuff
int sayCount;
int sayWarnings;
int sayWarnings;
int sayBans;
int sayMuteTime;
qboolean sayModerated; // so warnings are not repeated for multi-line, same-frame messages
@ -392,7 +392,7 @@ struct gclient_s {
int switchTeamTime; // time the player switched teams
// Begin Duffman
int numClips[MAX_WEAPONS]; // Number of clips each weapon has
// End Duffman
// End Duffman
int weaponCount[WP_NUM_WEAPONS]; // Elder: for duplicate unique weapon tracking
qboolean openDoor; //Blaze: used to hold if someone has hit opendoor key
@ -422,7 +422,7 @@ struct gclient_s {
// int zoomed; // Hawkins (SSG zoom)
//qboolean semi; // hawkins (semiauto mode for m4, mp5, pistol)
int shots; // Blaze: Number of shots fired so far with this weapon
int weaponfireNextTime; // for akimbos
int lastzoom; // Elder: save last zoom state when firing
@ -431,7 +431,7 @@ struct gclient_s {
int lastReloadTime; // Elder: for queuing M3/SSG reloads
int reloadAttempts; // Elder: for queuing M3/SSG reloads
int reloadStage; // Elder: 0, 1, 2 for sound queuing - move to stats?
int consecutiveShots; // Elder: for M4 ride-up/kick
int uniqueWeapons; // Elder: formerly a stat, now just a server var
int uniqueItems;
@ -706,6 +706,7 @@ gentity_t *fire_prox( gentity_t *self, vec3_t start, vec3_t aimdir );
//
void G_RunMover( gentity_t *ent );
void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace );
void Touch_DoorTriggerSpectator( gentity_t *ent, gentity_t *other, trace_t *trace ); // NiceAss: Added
//
// g_trigger.c

View file

@ -1099,29 +1099,32 @@ void Blocked_Door( gentity_t *ent, gentity_t *other ) {
Touch_DoorTriggerSpectator
================
*/
static void Touch_DoorTriggerSpectator( gentity_t *ent, gentity_t *other, trace_t *trace ) {
void Touch_DoorTriggerSpectator( gentity_t *ent, gentity_t *other, trace_t *trace ) {
int i, axis;
vec3_t origin, dir, angles;
axis = ent->count;
VectorClear(dir);
if (fabs(other->s.origin[axis] - ent->r.absmax[axis]) <
fabs(other->s.origin[axis] - ent->r.absmin[axis])) {
// NiceAss: "- 10" changed to "- 15" to prevent jumping back and forth occasionally when moving slowly
origin[axis] = ent->r.absmin[axis] - 15;
dir[axis] = -1;
// NiceAss: Only let spectators teleport through a door.
if (other->client->sess.sessionTeam == TEAM_SPECTATOR) {
axis = ent->count;
VectorClear(dir);
if (fabs(other->s.origin[axis] - ent->r.absmax[axis]) <
fabs(other->s.origin[axis] - ent->r.absmin[axis])) {
// NiceAss: "- 10" changed to "- 15" to prevent jumping back and forth occasionally when moving slowly
origin[axis] = ent->r.absmin[axis] - 15;
dir[axis] = -1;
}
else {
// NiceAss: "- 10" changed to "- 15" to prevent jumping back and forth occasionally when moving slowly
origin[axis] = ent->r.absmax[axis] + 15;
dir[axis] = 1;
}
for (i = 0; i < 3; i++) {
if (i == axis) continue;
origin[i] = (ent->r.absmin[i] + ent->r.absmax[i]) * 0.5;
}
vectoangles(dir, angles);
TeleportPlayer(other, origin, angles );
}
else {
// NiceAss: "- 10" changed to "- 15" to prevent jumping back and forth occasionally when moving slowly
origin[axis] = ent->r.absmax[axis] + 15;
dir[axis] = 1;
}
for (i = 0; i < 3; i++) {
if (i == axis) continue;
origin[i] = (ent->r.absmin[i] + ent->r.absmax[i]) * 0.5;
}
vectoangles(dir, angles);
TeleportPlayer(other, origin, angles );
}
/*
@ -1130,6 +1133,8 @@ Touch_DoorTrigger
================
*/
void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace ) {
// NiceAss: Not needed now that door's have their own spectator trigger
/*
if ( other->client && other->client->sess.sessionTeam == TEAM_SPECTATOR ) {
// if the door is not open and not opening
if ( ent->parent->moverState != MOVER_1TO2 &&
@ -1139,10 +1144,11 @@ void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace ) {
Touch_DoorTriggerSpectator( ent, other, trace );
}
}
*/
//else if ( ent->parent->moverState != MOVER_1TO2 &&
//ent->parent->moverState != ROTATOR_1TO2 ) {
//Elder: we want to handle MOVER_1TO2 and ROTATOR_1TO2 now
else {
//else {
//Blaze's broken open door code
//Elder: not as broken as you think :)
if (other->client->openDoor == qtrue ||
@ -1152,7 +1158,7 @@ void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace ) {
other->client->openDoor = qfalse;
other->client->openDoorTime = 0;
}
}
//}
}
@ -1190,11 +1196,10 @@ void Think_SpawnNewDoorTrigger( gentity_t *ent ) {
best = i;
}
}
// NiceAss: This affected spectators near doors (jumping too soon)
// This was expanding the bounds of the door trigger out from the door 120 units.
//maxs[best] += 120;
//mins[best] -= 120;
maxs[best] += 120;
mins[best] -= 120;
// NiceAss: This trigger will be for players
// create a trigger with this size
other = G_Spawn ();
other->classname = "door_trigger";
@ -1207,6 +1212,22 @@ void Think_SpawnNewDoorTrigger( gentity_t *ent ) {
other->count = best;
trap_LinkEntity (other);
// NiceAss: This trigger will be for spectators
// NiceAss: Undo most of the stretched box size so it is only a little bigger than the door
maxs[best] -= 110;
mins[best] += 110;
other = G_Spawn ();
other->classname = "door_trigger_spectator";
VectorCopy (mins, other->r.mins);
VectorCopy (maxs, other->r.maxs);
other->parent = ent;
other->r.contents = CONTENTS_TRIGGER;
other->touch = Touch_DoorTriggerSpectator;
// remember the thinnest axis
other->count = best;
trap_LinkEntity (other);
MatchTeam( ent, ent->moverState, level.time );
}