🐛 Fix Phasing teleporting to invalid locations
Phasing could end up attempting to teleport to hunreds of random location and still fail to find a valid target and send the player in to a wall or outside the map. This is fixed by first finding all valid locations within range and then picking one of them at random. Valid targets is a 13x13 area around the player minus the inner 7x7 In total there can be no more then 120 valid tiles and on average there should be 75 avalible.
This commit is contained in:
parent
1d50db0246
commit
4fd2e2dc97
2 changed files with 34 additions and 48 deletions
|
|
@ -3049,22 +3049,7 @@ bool OperateShrineHoly(int pnum)
|
|||
if (deltaload)
|
||||
return false;
|
||||
|
||||
auto &player = Players[pnum];
|
||||
|
||||
int j = 0;
|
||||
int xx;
|
||||
int yy;
|
||||
uint32_t lv;
|
||||
do {
|
||||
xx = GenerateRnd(MAXDUNX);
|
||||
yy = GenerateRnd(MAXDUNY);
|
||||
lv = dPiece[xx][yy];
|
||||
j++;
|
||||
if (j > MAXDUNX * MAXDUNY)
|
||||
break;
|
||||
} while (nSolidTable[lv] || dObject[xx][yy] != 0 || dMonster[xx][yy] != 0);
|
||||
|
||||
AddMissile(player.position.tile, { xx, yy }, player._pdir, MIS_RNDTELEPORT, TARGET_PLAYERS, pnum, 0, 2 * leveltype);
|
||||
AddMissile(Players[pnum].position.tile, { 0, 0 }, DIR_S, MIS_RNDTELEPORT, TARGET_PLAYERS, pnum, 0, 2 * leveltype);
|
||||
|
||||
if (pnum != MyPlayerId)
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue