mirror of
https://github.com/gooba42/adventureland.git
synced 2026-10-14 10:33:47 -05:00
Fix Overspawns
This commit is contained in:
+7
-9
@@ -12067,26 +12067,24 @@ function update_instance(instance) {
|
|||||||
const currentHpRatio = monster.hp / monster.max_hp;
|
const currentHpRatio = monster.hp / monster.max_hp;
|
||||||
const key = name + "_hp_" + threshold;
|
const key = name + "_hp_" + threshold;
|
||||||
|
|
||||||
if (currentHpRatio <= threshold && !monster.last[key]) { // trigger once per fight
|
if (currentHpRatio <= threshold && (monster.last[key] == undefined || monster.last[key] < count)) {
|
||||||
for (let i = 0; i < count; i++) {
|
|
||||||
const pname = random_one(Object.keys(monster.points));
|
const pname = random_one(Object.keys(monster.points));
|
||||||
const player = get_player(pname);
|
const player = get_player(pname);
|
||||||
if (!player || player.npc || distance(monster, player) > 400) return;
|
if (player && !player.npc && distance(monster, player) < 400) {
|
||||||
if (!is_same(player, get_player(monster.target), true)) return;
|
if (is_same(player, get_player(monster.target), true)) {
|
||||||
|
|
||||||
const spot = safe_xy_nearby(player.map, player.x + Math.random() * 20 - 10, player.y + Math.random() * 20 - 10);
|
const spot = safe_xy_nearby(player.map, player.x + Math.random() * 20 - 10, player.y + Math.random() * 20 - 10);
|
||||||
if (!spot) return;
|
if (spot) {
|
||||||
|
|
||||||
new_monster(instance.name, {
|
new_monster(instance.name, {
|
||||||
type: name,
|
type: name,
|
||||||
stype: "spawn",
|
stype: "spawn",
|
||||||
x: spot.x,
|
x: spot.x,
|
||||||
y: spot.y,
|
|
||||||
target: player.name,
|
target: player.name,
|
||||||
master: monster.id,
|
master: monster.id,
|
||||||
});
|
});
|
||||||
|
monster.last[key] = 1 + (monster.last[key] || 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
monster.last[key] = true; // mark this threshold as triggered
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user