From 20c5459ab3b0764e47e24b1b7e61a2c0f0743f98 Mon Sep 17 00:00:00 2001 From: thmsn <9084377+thmsndk@users.noreply.github.com> Date: Tue, 4 Jun 2024 22:42:52 +0200 Subject: [PATCH] exclude certain monsters from invasion --- design/maps.py | 12 +++++++++++- node/server_functions.js | 26 ++++++++++++++++---------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/design/maps.py b/design/maps.py index 1de3a5e7..63937785 100644 --- a/design/maps.py +++ b/design/maps.py @@ -740,7 +740,17 @@ # TODO: what types of invasions are enabled? # TODO: any specific monsters on the map that should not be part of an invasion? # disable fairies - # "disable":["crabxx"], + "exclude":[ + "crabxx", + "puppy1", + "puppy2", + "puppy3", + "puppy4", + "kitty1", + "kitty2", + "kitty3", + "kitty4", + ], # TODO: combined invasion of different mobs? # TODO: failure conditions? # TODO: "nearby" monster invasions, moles for example emergin from tunnels diff --git a/node/server_functions.js b/node/server_functions.js index b6ddfdcb..f91efd3c 100644 --- a/node/server_functions.js +++ b/node/server_functions.js @@ -2537,15 +2537,21 @@ function event_loop_invasion(c) { // start new event, make sure next event starts in the future timers[invasionMapKey] = future_s(INVASION_COOLDOWN); // TODO: random cooldown in a range - // TODO: check extra for additional monsters, like moles - // TODO: spawning crabx might mess with the crabxx event, some monsters should probably be filtered out - const monster_map_def = clone(random_one(Object.values(gMap.monsters))); + // TODO: spawning crabx might mess with the crabxx event, + // some monsters should probably be filtered out, spawning crabxx seems like a bad idea + const exclude = gMap.invasion.exclude; + const potentialInvaders = Object.values(gMap.monsters).filter((x) => !exclude || !exclude.includes(x.type)); + + // TODO: check/add extra for additional monsters, like moles + // TODO: do we pick a random monster? or should we prefer high level spawns? + // TODO: roll for success + // TODO: each 5 levels increases chance to spawn? + // TODO: chance to start invasion + + const monster_map_def = clone(random_one(potentialInvaders)); monster_map_def.grow = false; console.log(monster_map_def); - // TODO: each 5 levels increases chance to spawn - // TODO: chance to start invasion - // E is broadcasted to the players E[invasionMapKey] = event = { etype: "invasion", @@ -2580,6 +2586,7 @@ function event_loop_invasion(c) { broadcast_e(); } + // Bail out, no active event. if (!event) { continue; } @@ -2628,7 +2635,7 @@ function event_loop_invasion(c) { // if monster has a master, if it stops pursuit (no redirect) you get the hp or max 300 points to the master // if you are the burner, burn dmg gives you points // console.log("success", instance.invasion.points); - const numBins = 10; + const numBins = 5; const bins = groupObjectsIntoBins(instance.invasion.points, numBins); console.log("success", bins); @@ -2662,7 +2669,6 @@ function event_loop_invasion(c) { } // TODO: if you where farming here you might be overwhelmed, make event visible and wait N before starting spawning. - // TODO: move calculation to event initialization const { spawnAmount } = instance.invasion.stages[event.stage] || {}; if (event.stage === 0 && instance.invasion.monster_count === spawnAmount) { @@ -2683,7 +2689,7 @@ function event_loop_invasion(c) { ? { x: gMap.invasion.town[0], y: gMap.invasion.town[1] } : { x: gMap.spawns[0][0], y: gMap.spawns[0][1] }; // not sure if a target is required - // TODO: make all invaders move towards town + // TODO: monster movement should be extracted out to a function for (const monster of aliveInvasionMonsters) { const distanceToTargetPoint = distance(targetPoint, monster); @@ -2744,7 +2750,7 @@ function event_loop_invasion(c) { } } -// TODO: remove this to an invasion event specific file. +// TODO: move this to an invasion event specific file. function invasion_remove_monster(monster) { if (!monster.invasion) { return;