2016-08-18 16:37:38 +00:00
---
layout: wiki
title: Explosives Framework
description: Explains how to set-up custom explosives with the ACE3 explosives system.
group: framework
order: 5
parent: wiki
2016-08-30 13:49:04 +00:00
mod: ace
version:
major: 3
minor: 0
patch: 0
2016-08-18 16:37:38 +00:00
---
< div class = "panel callout" >
< h5 > Note:< / h5 >
< p > This is just the necessary to make explosives using the framework, this is not a guide to make your own explosives.< / p >
< / div >
## 1. Explosives
### 1.1 Setting the magazine
```cpp
class CfgMagazines {
class CA_Magazine;
class banana_satchel_remote_mag: CA_Magazine {
2017-08-26 16:37:31 +00:00
ACE_Explosives_Placeable = 1; // Can be placed
2016-08-18 16:37:38 +00:00
useAction = 0; // Disable the vanilla interaction
2017-08-26 16:37:31 +00:00
ACE_Explosives_SetupObject = "banana_satchel_place"; // The object placed before the explosive is armed
2016-08-18 16:37:38 +00:00
class ACE_Triggers { // Trigger configurations
SupportedTriggers[] = {"Timer", "Command", "MK16_Transmitter", "DeadmanSwitch"}; // Triggers that can be used
class Timer {
FuseTime = 0.5; // Time for the fuse to burn
};
class Command {
FuseTime = 0.5;
};
class MK16_Transmitter: Command {};
class DeadmanSwitch: Command {};
};
};
};
```
### 1.2 Setting the ammo
```cpp
class CfgAmmo {
class PipeBombBase;
class SatchelCharge_Remote_Ammo: PipeBombBase {
soundActivation[] = {"", 0, 0, 0}; // No sound on activation
soundDeactivation[] = {"", 0, 0, 0}; // No sound on deactivation
2024-08-12 13:18:21 +00:00
triggerWhenDestroyed = 1; // (Optional) Explode when the object is shot and destroyed (after being placed) (0-disabled, 1-enabled). Required to be enabled prior to ACE 3.18.0.
2016-08-18 16:37:38 +00:00
ACE_explodeOnDefuse = 0.02; // (Optional) Add a chance for the explosive to detonate after being disarmed (in percent)
2017-08-26 16:37:31 +00:00
ACE_explosives_defuseObjectPosition[] = {-1.415, 0, 0.12}; // (Optional) The position relative to the model where the defuse helper object will be attached and thus the interaction point will be rendered
ACE_explosives_size = 0; // (Optional) Setting to 1 will use a defusal action with a larger radius (useful for large mines or mines with a wide pressure plane trigger area)
2016-08-18 16:37:38 +00:00
};
};
```
### 1.3 Adding the place item
```cpp
class CfgVehicles {
class ACE_Explosives_Place;
class banana_satchel_place: ACE_Explosives_Place {
displayName = "Banana satchel"; // Name of the item
model = ""; // Path to your model
ACE_offset[] = {0, 0, 0}; // Offset of the interaction point from the model in meters on the X,Y,Z axis. Try setting this to the place where it makes most sense (e.g. to buttons/switches/pins)
};
};
```
## 2. Mines
### 2.1 Setting the magazine
_Pretty much the same as Explosives except that we inherit from_ `ATMine_Range_Mag` _instead of_ `CA_Magazine` .
```cpp
class CfgMagazines {
class ATMine_Range_Mag;
class BananaMine_Range_Mag: ATMine_Range_Mag {
2017-08-26 16:37:31 +00:00
ACE_Explosives_SetupObject = "BananaMine_Place"; // The object placed before the mine is armed
2016-08-18 16:37:38 +00:00
class ACE_Triggers { // Triggers
SupportedTriggers[] = {"PressurePlate"}; // This mine only support pressure plate activation
class PressurePlate {
digDistance = 0.05;
};
};
};
};
```
### 2.2 Setting up the Ammo
The class you inherit from depends of what type of trigger you are using, for `PressurePlate` and `Tripwire` you can skip this step, for timers and clackers refer to the Explosives entry.
Directional mines inherit from `DirectionalBombBase` .
## 3. Adding your own detonators
```cpp
class CfgWeapons {
class ACE_ItemCore; // ACE3 base item class
class ACE_Clacker; // Clacker base class
class banana_clacker: ACE_Clacker {
displayName = "banana clacker"; // Name of the item
picture = ""; // Path to the item's picture
2017-08-26 16:37:31 +00:00
ACE_Explosives_Range = 9000; // Explosives activation range in meters
ACE_Explosives_triggerType = "Command"; // Trigger type, see below
2016-08-18 16:37:38 +00:00
};
};
```
## 4. Trigger list
2024-04-19 20:53:33 +00:00
| Name | Use |
| ---- | ----- |
| `Command` | Explode when activated via clacker. |
| `MK16_Transmitter` | Explode when activated via M26 clacker. |
| `DeadManSwitch` | Explode after activated via the switch or the person dies. |
| `Cellphone` | Explode when the number is called. |
| `PressurePlate` | Explode upon being stepped upon. |
| `IRSensor` | Explode after movement is detected in front of the mine. |
| `Timer` | Explode after timer drop to 0. |
| `Tripwire` | Explode when something touch the tripwire. |
2016-09-08 19:19:07 +00:00
## 5. Scripting
### 5.1 Scripted Explosion
2017-01-11 23:35:35 +00:00
`ace_explosives_fnc_scriptedExplosive`
2016-09-08 19:19:07 +00:00
2024-04-19 20:53:33 +00:00
| | Arguments | Type | Optional (default value) |
|----| --------- | ---- | ------------------------ |
| 0 | Explosive objects | Array | Required |
| 1 | Delay before detonation | Number | Optional (default: `0` , randomized up to given number if negative) |
| **R** | None | None | Return value |
2016-09-08 19:19:07 +00:00
#### 5.1.1 Example
2017-01-11 23:35:35 +00:00
`[[charge1, charge2], -3] call ace_explosives_fnc_scriptedExplosive;`
2016-09-08 19:19:07 +00:00
2024-04-19 20:53:33 +00:00
| | Arguments | Explanation |
|----| --------- | ----------- |
| 0 | `[charge1, charge2]` | Explosive objects to detonate |
| 1 | `-3` | Randomized delay, up to 3 seconds |
2016-09-08 19:19:07 +00:00
### 5.2 Connect Explosive
`ace_explosives_fnc_connectExplosive`
2024-04-19 20:53:33 +00:00
| | Arguments | Type | Optional (default value) |
|----| --------- | ---- | ------------------------ |
| 0 | Unit to connect to | Object | Required |
| 1 | Explosive object to connect to | Object | Required |
| 2 | Detonator type class name (must be present on unit) | String | Required |
| **R** | None | None | Return value |
2016-09-08 19:19:07 +00:00
#### 5.2.1 Example
`[player, claymore1, "ACE_Clacker"] call ace_explosives_fnc_connectExplosive;`
2024-04-19 20:53:33 +00:00
| | Arguments | Explanation |
|----| --------- | ----------- |
| 0 | `player` | Unit explosive will connect to |
| 1 | `claymore1` | Explosive object that will be connected |
| 2 | `"ACE_Clacker"` | Detonator type class name |
2017-05-10 16:28:44 +00:00
#### 5.3 Detonation Handler.
Detonation Handlers are called when something attempts to trigger an explosive. They can be used to block the detonation.
These are only used for script based triggers like clackers, cellphone and timers (anything that uses `detonateExplosive` ).
Sensor based triggers like AT Mines, Tripwires are uneffected.
All added handlers will be called, if ANY one returns false, the detonation will be blocked.
`[{CODE}] call ace_explosives_fnc_addDetonateHandler;`
CODE will be passed `[Unit<OBJECT>, MaxRange <NUMBER>, Explosive <OBJECT>, FuzeTime <NUMBER>, TriggerItem <STRING>]` and should return a bool: true(allowed) / false(blocked)
#### 5.3.1 Example
Jammer that blocks RF triggers:
2021-10-31 19:48:47 +00:00
```sqf
2017-05-10 16:28:44 +00:00
[{
params ["_unit", "_range", "_explosive", "_fuzeTime", "_triggerItem"];
2017-08-26 16:37:31 +00:00
if (_triggerItem == "ace_cellphone") exitWith { systemChat "Blocking Cell Phone"; false }; // always block cell phones
2017-05-10 16:28:44 +00:00
if (_triggerItem == "ace_m26_clacker") exitWith {
_range = _range / 1000;
private _actualRange = _unit distance _explosive;
systemChat format ["Limited Range For RF Clacker [%1m / %2m]", _actualRange toFixed 1, _range toFixed 1];
(_actualRange < _range ) / / return bool
};
// allow anything else (like timers / wired clackers)
true
}] call ace_explosives_fnc_addDetonateHandler;
```
2023-05-03 16:55:02 +00:00
#### 5.4 Disabling `setShotParents`.
2024-04-19 20:53:33 +00:00
ACE will set the owner/instigator of the explosive to the unit placing/detonating it.
2023-05-03 16:55:02 +00:00
This can be disabled by executing
```sqf
ace_explosives_setShotParents = false;
```