Skip to content
Merged
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
5 changes: 3 additions & 2 deletions src/commands/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { FishEvents, fishPlugin, fishState, ipPortPattern, recentWhispers, tileH
import { FMap, PartialMapRun } from "/maps";
import { FishPlayer } from "/players";
import { Rank, RoleFlag } from "/ranks";
import { formatTime, formatTimeRelative, getColor, logAction, nearbyEnemyTile, neutralGameover, skipWaves, teleportPlayer } from "/utils";
import { formatTime, formatTimeRelative, getColor, logAction, nearbyEnemyTile, neutralGameover, skipWaves, teleportPlayer, vnwCondition } from "/utils";
import { VoteManager } from "/votes";

export const commands = commandList({
Expand Down Expand Up @@ -787,7 +787,8 @@ Please stop attacking and [lime]build defenses[] first!`
}),
requirements: [Req.cooldown(3000), Req.integerRange("waves", 1, 15), Req.mode("survival", "testsrv"), Req.gameRunning],
async handler({sender, args: {waves}, data:{manager}}){


if (!vnwCondition.check()) fail("You can only do that when all units from previous waves are dead.");
//Disable narrowing, this is async
if(!manager.session as boolean){
waves ??= await Menu.menu(
Expand Down
1 change: 1 addition & 0 deletions src/frameworks/commands/requirements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ export const Req = {
Req.integer(argName)({args}) &&
(args[argName] == undefined || args[argName] > 0
|| fail(`${argName} must be positive`)),

};
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { PartialMapRun } from "/maps";
import { loadPacketHandlers } from "/packetHandlers";
import { FishPlayer } from "/players";
import * as timers from "/timers";
import { addToTileHistory, fishCommandsRootDirPath, formatTimeRelative, matchFilter, processChat, restartNow, serverRestartLoop } from "/utils";
import { addToTileHistory, fishCommandsRootDirPath, formatTimeRelative, matchFilter, processChat, restartNow, serverRestartLoop, vnwCondition } from "/utils";

const { Menu } = menus;

Expand Down Expand Up @@ -326,6 +326,10 @@ Events.on(EventType.PlayEvent, () => {
fishState.startTime = Date.now();
});

Events.on(EventType.WaveEvent, () => {
if (Vars.state.rules.mode().name() === "survival") vnwCondition.onWaveStart();
});

Events.on(EventType.AdminRequestEvent, e => {
if(e.action == Packets.AdminAction.wave){
const fishP = FishPlayer.get(e.player);
Expand Down
13 changes: 13 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,19 @@
}
}

export const vnwCondition = {
waveUnits: [] as Unit[],
onWaveStart(){
let units = Groups.unit.copy(new Seq());

Check warning on line 481 in src/utils.ts

View workflow job for this annotation

GitHub Actions / PR_Tests

'units' is never reassigned. Use 'const' instead
let enemyTeam = getEnemyTeam();

Check warning on line 482 in src/utils.ts

View workflow job for this annotation

GitHub Actions / PR_Tests

'enemyTeam' is never reassigned. Use 'const' instead
this.waveUnits = units.select(u => u.team === enemyTeam).toArray();
},
check(){
if (this.waveUnits.some(u => !u.dead)) return false;
return true;
}
};


export function logHTrip(player:FishPlayer, name:string, message?:string){
Log.warn(`&yPlayer &b"${player.cleanedName}"&y (&b${player.uuid}&y/&b${player.ip()}&y) tripped &c${name}&y` + (message ? `: ${message}` : ""));
Expand Down
Loading