Skip to content

Loose mined gold can be picked up from neutral/unclaimed land #511

Description

@belgianguy

Description

OpenKeeper allows the player to pick up loose gold that an Imp leaves on neutral/unclaimed land.

I compared this with the original Dungeon Keeper 2. In the original game, this gold cannot be picked up with the Hand of Evil until the tile has been claimed.

In the original game, the Hand also cannot drop held gold or other objects onto neutral land. Therefore, manual dropping is not part of this reproduction. The gold reaches neutral land through the Imp mining workflow when available gold storage is full.

Steps to reproduce

  1. Start campaign Level 1.
  2. Fill the Dungeon Heart's gold storage capacity (16,000 gold), without building additional Treasury capacity.
  3. Have an Imp continue digging gold from terrain bordering neutral/unclaimed floor.
  4. Once the Imp cannot carry or store more gold, observe loose gold being left where it was mined, potentially on neutral land.
  5. Try to pick up that loose gold with the Hand of Evil.

Expected behavior

The loose gold cannot be picked up while its tile is neutral/unclaimed.

After an Imp claims the tile, the gold becomes pickable.

This matches the original Dungeon Keeper 2.

Actual behavior

OpenKeeper allows the loose gold to be picked up directly from neutral/unclaimed land.

Technical findings

How the gold reaches neutral land

Mining calls CreatureController.addGold(...). When the Imp cannot carry the full amount, the excess is turned into loose gold at the Imp's current coordinates.

This is distinct from dropping gold with the Hand.

OpenKeeper's drop-validation code appears intended to enforce the own-land rule when an object's CAN_BE_DROPPED_ON_ANY_LAND flag is absent. The Level 1 data for both gold objects does not contain that flag. However, manual dropping in OpenKeeper was not tested as part of this reproduction.

Pickup validation

EntityViewControl.isPickable(...) checks the entity's Interaction.pickUppable flag, but not the underlying tile.

GameWorldController.canPickUpEntity(...) checks entity ownership and interaction flags, but not tile ownership. It contains the following TODO:

// TODO: Was it so that it can be only picked up from own land?
return interaction.pickUppable && !isEntityIncapacitated(entityId, entityData);

The mined gold is created with the Imp's owner ID. Consequently, the Owner.controlId check succeeds even when the gold is physically located on neutral terrain.

Suggested fix

For loose-gold object entities, pickup should additionally require the underlying tile to be owned by the requesting player.

The rule must be enforced server-side. The client should apply the same validation so gold on neutral or enemy land is not highlighted as pickable.

The restriction should be specific to loose gold, or implemented through object-specific pickup rules. A blanket own-land restriction could unintentionally change creature and other object pickup behavior.

Suggested tests

  • Loose gold on neutral land is not pickable.
  • The same gold becomes pickable after the tile is claimed.
  • Loose gold on enemy-owned land is not pickable.
  • Loose gold on the player's land remains pickable.
  • Dropping held entities on neutral land follows the DK2 own-land rule.
  • Creature pickup behavior is unchanged.
  • A direct network pickup request cannot bypass the tile-ownership rule.

Relevant locations

  • src/main/java/toniarts/openkeeper/game/controller/creature/CreatureController.java
  • src/main/java/toniarts/openkeeper/game/controller/GameWorldController.java
  • src/main/java/toniarts/openkeeper/view/control/EntityViewControl.java
  • src/main/java/toniarts/openkeeper/game/controller/ObjectsController.java

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions