Page MenuHomeFeedback Tracker

[Feature Request] WeaponChanged and MagazineChanged eventhandler
Feedback, NormalPublic

Description

atm one has to do this in an expensive perFrame previous vs current check.
having an efficient EH would alllow also more systems as result.

params ["_unit","_weaponPrevious","_weaponNew"];
params ["_unit","_weaponPrevious","_weaponNew","_vehicle","_turret"];//for vehicles

Potentially also useful (not sure only previous or also both):

muzzle: String - muzzle
mode: String - current mode of the weapon
ammo: String - ammo

For MagazineChanged probably same setup useful with only weapon in addition

Details

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

Event Timeline

h- added a subscriber: h-.Jan 14 2024, 4:30 PM
dedmen set Ref Ticket to AIII-56205.EditedJan 17 2024, 7:00 PM
dedmen added a subscriber: dedmen.

@dedmen the link is to this ticket itself?

https://feedback.bistudio.com/T177742 because Magazine is also a WeaponSlotItem

params ["_unit","_weaponPrevious","_weaponNew"];

what would you imagine the weapons to be?
In code I have the weapon index. Do you want classnames?

Will this trigger on mode and muzzle change too? Perhaps all 3 can be included somehow.

UNIT, PREVIOUS_STATE, NEW_STATE?

where *_STATE is weapon+muzzle+mode?

params ["_unit","_weaponPrevious","_weaponNew","_vehicle","_turret"];//for vehicles

The first value is always the thing the eventhandler was added to.
If you want to get vehicle weapon changes, you need to add the handler to the vehicle.
Which will give you

params ["_unit","_weaponPrevious","_weaponNew","_turret"];

Adding the handler to the unit sitting in a vehicle, won't fire for the vehicle's turret weapon being changed.

Will this trigger on mode and muzzle change too? Perhaps all 3 can be included somehow.

Actually yes, I get the muzzle index. But I don't know of a scripted way to turn the index into mode/name.
https://community.bistudio.com/wiki/ArmA:_Armed_Assault:_Actions#SWITCHWEAPON

So do we need to add extra parameters for mode/muzzle too?
That would be somewhat performance annoying :/

IFV-6A Cheetah toggle gunner weapons
EH owner, prev, new, prevMode, newMode, prevMuzzle, newMuzzle, turretIndex

[B Alpha 1-1:3 (dedmen),"autocannon_35mm","missiles_titan_AA","manual","Player","autocannon_35mm","missiles_titan_AA",[0]]
[B Alpha 1-1:3 (dedmen),"missiles_titan_AA","autocannon_35mm","Player","manual","missiles_titan_AA","autocannon_35mm",[0]]

MX 3GL firemode switch

[B Alpha 1-1:1 (dedmen),"arifle_MX_GL_ACO_F","arifle_MX_GL_ACO_F","Single","FullAuto","arifle_MX_GL_ACO_F","arifle_MX_GL_ACO_F"]
[B Alpha 1-1:1 (dedmen),"arifle_MX_GL_ACO_F","arifle_MX_GL_ACO_F","FullAuto","Single","arifle_MX_GL_ACO_F","GL_3GL_F"]
[B Alpha 1-1:1 (dedmen),"arifle_MX_GL_ACO_F","arifle_MX_GL_ACO_F","Single","Single","GL_3GL_F","arifle_MX_GL_ACO_F"]

Pistol and back

[B Alpha 1-1:1 (dedmen),"arifle_MX_GL_ACO_F","hgun_P07_F","Single","Single","arifle_MX_GL_ACO_F","hgun_P07_F"]
[B Alpha 1-1:1 (dedmen),"hgun_P07_F","arifle_MX_GL_ACO_F","Single","Single","hgun_P07_F","arifle_MX_GL_ACO_F"]

We don't really need newWeapon, newMode, newMuzzle. Because you can just use the currentWeapon/currentWeaponMode/currentMuzzle script commands?
But I guess if you want this EH, then you do want to have this information and running the commands manually would be slower.

Instead of 6/7 element array, I could make the prev/new state sub-arrays. But that just decreases performance more.

The EH itself should not trigger frequently - in regards to performance.

How does the engine performance decrease amount vs sqf command use? (getters or setter + setVar&getVar for caching)

Adding one element to an array that already exists anyway, is much much much cheaper than executing a SQF command that looks up the weapon and returns the result.
Yeah it should be somewhat rare, also not many objects will have the EH added anyway. So we'll just leave the many args.

This EH can be added to all objects, also remote. I have not tested how it behaves in multiplayer though.
MP behavior is the same as https://community.bistudio.com/wiki/currentWeapon https://community.bistudio.com/wiki/currentWeaponMode https://community.bistudio.com/wiki/currentMuzzle
Which.. all have no multioplayer behavior documented :D

the array is always 8 elements, but turretPath will be nil if not a vehicle turrets weapon.

With this addition becoming a reality, is there any chance of seeing WeaponSlotItemChanged set up for the magazine half of this request?

I'm looking at WeaponSlotItem/MagazineChanged next

dedmen changed the task status from New to Feedback.May 15 2024, 4:04 PM
SaMatra added a comment.EditedMay 15 2024, 4:39 PM

Haven't tested it yet, does it trigger for countermeasures on vehicles?

I've recently looked into it and right now there is 0 way to control CMs: T181063

You don't switch to the countermeasures weapon. If you mean changing the CM firing mode. Don't know, test it and report back :harold:

Having a Weapon Muzzle Config Event version of the Weapon Changed event handler could prove to be useful in specifying scripts to run only when a specific weapon's muzzles are switched between as opposed to having to listen to every change on a unit and filtering them out.