Jump to content

Problem scripting ACE explosives

Recommended Posts

Hey, all.


I've been attempting to create a mission for some time now, and every problem I've encountered so far, I have been able to solve... until today.



Simply put, the mission uses ACE, which has its own explosive framework, and to that end the ACE site does provide some useful information. Specifically, I've been using 'ace_explosives_fnc_scriptedExplosive'. The good news is, it works like a charm. The catch is that it only seems to work for explosives which are spawned in through the editor, and not those created by scripts.


In my scenario, there is a trigger (code below). The idea is to have an area where all cars driven by blufor units have a demolition charge spawned and attached to said vehicle, then have it explode.

The problem is the line '[_newEp, -3] call ace_explosives_fnc_scriptedExplosive;'. For whatever reason, it works wonders with explosives placed within the editor (and subsequently attached to vehicles), but doesn't do a thing for any explosive spawned in via script.

I was hoping any of you, who are more versed in scripting, could shed some light on the subject. I am by no means an experienced script writer/programmer, and most of what I know is from hours of messing around, so any advice would be much appreciated.


Condition Code executed by the trigger:

count (nearestObjects [trig2, ["Car"], 50]) > 0;

On Activation code executed by the trigger (via script):

_carlist = _this select 0; 
    if (side (driver _x) == west) then {
        hint "true"; 
        _newEp = "DemoCharge_F" createVehicle [0, 0, 0]; 
        _newEp attachTo [_x, [0, 0, 0], "driverview"]; 
        [_newEp, -3] call ace_explosives_fnc_scriptedExplosive;
    } else {
        hint "false"
} forEach _carList;

Where _carList is:

nearestObjects [trig2, ["Car"], 50]


If I had to chance a guess at what was happening, I'd wager that ACE is only applying its explosive framework to the explosives placed in the editor, while those spawned via script maintain their vanilla class attributes.

Share this post

Link to post
Share on other sites

I am currently looking through the ace code right now. the problem could be this functions fnc_detonateExplosive.sqf. It does some checks and might just exit preemptively. It also returns its status as a boolean.


So first of what you need to test is which value does the function give back?

If it returns false then it most likely stops in line 36. this means there are some detonation handlers active. So you have to check the global variable "ace_explosives_detonationHandlers". It should be an array and if there is something in there it should be code blocks.


If it returns true, then it went through all the loops and should have detonated. If it has not, there are two warnings thrown in linke 52 and 55. So they should show up in your RPT file. The reason for i to not explode could be that the vehicle has to be of the type "CFGAmmo" and not "CFGVehicle". While if my google foo has not left me (and i do not have the game in front of me right now) the object you use is of type "CfgVehicle".

Share this post

Link to post
Share on other sites





Both work with your code. Not sure what the real difference is between them. The Config Viewer is very handy thing!

  • Thanks 1

Share this post

Link to post
Share on other sites

Brilliant, hats off to you guys.


Looks like it was a just matter of changing the config class to something designed to explode. It's always the simple things.


I still have to look into what you said, diwako. It still baffles me that placing "demoCharg_F" in the editor causes it to function, yet spawning it via script does not. It must, at some point during the mission initialisation, convert the explosive to a functional config class.

Share this post

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now