Skip to content

Multicast

fenix31415 edited this page Jan 23, 2024 · 29 revisions

This feature will allow you to launch multiple projectiles. All projectiles is divided by Spawn Group. All projectiles of the same group of the same type make up some kind of figure, and the same settings of the initial position, initial angle, spread, etc. also apply to them.

Multicast itself is a set of Spawn Groups, for each of which a basic type of projectile is defined, as well as new types, if necessary.

MulticastSpawnGroups

This is a map in which keys are strings (starting with key_) and values are spawn groups objects. The keys are unique, you will use them in Multicast Data to refer to the Spawn Group you need. Values are objects, that describe a position, shape, rotations, etc. of the Spawn Group.

Spawn group is a pattern and some other settings.

When creating a projectile, its type, initial position and initial direction are known. These are the initial values for Spawn Group's pattern. To create the Spawn Group, the following steps occur:

  1. Pattern points are defined.
  2. The initial direction of the projectiles is determined.
  3. The positions of the projectiles change by a random amount.
  4. An offset is added to each direction.
  5. Each direction changes by a random amount.

You can control these steps using the settings. Don't worry, it's really hard to understand the first time. Programming is even harder. I advise you to just experiment. Start with the minimum number of settings. Change something, look at the result. Add settings one by one and you will understand what each of them does. Do not forget to refer to the described algorithm to make it easier to understand the settings.

Spawn Group settings instance is an object with the following fields.

  • Pattern: a pattern settings. See 1.
  • rotation: a method to determine initial direction of placed projectiles. See 2.
  • posRnd: the maximum value of the random projectile position offset for each axis (default: [0,0,0]). See 3.
  • rotOffset: a value that added to every calculated projectile rotation (default: [0,0,0]). See 4.
  • rotRnd: the maximum value of the random projectile rotation offset for each axis (default: [0,0]). See 5.
  • sound: a method of playing sound in a Spawn Group. This parameter can take these values. Still have problems with it.
    • Single (default): play sound once for the Spawn Group.
    • Every: play sound for every projectile in the Spawn Group.
    • None: do not play sounds for the Spawn Group.

Spawn Group Rotation

In different situations, it may be necessary to orient the projectiles differently. The direction may depend on the direction of the Spawn Group, on the position of the projectile and the center of the Spawn Group, on the target of the attacker, and so on. The following options are currently available.

  • Parallel (default): set same direction, as Spawn Group's direction.
  • ToSight: projectiles aimed to caster's target.
  • ToCenter: projectiles are aimed at the center of the Spawn Group.
  • FromCenter: projectiles are aimed from the center of the Spawn Group.
  • ToTarget: projectiles are aimed to the target, defined by the Homing function.
    In the rotationTarget field, set the id of Homing instance.

MulticastData

This is a map where keys are strings (starting with key_) and values are instances of settings for this feature. The key identifies the settings instance. In the Triggers section, you can specify the instance of settings you need using this key. An instance of settings is an array of objects (single Spawn Data may consists of several Spawn Groups) with the following fields.

  • spawn_group: a key of the Spawn Group from MulticastSpawnGroups.
  • TriggerFunctions (optional): functions to call on every created projectile.
  • callTriggers: whether to call triggers with event ProjAppeared on new projectiles.

Weapon or Spell

To cast a projectile, you need to know whether it is an arrow or a magic projectile. To do this, there are fields weapID, arrowID, spellID. It can contains FormID, as well as value "Current", which means "use initial spell/arrow of the Spawn Group". Only one of the weapID or spellID should be defined. Make sure that if you use "Current" for spellID, then Spawn Group has initial spell (i.e. it is triggered by spell casted). Same for weapID. arrowID is optional, default is "Current".

Homing + Multicast

It is possible to set targets for projectiles evenly among the detected targets. If field Homing is defined inside TriggerFunctions, the object can contain field HomingDetection. It defines the method of setting targets.

  • Individual (default): Find the target for each projectile independently. Often they will fly into the same enemy.
  • Evenly: first get all possible targets for the entire Spawn Group, and then aim each projectile at random one of them.

Example

"MulticastSpawnGroups": {
  "key_SG_1": {
    "Pattern": {
      "Figure": {
        "shape": "Line",
        "count": 10,
        "size": 500
      }
    }
  }
},

"MulticastData": {
  "key_MC_1": [
    {
      "spawn_group": "key_SG_1",
      "spellID": "key_spellFireball"
    }
  ]
},
Clone this wiki locally