Mirror Imp death replaces staircases

https://attnam.com/topics/Mirror-Imp-death-replaces-staircases

The Cathedral of Attnam > Trouble Shooting and Bugs

#1 Feb 11, 9:08 am Hide

Dark-Star2018

I have found a bug in vanilla 0.59, a very nasty one that deletes staircases!

If a mirror imp croaks exactly on the stairs it replaces the tile with the crystal they leave and an engraving describing the staircase.
#2 Feb 11, 9:16 am Hide

Dark-Star2018

And in related news, i need a level editor to fix my savegame 8-(
#3 Feb 11, 9:55 am Hide

red_kangaroo

Oops! Added here: https://github.com/Attnam/ivan/issues/664

If you turn on wizard mode, you can level-teleport. Or if you haven't played much/saved, maybe if you force-close your game and load a quicksave, you will be back before that happened.
#4 Feb 11, 9:02 pm Hide

vasiliy

the easiest fix, btw, is this:
void mirrorimp::CreateCorpse (lsquare *Square) {
  // do not replace any interesting terrain
  if (!Square->GetOLTerrain()) {
    decoration *Shard = decoration::Spawn(SHARD);
    Shard->InitMaterials(MAKE_MATERIAL(GLASS));
    Square->ChangeOLTerrainAndUpdateLights(Shard);
  }
  SendToHell();
}
#5 Feb 12, 3:34 am Hide

red_kangaroo

Yeah, I will open a PR with this fix.
#6 Feb 12, 5:37 am Hide

vasiliy

maybe we can create a new item instead, "crystalshard", or something. currently, crystals are "digged" to stones, but imp may explode into much smaller "crystal shards". or even special kind of fluid, so it cannot be picked up, but can emit light, and can be spilled around — because small crystal shards are very close to "fluids", actually.

maybe i'll try to experiment with this later.
#7 Feb 12, 6:32 am Hide

red_kangaroo

The intention here was that the imp explodes and then freezes mid explosion, creating a weird statue of crystal.
#8 Feb 12, 3:25 pm Hide

vasiliy

ah. then maybe crystal statue as an item then? that is, so it can freely spawn above special terrain. we can check and don't spawn statue if there is another one already, to not make light emitation too bright.

of course, the bugfix works too, but with it, no crystals could be spawned above an open door, for example, or sofa, or fountain, or any other decoration. it is safe this way, but slightly less interesting, i think.

it is possible to change the code a little, and prevent spawning only over "important" olterra too, i actually implemented this fix first. maybe it is better than a new item, dunno…

p.s.: it is easy — just add `IsImprotant()` method to olterra, and make it return `true` for stairs. and check it in `ChangeOLTerrainAndUpdateLights()` (and don't forget to `delete` new terrain if update failed).