- icecubes, damageactor.

This commit is contained in:
Christoph Oelckers 2021-11-21 12:20:41 +01:00
parent 46b45b6a4d
commit bb736286c3

View file

@ -1495,39 +1495,42 @@ void trailingsmoke(int i, boolean ball) {
void icecubes(int i, int x, int y, int z, int owner) { void icecubes(int i, int x, int y, int z, int owner) {
int j = insertsprite(sprite[i].sectnum, FX); int j = insertsprite(sprite[i].sectnum, FX);
auto& spawned = sprite[j];
sprite[j].x = x; spawned.x = x;
sprite[j].y = y; spawned.y = y;
sprite[j].z = sector[sprite[i].sectnum].floorz - (getPlayerHeight() << 8) + (krand() & 4096); spawned.z = sector[sprite[i].sectnum].floorz - (getPlayerHeight() << 8) + (krand() & 4096);
sprite[j].cstat = 0; // Hitscan does not hit smoke on wall spawned.cstat = 0; // Hitscan does not hit smoke on wall
sprite[j].picnum = ICECUBE; spawned.picnum = ICECUBE;
sprite[j].shade = -16; spawned.shade = -16;
sprite[j].xrepeat = 16; spawned.xrepeat = 16;
sprite[j].yrepeat = 16; spawned.yrepeat = 16;
sprite[j].ang = (short) (((krand() & 1023) - 1024) & 2047); spawned.ang = (short) (((krand() & 1023) - 1024) & 2047);
sprite[j].xvel = (short) ((krand() & 1023) - 512); spawned.xvel = (short) ((krand() & 1023) - 512);
sprite[j].yvel = (short) ((krand() & 1023) - 512); spawned.yvel = (short) ((krand() & 1023) - 512);
sprite[j].zvel = (short) ((krand() & 1023) - 512); spawned.zvel = (short) ((krand() & 1023) - 512);
sprite[j].pal = 6; spawned.pal = 6;
sprite[j].owner = sprite[i].owner; spawned.owner = sprite[i].owner;
if(isWh2()) if(isWh2())
sprite[j].lotag = 2048; spawned.lotag = 2048;
else sprite[j].lotag = 999; else spawned.lotag = 999;
sprite[j].hitag = 0; spawned.hitag = 0;
} }
boolean damageactor(PLAYER& plr, int hitobject, short i) { boolean damageactor(PLAYER& plr, int hitobject, short const i) {
short j = (short) (hitobject & 4095); // j is the spritenum that the bullet (spritenum i) hit short const j = (short) (hitobject & 4095); // j is the spritenum that the bullet (spritenum i) hit
if (j == plr.spritenum && sprite[i].owner == sprite[plr.spritenum].owner) auto& spr = sprite[i];
auto& hitspr = sprite[j];
if (j == plr.spritenum && spr.owner == sprite[plr.spritenum].owner)
return false; return false;
if (j == plr.spritenum && sprite[i].owner != sprite[plr.spritenum].owner) { if (j == plr.spritenum && spr.owner != sprite[plr.spritenum].owner) {
if (plr.invincibletime > 0 || plr.godMode) { if (plr.invincibletime > 0 || plr.godMode) {
deletesprite(i); deletesprite(i);
return false; return false;
@ -1535,7 +1538,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
// EG 17 Oct 2017: Mass backport of RULES.CFG behavior for resist/onyx ring // EG 17 Oct 2017: Mass backport of RULES.CFG behavior for resist/onyx ring
// EG 21 Aug 2017: New RULES.CFG behavior in place of the old #ifdef // EG 21 Aug 2017: New RULES.CFG behavior in place of the old #ifdef
if (plr.manatime > 0) { if (plr.manatime > 0) {
if (/* eg_resist_blocks_traps && */sprite[i].picnum != FATSPANK && sprite[i].picnum != PLASMA) { if (/* eg_resist_blocks_traps && */spr.picnum != FATSPANK && spr.picnum != PLASMA) {
deletesprite(i); deletesprite(i);
return false; return false;
} }
@ -1543,16 +1546,16 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
// for animation // for animation
// FATSPANK is right in the middle of this group of tiles, so still keep an // FATSPANK is right in the middle of this group of tiles, so still keep an
// exception for it. // exception for it.
else if ((sprite[i].picnum >= EXPLOSION && sprite[i].picnum <= (MONSTERBALL + 2) else if ((spr.picnum >= EXPLOSION && spr.picnum <= (MONSTERBALL + 2)
&& sprite[i].picnum != FATSPANK)) { && spr.picnum != FATSPANK)) {
deletesprite(i); deletesprite(i);
return false; return false;
} }
} }
// EG 21 Aug 2017: onyx ring // EG 21 Aug 2017: onyx ring
else if (plr.treasure[TONYXRING] == 1 /*&& eg_onyx_effect != 0*/ else if (plr.treasure[TONYXRING] == 1 /*&& eg_onyx_effect != 0*/
&& ((sprite[i].picnum < EXPLOSION || sprite[i].picnum > MONSTERBALL + 2) && ((spr.picnum < EXPLOSION || spr.picnum > MONSTERBALL + 2)
&& sprite[i].picnum != PLASMA)) { && spr.picnum != PLASMA)) {
// if (eg_onyx_effect == 1 || (eg_onyx_effect == 2 && ((krand() & 32) > 16))) { // if (eg_onyx_effect == 1 || (eg_onyx_effect == 2 && ((krand() & 32) > 16))) {
deletesprite(i); deletesprite(i);
@ -1562,9 +1565,9 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
// EG 21 Aug 2017: Move this here so as not to make ouch sounds unless pain is // EG 21 Aug 2017: Move this here so as not to make ouch sounds unless pain is
// happening // happening
if ((krand() & 9) == 0) if ((krand() & 9) == 0)
spritesound(S_PLRPAIN1 + (rand() % 2), &sprite[i]); spritesound(S_PLRPAIN1 + (rand() % 2), &spr);
if (isWh2() && sprite[i].picnum == DART) { if (isWh2() && spr.picnum == DART) {
plr.poisoned = 1; plr.poisoned = 1;
plr.poisontime = 7200; plr.poisontime = 7200;
showmessage("Poisoned", 360); showmessage("Poisoned", 360);
@ -1573,9 +1576,9 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
if (netgame) { if (netgame) {
// netdamageactor(j,i); // netdamageactor(j,i);
} else { } else {
if (sprite[i].picnum == PLASMA) if (spr.picnum == PLASMA)
addhealth(plr, -((krand() & 15) + 15)); addhealth(plr, -((krand() & 15) + 15));
else if (sprite[i].picnum == FATSPANK) { else if (spr.picnum == FATSPANK) {
spritesound(S_GORE1A + (krand() % 3), &sprite[plr.spritenum]); spritesound(S_GORE1A + (krand() % 3), &sprite[plr.spritenum]);
addhealth(plr, -((krand() & 10) + 10)); addhealth(plr, -((krand() & 10) + 10));
if ((krand() % 100) > 90) { if ((krand() % 100) > 90) {
@ -1583,7 +1586,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
plr.poisontime = 7200; plr.poisontime = 7200;
showmessage("Poisoned", 360); showmessage("Poisoned", 360);
} }
} else if (sprite[i].picnum == THROWPIKE) { } else if (spr.picnum == THROWPIKE) {
addhealth(plr, -((krand() % 10) + 5)); addhealth(plr, -((krand() % 10) + 5));
} else } else
addhealth(plr, -((krand() & 20) + 5)); addhealth(plr, -((krand() & 20) + 5));
@ -1596,7 +1599,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
} }
if (j != plr.spritenum && !netgame) // Les 08/11/95 if (j != plr.spritenum && !netgame) // Les 08/11/95
if (sprite[i].owner != j) { if (spr.owner != j) {
// final int DEMONTYPE = 1; XXX // final int DEMONTYPE = 1; XXX
// final int DRAGONTYPE = 3; // final int DRAGONTYPE = 3;
@ -1605,7 +1608,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
// final int RATTYPE = 18; // final int RATTYPE = 18;
// final int SKULLYTYPE = 20; // final int SKULLYTYPE = 20;
switch (sprite[j].detail) { switch (hitspr.detail) {
case NEWGUYTYPE: case NEWGUYTYPE:
case KURTTYPE: case KURTTYPE:
case GONZOTYPE: case GONZOTYPE:
@ -1622,40 +1625,40 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
case FATWITCHTYPE: case FATWITCHTYPE:
case WILLOWTYPE: case WILLOWTYPE:
case GUARDIANTYPE: case GUARDIANTYPE:
if(isBlades(sprite[i].picnum)) { if(isBlades(spr.picnum)) {
sprite[j].hitag -= 30; hitspr.hitag -= 30;
if(sprite[i].picnum == THROWPIKE) { if(spr.picnum == THROWPIKE) {
if ((krand() % 2) != 0) if ((krand() % 2) != 0)
spritesound(S_GORE1A + krand() % 2, &sprite[i]); spritesound(S_GORE1A + krand() % 2, &spr);
} }
} else { } else {
switch (sprite[i].picnum) { switch (spr.picnum) {
case PLASMA: case PLASMA:
sprite[j].hitag -= 40; hitspr.hitag -= 40;
break; break;
case FATSPANK: case FATSPANK:
sprite[j].hitag -= 10; hitspr.hitag -= 10;
break; break;
case MONSTERBALL: case MONSTERBALL:
sprite[j].hitag -= 40; hitspr.hitag -= 40;
break; break;
case FIREBALL: case FIREBALL:
if(!isWh2()) if(!isWh2())
sprite[j].hitag -= 3; hitspr.hitag -= 3;
break; break;
case BULLET: case BULLET:
sprite[j].hitag -= 10; hitspr.hitag -= 10;
break; break;
case DISTORTIONBLAST: case DISTORTIONBLAST:
sprite[j].hitag = 10; hitspr.hitag = 10;
break; break;
case BARREL: case BARREL:
sprite[j].hitag -= 100; hitspr.hitag -= 100;
break; break;
} }
} }
if (sprite[j].hitag <= 0) { if (hitspr.hitag <= 0) {
newstatus(j, DIE); newstatus(j, DIE);
deletesprite(i); deletesprite(i);
} else } else
@ -1663,7 +1666,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
return true; return true;
} }
switch(sprite[j].detail) { switch(hitspr.detail) {
case GONZOTYPE: case GONZOTYPE:
case NEWGUYTYPE: case NEWGUYTYPE:
case KATIETYPE: case KATIETYPE:
@ -1678,9 +1681,9 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
case IMPTYPE: case IMPTYPE:
// JSA_NEW //why is this here it's in whplr // JSA_NEW //why is this here it's in whplr
// raf because monsters could shatter a guy thats been frozen // raf because monsters could shatter a guy thats been frozen
if (sprite[j].pal == 6) { if (hitspr.pal == 6) {
for (int k = 0; k < 32; k++) for (int k = 0; k < 32; k++)
icecubes(j, sprite[j].x, sprite[j].y, sprite[j].z, j); icecubes(j, hitspr.x, hitspr.y, hitspr.z, j);
// EG 26 Oct 2017: Move this here from medusa (anti multi-freeze exploit) // EG 26 Oct 2017: Move this here from medusa (anti multi-freeze exploit)
addscore(&plr, 100); addscore(&plr, 100);
deletesprite(j); deletesprite(j);
@ -1688,7 +1691,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
return true; return true;
} }
switch (sprite[j].picnum) { switch (hitspr.picnum) {
case BARREL: case BARREL:
case VASEA: case VASEA:
case VASEB: case VASEB:
@ -1702,8 +1705,8 @@ boolean damageactor(PLAYER& plr, int hitobject, short i) {
case STAINGLASS7: case STAINGLASS7:
case STAINGLASS8: case STAINGLASS8:
case STAINGLASS9: case STAINGLASS9:
sprite[j].hitag = 0; hitspr.hitag = 0;
sprite[j].lotag = 0; hitspr.lotag = 0;
newstatus(j, BROKENVASE); newstatus(j, BROKENVASE);
break; break;
default: default: