Skip to content
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

add cartridge ejection effect on repeat #1158

Merged
merged 5 commits into from
Jun 15, 2019
Merged

Conversation

commy2
Copy link
Contributor

@commy2 commy2 commented Jun 10, 2019

When merged this pull request will:

  • In Arma, the cartridge ejection effect is created once the weapon is fired.
  • This of course is not making sense for weapons that have to be repeated manually.
  • This engine side effect can be removed by setting the config entry cartridge in CfgAmmo of the fired projectile to the empty string.
  • We can script in our own effect on repetition of the weapon with vector magic.
  • The supplied config entries in the CBA_weaponEvents subclass of the weapon class are:

cartridgeType - CfgVehicles class particle effect. Example FxCartridge_556 or FxCartridge_762. If this string is undefined (default) or "", this scripted effect will not be created.
cartridgeEjectPosition - Position where the cartridge is created relative to model center of the weapon ([0,0,0]). x - forward (firing direction), y - right, z - up
cartridgeEjectVelocity - Velocity of ejected cartridge in weapon model space. x - forward, y - right, z - up; vector length is speed in m/s.
cartridgeEjectDelay - Delay in seconds that has to pass after repeating started for the cartridge to eject (time it takes to open the chamber in the repeat animation).

Nomenclature:

  • Repeat: Ejecting chamber and putting in new round. The last round can be ejected, but this is not repetition, as there is no round to put in. Neither is loading a magazine repetition.
  • Reload: Putting in a new magazine into the weapon. There has to be a magzine change otherwise it is just repetition. I don't care about gun nuttery; this is the syntax that makes the most sense to implement this behavior into the video game, so please spare me.

@commy2 commy2 added the Feature label Jun 10, 2019
@commy2 commy2 added this to the 3.12 milestone Jun 10, 2019
@commy2 commy2 added the WIP label Jun 10, 2019
@commy2
Copy link
Contributor Author

commy2 commented Jun 10, 2019

cartridgeEjectPosition or cartridgeEjectionPosition?

@commy2
Copy link
Contributor Author

commy2 commented Jun 10, 2019

Script to find cartridgeEjectPosition offset:

_offset = [-0.02,0.01,0.02];

["cba_debug", "onEachFrame", {
    params ["_unit", "_weapon", "_pos"];
    private _aim = _unit modelToWorldVisualWorld (_unit selectionPosition "aimPoint");
    private _cam = _unit modelToWorldVisualWorld (_unit selectionPosition "camera");
    private _up = _aim vectorFromTo _cam;

    private _wDir = _unit weaponDirection _weapon;
    private _wLat = vectorNormalized (_wDir vectorCrossProduct _up);
    private _wUp = _wLat vectorCrossProduct _wDir;

    private _origin = _unit modelToWorldVisualWorld (_unit selectionPosition "proxy:\a3\characters_f\proxies\weapon.001") vectorAdd
        (_wDir vectorMultiply _pos#0) vectorAdd
        (_wLat vectorMultiply _pos#1) vectorAdd
        (_wUp  vectorMultiply _pos#2);

    drawLine3D [ASLToAGL _origin, ASLToAGL (_origin vectorAdd _wDir), [1,0,0,1]];
    drawLine3D [ASLToAGL _origin, ASLToAGL (_origin vectorAdd _wLat), [0,1,0,1]];
    drawLine3D [ASLToAGL _origin, ASLToAGL (_origin vectorAdd _wUp), [0,0,1,1]];
}, [player, currentWeapon player, _offset]] call BIS_fnc_addStackedEventHandler;

I recommend adding 0.1 (10cm) to the Y coordinate (right), because of rendering issues with creating objects with velocity (may be drawn slightly in negative velocity direction from their actual position, presumably due to timing differences in simulation and draw frames).

@commy2 commy2 removed the WIP label Jun 10, 2019
@commy2 commy2 merged commit 6a42995 into master Jun 15, 2019
@commy2 commy2 deleted the weaponEventsCartridgeEject branch June 15, 2019 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants