VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Add Task Interaction (addTaskInteraction)

Table of Contents

The Add Task Interaction example demonstrates how to add support for a new interaction to task a VR-Forces entity.

For example, the NETN FOM has a module called the ETR (Entity Tasking and Reports) module which includes many interactions designed to send tasks or set requests to entities. VR-Forces supports a limited subset of these tasks, but it does not have full support. Additionally, users with other FOMs, or even custom DIS interactions, that offer similar capabilities may want to expand the ability of VR-Forces to process these messages. This example shows how to convert such an interaction into a VR-Forces task or set request message.

Registering a Conversion Function

This example registers a new conversion function with the DtVrlinkCommandInteractionTranslator. This class is responsible for translating incoming interactions into VRF tasks and set requests. If the Translator has a conversion function that matches an received interaction, it will call the conversion function to perform translation. The conversion function must then output a list containing one or more DtEvent instance. Most commonly these are a single DtTaskEvent and/or one or more DtSetEvent.

This particular example adds some support for the NETN ETR FireAtEntityWM interaction. This interaction represents a task for one entity to fire at another using a specified weapon, munition, quantity of rounds, and rate of fire. This example does not support all parameters, but it uses the specified munition type to select an appropriate weapon which will be fired the specified number of times. The rate of fire and weapon type are ignored.

How to Run the Example

This plugin only enables the VR-Forces sim engine to process the FireAtEntityWM interaction. To see this behavior, you will also need a remote application to send this interaction. The remoteControl example has an additional command that will send this interaction. This remoteControl example command will only have an effect when the sim is loaded with the addTaskInteraction plugin.

Usage

In the Launcher:

  1. Choose an HLA 1516 Evolved protocol configuration.
  2. Set the addTaskInteraction plug-in to load.
  3. Start VR-Forces.

To view the new behavior:

  1. Load the addTaskInteraction developer toolkit example scenario
  2. Notice that two F/A-18 aircraft are created, one friendly and one opposing.
  3. Run the scenario.
  4. Start the remoteControl example application. See the documentation on this example for more information.
  5. In the remoteControl example, type the following: etrfireat Blue Red "2:1:225:1:1:3:0" 2
  6. Watch the friendly F/A-18 fire two Sidewinder missiles at the opposing aircraft.

Code

/*******************************************************************************
** Copyright (c) 2025 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
//VR-Forces includes
#include <vrfcgf/cgf.h>
using namespace makVrf;
DtVrlinkCommandInteractionTranslator::EventList netnEtrFireAtEntityWMConverter(
const DtInteraction* inter, DtCommunicationManager* commMgr);
extern "C" {
{
info.pluginName = "addTaskInteraction";
info.pluginDescription = "Example showing how to receive a new interaction and map it to a VR-Forces task.";
info.pluginVersion = "1.00";
info.pluginCreator = "MAK Technologies";
info.pluginCreatorEmail = "support@mak.com";
info.pluginContactWebPage = "www.mak.com";
info.pluginContactMailingAddress = "10 Fawcett Street, Suite 204, Cambridge, MA 02138 USA";
info.pluginContactPhone = "(617) 876 8085";
}
DtExerciseConn* theExConn = 0;
DT_VRF_DLL_PLUGIN bool DtPostInitializeVrfPlugin(DtCgf* cgf)
{
// Find the exercise connection from the communications manager's VR-Link communication interface
if (vrlinkInterface)
{
// Find the command interaction translator, which is responsible for translating task (and set)
// interaction events.
if (translator)
{
// Remove the conversion function
translator->addConversionFunction<DtTaskFireAtEntityWMInter>(netnEtrFireAtEntityWMConverter);
}
}
return true;
}
DT_VRF_DLL_PLUGIN void DtUnloadVrfPlugin(DtCgf* cgf)
{
if (vrlinkInterface)
{
if (translator)
{
// Remove the conversion function
}
}
}
}
// This conversion function will be called whenever VR-Forces receives the interaction specified
// by the class DtTaskFireAtEntityWMInter. This class is a VR-Link extension to handle the NETN
// ETR FireAtEntityWM interaction class. If you want to add a new interaction class not yet
// supported by VR-Link or any of its extensions in VR-Forces, you will also need to develop your
// own VR-Link interaction class to support it.
DtVrlinkCommandInteractionTranslator::EventList netnEtrFireAtEntityWMConverter(
const DtInteraction* inter, DtCommunicationManager* commMgr)
{
// Some task interactions require the generation of a task as well as some set requests.
// As a result, the conversion function can return a list of events. This list should only
// contain a single task for the tasked entity (unless the tasks do not conflict with one another),
// because the entity will try to run any specified tasks immediately, and concurrently.
const DtTaskFireAtEntityWMInter* taskInter = static_cast<const DtTaskFireAtEntityWMInter*>(inter);
if (taskInter)
{
DtUUID entity(taskInter->taskee());
DtUUID target(taskInter->target());
if (entity.isValid() && target.isValid())
{
DtScriptedTaskTask fireAtTask;
fireAtTask.setScriptId("fire_at_with_munition");
locRef.setObjectLocation(target);
fireAtTask.setValue("targetLocRef", locRef, DtRwLocationReferenceType);
fireAtTask.setValue("numberOfRounds", taskInter->quantityFired());
// The default VRF fire tasks have no way to indicate rate of fire. This could be done
// with a new Lua script, but for this example we will ignore the RateOfFire parameter.
// There is no good mapping between a weapon type and VRF weapon system. Instead, this
// converter will rely solely on the munition type. Each weapon system will be able to
// fire only certain munition types. The fire_at_with_munition task finds a system that
// is capable of firing the selected munition type (if one exists), and uses that to
// perform the task.
fireAtTask.setValue("munitionType", taskInter->munitionTypeToUse());
fireAtTask, entity)));
}
else
{
DtWarn << "Received a NETN ETR FireAtEntityWM task without a valid taskee or target." << std::endl;
}
}
return result;
}

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)