1 /**********************************************************************************
2 * Copyright (c) 2008, 2009 Derek Yu and Mossmouth, LLC
3 * Copyright (c) 2010, Moloch
4 * Copyright (c) 2018, Ketmar Dark
6 * This file is part of Spelunky.
8 * You can redistribute and/or modify Spelunky, including its source code, under
9 * the terms of the Spelunky User License.
11 * Spelunky is distributed in the hope that it will be entertaining and useful,
12 * but WITHOUT WARRANTY. Please see the Spelunky User License for more details.
14 * The Spelunky User License should be available in "Game Information", which
15 * can be found in the Resource Explorer, or as an external file called COPYING.
16 * If not, please obtain a new copy of Spelunky from <http://spelunkyworld.com/>
18 **********************************************************************************/
19 class MapTileSacAltarBase : MapTile;
24 // spriteName should be already set
25 override void setupTile () {
30 sacrificingAltar = true;
34 // deactivate neighbour altars
35 final void deactivateAltarAt (int px, int py) {
37 auto t = MapTileSacAltarBase(level.checkTilesInRect(px-16, py-16, 16*3, 16*3, delegate bool (MapTile t) {
38 auto alt = MapTileSacAltarBase(t);
39 if (alt && alt.doPunish && alt.isInstanceAlive) return true;
43 writeln("deactivating altar at (", t.ix/16, ",", t.iy/16, "); starter is at (", ix/16, ",", iy/16, ")");
45 deactivateAltarAt(t.ix, t.iy);
53 override bool smashMe () {
54 if (invincible) return false;
58 checkSmashedVineSupport();
63 // find and remove the other side of the altar
64 auto a2 = level.isCollisionAtPoint(ix+18, iy+8, &level.cbCollisionSacAltar);
65 if (a2) a2.instanceRemove();
66 a2 = level.isCollisionAtPoint(ix-8, iy+8, &level.cbCollisionSacAltar);
67 if (a2) a2.instanceRemove();
69 if (smashed) scrSprayRubble(ix, iy, 3);
70 scrDropRubble(ix, iy, 3);
75 ++level.stats.totalDestroyedKaliAltars;
76 level.osdMessage("YOU DARE DEFILE MY ALTAR?\nI WILL PUNISH YOU!", 6.66);
79 // deactivate neighbour altars
80 deactivateAltarAt(ix, iy);
84 if (global.kaliPunish == 0) {
85 //!with (oKaliHead) alarm[0] = 1;
87 level.forEachTile(delegate bool (MapTile t) {
88 auto th = MapTileKaliHead(t);
90 writeln("found Kali head!");
91 th.angryAlarmCounter = 1; // on the next step
94 }, castClass:MapTileKaliHead);
95 } else if (global.kaliPunish == 1) {
97 level.player.spawnBallAndChain();
99 // summon spiders or ghost
100 if (global.darkLevel && level.ghostSpawned) {
101 //with (oKaliHead) alarm[0] = 1;
102 level.forEachTile(delegate bool (MapTile t) {
103 auto th = MapTileKaliHead(t);
105 writeln("found Kali head!");
106 th.angryAlarmCounter = 1; // on the next step
109 }, castClass:MapTileKaliHead);
111 global.darkLevel = true;
112 if (!level.ghostSpawned) level.spawnGhost();
115 global.kaliPunish += 1;
126 // ////////////////////////////////////////////////////////////////////////// //
127 class MapTileSacAltarLeft['oSacAltarLeft'] : MapTileSacAltarBase;
130 spriteName = 'sSacAltarLeft';
134 // ////////////////////////////////////////////////////////////////////////// //
135 class MapTileSacAltarRight['oSacAltarRight'] : MapTileSacAltarBase;
138 spriteName = 'sSacAltarRight';