mirror of
https://github.com/yquake2/zaero.git
synced 2024-11-21 19:41:07 +00:00
T_Damage no longer modifies dir parameter
This commit is contained in:
parent
50f18732f6
commit
30b91965e2
3 changed files with 38 additions and 37 deletions
|
@ -398,6 +398,21 @@ qboolean CheckTeamDamage (edict_t *targ, edict_t *attacker)
|
|||
return false;
|
||||
}
|
||||
|
||||
static void apply_knockback(edict_t *targ, vec3_t dir, float knockback, float scale)
|
||||
{
|
||||
vec3_t kvel;
|
||||
float mass;
|
||||
|
||||
if (!knockback)
|
||||
return;
|
||||
|
||||
mass = (targ->mass < 50) ? 50.0f : (float)targ->mass;
|
||||
|
||||
VectorNormalize2 (dir, kvel);
|
||||
VectorScale (kvel, scale * (knockback / mass), kvel);
|
||||
VectorAdd (targ->velocity, kvel, targ->velocity);
|
||||
}
|
||||
|
||||
void T_Damage (edict_t *targ, edict_t *inflictor, edict_t *attacker, vec3_t dir, vec3_t point, vec3_t normal, int damage, int knockback, int dflags, int mod)
|
||||
{
|
||||
gclient_t *client;
|
||||
|
@ -453,8 +468,6 @@ void T_Damage (edict_t *targ, edict_t *inflictor, edict_t *attacker, vec3_t dir,
|
|||
else
|
||||
te_sparks = TE_SPARKS;
|
||||
|
||||
VectorNormalize(dir);
|
||||
|
||||
// bonus damage for suprising a monster
|
||||
if (!(dflags & DAMAGE_RADIUS) && (targ->svflags & SVF_MONSTER) && (attacker->client) && (!targ->enemy) && (targ->health > 0))
|
||||
damage *= 2;
|
||||
|
@ -509,30 +522,20 @@ void T_Damage (edict_t *targ, edict_t *inflictor, edict_t *attacker, vec3_t dir,
|
|||
asave += save;
|
||||
|
||||
// figure momentum add
|
||||
if (!(dflags & DAMAGE_NO_KNOCKBACK))
|
||||
if (knockback && !(dflags & DAMAGE_NO_KNOCKBACK) &&
|
||||
(targ->movetype != MOVETYPE_NONE) &&
|
||||
(targ->movetype != MOVETYPE_BOUNCE) &&
|
||||
(targ->movetype != MOVETYPE_BOUNCEFLY) &&
|
||||
(targ->movetype != MOVETYPE_PUSH) &&
|
||||
(targ->movetype != MOVETYPE_STOP))
|
||||
{
|
||||
if ((knockback) && (targ->movetype != MOVETYPE_NONE) && (targ->movetype != MOVETYPE_BOUNCE) && (targ->movetype != MOVETYPE_BOUNCEFLY) && (targ->movetype != MOVETYPE_PUSH) && (targ->movetype != MOVETYPE_STOP))
|
||||
if ((dflags & DAMAGE_ARMORMOSTLY) && damage > take)
|
||||
{
|
||||
vec3_t kvel;
|
||||
float mass;
|
||||
|
||||
if((dflags & DAMAGE_ARMORMOSTLY) && damage > take)
|
||||
{
|
||||
knockback = (int)((float)knockback * (((float)(damage - take) / (float)damage) + 1.0));
|
||||
}
|
||||
|
||||
if (targ->mass < 50)
|
||||
mass = 50;
|
||||
else
|
||||
mass = targ->mass;
|
||||
|
||||
if (targ->client && attacker == targ)
|
||||
VectorScale (dir, 1600.0 * (float)knockback / mass, kvel); // the rocket jump hack...
|
||||
else
|
||||
VectorScale (dir, 500.0 * (float)knockback / mass, kvel);
|
||||
|
||||
VectorAdd (targ->velocity, kvel, targ->velocity);
|
||||
knockback = (int)((float)knockback * (((float)(damage - take) / (float)damage) + 1.0));
|
||||
}
|
||||
|
||||
apply_knockback (targ, dir, knockback,
|
||||
((client && attacker == targ) ? 1600.0f : 500.0f));
|
||||
}
|
||||
|
||||
// team damage avoidance
|
||||
|
|
|
@ -869,7 +869,14 @@ void bfg_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf
|
|||
gi.sound (self, CHAN_VOICE, gi.soundindex ("weapons/bfg__x1b.wav"), 1, ATTN_NORM, 0);
|
||||
self->solid = SOLID_NOT;
|
||||
self->touch = NULL;
|
||||
VectorMA (self->s.origin, -1 * FRAMETIME, self->velocity, self->s.origin);
|
||||
|
||||
// move it back a bit from walls so the effects aren't cut off
|
||||
if (!other->takedamage)
|
||||
{
|
||||
VectorNormalize (self->velocity);
|
||||
VectorMA (self->s.origin, -40.0f, self->velocity, self->s.origin);
|
||||
}
|
||||
|
||||
VectorClear (self->velocity);
|
||||
self->s.modelindex = gi.modelindex ("sprites/s_bfg3.sp2");
|
||||
self->s.frame = 0;
|
||||
|
@ -879,6 +886,8 @@ void bfg_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf
|
|||
self->nextthink = level.time + FRAMETIME;
|
||||
self->enemy = other;
|
||||
|
||||
gi.linkentity (self);
|
||||
|
||||
gi.WriteByte (svc_temp_entity);
|
||||
gi.WriteByte (TE_BFG_BIGEXPLOSION);
|
||||
gi.WritePosition (self->s.origin);
|
||||
|
|
|
@ -504,20 +504,9 @@ VectorNormalize(vec3_t v)
|
|||
vec_t
|
||||
VectorNormalize2(vec3_t v, vec3_t out)
|
||||
{
|
||||
float length, ilength;
|
||||
VectorCopy(v, out);
|
||||
|
||||
length = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
|
||||
length = (float)sqrt(length);
|
||||
|
||||
if (length)
|
||||
{
|
||||
ilength = 1 / length;
|
||||
out[0] = v[0] * ilength;
|
||||
out[1] = v[1] * ilength;
|
||||
out[2] = v[2] * ilength;
|
||||
}
|
||||
|
||||
return length;
|
||||
return VectorNormalize(out);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue