Git Product home page Git Product logo

Comments (5)

10Dozen avatar 10Dozen commented on August 28, 2024

I can reproduce, but don't know why this happens. CUP Weapons didn't update from Dec 2021.

For optics that supports both 2d and 3d MRT Switch scheme is the same bi-directional 2D <-> 3D and one-directional PIP -> 3D (2D switches to PIP variant by CBA logic).

Configs related to M145 scopes (2d (default), PIP and 3D variant):

// 2D variant (default)
class CUP_optic_ElcanM145: ItemCore
{
	scope = 2;
	weaponInfoType = "CBA_ScriptedOptic";
	class CBA_ScriptedOptic
	{
		reticleTexture = "\CUP\Weapons\CUP_Weapons_West_Attachments\Elcan_M145\data\elcan_m145w_reticle_ca.paa";
		reticleTextureNight = "\CUP\Weapons\CUP_Weapons_West_Attachments\Elcan_M145\data\elcan_m145w_reticle_n_ca.paa";
		reticleTextureSize = 1;
		manualReticleNightSwitch = 1;
		bodyTexture = "\CUP\Weapons\CUP_Weapons_West_Attachments\Elcan_M145\data\body\elcan_m145w_body_ca.paa";
		bodyTextureNight = "\CUP\Weapons\CUP_Weapons_West_Attachments\Elcan_M145\data\body\elcan_m145w_body_night_ca.paa";
		bodyTextureSize = 1.95;
	};
	MRT_SwitchItemNextClass = "CUP_optic_ElcanM145_3D";
	MRT_SwitchItemPrevClass = "CUP_optic_ElcanM145_3D";
	MRT_switchItemHintText = "$STR_CUP_dn_OpticsMode_2D";
};

// PIP variant
class CUP_optic_ElcanM145_PIP: CUP_optic_ElcanM145
{
	author = "$STR_CUP_AUTHOR_STRING";
	scope = 1;
	class ItemInfo: ItemInfo
	{
		modelOptics = "\x\cba\addons\optics\cba_optic_big_pip.p3d";
	};
	MRT_SwitchItemNextClass = "CUP_optic_ElcanM145_3D";
	MRT_SwitchItemPrevClass = "CUP_optic_ElcanM145_3D";
	MRT_switchItemHintText = "$STR_CUP_dn_OpticsMode_2D";
};

// 3D variant
class CUP_optic_ElcanM145_3D: ItemCore
{
	author = "$STR_CUP_AUTHOR_STRING";
	dlc = "CUP_Weapons";
	scope = 1;
	inertia = 0.1;
	MRT_SwitchItemNextClass = "CUP_optic_ElcanM145";
	MRT_SwitchItemPrevClass = "CUP_optic_ElcanM145";
	MRT_switchItemHintText = "$STR_CUP_dn_OpticsMode_3D";
};

from cba_a3.

10Dozen avatar 10Dozen commented on August 28, 2024

After some testing:

  • When 'Use PIP optics' option is disabled - 2D -> 3D switch works fine.

  • When PIP optics enabled - direct call of actual switch code works perfectly fine:

    [{
    params ["_unit", "", "_switchItem"];
    _unit addPrimaryWeaponItem _switchItem;
    ["CBA_attachmentSwitched", _this] call CBA_fnc_localEvent;
    }, [_unit, _currItem, _switchItem, _currWeaponType]] call CBA_fnc_execNextFrame;
    )

  • But direct call of [2, "next"] call CBA_accessory_fnc_switchAttachment; is buggy for some reason. However if exec call twice - in current and next frame - it works:

[2, "next"] call CBA_accessory_fnc_switchAttachment;
[{ [2, "next"] call CBA_accessory_fnc_switchAttachment; }] call CBA_fnc_execNextFrame;

Looks like there was a change in accessory functions in #1595.

Tried older version of the CBA_accessory_fnc_switchAttachment - https://raw.githubusercontent.com/CBATeam/CBA_A3/953cdfe1ff97c17c6e2fbcfa4a98dfaf81fdbf8e/addons/accessory/fnc_switchAttachment.sqf - and it works good, but i can't tell why :)

from cba_a3.

10Dozen avatar 10Dozen commented on August 28, 2024

Something is wrong with this part:

if (_configs isEqualTo []) then {
_testItem = "";
} else {
_testItem = getText (_configs select 0);
if (_testItem == "") exitWith {};
if (_testItem == _currItem) exitWith { _testItem = ""; }; // same as start (full loop)
private _usageArray = GVAR(usageHash) getOrDefault [_testItem, []];
if ((_usageArray findIf {([_testItem] call _x) isEqualTo false}) == -1) then { // none returned false
_switchItem = _testItem;
};
};

TBH I don't quite understand what is the purpose of entire loop, but in this specific case the next happens:

  1. On first step it finds target class successfully, but as _testItem is not "" - iteration continues
Test item: CUP_optic_ElcanM145_PIP.
Configs found: [bin\config.bin/CfgWeapons/CUP_optic_ElcanM145_PIP/MRT_SwitchItemNextClass].
Configs not empty, test item class: CUP_optic_ElcanM145_3D,
Test against UsageArray passed.
_switchItem = CUP_optic_ElcanM145_3D.
  1. Tests found 3D item and successfully finds 'next' class for it. But again - _testItem is not empty and loop continues
Test item: CUP_optic_ElcanM145_3D.
Configs: [bin\config.bin/CfgWeapons/CUP_optic_ElcanM145_3D/MRT_SwitchItemNextClass].
Configs not empty, test item class: CUP_optic_ElcanM145.
Test against UsageArray passed.,
_switchItem = CUP_optic_ElcanM145.

Due to cyclic scheme of MRT Switch used for CUP scopes - loop continues until reaches execution limit (10000 iterations)

  1. Loop is terminated. Resulting in _switchItem to be "CUP_optic_ElcanM145". After switching, optics handlers replaces 2d scope to PIP variant. From player's perspective nothing was changed at all - the very same scope reamined.

When user is spamming switch button, i guess, sometimes script starts when 2D variant is added, but not yet replaced with PIP variant by optics. So in this case on loop termination - 3D variant is the last one and switch works.

When PIP optics is disabled, the loop is only 2 step -- on step 1 in 2D class config reference to 3D is found, on step 2 in 3D class config reference to 2D is found, and as reference is equal to original 2d variant class - loop breaks.

Previously no while loop was used, so _switchItem was picked from MRT_SwitchItemNextClass property and no additional checks were made.

@PabstMirror Could you, please, tell - is it possible to fix on CBA side or should CUP use diffrent MRT-switch scheme (and what scheme should be used)?

from cba_a3.

Mike-MF avatar Mike-MF commented on August 28, 2024

This is something I think I fixed.

Caused in CUP by having only a next cycle being Regular > 3D > PIP. Would be nice to have some people confirm this is no longer an issue before closing.

from cba_a3.

10Dozen avatar 10Dozen commented on August 28, 2024

This is something I think I fixed.

Caused in CUP by having only a next cycle being Regular > 3D > PIP. Would be nice to have some people confirm this is no longer an issue before closing.

Works fine for me.

from cba_a3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.