#arma3_scripting
1 messages ยท Page 296 of 1
not the easiest task though. but depending on how clean the flamethrower code is set up it might be as easy as applying a "fired" EH to the vehicle's weapon and run a function that already exists from there.
guys, is there anyway to get task position?
// something like:
_tsk = currentTask (driver (vehicle player));
_pos = getPos _tsk;
hint format["%1",_pos];
@tough abyss maybe, but what if i dont want to use the name, just the current task assingned
taskDestination currentTask player
Np ๐
anyone here know the cutText comman well
im having a bit of an issue with it atm
0 CutText ["","Black OUT", 0.1];
this gives the effect i want but i want it to fade back in later
using 0 CutText ["","Black IN", 0.1];
does not work
i figured since its all on the same layer that it would fade the screen back in but it does not seem to work that way
btw, I wouldn't use numbers like that as layers. You probably break something by accident by using layer 0
the problem was, when using the effect "black out" i was un-able to brink back the picture
you can use layers 0 to 99
what was happening is on the bottome layer i used black out
and then i tried to overwrite that layer with a new effect
to black in
problem was it was not overwriting the old effect
the way i solved it was by using cutFadOut
so after the title screens show i cut the bottom layer compleatly
another un-documented change to arma lol
never had to do that before as it used to work with just overwriting the existing layer
Hey guys, any reliable way to get unique weapon id? besides weaponstate
for example the weapon in crate
cutFadeOut is documented https://community.bistudio.com/wiki/cutFadeOut
@little eagle yes that command is documented, but bis removing the overwriting title effects on the same layer is not
i only noticed it when i opened up an old mission ware i used the same effect sequence and it no longer worked
But overwriting the previous layer with the same id is the whole point of the layer stuff in the first place
That and sorting them on top of another
you use to be able to overwrite the same layer with different effects but with the way "black out" nad "black in" now work, its no longer possable to do it in the same layer space, ex.. "black out" screen for 20 seconds and "black in" the same layer after the duration you wanted the screen to be "blacked out" < this does not function like this anymore from what i have been testing. Its a nice change but its something that should be noted on the wiki what the layer chaged actualy did. Their is a change noted on it but not how it changed its function
Pretty sure you could never do that.
you used to be able to but that was back around 2014 when i was last messing with the system
what you men like
0 CutText ["","Black out", 3];
sleep 15;
0 CutText ["","Black in", 3];
cause that what i was doing and the screen would never come back lol
acts like the system noticed layer 0 already had an effect on it and moved the new one to layer 1
This gave me the effect i was going for so no worries ๐
0 CutText ["","Black OUT", 0.1];
sleep 15;
0 cutFadeout 1;
though i would like to see some tutorials on the new splended camera and how to record inputed motions so they can be played back via script at some point lol
this way we can pull off complex cutscene with moving shots
Again, don't use layer 0
Hey guys, is there any way to parse chat from in-game? Like parse chat to another ctrl?
ctrlText probably, but the display has no idd and I see no controls in config either, so it's either tricky or impossible.
Hmm I want to believe that someone did something with the chat in A2(:OA)
From SQF? No, not possible IIRC
As in, no event, etc
You could monitor when they open the chat box, and capture the text though @rotund cypress
// init.sqf
["cba_events_chatMessageSent", {
params ["_message"];
hint _message;
}] call CBA_fnc_addEventHandler;
yet another undocumented CBA thing ๐
well it is kinda but the only google hit for that event is a PR
It's only about a month old :u
Dunno if it should be considered API. I use it for internal stuff.
And the event only really fires if you enter the message. Not when anyone else does it or when it's done by command.
So it's not really as useful outside of what I'm doing with it.
Alright hmm
How many years before there is a fileExists command?
Maybe around the time you'll be able to generate files through script without needing a dll extension
Has someone an experience to align Structured Text font size with display resolution, even on the same screen ratio I get very different result on different resolutions
say on 1776*1000 I need to set picture size to 10
on FullHD I need to set it to 15
Is there a way to open someone's briefing tab on the map forcefully?
I know you can open the map forcefully but I want it to open in the "Briefing" section
Hot DAYUM the debugger adds a LOT of overhead
No debugger attached: 5.5445ms.
Debugger attached: 245.4253ms.```
It's debugging!
If I have something like this _hList= _pos nearObjects ["House",_distance];
Can I refer to the house with _house=_X; ?
if you forEach _hList then yes
{
private _house = _x;
} forEach (_pos nearObjects ["House",_distance]);
so typeOf _house in foo wont give back buildings in _hList. I cant just use the class "house"?
no clue what you mean ยฏ_(ใ)_/ยฏ
one sec
{
_house=_X;
if (!(typeOf _house in _exclusionList))
then {foo}```
why the heck does this work?
Is defined
Also, the curly bracket are all over the place
yes thats is the thing I think, I think I have to do some research on "private"
ok thats not it
What does it even mean if you put something in {} with not arg whatsoever
"with not arg whatsoever", you're kinda talking gibberish
as in hard to understand
bad englisch and I have no idea how to explain better sry^^
best is to show the whole code with all variables.
Also idk about actual programmers here, but foo an bar does nothing for me when trying to understand code.
It confuses me more....
private _var = 1;
systemChat str [_var]; // [1]
// use private
call {
private _var = 2;
systemChat str _var; // [2]
};
systemChat str [_var]; // [1]
// no private
call {
_var = 3;
systemChat str _var; // [3]
};
systemChat str [_var]; // [3]
{
_house=_X;
if (!(typeOf _house in _exclusionList))
then {
for "_n" from 0 to 50 do {
_buildingPos=_house buildingpos _n;
if (str _buildingPos == "[0,0,0]") exitwith {};
if (_probability > random 100)
then {
null=[_buildingPos,_showLoot] execVM "spawnloot.sqf";
};
};
};
}foreach _hList;```
Loot spawn script I found on YT to learn a bit. The whole code after _house = _X is one bracket.
as far as I can see, been writing with standard editor^^
_exclusionList is still undefined
well whoever wrote that shouldn't have ๐
If it works, then what is the problem?
Just dont get why he can use _house when that was never defined with the actual housList
or is he using the class "house" and not the variable?
_x is a magic variable in the forEach scope
forEach is a loop that iterates through an array (here: _hlist)
And _x is the current array element of the iteration.
_forEachIndex is the position of the current element in the array. Another magic variable
so everthing is in the forEach Scope and he is going through them with _X and saving in _house from hList?
thank you very much !
Does anyone know here can I find info about CBA's QUOTE(), COMPILE_FILE(), PREP(), FUNC(), QGVAR(), etc. stuff?
Not sure if they are documented, but: https://github.com/CBATeam/CBA_A3/blob/master/addons/main/script_macros_common.hpp @tough abyss
I'm quite sure @little eagle knows nothing about CBA ๐
Thanks @dusk sage.
Don't look too deep into this. There's a lot of ooold stuff that is no longer really needed in A3.
Like two thirds are just bwc.
With one half of that being used nowhere anymore.
The styles stuff and functions documentation is a good habit though
Oh, I meant the script_macros_common.hpp, not the ACE doc.
Oh haha
I don't like the ACE function headers. Too much ASCII art
Thanks @little eagle. Can those be used in .cpp files as well?
Most of them.
Cool.
I generally use a shroter version of them
pretty much identical to the BIS style
only for more complex functions though, small ones are generally two liner descriptions
/*
* Author: commy2
* Get the config path of a vehicles turret.
*
* Arguments:
* 0: Vehicle Config <CONFIG>
* 1: Turret indecies <ARRAY>
*
* Return Value:
* Turret config <CONFIG>
*
* Public: Yes
*/
vs.
/* ----------------------------------------------------------------------------
Function: CBA_fnc_getTurret
Description:
A function used to find out which config turret is turretpath.
Parameters:
_vehicle - Vehicle or vehicle class name <STRING, OBJECT>
_turretPath - Turret path <ARRAY>
Example:
(begin example)
_config = [vehicle player, [0]] call CBA_fnc_getTurret
(end)
Returns:
Turret Config entry
Author:
Sickboy, commy2
---------------------------------------------------------------------------- */
CBA looks cleaner to me.
// by commy2
๐
//player call forks_are_weird;
//proves to the target that forks are weird
I always wanted to make pretty comments
should be integrated into engine if you ask me
True that
it's like SKSE for Skyrim
Bethesda still don't want to integrate it but everyone uses SKSE
same for BI
CBA_A3 is like CBA A2 is to arma 2
yup
im a bit dissapointed about testing of new CBA releases
last time they broke critical functions like Patrol/attack/defend and almost every mission was broke
๐ฆ
4 days for fix lol
Haha, the real test starts when the update goes public ๐
1 line of code
they added unit tests for that function now
so shouldnt break in future
Wouldn't be a problem if Steam didn't force anyone to update or had any kind of version control.
yup
Not really a problem of CBA, more like of Steam tbh.
Steam workshop has it's problems
Ez pz
nice
I think I'll publish my work in this week
19 COOP RHS+ACE
scripted events in bases. When enemy detects you then you need to kill radiooperator before he goes to the radio and call for reinforcements
blow up fuel station to make armored vehicles run from town of your target to fuel base
I think it's not bad but users will verify
it's my first mission
random garrisons and random patrols + random location of ISIS leader
should be replayable
I don't know why would it be?
what's anti-sematic because I can't find the right definition
Is this the A3 equivalent of deleting system32? ```SQF
[] spawn {
while {true} do {
if (!isNull objectParent player) then {
detach player;
};
};
};
sorry if I didn't recognize your joke ๐ Im not a native speaker and I could not understand some specific jokes
disableUserInput true
@tough abyss Keep it simple.
_a = {call _a};
isNil _a;
disableUserBreathing true
have fun
a simple and elegant solution for users who writes negative comments on your workshop pages
Eh, negative of comments are fine, but the misinformation spread is unbearable.
Just look at the Red Hammer conversion for ARMA 3
tons of comments of crybabies "Its too hard BUEEEEEE"
it was hard in original OFP
Also every update people complaining about that they get signature mismatches when trying to connect to a server that didn't patch yet.
why it should be easier here
"test your shit, signature mismatch, please patch"
ugh, disgusting
would be nice if steam workshop would introduce branches and/or versioning
Dont get to happy you might have to wait awhile before it hits stable branch
I'm more excited about
enableEnvironment [ambientLife, ambientSound] (Since Arma 3 v1.67)
Fuck those rabbits. I want sheep and goats
I really hope project orange is an animal enhancement expansion
Why stop at goats?
There are many wonderful animals that crave includement to the ArmA series
Dogs, foxes, coyotes, frogs, cranes. I wonder if they went to real life altis and saw a bunch of rabbits and snakes and were like : "Wildlife - Check"
Yeah, no women, wtf? Women DLC when?
I don't see the point of having 3 rabbits hopping around when you could have women and foxes running around...
who needs women when you ahve goats to fuck
It's not about the fuck. It's about something to distract the player and to give more immersion
Having the only thing that moves on your screen be an enemy is boring
oh we were talking about arma, nvm
Having to check again to see what it was, to identify the target and make sure it was not a goat a civilian or a woman is what arma is really about
rabbits and snakes are pretty pointless when they aren't even synched over the network.
Sure, more network traffic, but now 20 connected clients calculate their own 5 rabbits.
It's more load overall, feels like a waste
Rabbit's AI crap is almost 4ms per Frame. Which can't really be disabled till 1.68 without sacrificing environmental sounds
so that waste is literally a couple fps
How the fuck did they manage 4ms/frame?
All of the Animations.
Pathfinding
checking for Snakes
run from snakes
dig holes (3 of the 4ms)
Rabbits run from snakes?
But you don't need to do that every frame.
no, that was a joke ^^
You're wrong commy! That totally needs to be done every frame. We want the Rabbits to be smooth.... Before we cook them
I should fix that shit.
You won't.
Yeah :3 Disable all the Rabbit FSM's ๐ and break the Animal scripts
Basicly, the Hare/rabbit/Snake needs NOTHING, except: Move from A to B. No Sensors, no targeting, nutting
You can do a lot of shit in way less than 4ms/frame.
The first thing to fix is the amount of these beasts
Also delete fish entirely. No one dives anyway.
Or at least make it a mission setting to have them.
How do I disable the animals without a config edit? How do I disable with config edit?
Never have seen any animals in my mission... nor fishes
https://community.bistudio.com/wiki/enableEnvironment First syntax also disables all environmental sounds
Not yet, I'm looking for alternatives
there are non
Why bother just wait for arma update for the command.
There is... I managed to do this xD but hell can't find it in my code
You can also override the animals defines in the map config. But that requires an addon. Think Exile uses that method
Oh my god
ITS 1 SCRIPT PER ANIMAL WITH LOOPS INSIDE OF IT
and yeah, they have to run fast, because "reactions"
It uses nearObjects
the animal script isn't even the problem
that's a script VM with realitvly low load. compared to the AI calculations
Man, for every animal you have one of these. So if you have 10 animals. It's already 10 loops
and?
Considering that there are 30 players, this would mean 300 loops in total
What a waste
Those loops could have been used for something better.
10 mostly sleeping scripVM loops
The energy wasted to run those loops is bad for the enivronment
Just because its a loop, it doesn't mean its bad oO
We would keep the planet green if we run 1 loop on the server
30 players means 10 loops per player computer
Exactly
And?
๐คฆ
haha ๐
none on the Server I'd guess. Because server doesn't have Animals. The script load is completly negligible. stop focusing on that ^^ scripts are maybe 0.2ms a frame. where the AI calculations are 3-5ms
My point is they are not syncronized. "See that rabbit?" - "what? Lay off the morphine!"
We do that quite often in my group ๐ The "You got too much morphine" thingy ๐
Man, I usually have like 100 AI active. Having 10 animals added to that is like nothing...
Also they would reduce the load from players, even if slightly
Not like servers run slow nowadays anyway. HC gets a decent FPS with the ai and server is left to do nothing, checks the tasks every few seconds and that's it.
I'm scared of AI. Keeping it on an absolutly minimum ^
Haha, why is that?
Still from A2 times. Once we removed the AI and all the Groups they've created we got massive performance improvements and finally got rid of the crow-bug
They weren't working well anyways when too many players went on
Remove all the sealife and replace with a coastal patrol boat
Remove all sealife and replace with those enormous submarines
Remove all sea life and replace it with ten more snakes.
They should make fully physical snakes using the rope physics. Also give the new snakes collision and sophisticated social simulation.
@tough abyss from 25 to 111 ๐ค
enableEnvironment true
Current FPS 82
enableEnvironment false
Current FPS 92
Sweet.
around 1.3 MS
Or just have 1 script that managest all of them
I don't see how that would not work
createUnit on them?
createAgent. Isn't this more hard on the frames?
I guess 10 agents could be more expensive than one group with 10 units.
Depends on what you do with them too.
What are even agents?
ai without group
I'm guessing a single independent AI unit doesn't count - since it has it's own group, correct?
Can an agent join a group, though?
I'm not sure, maybe.
It's mainly meant for animals, which obviously don't want to be in groups.
Can you imagine being in a squad of actual snakes in an MGS themed mission?
Would those be solid snakes? ๐
๐คฆ
๐คฆ
๐คฆ
Everyone's a critic ๐
Can you do conditional checks within switch case matches within SQF?
uhm
private _n = random 3;
switch (true) do {
case (_n < 1): {...};
case (_n < 2): {...};
default {};
};
Like this?
^ SQF's ghetto if-elseif-else
Well it's a normal switch
That's pretty much it, can you not do a switch statement on the variable and conditionally check it within the cases?
" conditionally check it " ?
switch (_n) do { case (_n < 1): {...}; default {}; };
for example, instead of switching on true
normal switch is ```CPP
enum class foo
{
foo_0,
foo_1,
};
void bar(foo foo)
{
switch (foo)
{
case ::foo::foo_0:
break;
case ::foo::foo_1:
break;
default:
}
}``` the sqf switch is a monstrosity
No, Bose, that would make no sense
< reports a boolean and _n has to be a number. That would never match in your example
That is pretty much the same thing, Untelo. Stop being so picky
switch (foo) do
{
case 0: {};
case 1: {};
default {};
};``` would be similar, but sqf switch cases are evaluated at runtime
which is what allows you to do the SQF switch (true) {...}
The only real thing that's missing is break. You basically always exit the do scope if the case matches, but I wonder if you can explicitly work around this with scopeName on the do-block and using that breakTo.
Roger, I derped pretty hard there. Was considering case checking on the return value of the condition, and not matching against the integral data type of the switch statement itself. You've presented a solid working way for me, thank you.
what exactly is it that you're trying to do
Cut downing if-else chains ;)
then the switch (true) { case foo: {}; case bar: {}; default {}; }; is probably the way to go
Yeah, it is. Cheers guys.
unless you're doing something like SQF switch (some_number) do { case 0: {}; case 1: {}; case 2: {}; case 3: {}; };and want the best performance in which case a jump table would be better
iirc several IFs are still faster than Switch.
i can't speak to that, but switch might be more readable
and performance isn't always critical
Stop using foo and bar.
why
its foobar!
I'm not too concerned about execution on this, it's run once. It's a polling system with a min required players that's different with lower player counts, which then changes to a general majority check over a certain threshold.
Dscha is right for once.
fuuu bar
It confuses more than it helps.
whats confusing about it
Use actual examples
like what
Yep. Helps more.
This is why I hate programers.
Like Commys example
this is why i hate scriptkiddies
with Number etc
Oh boy
Long Story short: Beginners understands it better, when you give them a "usable" example.
I didn't mean to start anything guys, I just wanted to avoid finding out the hard way about SQF specific caveats.
Oh, you are still here? ๐
Don't worry about it.
switch (1 + floor ((((toArray animationState player) select 5) - 100) / 5)) do
{
case 1:
{
systemchat "standing";
};
case 2:
{
systemchat "kneeling";
};
case 3:
{
systemchat "prone";
};
};```
there's a real example
is it better now?
๐
You could've used stance player and the strings that reports, but it's still better than foo bar.
no stance in A2 though, that's why i why went with this one
No one cares about A2.
๐
#end_of_life_arma ๐ A2 =}
โ
i do, but that's beside the point. the discussion was about the switch which hasn't changed since A2 and the example i gave was real either way. i was just informing you on why i went with this example instead of the stance thing: because i'm more familiar with A2 than A3
Ah. I thought you chose a weird expression like (1 + floor ((((toArray animationState player) select 5) - 100) / 5)) to prove some kind of point or something.
no it works perfectly in A2
The Discussion was: Read/Usability/Understandability VS. CoderStuff that Scripting won't understand properly, since they (mostly) have no clue what to do with "foo" and "bar"
well, i guess we'll just have to agree to disagree. i think an example should be as simple as possible. foo and bar are just placeholder names for variables. if the newbie asks, they're easily explained. and if the newbie still doesn't get it after the explanation... well, let's face it maybe they're not cut out for it anyway
Yeah. So many possibilities to choose from. Virtually infinite examples of code that could be presented, but no: Let's make up new words that should never be used in real code anyway.
All that did was bring people to actually use foo and bar in finished code. lol
Programers.
how do i determin when a lamps light bulb is shot out?
been trying to use _damage = getDammage light!;
thanks commy2 ๐
OR:
https://community.bistudio.com/wiki/getAllHitPointsDamage (if you got no idea what the name is)
hey i didn't come up with foo and bar, they've been used for over 50 years so i think they're pretty well established
Over 50? ๐
Fact: The older something is, the more likely it is to be wrong.
No one cares about the origin of it, or if programmers use it. It's still dumb.
ยฏ_(ใ)_/ยฏ
how do i pull out the hitPoint names on objects? not sure if im reading the object config file correctly
C&P! You Lifer @little eagle
Dscha - Today at 7:18 PM
OR:
https://community.bistudio.com/wiki/getAllHitPointsDamage (if you got no idea what the name is)
It's a new question with an old answer.
Lifer!
What?
C&Per! Lifer!
xD wtf?
My Text = My IP = You lifer! C&Per!
๐
waiting for a friend to play some Wildlands, i am bored ๐
@little eagle This is why I hate programers.The prejudice is strong...
It's no longer prejudice at this point.
They were first used in 1965
Commonly accepted? The words have been used a lot since the 60s and 70s, and are still used
I don't know a programmer who hasn't used them one way or another
Tell them to stop.
@open vigil They're placeholders or example names, not actual names..
(1 + floor ((((toArray animationState player) select 5) - 100) / 5))
Jeebus, this is exotic. ๐ฎ
On the general topic of tracking anims: Please never never never never never never compare to or use the string of the animation classname.
Instead, go by params inside this class, namely actions=; which points at cfgSomeMoves\Actions\<actionMap>
In this action map you'll find upDegree=;. This is where it all is decided. This integer tells AI and engine/anim system what stance/weapon combo you are currently in.
upDegrees are engine specific. One cannot add new ones.
And adding new ones in the engine is huge PITA
Oh, and while at it:
switchMove is bad. Never use this.
@open vigil They're not used for complex examples. They used for some examples when it makes sense to not spend a lot of time making up names for variables. Eg. if someone asks how to output text, eg.
void foo(char* bar)
{
printf("%s", bar);
}```
How is that in any way relevant to whether programmers use foo and bar or not?
All other problems were already sloved. So this one was on top of the backlog...
it would be nice if the topic was arma scripting so Mondkalbs nice explanation wouldnt get drowned out by noise.
Time to get out of here before godwin's law strikes.
Nah. I apologise for interrupting.
Informaticians are basically Hitler.
So setpos has to be local to the object it's moving huh
Not according to the wiki.
Arguments Global
Arguments of these scripting commands don't have to be local to the client the command is executed on.
I would use "machine" instead of "client", because it also applies to the "server" as well.
But when i terminal setpos _pos it doesn't move unless its a server or global execute in the debug
terminal variable defined on your machine?
@plucky beacon Well, setPos at least used to have to be executed where the unit is local.
Wiki doesn't say so.
@little eagle No shit.
whoah
in any case
terminal is an object in the map so yes
I'll just run a remoteexec
Probably a similar issue to the setdir
Did you disable the simulation or something like that?
nope
This command has local effect, but some simulation types do synchronise their changes over the network whilst others do not.
some simulation types?
Where does it say that?
Since ArmA 1.08 and later the command is global for every object again.
the object I am moving is a static object if that has anything to do with it
simulation is a property of every CfgVehicles / CfgAmmo / CfgNonAiVehicle class and defines the behavior of the object.
it's not an object with physics
tankX, carX, bullet, house
I guess it would qualify as "house" then?
getText (cursorObject call CBA_fnc_getObjectConfig >> "simulation")
need a bit of help understanding arrays in arma
I'm guessing you looked at the wiki page then?
yeah
what's the trouble
i understand array in c++ but the way arma does things is a bit strange
i understand X in c++ but the way arma does things is a bit strange
the way arma does things is a bit strange
Step 1 complete. ๐
>arma==strange
is there something you're trying to do that isn't acting how you expect?
arma arrays are more like std::vector than c++ arrays
im creating an array for each of the light lamps in the mission
lightArray_1 = [bulb_1,bulb_2];
and im trying to store the current states of each hitpoint in the array
so you want a multidimensional array?
you mean a jagged array?
Use a second array.
you can also use arrays in arrays granted I haven't tried that but wiki says
well the problem im having is i cant get the data from getHitpoint to store in the array
How so?
lightArray_1 = [bulb_1,bulb_2];
lightArray_2 = lightArray_1 apply {getAllHitPointsDamage _x select 0};
the lamp has 4 hitpoints and i want to store each of the hitpoints in each part of an array
so i need an array that can hold it but i dont know how to do that
I posted it.
if lightArray_1 is created as an empty array will arma auto create each selection? cause i cant defind it like array[3] = {}
Are you looking for this?
https://community.bistudio.com/wiki/select
no
What do you mean by "auto create each selection"?
defining an array = [] < is an empty set array in arma
Yes.
but how many selects are inside it
zero
in c++ you define a array[3] = {} and this will give you an array with 4 selects to store data inside, how do i do this in arma lol
You can put as many elements inside the array as you wish.
if I have an object with a holdaction, and I attatch it to another object, will it retain it's individual action commands
The limit is 10 million minus one.
Imma test this
how do i make one with 4 elaments then
my_array = [];
my_array resize 4;
ahhh
you dont need to explicitly define the size before adding elements to it
it also automatically resizes when you remove elements
thats nifty
It's a scripting language, not a programming language.
main reason its causeing me trouble lol
You're overthinking it.
lmao
arma doesnt really care about what you do with its variables. no strict types etc.
Doesn't mean you should do that though.
would i be able to get away with doing
lightArray_1 = [];
lightArray_2 = lightArray_1 apply {light1 getAllHitPointsDamage _x select 0};
no
because the first array is empty
you need to fill it with lamp objects like commy showed you
You would end up with two empty arrays.
oh ok
Also
light1 getAllHitPointsDamage _x
is wrong
then how do i define what object i want to pull from then
How to retrieve the object reference of some map preplaced lamps?
lightArray_1 = [light_1];
/facepalm
basicaly what im doing is having a enemy FOB that has outword facing lights, when bluefor is detected the lights turn on and base alarm goes off, what im trying to account for is if the player has covertly shot out the lights before being detected. this way when the player is detected if light_1_hitpoint damage is > 0.91 then the lights are cosidered shot out and the script will not turn the light on when the base is on alert
only way i know of setting lights to on/off is by damage states of the bulbs
it should give players bit of a surprise ๐
@dry egret Forget almost EVERYTHING you know from ANY other Coding/Scripting Language.
My_fnc_checklights = {
private _kaput = false;
{
if (selectMax (getAllHitPointsDamage select 2) isEqualTo 1) exitWith {
_kaput = true;
};
} forEach _this;
_kaput
};
lightArray_1 call My_fnc_checklights // false or true
*kaputt
Probably something like this,
My_fnc_checklightArray_1 =
{
private _kaputt = false;
{
if (selectMax (getAllHitPointsDamage select 2) > 0.91) exitWith
{
_kaputt = true;
};
} forEach _this;
_kaputt
};```
oops, forgot to rename the function.
so its best to do what im attempting to do through a function?
if you use it more than once > you put it in a function (generally)
got some reading up to do to even know how to use that code lol
i have not gotten into using function in arma yet...
@dry egret Well, they're just a code block. It's not technically called a function until it's defined in CfgFunctions
In either case, whether defined there or not, they're called the same way, through call
argument call codeblock
Defining them in CfgFunctions is not necessary, but does come with some advantages
I always found that to be overkill for missions.
CfgFunctions is pretty clunky.
You don't even get the benefits of having the functions be precompiled and cached at game start.
So what's the point.
@little eagle Well, if nothing else, it allows circular dependencies automatically, and it allows you to view your mission functions in the function viewer
yay
and then of course, there's preInit, postInit and preStart
Sure.
ok, so from what im reading i need to put that function in the description.ext under class CfgFunction correct?
and i should call it by trigger detected for onActivation lamp_1 call My_fnc_checklights
You can also just do what dscha said, it's quite a bit quicker
< didnt understand what he was saying to do exactly
All inputs should be in array format, ie [parameter 1, parameter 2]
Write your code
Put these brackets {}; around it
And name it by using fnc_nameoffunction = {codeblock}
then does that just go into the init.sqf so i can call it later then?
You can also 'functionise' sqf files by using fnc_nameoffunction = compile preprocesslinefilenumbers "Pathtoscript.sqf";
Yep!
/facepalm < was looking on the wiki about functions
๐
CfgFunctions iirc is more of a campaign thing to make your pbos a bit smaller
oO
Not realy
It's just a better way of having your stuff sorted.
CfgFunctions does more or less the same as compile preprocesslinefilenumbers "bla.sqf"; just in a more elegant way.
elegant is kind of subjective though. i only use CfgFunctions in missions to force myself to keep things some what organised. those one liner solutions will just amplify my bad habits ๐
could anyone tell me what the oposite of getPosVisual is?
like there is no setPosVisual
There is none. You cannot set the position in render scope.
hmm
that'd be crazy ๐ maybe useful for crazy arma hacks
Yeah, it makes no sense.
and is getPos* supposed to be grab 0,0,0 pos of a model?
-Visual stuff is for when simulation position and rendered model position differ
getPos uses x and y from the model center, but z is the distance from the models lowest point in the roadway LOD to the first object with the highest point in the pathway LOD below it or, if there is no object below it the terrain height when on land, or the height of the waves on sea.
It's called AGLS
"above gorund level surface"
getPosVisual does the same, but in render scope instead of simulation scope. The position is updated more frequently there to get smooth movements, but the object isn't really "there" if you understand.
my problem is i getPosATL from a mine which is below the surface ans setPosATL a object to it, the setPosed model is at the very bottom of the mine even tho the mines 0,0,0 is at the fuze
i used to just setPosATL[x,y,0] but i realized that this wont work in buildings so i try to solve that now
I'd use ASL and if the object you're placing is too deep, just add some constant to the z axis.
I like c#
Did I scare you?
Me?
That comment seemed so random.
C# is a programming language
Is it pssible to script a frog sound instead of gatling gun sound?
Replace the sound the gatling makes with a frog?
Not with scripting alone I'm afraid. You'll need to edit some configs.
config.cpp means you need to make an @Addon.
C++ cool
It's not really C++. It's just looks like it and uses some basic stuff from it. .cpp probably because the syntax highlighting works for it.
@little eagle sadly that isn't dynamic and it should work with any mine...
i just don't understand why it would grab that position
Well. What object are you attaching?
feck
And the biggest problem with that in your case is, that these don't work under ground.
well i just want to have the 0,0,0 point of the mine model
that should be at the perfect surface height
and your explenation of getPos* doesn't explain why it grabs the wrong position, or i didn't understand it ๐
If you want to get the ASL position not from z being the lowest point in the roadway LOD, but model center, then you can use getPosWorld.
hm that's worth a shot!
PosWorld is basically a subset of ASL where you just use z from the model center instead.
It also has a setter:
https://community.bistudio.com/wiki/setPosWorld
But I doubt that the model center necessarily is at the terrain level for mines.
No idea though.
Never implemented a mine.
Cpp is the file name for c ++
And it also is for Arma config files, which are not the same as C++ files.
What
There is no C++ in Arma, unless you make .dll's and .so's and use them via the callExtension command from SQF.
There is not much you can do with those though since you can only pass strings and report strings via callExtension.
I'm learning it I guess.
That is still c++
What is?
are there any drawbacks using setPosWorld?
like it would be the most logical for me to just use it all the time now
It's faster than ASL
world is faster.
i always think in this 0,0,0 position
It's the simplest of all position commands.
Cpp is thee fike exstenstion for c++ and the config.cpp is the same as c++ in the code
well bye bye ATL here you come World :3
@crude plank Forget everything you know about other Languages, when it comes to SQF.
Status Quo Function
ok need some help getting stuff to work on a dedicated server
trying to get the command setSlingLoad to work
using a trigger to call boatRelease.sqf
I found the proof that "For those involved with computer programming, the concepts of classes, inheritance and overriding should be familiar. As implemented in the coding of the configuration files in VBS3 the structure is similar to that found in C++ but without multiple inheritances."
That was taken by bisimulation
Site
sling_1 = ch1 setSlingLoad objNull;
but the chopper is not detaching
@crude plank What's your point?
Config.cpp is based on c++
No?
Look at the website
Not here.
It's like saying a Boing 747 is based on a Ferrari, because they have similarities
It is based on it I guess in that you can use the C++ syntax highlighting and everything will look right.
That's it.
๐
@crude plank Just because it uses somewhat similar syntax and style, does not make it C++. As for the extension, you could also rename a .txt file to .cpp, that doesn't make the text inside of it valid C++.
im calling a script via a trigger on activation nul = [] execVM "spectre\intro\boatdrop.sqf"; inside that script im using
_sling_1 = ch1 setSlingLoad objNull;
but when on a dedicated server the chopper fails to detach the sling?
is this the propper way of going it on dedicated?
if (isServer) then {
_sling_1 = ch1 setSlingLoad objNull;
};
to get it to work?
@dry egret The wiki doesn't say what the behaviour is in multiplayer. Could be that the chopper has to be local, or both the chopper and cargo has to be local. I guess you'd have to experiment
it works in hosted sessions just fine lol. i had the debug running on the server and tried it but it didnt work reguardless of what i executed it on. Thinkig im doing something wrong
@dry egret Works in hosted sessions?
in the editor when running it from play from MP
thats a local hosted session
having issues when running this on the dedicated server exe
Then when doesn't it work?
on the dedicated server
How is ch1 spawned?
Who's piloting it?
Is it placed in the editor with AI in it?
in the choppers init i use ch1 setSlingLoad boat_1;
yes
the players are riding in back
and the chopper is set on waypoints to the drop location
once it gets to the location players are transfered to the boats and the chopper unhooks from the boats
but on the dedicated the choppers will not release for some reason
Okay, I think I see the problem
When you host, are you placed as driver in the boat?
๐ฟ
you get transfered to the boat and placed in cargo of the boat
then players can take the driver slot
What's your unhook code? verbatim
Use waypoints
sleep 3;
ch2 forcespeed 5;
sleep 0.5;
ch2 forcespeed 3;
sleep 0.5;
ch2 forcespeed 1;
ch1 flyinHeight 9;
ch2 flyinHeight 9;
sleep 8;
_sling_1 = ch1 setSlingLoad objNull;
sleep 0.35;
_sling_2 = ch2 setSlingLoad objNull;
sleep 0.3;
ch1 flyinHeight 15;
ch2 flyinHeight 15;
If people become driver before the server unhooks, the server might not be able to unhook the boat (granted the command demands locality)
@dry egret Where is that executed from?
a trigger with 0 = [] execVM "dropBoat.sqf"
on act?
yep nul = [] execVM "spectre\intro\boatdrop.sqf";
during the test the second boat didnt have anybody in it and it did not release either
Is it set to "Server Only"?
the trigger... no
When using if statements, and have a lot to check for , is there a limit to how many conditions I can/should put in one?
@plush cargo Not. But you might want to use lazy evaluation
Im not sure what that is :/
@plush cargo It's an optimization. If you do just if (alive enemy1 && alive enemy2) then it'll check if enemy2 is alive, even if the check for alive enemy1 failed. Which is unnecessary
If you do, if (alive enemy1 && {alive enemy2}) then, the alive enemy2 will not be evaluated if alive enemy1 returned false
Computational wise, the first is equivalent to sqf _alive1 = alive enemy1; _alive2 = alive enemy2; if (_alive1 && _alive2) then { };
And the second (lazy evaluation) is equivalent to
if (alive enemy1) then
{
if (alive enemy2) then
{
};
};```
ahh ok cool
thought I was being slick getting all this shit to work in one statement lol
@dry egret What is it using from ACE?
if
(((_boatMpIndex isEqualTo 1) &&
((_dirDiff >90)&&(_dirDiff <270)))
||
((_boatMpIndex isEqualTo 0) &&
((_dirDiff < 270) && (_dirDiff >90))))
then
right now nothing for that one but since i have it loaded it forces the mission to required addons
i use ace a lot in the full mission
@plush cargo Most other languages support lazy evaluation on "regular" && operations, etc. But SQF being a pure expression language, does not, and has to use code blocks
@plush cargo Yea, that'll evaluate everything, whether everything before it failed to return true, adding unneccessary overhead. And in most languages, that's not a problem since they support lazy evaluation just like that.
But if you put right hand side operands inside {}, you'll get lazy evaluation
I mean, unless you do some really computational expensive shit in them over and over, I wouldn't bother changing them to lazy
@dry egret If it doesn't actually use anything from ACE, I can just strip the requirement
@dry egret Hmm, can you resave the mission with "Binarize Mission File" unticked?
yep
unless it'll allow me to load it without the addons, so I can resave it myself
hang no
there is a dock with a mem point in the water on each side, and each boat has a mem point on the sides of ship, it compares the distances and mem points to find the correct way to turn and park https://www.youtube.com/watch?v=_O1IdyLcuZo
so it only runs the if statement when player decides to tie up
@dry egret Nope, won't allow me to even load it
unless I can hack the binarized file
thats one you change
thx
np
not sure what i did wrong though in the scripts for it not to work. normaly i can get away with stuff by running things from triggers on dedicated but this has me stumped
even tried putting the if (isServer) {code} to see if that worked but it did not
maybe i need to call the script file via bis_fnc_mp?
@dry egret Should not matter
You're executing it in a trigger, which will execute it on all machines
if (isServer) would just ensure it only ran on the server
it works in the editor and play testing by MP from editor but not dedicated...
im not great at arma scripting lol
hmm, you're right. it doesn't work
maybe the boat somehow switches ownership to the player on dedicated
Hang on
it even returns false
?
What's the variable name of the boat?
ahh ok
I have a feeling it may be broken altogether on dedicated
Because even if I empty the boat, it won't drop
I can't make it sling load another object either
@dry egret this isn't relevant to getting your script to work but you should develop missions without ACE on and/or save your missions as unbinarized sqm's to save yourself a headache later when you forget it needs ACE or you need to remove the dependency
@dry egret How are you attaching the boats at the beginning, though?
That's using setSlingLoad too, isn't it?
through the choppers init
yes
ch1 setSlingLoad ab1 from the choppers init
thanks for the tip @nocturne iron
I'll try something
this issue and one other are the only ones i have left to solve for the mission lol
the other is just how to spawn vehicle on dedicated and set waypoint
No worries
i should be able to figure this stuff out but damn i feel stupid sometimes when it comes to coding in arma lol
You'll lose many a project to mod deprecation so it's never a bad idea to ensure you can sub out mod objects
i plan on just making missions that require my own mods in the future but having ace mod and alive are so much fun to work in
for this mission it runs on cba, ace, alive, eden_objects, plp containers, arp2.
noice
im working with the arp2 creator to get the mod fixed and to get the object configs up to current arma.
so no more laders\ out of scope lol
commy2 helped me a ton getting to the point ware i can bring items into arma from blender.
making a bunch of intel items you can place via eden so the players can place that eden placed object into inventory
@dry egret I tried changing the mission to never putting anyone in the boat, and it still doesn't work
The only conclusion I can draw, is that the command is broken on dedicated
just my luck
I'll try making a completely empty mission with just loading and unloading the sling, and see if I can reproduce it
maybe Dwarden can get it fixed if its broken
If you do that, I might need to use your mod haha
i made intel items like HDD that players can pick up off the ground
i just use a trigger to check if its in inventory at the end of the mission to see if the objective was completed
if("itemClassName" in magazines player)then{MyVar = true};```
@compact galleon i dont see how the command is broken since people use slingLoad on dedicated servers all the time lol
+no need for a placed trigger.
but i dont think anybody has tried to use it like i am lol
@jade abyss dont you need to run it from a trigger condition field so it constantly checks or runs the check at the end of the objective or mission
like having a sandbox type mission ala insurgency and bring item back to base and when in trigger zone complete objective?
Trigger -> Checking every 0.5s, is that rly needed?
If not ->
while{true}do
{
sleep 5;
if(MyVar)then{hint "end"};
};```
hmmm
You wanna check if someone in an Area?
-> InArea
uh.. well, if he's using a trigger, it's probably because he's checking if they've reached the extraction point
https://community.bistudio.com/wiki/Category:Scripting_Commands
Save that Link somewhere, where you can access it everytime you do coding.
then doing the check when it activates
Doesn't change the fact, that inArea would be better.
The Trigger still checks. No matter if someone is in the Zone or not.
Might not be a Prob with small/tiny missions, but still a bad habbit, wich shouldn't be done this way, especialy when someone is just learning ๐
Triggers don't add anywhere near enough overhead to warrant writing a script instead everytime you want to check if someone's reached a point
how do you format that code in discord?
such fail lmao
eeeh
fu discord
@dry egret You can also use a single ` for single line code like `code here`
code here
markdown ftw
can never get markdown to ever work
i actually prefer bbcode but thats kinda goin offtopic
@dry egret It's still `, not ' or ยด
do ``` not '''
On Nordic keyboards, it's Shift + |
on US layout keyboards its the button above tab (tilde/grave key)
ew, who is using US layout?
hator
it the damn tilda key lol
US layout can be qwerty?? what you on about
if (isServer) then {
endTimeVar = false;
extractChopper_1 = [[getMarkerPos "extractionSpawn_1" select 0, getMarkerPos "extractionSpawn_1" select 1], 0, "B_Heli_Transport_03_F", WEST] call Bis_fnc_spawnvehicle;
Raider_1 = extractChopper_1 select 2;
RaiderChopper_1 = extractChopper_1 select 0;
//Extraction Waypoints
_wp = Raider_1 addWaypoint [wp_POS, 0];
_wp setWaypointType 'MOVE';
_wp setWaypointSpeed "FULL";
_wp1 = Raider_1 addWaypoint [position ab1, 1];
[Raider_1, 2] waypointAttachVehicle vehicle ab1;
_wp1 setWaypointType 'MOVE';
_wp1 setWaypointSpeed "FULL";
};
Isn't US always QWERTY?
\0/
Only german is QWERTZ
only ze deutsch use qwertz amirite
On my keyboard, it's right to the left of backspace http://i.imgur.com/jPQI5pF.png
btw Spiegel, is that code just for testing or do u need halp?
thats my second issue
qwertz = Best
getting createVehicle to work on dedicated
I liked you Dscha....but now...
๐
lol
only thing worse than QWERTZ is french AWERTY
monsieur Spiegel, I assume le functione BIS_fnc_spawnVehicle ist global jaja, so what seems to be the problem? does it not spawn?
A and Q switched. W and Z switched. And M is right of L
doesnt spawn the chopper
does it spawn ze choppah in SP monsieur Spiegel
*madame
c'est une madame? excusez moi
Gesundheit
danke
btw. n8 ^^
no on dedicated
gn8
o7
have you tested it on SP tho Spiegel
works great in SP
just need a verson of it to work on dedicated
< bi wiki new homepage
when you test it on ze dedi, where are you executing this code? in a trigger?
isServer returns true on dedicated servers as well
you could explicitly target the dedi by doing: isDedicated but there's no real difference
what is the trigger condition btw?
when bluefore present
I'll have a test on my dedi - the thought of bis_fnc_spawnVehicle not working on a dedicated server seems very odd
i think its me that the issue lol
@dry egret Alright, I've confirmed that setSlingLoad is indeed broken on dedicated. I made a very simple mission with a player on the ground, an AI controlled helicopter in the air, and an empty boat. And then on init, the server calls setSlingLoad to attach it, which works. But it cannot detach it
Uuuhhh
Nevermind
Typo
on dedicated?
please send me that file
i may be doing something wrong
i may be able to adapt it for my mission or tract whats causing it to not work
Well, I tried spamming setSlingLoad objNull in the console in your mission, and nothing
There we go
My theory was right
whats that
You need to make sure only the server attaches it
if you let it run on everyone's machines, it becomes undetachable
eg.
Undetachable: 0 = chopper setSlingLoad boat
Detachable: if (isServer) then { chopper setSlingLoad boat }
The problem lies in the attachment, not detachment
so if i put that in my init.sqf and then call the detach the way i was it will work?
If you just change how you ATTACH, to just do it on the server, it should work fine
@dry egret Well, it's not original ๐
Spiegel, I tested your isServer code on my dedi. I however used the debug console to execute the code on the server. The chopper spawned all nice n dandy
i have not seen anyone do it for a coop mission before lol
I recommend going over your trigger again making sure it'll get triggered on the server.
should i set the trigger to server only then
@dry egret Just tested on your mission. Still fails..
hmpf
nvm
I actually made a mistake. Let me test again
ok
@compact galleon there is more neat lazy evaluation syntax
if ( (_cond1) && {_cond2}) then {};
_cond2 is not evluated, if _cond1 returns false
@vital onyx Huh? That's exactly what I posted
@compact galleon
if (isServer) then { sling_1 = ch1 setSlingLoad ab1; }
is this how your attaching
yup and now it works
@compact galleon no
if you use bool && bool both expressions are evaluated
@vital onyx That's what I said...
but if you use bool && {code} - this is classic lazy eval
you need to do bool&&{bool} to get lazy
I said: "MulleDK19 - Today at 12:07 AM
@plush cargo It's an optimization. If you do just if (alive enemy1 && alive enemy2) then it'll check if enemy2 is alive, even if the check for alive enemy1 failed. Which is unnecessary(edited)
If you do, if (alive enemy1 && {alive enemy2}) then, the alive enemy2 will not be evaluated if alive enemy1 returned false"
technically ...
bool && { bool && { bool && { bool } } }
earlier you have posted nested if
Last paragraph of my quote
@vital onyx That was to explain what it is equivalent to
lazy evaluation
then make it clear with proper code highlight
It was clear to everyone else
now I see what you meant, but that was hard to read :)
@compact galleon thank you so much... its WORKS ๐
please do not consider it as an offense, very tired to make a cluster of Arma 3 servers coding
@thin pine im calling the script via trigger onActivation
cutSceneExtractSeq = [] execVM "scripts\cutSceneExtraction.sqf";
extractChopper_1 = [];
if (isServer) then {
endTimeVar = false;
extractChopper_1 = [[getMarkerPos "extractionSpawn_1" select 0, getMarkerPos "extractionSpawn_1" select 1], 0, "B_Heli_Transport_03_F", WEST] call Bis_fnc_spawnvehicle;
Raider_1 = extractChopper_1 select 2;
RaiderChopper_1 = extractChopper_1 select 0;
//Extraction Waypoints
_wp = Raider_1 addWaypoint [wp_POS, 0];
_wp setWaypointType 'MOVE';
_wp setWaypointSpeed "FULL";
_wp1 = Raider_1 addWaypoint [position ab1, 1];
[Raider_1, 2] waypointAttachVehicle vehicle ab1;
_wp1 setWaypointType 'MOVE';
_wp1 setWaypointSpeed "FULL";
};
oh so its an execVM huh
yeah, it hadels all of the code for the cutscene
im guessing this is not the correct way of doing it
are you sure wp_pos and ab1 variables are defined? Make sure there arent any errors, check the server log
also its a better habit to first check if(isServer) and then { execVM } - that saves clients from having to preprocess compile and call the sqf file. (Not that it's very intensive in this case, but its a good habit)
double check for errors. I'd also recommend debugging your code by adding diag_logs
both in the trigger activation (if possible) and in the sqf to see where the code may possibly end - or to see if the activation code is triggered at all
diag_log output is readable in the .rpt file as you may know
im off to bed, best of luck ^^
@dry egret Created an issue about it https://feedback.bistudio.com/T123733
is it really a but or just me being bad at arma coding lol
It's a bug
ahh ok
And only on dedicated servers
@compact galleon you mind helping me with the spawn vehicle problem if you have time?
@dry egret I'd just use the createVehicle and createVehicleCrew commands
@compact galleon rewriting rn thanks for the help!
stupid question, when creating a group inside if (isServer)
whats the difference between _crew1 = createGroup west; and crew1 = createGroup west;
im looking at what the _ serves since its a local variable
_ would make the variable local to the scope
oh so it would be local to only the server then
No to the scope
If you want a variable local to the server create a global variable on the server
meaning only accessable by server
Yes
is there a way to make a diffrent 3rd person camera without using an addon
i.e. some way of making a camera but retaining control of the unit
@dry egret _crew1 is a local variable, crew1 is a global variable
crew1 will be accessable from everywhere, eg. in other scripts, after the point it's been initialized
_crew1 is only available to the scope itself, and any child scopes
if (alive player) then
{
_bla = "Hello World";
hint _bla;
// _bla runs out of scope here.
};
hint _bla; // Error. _bla not defined.```
_bla = nil; // _bla declared here, available to this scope and child scopes.
if (alive player) then
{
_bla = "Hello World";
hint _bla;
};
hint _bla; // undefined if player was dead.
// _bla runs out of scope here.```
ahh ok
so since i want to create a vehicle on the server and attach a camera to it later on in the script i need it to be global since the vehicle is actualy created from inside isServer {scope}
or make a global variable that stores is say raiderChopper = _chopperFrame
they way i have something i can talk to?
Almost sounded like what I asked about
what im doing is creating a chopper on a dedicated server and making a camera attached to it for cenematics
i think the choppers has been created correctly this whole time but i think what was heppening is the camera is not being created correctly
_Raider_1 = [];
_extractChopper_1 = [];
if (isServer) then {
_Raider_1 = createGroup WEST;
_extractChopper_1 = [getMarkerPos "extractionSpawn_1", 0, "B_Heli_Transport_03_F", _Raider_1] call BIS_fnc_spawnVehicle;
//Extraction Waypoints
_wp = _Raider_1 addWaypoint [wp_POS, 0];
_wp setWaypointType 'MOVE';
_wp setWaypointSpeed "FULL";
_wp1 = _Raider_1 addWaypoint [position ab1, 1];
[_Raider_1, 2] waypointAttachVehicle vehicle ab1;
_wp1 setWaypointType 'MOVE';
_wp1 setWaypointSpeed "FULL";
};
revised code
i think what i need to do to get the cenematics to work is create the camera on the server as well since i originaly had it outside of the isServer code block
@dry egret You only need it to be global if you need to access it from a different script
Eg. the names you give vehicles and units are global variables that you can access from anywhere
well i know the chopper spawns now lol
/*
Author: Soolie
Description: Returns closest/furthest memory point, distance from object and world location
Paramaters: [Object,[Target Object,Array of Memory Points],Bool - True for closest, false for furthest]
Returns: [Memory Point name, Distance from Object, Memory point world location]
Example: [player,[Car1,["wheel_1_1","wheel_1_2","wheel_1_3","wheel_1_4"]],true] call fnc_GetMpInfo;
*/
fnc_GetMpInfo =
{
params ["_obj1","_target","_closest","_num"];
_target params ["_obj2","_memPts"];
_mpNames = [];
_mPDist = [];
_mpPos = [];
_objPos = getPos _obj2;
{
_objMpPos = _obj2 selectionPosition _x;
_mpWorldPos = _obj2 modelToWorld _objMpPos;
_mpNames pushBack _x;
_mpDist pushBack (_mpWorldPos distance _obj1);
_mpPos pushBack _mpWorldPos;
}forEach _memPts;
if (_closest) then
{
_num = _mpDist call BIS_fnc_lowestNum;
}else
{
_num = _mpDist call BIS_fnc_greatestNum;
};
_index = _mpDist find _num;
_return = [(_mpNames select _index),(_mpDist select _index),(_mpPos select _index)];
_return
};
working great wondering about optimization