improved Shadow slaing: SWORD, SWORD_INTO and CRUSH now clear the Shadow history (previously SWORD killed it for 1 turn)

This commit is contained in:
Zeno Rogue 2021-06-03 10:48:32 +02:00
parent dd3f5a3d6b
commit 41f8f7fba3
2 changed files with 17 additions and 4 deletions

View File

@ -153,7 +153,7 @@ EX bool canAttack(cell *c1, eMonster m1, cell *c2, eMonster m2, flagtype flags)
if(c1 && c2 && againstRose(c1, c2) && !ignoresSmell(m1))
return false;
if(m2 == moShadow && !(flags & AF_SWORD)) return false;
if(m2 == moShadow && !(flags & (AF_SWORD | AF_SWORD_INTO | AF_CRUSH))) return false;
if(isWorm(m2) && m2 != moTentacleGhost && !isDragon(m2)) return false;
// dragon can't attack itself, or player who mounted it
@ -457,7 +457,8 @@ EX void killMonster(cell *c, eMonster who, flagtype deathflags IS(0)) {
bool fallanim = (deathflags & AF_FALL) && m != moMimic;
int pcount = fallanim ? 0 : 16;
if(m == moShadow) return;
if(m == moShadow)
kill_shadow_at(c);
#if CAP_HISTORY
if(!isBug(m) && !isAnyIvy(m)) {

View File

@ -1443,6 +1443,14 @@ EX void clearshadow() {
shpos[i][p] = NULL;
}
/** \brief kill the shadow by clearing its history -- c is provided for multiplayer */
EX void kill_shadow_at(cell *c) {
for(int p=0; p<MAXPLAYER; p++)
if(shpos[cshpos][p] == c)
for(int i=0; i<SHSIZE; i++)
changes.value_set(shpos[i][p], (cell*) nullptr);
}
EX void moveshadow() {
cell *shfrom = NULL;
@ -1462,8 +1470,12 @@ EX void moveshadow() {
cshpos = (cshpos+1) % SHSIZE;
for(int p: player_indices()) {
cell* where = shpos[cshpos][p];
if(where && where->monst == moNone && where->cpdist && among(where->land, laGraveyard, laCursed) &&
!sword::at(where)) {
if(sword::at(where)) {
kill_shadow_at(where);
fightmessage(moShadow, moPlayer, false, AF_SWORD_INTO);
continue;
}
if(where && where->monst == moNone && where->cpdist && among(where->land, laGraveyard, laCursed)) {
if(shfrom) animateMovement(match(shfrom, where), LAYER_SMALL);
where->monst = moShadow;
where->hitpoints = p;