This is a work in progress - Please be patient while I attempt to transpose all my thoughts into this forum post.
Preface:
Activation Event Types:
"Specific Team Only Enabled" Option
Listeners
Power
Setting up a Forge Object with this listener type is done via that object's "Power Channel" property under its "Scripting" object properties; setting that property's value to a valid broadcast channel activates the power listener.
Forge Objects with this listener react in the following way to the associated broadcast channel's state:
"Power" Listener Tutorial Video
Spawning
Setting up a Forge Object with this listener type is done via that object's "Spawn Channel" property under its "Scripting" object properties; setting that property's value to a valid broadcast channel activates the spawning listener.
In addition to the "Spawn Channel" property, the spawning listener has another piece of configuration, which is its "Can Despawn" property - also under its "Scripting" object properties; by default this property is set to "false".
Forge Objects with this listener react in the following way to the associated broadcast channel's state, and the "Can Despawn" property setting.
Every Forge Object in the game has the spawning listener configuration. However...
Bug Warning: As detailed in the "Scripting Bugs" section, there are a number of Forge Objects which, despite having a "Spawn Channel" and "Can Despawn" property, cannot actually have their spawning controlled via their spawning listener. For these objects, they will always be spawned onto the map regardless of their configuration.
"Spawning" Listener Tutorial Video
Scripting Bugs
Preface:
This is a guide to try and explain how scripting in H2A Forge works. Included is basic information and tutorials on the different scripts, switches, timers, and triggers, and how to set them up; plus some advanced tutorials for creating scripts that go above and beyond the standard ones.
The advanced tutorials will currently cover some complex scripts I have created; but, as time goes on , if other forum members come up with their own advanced scripts and post them here, then I will add them to the Advanced Tutorials section.
Contents:The advanced tutorials will currently cover some complex scripts I have created; but, as time goes on , if other forum members come up with their own advanced scripts and post them here, then I will add them to the Advanced Tutorials section.
- Overview
- Broadcasters
- Broadcast Channel Activation Types
- On
- Off
- Toggle
- Activation Event Types
- Switch
- Timer
- Proximity Trigger
- On-Destroyed Trigger
- "Specific Team Only Enabled" Option
- Broadcast Channel Activation Types
- Listeners
- Listener Types
- Special
- Explosive
- Animation
- Emp
- Power
- Spawning
- Special
- Listener Types
- Scripting Bugs
- Basic Tutorials
- Providing player feedback
- Advanced Tutorials
- On-Destroyed: Off/Toggle
- Switch/Trigger: On-Duration-Off
- Switch/Trigger: On-ExtendableDuration-Off
Scripting is a feature new to H2A forge which allows forgers to setup player-driven and non player-driven, events, actions, and behaviours. For example, a forger could add a script to their map which allows a player to open a door whenever they press a button switch.
Forum member Stevo has provided a brief video showing off some basic script functions. http://1drv.ms/1xkZhMu
Below is a summary of the three required components of a working forge script.
Broadcaster component
BroadcastersBelow is a summary of the three required components of a working forge script.
Broadcaster component
Only a broadcaster forge object is a broadcaster component; they are found under "Scripting" on the "Place Object" Menu (and there is also the "Garage Door Switch" broadcaster under "Map Gadgets").
This component's role is to change the activation state of a particular broadcast channel, based on a given activation event.
Example: The "Switch: On" broadcaster object, set to broadcast channel 1 - this turns on broadcast channel 1 when the player holds down the "Use" button on it.
A more in-depth look at broadcasters, their activation event types, and broadcast channel activation types, is detailed under the "Broadcasters" section of this guide.
Listener componentThis component's role is to change the activation state of a particular broadcast channel, based on a given activation event.
Example: The "Switch: On" broadcaster object, set to broadcast channel 1 - this turns on broadcast channel 1 when the player holds down the "Use" button on it.
A more in-depth look at broadcasters, their activation event types, and broadcast channel activation types, is detailed under the "Broadcasters" section of this guide.
Any forge object can have a listener component (even broadcaster objects), and many can have multiple listeners. A forge object is assigned listeners via the "Scripting" properties under the object's "Object Options" Menu.
This component's role is to listen on a particular broadcast channel, and then respond with some kind of action, or behaviour, based on what type of listener it is and the activation state of the channel.
Example: The "Garage Door" forge object, with the "Animation" listener listening on broadcast channel 1 - the garage door is opened when broadcast channel 1 is on, and closed when that channel is off.
A more in-depth look at listeners, and their types, is detailed under the "Listeners" section of this guide.
Broadcast channel componentThis component's role is to listen on a particular broadcast channel, and then respond with some kind of action, or behaviour, based on what type of listener it is and the activation state of the channel.
Example: The "Garage Door" forge object, with the "Animation" listener listening on broadcast channel 1 - the garage door is opened when broadcast channel 1 is on, and closed when that channel is off.
A more in-depth look at listeners, and their types, is detailed under the "Listeners" section of this guide.
This component's role is to act as the link between any broadcasters and listeners set to it. The channel is represented as a number, from 0 to 63. If a broadcaster or listener is set to a channel of -1 then it means it is not set to any broadcast channel at all.
A broadcast channel can be in one of two activation states: "on" or "off". The default starting state of a broadcast channel is "off", until altered by an associated broadcaster.
Tip: Although a broadcast channel's starting state is "off", you can use a "Timer: On Once" broadcaster to set it to "on" at the start of a game. If you do this though, you should not set the timer's delay to 0 because this will cause issues for anyone who isn't the Host of the game; instead, set the timer's delay to somewhere around 5 seconds, as this allows for Non-Host players to load into the map before the timer activates - don't worry, the timer still activates long before anyone spawns onto the map itself thanks to the 10 second "deploying" countdown at the start of a game.
A broadcast channel can be in one of two activation states: "on" or "off". The default starting state of a broadcast channel is "off", until altered by an associated broadcaster.
Tip: Although a broadcast channel's starting state is "off", you can use a "Timer: On Once" broadcaster to set it to "on" at the start of a game. If you do this though, you should not set the timer's delay to 0 because this will cause issues for anyone who isn't the Host of the game; instead, set the timer's delay to somewhere around 5 seconds, as this allows for Non-Host players to load into the map before the timer activates - don't worry, the timer still activates long before anyone spawns onto the map itself thanks to the 10 second "deploying" countdown at the start of a game.
Any given broadcaster object has a particular activation event and broadcast channel activation type.
Example: The "Switch: On" object uses the "Switch" activation event (requires a user to hold a button to activate the broadcaster), and is of the "On" channel activation type (it will turn on the associated broadcast channel).
Example: The "Switch: On" object uses the "Switch" activation event (requires a user to hold a button to activate the broadcaster), and is of the "On" channel activation type (it will turn on the associated broadcast channel).
Note that all broadcasters will work while in Forge; this means you can test them without needing to load your map in Custom Games.
Broadcast Channel Activation Types:
On
When activated, a broadcaster with this channel activation type will turn on its associated broadcast channel.
Off
When activated, a broadcaster with this channel activation type will turn off its associated broadcast channel.
Toggle
When activated, a broadcaster with this channel activation type will flip its associated broadcast channel between "on" or "off", i.e. if the associated broadcast channel is currently on then it will be turned off, and if it is currently off then it will be turned on.
Switch
Activating a broadcaster with this event type always requires a player to hold down the "Use" button in the location where the broadcaster object has been placed.
All switch broadcaster objects are invisible outside of Forge, but will provide a user prompt of "Hold {use button} to use" when a player is close enough to the object.
List of broadcaster objects with this event type:
TimerAll switch broadcaster objects are invisible outside of Forge, but will provide a user prompt of "Hold {use button} to use" when a player is close enough to the object.
List of broadcaster objects with this event type:
- Place Object -> Scripting -> Switches:
- Switch: On - When a player holds the "use" button near it, its associated broadcast channel turns on.
- Switch: Off - When a player holds the "use" button near it, its associated broadcast channel turns off.
- Switch: Toggle - When a player holds the "use" button near it, its associated broadcast channel flips between "on" or "off".
Activating a broadcaster with this event type happens automatically, as soon as the broadcaster is created. Once the broadcaster has activated, it can be given a delay, via its "Timer/User data" in seconds, before it alters its associated broadcast channel. By default, a Timer will have no delay (it's set to 0).
All timer broadcaster objects are invisible outside of Forge, and will give no indication to the player that they exist.
Because a timer automatically activates when created, it will typically be used in conjunction with a broadcaster that does require player input, so that the activation of the timer can be controlled. Controlling the activation of a timer is done by assigning it a "Power" listener, which will then only enable the timer (and begin its delay, if any) when the broadcast channel of that listener is on.
There is also the "once" variant of timers. A standard timer, when its timer delay has expired, and it alters a broadcast channel, will then reset and countdown its delay time again. A "once" timer, however, will only countdown its delay one time; after its first delay has expired, and it alters a broadcast channel, it is no longer active; its delay can then only be started again by deactivating and reactivating its power channel, or if it is respawned.
List of broadcaster objects with this event type:
Timer Tutorial Video
Proximity TriggerAll timer broadcaster objects are invisible outside of Forge, and will give no indication to the player that they exist.
Because a timer automatically activates when created, it will typically be used in conjunction with a broadcaster that does require player input, so that the activation of the timer can be controlled. Controlling the activation of a timer is done by assigning it a "Power" listener, which will then only enable the timer (and begin its delay, if any) when the broadcast channel of that listener is on.
There is also the "once" variant of timers. A standard timer, when its timer delay has expired, and it alters a broadcast channel, will then reset and countdown its delay time again. A "once" timer, however, will only countdown its delay one time; after its first delay has expired, and it alters a broadcast channel, it is no longer active; its delay can then only be started again by deactivating and reactivating its power channel, or if it is respawned.
List of broadcaster objects with this event type:
- Place Object -> Scripting -> Timers:
- Timer: On - When activated, after a set delay, its associated broadcast channel turns on, and then it loops.
- Timer: On Once - When activated, after a set delay, its associated broadcast channel turns on one time.
- Timer: Off - When activated, after a set delay, its associated broadcast channel turns off, and then it loops.
- Timer: Off Once - When activated, after a set delay, its associated broadcast channel turns off one time.
- Timer: Toggle - When activated, after a set delay, its associated broadcast channel flips between "on" or "off", and then it loops.
- Timer: Toggle Once - When activated, after a set delay, its associated broadcast channel flips between "on" or "off" one time.
Timer Tutorial Video
Activating a broadcaster with this event type requires a player to enter/exit a trigger zone, which is created around the trigger object. This trigger zone's size and shape can be configured in the same way that, for instance, a hill marker's size and shape can be configured.
All proximity trigger broadcaster objects are invisible outside of forge, and will give no indication to the player that they exist.
There are three variants of a proximity trigger which alter how a player's interactions with its trigger zone activates the broadcaster:
Proximity Trigger Tutorial Video
Proximity Trigger "Broken Power Channel" Workaround Video
On-Destroyed TriggerAll proximity trigger broadcaster objects are invisible outside of forge, and will give no indication to the player that they exist.
There are three variants of a proximity trigger which alter how a player's interactions with its trigger zone activates the broadcaster:
- On-Enter - This broadcaster activates when a player enters its trigger zone.
- On-Exit - This broadcaster activates when a player leaves its trigger zone.
- On-Stay - This broadcaster activates when the first player enters its trigger zone, and activates again when the last player leaves its trigger zone, e.g. 2 players enter the trigger zone - only the first player activates the trigger; then both players leave the trigger zone - only the second player activates the trigger again.
- Place Object -> Scripting -> Triggers:
- On-Enter: On - When a player enters its trigger zone, its associated broadcast channel turns on.
- On-Enter: Off - When a player enters its trigger zone, its associated broadcast channel turns off.
- On-Enter: Toggle - When a player enters its trigger zone, its associated broadcast channel flips between "on" or "off".
- On-Exit: On - When a player leaves its trigger zone, its associated broadcast channel turns on.
- On-Exit: Off - When a player leaves its trigger zone, its associated broadcast channel turns off.
- On-Exit: Toggle - When a player leaves its trigger zone, its associated broadcast channel flips between "on" or "off".
- On-Stay: On - When first player enters its trigger zone, and again when last player leaves its trigger zone, its associated broadcast channel turns on.
- On-Stay: Off - When first player enters its trigger zone, and again when last player leaves its trigger zone, its associated broadcast channel turns off.
- On-Stay: Toggle - When first player enters its trigger zone, and again when last player leaves its trigger zone, its associated broadcast channel flips between "on" or "off".
Proximity Trigger Tutorial Video
Proximity Trigger "Broken Power Channel" Workaround Video
Activating a broadcaster with this event type requires the broadcaster object to be damaged in some way. Note that the object does not need to be damaged where it is lit up - it can be damaged anywhere on the object.
Methods of damaging the on-destroyed trigger object, to activate it:
Unlike other broadcaster objects, on-destroyed objects are visible in both forge and custom games.
Unlike with other broadcasters, the only version of an on-destroyed trigger is one that turns on an associated broadcast channel; there are no "off" and "toggle" variants. It is still possible however to replicate "off" and "toggle(ish)" behaviour using timers as an intermediary between your trigger and the object you want to affect.
List of broadcasters with this event type:
On-Destroyed Trigger Tutorial Video
Methods of damaging the on-destroyed trigger object, to activate it:
- A player shooting the trigger object.
- A player performing a melee attack on the trigger object.
- An explosion going off close enough to the trigger object.
- A player or object smashing into the trigger object with enough speed/force.
Unlike other broadcaster objects, on-destroyed objects are visible in both forge and custom games.
Unlike with other broadcasters, the only version of an on-destroyed trigger is one that turns on an associated broadcast channel; there are no "off" and "toggle" variants. It is still possible however to replicate "off" and "toggle(ish)" behaviour using timers as an intermediary between your trigger and the object you want to affect.
List of broadcasters with this event type:
- Place Object -> Scripting -> Triggers:
- On-Destroyed: When this broadcaster is damaged, its associated broadcast channel turns on.
- Place Object -> Gadgets -> Map Gadgets:
- Garage Door Switch: When this broadcaster is damaged, its associated broadcast channel turns on.
On-Destroyed Trigger Tutorial Video
For the "Switch" and "Proximity Trigger" broadcasters, it is possible to configure them so that they are only enabled for a specific team and then disabled for all others.
To setup one of these broadcasters for a specific team, change its "Team" property from "Neutral" to the team you want that broadcaster to be enabled for, e.g. setting a "Switch: On" broadcaster's "Team" property to "Defenders" will mean that only the Red Team can activate that switch - for any other team that switch will be disabled.
For FFA gametypes this setting will have no effect - regardless of the "Team" property's setting, the broadcaster object will always be enabled. Note that the "Infection" gametype is classed as FFA as far as this property is concerned.
"Specific Team Only Enabled" Option Tutorial Video
To setup one of these broadcasters for a specific team, change its "Team" property from "Neutral" to the team you want that broadcaster to be enabled for, e.g. setting a "Switch: On" broadcaster's "Team" property to "Defenders" will mean that only the Red Team can activate that switch - for any other team that switch will be disabled.
For FFA gametypes this setting will have no effect - regardless of the "Team" property's setting, the broadcaster object will always be enabled. Note that the "Infection" gametype is classed as FFA as far as this property is concerned.
"Specific Team Only Enabled" Option Tutorial Video
A listener is setup against a Forge Object via that object's channel properties. A particular type of listener is associated with a particular channel property. Setting a channel property to a valid broadcast channel is what activates a particular listener to listen to that broadcast channel. A Forge Object can then react to that broadcast channel being turned on or off.
Example: A Mongoose has the "Spawn Channel" property, which is associated with the "Spawning" type of listener. Setting that Mongoose's spawn channel property to 0 means that the Mongoose will spawn onto the map when broadcast channel 0 is turned on.
Listener Types:
Special
The "Special" category of listeners covers a set of listener types that are all configured on the same channel property, which is the "Broadcast Channel" property; note that this is the same property as used by Broadcaster objects, but for any Forge Objects that is not a Broadcaster this property instead configures its special listener.
A Forge Object that has a special listener can only be one of the following special listener types:
Explosive
Setting up a Forge Object with this listener type is done via that object's "Broadcast Channel" property under its "Scripting" object properties; setting that property's value to a valid broadcast channel activates the explosive listener.
Forge Objects with this listener react in the following way to the associated broadcast channel's state:
List of Forge Objects with the explosive listener:
AnimationForge Objects with this listener react in the following way to the associated broadcast channel's state:
- Broadcast channel turns on: The Forge Object explodes
- Broadcast channel turns off: No reaction
List of Forge Objects with the explosive listener:
- Place Object -> Gadgets -> Explosives:
- Fusion Coil
- Fusion Coil, EMP
- Landmine
- Landmine, EMP
- Explosion Volume, Small
- Explosion Volume, Small Inv
- Explosion Volume, Large
- Explosion Volume, Large Inv
Setting up a Forge Object with this listener type is done via that object's "Broadcast Channel" property under its "Scripting" object properties; setting that property's value to a valid broadcast channel activates the animation listener.
Forge Objects with this listener react in the following way to the associated broadcast channel's state:
List of Forge Objects with the animation listener:
EMP- Broadcast channel turns on: The Forge Object animates to a new object state
- Broadcast channel turns off: The Forge Object animates back to its original object state
List of Forge Objects with the animation listener:
- Place Objects -> Gadgets -> Lights:
- All Lights under this category: The light turns off when the broadcast channel turns on, and the light turns back on again when the broadcast channel turns off
- Place Objects -> Gadgets -> Map Gadgets:
- Switch: Animates closed when the broadcast channel turns on, and opens back up when the broadcast channel turns off
- Garage Door: Animates open when the broadcast channel turns on, and closes back up when the broadcast channel turns off
- Console Switch: Shows a blue-screen when the broadcast channel turns on, and goes back to showing the ready screen when the broadcast channel turns off
Setting up a Forge Object with this listener type is done via that object's "Broadcast Channel" property under its "Scripting" object properties; setting that property's value to a valid broadcast channel activates the EMP listener.
Forge Objects with this listener react in the following way to the associated broadcast channel's state:
List of Forge Objects with the EMP listener:
"Special" Listeners Tutorial VideoForge Objects with this listener react in the following way to the associated broadcast channel's state:
- Broadcast channel turns on: An EMP detonates around the Forge Object, and it animates to a new object state
- Broadcast channel turns off: The Forge Object animates back to its original object state
List of Forge Objects with the EMP listener:
- Place Objects -> Gadgets -> Map Gadgets:
- EMP Device, Blue: Gives off a blue coloured EMP, and animates closed, when the broadcast channel turns on, and animates back to open, with a blue glowing orb, when the broadcast channel turns off
- EMP Device, Red: Gives off a red coloured EMP, and animates closed, when the broadcast channel turns on, and animates back to open, with a red glowing orb, when the broadcast channel turns off
Setting up a Forge Object with this listener type is done via that object's "Power Channel" property under its "Scripting" object properties; setting that property's value to a valid broadcast channel activates the power listener.
Forge Objects with this listener react in the following way to the associated broadcast channel's state:
- Broadcast channel is on: Certain scripting functionality on the Forge Object is enabled
- Broadcast channel is off: Certain scripting functionality on the Forge Object is disabled
- Place Objects -> Scripting:
- All Scripting Broadcasters under this category: Broadcasting ability is enabled when the broadcast channel is on, and disabled when the broadcast channel is off
- Place Objects -> Gadgets:
- All Forge Objects with special listeners under this category: The object's special listener is enabled when the broadcast channel is on, and disabled when the broadcast channel is off
"Power" Listener Tutorial Video
Setting up a Forge Object with this listener type is done via that object's "Spawn Channel" property under its "Scripting" object properties; setting that property's value to a valid broadcast channel activates the spawning listener.
In addition to the "Spawn Channel" property, the spawning listener has another piece of configuration, which is its "Can Despawn" property - also under its "Scripting" object properties; by default this property is set to "false".
Forge Objects with this listener react in the following way to the associated broadcast channel's state, and the "Can Despawn" property setting.
- Can Despawn: False, Broadcast channel is on: The Forge Object tries to spawn onto the map
- Can Despawn: False, Broadcast channel is off: No reaction
- Can Despawn: True, Broadcast channel is on: The Forge Object tries to spawn onto the map
- Can Despawn: True, Broadcast channel is off: The Forge Object despawns off of the map
- Object Properties:
- Spawn Time: Set this to "Never", so that the Forge Object doesn't try to respawn itself every x seconds
- Object Properties -> Advanced:
- Place At Start: Set this to "False", so that the Forge Object doesn't spawn itself in at the beginning of the game - otherwise this would override the scripting, which says an object should not be spawned onto the map unless its associated broadcast channel is on
- Min Count: Make sure to keep this number below the number of instances of this object type that are involved in spawning scripts. If you're unsure what this means, just keep it at 0. If you set this number too high, it will force the object to spawn onto the map, regardless of the spawn scripting behaviour on that object.
Every Forge Object in the game has the spawning listener configuration. However...
Bug Warning: As detailed in the "Scripting Bugs" section, there are a number of Forge Objects which, despite having a "Spawn Channel" and "Can Despawn" property, cannot actually have their spawning controlled via their spawning listener. For these objects, they will always be spawned onto the map regardless of their configuration.
"Spawning" Listener Tutorial Video
- The "Power Channel" property on Proximity Trigger broadcasters does not work: No matter what broadcast channel this broadcaster's power channel is set to, and regardless of whether that broadcast channel is "on" or "off", this broadcaster will always be enabled.
- The "Spawn Channel" property of the "Trait Zone" object does not work: No matter what broadcast channel this object's spawn channel is set to, and regardless of whether that broadcast channel is "on" or "off", this object will always be spawned onto the map at the beginning of the game, and it cannot be despawned.
- A "Timer: On Once" broadcaster, set to turn on a Broadcast Channel at the start of a game, will not work for Off-Host players if its delay is set to "0": For any player who isn't the host, this broadcaster will not appear to be turned on - most likely due to the timer activating as soon as the Host has entered the game, which happens before any other player has entered the game. To resolve this, give this broadcaster a delay of around 5 seconds, so that the timer activates after everyone has entered the game, but before any players have spawned onto the map.
Last edited: