Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup for weapon explosions #7573

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions Source/missiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1973,8 +1973,14 @@ void AddMissileExplosion(Missile &missile, AddMissileParameter &parameter)

void AddWeaponExplosion(Missile &missile, AddMissileParameter &parameter)
{
missile.var2 = parameter.dst.x;
if (parameter.dst.x == 1)
bool isFireExplosion = parameter.dst.x == 1;

if (missile._midam > 0) {
DamageType damageType = isFireExplosion ? DamageType::Fire : DamageType::Lightning;
CheckMissileCol(missile, damageType, missile._midam, missile._midam, false, missile.position.tile, true);
}

if (isFireExplosion)
SetMissAnim(missile, MissileGraphicID::MagmaBallExplosion);
else
SetMissAnim(missile, MissileGraphicID::ChargedBolt);
Expand Down Expand Up @@ -3510,21 +3516,6 @@ void ProcessWeaponExplosion(Missile &missile)

missile.duration--;
const Player &player = Players[missile._misource];
int mind;
int maxd;
DamageType damageType;
if (missile.var2 == 1) {
// BUGFIX: damage of missile should be encoded in missile struct; player can be dead/have left the game before missile arrives.
mind = player._pIFMinDam;
maxd = player._pIFMaxDam;
damageType = DamageType::Fire;
} else {
// BUGFIX: damage of missile should be encoded in missile struct; player can be dead/have left the game before missile arrives.
mind = player._pILMinDam;
maxd = player._pILMaxDam;
damageType = DamageType::Lightning;
}
CheckMissileCol(missile, damageType, mind, maxd, false, missile.position.tile, false);
if (missile.var1 == 0) {
missile._mlid = AddLight(missile.position.tile, 9);
} else {
Expand Down
21 changes: 12 additions & 9 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,15 +779,6 @@ bool DoAttack(Player &player)
}
}

if (!gbIsHellfire || !HasAllOf(player._pIFlags, ItemSpecialEffect::FireDamage | ItemSpecialEffect::LightningDamage)) {
if (HasAnyOf(player._pIFlags, ItemSpecialEffect::FireDamage)) {
AddMissile(position, { 1, 0 }, Direction::South, MissileID::WeaponExplosion, TARGET_MONSTERS, player, 0, 0);
}
if (HasAnyOf(player._pIFlags, ItemSpecialEffect::LightningDamage)) {
AddMissile(position, { 2, 0 }, Direction::South, MissileID::WeaponExplosion, TARGET_MONSTERS, player, 0, 0);
}
}

if (monster != nullptr) {
didhit = PlrHitMonst(player, *monster);
} else if (PlayerAtPosition(position) != nullptr && !player.friendlyMode) {
Expand All @@ -798,6 +789,18 @@ bool DoAttack(Player &player)
didhit = PlrHitObj(player, *object);
}
}

if (!gbIsHellfire || !HasAllOf(player._pIFlags, ItemSpecialEffect::FireDamage | ItemSpecialEffect::LightningDamage)) {
if (HasAnyOf(player._pIFlags, ItemSpecialEffect::FireDamage)) {
int elementalDamage = didhit ? RandomIntBetween(player._pIFMinDam, player._pIFMaxDam) : 0;
AddMissile(position, { 1, 0 }, Direction::South, MissileID::WeaponExplosion, TARGET_MONSTERS, player, elementalDamage, 0);
}
if (HasAnyOf(player._pIFlags, ItemSpecialEffect::LightningDamage)) {
int elementalDamage = didhit ? RandomIntBetween(player._pILMinDam, player._pILMaxDam) : 0;
AddMissile(position, { 2, 0 }, Direction::South, MissileID::WeaponExplosion, TARGET_MONSTERS, player, elementalDamage, 0);
}
}

if (player.CanCleave()) {
// playing as a class/weapon with cleave
position = player.position.tile + Right(player._pdir);
Expand Down
Loading