#arma3_scripting
1 messages · Page 39 of 1
pitch is nose to horizon regardless of velocity. aoa is nose to velocity while accounting for side slip, regardless of horizon.
"pitch" is "how high the nose is above horizon". "AoA" is "how high nose is above the velocity vector"
Maybe™
-asin (((velocity _plane) vectorDotProduct (vectorNormalized vectorUp _plane))/(vectorMagnitude velocity _plane + 0.0001)) may work for AoA 🤷♂️ or not
Alright i fixed it thanks for all the help
id need a distance check in this addaction command, can someone hint me ?
this addAction ["<t color=""#57ba14"" size='1.5' shadow='2'>" +"Mit Zivilist reden","script.sqf"];
Have you looked at the condition argument on https://community.bistudio.com/wiki/addAction ?
seems to produce somewhat believable results where i test it
asin (vectorNormalized velocityModelSpace _veh select 2)
divided by vectorMagnitude velocity _plane, but yes
I forgot vectorNormalized
another code golf challenge lost by me:3
still needs a - (positive AoA = nose higher than speed = negative velocity component) :3
@granite haven here, have a proper solution (pinging in case the channel goes way up before you look here)
it seems like he didn't want AoA tho
just pitch
welp, silly me again
That doesn't take side slip into account, right?
it does (at least for what i care)
no (not 100% sure what you mean tho)
well, i'd say it drops the slip, as it effectively projects the velocity vector onto the plane's up vector
Could not find words... https://imgur.com/a/oFh5JLl
aoa is angle between y and p, not between y and v, right? axes being model space
use lazy eval, you can also remove all the ifs and combine everything in that waitUntil
assign common expressions once, instead of calling objectParent 50 times
Yeah, setting a side component of model-space speed to 0 may be more accurate in this context 🤔
ctrlparent crtlpos + ctrlpos?
that for fixed wing only? or also for rotary?
body AoA doesn't really seem important for rotary. And i'm not bored ||or smart|| enough to calculate individual blade AoA depending on velocity, rotor RPM and controls position 🤣
Hi,
Is there way to get area/size etc from house , where is it build. Because nearestTerrainObject return [] if i have too low number even im standing right next to house.
example
player distance2d nearestTerrainObjects [player, ["House"], 20]#0;
// return 8.5
Imprecise: sizeOf
Precise but requires additional calculations: boundingBoxReal
Yeah, those return
sizeOf
//return
24.1846
boundingBoxReal
// return
[[-7.89347,-8.48253,-6.60997],[7.89347,8.48253,6.60997],12.0923]
So , what i do with these nice numbers XD
eat them
Ouuu jeah, Nice breakfast. I will start from 24
the bounding box results are minX, minY, minZ and maxX, maxY, maxZ from the object's position
Thanks. 👍
(and the last number 12.0923 is sizeOf/2, the sphere radius)
Holy shit are yall still going about this
so i have approaching a civilian and talking to him work, however the script does not trigger. my side chat is not working, just nothings happens.
this addAction
[
"<t color=""#FFAD1F"" size='1.5' shadow='2'>" +"Mit Einwohner sprechen",
{ [civ1,"ich habe nix gesehen, hau ab Amerikaner"] remoteExec ["sideChat"]},
nil,
1.5,
true,
true,
"",
"_this distance _target <= 2",
50, false,
"",
""
];
!code
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
sorry
No sorry required. Just do, everyone happy
i cant find the button 
Button?
to insert it it correctly
The instruction is pretty much there, no action else required
just write with the ``` and you're good
It is a formatting way in your text field
this addAction
[ "<t color=""#FFAD1F"" size='1.5' shadow='2'>" +"Mit Einwohner sprechen", { [civ1,"ich habe nix gesehen, hau ab Amerikaner"] remoteExec ["sideChat"]}, nil, 1.5, true, true, "", "_this distance _target <= 2", 50, false, "", "" ];
anyway```sqf
this addAction
[
"<t color=""#FFAD1F"" size='1.5' shadow='2'>" +"Mit Einwohner sprechen",
{ [civ1,"ich habe nix gesehen, hau ab Amerikaner"] remoteExec ["sideChat"]},
nil,
1.5,
true,
true,
"",
"_this distance _target <= 2",
50, false,
"",
""
];
It is not a button or something else, write so, it does so
` ` ` s q f
` ` `
oh okay
if you are on PC you will see the formatting live 🙂
are you on the civilian side?
urgh
nope
lol
wow
my coffee has no effect this morning
thanks mate
well i use ""sqf "" but it does nothing
` x3 not '
Wrong char to use
This but triple
A line break between first line and sqf
Pretty much the bot says, if in doubt re read it
okay thanks Polpox
this script should make some goats and make them stay on one position (since on dedicated server animal functions are bugged, goats moving from the location away), but for some reason they dont move back to marker a1
_spawnPos = getMarkerPos "a1";
_group = createGroup West;
Goat1= _group createUnit ["Goat_random_F", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
Goat1= _group createUnit ["Goat_random_F", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
Goat2= _group createUnit ["Goat_random_F", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
Goat3= _group createUnit ["Goat_random_F", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
Goat4= _group createUnit ["Goat_random_F", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
Goat5= _group createUnit ["Goat_random_F", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
while {true} do
{
goat1 doMove getMarkerPos "a1";
sleep 10;
};
someone any idea why´its not working? thx in advance
please use code formatting (as shown below)
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
oh damnit thx for the info lol
!code
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
🕵️
…yes
opfor shoots @ agents? 😮
opfor shoots at west/blufor goat units yes
does that include indep regarding their side relation?
wait, wait.
OPFOR shoots at units, not agents.
Beware of the goats
Hi all, would anyone have at look and point me in the right direction? Trying to modify the size of a container that is being spawned, but it wont stick... Maybe I'm using the wrong code or should use a different method?
//spawn crate
private _createType = FactionGet(occ,"surrenderCrate");
_position = (getPos _unit) findEmptyPosition [1,10,_createType];
if (_position isEqualTo []) then {_position = getPos _unit};
private _crate = _createType createVehicle _position;
_crate allowDamage false;
clearMagazineCargoGlobal _crate;
clearWeaponCargoGlobal _crate;
clearItemCargoGlobal _crate;
clearBackpackCargoGlobal _crate;
_crate setMaxLoad 10000000;
[_crate] call A3A_Logistics_fnc_addLoadAction;```
setMaxLoad is a server command
be sure to execute this through the host/server and then remote exec the remainder of the function
edit:
Or better yet, do everything in the server/host. Your code block doesn't have to run in a client
Then I picked up some wrong info somewhere..., thanx!
Needs to go into a sqf file, would maximumload = x be better?
no, are you aware of the concept of locality for commands and functions?
I think thats were you are failing right now.
The command itself is correct, as a matter of fact, your code is entirely correct. The issue here is where you are running it.
Edit:
Are you perhaps trying to run this in an init field?
It triggers after selecting the option as a player in the interaction menu. So I think it wil run on server level as to create said box? Or would that be wrong and is it local as the player makes the request?
where are you placing this code block?
In a sqf file stored inside the mission folder. It's a system to spawn a crate to put stuff in for storage/transfer.
and where are you calling/spawning/execVM this file?
You stand ingame, aim at a flag, then the options shows. After selection it triggers this file to run a check and then execute this code. The spawn part itself works.
im asking where are you calling the script, not how x)
can i talk to the person that allowed variable shadowing when calling functions?
i promise my intentions are peaceful
call is call, spawn is spawn 🙃
(no, not me, put that cactus down)
It sounds like it's an addAction, which means the script is being run locally on whichever client activated the action
Sorry, just got some basic knowledge and trying to learn on the fly. So far I can find that spawnCrate is registered in functions.hpp.
I think it is, trying to find it but this code is spread over a whole bunch of sqf's...
lets assume that you are doing this on the init of your flag object (which you shouldn't) and that your file is a function:
This is your file - V
//spawn crate
imp_fnc_crateCreation = {
private _createType = FactionGet(occ,"surrenderCrate");
_position = (getPos _unit) findEmptyPosition [1,10,_createType];
if (_position isEqualTo []) then {_position = getPos _unit};
private _crate = _createType createVehicle _position;
_crate allowDamage false;
clearMagazineCargoGlobal _crate;
clearWeaponCargoGlobal _crate;
clearItemCargoGlobal _crate;
clearBackpackCargoGlobal _crate;
//from
//_crate setMaxLoad 10000000;
//to
[_crate, 10000000] remoteExec ["setMaxLoad", 2];
//Leaving this line out, as you need to check if this should be done through server or if you need to remote exec this to all players
//[_crate] call A3A_Logistics_fnc_addLoadAction;
};
What you are doing here is basically telling whoever used the flag and get the code running to remote execute the command to the server (network ID: 2), of course this implies more changes, and probably a restructure of the code itself to be made using your server/host as a catalyst for this action to happen, for example, idk if you want this function to repeat, so probably remove the action itself once completed?
Anyways, the reason of why the other command works is because they run globally, they are executed everywhere disregarding the location of execution, while setMaxLoad is a command that only works when run through the server, so if you are hosting it will work for the host and propagate to everyone if the host does it, but not if anyone else does it, same applies to server but since a server can or cannot be a player, it won't execute since the player will never be able to communicate to the server. Hence the remote execution
that line here looks fucky.
private _createType = FactionGet(occ,"surrenderCrate");
not a valid function call
This might just be a #define'd one
prolly as polpox said, the person mentions that the crate spawns after all
is that mixed in cpp or what? never really got into that stuff
A SQF can have that
wasnt aware you can actually call it from inside of sqf
Thanks for explaining in such detail! Starting to get the bottom of it. Hard part is trying to figure out how everything is being triggered before this script, have to work my way through the github to find the possible init.
@glossy marlin consider reading the literature for event scripts here, it's better to use addactions or stuff that will only be done once in this ones if you are not creating stuff dynamically:
https://community.bistudio.com/wiki/Event_Scripts
also, for locality explanation for functions/commands (usually marked in the top part of the page):
https://community.bistudio.com/wiki/Multiplayer_Scripting#locality
It's defined in some other file which set's it to a certain class name depending on selected/available mod's. By default the type is Box_IND_Wps_F I think.
if you dont watch out for locality, you will run your code on every machine wiht global effects, spawning x things in the crate for x players online
we once had a loadout script do that, and wondered why the enemy AI didnt move at all.
they had 800kgs of handgranades each in their loadouts
Good thing it's an empty crate xD
Will do! Been reading a lot on the wiki lately as to understand the functions better and how to use them correctly. But examples are never your exact situation so the tricky part is using the right parts in the correct place
Its a whole journey, have fun in it 🙂 Good luck
Think I finnaly found it, it is an addAction in the fn_initClient.sqf. Which calls this spawnCrate.
ok, so this means that you should probably watch out and remove the action globally once the action was done by someone, otherwise you end up with multiple crates as ironsight mentioned
hey where is the general chat i just joined this server its gigantic
it's a macro,
#define ADD(a,b) (a + b)
private _result = ADD(1,2);
//after preproc becomes
private _result = (1 + 2);
Looks like the are some safeguards so it triggers once and only for the person requesting it. Also works like a charm now with all your help, and gained better understanding of locality! Many thanks!
variable shadowing? the only thing that comes close to that is private initializing a new variable when there was some previous one in the parent scope. not sure what you mean by that
no problem, good to know that you understand it better now
Funnily enough it's called "General Chat" #general_chat_arma
You can access all non-private variables from the upper, calling scope in your function.
Terrible design and safety issue
doesn't have to do anything with private, and nothing with "functions" either, they don't actually exist or mean anything, they're just a piece of instructions (code). what you're talking about is dynamic scoping, which exists pretty much everywhere in sqf
it's not a safety issue if you declare all your local variables private, which is what you should be doing
private _code1 = { _a = 5; }; // bad
private _code2 = { private _a = 5; }; // good
private _a = 1337;
call _code1;
systemChat str _a; // 5
_a = 1337;
call _code2;
systemChat str _a; // 1337
Its a design flaw if you cant make sure that called function causes wierd sode effects because they arent privatized.
Sure "you should privatize everything" but the truth is, hurting scope shouldbt be a thing to begin with
So, if i want increase neareastTerrainObjects radius (distance to nearest house) by house size. Let's say if house is 12 x 24
How i do get current pos of player to house to increase distance check +6 or +12 .
if you already know the house, why do you want to use nearestTerrainObjects
otherwise, a² + b² = c² :)
Well i don't , i use that to get neareast house of player
so if neareast house is too close player cannot dig ground
but currenlty it return [] if i'm next to house, if i got too small value in range. but i want it to be low because i want dig some holes between houses
put a big radius, for the biggest type of house you know is on that terrain
otherwise you will run in circles: you need to know the houses to get the biggest size, but you don't know which radius to use for you need to know the houses around ;-)
big nearestTerrainObjects, then for each check if the position is in their boundingBox
I will try this out, thanks
I had a similar issue where i need to make sure the space is clear. Im using lineinterSects now. No way to properly test with boundingsphere or near objects, to flakey
Reforger allows that
Nice
Maybe someone can help me with a scriptcode: Id need a trigger which says, each unit move to the middle of the trigger area and that in a 10 secound loop.
I have a Map control created on a RscTitles Display
with some display EH to control zoom and panning
code here: https://pastebin.com/Gz3F19NW
My problem is that the panning is shaky and the zoom jerks at times
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
were can I see the code that controls the zoom and panning for the default game's map?
Does anyone know a way to allow players to use their TFAR radio when in spectator mode?
I'm currently using BIS_fnc_EGSpectator via an addAction script that I have tied to an object so a player can interact with it and pop into spectator mode, the problem is that I need the player to retain the ability to use their radio while spectating.
No clue how to approach this but have you tried the ace spectator system? It may work there
https://ace3.acemod.org/wiki/framework/spectator-framework.html
Has anyone tried anything with drawing a bounding box without the entity itself?
like classname+pos+orientation instead of vehicle+pos+orientation
Thank you for the link! I'll give it a try and see if it works
Apparrently bbox data is in the model
So maybe u can use createvehicle, get the bbox data and then deletevehicle?
can anyone point me into the direction of tutorials for making a mod for Arma 3?
I'm trying to make a server side mod for my server that would simply run a script throughout the game, and while I tried looking through the ace file addon.
I couldn't figure out how the sqf files are ran, since for missions they use specific file names I don't know for mods.
Well, ACE uses the CBA XEH system. Otherwise you can use CfgFunctions with functions tags to run automatically at various points in the mission start process.
hmm, any way to get a rope from a rope segment without knowing the rope parent vehicle?
I don't think so. There are some missing rope accessors.
thank you
When opp kills opps, do they not turn hostile?
as blufor, they turn hostile after killing two blus but is it not the same for op?
same thing w/op killing civilians
False. If you kill them as an OPFOR you will be shot by your friends
🤔 it's not doing that for me, let me try again w/civilians
nvm it's letting me kill anyone regardless and doesn't turn my team hostile
idk what's going on w/my arma
what is the difference between these endings, they all seem to be the same so what's their purpose
Is there function/ command to close doors (not lock) , if ai opens door, I want to close that. Ai leaves doors open so how I make them (house it self) to close Doors
animateSource
So I get all the doors how do I add the animateSource to the existing doors? Can I add an animated EH to the house that closes the door every time it is opened
perhaps ^^
I will test out, I let you know if that is possible.
Hi all, just looking for a script to prevent AI from laying land mines.. Is anyone aware of a way to reduce dramatically or remove land mines all together? cheers
AIs don't place land mines by themselves, unless you use a mod.
Hmm ok thanks.. It must be either ALiVE or Lambs Danger
thanks mate
'pleasure!
no
there are no EHs for object animations
aa . thank. Could you know any other way to get doorstate?
and get it closed when it get opened
animationPhase to check its "state"
animate or animateSource to close
sadly you'd need a loop for that
so it'd be impossible to do this for all objects on the terrain. even checking every object near an AI is still not optimal
only doing to one house
params ["_trigger"];
private _area = triggerArea _trigger;
private _radius = (_area #0 max _area #1) * 1.42;
private _myHouses = nearestTerrainObjects [_trigger, ["House"], _radius];
{
_countOfDoor = getNumber (configFile >> "CfgVehicles" >> typeOf _x >> "numberOfDoors");
for "_i" from 1 to _countOfDoor do {
private _var = format ["bis_disabled_door_%1", _i];
systemChat _var;
_x setVariable [_var,1,true];
sleep 0.02;
};
} forEach _myHouses;
with this i get them locked , but if door is open it will "locked" (u cannot close it), so i want them get closed every time those are opened.
Spawning this function from thigger
a lazy way to do it is:
_doorAnims = animationNames _house select {"door" in _x};
while {alive _house} do {
{
if (_house animationPhase _x == 1) then {
_house animate [_x, 0];
};
} forEach _doorAnims;
sleep 1;
}
i like lazy ways XD
thanks !
but keep in mind that there's no guarantee all door anims have the word "door" in them
hence why I called it lazy
["door_1_rot","door_1_locked_rot","door_2_rot","door_2_locked_rot","door_3_rot","door_3_handle_rot_1","door_3_handle_rot_2","door_3_locked_rot","door_3_handle_locked_rot","door_4_rot","door_4_handle_rot_1","door_4_handle_rot_2","door_4_locked_rot","door_4_handle_locked_rot","door_5_rot","door_5_locked_rot","door_6_rot","door_6_locked_rot","door_7_rot","door_7_handle_rot_1","door_7_handle_rot_2","door_7_locked_rot","door_7_handle_locked_rot","door_8_rot","door_8_handle_rot_1","door_8_handle_rot_2","door_8_locked_rot","door_8_handle_locked_rot","glass_1_hide","glass_1_unhide","glass_2_hide","glass_2_unhide","glass_3_hide","glass_3_unhide","glass_4_hide","glass_4_unhide","glass_5_hide","glass_5_unhide","glass_6_hide","glass_6_unhide","glass_7_hide","glass_7_unhide","glass_8_hide","glass_8_unhide","glass_9_hide","glass_9_unhide","glass_10_hide","glass_10_unhide","glass_11_hide","glass_11_unhide","glass_12_hide","glass_12_unhide","glass_13_hide","glass_13_unhide","glass_14_hide","glass_14_unhide","glass_15_hide","glass_15_unhide","glass_16_hide","glass_16_unhide","glass_17_hide","glass_17_unhide","glass_18_hide","glass_18_unhide","glass_19_hide","glass_19_unhide","glass_20_hide","glass_20_unhide","glass_21_hide","glass_21_unhide","glass_22_hide","glass_22_unhide","glass_23_hide","glass_23_unhide","glass_24_hide","glass_24_unhide"]
Return this from current house
you mean animationNames returns that?
yeah
handle and other stuff have their own animation
but they're all linked
so you only need to animate one
I think door_x_rot
getNumber (configFile >> "CfgVehicles" >> typeOf _x >> "numberOfDoors"); configOf _x is a thing 😉
yeah, with this i got everything working. Thanks alot guys for help.
[] spawn {
private _myHouse = cursorObject;
private _countOfDoor = getNumber (configFile >> "CfgVehicles" >> typeOf _myHouse >> "numberOfDoors");
while {alive _myHouse} do {
for "_i" from 1 to _countOfDoor do {
private _var = format ["door_%1_rot", _i];
private _state = _myHouse animationPhase _var;
if (_state > 0) then {
_myHouse animate [_var, 0];
systemChat "OPEN";
};
};
sleep 0.5;
};
};
it returns [0.635] from animationPhase
there's no need to put a sleep in the for loop
Good to know, thanks
AnimationSource plays both door and handle movement and may be bit better for networking.
unfortunately the ace spectator does not work with TFAR either
Is there a way to add a player as a curator via scripting without having to create a game master module and then assign them as the curator?
yes
I'm not sure if this is the actual tutorial for that because it seems to be missing some of the stuff I was hoping for but anyway this is a start:
https://community.bistudio.com/wiki/Arma_3:_Curator
you can find more details by reading these functions:
https://community.bistudio.com/wiki/Category:Function_Group:_Curator
Are you able to change what addons they have access to, similar to how you can in the module?
Thanks, I'll look into it then!
np. just as a general rule, you can do more things using scripting. not less than 3DEN!
I figured you would be able to, just wanted to double check before I started lol
does anyone know how to convert this script to BLFOR:
{side group _x == civilian} count allDeadMen > 4
sides are listed here https://community.bistudio.com/wiki/Side
thankss
{side group _x == BLUFOR} count allDeadMen > 4
Hi sorry i was reading this and i am a bit confused what is that While loop doing? its infinite loop and its not doing anything ?
it close all the doors every half a second (at least it seems to do so)
Yea but isnt it enough to do it once ?
Can I add an animated EH to the house that closes the door every time it is opened
the intention was to do it continuously
Yeah, that one. Ai doesn't close doors 😁
uncivilized bastards
Yeah😂
at least they have the decency to open the doors... most of the times
(although that's hard baked into their nav mesh if i remember correctly)
In some of my game they dont even use doors they use ghost technology and go trough walls 😄
now that i think about it
// Here are references binding specific positions in Path lod in p3d to specific actions from "class UserActions" for AI to know when to use which doors. The actionBegin# and ActionEnd# is a hardcoded naming system.
from config.cpp of the sample house
params ["_unit", "_container"];
_unitRPG = secondaryWeapon _unit;
_weaponsConfig = configFile >> "CfgWeapons";
_checkunitRPG = getnumber (configfile >> "CfgWeapons" >> _unarmoredheadgear >> "ItemInfo" >> "HitpointsProtectionInfo" >> "Head" >> "armor");
_RPGincontainer = ((getweaponCargo _container) select 0) select {
_itemConfig = _weaponsConfig >> _x;
((getText (_itemConfig >> "simulation")) == "Weapon") and { (getNumber (_itemConfig >> "type")) == 4 } and {
((getText (_itemConfig >> "nameSound")) == "atlauncher")
}
};
_RPG = if ((count _RPGincontainer) > 0) then { selectrandom _RPGincontainer } else { "" };
if ((_unitRPG == "") and (_RPG != "")) then {
_unit addweapon _RPG;
[_container, _RPG, 1] call CBA_fnc_removeWeaponCargo;
_unit addMagazine [_NEED_RPG_MAGAZINE_NAME, 15];
[_container, _NEED_RPG_MAGAZINE_NAME, 1] call CBA_fnc_removeMagazineCargo;
} else {
};
How can i find magazine name for _RPG in this _container , who knows ?
to add it in 2 last commands
something like getArray (configFile >> "CfgWeapons" >> _RPG >> "magazines") select 0, i guess
compatibleMagazines _RPG # 0 is preferable now.
some modsets actually put garbage in the early slots.
or selectRandom of that, yes
does compatibleMagazines do any filtering/sanitizing, though?
Yeah, it does an isClass check.
i need to check if is there some magazines for that _RPG in _container and if it > 0 , _unit adds magazine with _RPG
Also fixes bad casing, which can be handy.
(magazineCargo _container) arrayIntersect (compatibleMagazines _RPG)
That'll give you an array of all magazine types in _container that are compatible with _RPG.
_RPGmags = (magazinesCargo _container) arrayIntersect (compatibleMagazines _RPG);
if ((_unitRPG == "") and (_RPG != "")) then {
_unit addweapon _RPG;
[_container, _RPG, 1] call CBA_fnc_removeWeaponCargo;
_unit addMagazine [_RPGmags, 1];
[_container, _RPGmags, 1] call CBA_fnc_removeMagazineCargo;
} else {
};
like this ?
Nah, you'd have to select one of them.
Also also test that it's not an empty array first.
something like this? (Sorry, my script skills is too low 🙂 )
_RPGmags = (magazineCargo _container) arrayIntersect (compatibleMagazines _RPG);
if ((count _RPGmags > 0) then {
_RPGmag = selectRandom [_RPGmags];
} else {
};
dead people leave groups, this most likely won't work (if their deaths are spread over time)
yeah i noticed
what would a command be that works?
@granite sky I made it. It works. Thanks.
What is your goal? a condition for "more than 4 dead blu units"?
Yep, there must be 4 dead blu units in order for the mission to be a failure
the note on the wiki page for allDeadMen shows one way to do that condition.
at the bottom, by Pierre MGI
I am gonna assume you are using trigger conditions so you could do something like this:
Activation: BLUFOR
Activation Type: Present
Condition:
{_x inArea thisTrigger && getNumber (configfile >> "CfgVehicles" >> typeOf _x >> "side") == 0} count allDeadMen > 4;
On Activation:
["epicFail", false, 2] call BIS_fnc_endMission;
omg thank you so much! ❤️
I haven't tested it so dont know if it works
nope didnt work
thanks for the help tho
This one works
Activation: None
Activation Type: None
Condition:
{side group _x == BLUFOR} count allDeadMen > 2
Active:
"End1" call BIS_fnc_endMissionServer;
but only if they're killed instantly
like by an explosion
not if killed separately
is there any way to "forceaddmagazine" to unit? If it don't have free space magazine doesn't adds by addmagazine command.
setUnitLoadout can ignore the carry capactity of containers used by a unit.
Although i might be misremebering
So i have some code that i want to execute on server side. Is there any way to make sure it executes before anyone can join the server? It's important because in that code i add PlayerConnected, PlayerDisconnected and EntityRespawned event handlers and i want them to fire for every new player.
some options are
you can write your code in the initServer.sqf
or in the init.sqf under an isServer condition
Neither of those guarantee that the code will be executed before any players join.
In fact, it's not possible to guarantee that code will be executed before any players join, because players can be already connected before the server selects a mission (and often will be).
what I told him is good enough for what he wants
Well i already do that via init.sqf + isServer and from my tests PlayerConnected EH doesn't fire sometimes
dedicated? local hosted?
https://community.bistudio.com/wiki/Arma_3:_Mission_Event_Handlers#PlayerConnected
Dedicated
The problem is server does a lot of work at init before adding those event handlers so if you join fast enough those EHs might not fire because they're not added yet
sounds like a clientside issue then
have the client request a server status and wait for server response
That means trusting client then :/
And i'm trying to avoid that
I could move the code that adds event handlers to the very beginning of init script but the code in those EHs depends on some global vars to be initialized
idk about that but
server side after u finish loading everything you can call the code inside those EH
for each new player that may be connected
(already connected)
there surely is, I just don't know enough about how your project is structured
maybe u can kick out all players and not let them join before the server is done loading?
I still think the better approach is to just run the code inside the PlayerConnected EH after the server finish loading
you know for each already connected client
Both sounds like a dirty solutions but if there's no better way...
wait, sounds like a design issue actually
if you want to do something before anyone joins, that's not scenario-related, that's a server mod
otherwise have code that runs on mission start on connected players, + a JIP way to run that code too
All i want is to reliably add PlayerConnected EH before anyone can join 🥲
And i guess that's not possible
Code that runs for every connected client serverside
That initializes some data for that client
then yeah, either a server-side mod (one mod, will cover all missions)
if it is for only one mission, having the code run even if people are connected is acceptable too
or move the time boundary to the moment said data is actually used, if that's possible 🤷♂️
no way!
what is wrong with running code after server+mission initialisation?
I wanted to handle all players via PlayerConnected EH
There can be players that join at the very start of the mission. There can be players that join during the mission.
yep, I know that, I told you already
the thing is "one code does it all" won't fit
so have one function, called in two places
Ok thanks for the help
depends if you need the player object
if you just need the player ID you can start much earlier in client init
initPlayerServer.sqf is meant for that
why not have the client send the server the player variable?
That means trusting client to do that
that is what initPlayerServer.sqf does
spawn civ in neutral zone with disabled controls, assign side/loadout/position and return control when the data is actually loaded 🤷♂️
Wiki says initPlayerServer shouldn't be used
you can run serverside code to any clients who dont send the var, for lag or exploit reasons
basically kick if no handshake in 10 seconds
you can write your own initplayerserver.sqf once the need arises
lot of things in the wiki are from people who havent published much, or worked on projects where you have to budget time
you have a solution that only cost 5 minutes.
Ok, thanks
if i use addAction, id need a line in the script to remove the addaction after using it. can someone help?
[
"<t color=""#FFAD1F"" size='1.5' shadow='2'>" +"Mit Einwohner sprechen",
{ [civ1,"Ich habe nix gesehen, hau ab Amerikaner,wir haben hier zu tun, Ihr stört uns bei der Arbeit...!"] remoteExec ["GlobalChat"]},
nil,
1.5,
true,
true,
"",
"_this distance _target <= 4",
50, true,
"",
""
];```
{[civ1,"Ich habe nix gesehen, hau ab Amerikaner,wir haben hier zu tun, Ihr stört uns bei der Arbeit...!"] remoteExec ["GlobalChat"]; (_this select 0) removeAction (_this select 2);},
That will remove the action for the client that used the action, but not for anyone else
inb4 removing the action by checking the global variable inside the condition
Or remoteExec-ing removeAllActions if that's acceptable
maybe he wants just that?
The action looks like some kind of story event, where the unit the action is on gives some information or something when you speak to them. Since that message is already visible to all players, it would be kinda weird if every player could interact with them.
Yes, maybe they do want that, but on balance, I think that's the less likely case - and having both solutions available would probably be useful. Or at least knowing which one the example does, which is all I said.
removeAllActions is usually not recommended (think of mods adding an action for example)
rather addAction and store the id with setVariable (locally, not broadcast of course)
and the action should grab that id and remove the action, locally again
Does anyone have any info on error GIAR pre stack size violation ? I'm calling an event handler and I get this error. I tried looking it up on the wiki and couldn't find anything. The only thing on google I found is from crashes, but not scripting errors. Any help would be appreciated .
It's just "something's wrong", apparently
code?
[{
params ["_unit", "_object", "_cost"];
private _isConstructionAllowed = false;
private _unitAllowed = false;
private _placementAllowed = false;
{
private _supply_distance = _unit distance2D _x;
if (_supply_distance < 100 && _supply_distance > 5 && getPosATL _object select 2 < .3) then {
_isConstructionAllowed = true;
break;
};
} forEach supply_vics;
{
hint str (_x select 0);
hint str typeOf vehicle _object in (_x - [_x select 0]);
hint str [(_x select 0), str group _unit] call BIS_fnc_inString
if (typeOf vehicle _object in (_x - [_x select 0]) && [(_x select 0), str group _unit] call BIS_fnc_inString) then {_unitAllowed = true; break;};
} forEach buildableInit;
if (_unitAllowed && _isConstructionAllowed) then {_placementAllowed = true;};
_placementAllowed
}] call ace_fortify_fnc_addDeployHandler;
@winter rose
If i wanted to pass another param into this handler, how would I do that?
right now I have to make buildableInit public, but I know that's not the best way.
What's the param related to?
#arma3_scripting message
Tried to explain a bit ago
thanks
#arma3_scripting message with example there
// Define _unit inside the entire script locally
private ["_unit"];
if (alive _unit) then {
hint "Unit is alive"
/*
_localVar doesn't exist outside of this scope. When using private variables you are defining an inner most "local scope" this means the variable doesn't exist outside of this scope
*/
private _localAliveUnits = [] pushBack _unit;
// Do something with localAliveUnits
};
// _localAliveUnits goes out of scope if you tried to use _aliveLocalUnits outside of the private assignment it won't exist and so you'll get an undefined variable.
Does the "{side group _x" here refer to the blue teams, if so, how can i make it only activate for the group (Alpha 1-2) rather than the entire BLUFOR entities
{side group _x == BLUFOR} count allDeadMen > 2
BLUFOR or west
Wish dropping vehicles in Arma 3 wasn't so jank. Parametric curve derivative probably wouldn't help either. Even if you could smooth out the movement of the drop collision impact would probably send you flying
Let's break down what's happening here so you understand it.
The first thing that happens is the command allDeadMen. This returns an array of dead men (shocker). You're then taking that output, and using it as one of two inputs for the count command. The other input to the count command is a condition. The condition is a piece of code that gets checked once for every item in the right-hand input, and if the condition returns true, that item gets counted towards the final count result. _x is a special reference to the current item being checked.
The condition being side group _x == BLUFOR means it returns true - and counts the item - if the item is in a group belonging to the BLUFOR side. If the side of group of _x is equal to BLUFOR.
Now instead of checking the side of the group, you want to see if it is a specific group. First you need a reference to that specific group, so you'll need to give the group a variable name. If it's an Editor-placed group, the "variable name" field is one of the top fields in the group's Attributes windows. If it's script-spawned, you'll need to save the output of the createGroup or BIS_fnc_spawnGroup you used to create it, e.g. yourGroupName = createGroup .... Let's say you call it yourGroupName.
Now you can check if the group of _x is the same as the group you want to look for. That's pretty simple:
{group _x == yourGroupName} count allDeadMen > 2```
Nice NikkoJT, better than just give two last lines to swizz
They could just you know test it?
You mean this one?
Example from wiki
house animateSource ["Door_1_source", 1, true];
But house doesn't return animationsNames any of "Door_%_source"
Or is this "door_%_rot"? Where I can use this
yes
Thank you so much, i appreciate it a lot
animationsNames and animateSource involve different types of animations (which are sometimes the same, but also not). You can find animationSources in the object's cfgVehicles properties. Usually the sources are named animationName_source, where animationName is the name of the animationsNames result which the source corresponds to.
? I didn't get it. I was just saying for Nikko that he's answers is good because he explains what current command do
Thanks , I will check out this
Does anybody know what parametr from grenade launcher's config i must get to check is it disposable or not?
just moving the drone AI crew to the csat side should be enough 🤔
BIN_fnc_hackAIDrone is only available if you have the Contact Optional Data loaded. It's the thing from the Contact campaign.
You can give a unit the ability to convert a UAV to their side by giving them the UAVHacker trait (https://community.bistudio.com/wiki/setUnitTrait)
_grp = createGroup east;
crew dddd joinSilent _grp;```literally enough, `dddd` being the drone 🤷♂️
just for consistency sake: the code was tested in debug console in already running mission
works from drone Init with this as well
This functionality isn't part of the base engine weapon stuff, so unfortunately there is no one config value that controls it - different mods implement it in different ways. For example, the GM M72 LAW has a "fired" event handler that calls a GM-specific function to replace the weapon. The gm_spentLauncherType config value contains the "used" launcher type for that function to reference, so you could check for that config value existing....but only for GM weapons. The CSLA M72 LAW uses a similar method, but the EH-called function is different and there's no config value for the "used" type. And lord knows how many different ways other mods do it.
@hallow mortar yeah, i already found all of this. Seems you are right. Thanks.
is there a way i can check if a video is playing ? im using BIS_fnc_playVideo
myVideo = [...] spawn BIS_fnc_playVideo;
waitUntil { scriptDone myVideo};
Hint "video is done"
Scriptdone returns true or false. So that's your check
Hi guys a quick question what dose the $ sing represents here is that a macro or something else ?:
and if it is a macro could i run code in this example as a macro as well or not ?
class Sentences
{
class Sentence1
{
text = $STR_HelloThere; //this line
speech[] = { "\Sound\hello.ogg" };
class Arguments {};
actor = "obi1";
};
};
It's a string from a stringtable
https://community.bistudio.com/wiki/Stringtable.xml
Ah ok got it now.
is there a way to see functions from another mod in-game? just to browse any created by a mod
They should show up in the functions viewer.
Probably CfgFunctions only though.
Ah, if you use Advanced Developer Tools then the non-CfgFunctions stuff shows up in Misc.
Hi guys quick question. If i remoteExec the addaction will the script that is inside the addaction be remoexecuted or do i have to do that sepertly then the addaction ?
no
Also another question if i remoteexec a script like execVM dose that mean that everything inside the script will be executed on the server or no ?
remoteExec executes something on whatever machine(s) you tell it to, if you remoteExec execVM with target 2, it will execute that script on the server
Hello everyone, come across a mod thats secretly targeting certain SteamIDs and causing them to have memory leaks, was wondering what (if any) this would be breaking as far as ToS for steam or Arma workshop
Crashes the game and causes the computer to slow massively, sometimes crashing that too.
Apologies if this is the incorrect channel, just looking for some guidance
This is the script for the record, Again im not at all versed in scripting so I cant speak for what the code is or does, but just want some guidance on the situation with this sort of thing
https://cdn.discordapp.com/attachments/105792634995388416/1061444504386814022/image.png
just need someone who knows what the script is doing
Would greatly appreciate the help
It's creating a memory leak and majorly impacting performance by endlessly populating an array with all objects on the map within 50km of each unit.
Okay thanks, massively appreciate the help
Just curious, whats the rules on this sort of thing if you know?
Im just curious whether it violates any ToS etc
I don't know, but it's pretty scummy. Those people must've really wronged whoever wrote this.
They've barely spoken to the guy, just known through mutual acquaintances 😆
I wouldn't be surprised if it violates some rules though.
was gonna say, surely a mod that targets people and crashes their games through memory leaks cant be allowed to just sit on the workshop
that's definetly not ok, which mod is that?
is there any reason of why a binarized mod would not be able to find an #include 'd file, but when you repack it as unbinarized the file is found?
Well, binarizing evaluates preprocessor stuff at the point of binarizing.
is this specified into documentation by any chance?
#include 'ing seems more convenient than straight up defining just a function or execVMing a file to add additional definitions for variables in another script, perhaps setting pboPrefix can influence this too?
Oh, I'm probably barking up the wrong tree anyway.
Hey folks! Just a conceptual question. Bit puzzled. To explain:
with various triggers and things, I had triggers that, upon activation, would removeAllActions+remoteExec an addAction from an object. Idea was to have a chain of triggers so that upon selecting the "right" scrollwheel option, previous added actions would get erased and the new options for the next phase would be added. If wrong answer was selected, all actions were erased, some code would happen, and then the same set of actions were added again.
Problem is, when my players came to the object and went through the chain of triggers, the object had multiple sets of the addedActions in it.
Multiplayer game, triggers were set to repeating and evaluated on server, but though they were set on repeating, the scripts would ensure that it wasnt getting repeated without further player input, so it's not like the triggers kept going off repeatedly.
Q: Can anyone think why I had multiple sets of addedActions on the object? Was it because I set the trigger to be evaluated on the dediserver? (My MP session is over, so I don't have my friends to test it out with me, if I fiddle with whether its evaluated on server or not).
It works completely fine when I test it out just by myself.
i'll see if there is anything related to this anyway, thanks
How exactly you use addAction?
To give an example:
I have two triggers. First one is set to be activated when t == 1; When it gets activated, it does the following (to figure out which phase of the phase we're in:
switch (tr) do
{
case 0: {trg0 = 1};
case 1: {trg1 = 1;};
case 2: {trg2 = 1;};
};
t = 0; //resets this trigger, so it can be used again.
For each phase, their respective triggers get activated when trg0 == 1;
//all of this is addedActions for first phase
[terminal,
["1st Wrong Option",
{ removeAllActions terminal;
//script completely unrelated to addAction; changes screen texture and other stuff
t = 1;
}
]
] remoteExec ["addAction", 0];
["Correct Answer",
{ removeAllActions terminal;
//unrelated script.
tr = tr + 1; //to increase the value of tr and pass to the next phase.
t = 1;
}
]
] remoteExec ["addAction", 0];
trg0 = 0; //to reset this trigger too
First time the first trigger gets activated is when a simpleAddAction, added in the object's init box, says {t = 1}
Both triggers are set to be repeatable, to be evaluated on server. When I test it out, I get only one set of "1st wrong Option", "Correct Answer" actions on object. But tonight, on actual game session with multiple people. I got many such sets.
So basically you want to have three phases, and they need to select the correct answers three times in a row to proceed?
And how is the settings of the first trigger and second (the trigger that adds actions) one?
Basically, yeah. If they get the wrong answer, they get the addActions for the phase they're in.
Type= None, Activation=None, both Repeatable and Server Only are checked, and under Condition, I only have the t == 1 or trg0 == 1 conditions.
Hmm it sounds like you're executing the remoteExec's globally which causes multiple same actions, but not sure which part of it causes
its a mod for a community, basically the mods being used as a ban list without the unit owners consent
Yeah, that's why I'm confused. I'm fairly new to scripting, but I realized I needed to do remoteExec to make the actions available to everyone. But they seem to be getting executed repeatedly. That's why I'm confused. Do you think it's me making the trigger evaluated on the server?
Hi, I'm new to scripting in Arma 3 and i barely know anything. Can someone explain to me a step by step on how to integrate Firewill aws please. I know the google doc tells me how but I'm confused on what to do still.
https://docs.google.com/document/d/1Jb8sj8uX4f-vQSKJlr55ckJq6AQ6ZM3LZLe9w4ACM40/edit
FIR Air Weapon System(AWS) Integration manual for addon maker by Firewill New Version : 2019OCTV2 Table of contents 1. Basic Integration 2. I-TGT Integration 3. ECM Integration 4. AMS-Lite Integration 5. Example config Basic Integration after AWS 1.98 “Joint Assault” update, many thing...
So can anyone help me with setting squad names in game. I am running the KP Liberation Framework and want to rename my squads however when I load into a multiplayer game with the squads, the name is reverted back to the default name (in this particular case Bravo 1-6)
There is a chance something is renaming it but I cannot find what is as I have disabled all of the KP liberation renaming menus and whatnot
RoleName @RoleGroup
is what I use, and it seems to work.
See ive tried that, and ive tried having it pushed the same name as part of the init field, and it still switched back after about 3 seconds in game
sounds like the framework overwrites it then
Ughhhh, ive looked for all instances of groupId and groupIdGlobal. Disabled all of them that make changes. Is there another way to rename squads outside of those 2 commands
Sorry setGroupId and setGroupIdGlobal
Have you looked for framework documentation, or asked the framework author?
Yeah ive talked to a couple of them. Its a reoccurring issue with this framework that nobody has put out a clear solution to, even though several other Lib servers somehow make it work.
Sadly changing the callsign doesnt work either
Hi all. How to get effect in SQF script as Hack UAV vanilla action?
I need to connect to enemy UAV
https://community.bistudio.com/wiki/enableUAVConnectability
I do believe this should work
Never bothered with it, not sure how it will work but official mission uses this command
what happens to client's network ID when he disconnects from server, will some other player who joins get that same ID?
Didn't help...
no, afaik it just keeps incrementing as new clients join
ok, ty
it's a unit trait, see setUnitTrait
https://community.bistudio.com/wiki/setUnitTrait
I need to connect to enemy UAV.
I know, hence why I answered this
Did you read the page?
Yes, i did use this command before, it allows unit to use special traits...
I not need "addAction", i need result: connected UAV
ah, then it's different
try switchCamera and/or remoteControl then
if it is to have a hacked, on your side UAV you have to make it join a group of your your side I believe
question: so im planning on doing unitCapture for a helo insert for the start of an op, but i only want the insert part be done with unit capture, and after the payload is dropped off, i want ai to take over, does that work?
Yep
perfect!
Something is wrong with this code (brackets, i guess) Who can say how will be right?
_backpackincontainer = ((getBackpackCargo _container) select 0) select {
_vehiclesConfig = configFile >> "CfgVehicles";
_itemConfig2 = _vehiclesConfig >> _x;
(getNumber (_itemConfig2 >> "isbackpack")) == 1 and { (getNumber (_itemConfig2 >> "type")) == 1 AND configName _x isKindof "Bag_Base"} configClasses (configFile >> "CfgVehicles")
};
The brackets are fine, it's the condition that does not make sense. The condition (i.e. the last line) is (...) == 1 && {...} configClasses (...), and that evaluates to <boolean> && <array>, which is not valid.
What is the code supposed to do?
check it is backpack or not
Is (getBackpackCargo _container) # 0 not accurate enough? It returns all backpacks stored in _container.
May be, will check it.
@willow hound not working this way :
_backpackincontainer = (getBackpackCargo _container) # 0;
What output do you get?
And what is the output of systemChat str _container?
no errors with last command
But that doesn't answer either of my questions.
Sorry , my knowledge in this is quite low. What i need to do?
Use this code ...
systemChat str _container;
_backpackincontainer = (getBackpackCargo _container) # 0;
systemChat str _backpackincontainer;
```... and tell us what the output in the system chat is.
14f5a88eb00# 4485321: proxy_usbasicammobox.p3d
["B_Kitbag_mcamo","B_FieldPack_cbr"]
seems it's working and my next steps not working...
Basically repeat that process until you find what's wrong
That is quite possible, yes.
Thanks, will do
(getNumber (_itemConfig2 >> "isbackpack")) == 1 and {
(getNumber (_itemConfig2 >> "type")) == 1 AND configName _x isKindof "Bag_Base"
} configClasses (configFile >> "CfgVehicles")```
This part doesn't make any sense. It's logically wrong. The condition for `configClasses` is somehow also the right half of an `and`. It needs rethinking.
It isn't always the most compact, but when I make complex lookups I usually split them into conditions. At least when first writing it
_cond1= 5==5
_cond2= true==true
If (_cond1 and _cond2 and _cond3)
@manic kettle good idea, thanks
In CfgWorlds and airports we have ilsDirection[] = {-0.5505,0.06105,-0.8349};, how do I translate that to the direction the runway is facing?
So i got ACRE2 installed and i added two languages: arabic and english, it shows as common and civilian. Any help?
https://community.bistudio.com/wiki/Arma_3:_Dynamic_Airport_Configuration has some information about runway stuff.
Cheers, took me a while but got it;
DT_airportLocations = [];
private _config = configFile >> "cfgWorlds" >> worldName;
private _primAirport = getArray(_config >> "ilsPosition");
private _primAirportDirection = abs (asin ((getArray(_config >> "ilsDirection")) select 0));
DT_airportLocations pushBack [_primAirport,_primAirportDirection];
player setpos _primAirport;
player setDir _primAirportDirection;
also made a horror of a one liner 🤣
AI just moves through my script-spawned compositions, is there some way to not have that happen?
like maybe a special setting so AI at least tries to move around it?
How did you spawned the stuff?
This happend you in singleplayer or in a server?
Wiki dont say anything on how is created, maybe reading the fuction will be a good way to know if its created as simpleObjects or locally where the fuction is executed
nevermind, doesn't work on 2 of the airports at altis
Points 180 degrees the wrong direction
don't you use atan2 to get the angle? 🤔
I want the runway direction, not the glideslope 😦
isnt ilsDirection that
yes
I use something like this: ```sqf
_afDir = getArray(_afCfg >> "ilsDirection");
_runwayAngle = (_afDir # 0) atan2 (_afDir # 2) - 180;
Why not just use getdir on the runway itself
didnt know that works
Whaddaya mean the runway?
[[[14382.4,15924.6,0],scalar NaN]] happens for the terminal
Well runways are just roads. Use nearRoads
Or
_runway= roadAt _pos
the nearroads thing may work, just trying it now
If you know the exact location of the runway which I assume you do, roadAt is better
ilsPosition is relative to the airfield's own position (ONLY in case of dynamic airports)
Some of the runways have the runway object facing the wrong way aka, not down the strip
DT_airportLocations = [];
private _config = configFile >> "cfgWorlds" >> worldName;
private _primAirport = getArray(_config >> "ilsPosition");
_primAirport set [2,0];
private _primAirportDirection = getDir (roadAt _primAirport);
DT_airportLocations pushBack [_primAirport,_primAirportDirection];
{
private _secAirport = getArray(_x >> "ilsPosition");
_secAirport set [2,0];
private _secAirportDirection = getDir (roadAt _secAirport);
DT_airportLocations pushBack [_secAirport,_secAirportDirection];
} forEach ("true" configClasses (_config >> "SecondaryAirports"));
(DT_airportLocations select 4) params ["_pos","_dir"];
player setPos _pos;
player setDir _dir;
For example on Altis, this sets you at Molos airfield, north side of runway, pointing into the sea
I would put a picture but 🙃
I guess I'd need to figure out if there is another slab of runway ahead of it, and if there isn't, invert it by 180 deg
Oh. Did you convert your ilsdirection to degrees?
What result did it give you
For what sorry, I ended up looking at roadAt
also for context, i basically want to write a script which can spawn helicopters nicely spaced down a runway, starting at the ilsPosition
This is what you want. It's just math to Convert at this point.
Inverse sin(-.5505) = -.58 radians
= -33 degrees
That's the opposite of the landing direction
So adding 180 = 147
lemme see if it works on these 2 weird airfields
DT_airportLocations = [];
private _config = configFile >> "cfgWorlds" >> worldName;
private _primAirport = getArray(_config >> "ilsPosition");
private _primAirportDirection = 180 + (asin ((getArray(_config >> "ilsDirection")) select 0));
DT_airportLocations pushBack [_primAirport,_primAirportDirection];
player setpos _primAirport;
player setDir _primAirportDirection;
Is this what you mean?
private _config = configFile >> "cfgWorlds" >> worldName;
private _afDir = getArray(_config >> "ilsDirection");
_runwayAngle = (_afDir # 0) atan2 (_afDir # 2) - 180;
player setdir _runwayAngle;
That works on all Altis airfields 🙂
Just gonna check Tanoa - works perfectly
Thankyou so much bud, you've hit it perfectly now;
DT_airportLocations = [];
private _config = configFile >> "cfgWorlds" >> worldName;
private _primAirport = getArray(_config >> "ilsPosition");
_primAirport set [2,0];
private _ilsDirection = getArray(_config >> "ilsDirection");
private _primAirportDirection = (_ilsDirection # 0) atan2 (_ilsDirection # 2) - 180;
DT_airportLocations pushBack [_primAirport,_primAirportDirection];
{
private _secAirport = getArray(_x >> "ilsPosition");
_secAirport set [2,0];
private _ilsDirection = getArray(_x >> "ilsDirection");
private _secAirportDirection = (_ilsDirection # 0) atan2 (_ilsDirection # 2) - 180;
DT_airportLocations pushBack [_secAirport,_secAirportDirection];
} forEach ("true" configClasses (_config >> "SecondaryAirports"));
This gets all airports, and populates an array with their position and direction 🙂
If you don't mind, could you explain how you came to use atan2 for the right solution?
i'm not very good at maths but I have learned you get directions that way
the solution you find when googling also I believe 🙂
sine and cosine are sorta "symmetric" around x and y axes (I'm not sure if that's the correct word, but what I mean is: sin(-x) == sin(x + 180) but -x != x + 180 )
so you can never correctly get the whole range of 360 angles just by doing asin or acos alone
you need both
sine gives you the "y"
cosine gives you the "x"
dividing the two gets you the slope
but if you devide and do atan the sign gets lost
hence why atan2 is used
is there a way to throw an error that just kills the running script, ideally also from called functions?
im trying to crash the script so hard on invalid input types, that the whole thing stopps running
bis_fnc_error and assert dont do that, they basically just print a message afaik
params returns false
use that and exitWith?
well, it also returns false on default value, sooo
isEqualTypeArray or isEqualTypeParams
_crash = {
if (true) exitWith {
["FUCKY WUCKY"] call bis_fnc_error;
}
};
[] call _crash;
diag_log["its still running :("];
it logs the last statement still
i want to crash the calling script too
18:02:28 ["after error code ran"]
18:05:30 ["its still running :("]
of course
exitWith requires to be called in the main scope
yeah thats what i mean. i want to exit all scopes, not just the innermost ne
like a good old java error that just kills the whole application
if !(_this call _areParamsValid) exitWith { ["wrooong"] call BIS_fnc_error };
// do stuff
you don't have exception systems in SQF, so no Java for you
yeah i see
you have try-catch, though
shame. means the main "application" keeps running with invalid return values from crashed fucntions, which is dumb
thanks anyways
^
have error management in your functions
cant really manage invalid input data though except return nothing or an error 😛
thats why im trying to crash
cant handle -> hard crash
collect result
check null or nil
exitWith
yeah
guess the main script will just have to test return stuff 🤷♂️
or just make up data for the invalid inputs and run silently wihtout ever telling the caller lol 🧠
what type are road (-objects)?
testing for "isEqualType objNull" returns true
18:24:36 ["crossroads before fortifying:",[1683651: ,1683483: ,1683827: ,1683469: ,1683485: ,1683692: ,1683521: ,1683672: ,1683676: ,1683482: ],"type objNull:",[true,true,true,true,true,true,true,true,true,true]]
never mind, i effed up my debug. they are equalType objNull
Yeah roads are (map) objects.
well, they are technically objects but they don't have classes (iirc)
Hey. this might be a dumb question. I am trying to wrap my head around creating and calling/spawning functions in a mod. I have a scripts folder in my mod with an sqf file named fn_test.sqf.
this is the contents of that file:
/*
Author: Sox
Description:
Returns:
*/
_testUnit = _this # 0;
_testUnit enableSimulationGlobal false;
and I have an init event handler on a unit using _this spawn nmd_fnc_test;
when I spawn my unit in Zeus the function is not executed. Is anyone able to see where I am going wrong?
https://community.bistudio.com/wiki/Arma_3:_Functions_Library#Function_Declaration
You still need a cfgFunctions to tell the game where to look for function files
Ah okay. Thank you
im having trouble adding a briefing to a dedicated server, writing it in the initServer does not work for me.
player createDiaryRecord ["Diary", ["Mission", "Die takistanische Armee hat zwei hochrangige Generäle zu Besuch bei Ihren Artilleriestellungen"]];
player is nonsense on a dedicated machine
you should be running that in initPlayerLocal.sqf
Does anyone have any bright ideas for figuring out if the player can be seen (line of sight ideally, knowsAbout stays at 4 even when player goes into cover) by enemies?
how long does arma’s credits last for again? need it for a script where the mission ends immediately upon the credit roll’s end
also using bis_fnc_credits_movie, players could just press esc, and they’d return to their normal screens, anyway of disabling that?
raycasting
For each placed enemy? Sounds expensive to me 
This is to be run every second/half second btw ^
Next question too, what's the command for finding ballistic protection of an item? Wiki search doesn't seem to be helping me
You can exclude the ones that are not within FOV
But said enemies may be looking at player from behind
I mean exclude from raycasting the enemies which the player is not within their FOV
do you really need to check every single one?
just do group leaders only, with various constraints, like said above, fov etc
Needs to be all enemies within a radius I suppose as is checking if player is undercover or not
some commands that might be of use, lineIntersectsSurfaces, selectionPosition, eyepos...
maybe each enemy can cast 3 lineIntersectsSurfaces, head, pelvis, legs
thus far I've found this from the forums
if (!(terrainIntersect [(eyePos player), (eyePos peter)]) && {!(lineIntersects [(eyePos peter), (eyePos player), peter, player])} && {peter knowsAbout player > 0.35}) exitWith {systemChat "I CAN SEE YOU";};```
targetKnowledge
use the last seen time
subtract it from current time
you get how long it's been since AI last saw the player
if it's short enough he's been spotted
if the AI hasn't seen the player I think the spot time is -someLargeNumber (e.g. -1e10)
which when subtracted from the current time becomes a very large positive number=> not spotted for a long time => still undercover
legendary, thanks -- should be all i need now for this, first time ive used pseudocode 
assume it's same/similar performance as variable lookup?
no targetKnowledge is relatively expensive
but at least it's way faster than line intersection
no way to do it for the entire side or something similar?
also it should be eyePos to aimPos not eyePos to eyePos
(actually engine does both in short distances)
targetKnowledge is unit-unit
iterate it over an array of certain side to get what you want
should be better than raycasts for that purpose then, right?
ofc
you'll actually use the AI visibility checks
not your own code (which could be wrong)
Ah, so engine's doing it already and I'm just checking what it's doing?
e.g. in your code the player will be spotted even if you manage to get a raycast in a split second
but AI usually have a time period before they spot the enemy
yes
how do you think the AI spot you? 
with aimbot, usually 😅
but yes, just checking through all units to see if any of them have seen the player in the past 10 seconds or so? should be fairly easy then just checking if player is overt etc
yeah
also combine it with knowsAbout
iirc sometimes the AI do spot you but don't correctly identify you
So check if knowsAbout == 0.4 too?
Oh wait I meant 4 yeah
use something like _knowsAbout > 2
or just 4 
you should test it yourself to see which one gives the best result
How long does it take roughly for it to go back down from 4? I couldn't get it to decrease on VR terrain once the AI spotted me 
Yeah, probably not best then if it's being used for checking if enemy can see player or not
It's moreso for ensuring the player doesn't just take off all their armour etc in front of enemies to go undercover, actual overtness will generally be done by the conditions (weapon equipped etc) so AI will shoot at them regardless
like I said, use it to see if they have identified you
not to check if they see you
Oh so they won't have a high knowsAbout if the player is at a longer distance?
yeah
it goes up gradually the more they see you
just monitor both knowsAbout and deltaSpotTime via debug console watches or hints or something to see how they change and relate to each other
That's probably quite useful for the wanted list then, only increase timer if knowsAbout is over a threshold -- and if player hasn't been identified yet with targetKnowledge then thats fine as they're probably too far out of range, right..?
And I'm doing that at the moment, trying to get knowsAbout to drop beneath 4 though
if you want it to drop you can do so manually using the forgetTarget command
e.g. if deltaSpotTime > 60 (i.e time > spotTime + 60)
I could always divide the deltaSpotTime by knowsAbout perhaps in order to scale it?
So if 12 seconds has passed since player seen but knowsAbout is still 4, gives value of 3
Yeah add a check for knowsAbout being 0 too?
nah doesn't make much sense
e.g if dT is 3 but knowsAbout is 0.25 you get 12... 
Wait yeah that's true ffs
if anything you should multiply them not divide them
but that doesn't make any sense either
just use 2 separate conditions
Wait yeah for some reason I thought they were the other way around
Does targetKnowledge only work once they've identified the player then? If so that's exactly what I want lol
no like I said it returns some large/invalid numbers/values
I think it also had a detected side parameter
also iirc it does incorporate knowsAbout into itself?
check the wiki
[knownByGroup, knownByUnit, lastSeen, lastThreat, side, errorMargin, position]:
yeah it has detected side but not knowsAbout
Yeah I'll mostly just do > 60 or something similar so the large numbers won't be a massive issue, knowsAbout not dropping even when player is out of LOS and distance is an issue for me though as I want the player to be able to go out of LOS and drop their kit and then go back in LOS and be fine provided they're not on the wanted list
Yeah, check for side being one the side of the target is hostile to right?
no I think just checking _side == side player is enough
What'd be the point of the check then? I'm confused
if they haven't identified you you get sideUnknown iirc
Aaaah gotcha
I was thinking for independent units but I can just run the entire script on all sides that are hostile to the player's
just monitor those stuff in debug console (or via hints) like said before
yeah
And then I'll just add another server handler that searches through the naughty list every second or so and checks if those have been seen by any enemies in the past minute or so then remove them?
Wait no I've confused myself now
I want to make it so the player won't be able to go undercover if they've been identified via face etc which would be mitigated by wearing a balaclava
Which yeah I'd just do how I'm already doing it 
if i use briefing on dedicated server it does not work in the localplayerInit on for some reason with
player createDiaryRecord ["Diary", ["Mission", "Die takistanische Armee hat zwei hochrangige Generäle zu Besuch bei Ihren Artilleriestellungen"]];
no briefing
waitUntil {!isNull player}
in the initplayerlocal right? then it should show
yeah (if that was the problem)
but not sure if diary records are persistent after respawn 
they should be but idk
coolio
i will try thx Leo !
mhh
no entries in diary
im on dedicated server
people told me that player is not existent there?
For some reason the targetKnowledge position value is increasing even when both units are stood still 
initPlayerLocal runs for every connecting player on their machine
not DS
yes
why would you want that anyway? 
it updates based on their last velocity when they saw each other
that's why the red target icon moves when you lose sight of enemy
Stopping the player going undercover within a radius of when they last fired at the AI 🤔
Oh right
that parameter doesn't give last fired pos
Wait that's probably actually more useful so the AI don't be completely stupid if you shoot from moving vehicles then go undercover again further down the road 🤔
thx ! another question, still searching for a way to sync all players for the loading screen and mission start before a intro is played in the mission on dedicated server
i tried several methods which worked, but now i switched to dedicated server where they are absolute
Been using createVehicle to make interactable spawners for vehicles.
Below is an example of the contents of an SQF file called by the in-game object's init
_hemtt = "B_Truck_01_mover_F" createVehicle [5753.113,1116.691,0.061];
How do I modify the script so I can add rotation as a parameter?
use setDir after the vehicle has been created using _hemtt as the vehicle name
you mean you want all intros to play at the same time?
yes indeed. briefing is not showing on dedicated server for some reason
what is argument locality for ropeUnwind ?Unfortunately wiki has no information on that?
any idea why i cant join my server ?
i got all mods active but cant get past lobby:
No entry 'bin\config.bin/CfgGlasses/VSM_Balaclava_black_glasses.identityType
using TOPHES server tool
if cant solve the error is there no command for server tools that they skip errors ?
tried loading that mod? (on both the server and on yourself)
Hey boys, theres not a looking for script section, but Im hoping one of yall can point me in a direction to find a script to arrest a multiplayer player. Just need to be able to scroll wheel them and have that tp them to a jail (just tp to xyz)
setPosASL? 🙂
Sure.
To be honest, I have never scripted in A3. I don't know the logic (siad yes bc I googled it) 🙂
So theres a chance I could be wrong.
you will need addAction and setPosASL
their name state what they do more or less (unfortunately I am not on PC so I cannot help further for now, but in 10h yup)
Ok, this is something I didn't expect and wasted a few hours on: Turns out that the remote execution status is passed through spawn.
oh!
Is there a way to do something like copyToClipboard in multiplayer? Running a mission where I'd like to save player kits and I got that part of the script working but I can't get the information
it's engine-based
I believe the conventional way is to save it to a variable, perhaps in the server profileNamespace
you can if you are the player-server, otherwise use diag_log (or indeed save it somewhere ^)
You can use https://community.bistudio.com/wiki/getSoundController with the interior controller (https://community.bistudio.com/wiki/Arma_3:_Sound:_SoundControllers) to find that information with exactly the same accuracy as the indoor gun sounds system
just double checking what this means in plain english
there is a 70% chance of either helmets or headgear being selected, figured that much out
but what does the randomweighted part imply? that the option becomes between Helmets and Fullmask, and you're more likely to receive a Helmet?
30% chance of the first part running, 70% chance of the second part running, mutually exclusive
and selectrandomweighted will select an element in an array based on the weightings provided to it
so [] has a 1.5 weighting versus the second which has a 1 weighting -- so you have a 25% chance of something being put on if my maths is right
ahh, thanks.
my maths probably isnt right but you get the gist
since armaholic is down, im searching for the enigma civilian script, any idea where i cant find it?
How can you remove the option to pick up a weapon off of the ground?
Disabling simulation just made it so that the model would move downwards and not appear in the inventory, using BIS_fnc_replaceWithSimpleObject just made the model disappear, and I even tried using removeAllActions this to see if that might work, which it did not.
simplest solution I found is to simply make it a simple object
When I did that, it didn't display the model for it
Unless that is a different case for when simulation is diabled and replaced with a simple object
Yep I tested it again, with simulation disabled and using this call BIS_fnc_replaceWithSimpleObject, the model does not appear
the function is likely using the weaponholder entity instead of the weapon
manually creating the simple object should work\
A createSimpleObject can take a weapon p3d. It might helps
Yep, I tested it in-game and it did work, but it didn't apply the texture, but I saw setObjectTexture on the createSimpleObject page, so I'm looking at that now
You can't sadly
Oh wait, just came up to my mind, have you tried to disable the simulation of weaponholder?
Not through the init or anything, I can give that a shot though
I barely remember that it works
Yep that worked perfectly
At least for one of the weapons I had placed, the other is still invisible but I might have just forgotten to change something on that
Yep, forgot to select them when changing the init, so they were still being replaced with simple objects
Nice
Thank ya Polpox
I guess its technically impossible to have vehicle shoot without any unit inside it?
Not taking UAV/invisible units into account.
I barely remember that a Logic can fire a vehicle weapon. Not sure if I'm misremembered
I went to work on some other parts and apparently it does still have the action, it just appears lower than the weapon itself for whatever reason
Good morning,
If I want texture in screen
(Land_TripodScreen_01_large_black_F) from screenshot which I taken in game.
Resolution to pic is 1911*1065.
How to I define that fits in screen. So do I need make transparent background which is 2048*1024 and my pic get little scale from normal. But it fits in screen correctly with wrong scale?
A resolution doesn't matter but aspect ratio. Of course it does need to be 2^n though
Jeah , so I must scale it to 2048*1024 to get that 2^n , and it's not same scale than in my screen. Maybe I just live with this. It looks in screen almost same but maybe I'm only one who knows is not correct ratio
I meant ratio is 1911*1065 pixels, and I need get that to 2^n, just thought if there is some kind workaround to this.
In example is
_obj setObjectTexture [0, "#(argb,512,512,1)r2t(rendersurface,1.333)"];
What does r2t(rendersurface,1.333) ?
If you supply your texture as JPEG, you can use non-2^n sizes, game converts it all automatically to proper sizes, generates mipmaps, etc.
Yes, I see and it works correctly. The only problem is the image size which is 3 times larger than the .paa, but maybe players could wait a couple of seconds more when loading a mission
not possible, you need a unit to man the weapon
You can try playing around with JPEG quality. Its always a trade-off between file size and amount of artefacts your image can withstand. PAA has its own (DXT5?) artefacts and sometimes can look even worse than JPEG.
Yeh, that's true. I will set up that in JPEG format. Thanks for the info
any luck?
Nope, even if you start shooting salvo and move unit out, shooting stops until another unit enters the seat.
What's the usecase/situation of it BTW?
i guess you could attach fixed forward firing turrets to a car, and fire them on input action / key press
"\A3\Ui_f\data\Map\Markers\Flags\AAF_ca.paa"
how do i actually get to this directory? i dont know where the \A3\ folder is
i can unpack PBOs etc. i just cant find this specific directory
a3 is the prefix of almost every vanilla pbos. So in this case, Arma 3\addons\ui_f_data.pbo it is
Am I being blind or is there no way to easily find what sides the player's side is hostile against without having to do a big switch statement?
_enemySides = [];
{
if ((side player getFriend _x) < 0.6) then {
_enemySides pushBack _x;
};
} forEach [east,west,independent,civilian];```
or even [east, west, independent, civilian] select {(side player getFriend _x) < 0.6} for extra one-lineniness
Ah, thanks 🙂
Oh, [player] call BIS_fnc_enemySides is a thing but runs much worse than what Nikko provided 
next question
_enemySides = call KJW_Imposters_fnc_enemySides;
{
{
if (_x knowsAbout player == 4) exitWith{true};
} forEach units _x;
} forEach _enemySides;``` How would I make the sides loop exit if `true` is ever found? 
findIf?
_enemySides = call KJW_Imposters_fnc_enemySides;
_knownAbout = {
_knowsAbout = {
if (_x knowsAbout player == 4) exitWith {true};
} forEach units _x;
if (_knowsAbout) exitWith {true}
else {false}
} forEach _enemySides;
_knownAbout```
I *think* this should work but will check `findIf`
private _isFullyKnownByEnemies = _enemySides findIf { _x knowsAbout player == 4 } != -1;
oh thats probably more efficient then lol
knowsAbout takes a side too yes 🙂
wait does it
oh so it does im blind then
and that'll return the number so just make it return true if > -1?
_isFullyKnownByEnemies is a boolean
findIf returns the array position where said condition applies
oh, perfect then, thanks 🙂
time to iterate through all units to make sure the player isn't within radius of where the enemies think they are and hasnt been seen in # amount of time 
_enemySides = call KJW_Imposters_fnc_enemySides;
_knownToEnemies = {
_knowsAbout = {
_knowledge = _x targetKnowledge player;
_deltaTimeSeen = time - _knowledge#2;
_distFromPos = player distance _knowledge#6;
if ((_deltaTimeSeen > KJW_Imposters_Setting_TimeToIgnore) && (_distFromPos > KJW_Imposters_Setting_DistanceToIgnore)) exitWith {true};
} forEach units _x;
if (_knowsAbout) exitWith {true};
false;
} forEach _enemySides;
_knownToEnemies``` similar principle to the other though
not sure about the exitWith in the forEach though
https://community.bistudio.com/wiki/exitWith says "Often used for exiting do, for, count, forEach or the whole script."
Though it doesn't give any examples to be fair
_arr = [1,2,3,4,5,6,7,8,9];
{
systemChat str _x;
if (_x == 6) exitWith {systemChat "Exited!"};
} forEach _arr;``` works as expected, exits loop at 6
yes
you exit the loop
not the scope where forEach is
Yeah, that's what I want to do, exit loop on first occurrence and then run the rest of the code 🤔
your indentation makes it tough, let me redo it
or was it my Discord window size
Probably discord window size, I usually fullscreen for looking at code :p
want it to exit the earlier forEach too as returned value is just true for first occurrence
else it'll be false and iterate through the rest of the units in the side
But it won't exit the loop surely? I'm confused
you can replace both of those with findIf
Certainly I'm just confused how I would do that
_enemySides = call KJW_Imposters_fnc_enemySides;
_knownToEnemies = _enemySides findIf {
units _x findIf {
_knowledge = _x targetKnowledge player;
_deltaTimeSeen = time - _knowledge#2;
_distFromPos = player distance _knowledge#6;
(_deltaTimeSeen > KJW_Imposters_Setting_TimeToIgnore) && (_distFromPos > KJW_Imposters_Setting_DistanceToIgnore);
} != -1;
} != -1;
``` I would imagine something like this but unsure how I would do the condition for this
How do you find the ballistic protection value for an item? Just search through config or is there a scripting command that I cannot find
yep don't listen to me 😑 was doing 3 things at the same time
all good the findIf probably works better anyway lol
if it does work that is
config, if that's not in the model itself 😬
I presume the base game already has the calculation bits for the bars in arsenal?
and then we come to the intricacies of defining "ballistic protection" in Arma
*hides*
indeed
just for an undercover system though so it should be relatively straightforward i hope
private _armor = getnumber (_x >> "armor");
_value = (_armor / (1 + _armor))^18;```noice
what
fn_arsenal calls fn_configExtremes. fn_configExtremes does that 🤷♂️
private _armor = getnumber (_x >> "armor");
private _passThrough = getnumber (_x >> "passThrough");
_value = (_armor / (1 + _armor))^9 * (1 - _passThrough);```
ah
you know what the purpose of the maths bit is?
Should be easy as just checking if _armor > 0 really
Wait what you can just do getNumber (_x >> property) wtf
I've been trying to do logics for each cfg class for ages
…think of all the time you will save from now on!
why would you even put a cfg class in it in that case
?
no
Oh wait
I understand
you can _x = configFile >> "CfgVehicles" >> "Thing"; getNumber (_x >> "maxSpeed");
_x up here includes the Cfg stuff its within instead right?
Versus this which would look for "Thing" instead of CfgVehicles etc?
here? yes, _x is a config
Oh right, I thought it was classname
Looks like I still have to do that logic anyway
welp, sounds like "ballistic" is basically getNumber (configOf _item >> "ItemInfo" >> <MostRelevantHitpoint> >> armor) with some math voodoo to spread the values a bit
here it's more of a pseudocode, it needs an actual object to work
I would assume the hitpoint I want would be whatever the aimpos is or something?
MostRelevantHitpoint being something like "Head" for helmets and "Chest" for vests
But there's a chance they may not be configured like that, right?
🤷♂️ it all goes into the soldier damage voodoo doll in the end
if somebody decides to make funny classnames for armor hitpoints - they're likely to still have a vanilla HitpointName member 🤔
No "central" armour value and such is there?
Vest class 1: abdomen/body/chest/diaphragm, armor 8, passtrhough 0.5
Vest class 2: abdomen/body/chest/diaphragm(/pelvis), armor 12, passtrhough 0.4
Vest class 3: abdomen/body/chest/diaphragm, armor 16, passtrhough 0.3
Vest class 4: abdomen/body/chest/diaphragm, armor 20, passtrhough 0.2
Vest class 5: abdomen/body/chest/diaphragm/arms/neck, armor 24, passthrough 0.1
Vest class ER:abdomen/body/chest/diaphragm/arms/neck/pelvis, armor 8/16/78, passthrough 0.5/0.3/0.6
=======================
Helmet class 1: head(/face), armor 4-2(/4), passthrough 0.5-0.8
Helmet class 2: head(/face), armor 6(/4), passthrough 0.5
Helmet class 3: head(/face), armor 8-7-6-10(/4), passthrough 0.5
Helmet class 4: head, armor 10, passthrough 0.5
Helmet class 5: head(/face), armor 12(/8), passthrough 0.5``` for vanilla balance if my old dump is correct
Wonder how ACE arsenal does their sliders 🤔
at the cursory glance - the same as vanilla arsenal does
so private _armor = getnumber (_x >> "armor"); etc? What would _x point to in this instance?
configFile >> "CfgWeapons" >> _classnameOfItem >> "ItemInfo" >> <MostRelevantHitpoint>
this seems to be ACE protection sorting function sqf (([[_itemCfg], ["passthrough", "armor"]] call BIS_fnc_configExtremes) select 1) params [["_passthroughMax", 0], ["_armorMax", 0]]; private _protectionCombined = _passthroughMax * _ballisticCo + _armorMax * _explosiveCo; _protectionCombined
Ah right
I’m using the amazing MGI vehicle respawn script and trying to get respawned vehicles to join high command. I’ve tried hcsetgroup in the vehicle init field and while it works on mission start it doesn’t when they respawn. I guess init is not passed to respawn. Any other way to call the hcsetgroup when the unit respawns?
I can see 2 ways of doing it, both implies coding, you can either set them manually upon spawn to be part of HC or integrate the init field upon spawn inside your script, but its basically doing the same.
Both also implies modifying the vehicle respawn script but I guess you are looking for not doing such thing as you are using the init field.
hello very stupid elementary scripting question
_enemySides = call KJW_Imposters_fnc_enemySides;
_knownToEnemies = _enemySides findIf {
units _x findIf {
_knowledge = _x targetKnowledge player;
_deltaTimeSeen = time - _knowledge#2;
_distFromPos = player distance _knowledge#6;
(_deltaTimeSeen > KJW_Imposters_Setting_TimeToIgnore) && (_distFromPos > KJW_Imposters_Setting_DistanceToIgnore);
} != -1;
} != -1;
[_knownToEnemies,_deltaTimeSeen]``` how do I "carry" the `_deltaTimeSeen` variable back out to the main scope of the script?
_deltaTimeSeen = 0; at top
might make more sense to make it 1e10 or something by default tho
Yeah. Good suggestions but the respawn script is a module from the workshop that works really well so I’d rather not mess with its coding
Gotcha,
also, leopard -- do you know if ADT's performance measures just the performance of sending of the command or the effect of it? setCaptive seemed to run quicker than having a check for if player is captive first, regardless of captive state 🤔
depends on the command
setCaptive should occur instantly I think
so both in that case
wait, how is that particular example a surprise
seemed to run quicker than having a check for if player is captive first, r
the more sqf you run, the slower it gets ofc
I would've thought it would've had a larger performance impact given that it's changing side or am I totally mistaken
Oh right, fair enough then -- I thought it would've been slow tbh
It's probably just setting a flag.
yeah
Ah, fairs
Now addWeapon is slow :P
Time to try and bug fix my code that I never tested 🙂
Anyone got any idea as to why this isn't working?
_classname = vest player;
if ((getNumber (configFile >> "CfgWeapons" >> _classname >> "ItemInfo" >> "HitpointsProtection" >> "Chest" >> "armor") > 0) || (getNumber (configFile >> "CfgWeapons" >> _classname >> "ItemInfo" >> "HitpointsProtection" >> "Head" >> "armor") > 0)) exitWith {true};
false```
Returns false every time despite it being > 0 nvm its hitpointsprotectioninfo 
a question for the design knowledgeable:
Generally speaking, what is considered caching in arma3, both in units and objects?
Is dynamic simulation technically caching?
Is it case-use based?
Let's say for example, that I have 1000 objects distributed across a map that should be there all time until a player gets close and do something to them, let's say in this example that the player is destroying them and that locality doesn't matter.
Is caching these items prefered over having them be dynamically simulated?
I know that dynamic simulation freezes (disables simulation) them, but according to some scripters, hiding them altogether is the way to go.
Is this not done by the view distance too?
If all the criteria on this case being specifically static objects is to hide them and disable their interaction, isn't this being technically done by just the client view distance?
If we go by this logic, would it be correct to assume that designing a system that populates, hides, assigns dynamic sim and then unhides based on dynamic sim would be an ideal way to do basically a lot of systems that require caching?
I've been reading a couple of scripts here and there that handle large objects quantities and its doesnt come as clear the design intent, so i would appreciate opinions/experiences on this. Maybe i'm just overlooking a crucial part/meaning behind caching and that's why i cannot comprehend it fully.
This might not be the correct chat channel, but might as well leave it here.
what do you call "caching objects"? disabling simulation?
from what i've read from many what I understand by it is,
making them be available upon specific conditions, usually distance to players
disabling simulation, depending on objects, may save performance (but it is not exactly "caching")
do you have anything specific i could go read to better understand what "caching" usually means in the context of arma?
system that populates, hides, assigns dynamic sim and then unhides based on dynamic sim
Sounds like ALiVE mod
haven't used alive in a while now, but yeah, sounds similar enough.
is there a way to exit a findIf if the given condition is not met and not check any subsequent ones?
nvm exitWith{} works fine
Hey guys for a intro scene i am trying to setup infantry and tank units that will march and after 2 minutes get deleted. There are various units with different animations so i want to limit it to a radius. These two scripts got the closest to what i wanted to see but i can't seem to get it right. Any help.
I put the code within a trigger that gets activated when opfor is present
{ _x playMove "AmovPercMwlkSlowWrflDf"; _x disableAI "ANIM"; }forEach nearestObjects [this, ["all"], 100]; sleep 120; {deleteVehicle _x} forEach nearestObjects [this, ["all"], 200];
and
{ _x playMove "AmovPercMwlkSlowWrflDf"; _x disableAI "ANIM"; }forEach allUnits; sleep 120; {deleteVehicle _x} forEach nearestObjects [this, ["all"], 200];
This, in trigger is thisTrigger
Oh, thanks
I'll test it out now
It deletes everything without listening to the sleep
Right now i got it like this
{ _x playMove "AmovPercMwlkSlowWrflDf"; _x disableAI "ANIM"; }forEach nearestObjects [thisTrigger, ["all"], 100];
sleep 60;
{deleteVehicle _x} forEach nearestObjects [thisTrigger, ["all"], 200];
};```
But the animation won't play
And it also don't delete
🤔
When using spawn , you need define trigger in spawn.
[thisTrigger] spawn {
params ["_trigger"];
{
_x playMove "AmovPercMwlkSlowWrflDf";
_x disableAI "ANIM";
} forEach allUnits;
sleep 120;
{
deleteVehicle _x
} forEach nearestObjects [_trigger,["all"], 200];
};
Thanks
Also doesn't forEach allUnits activate the animations across all opfor on the map?
Hmm.. should I be using spawn over execvm?
breakWith might be better
I think the code isn't the best for performance regardless, double checking now but it seems to have worse performance with more AI when they all know about the player
depends on use case but generally speaking yes
execVM recompiles the script every time
Which is certainly odd as I should just be accessing variables I believe? No actual calculations are done other than subtracting last seen time from current time and getting player's distance to where AI thinks they are, which is a pretty lightweight calculation 
well like I said before targetKnowledge is not exactly cheap
Cheaper than raycasts though, no?
I was under the impression raycasts were quite cheap though
I'll post once I've verified what it's doing performance wise
I can confirm that you misunderstand the meaning of the term caching - just have a look at https://en.wikipedia.org/wiki/Cache_(computing) and you should see what I mean. What you describe is not caching.
As for the other part: Things that are outside of your view distance are still simulated, they are just not rendered.
If they were not simulated, they could not do anything (e.g. move, shoot), and under many conditions, that is not desirable: Imagine an enemy aircraft that attacks a position within your view distance and then leaves your view distance while circling back around for another attack run - that aircraft would freeze in mid-air until you move closer to it so that it comes back into your view distance. Disabling simulation on units also means that they stop keeping track of enemies that they know about - so by the time you moved the aircraft back into view, the position it was going to attack may no longer be a valid target.
(Take the following statements with a grain of salt since I have no knowledge of the inner workings of the RV engine.)
The optimization potential of disabling simulation comes from reducing the load on the server in terms of AI (e.g. path finding, target allocation) and physics (e.g. collisions, projectile trajectories) computations.
If you hide an object, it is no longer rendered and it can no longer collide with other objects. Maybe this reduces collision calculations a little bit, I don't know. It also reduces load on your GPU since it no longer renders the object, but the main performance bottleneck in A3 is the CPU, not the GPU. And the CPU load for the object probably hardly changes just be making the object invisible, because it doesn't halt simulation of the object (i.e. objects still do almost everything they normally do, you just can't see it).
the CPU load for the object probably hardly changes just be making the object invisible
actually I think since it won't check collisions anymore it'll make a diff when objects are close to each other
and maybe the engine won't poll those objects for screen draw (which does need some CPU calc)
0.0229 ms
10 OPFOR AI, unaware of player
0.0790 ms
10 OPFOR AI, all aware of player
0.0226 ms
2 OPFOR AI, unaware of player
0.0287 ms
2 OPFOR AI, both aware of player
_enemySides = call KJW_Imposters_fnc_enemySides;
_knownToEnemies = _enemySides findIf {
units _x findIf {
if (player distance _x > 1000 || !(alive _x)) exitWith{};
_knowledge = _x targetKnowledge player;
_deltaTimeSeen = time - _knowledge#2;
_distFromPos = player distance _knowledge#6;
(_deltaTimeSeen > KJW_Imposters_Setting_TimeToIgnore) && (_distFromPos > KJW_Imposters_Setting_DistanceToIgnore);
} != -1;
} != -1;```
`KJW_Imposters_fnc_enemySides` just checks which sides are hostile to the player, small `forEach` loop with `pushback`
oh I do want breakAt there then but no AI were meeting that condition regardless
no
you just need lazy eval or continueWith
_player = player;
units _x findIf {
_player distance _x < 1000 && alive _x && {
_knowledge = _x targetKnowledge _player;
_deltaTimeSeen = time - _knowledge#2;
_distFromPos = _player distance _knowledge#6;
(_deltaTimeSeen > KJW_Imposters_Setting_TimeToIgnore) && (_distFromPos > KJW_Imposters_Setting_DistanceToIgnore);
}
}
also using nearEntities might be faster that looping over all units
That's giving 0.0692 ms for 10 OPFOR AI who don't know about player yet too
And will try nearEntities
well your code was wrong anyway
it was ending too early
also your code will run in schd env
performance is pretty much irrelevant
Irrelevant how?
it won't affect the FPS
Oh right -- seeing as it's running locally I would imagine it won't influence network either?
So should be using
_enemySides = call KJW_Imposters_fnc_enemySides;
_knownToEnemies = _enemySides findIf {
_player = player;
units _x findIf {
_player distance _x < 1000 && alive _x && {
_knowledge = _x targetKnowledge _player;
_deltaTimeSeen = time - _knowledge#2;
_distFromPos = _player distance _knowledge#6;
(_deltaTimeSeen > KJW_Imposters_Setting_TimeToIgnore) && (_distFromPos > KJW_Imposters_Setting_DistanceToIgnore);
}
} != -1;
} != -1;
[_knownToEnemies,_deltaTimeSeen]``` right?
put player outside the findIf
Just beneath _enemySides?
above
gotcha
I mean outside _enemySides findIf
Ya gotchu
also you might want to use privates
Oh, think I ran this time when AI hadn't finished initialising or something similar -- remember reading a wiki note that AI will have things like that
Yeah will go through and private everything once it's all working well
Wait, why is that code running in scheduled environment? I'm missing something here
well I mean you should even if you're not
where are you running it anyway?
isn't it a loop that constantly checks that?
Every half second inside a CBA PFH 
wat...
per frame handler
ik
so yes loop every 0.5 seconds
Yeah, suppose I should spawn that function specifically?
while true loop every 0.5 seconds?
yeah
that code has variable performance and can get potentially very slow
it's not a good idea to run it unschd
Ah
Should I still be using call within the loop or switch all those to spawn?
Oh wait, I didn't explain properly
the cba pfh is calling the functions one of which contains this code, the code itself is not inside the cba pfh
running a spawn makes 0.0023ms versus cba pfh which makes 0.0116ms so think im fine
wat...
spawning the code does 0.0023ms versus cba pfh which does 0.0116ms
you need a return out of that so you should call it.
and why would you use spawn in a unschd code...?
I was asking because of the function that you said to run scheduled was being called inside the CBA PFH not the code itself running in there
In answer to myself, Yes there is a difference. Only some targets can use the scoreboard.
Pop-Up Target 1 "TargetP_Inf_F" cannot, however Pop-Up Target 1 (Zones) "TargetP_Inf_Acc1_F" can.
there's no difference
call in unschd = unschd
call in schd = schd
OH I was told call in scheduled created an unscheduled thread
I shall inform them of their incorrectness thanks 🙂
either way using spawn in your PFEH makes no sense
either drop the PFEH and do schd loop
thanks for you answer.
So dynamic simulation is pretty much case-based indeed, I was under the assumption that view distance and rendering did some sort of disabling when making the invisible since their collision is not calculated anymore as Leo said.
The example given is pretty much the specific case in where I would want to find a way to dynamically hide/un-hide a bunch of objects around player based locations
Let's say for example, that I have 1000 objects distributed across a map that should be there all time until a player gets close and do something to them, let's say in this example that the player is destroying them and that locality doesn't matter.
But I was kinda lost in the consideration of it even being worth it, I will waste more cycles getting proximity and hiding them than straight up relying on dynamic sim and view distance tbh. As the mission Im considering this from does have the benefit of having to traverse long distance and having stuff hidden in interiors. In the end of the day, having simulation disabled for this items that I'm using might be the best alternative, as a lot of even handlers seems to be able to intercept their events even if their sim is not active.
Alternatively, if the existence of an eventHandler that activates upon changes in simulation states of objects was possible, I could see very interesting stuff done for performance disregarding locality.
I will give a more in-depth read at what caching is in reality and what it is supposed to be describing for some of the scripts i was reading upon, as people associate it with grid based sim/hiding of units for whatever reason, Im interested in doing my own system after all.
Im gonna stop rambling now, thanks for the insight.
or do the whole thing unschd at the cost of perf drop
Yeah I replaced the pfeh with while true loop every 0.5 seconds
That's what I meant by this sorry if it was unclear