|
|
|
@ -4685,51 +4685,43 @@ void RedoPlayerVision() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MonstCheckDoors(Monster &monster) |
|
|
|
void MonstCheckDoors(const Monster &monster) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int mx = monster.position.tile.x; |
|
|
|
for (Direction dir : { Direction::NorthEast, Direction::SouthWest, Direction::North, Direction::East, Direction::South, Direction::West, Direction::NorthWest, Direction::SouthEast }) { |
|
|
|
int my = monster.position.tile.y; |
|
|
|
Object *object = ObjectAtPosition(monster.position.tile + dir); |
|
|
|
if (dObject[mx - 1][my - 1] != 0 |
|
|
|
if (object == nullptr) |
|
|
|
|| dObject[mx][my - 1] != 0 |
|
|
|
continue; |
|
|
|
|| dObject[mx + 1][my - 1] != 0 |
|
|
|
|
|
|
|
|| dObject[mx - 1][my] != 0 |
|
|
|
Object &door = *object; |
|
|
|
|| dObject[mx + 1][my] != 0 |
|
|
|
// Doors use _oVar4 to track open/closed state, non-zero values indicate an open door
|
|
|
|
|| dObject[mx - 1][my + 1] != 0 |
|
|
|
// we don't use Object::isDoor since the later conditions will check the object is actually a door anyway.
|
|
|
|
|| dObject[mx][my + 1] != 0 |
|
|
|
if (door._oVar4 != 0) |
|
|
|
|| dObject[mx + 1][my + 1] != 0) { |
|
|
|
continue; |
|
|
|
for (int i = 0; i < ActiveObjectCount; i++) { |
|
|
|
|
|
|
|
Object &object = Objects[ActiveObjects[i]]; |
|
|
|
// Strictly speaking these checks shouldn't be required, they're guarding against monsters
|
|
|
|
if ((object._otype == OBJ_L1LDOOR || object._otype == OBJ_L1RDOOR) && object._oVar4 == 0) { |
|
|
|
// standing in a wall opening an adjacent door. Shouldn't be possible?
|
|
|
|
int dpx = abs(object.position.x - mx); |
|
|
|
if (IsNoneOf(dir, Direction::NorthEast, Direction::SouthWest)) { |
|
|
|
int dpy = abs(object.position.y - my); |
|
|
|
if (door._otype == OBJ_L1LDOOR) { |
|
|
|
if (dpx == 1 && dpy <= 1 && object._otype == OBJ_L1LDOOR) |
|
|
|
OperateL1LDoor(door, true); |
|
|
|
OperateL1LDoor(object, true); |
|
|
|
} else if (door._otype == OBJ_L2LDOOR) { |
|
|
|
if (dpx <= 1 && dpy == 1 && object._otype == OBJ_L1RDOOR) |
|
|
|
OperateL2LDoor(door, true); |
|
|
|
OperateL1RDoor(object, true); |
|
|
|
} else if (door._otype == OBJ_L3RDOOR) { |
|
|
|
} |
|
|
|
// L3 doors are backwards, see OperateL3Door
|
|
|
|
if ((object._otype == OBJ_L2LDOOR || object._otype == OBJ_L2RDOOR) && object._oVar4 == 0) { |
|
|
|
OperateL3RDoor(door, true); |
|
|
|
int dpx = abs(object.position.x - mx); |
|
|
|
} else if (door._otype == OBJ_L5LDOOR) { |
|
|
|
int dpy = abs(object.position.y - my); |
|
|
|
OperateL5LDoor(door, true); |
|
|
|
if (dpx == 1 && dpy <= 1 && object._otype == OBJ_L2LDOOR) |
|
|
|
|
|
|
|
OperateL2LDoor(object, true); |
|
|
|
|
|
|
|
if (dpx <= 1 && dpy == 1 && object._otype == OBJ_L2RDOOR) |
|
|
|
|
|
|
|
OperateL2RDoor(object, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ((object._otype == OBJ_L3LDOOR || object._otype == OBJ_L3RDOOR) && object._oVar4 == 0) { |
|
|
|
|
|
|
|
int dpx = abs(object.position.x - mx); |
|
|
|
|
|
|
|
int dpy = abs(object.position.y - my); |
|
|
|
|
|
|
|
if (dpx == 1 && dpy <= 1 && object._otype == OBJ_L3RDOOR) |
|
|
|
|
|
|
|
OperateL3RDoor(object, true); |
|
|
|
|
|
|
|
if (dpx <= 1 && dpy == 1 && object._otype == OBJ_L3LDOOR) |
|
|
|
|
|
|
|
OperateL3LDoor(object, true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if ((object._otype == OBJ_L5LDOOR || object._otype == OBJ_L5RDOOR) && object._oVar4 == 0) { |
|
|
|
} |
|
|
|
int dpx = abs(object.position.x - mx); |
|
|
|
if (IsNoneOf(dir, Direction::NorthWest, Direction::SouthEast)) { |
|
|
|
int dpy = abs(object.position.y - my); |
|
|
|
if (door._otype == OBJ_L1RDOOR) { |
|
|
|
if (dpx == 1 && dpy <= 1 && object._otype == OBJ_L5LDOOR) |
|
|
|
OperateL1RDoor(door, true); |
|
|
|
OperateL5LDoor(object, true); |
|
|
|
} else if (door._otype == OBJ_L2RDOOR) { |
|
|
|
if (dpx <= 1 && dpy == 1 && object._otype == OBJ_L5RDOOR) |
|
|
|
OperateL2RDoor(door, true); |
|
|
|
OperateL5RDoor(object, true); |
|
|
|
} else if (door._otype == OBJ_L3LDOOR) { |
|
|
|
|
|
|
|
// L3 doors are backwards, see OperateL3Door
|
|
|
|
|
|
|
|
OperateL3LDoor(door, true); |
|
|
|
|
|
|
|
} else if (door._otype == OBJ_L5RDOOR) { |
|
|
|
|
|
|
|
OperateL5RDoor(door, true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|