ZockiRR / RustSirens

Gives players with permissions the ability to attach sirens to vehicles.
https://umod.org/plugins/sirens
MIT License
0 stars 0 forks source link

How It Works

The sirens will get attached to the vehicle or every configured module of the modular car the player looks at, if the siren supports that vehicle. What and at what position the entities will spawn is dependend on the configuration of each siren. When pressing the button inside the vehicle (or whereever the button is configured to be) the sirens will iterate through the states off, on and lights only. If sound is configured as disabled or a siren without tones was chosen, then the on state will be skipped. Sirens can also be attached and detached globally.

Commands

AttachSirens

This will attach the given siren (or the default) to the vehicle the player looks at. Already existing sirens will be overridden.

/attachsirens [optional:sirenname]
Example: /attachsirens police-germany

Syntax - Options

DetachSirens

This will remove the siren from the vehicle the player looks at.

/detachsirens
Example: /detachsirens

AttachAllSirens

This will attach the given siren (or the default) to all existing vehicles on the map, if supported by the siren. Already existing sirens will be overridden.

/attachallsirens [optional:sirenname]
Example: /attachallsirens police-germany

Syntax - Options

DetachAllSirens

This will remove all sirens from all vehicles on the map.

/detachallsirens
Example: /detachallsirens

ListSirens

This will post a list of all available sirens to the players chat.

/listsirens
Example: /listsirens

ToggleSirens

This will toggle the siren state of the vehicle the player is mounted to. If the player is not mounted it toggles the siren state of the vehicle the player is looking at, if the MountNeeded configuration is set to false. This is especially useful for horses, because buttons are quite difficult to fit on them.

/togglesirens
Example: /togglesirens

Paste bind j togglesirens into the ingame console to bind that command to the J key as an example.

Permissions

Configuration

{
  // Sets if a player needs to be mounted on the car to press the button
  "MountNeeded": true,
  // Global config for enabling the usage of sounds for sirens
  "SoundEnabled": true,
  // Sets the probability of newly spawning vehicles (or existing ones when loading the plugin)
  // having a siren attached to [0.0; 1.0]
  // MODULAR_CAR is a special key for the modular car vehicle type.
  "SirenSpawnProbability": {
    "MODULAR_CAR": 0.0,
    "assets/rust.ai/nextai/testridablehorse.prefab": 0.0,
    "assets/content/vehicles/crane_magnet/magnetcrane.entity.prefab": 0.0,
    "assets/content/vehicles/minicopter/minicopter.entity.prefab": 0.0,
    "assets/content/vehicles/boats/rhib/rhib.prefab": 0.0,
    "assets/content/vehicles/boats/rowboat/rowboat.prefab": 0.0,
    "assets/content/vehicles/sedan_a/sedantest.entity.prefab": 0.0,
    "assets/content/vehicles/scrap heli carrier/scraptransporthelicopter.prefab": 0.0,
    "assets/content/vehicles/workcart/workcart.entity.prefab": 0.0
  },
  // Sets the default state (OFF, ON, LIGHTS_ONLY) which a newly attached siren will have
  "DefaultState": "OFF"
}

Sirens

The folder '/data/sirens/' contains the available sirens. Existing ones can be edited or new ones can be created. To find correct positions I suggest to edit the siren file directly on the server (via winscp, filezilla or whatever you use). You can attach the siren to the vehicle you plan to configure, change the config file as you want and type oxide.reload Sirens in the console to reload and directly apply the changes. Repeat the last two steps until it fits your needs. You don't need to reattach the siren. This is the way I used to preconfigure the default sirens. As an example the police-germany.json file with some additional comments:

{
  // Mapping name to identify the siren while attaching
  "Name": "police-germany",
  // the tone order
  "Tones": [
    {
      // The notes [A; G]
      "Note": "A",
      // The note type (Regular, Sharp)
      "NoteType": "Regular",
      // The octave
      "Octave": 4,
      // The time till this tone will stop and the next one plays (in seconds)
      "Duration": 1.0
    },
    {
      "Note": "D",
      "NoteType": "Regular",
      "Octave": 5,
      "Duration": 1.0
    }
  ],
  // These are the configs for each module of modular cars relevant for this siren,
  // if a module is not set here there won't be anything attached to it
  "Modules": {
    // The module which is described
    "assets/content/vehicles/modularcar/module_entities/1module_cockpit.prefab": [
      {
        // the prefab that will spawn
        "Prefab": "assets/prefabs/io/electric/switches/pressbutton/pressbutton.prefab",
        // the local position of that entity
        "Position": {
          // Left/Right
          "x": 0.05,
          // Up/Down
          "y": 1.7,
          // Forward/Backward
          "z": 0.78
        },
        // the local angles of that entity
        "Angle": {
          "x": 210.0,
          "y": 0.0,
          "z": 0.0
        }
      },
      {
        "Prefab": "assets/prefabs/deployable/playerioents/lights/flasherlight/electric.flasherlight.deployed.prefab",
        "Position": {
          "x": -0.4,
          "y": 1.4,
          "z": -0.9
        },
        "Angle": {
          "x": 0.0,
          "y": 0.0,
          "z": 0.0
        }
      },
      {
        "Prefab": "assets/prefabs/deployable/playerioents/lights/flasherlight/electric.flasherlight.deployed.prefab",
        "Position": {
          "x": 0.4,
          "y": 1.4,
          "z": -0.9
        },
        "Angle": {
          "x": 0.0,
          "y": 0.0,
          "z": 0.0
        }
      },
      {
        "Prefab": "assets/prefabs/instruments/trumpet/trumpet.weapon.prefab",
        "Position": {
          "x": -0.08,
          "y": 1.4,
          "z": -0.9
        },
        "Angle": {
          "x": 148.0,
          "y": 150.0,
          "z": 30.0
        }
      }
    ],
    ...
  },
  / These are the configs for all other vehicles (BaseVehicle entity) relevant for this siren,
  // if a vehicle is not set here it will not be supported by the siren and there won't be anything attached to it
  "Vehicles": {
    // The vehicle which is described
    "assets/content/vehicles/sedan_a/sedantest.entity.prefab": [
      {
        // the prefab that will spawn
        "Prefab": "assets/prefabs/io/electric/switches/pressbutton/pressbutton.prefab",
        // the local position of that entity
        "Position": {
          // Left/Right
          "x": 0.0,
          // Up/Down
          "y": 2.05,
          // Forward/Backward
          "z": 1.9
        },
        // the local angles of that entity
        "Angle": {
          "x": 210.0,
          "y": 0.0,
          "z": 0.0
        }
      },
      {
        "Prefab": "assets/prefabs/deployable/playerioents/lights/flasherlight/electric.flasherlight.deployed.prefab",
        "Position": {
          "x": -0.4,
          "y": 1.65,
          "z": 0.2
        },
        "Angle": {
          "x": 0.0,
          "y": 0.0,
          "z": 0.0
        }
      },
      {
        "Prefab": "assets/prefabs/deployable/playerioents/lights/flasherlight/electric.flasherlight.deployed.prefab",
        "Position": {
          "x": 0.4,
          "y": 1.65,
          "z": 0.2
        },
        "Angle": {
          "x": 0.0,
          "y": 0.0,
          "z": 0.0
        }
      },
      {
        "Prefab": "assets/prefabs/instruments/trumpet/trumpet.weapon.prefab",
        "Position": {
          "x": -0.08,
          "y": 1.68,
          "z": 0.2
        },
        "Angle": {
          "x": 148.0,
          "y": 150.0,
          "z": 30.0
        }
      }
    ],
    // the horse that is described (actually this is for all ridable horses)
    "assets/rust.ai/nextai/testridablehorse.prefab": [
      {
        // the prefab that will be spawned
        "Prefab": "assets/prefabs/deployable/playerioents/lights/flasherlight/electric.flasherlight.deployed.prefab",
        // the local position of that entity
        "Position": {
          "x": 0.0,
          "y": 1.7,
          "z": 1.2
        },
        // the local angles of that entity
        "Angle": {
          "x": 45.0,
          "y": 0.0,
          "z": 0.0
        },
        // the bone that entity will be parented to, so that it moves with that bone
        "Bone": "head"
      },
      {
        "Prefab": "assets/prefabs/instruments/trumpet/trumpet.weapon.prefab",
        "Position": {
          "x": -0.06,
          "y": 1.15,
          "z": 1.3
        },
        "Angle": {
          "x": 90.0,
          "y": 150.0,
          "z": 90.0
        },
        "Bone": "lip_lower"
      }
    ],
    ...
  }
}

Available Horse Bones

This are all currently available horse bones, which can be used to parent entites: