SocksTheWolf / L4D2Bridge

Allows outside sources to influence and modify a L4D2 server based on user-defined rules using data from events via external sources
https://wolf.stream
MIT License
0 stars 0 forks source link
avalonia avaloniaui l4d2 l4d2-coop-plugins l4d2-server left4dead2 rcon sourcemod sourcemod-plugin sourcemod-plugins srcds-rcon tiltify twitch twitchlib twitchtv

L4D2 Bridge

This is an application and service layer to a L4D2 server, that allows for external events to influence an active server live.

Main Window

Features

Console Functionality

Anything typed in the text box will be sent directly to the server via RCON, with the following exceptions:

Influence Service Sources

Setup

Configuration

All configuration data is stored in a flat file called config.json. Upon first time running the application, a blank config.json file will be created for you. For the most part, these settings are fairly straight forward to fill out. The rest of the sections are explained below.

Actions

The actions section is a dictionary with key names that correspond to the RuleName or SuccessEvent of a matching rule definition (see Rules section), and the string array of server commands that should be ran when rules with the given keyname matches.

Acceptable server actions are:

    SpawnTank,
    SpawnSpitter,
    SpawnJockey,
    SpawnWitch,
    SpawnMob,
    SpawnMobSmall,
    SpawnMobMedium,
    SpawnMobLarge,
    SpawnBoomer,
    SpawnHunter,
    SpawnCharger,
    SpawnSmoker,
    Lootbox,
    SupplyCrate,
    HealAllPlayersSmall,
    HealAllPlayersLarge,
    HealAllPlayersRand,
    RespawnAllPlayers,
    UppiesPlayers,
    RandomPositive,
    RandomNegative,
    RandomSpecialInfected,
    Random

The Random server action does a coin flip and if heads, will run a RandomPositive action, if tails, a RandomNegative action will execute instead.

Example

Here is an example of some actions that are defined in a config file. Names such as "chaos" and "santa" are used in the rules.json later.

  "Actions": {
    "chaos": [
      "SpawnMobLarge",
      "RandomSpecialInfected",
      "SpawnCharger"
    ],
    "tank": [
      "SpawnTank"
    ],
    "lootbox": [
      "Lootbox"
    ],
    "santa": [
      "Lootbox",
      "Lootbox",
      "SupplyCrate"
    ]
  },

Mob Sizes

These are the ranges for each type of mob spawn size in the server commands list. The Rand setting is when the mob size is not provided (using SpawnMob).

Negative Weights

These are the weights for each of the negative-based Actions with their weightings from 1-100 on how often they should appear. These are used to calculate what affect is used when a rule with the action RandomNegative is executed. If a negative action is not specified, it will not be randomly chosen when RandomNegative is executed. This field is also used to determine RandomSepcialInfected roll spawn chances.


Rules

rules.json is an MS RulesEngine formatted file.

The following important notes are:

Source Event Types

Rules can check their input object types against these values to determine actions. These are the types that are supported:

    Donation,
    Subscription,
    Resubscription,
    GiftSubscription,
    MultiGiftSubscription,
    Raid,
    ChatCommand

Source Event Data

All input objects are data objects that contain the following fields that can be checked against:

Rules Extensions

The rules can take advantage of some added extensions to the processor to do string based checks. A class named REUtils is provided to the RulesEngine to help you with string processing.

Example

[
  {
    "WorkflowName": "tiltify",
    "Rules": [
      {
        "RuleName": "tank",
        "RuleExpressionType": "LambdaExpression",
        "Expression": "input1.Type == EventType.Donation AND input1.Amount >= 5.00"
      },
      {
        "RuleName": "santa",
        "SuccessEvent": "nothing",
        "RuleExpressionType": "LambdaExpression",
        "Expression": "input1.Type == EventType.Donation AND REutils.CheckContains(input1.Message, \"help,santa,save\") == true AND input1.Amount > 1.00"
      },
      {
        "RuleName": "EveryCoolAndAwesomeRuleName",
        "SuccessEvent": "lootbox",
        "RuleExpressionType": "LambdaExpression",
        "Expression": "input1.Type == EventType.Donation"
      }
    ]
  }
]

Server Dependencies

In addition to the modifications made in the L4D2Mods directory, the following additional plugins are needed.