Add FogOfWar plugin

This commit is contained in:
Thomas Smyth 2021-04-07 16:48:00 +01:00
parent 29fc06e045
commit fa31300c28
4 changed files with 73 additions and 0 deletions

View File

@ -733,6 +733,23 @@ Grafana:
<pre><code>false</code></pre></li></ul>
</details>
<details>
<summary>FogOfWar</summary>
<h2>FogOfWar</h2>
<p>The <code>FogOfWar</code> plugin can be used to automate setting fog of war mode.</p>
<h3>Options</h3>
<ul><li><h4>mode</h4>
<h6>Description</h6>
<p>Fog of war mode to set.</p>
<h6>Default</h6>
<pre><code>1</code></pre></li>
<li><h4>delay</h4>
<h6>Description</h6>
<p>Delay before setting fog of war mode.</p>
<h6>Default</h6>
<pre><code>10000</code></pre></li></ul>
</details>
<details>
<summary>IntervalledBroadcasts</summary>
<h2>IntervalledBroadcasts</h2>

View File

@ -174,6 +174,12 @@
"color": 16761867,
"disableSCBL": false
},
{
"plugin": "FogOfWar",
"enabled": false,
"mode": 1,
"delay": 10000
},
{
"plugin": "IntervalledBroadcasts",
"enabled": false,

View File

@ -0,0 +1,46 @@
import BasePlugin from './base-plugin.js';
export default class FogOfWar extends BasePlugin {
static get description() {
return 'The <code>FogOfWar</code> plugin can be used to automate setting fog of war mode.';
}
static get defaultEnabled() {
return false;
}
static get optionsSpecification() {
return {
mode: {
required: false,
description: 'Fog of war mode to set.',
default: 1
},
delay: {
required: false,
description: 'Delay before setting fog of war mode.',
default: 10 * 1000
}
};
}
constructor(server, options, connectors) {
super(server, options, connectors);
this.onNewGame = this.onNewGame.bind(this);
}
async mount() {
this.server.on('NEW_GAME', this.onNewGame);
}
async unmount() {
this.server.removeEventListener('NEW_GAME', this.onNewGame);
}
async onNewGame() {
setTimeout(() => {
this.server.rcon.setFogOfWar(this.options.mode);
}, this.options.delay);
}
}

View File

@ -173,6 +173,10 @@ export default class SquadRcon extends Rcon {
await this.execute(`AdminBroadcast ${message}`);
}
async setFogOfWar(mode) {
await this.execute(`AdminSetFogOfWar ${mode}`);
}
async warn(steamID, message) {
await this.execute(`AdminWarn "${steamID}" ${message}`);
}