Jump to content

Recommended Posts

HandleScore EH does not persist after respawn. Since it's server only, it should definitely have been implemented via addMissionEventHandler, not addEventHandler.

Share this post


Link to post
Share on other sites
HandleScore EH does not persist after respawn. Since it's server only, it should definitely have been implemented via addMissionEventHandler, not addEventHandler.

Agreed, considering that the unit it is attached to is _this select 0, might as well have it server only missionEventHandler

It also doesn't quite work right: http://feedback.arma3.com/view.php?id=21147

Share this post


Link to post
Share on other sites

I thought I read somewhere on here that they were looking at disconnecting the simulation from the renderer but I can't find any quotes.

That would be *so* promising and needed for A3 performance. The current bottleneck is ridiculous.

Share this post


Link to post
Share on other sites
That would be *so* promising and needed for A3 performance. The current bottleneck is ridiculous.

That's what they're doing with DayZ, not Arma unfortunately.

Share this post


Link to post
Share on other sites

Hi guys,

Just checking code I haven't checked in ages.

I'm noticing a lot of errors (which weren't present before) related to the pushBack command.

https://community.bistudio.com/wiki/pushBack

'Error type number expected Bool'

_as = [west,civilian];
_au = [];

{
if (((side _x) in _as) || {(captive _x)}) then {
	_au pushBack _x;
};
} count allUnits;

when I replace:

_au pushBack _x;

with:

_au set [count _au,_x];

It works fine.

Is this normal? Is my understanding of pushBack slightly off? :)

Share this post


Link to post
Share on other sites

....

Is this normal? Is my understanding of pushBack slightly off? :)

If you do this:

_as = [west,civilian];
_au = [];

{
   if (((side _x) in _as) || {(captive _x)}) then {
       _au pushBack _x;
   };
   true; // Count probably expects a bool return
} count allUnits;

or

_as = [west,civilian];
_au = [];

{
   if (((side _x) in _as) || {(captive _x)}) then {
       _au pushBack _x;
   };
} forEach allUnits; // Foreach expects no return value

Does it work?

If so, it's not a problem with pushBack. Count probably expects a boolean to determine if it should be considered to be counted, and the pushBack is returning the index or the amount of elements in the array.

Share this post


Link to post
Share on other sites
If you do this:

_as = [west,civilian];
_au = [];

{
   if (((side _x) in _as) || {(captive _x)}) then {
       _au pushBack _x;
   };
   true; // Count probably expects a bool return
} count allUnits;

or

_as = [west,civilian];
_au = [];

{
   if (((side _x) in _as) || {(captive _x)}) then {
       _au pushBack _x;
   };
} forEach allUnits; // Foreach expects no return value

Does it work?

If so, it's not a problem with pushBack. Count probably expects a boolean to determine if it should be considered to be counted, and the pushBack is returning the index or the amount of elements in the array.

Thanks.

This seems to work, or at least stops it producing an error:

_au pushBack _x; true;

As in:


_as = [west,civilian];
_au = [];

{
   if (((side _x) in _as) || {(captive _x)}) then {
      [color="#008000"] _au pushBack _x; true;[/color]
   };
} count allUnits;  

I don't recall having to do that when i wrote these scripts a month or so ago ... Strange ...

The issue isn't with forEach v count. Always use count unless you need forEach.

Thanks anyways, amending now.

Share this post


Link to post
Share on other sites
Thanks.

This seems to work, or at least stops it producing an error:

_au pushBack _x; true;

As in:


_as = [west,civilian];
_au = [];

{
   if (((side _x) in _as) || {(captive _x)}) then {
       _au pushBack _x; true;
   };
} count allUnits;  

I don't recall having to do that when i wrote these scripts a month or so ago ... Strange ...

The issue isn't with forEach v count. Always use count unless you need forEach.

Thanks anyways, amending now.

Just checked the Biki, pushBack didn't return anything early in it's life, but then was changed at some point to return the index at which the element was appended. That started to mess with the count.

Share this post


Link to post
Share on other sites
Hi guys,

Just checking code I haven't checked in ages.

I'm noticing a lot of errors (which weren't present before) related to the pushBack command.

https://community.bistudio.com/wiki/pushBack

'Error type number expected Bool'

_as = [west,civilian];
_au = [];

{
if (((side _x) in _as) || {(captive _x)}) then {
	_au pushBack _x;
};
} count allUnits;

when I replace:

_au pushBack _x;

with:

_au set [count _au,_x];

It works fine.

Is this normal? Is my understanding of pushBack slightly off? :)

someone had same trouble as you on FT :) http://feedback.arma3.com/view.php?id=21154

Share this post


Link to post
Share on other sites

I recently did a code performance test on forEach vs count and count came out slower on my machine.

I read it was faster, but that advice on BIKI seems very situational. For example:

_ret = ["_hasPlayers = {isPlayer _x} count (_this select 0) > 0",[allUnits],10000,FALSE] call BIS_fnc_codePerformance;
// 0.0870056 <== ON MY PC

_ret = ["_hasPlayers = FALSE;scopeName 'root';{if (isPlayer _x) exitWith {_hasPlayers = TRUE;breakTo 'root';};} forEach (_this select 0)",[allUnits],10000,FALSE] call BIS_fnc_codePerformance;*/
// 0.00690002 <== ON MY PC

I think here forEach is much faster because of the amount of Units on the map when I tested it. The more there are, the more count will have to loop through, whereas forEach with a breakTo can quit out. Especially if the first unit in allUnits is a player (which is likely as they are often one of the first units placed on the map in a mission).

So I wouldn't take it for gospel that count is always faster as in some situations, it's much slower. Best thing is to test the code yourself as you write it and select the best thing for your requirements imo.

Share this post


Link to post
Share on other sites
I recently did a code performance test on forEach vs count and count came out slower on my machine.

I read it was faster, but that advice on BIKI seems very situational. For example:

_ret = ["_hasPlayers = {isPlayer _x} count (_this select 0) > 0",[allUnits],10000,FALSE] call BIS_fnc_codePerformance;
// 0.0870056 <== ON MY PC

_ret = ["_hasPlayers = FALSE;scopeName 'root';{if (isPlayer _x) exitWith {_hasPlayers = TRUE;breakTo 'root';};} forEach (_this select 0)",[allUnits],10000,FALSE] call BIS_fnc_codePerformance;*/
// 0.00690002 <== ON MY PC

I think here forEach is much faster because of the amount of Units on the map when I tested it. The more there are, the more count will have to loop through, whereas forEach with a breakTo can quit out. Especially if the first unit in allUnits is a player (which is likely as they are often one of the first units placed on the map in a mission).

So I wouldn't take it for gospel that count is always faster as in some situations, it's much slower. Best thing is to test the code yourself as you write it and select the best thing for your requirements imo.

Well, you cannot really do that, make totally different detection routine and say, you see, count is slower than forEach. In first example you want to first count all player units and see if the result > 0, in second example you are happy with the 1st player unit you found. If you really wanna use your example to compare count and forEach you need to modify count example to something like this:

[color="#FF8040"][color="#1874CD"]_ret[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"_hasPlayers = FALSE;scopeName 'root';{if (isPlayer _x) exitWith {_hasPlayers = TRUE;breakTo 'root';};} count (_this select 0)"[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#191970"][b]allUnits[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]10000[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]false[/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_codePerformance[color="#8B3E2F"][b];[/b][/color] [color="#006400"][i]//0.0139[/i][/color]
[color="#1874CD"]_ret[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"_hasPlayers = FALSE;scopeName 'root';{if (isPlayer _x) exitWith {_hasPlayers = TRUE;breakTo 'root';};} forEach (_this select 0)"[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#191970"][b]allUnits[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]10000[/color][color="#8B3E2F"][b],[/b][/color][color="#000000"]false[/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_codePerformance[color="#8B3E2F"][b];[/b][/color] [color="#006400"][i]//0.0148[/i][/color][/color]

Made with KK's SQF to BBCode Converter

Comments ^^ are my performance times.

Share this post


Link to post
Share on other sites

Ah, very good - I hadn't seen it was a bad comparison. Thanks for the correction - I'll happily eat my words and go away a bit wiser :)

Share this post


Link to post
Share on other sites

"Take" and "Put" EHs return "SupplyXXX" weaponholder now for when player moves items within inventory, or reloads. It used to be player object now it is SupplyXXX weaponholder, and even this is not guaranteed. It seems XXX number depends of whether or not it is a uniform or vest etc. But this is not a fact. Could well still return player object instead.

Why there was no announcement of this important change in functionality, and for christ's sake, why there is still no dedicated "Reload" EH? Now cannot even use "Take" EH to detect reload.

Share this post


Link to post
Share on other sites
Why there was no announcement of this important change in functionality, and for christ's sake, why there is still no dedicated "Reload" EH? Now cannot even use "Take" EH to detect reload.

Maybe you should reset the status of this ticket? http://feedback.arma3.com/view.php?id=18265

Share this post


Link to post
Share on other sites
...

The "Take" and "Put" eventhandlers now return a units container instead of the unit. This is actually an improvement. If you want to emulate a reload eventhandler now, you have to replace:

_this select 1 == player

with:

(_this select 1) in [player, uniformContainer player, vestContainer player, backpackContainer player]

They really should have mentioned it somewhere though.

Edited by [PzGrenBrig37]commy2

Share this post


Link to post
Share on other sites

I've been doing some tests and either I don't know how to use lineIntersects properly, or it is broken when using underwater.

Here is a little script for someone to check:

_eyePos = [15514.2,15782.3,-6.1243];
_worldPosASL = [15515.6,15772.4,-8.97415];
diag_log format ["EYE POS: %1",_eyePos];
diag_log format ["WORLD POS ASL: %1",_worldPosASL];

_helper = createVehicle ["Sign_Sphere25cm_F",[0,0,0],[],0,"CAN_COLLIDE"];
_helper setPosASL _eyePos;
_helper setObjectTexture [0,"#(argb,8,8,3)color(1,0,0,1)"];

_helper = createVehicle ["Sign_Sphere25cm_F",[0,0,0],[],0,"CAN_COLLIDE"];
_helper setPosASL _worldPosASL;
_helper setObjectTexture [0,"#(argb,8,8,3)color(1,0,1,1)"];
_intersect = lineIntersects [_eyePos,_worldPosASL];
diag_log format ["INTERSECT ?: %1",_intersect];

Here is the .rpt:

"EYE POS: [15514.2,15782.3,-6.1243]"
"WORLD POS ASL: [15515.6,15772.4,-8.97415]"
"INTERSECT ?: false"

And a picture taken inside the pier object (diver and _eyePos are on the outside of the pier):

LIunderwater.jpg

If you change the z values to zero or higher, then you get an intersect as expected:

"EYE POS: [15514.2,15782.3,0]"
"WORLD POS ASL: [15515.6,15772.4,0]"
"INTERSECT ?: true"

I googled this but didn't find any info. If there is a bug then I'll make a ticket.

Share this post


Link to post
Share on other sites

It might just not work under water. I'd say make a ticket to extend command to work under water or provide alternative.

Share this post


Link to post
Share on other sites

You know what would make the world a much nicer place in A3 scripting?

A history on the debug console. I'd love that.

Share this post


Link to post
Share on other sites

I do remember in A2/OA that it worked fine until there was a pond in between then it failed.

Share this post


Link to post
Share on other sites

i remember that i never got it to work underwater. very frustrating. would be useful for countless things including placing sachtels on boats precisely.

and while we're at it. eventhough some of it has been mentioned before. here's a list of problems with intersect commands and features that would make them much more useful.

intersect:

- apparently can't detect stuff named "componentX" (x being a number) in geo lods...really? those are the ones you most vertainly look for in that lod....Nou should know more. he told me that's why it didn't work for me when i tried

lineintersects/-with:

- seems to use only view geo lod. this is insanely frustrating because a) it's very limiting for everything that requires just simple collision detection (geo lod) and b) due to the above limitation of intersect there is no alternative to fix this

- no position output/return of where the intersection is happening. again very frustrating if you need that info very quickly. i know the usual workaround but it's slow and shouldn't be needed. why use countless small rays when all you need is the data that is already there from one ray? and also why the fuck not? it's just useful

- doesn't seem to work underwater (for completeness' sake)

can't log into the tracker for some reason. maybe someone wants to compile this and what else you can think of into a ticket.

Share this post


Link to post
Share on other sites

Hey everyone,

I've already seen tanks being slingloaded by the new helis.

What's need to be changed to make that happen?

Share this post


Link to post
Share on other sites
Hey everyone,

I've already seen tanks being slingloaded by the new helis.

What's need to be changed to make that happen?

You need to create selections for hook placement in the model of given vehicle and define parameters slingLoadCargoMemoryPoints and slingLoadCargoMemoryPointsDir (this affects orientation of hooks, you can use an empty array for default orientation) in config class of given vehicle.

This way you will allow sling loading of given vehicle and the only issue will be the mass, which can be changed by scripting command setMass in the mission. But be aware, that any change of mass will affect the behaviour of given vehicle and you should change the mass back when the vehicle is back on the ground.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×