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

error in CBA_fnc_taskDefend #488

Closed
DaVidoSS opened this issue Aug 27, 2016 · 6 comments
Closed

error in CBA_fnc_taskDefend #488

DaVidoSS opened this issue Aug 27, 2016 · 6 comments
Labels
Milestone

Comments

@DaVidoSS
Copy link

Arma 3 Version: 1.62 (stable)
CBA Version: 3.0.0 (stable )

Mods:

  • @CBA_A3

Description:
CBA_fnc_taskDefend line 47

[_statics,{(_x emptyPositions "Gunner") > 0},true] call CBA_fnc_filter;

changes the _statics array from

[object, object]

to

[true, true]

which is trowing an error

Error in expression <{ !(_statics isEqualto []) }) then {
_x assignAsGunner (statics deleteAt 0);
[
>
23:09:17 Error position: <assignAsGunner (statics deleteAt 0);
[
>
23:09:17 Error assignasgunner: Type Bool, need Object
23:09:17 File x\cba\addons\ai\fnc_taskDefend.sqf, line 79

because of

_x assignAsGunner ([true, true] deleteAt 0);

Steps to reproduce:
Spawn a group on position where are 2 static MG

    _outpost_grp = [getMarkerPos _mrk, WEST, [

        "B_Soldier_SL_F",
        "B_Soldier_F",
        "B_soldier_M_F",
        "B_Soldier_TL_F",
        "B_soldier_AR_F",
        "B_Soldier_A_F",
        "B_medic_F",
        "B_Soldier_F"

    ]] call BIS_fnc_spawnGroup;

    sleep 2;

    [_outpost_grp, getMarkerPos _mrk, 70, 2, false] call CBA_fnc_taskDefend;

Where did the issue occur?

  • Dedicated / Self-Hosted Multiplayer / Singleplayer / Editor (Singleplayer) / Editor (Multiplayer)

RPT log file:

  • none
@PabstMirror
Copy link
Contributor

Looks like it was fixed in #440

-[_statics,{(_x emptyPositions "Gunner") > 0},true] call CBA_fnc_filter;
 +_statics = _statics select {(_x emptyPositions "Gunner") > 0};

CBA_fnc_filter 's name can be confusing as it works like apply(map) but in some languages you would expect it to work like select and only return elements that pass the given function.

@DaVidoSS
Copy link
Author

DaVidoSS commented Aug 28, 2016

Yes. See that. Waiting for release.

using:
[_statics,{(_x emptyPositions "Gunner") > 0},false] call CBA_fnc_filter;

would be do the trick as well.

@commy2 commy2 added this to the 3.0.1 milestone Aug 31, 2016
@Dr-Eyeball
Copy link

Additional fix probably required for CBA_fnc_taskDefend:

I suspect the use of optional evaluation via the && { ... } part, should not be optional in this case.

Current code: (around line 78)
if ((random 1 < 0.31) && { !(_statics isEqualto []) }) then {

i.e. change to full evaluation:
if ((random 1 < 0.31) && !(_statics isEqualto [])) then {

since next line unconditionally requires non-empty array:
_x assignAsGunner (_statics deleteAt 0);

@commy2
Copy link
Contributor

commy2 commented Sep 14, 2016

What do you mean by "optional evaluation" ?
The _statics deleteAt 0 line will never be executed if !(_statics isEqualto []) reports false. It's just that that check will be skipped if (random 1 < 0.31) already reports false

@Dr-Eyeball
Copy link

Dr-Eyeball commented Sep 14, 2016

Sorry, you are right. I misinterpreted that line plus the original error description.

I was just trying to solve the cause of the same error I am getting in CBA_fnc_taskDefend.

It seems it will already be fixed with the original fix of this task.

@commy2
Copy link
Contributor

commy2 commented Sep 14, 2016

Good to hear. We will update as soon as 1.64 vanilla Arma is released (some changes are necessary with Joint Rails that require the Arma update)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants