mirror of
https://github.com/AsgardEternal/SquadJS.git
synced 2024-09-28 11:54:23 -05:00
Add FogOfWar plugin
This commit is contained in:
parent
29fc06e045
commit
fa31300c28
17
README.md
17
README.md
@ -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>
|
||||
|
@ -174,6 +174,12 @@
|
||||
"color": 16761867,
|
||||
"disableSCBL": false
|
||||
},
|
||||
{
|
||||
"plugin": "FogOfWar",
|
||||
"enabled": false,
|
||||
"mode": 1,
|
||||
"delay": 10000
|
||||
},
|
||||
{
|
||||
"plugin": "IntervalledBroadcasts",
|
||||
"enabled": false,
|
||||
|
46
squad-server/plugins/fog-of-war.js
Normal file
46
squad-server/plugins/fog-of-war.js
Normal 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);
|
||||
}
|
||||
}
|
@ -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}`);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user