User Tools

Site Tools


mr:chests

Chests - Code References

Java Classes

Java Class Content

// Heap.java - Chest type definitions
public enum Type {
    // ...
    CHEST,
    LOCKED_CHEST,
    CRYSTAL_CHEST,
    // ...
}
 
// Heap.java - Chest spawn weights
static {
    regularHeaps.put(Type.CHEST, 4f);
    sageHeaps.put(Type.CHEST, 4f);
}
 
// OpenChest.java - Chest opening logic
public class OpenChest extends CharAction {
    public OpenChest(int dst) {
        // ...
        if (heap != null && (heap.type == Heap.Type.CHEST
            || heap.type == Heap.Type.TOMB
            || heap.type == Heap.Type.SKELETON
            || heap.type == Heap.Type.LOCKED_CHEST
            || heap.type == Heap.Type.CRYSTAL_CHEST
            || heap.type == Heap.Type.MIMIC)) {
            // Handle chest opening
            if (heap.type == Heap.Type.LOCKED_CHEST
                || heap.type == Heap.Type.CRYSTAL_CHEST) {
                // Requires key
                if (!hasKey) {
                    GLog.w(StringsManager.getVar(R.string.Hero_LockedChest));
                }
            }
        }
    }
}

Key Properties from Code

  • Chest Types:
    1. `CHEST` - Regular chest, can be opened freely
    2. `LOCKED_CHEST` - Requires skeleton key to open
    3. `CRYSTAL_CHEST` - Requires crystal key to open
    4. `MIMIC` - May appear instead of CHEST (hostile monster)
  • Spawn Weights: CHEST has weight of 4f in regular and sage heap distributions
  • Key Requirement: LOCKED_CHEST and CRYSTAL_CHEST require corresponding keys
  • Mimic Chance: Some chest spawns may be replaced by Mimics

JSON Configuration

  • Level configurations that may include treasure: levelsDesc/
  • Chest contents are generated dynamically by the Generator class

String Resources

<!-- English strings -->
<string name="Hero_LockedChest">This chest is locked and you don't have a key</string>
<string name="WndInfoItem_Chest">Chest</string>
<string name="WndInfoItem_CrystalChest">Crystal chest</string>
<string name="WndInfoItem_LockedChest">Locked chest</string>

Lua Scripts

This entity is implemented in Java, no Lua script exists

Sprite References

  • Chest Level Objects:
    1. Chest 1
    2. Chest 2
    3. Chest 3
mr/chests.txt · Last modified: by 127.0.0.1