Skip to content

Commit

Permalink
Restrict dropping items to adjacent tiles
Browse files Browse the repository at this point in the history
This more closely matches vanilla behaviour until more intelligent dropping item behaviour is implemented (see diasurgical#3489)
  • Loading branch information
ephphatha authored and AJenbo committed Dec 28, 2021
1 parent ae112c7 commit e633d7f
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions Source/inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,14 +1129,28 @@ bool PutItem(Player &player, Point &position)
if (CanPut(position))
return true;

std::optional<Point> itemPosition = FindClosestValidPosition(CanPut, player.position.tile, 1, 50);
position = player.position.tile + Left(Left(d));
if (CanPut(position))
return true;

if (itemPosition) {
position = *itemPosition;
position = player.position.tile + Right(Right(d));
if (CanPut(position))
return true;
}

return false;
position = player.position.tile + Left(Left(Left(d)));
if (CanPut(position))
return true;

position = player.position.tile + Right(Right(Right(d)));
if (CanPut(position))
return true;

position = player.position.tile + Opposite(d);
if (CanPut(position))
return true;

position = player.position.tile;
return CanPut(position);
}

bool CanUseStaff(Item &staff, spell_id spell)
Expand Down

0 comments on commit e633d7f

Please sign in to comment.