mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-13 07:58:04 +00:00
Minor no-functionality-changing tweaks.
- factor out: G_WallSpriteDist() - factor out: Proj_MaybeDamageCF() and Proj_MaybeDamageCF2() in preparation for the next commit - Make PROJ_DECAYVELOCITY macro take an arg for readability's sake git-svn-id: https://svn.eduke32.com/eduke32@4204 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
0f6e22e20e
commit
99894812d8
4 changed files with 59 additions and 43 deletions
|
@ -107,6 +107,12 @@ void G_ClearCameraView(DukePlayer_t *ps)
|
||||||
sprite[k].yvel = 0;
|
sprite[k].yvel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Manhattan distance between wall-point and sprite.
|
||||||
|
static int32_t G_WallSpriteDist(const walltype *wal, const spritetype *spr)
|
||||||
|
{
|
||||||
|
return klabs(wal->x - spr->x) + klabs(wal->y - spr->y);
|
||||||
|
}
|
||||||
|
|
||||||
void A_RadiusDamage(int32_t i, int32_t r, int32_t hp1, int32_t hp2, int32_t hp3, int32_t hp4)
|
void A_RadiusDamage(int32_t i, int32_t r, int32_t hp1, int32_t hp2, int32_t hp3, int32_t hp4)
|
||||||
{
|
{
|
||||||
int32_t d, q, stati;
|
int32_t d, q, stati;
|
||||||
|
@ -143,19 +149,13 @@ void A_RadiusDamage(int32_t i, int32_t r, int32_t hp1, int32_t hp2, int32_t hp3,
|
||||||
{
|
{
|
||||||
const int32_t w2 = wall[startwall].point2;
|
const int32_t w2 = wall[startwall].point2;
|
||||||
|
|
||||||
d = klabs(wall[startwall].x-s->x)+klabs(wall[startwall].y-s->y);
|
if (G_WallSpriteDist(&wall[startwall], s) < r ||
|
||||||
if (d < r)
|
G_WallSpriteDist(&wall[wall[w2].point2], s) < r)
|
||||||
Sect_DamageCeiling(dasect);
|
Sect_DamageCeiling(dasect);
|
||||||
else
|
|
||||||
{
|
|
||||||
d = klabs(wall[wall[w2].point2].x-s->x)+klabs(wall[wall[w2].point2].y-s->y);
|
|
||||||
if (d < r)
|
|
||||||
Sect_DamageCeiling(dasect);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (w=startwall,wal=&wall[startwall]; w<endwall; w++,wal++)
|
for (w=startwall,wal=&wall[startwall]; w<endwall; w++,wal++)
|
||||||
if ((klabs(wal->x-s->x)+klabs(wal->y-s->y)) < r)
|
if (G_WallSpriteDist(wal, s) < r)
|
||||||
{
|
{
|
||||||
int16_t sect = -1;
|
int16_t sect = -1;
|
||||||
const int32_t nextsect = wal->nextsector;
|
const int32_t nextsect = wal->nextsector;
|
||||||
|
@ -2650,7 +2650,23 @@ static void Proj_BounceOffWall(spritetype *s, int32_t j)
|
||||||
s->ang = ((k<<1) - s->ang)&2047;
|
s->ang = ((k<<1) - s->ang)&2047;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PROJ_DECAYVELOCITY s->xvel >>= 1, s->zvel >>= 1
|
#define PROJ_DECAYVELOCITY(s) s->xvel >>= 1, s->zvel >>= 1
|
||||||
|
|
||||||
|
// Maybe damage a ceiling or floor as the consequence of projectile impact.
|
||||||
|
// Returns 1 if sprite <s> should be killed.
|
||||||
|
// NOTE: Compare with Proj_MaybeDamageCF2() in sector.c
|
||||||
|
static int32_t Proj_MaybeDamageCF(const spritetype *s)
|
||||||
|
{
|
||||||
|
if (s->zvel < 0)
|
||||||
|
{
|
||||||
|
if ((sector[s->sectnum].ceilingstat&1) && sector[s->sectnum].ceilingpal == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
Sect_DamageCeiling(s->sectnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ACTOR_STATIC void Proj_MoveCustom(int32_t i)
|
ACTOR_STATIC void Proj_MoveCustom(int32_t i)
|
||||||
{
|
{
|
||||||
|
@ -2804,7 +2820,7 @@ ACTOR_STATIC void Proj_MoveCustom(int32_t i)
|
||||||
A_PlaySound(proj->bsound, i);
|
A_PlaySound(proj->bsound, i);
|
||||||
|
|
||||||
if (proj->workslike & PROJECTILE_LOSESVELOCITY)
|
if (proj->workslike & PROJECTILE_LOSESVELOCITY)
|
||||||
PROJ_DECAYVELOCITY;
|
PROJ_DECAYVELOCITY(s);
|
||||||
|
|
||||||
if (!(proj->workslike & PROJECTILE_FORCEIMPACT))
|
if (!(proj->workslike & PROJECTILE_FORCEIMPACT))
|
||||||
return;
|
return;
|
||||||
|
@ -2868,7 +2884,7 @@ ACTOR_STATIC void Proj_MoveCustom(int32_t i)
|
||||||
A_PlaySound(proj->bsound, i);
|
A_PlaySound(proj->bsound, i);
|
||||||
|
|
||||||
if (proj->workslike & PROJECTILE_LOSESVELOCITY)
|
if (proj->workslike & PROJECTILE_LOSESVELOCITY)
|
||||||
PROJ_DECAYVELOCITY;
|
PROJ_DECAYVELOCITY(s);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2878,17 +2894,12 @@ ACTOR_STATIC void Proj_MoveCustom(int32_t i)
|
||||||
case 16384:
|
case 16384:
|
||||||
setsprite(i, &davect);
|
setsprite(i, &davect);
|
||||||
|
|
||||||
if (s->zvel < 0)
|
if (Proj_MaybeDamageCF(s))
|
||||||
{
|
|
||||||
if (sector[s->sectnum].ceilingstat&1 && sector[s->sectnum].ceilingpal == 0)
|
|
||||||
{
|
{
|
||||||
A_DeleteSprite(i);
|
A_DeleteSprite(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sect_DamageCeiling(s->sectnum);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (proj->workslike & PROJECTILE_BOUNCESOFFWALLS)
|
if (proj->workslike & PROJECTILE_BOUNCESOFFWALLS)
|
||||||
{
|
{
|
||||||
A_DoProjectileBounce(i);
|
A_DoProjectileBounce(i);
|
||||||
|
@ -2900,7 +2911,7 @@ ACTOR_STATIC void Proj_MoveCustom(int32_t i)
|
||||||
A_PlaySound(proj->bsound, i);
|
A_PlaySound(proj->bsound, i);
|
||||||
|
|
||||||
if (proj->workslike & PROJECTILE_LOSESVELOCITY)
|
if (proj->workslike & PROJECTILE_LOSESVELOCITY)
|
||||||
PROJ_DECAYVELOCITY;
|
PROJ_DECAYVELOCITY(s);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3132,15 +3143,9 @@ ACTOR_STATIC void G_MoveWeapons(void)
|
||||||
case 16384:
|
case 16384:
|
||||||
setsprite(i, &davect);
|
setsprite(i, &davect);
|
||||||
|
|
||||||
if (s->zvel < 0)
|
if (Proj_MaybeDamageCF(s))
|
||||||
{
|
|
||||||
if (sector[s->sectnum].ceilingstat&1)
|
|
||||||
if (sector[s->sectnum].ceilingpal == 0)
|
|
||||||
KILLIT(i);
|
KILLIT(i);
|
||||||
|
|
||||||
Sect_DamageCeiling(s->sectnum);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->picnum == FREEZEBLAST)
|
if (s->picnum == FREEZEBLAST)
|
||||||
{
|
{
|
||||||
A_DoProjectileBounce(i);
|
A_DoProjectileBounce(i);
|
||||||
|
|
|
@ -1850,7 +1850,6 @@ function _setgamepalette(pli, basepal)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Map state persistence.
|
-- Map state persistence.
|
||||||
-- TODO: saving/restoration of per-player or per-actor gamevars.
|
|
||||||
function _savemapstate()
|
function _savemapstate()
|
||||||
ffiC.G_SaveMapState()
|
ffiC.G_SaveMapState()
|
||||||
end
|
end
|
||||||
|
|
|
@ -684,7 +684,7 @@ local FADE_SPEED = {
|
||||||
5,
|
5,
|
||||||
127, -- freezer; such a fast fade is not visible, but it clears any
|
127, -- freezer; such a fast fade is not visible, but it clears any
|
||||||
-- existing one (if of higher priority)
|
-- existing one (if of higher priority)
|
||||||
[WEAPON.GROW] = 9.9, -- test banker's rouding -- should be like 10
|
[WEAPON.GROW] = 9.9, -- test banker's rounding -- should be like 10
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Test player[]:fadecol(), a better palfrom.
|
-- Test player[]:fadecol(), a better palfrom.
|
||||||
|
@ -711,7 +711,7 @@ gameevent
|
||||||
|
|
||||||
function(aci, pli)
|
function(aci, pli)
|
||||||
local ps = player[pli]
|
local ps = player[pli]
|
||||||
-- WARNING: This function uses INTERNAL interfaces.
|
-- WARNING: _pals in INTERNAL and off-limits to users!
|
||||||
local curf = ps._pals.f
|
local curf = ps._pals.f
|
||||||
if (curf > last_f) then
|
if (curf > last_f) then
|
||||||
-- Starting a tint
|
-- Starting a tint
|
||||||
|
|
|
@ -599,6 +599,24 @@ static void HandleHitWall(hitdata_t *hit)
|
||||||
hit->wall = hitwal->nextwall;
|
hit->wall = hitwal->nextwall;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Maybe damage a ceiling or floor as the consequence of projectile impact.
|
||||||
|
// Returns 1 if projectile hit a parallaxed ceiling.
|
||||||
|
// NOTE: Compare with Proj_MaybeDamageCF() in actors.c
|
||||||
|
static int32_t Proj_MaybeDamageCF2(int32_t zvel, int32_t hitsect)
|
||||||
|
{
|
||||||
|
if (zvel < 0)
|
||||||
|
{
|
||||||
|
Bassert(hitsect >= 0);
|
||||||
|
|
||||||
|
if (sector[hitsect].ceilingstat&1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
Sect_DamageCeiling(hitsect);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Finish shooting hitscan weapon from player <p>. <k> is the inserted SHOTSPARK1.
|
// Finish shooting hitscan weapon from player <p>. <k> is the inserted SHOTSPARK1.
|
||||||
// * <spawnatimpacttile> is passed to Proj_MaybeSpawn()
|
// * <spawnatimpacttile> is passed to Proj_MaybeSpawn()
|
||||||
// * <decaltile> and <damagewalltile> are for wall impact
|
// * <decaltile> and <damagewalltile> are for wall impact
|
||||||
|
@ -614,17 +632,12 @@ static int32_t P_PostFireHitscan(int32_t p, int32_t k, hitdata_t *hit, int32_t i
|
||||||
{
|
{
|
||||||
if (hit->wall == -1 && hit->sprite == -1)
|
if (hit->wall == -1 && hit->sprite == -1)
|
||||||
{
|
{
|
||||||
if (zvel < 0)
|
if (Proj_MaybeDamageCF2(zvel, hit->sect))
|
||||||
{
|
|
||||||
if (sector[hit->sect].ceilingstat&1)
|
|
||||||
{
|
{
|
||||||
sprite[k].xrepeat = 0;
|
sprite[k].xrepeat = 0;
|
||||||
sprite[k].yrepeat = 0;
|
sprite[k].yrepeat = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Sect_DamageCeiling(hit->sect);
|
|
||||||
}
|
|
||||||
|
|
||||||
Proj_MaybeSpawn(k, spawnatimpacttile, hit);
|
Proj_MaybeSpawn(k, spawnatimpacttile, hit);
|
||||||
}
|
}
|
||||||
|
@ -1272,8 +1285,7 @@ int32_t A_ShootWithZvel(int32_t i, int32_t atwith, int32_t override_zvel)
|
||||||
|
|
||||||
if (hit.wall == -1 && hit.sprite == -1 && hit.sect >= 0)
|
if (hit.wall == -1 && hit.sprite == -1 && hit.sect >= 0)
|
||||||
{
|
{
|
||||||
if (zvel < 0 && (sector[hit.sect].ceilingstat&1) == 0)
|
Proj_MaybeDamageCF2(zvel, hit.sect);
|
||||||
Sect_DamageCeiling(hit.sect);
|
|
||||||
}
|
}
|
||||||
else if (hit.sprite >= 0) A_DamageObject(hit.sprite,j);
|
else if (hit.sprite >= 0) A_DamageObject(hit.sprite,j);
|
||||||
else if (hit.wall >= 0 && wall[hit.wall].picnum != ACCESSSWITCH && wall[hit.wall].picnum != ACCESSSWITCH2)
|
else if (hit.wall >= 0 && wall[hit.wall].picnum != ACCESSSWITCH && wall[hit.wall].picnum != ACCESSSWITCH2)
|
||||||
|
|
Loading…
Reference in a new issue