Search in sources :

Example 1 with GuidePage

use of com.shatteredpixel.shatteredpixeldungeon.items.journal.GuidePage in project shattered-pixel-dungeon-gdx by 00-Evan.

the class RegularLevel method createItems.

@Override
protected void createItems() {
    // drops 3/4/5 items 60%/30%/10% of the time
    int nItems = 3 + Random.chances(new float[] { 6, 3, 1 });
    for (int i = 0; i < nItems; i++) {
        Heap.Type type = null;
        switch(Random.Int(20)) {
            case 0:
                type = Heap.Type.SKELETON;
                break;
            case 1:
            case 2:
            case 3:
            case 4:
                type = Heap.Type.CHEST;
                break;
            case 5:
                type = Dungeon.depth > 1 ? Heap.Type.MIMIC : Heap.Type.CHEST;
                break;
            default:
                type = Heap.Type.HEAP;
        }
        int cell = randomDropCell();
        if (map[cell] == Terrain.HIGH_GRASS) {
            map[cell] = Terrain.GRASS;
            losBlocking[cell] = false;
        }
        Item toDrop = Generator.random();
        if (toDrop == null)
            continue;
        if ((toDrop instanceof Artifact && Random.Int(2) == 0) || (toDrop.isUpgradable() && Random.Int(4 - toDrop.level()) == 0)) {
            Heap dropped = drop(toDrop, cell);
            if (heaps.get(cell) == dropped) {
                dropped.type = Heap.Type.LOCKED_CHEST;
                addItemToSpawn(new GoldenKey(Dungeon.depth));
            }
        } else {
            drop(toDrop, cell).type = type;
        }
    }
    for (Item item : itemsToSpawn) {
        int cell = randomDropCell();
        drop(item, cell).type = Heap.Type.HEAP;
        if (map[cell] == Terrain.HIGH_GRASS) {
            map[cell] = Terrain.GRASS;
            losBlocking[cell] = false;
        }
    }
    Item item = Bones.get();
    if (item != null) {
        int cell = randomDropCell();
        if (map[cell] == Terrain.HIGH_GRASS) {
            map[cell] = Terrain.GRASS;
            losBlocking[cell] = false;
        }
        drop(item, cell).type = Heap.Type.REMAINS;
    }
    // guide pages
    Collection<String> allPages = Document.ADVENTURERS_GUIDE.pages();
    ArrayList<String> missingPages = new ArrayList<>();
    for (String page : allPages) {
        if (!Document.ADVENTURERS_GUIDE.hasPage(page)) {
            missingPages.add(page);
        }
    }
    // these are dropped specially
    missingPages.remove(Document.GUIDE_INTRO_PAGE);
    missingPages.remove(Document.GUIDE_SEARCH_PAGE);
    int foundPages = allPages.size() - (missingPages.size() + 2);
    // chance to find a page scales with pages missing and depth
    if (missingPages.size() > 0 && Random.Float() < (Dungeon.depth / (float) (foundPages + 1))) {
        GuidePage p = new GuidePage();
        p.page(missingPages.get(0));
        int cell = randomDropCell();
        if (map[cell] == Terrain.HIGH_GRASS) {
            map[cell] = Terrain.GRASS;
            losBlocking[cell] = false;
        }
        drop(p, cell);
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) GoldenKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey) GuidePage(com.shatteredpixel.shatteredpixeldungeon.items.journal.GuidePage) ArrayList(java.util.ArrayList) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap) Artifact(com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact)

Example 2 with GuidePage

use of com.shatteredpixel.shatteredpixeldungeon.items.journal.GuidePage in project shattered-pixel-dungeon-gdx by 00-Evan.

the class EntranceRoom method paint.

public void paint(Level level) {
    Painter.fill(level, this, Terrain.WALL);
    Painter.fill(level, this, 1, Terrain.EMPTY);
    for (Room.Door door : connected.values()) {
        door.set(Room.Door.Type.REGULAR);
    }
    do {
        level.entrance = level.pointToCell(random(2));
    } while (level.findMob(level.entrance) != null);
    Painter.set(level, level.entrance, Terrain.ENTRANCE);
    if (Dungeon.depth == 1 && !Document.ADVENTURERS_GUIDE.hasPage(Document.GUIDE_INTRO_PAGE)) {
        int pos;
        do {
            // can't be on bottom row of tiles
            pos = level.pointToCell(new Point(Random.IntRange(left + 1, right - 1), Random.IntRange(top + 1, bottom - 2)));
        } while (pos == level.entrance || level.findMob(level.entrance) != null);
        GuidePage p = new GuidePage();
        p.page(Document.GUIDE_INTRO_PAGE);
        level.drop(p, pos);
    }
    if (Dungeon.depth == 2) {
        if (!Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_1)) {
            for (Room.Door door : connected.values()) {
                door.set(Door.Type.HIDDEN);
            }
        }
        if (!Document.ADVENTURERS_GUIDE.hasPage(Document.GUIDE_SEARCH_PAGE)) {
            int pos;
            do {
                // can't be on bottom row of tiles
                pos = level.pointToCell(new Point(Random.IntRange(left + 1, right - 1), Random.IntRange(top + 1, bottom - 2)));
            } while (pos == level.entrance || level.findMob(level.entrance) != null);
            GuidePage p = new GuidePage();
            p.page(Document.GUIDE_SEARCH_PAGE);
            level.drop(p, pos);
        }
    }
}
Also used : GuidePage(com.shatteredpixel.shatteredpixeldungeon.items.journal.GuidePage) Point(com.watabou.utils.Point) Room(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room) Point(com.watabou.utils.Point)

Aggregations

GuidePage (com.shatteredpixel.shatteredpixeldungeon.items.journal.GuidePage)2 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)1 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)1 Artifact (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact)1 GoldenKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey)1 Room (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room)1 Point (com.watabou.utils.Point)1 ArrayList (java.util.ArrayList)1