Don't treat spikes as solid for non-humanoid entities

There's always been a bit of an inconsistency in the game where enabling
invincibility would make spikes so solid that enemies and moving
platforms would treat spikes as solid and bounces off of them.

This fixes that by adding an `invincible` parameter to collision
functions, so the functions will only treat spikes as solid if that
parameter is true, and the parameter passed will only be true if it's
called for an entity that is a humanoid and invincibility mode is
enabled.

Also, for clarity, `spikecollide` is renamed to `towerspikecollide`
because it's only used for tower spikes. And as a small optimization,
`checktowerspikes` returns early if invincibility mode is enabled.
This commit is contained in:
Misa
2022-06-05 20:17:26 -07:00
parent cc61194bed
commit f0aa1a8cae
4 changed files with 59 additions and 47 deletions

View File

@@ -672,19 +672,18 @@ void mapclass::settowercolour(int t)
updatebgobj(graphics.titlebg);
}
bool mapclass::spikecollide(int x, int y)
bool mapclass::towerspikecollide(int x, int y)
{
if (invincibility) return false;
if (tower.at(x,y,0)>= 6 && tower.at(x,y,0) <= 11) return true;
return false;
}
bool mapclass::collide(int x, int y)
bool mapclass::collide(int x, int y, const bool invincible)
{
if (towermode)
{
if (tower.at(x, y, 0) >= 12 && tower.at(x, y, 0) <= 27) return true;
if (invincibility)
if (invincible)
{
if (tower.at(x, y, 0) >= 6 && tower.at(x, y, 0) <= 11) return true;
}
@@ -692,14 +691,14 @@ bool mapclass::collide(int x, int y)
else if (tileset == 2)
{
int tile;
if (y == -1) return collide(x, y + 1);
if (y == 29+extrarow) return collide(x, y - 1);
if (x == -1) return collide(x + 1, y);
if (x == 40) return collide(x - 1, y);
if (y == -1) return collide(x, y + 1, invincible);
if (y == 29+extrarow) return collide(x, y - 1, invincible);
if (x == -1) return collide(x + 1, y, invincible);
if (x == 40) return collide(x - 1, y, invincible);
if (x < 0 || y < 0 || x >= 40 || y >= 29 + extrarow) return false;
tile = contents[TILE_IDX(x, y)];
if (tile >= 12 && tile <= 27) return true;
if (invincibility)
if (invincible)
{
if (tile >= 6 && tile <= 11) return true;
}
@@ -707,17 +706,17 @@ bool mapclass::collide(int x, int y)
else
{
int tile;
if (y == -1) return collide(x, y + 1);
if (y == 29+extrarow) return collide(x, y - 1);
if (x == -1) return collide(x + 1, y);
if (x == 40) return collide(x - 1, y);
if (y == -1) return collide(x, y + 1, invincible);
if (y == 29+extrarow) return collide(x, y - 1, invincible);
if (x == -1) return collide(x + 1, y, invincible);
if (x == 40) return collide(x - 1, y, invincible);
if (x < 0 || y < 0 || x >= 40 || y >= 29+extrarow) return false;
tile = contents[TILE_IDX(x, y)];
if (tile == 1) return true;
if (tileset==0 && tile == 59) return true;
if (tile>= 80 && tile < 680) return true;
if (tile == 740 && tileset==1) return true;
if (invincibility)
if (invincible)
{
if (tile>= 6 && tile <= 9) return true;
if (tile>= 49 && tile <= 50) return true;