SimConnect_ReportWeaponDamaged() is not working? SimObject API

For topics related to the creation of simulation objects (SimObjects). This includes development of aircraft, ground, and maritime vehicles.
zamirk
Posts: 85
Joined: Mon Jul 21, 2014 8:39 am

SimConnect_ReportWeaponDamaged() is not working? SimObject API

Postby zamirk » Wed Jan 11, 2017 7:59 am

hi everyone,

i am working on Missile SimObject API, and start with Missile Sample Code for SimObject API, So i have an issue with SimConnect "WeaponDetonated" event which is not call when weapon destroyed or collide with target objects.

i found this sample code for reporting to simconnect about Weapon Detonation :

Code: Select all

SIMCONNECT_DATA_OBJECT_DAMAGED_BY_WEAPON WeaponDamageData = { missileID, attackerID, targetID };
SimConnect_ReportWeaponDamaged(g_hSimConnect, WeaponDamageData); 


and also handle multiple Weapon Events in SimConnect Dispatch function like WEAPON_FIRED_EVENT and WEAPON_DETONATED_EVENT, when i fire missile than WEAPON_FIRED_EVENT successfully call but when missile hit the targets or hit to the ground than WEAPON_DETONATED_EVENT not call in SimConnect?

Any one from LM?

Thanks

Clifton Crane
Lockheed Martin
Posts: 755
Joined: Tue Sep 25, 2012 2:34 pm

Re: SimConnect_ReportWeaponDamaged() is not working? SimObject API

Postby Clifton Crane » Wed Jan 11, 2017 3:06 pm

Hi zamrik,

The WEAPON_FIRED_EVENT is issued by the native WeaponsSystemManager whereas the WEAPON_DETONATED_EVENT is issued by the native Weapon SimObject. This is why you see the WEAPON_FIRED_EVENT but not the WEAPON_DETONATED_EVENT.

You might want to try using the RegisterOnSimObjectRemoveCallback function from the ISimObjectManager. Upon your weapon detonating or colliding and being removed, you would be able to query a custom interface that you would implement to provide the information required (i.e. target, position, etc.).

On a side note, in a future release the WEAPON_FIRED_EVENT will be issued by the native Weapon SimObject rather than the native WeaponSystemManager. To work around this event not being issued for an ISimObject, you might want to query all objects that implement the IWeaponService and check the return value of the IsAttachedToOwner function to monitor fired events.
Clifton Crane
Prepar3D® Software Engineer

zamirk
Posts: 85
Joined: Mon Jul 21, 2014 8:39 am

Re: SimConnect_ReportWeaponDamaged() is not working? SimObject API

Postby zamirk » Thu Jan 12, 2017 4:06 am

Hi Clifton,

Thanks for your guidance, will be back if there is any issue.

Regards,
Zamirk

zamirk
Posts: 85
Joined: Mon Jul 21, 2014 8:39 am

Re: SimConnect_ReportWeaponDamaged() is not working? SimObject API

Postby zamirk » Thu Jan 12, 2017 5:34 am

Hi Clifton,

i analyse your message and P3d documentation, i found that by using your approach we can notify detonation of Missile in same Missile SimObject Code (Missile.dll) by using RegisterOnSimObjectRemoveCallback() for callback funstion registration and creating callback function which will notify after detonated.

But my problem is that i have another application which implement's SimConnect SDK for communication with P3d, in this application i handle all weapon events like Fired and Detonated. Before working on SimObject API i was using your built in Weapons/Missiles, so i handle these events (FIRED, DETONATED) in this Simconnect application these events successfully notified when your built in missile fired or detonated.

Now i am working on SimObject API for Missile's and remove built in Missile's and i want that when missile destroy than it should notify Weapon Detonation in my SimConnect Application, means i want Weapon Detonation will notify to Simconnect.

Thanks.

zamirk
Posts: 85
Joined: Mon Jul 21, 2014 8:39 am

Re: SimConnect_ReportWeaponDamaged() is not working? SimObject API

Postby zamirk » Thu Jan 19, 2017 6:47 am

hi,
Any from from LM?
who can help me to solve my problem, i am confusing how i can generate/trigger event in SimConnect
when my Missile SimObject destroy?

Thanks

Clifton Crane
Lockheed Martin
Posts: 755
Joined: Tue Sep 25, 2012 2:34 pm

Re: SimConnect_ReportWeaponDamaged() is not working? SimObject API

Postby Clifton Crane » Thu Jan 19, 2017 4:51 pm

Hello,

There is currently no way to trigger the SimConnect event externally. The event is only fired by the core simulation.
Clifton Crane
Prepar3D® Software Engineer

zamirk
Posts: 85
Joined: Mon Jul 21, 2014 8:39 am

Re: SimConnect_ReportWeaponDamaged() is not working? SimObject API

Postby zamirk » Thu Jan 26, 2017 6:18 am

Hi Clifton,

Thanks for your guidance, i found there is an Option in SimObject API to register event's, so i am using this functionality to register Weapon_Detonated event in Missile SimObject API Sample, so it is possible to trigger this Weapon_Detonated event in SimConnect?
Is possible, then how? because i found there is no documentation about this.

Regards,
Zamirk

Clifton Crane
Lockheed Martin
Posts: 755
Joined: Tue Sep 25, 2012 2:34 pm

Re: SimConnect_ReportWeaponDamaged() is not working? SimObject API

Postby Clifton Crane » Thu Jan 26, 2017 3:19 pm

Hi Zamirk,

Yes, ISimObject registered properties can be get, set, and triggered by using the SimConnect_SetDataOnSimObject function in same way as SimVars. You would likely want to register both get and set functions for the registered property.

From ISimObject.h:
RegisterProperty - Get

Code: Select all

STDMETHOD (RegisterProperty) (__in LPCWSTR pszPropertyName, __in LPCWSTR pszPropertyBaseUnits, __in __notnull PPropertyCallback pcbProperty) PURE; //double "get"
RegisterProperty - Set

Code: Select all

STDMETHOD (RegisterProperty) (__in LPCWSTR pszPropertyName, __in LPCWSTR pszPropertyBaseUnits, __in __notnull PEventCallback pcbEvent, __in EVENTTYPE eType) PURE; //double "set"
Clifton Crane
Prepar3D® Software Engineer

zamirk
Posts: 85
Joined: Mon Jul 21, 2014 8:39 am

Re: SimConnect_ReportWeaponDamaged() is not working? SimObject API

Postby zamirk » Tue Jan 31, 2017 5:08 am

Hi @Clifton,

Thanks for your guidance, i got it your point.


Return to “Simulation Object Development Questions”

Who is online

Users browsing this forum: No registered users and 1 guest