-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optimize player events #1289
optimize player events #1289
Conversation
old 0.0305623 ms |
Updated documentation with the new events and new passed arguments.Available events
["unit", {
params ["_newUnit", "_oldUnit"];
systemChat str "Unit changed.";
}, true] call CBA_fnc_addPlayerEventHandler;
["weapon", {
params ["_unit", "_newWeapon", "_oldWeapon"];
systemChat str "Weapon changed.";
}, true] call CBA_fnc_addPlayerEventHandler;
["muzzle", {
params ["_unit", "_newMuzzle", "_oldMuzzle"];
systemChat str "Muzzle changed.";
}, true] call CBA_fnc_addPlayerEventHandler;
["weaponMode", {
params ["_unit", "_newWeaponMode", "_oldWeaponMode"];
systemChat str "Weapon Mode changed.";
}, true] call CBA_fnc_addPlayerEventHandler;
["loadout", {
params ["_unit", "_oldUnitLoadout", "_newLoadout"];
systemChat str "Inventory changed.";
}, true] call CBA_fnc_addPlayerEventHandler;
["vehicle", {
params ["_unit", "_newVehicle", "_oldVehicle"];
systemChat str "Vehicle changed.";
}, true] call CBA_fnc_addPlayerEventHandler;
["turret", {
params ["_unit", "_newTurret", "_oldTurret"];
systemChat str "Turret changed.";
}, true] call CBA_fnc_addPlayerEventHandler;
["featureCamera", {
params ["_unit", "_newCamera"];
systemChat str "Camera changed.";
}, true] call CBA_fnc_addPlayerEventHandler;
["cameraView", {
params ["_unit", "_newCameraMode", "_oldCameraMode"];
systemChat str "Camera Mode changed.";
}, true] call CBA_fnc_addPlayerEventHandler;
["visionMode", {
params ["_unit", "_newVisionMode", "_oldVisionMode"];
systemChat str "Vision Mode changed.";
}, true] call CBA_fnc_addPlayerEventHandler;
["visibleMap", {
params ["_unit", "_isMapShown"];
systemChat str "Map opened or closed.";
}, true] call CBA_fnc_addPlayerEventHandler;
["group", {
params ["_unit", "_oldGroup", "_newGroup"];
systemChat str "Group changed.";
}, true] call CBA_fnc_addPlayerEventHandler;
["leader", {
params ["_unit", "_oldLeader", "_newLeader"];
systemChat str "Group Leader changed.";
}, true] call CBA_fnc_addPlayerEventHandler; |
As talked about in the ACE Slack, the weapon mode event should also trigger on the switch from Pistol/Single -> Rifle/Single, as well as Rifle/Single -> GL/Single. Same for the muzzle event, but it is hard to come up with an example where pistol and rifle share the same muzzle name, that is not the weapon classname/this and also the primary selected muzzle. Some code to mess around with: ["weaponMode", {
params ["_unit", "_newWeaponMode"];
private _vehicle = vehicle _unit;
private _weapon = currentWeapon _unit;
if !(_unit call CBA_fnc_canUseWeapon) then {
private _turret = _unit call CBA_fnc_turretPath;
_weapon = _vehicle currentWeaponTurret _turret;
};
private _muzzle = currentMuzzle _unit;
private _muzzleConfig = configfile >> "CfgWeapons" >> _weapon;
if (_muzzle != _weapon) then {
_muzzleConfig = _muzzleConfig >> _muzzle;
};
private _muzzleName = getText (_muzzleConfig >> "displayName");
private _weaponModeName = getText (_muzzleConfig >> _newWeaponMode >> "displayName");
systemChat format ["Switched to %1 (%2) fire mode.", _weaponModeName, _muzzleName];
}] call CBA_fnc_addPlayerEventHandler; Best as grenadier with an empty Slammer nearby. |
retested 0.0238209 ms |
Any objections to the changes otherwise? I must say that I like this way more overall. |
adding old to event params is great |
Co-Authored-By: PabstMirror <pabstmirror@gmail.com>
Sadly, group, leader and loadout report <unit,old,new>, while the others report <unit,new,old>. I must've fucked up sometime in the past. |
Co-Authored-By: Dedmen Miller <dedmen@users.noreply.github.com>
Added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
When merged this pull request will:
muzzle
,weaponMode
andturretWeapon
player events