Skip to content

Regression-Games/rg-ctf-utils

Repository files navigation

rg-ctf-utils

NPM

A collection of utilities for use in the Regression Games Capture the Flag game mode.

Classes

CTFEvent

A set of event names that are emitted by the RGCTFUtils class, which can be registered on an RGBot.

RGCTFUtils

Members

CTFEvent

A collection of utilities for the Capture the Flag game mode. Includes location of points of interest, simplified functions for gathering and scoring the flag, and utilities for finding both teammates and enemies.

When using this class, it will register a set of listeners on RGBot, which helps with reacting to CTF game mode events. See the examples within the CTFEvent documentation for more information.


CTFEvent

A set of event names that are emitted by the RGCTFUtils class, which can be registered on an RGBot.


RGCTFUtils


new RGCTFUtils(bot)

Creates a new instance of the CTF utilities, attached to an RGBot

Param Type Description
bot RGBot

The bot to use when calling these utilities

Example

const rgctfUtils = new RGCTFUtils(bot);


rgctfUtils.setDebug(debug)

Sets the debug state of this plugin - true if you want to see debug statements, false otherwise

Param Type Description
debug boolean

Whether or not to print debug statements


rgctfUtils.getFlagLocation() ⇒ Vec3 | null

Gets the location of either the neutral flag OR a team's flag on the ground.

Returns: Vec3 | null -

The location of either the neutral flag OR a team's flag on the ground.


Example

const flagLocation = ctfutils.getFlagLocation();
if (flagLocation) await bot.approachPosition(flagLocation);


rgctfUtils.approachFlag() ⇒ Promise.<boolean>

Commands the bot to move toward the current flag location, if the flag exists. This will not follow the flag, but will simply move the bot to the location of the flag when this command is called.

Returns: Promise.<boolean> -

true if the bot reached the location, false otherwise


See{getflaglocation}:
Example

await bot.approachFlag();


rgctfUtils.scoreFlag() ⇒ Promise.<boolean>

Commands the bot to score the flag in your team's base.

Returns: Promise.<boolean> -

true if the bot reached the scoring zone, and false otherwise


Example

if (rgctfUtils.hasFlag()) {
    await rgctfUtils.scoreFlag();
}


rgctfUtils.hasFlag() ⇒ boolean

Returns true if this bot has the flag, and false otherwise.

Returns: boolean -

true if the bot has the flag, false otherwise


Example

if (rgctfUtils.hasFlag()) {
    await rgctfUtils.scoreFlag();
}


CTFEvent

A collection of utilities for the Capture the Flag game mode. Includes location of points of interest, simplified functions for gathering and scoring the flag, and utilities for finding both teammates and enemies.

When using this class, it will register a set of listeners on RGBot, which helps with reacting to CTF game mode events. See the examples within the CTFEvent documentation for more information.

© 2023 Regression Games, Inc.

About

Utilities for the Regression Games Capture the Flag game mode.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •