Skip to content

Commit

Permalink
Merge branch 'feature/invasion' into thmsn.adventureland.community
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsndk committed Nov 9, 2024
2 parents 87febd0 + 07bc5e0 commit 92ab0c5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions node/server_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2538,8 +2538,14 @@ function event_loop_invasion(c) {
const HOUR_MS = 3600000; // 60 * 60 * 1000;
// 6 * 3600000 = 21600000
// Default an invasion every 1..2 hours
const [MIN_INVASION_COOLDOWN_MS = 1 * HOUR_MS, MAX_INVASION_COOLDOWN_MS = 2 * HOUR_MS, INVASION_CHANCE = 0.75] =
gMap.invasion.frequency || [];
// const [MIN_INVASION_COOLDOWN_MS = 1 * HOUR_MS, MAX_INVASION_COOLDOWN_MS = 2 * HOUR_MS, INVASION_CHANCE = 0.75] =
// gMap.invasion.frequency || [];
// debug
const [
MIN_INVASION_COOLDOWN_MS = 1000 * 60 * 10 /* 10 minute */,
MAX_INVASION_COOLDOWN_MS = 1000 * 60 * 30 /* 30 minutes */,
INVASION_CHANCE = 0.75,
] = gMap.invasion.frequency || [];

const NEXT_INVASION_COOLDOWN_MS =
Math.random() * (MAX_INVASION_COOLDOWN_MS - MIN_INVASION_COOLDOWN_MS) + MIN_INVASION_COOLDOWN_MS;
Expand Down Expand Up @@ -2641,11 +2647,13 @@ function event_loop_invasion(c) {

const aliveInvasionMonsters = instance.invasion.monsters.filter((m) => !m.rip && !m.dead);
event.c = aliveInvasionMonsters.length;
console.log(`${invasionMapKey} ${event.c} alive monsters`);

if (event.end && c > event.end) {
// FAILURE: Time has run out

// remove remaining alive invasion monsters and also count up coop points
console.log(`${invasionMapKey} removing ${event.c} alive ${event.mtype} with nospawn: true`);
for (const monster of aliveInvasionMonsters) {
remove_monster(monster, { nospawn: true, method: "disappear" });
}
Expand Down

0 comments on commit 92ab0c5

Please sign in to comment.