Crowdedlight / Crows-Electronic-Warfare

Arma 3 Mod that enables electronic warfare features such as Radio/Drone jamming and spectrum signal tracking
https://crowdedlight.github.io/Crows-Electronic-Warfare/
Other
19 stars 7 forks source link

Lambs AI integration #43

Open SewerynRoznowski opened 2 years ago

SewerynRoznowski commented 2 years ago

Hi.

I have been working on splicing Crows Electronic Warfare with Lambs AI for my Arma group.
The intent is to use event handlers from Lambs AI to dynamically create signal sources. Allowing players to gather intel on AI actions or triangulate AI artillery positions for counterbattery fire.
Overview of Lambs AI event handlers can be found here: https://github.com/nk3nny/LambsDanger/wiki/Event-handlers

As proof of concept, I made a very simple script that creates a signal source when AI calls for artillery support.
It creates a signal source on the artillery caller for 15 seconds to simulate a call for support.
It then creates a signal source on the artillery gun to simulate a reply from the support provider.

This goes into missions initserver.sqf to create the event handler:

["lambs_danger_OnArtilleryCalled", {
     params ["_unitThatCalledArtillery", "_groupOfUnit", "_ArtilleryGun", "_TargetPosition "];
     [_unitThatCalledArtillery, _groupOfUnit, _ArtilleryGun, _TargetPosition] execVM "Scripts\EW\ewcallarty.sqf";
}] call CBA_fnc_addEventHandler;

This is the script executed by the eventhandler:

params ["_unitThatCalledArtillery", "_groupOfUnit", "_ArtilleryGun", "_TargetPosition"];

// debugging hint
hint format ["%1, %2, %3, %4", _unitThatCalledArtillery, _groupOfUnit, _ArtilleryGun, _TargetPosition];

// Simulate arty being called in
["crowsEW_spectrum_addbeacon", [_unitThatCalledArtillery, 225, 1000, "chatter"]] call CBA_fnc_globalEvent;
sleep 15;
["crowsEW_spectrum_removebeacon", [_unitThatCalledArtillery]] call CBA_fnc_globalEvent;

// simulate reply from arty 
["crowsEW_spectrum_addbeacon", [_ArtilleryGun, 225, 1000, "chatter"]] call CBA_fnc_globalEvent;
sleep 15;
["crowsEW_spectrum_removebeacon", [_ArtilleryGun]] call CBA_fnc_globalEvent;

It is currently really crude but offers interesting gameplay options.

Full implementation would require more specific voice lines for specific situations.

SewerynRoznowski commented 2 years ago

Alternatively, having a way to select a sound file defined outside the spectrum addon would allow for mission makers to add their own sounds and create this functionality using a mission script or standalone addon.

In fnc_spectrumDeviceMouseDown.sqf. line 56 Would adding a default case which plays _sound = _type work? This would allow other addons and mission makers to create beacons with custom sound by using:

["crowsEW_spectrum_addbeacon", [ _unit, _frequency, _scanRange, "CustomSoundClassName"]] call CBA_fnc_globalEvent;

SewerynRoznowski commented 2 years ago

Actually, now that looked into it. I should be able to add custom voice packs by adding to crowsEW_spectrum_voiceLinePacks and defining the classes for the different sounds in missionfile.

Crowdedlight commented 2 years ago

Interesting findings. I like the seemingly simple automatic interaction with lambs for arty fire missions. I will consider implementing it when I get more time. As the mod's goal is to give zeus/mission-maker new tools to use, it would have to be implemented so zeus can "turn it off/on" depending on need for the mission, and only loaded and available when lambs is loaded. To limit unnessecery performance hits. Due to lambs requirement its not so widely applicable, but still a rather cool interaction!

In regards to the custom voice-lines, yes, you can add custom through the mission. It does require the sounds used are defined in a cfgSounds block with the path, name and volume. You can see how I do that here: https://github.com/Crowdedlight/Crows-Electronic-Warfare/blob/main/addons/spectrum/CfgSoundsBritish.hpp

Then you would need to make an array of the sounds in the custom voicepack, and an array of equal length of the weight of each sound. (weight can be changed from 1, to make certain sounds more rare than others). You can see how I do that in the postInit event here: https://github.com/Crowdedlight/Crows-Electronic-Warfare/blob/main/addons/spectrum/XEH_preInit.sqf#L155-L177

Then finally add it to the voice-pack array as seen here: https://github.com/Crowdedlight/Crows-Electronic-Warfare/blob/main/addons/spectrum/XEH_preInit.sqf#L182

Then it should automatically be an option as a voicepack if using the radio chatter module.

For using it specific in scripting for specific voicelines, you need to set the variable on the unit to the voice-pack when using the "chatter" option. Otherwise you might get script error, and the sound would definitely not play ;-)

Doing it like this, with a voicepack defined as customPack as described above, should work.

_unit setVariable["crowsEW_spectrum_radioChatterVoicePack", "customPack", true];
["crowsEW_spectrum_addbeacon", [_unitThatCalledArtillery, 225, 1000, "chatter"]] call CBA_fnc_globalEvent;

from: https://github.com/Crowdedlight/Crows-Electronic-Warfare/blob/main/addons/spectrum/functions/fnc_addRandomRadioTrackingChatterServer.sqf#L81

You can see where it "reads" what voicepack to play based on the unit variable here: https://github.com/Crowdedlight/Crows-Electronic-Warfare/blob/main/addons/spectrum/functions/fnc_spectrumDeviceMouseDown.sqf#L68