Skip to content

Commit

Permalink
Chain Lightning crawl
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Mar 7, 2024
1 parent 1c3f64a commit 89f1a48
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Source/missiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3528,13 +3528,25 @@ void ProcessChainLightning(Missile &missile)
Point position = missile.position.tile;
Point dst { missile.var1, missile.var2 };
Direction dir = GetDirection(position, dst);

AddMissile(position, dst, dir, MissileID::LightningControl, TARGET_MONSTERS, id, 1, missile._mispllvl);

int rad = std::min<int>(missile._mispllvl + 3, MaxCrawlRadius);

Crawl(1, rad, [&](Displacement displacement) {
Point target = position + displacement;
if (InDungeonBounds(target) && dMonster[target.x][target.y] > 0) {
dir = GetDirection(position, target);
AddMissile(position, target, dir, MissileID::LightningControl, TARGET_MONSTERS, id, 1, missile._mispllvl);
const auto &monsterId = dMonster[target.x][target.y];

if (InDungeonBounds(target) && monsterId > 0) {
const auto &player = Players[id];
const auto &monster = Monsters[std::abs(monsterId - 1)];

// Should we also be checking isPossibleToHit() and isImmune()?
if (!monster.belongsToPlayer(player) && !(monster.isPlayerMinion() && sgGameInitInfo.bFriendlyFire == 0 && player.friendlyMode)) {
dir = GetDirection(position, target);
AddMissile(position, target, dir, MissileID::LightningControl, TARGET_MONSTERS, id, 1, missile._mispllvl);
}

}
return false;
});
Expand Down

0 comments on commit 89f1a48

Please sign in to comment.