Page MenuHomeFeedback Tracker

[Feature request] Eventhandler to fire if knowsAbout value changes
Closed, ResolvedPublic

Description

Atm one has constantly check the value to notice a change.
If you want to script things like events or behavior change based on awareness level, this is quite costly - hence a EH hook would be great.

Depending on the underlying engine code different approaches may be the most meaningful [in regards to EH design and parameters]:
+ per unit and all its knownTargets
+ per unit and a specific target unit
+ mission EH for any unit about its knownTargets

Details

Severity
None
Resolution
Open
Reproducibility
N/A
Operating System
Windows 10 x64
Category
Scripting

Event Timeline

Agreed, that would be very helpful and save alot of checks.

From what i was reading about knowsAbout etc. i also thought once that elements of a group would report positions etc. back to group leader, so it was only necessary to check group leaders knowledge about enemies, but that assumption turned out to be wrong. So you really have to gather information from all elements of a group to get a proper overview of known enemies of a group.

That can be pretty expensive especially with many groups, for example when there are many guard towers to populate in a mission.

h- added a subscriber: h-.Oct 20 2021, 7:50 AM

Yes please.
This probably should return things like the knowsAbout value and such? And stuff the command targetKnowledge returns?

Going even further wouldn't mind seeing event for returning the different danger causes that are available only in danger.fsm 🤔

dedmen added a subscriber: dedmen.Nov 15 2021, 6:34 PM

It will only fire where the AI is local, that should be fine right?

From my point of view it would be enough, especially as the followup code usually has to be executed where unit and its group is local anyway.

Tenshi added a subscriber: Tenshi.Nov 18 2021, 1:01 PM

Thank you for requesting the feature.
Due to the current phase of Live Ops development in Arma 3, we cannot commit to any new features, though we will try to consider them.

Tenshi set Ref Ticket to Internal Ref.: AIII-54753.Nov 18 2021, 1:01 PM

From my point of view it would be enough, especially as the followup code usually has to be executed where unit and its group is local anyway.

sorry for disturbing this thread. but i think ron4swat is a former gamingfriend of me and i dont have any possibility to contact him. so ron4swat if you remember me 15 years ago i would be happy to get a message from here. :)

dedmen changed the task status from New to Feedback.EditedFeb 15 2022, 5:18 PM

2.10 adds group eventhandlers with KnowsAboutChanged /*group:group, object:targetUnit, number:newKnowsAbout, number:oldKnowsAbout*/ \
dev branch this or next week

As yesterdays development branch changelog says "Added: Group Event Handlers" i assume its suppossed to work already with this version.

I added the eventhandler to each group with no access. I added a minimal event handler for debugging via

[_group,"knowsAboutChanged",{hint "enemy Detected"}] call BIS_fnc_addScriptedEventHandler;

with no success either.

However i see alot of debugging messages like

Group B Alpha 1-2 sees 11e1a0100# 482246: fridge_01_f.p3d delta 4.000000 now at 4.000000
Group B Alpha 1-2 sees 11e143580# 482247: disinfectantspray_f.p3d delta 4.000000 now at 4.000000
Group B Alpha 1-2 sees 11e141600# 482250: bandage_f.p3d delta 4.000000 now at 4.000000
Group B Alpha 1-2 sees 11e140b80# 482251: bandage_f.p3d delta 4.000000 now at 4.000000
Group B Alpha 1-2 sees 11e140100# 482252: radio.p3d delta 4.000000 now at 4.000000

and some more valid looking (addressing units instead of other objects) like

Group R Delta 1-6 sees bis_o2_12740 delta 0.034301 now at 0.050794
Group R Delta 1-6 sees bis_o2_12740 delta 0.037155 now at 0.087950
Group R Delta 1-6 sees bis_o2_11577 delta 0.017118 now at 0.091382

I also have seen some interesting messages like the one belows, but dozends of them reported in under a second, in that case it were around 50-60 items, all dummy items. Seens they are generated when AI fires, at least their report correlates with such events.

Group R Charlie 4-6 sees 146298100# 476562: dummyitem.p3d delta 0.018078 now at 0.091271
Group R Charlie 4-6 sees 146298b80# 476561: dummyitem.p3d delta 0.018079 now at 0.091264
Group R Charlie 4-6 sees 146299600# 476560: dummyitem.p3d delta 0.018084 now at 0.091275
Group R Charlie 4-6 sees 14bf37580# 476559: dummyitem.p3d delta 0.018084 now at 0.091265
Group R Charlie 4-6 sees 14bf36b00# 476558: dummyitem.p3d delta 0.018084 now at 0.091254

dedmen added a comment.EditedFeb 18 2022, 10:22 AM

The sees messages were debug messages that I forgot to remove
But each f these triggers the "KnowsAboutChanged" handler.

[_group,"knowsAboutChanged",{hint "enemy Detected"}] call BIS_fnc_addScriptedEventHandler;

Scripted? These are not scripted handlers. addEventHandler is what you want.

Leopard20 added a subscriber: Leopard20.EditedFeb 18 2022, 1:03 PM

@dedmen
I think the real question here is:

Group B Alpha 1-2 sees 11e1a0100# 482246: fridge_01_f.p3d delta 4.000000 now at 4.000000
Group B Alpha 1-2 sees 11e140b80# 482251: bandage_f.p3d delta 4.000000 now at 4.000000
Group B Alpha 1-2 sees 11e140100# 482252: radio.p3d delta 4.000000 now at 4.000000
Group R Charlie 4-6 sees 14bf36b00# 476558: dummyitem.p3d delta 0.018084 now at 0.091254

why does the AI even bother to check if non-unit/non-vehicle objects are visible?! The group sees a fridge?! A bandage?! They can't do anything about them anyway, so as far as I see it's just a waste of performance...

Couple more strange ones:

sees DDD: <no shape>

sees DDD: dummyweapon.p3d

sees DDD: campfire_f.p3d
sees DDD: cluttercutter_large_f.p3d
sees DDD: decal_mud_road_1.p3d
sees DDD: decal_mud_road_2.p3d
sees DDD: decal_mud_road_6.p3d
sees DDD: decal_mud_road_7.p3d
sees DDD: dirt_road_damage_long_03_f.p3d
sees DDD: dirtpatch_05_f.p3d
sees DDD: dirtpile_small_house.p3d
sees DDD: shed_10_f.p3d
sees DDD: woodencrate_01_stack_x3_f.p3d
sees DDD: woodencrate_01_stack_x5_f.p3d

sees DDD: virtualsound_01_f.p3d

sees DDD: ww2_ger_ammo.p3d
sees DDD: ww2_ger_weapons.p3d

sees DDD: ww2_gmc353truck.p3d
sees DDD: ww2_gmctruck_repair.p3d
sees DDD: ww2_lefh18.p3d
sees DDD: ww2_mg34_bipod.p3d
sees DDD: ww2_mg42_bipod.p3d
sees DDD: ww2_mgunner.p3d
sees DDD: ww2_opelblitz.p3d
sees DDD: ww2_opelblitz_destruct_back_bort.p3d
sees DDD: ww2_opelblitz_destruct_left_door.p3d
sees DDD: ww2_sdkfz251.p3d
sees DDD: ww2_sdkfz251_2.p3d

sees DDD: ww2_soldier.p3d
sees DDD: ww2_soldier_camo5.p3d
sees DDD: ww2_soldier2.p3d
sees DDD: ww2_soldier3.p3d

also logic groups can see or been seen

Group L Alpha 1-1 sees
Group L Bravo 3-3 sees
Group L Bravo 4-2 sees
Group L Charlie 3-5 sees
Group L Object Modifiers sees
sees L Alpha 1-2:9 delta
sees L Bravo 3-3:1 delta
sees L Bravo 3-3:10 delta
sees L Bravo 3-3:2 delta
sees L Bravo 3-3:3 delta
sees L Bravo 3-3:4 delta
sees L Bravo 3-3:5 delta
sees L Bravo 3-3:6 delta
sees L Bravo 3-3:7 delta
sees L Bravo 3-3:8 delta
sees L Bravo 3-3:9 delta
sees L Bravo 4-2:1 delta
sees L Bravo 4-2:2 delta
sees L Charlie 1-2:1 delta
sees L Charlie 3-5:1 delta
sees L Effects:1 delta
sees L Effects:2 delta
sees L Object Modifiers:1 delta
sees L Object Modifiers:10 delta

They don't check. 4.0 is max value, thats special, they are not checking.

What about these?

Group L Bravo 3-3 sees B Alpha 1-1:3 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees B Alpha 1-1:4 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees B Alpha 1-3:3 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees B Alpha 2-3:1 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees B Alpha 2-5:1 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees B Alpha 4-3:1 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees B Alpha 4-3:4 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees B Alpha 4-4:1 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees B Alpha 4-4:2 delta 1.500000 now at 1.500000
Group L Bravo 3-3 sees B Bravo 2-1:5 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees B Bravo 3-6:3 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees B Bravo 4-3:3 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees B Bravo 4-3:3 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees B Bravo 4-3:3 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees bis_o1 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees bis_o1 delta 1.400000 now at 1.500000
Group L Bravo 3-3 sees R AT Squad:2 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees R AT Squad:4 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees R Mortar Group:2 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees R Mortar Group:2 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees R Mortar Group:3 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees tank1 delta 0.100000 now at 0.100000
Group L Bravo 3-3 sees tank1 delta 1.400000 now at 1.500000
Group L Bravo 3-3 sees tank1 delta 1.500000 now at 1.500000
Group L Bravo 3-3 sees tank1 delta 1.500000 now at 1.500000
Group L Bravo 4-2 sees B Bravo 2-1:4 delta 0.100000 now at 0.100000
Group L Bravo 4-2 sees B Bravo 2-1:5 delta 0.100000 now at 0.100000
Group L Bravo 4-2 sees B Bravo 4-3:3 delta 0.100000 now at 0.100000
Group L Bravo 4-2 sees B Bravo 4-3:3 delta 0.100000 now at 0.100000
Group L Bravo 4-2 sees B Bravo 4-3:3 delta 0.100000 now at 0.100000
Group L Bravo 4-2 sees tank1 delta 0.100000 now at 0.100000
Group L Bravo 4-2 sees tank1 delta 0.100000 now at 0.100000
Group L Bravo 4-2 sees tank1 delta 1.400000 now at 1.500000
Group L Bravo 4-2 sees tank1 delta 1.400000 now at 1.500000
Group L Bravo 4-2 sees tank1 delta 1.500000 now at 1.500000
Group L Charlie 3-5 sees B Bravo 4-3:3 delta 0.100000 now at 0.100000
Group L Charlie 3-5 sees tank1 delta 1.500000 now at 1.500000

Group L Object Modifiers sees B Alpha 4-4:2 delta 0.100000 now at 0.100000
Group L Object Modifiers sees B Alpha 4-4:4 delta 0.100000 now at 0.100000
Group L Object Modifiers sees B Alpha 4-6:2 delta 0.100000 now at 0.100000
Group L Object Modifiers sees R Infantry West:1 delta 0.100000 now at 0.100000
Group L Object Modifiers sees R Mortar Group:3 delta 1.500000 now at 1.500000
Group L Object Modifiers sees R Mortar Group:4 delta 0.100000 now at 0.100000

<no shape> also has an "interesting" value

Group B Bravo 4-3 sees 20e97802080# 632411: <no shape> delta 340282346638528860000000000000000000000.000000 now at 340282346638528860000000000000000000000.000000

They don't check. 4.0 is max value, thats special, they are not checking.

Well still the EH fires for irrelevant objects...

:poutcat:
could filter for only units

Leopard20 added a comment.EditedFeb 18 2022, 7:47 PM

Yeah but my point was more from a performance POV than mere inconvenience.

I think the EH can trigger multiple times per frame (for multiple objects), right?

If so, and if you add this EH to multiple groups, and each EH fires multiple times for irrelevant objects, a lot of performance will be wasted for these objects. I'm sure no one cares if the AI knows about a fridge... :meowsweats:

At least an engine-side filter might be better.

Ron4Swat added a comment.EditedFeb 18 2022, 8:45 PM

[_group,"knowsAboutChanged",{hint "enemy Detected"}] call BIS_fnc_addScriptedEventHandler;

Scripted? These are not scripted handlers. addEventHandler is what you want.

My bad. Added it to groups and it works now. I think thats the first event handler for group, because even https://community.bistudio.com/wiki/addEventHandler doesnt event mention groups as option to add events to.

Originally expected the event to be per unit, as even different units of same group often have different knowledge of same target. As units in a group for whatever reason can also be sometimes in different places of a battle (especially with FULL speedmode)

:poutcat:
could filter for only units

I would expect the event to return the same type of objects like for example targetsQuery, which would be only units and vehicles (=anything the vehicles command returns)

Also it can easily getting confusing why the event handler reports about objects that for example targetsQuery does not return.

Yeah but my point was more from a performance POV than mere inconvenience.

I think the EH can trigger multiple times per frame (for multiple objects), right?

I suspect every unit of a group will report their knowsAbout changes to the group, so there are often multiple updates about same target for each group, often with same changes.

If so, and if you add this EH to multiple groups, and each EH fires multiple times for irrelevant objects, a lot of performance will be wasted for these objects.

It doesn't do any extra checking in order to fire the EH. But yes if you have a handler attached it wasted performance by calling it. I'll add a filter that only units/vehicles get detected... though vehicles is hard 😓 as houses are also vehicles.

I think thats the first event handler for group, because even https://community.bistudio.com/wiki/addEventHandler doesnt event mention groups as option to add events to.

There are many group eventhandlers, noone found the time yet to update the wiki, its brand new.

as even different units of same group often have different knowledge of same target.

Can't be, knowsAbout command returns knowledge of the group, not the unit.
The same thing that the event reports, is what knowsAbout command also uses.

I suspect every unit of a group will report their knowsAbout changes to the group, so there are often multiple updates about same target for each group, often with same changes.

The EH only triggers if the value changed more than 0.001, so when multiple units send the same value (which they don't) it would only trigger once.

Ron4Swat added a comment.EditedFeb 19 2022, 2:30 AM

I'll add a filter that only units/vehicles get detected... though vehicles is hard 😓 as houses are also vehicles.

If i'm not mistaken houses are only vehicles when placed in the editor and also only returned with vehicles command in this cases, at least on scripting side of things, this might be different internally.

I would say its reasonable that the event would also report these "vehicles" as other commands like targetsQuery and vehicles already do. It certainly would be preferable if normal objects that are no vehicles in that sense are filtered out.

As all the non vehicle objects are already detected fully on first sight, they will be only reported once, so even in the current state the performance problem is not as much of an issue as it first seemed.

Leopard20 added a comment.EditedFeb 19 2022, 7:30 AM

As all the non vehicle objects are already detected fully on first sight, they will be only reported once, so even in the current state the performance problem is not as much of an issue as it first seemed.

You still have to filter them out yourself in SQF, which is relatively slow. You're only thinking of those non vehicle objects, but your filter will still be in effect for actual targets too.
If the EH trigger is pre-filtered you don't have to do anything. The EH will only trigger for actual targets.

though vehicles is hard 😓 as houses are also vehicles.

Basically I mean any object that you can mount. (has driver/gunner/etc. seats)
I don't think there are any other objects that can be a threat to (and thus engaged by) the AI...?

Ron4Swat added a comment.EditedFeb 19 2022, 9:07 AM

You still have to filter them out yourself in SQF, which is relatively slow. You're only thinking of those non vehicle objects, but your filter will still be in effect for actual targets too.
If the EH trigger is pre-filtered you don't have to do anything. The EH will only trigger for actual targets.

There has to be some script side filtering anyways, as the event reports changes in knowledge about friendly and enemy units/vehicles. Its not only about enemy targets. Even civilian groups are receiving events about "targets".

Basically I mean any object that you can mount. (has driver/gunner/etc. seats)
I don't think there are any other objects that can be a threat to (and thus engaged by) the AI...?

There are other interesting use cases beside direct threats to AI. For example if you want react to the fact that AI has detected some other object that is no threat, that you placed on the terrain, like supply boxes etc., which would be technically a vehicle that would also be reported through targetsQuery.

There has to be some script side filtering anyways, as the event reports changes in knowledge about friendly and enemy units/vehicles. Its not only about enemy targets. Even civilian groups are receiving events about "targets".

So? Friendly units are targets too. I never said "enemies". Plus a simple side check is nothing compared to a config check to detect what the object actually is.

react to the fact that AI has detected some other object that is no threat, that you placed on the terrain, like supply boxes etc.

That could be useful. But completely useless props should obviously be filtered.

I don't think there are any other objects that can be a threat to (and thus engaged by) the AI...?

UAV's, though technically they have a seat, you just can't mount them

@Leopard20 @Ron4Swat can this be closed? maybe open new tickets for the remaining issues/additions?

From my POV it can be closed.

kju-PvPscene closed this task as Resolved.Feb 8 2024, 2:50 PM
kju-PvPscene claimed this task.