#arma3_scripting
1 messages Β· Page 104 of 1
It might be possible to overwrite the functions from mission CfgFunctions; I'm not sure if that's allowed to overwrite addon CfgFunctions. You can also do whatever other scripting you like, using mission scripts - you could make your own Warlords framework with its own functions and so on if you wanted.
What you cannot do is go into the main Arma 3 directory - not the Missions or MPMissions folder - and make direct manual changes to the base Arma 3 PBOs. Those files are outside of your mission, changes to them will not be included in your mission, they will only apply to your local installation of the game, that is not a proper way to mod Arma.
Is it possible to execute code on specific steam IDs
ok. thank you for the info. I do all my warlords work via scripts(not the editor).
I know now if someone is building a mission in eden editor via modules they are limited the what the modules are setup to do.
π€ hopefully if we get an arma 3 datapack it will have files for the base warlords stuff π€ It would be very easy if I could host those on github and be able to easily grab/fix/search things as needed.
returns 1 in sp
Thank you kjw
note its somewhat questionable regarding whether or not executing code on specific steam users is allowed in steams subscriber agreement too
Uhhh, im gonna have to go read that now
It must be a little bit allowed otherwise banning or admin allowlisting wouldn't be things
thats for servers which are not privy to the subscriber agreement
yeah i use both actually thats why I think its possible
so far the one by POLPOX works
addMissionEventHandler ["Draw3D",{BIS_gearKeyPressed = true}] ;
I mean, im just trying to use it to teleport a specific player. Not anything malicious
Doesnt mean its not against the agreement
if its part of a mission its fine too
but in the start of warlords, theres a cutText(i think?) says "OPEN REQUEST MENU WIHT I" or something like that. Not sure how to get rid of it...
its only for steam workshop published stuff
So wait, im good aslong as i dont put it on the workshop?
Quick Question if anybody knows why this happends so if i put this in init of a static turret that is controled by AI i get this error:
this addMagazineTurret [currentMagazine this, [0],100];
badly made turret
has property[] = {""}; somewhere in its config rather than property[] = {};
its a vanilla turret
and
possible a mod overwrites it etc too
but that is what causes incorrect no entry .model messages apparently
There is no mods just vanilla
what turret is it
All of them.
Perhaps the code is being executed before it has a currentMagazine
you guys can test it to just to make sure i am not crazy put this code in init of a turret and put AI on it.
currentMagazine is returning "" on the turrets 
but when you get in it then it returns the magazine
odd
But if you put this code on when player is on the turret then it works.
wait is it until a player gets in it 
ah no any unit
put ft ticket on for that then ig
ok will do.
What would be faster to execute? Thanks
private _i = 0;
private _timeToLoseTarget = ((_timeToLoseUndetected select _i) select 1);
while {_knowsAbout > ((_timeToLoseUndetected select _i) select 0)} do
{
_i = _i + 1;
_timeToLoseTarget = ((_timeToLoseUndetected select _i) select 1);
};
private _timeToLoseTarget = _timeToLoseUndetected findIf { _x#0 >= _knowsAbout };
_timeToLoseTarget = (_timeToLoseUndetected select _timeToLoseTarget) select 1;
What it does basically is that it selects a value from an array based on some value (knowsAbout).
use the ingame code performance checker
if base game its the speedometer in debug console next to uhhh server exec iirc
if adt its the stopwatch
Major difference π
private _timeToLoseTarget = myArray findIf { _x#0 >= _target select 2 };```
Is the part _target select 2 done every time it checks a new _x value or is it done once and then compared with all the items in the array. Would it be better to do the select outside the findIf?
this is what is says on wiki:
Code on the right side of the command is evaluated for each element of the array,
is there a getter for radar target
is there a way to get the current selected one
cursorTarget does it IIRC
hi its me again. I have this line: addMissionEventHandler ["Draw3D",{BIS_gearKeyPressed = true}] ;
it stops me from using the request menu in warlords which is what I want. The thing is warlords has this text on screen in the start telling everyone to hold I to open request menu. Is there anyway to remove that?
oh its polpox
or maybe to open the request menu once to remove the text then disable it? if i put a sleep though before addMissionEventHandler ["Draw3D",{BIS_gearKeyPressed = true}] ; it stops working
this is all i have in initPlayerLocal.sqf
You simply want to ignore your idea and notify players in a different way
hmmm
i can kinda live with it
was just hoping i can remove it
hahah
You need no remoteExec there
since its initPlayerLocal?
Yes
thing is tho the script you gave me stops the text from going away
since u need to open the request menu once to remove it
is there a way to addMissionEventHandler
after the request menu was opened once?
uiNamespace getVariable ["BIS_WL_purchaseMenuDiscovered", true]```
fn_WLClientInit
Thanks again @warm hedge !
Does anyone have any insight on why addItemToUniform command isn't working for me for magazines
scratch that, it's working fine. It was loading them into my empty weapons
whats the cheapest way to get all units in a marker area? and what for a trigger area?
allUnits inAreaArray _area is quite expensive if you have any units
for triggers should be: _unitsInArea = list _area;
Only if the units match the triggers condition
for markers: _unitsInArea = (getMarkerPos _area) nearObjects ["CAManBase",(getMarkerSize _area)#0];
well yes. trigger needs to be set up in this way
But that's bad
and marker woul need to be a cricle
Create any-unit trigger that matches the marker area, list units in trigger, delete trigger?
AllUnits select {_x distance marker < radiusOfMarker}?
That's super slow
private _markerPos = (getMarkerPos "marker1");
private _radius = vectorMagnitude getMarkerSize "marker1"
private _entities = _markerPos nearEntities ["CAManBase", _radius];
private _inAreaEntities = _entities inAreaArray "marker1";
with 300 units 0.0086ms, 20 in area.
and 0.0101ms if 40 in area.
allUnits inAreaArray "marker1"
// 0.0527ms
This what i used , dont remember who tell me to 1st get max radius (if not using cricle marker) and then check inAreaArray
(edited , correct way to get correct radius vectorMagnitude)
NearEntities
I've placed a prop in the editor (one the large rocks) and AI on the other side immediately tries to shoot through it. Is there a way to stop them seeing through?
how would i ensure that an action added with addAction can only be used by one player at the time?
example code:
uav1 addAction
[
"title", // title
{
params ["_target", "_caller", "_actionId", "_arguments"]; // script
},
nil, // arguments
1.5, // priority
true, // showWindow
true, // hideOnUse
"", // shortcut
"alive _target && remoteControlled driver _target != _this", // condition
50, // radius
false, // unconscious
"", // selection
"" // memoryPoint
];
i think this is the wrong way to use the remoteControlled command?
Do you mean in MP and you want an action that lasts for a few, and during that nobody can activate that?
yes it is for MP and the action should not be accessible while the uav is remoteControlled
the addAction is in the init field of the uav so anyone can access it
But not when the UAV is used by someone?
How about isNull (remoteControlled _target)?
remoteControlled driver _target isEqualTo objNull
Dunno comparing with objNull is better than that
probably slightly quicker as doesnt need to check against multiple null types but shrug
oh no you're right
isNull is quicker 
Because it checks if it is objNull, not any nulls?
Object
versus just is this the same as that
Anyone know why setDir doesn't work accuratley on AttachedObjects
Running this on an attached object but it appars that its very glitchy, sometimes it will roatet the object 90 degrees but sometimes it'll rotate less or more than 90
(_this select 0) setDir ((getDir (_this select 0)) + 90);
What's the intention behind getDir there?
its in modelspace, not sure your meant to use setdir on attached objects
To get the current direction of the "Object" and then add 90 degrees to it,
WHat would I use instead?
setvectordirandup
though you may need to write code that interprets it into roll/pitch/yaw
DO you have an example?
Or simply sqf _this#0 setDir 90?
Yeah doing that though sets the object to 90 degrees, it doesn't add 90 to the current orientation value
not for what you are trying to do
So I think either store the current value or getDir'ing the attachedTo object
Is it possible to use this command, and not get any errors, if the variable is not defined (isNil)? I want to get inside the "then" code, only if the switch variable "stealthUnit" is declared and is equal to true.
if ( _targetUnit getVariable "stealthUnit" == true ) then
{```
I mean, it works, but I am not sure if comparing Nil and Bool is acceptable.
_targetUnit getVariable ["stealthUnit",false]```
Oh, nice.
In case you want to check both nil and bool the same time, here is the way: sqf isNil "_variable" and {_variable isEqualTo true}
This is correct for elliptical markers but you need to use _radius = vectorMagnitude getMarkerSize "marker1" instead for rectangular markers, otherwise it'll miss units.
Hello, I am playing around with Old Man quest system, is cfgQuest a file itself?
Thanks. I edited my post and edited that in my own too. I didn't realize that my max range does not take corners of the rectangular. π
should I use setFog with remoteExec or BIS_fnc_setFog π€ ?
You should read BIS_fnc_setFog and see if it's doing anything interesting.
setFog on server should sync to client anyway.
(at least in current A3...)
private ["_fog","_density","_altitude"];
_fog = _this param [0,fogparams select 0,[0]];
_density = _this param [1,fogparams select 1,[0]];
_altitude = _this param [2,fogparams select 2,[0]];
if !(isserver) then {
[[_fog,_density,_altitude],_fnc_scriptname,false] call bis_fnc_mp;
};
0 setfog [_fog,_density,_altitude];
[_fog,_density,_altitude]
BIS_fnc_setFog
So basically just remoteExec but the old way
anyone know how the contact campaign blanks work? is it just a script that logs positions of dead people or some other sort of script?
or are the people who are hit just forced into an animation?
most likely normal bullets but for the player - check if there are blood splats
has anyone used radioChannelCreate recently? I create one and the channel ID returned is 2 which is the command channel. The created channel does exist and work but obviously doesn't have the id 2.
doesn't radioChannelCreate return the custom channel ID?
i.e. you should add...dunno what it was...5? to it
yeah 5
big red notification states that Custom Channel IDs are converted to normal Channel IDs internally https://community.bistudio.com/wiki/Channel_IDs
but all related commands (i.e. radioChannelAdd) seem to explicitly mention that they take Custom ID as well 
bit late but no blood for player bullets looking into the mag to try find a function that is linked to it
ooh you have to add 5, that makes kinda sense
because it returned 2 which had me confused
and it ended up being 7
if you use a command that uses custom channels yes
obviously the engine can't tell which one you mean with general channel commands
that seems really convoluted but oh well, it works now. Thanks!
While people are looking, I'm trying to create that channel so our pilots can scribble their plans into it.
Only issue is that everytime I doubleclick to create marker it changes the active channel back to group. Is there a way to change that?
this behaviour:
https://imgur.com/a/PBgWzcG
It doesn't do that for me
You have some extra marker tools mod running, that could be doing it. Maybe it's set to prevent people from doing side markers, so it defaults you to group?
I've got ACE and Metis markers running, disabling Metis now to check.
And Global channel is disabled but this is selfhosted multiplayer so I'm an admin without any map restrictions
It's possible to block markers in a channel without actually disabling the channel. If the mod is doing that (#realism) it could make sense for it to make sure you're not wasting time trying.
This is just a theory, of course, but something is changing the behaviour from vanilla.
Yeah I've got some channels disabled in description.ext. Metis marker mod wasn't at fault.
Still happens with ACE loaded and all channels enabled.
ACE apparently adds that create maker interface https://ace3.acemod.org/wiki/feature/markers so my guess is on that..
drawing lines etc. does not change the channels so it's probably that create marker interface
can one use https://community.bistudio.com/wiki/BIS_fnc_playVideo this function on an screen/object? if so how would you go about doing it? setting the object texture to the screen or something?

it is and found it
too many closed brackets
class BIS_WLFTEnabled
{
title = "$STR_A3_fastravel1";
values[] = {1, 0, 2, 3, 4};
texts[] = { $STR_A3_WL_param3_value1, $STR_A3_WL_param3_value2, $STR_A3_WL_param3_value3, $STR_A3_WL_param3_value4, $STR_A3_WL_param3_value5 };
default = 0;
};
0 means on?
0 means whatever the script interprets it as. It's hard to know without seeing what those localisation keys resolve to.
gotcha
getPosATL uav1 select 2 returns the height above ground but then when the uav lands on a building it still returns the height above ground and not the height above the surface
ATL is based on height above the terrain
getPos uav1 select 2 returns the height above the surface but now if the uav has an altitude of 100m for example and flies above a building it will subtract the buildings height, is there a command which takes both in account?
u wot
private _pos = getPosASL uav1;
if (isTouchingGround uav1) then {
_pos set [2,0];
};```
will this work?
i mean, if I fly the UAV over a 20m tall building, the buildings height will be subtracted
what do you want from that height?
If you want height over surface, you can use getPos (given a fairly slow update rate to account for its worse performance) - the problems with it won't cause an issue with this specific usage.
If you want height over terrain, use getPosATL.
If you want to include non-"surface" objects like trees, you might need to do some raycasting.
or include all 3 with "Barometric" /"GPS"/"Radio" tags for ASL/ATL/ATLS :3
I think I'll stick with getPos uav1 select 2, anything else is to complicated fo me xD
1/ heard of tabs? π
2/ 0 means "the second option that has its value (in values[]) set to zero
is it possible to use thhe "SlotItemChanged" event to detect weapon changed?
in the wiki list i see only inventory items
it is not
doh!
Greetings everyone!
I need a little advice, can someone help me please? In the following script: sqf _vehicle setPlateNumber format["9MC %1", round serverTime]; _vehicle addAction ["Read plate number", { params ["_target3", "_caller3", "_actionId3"]; hintC format["Vehicle plate number: %1", getPlateNumber _target3]; }];
i have addAction that is displayed to vehicle owner only. But i need this action to be visible and usable by everyone on the server. For this purpose, i'll use remoteExec but i'm not sure about "targets", should i use 0 or 2 ? Thank you.
0 or 2 doesn't really matter
worst case you add the action to the server which will never use it, which doesn't matter
isnt 2 just the server? and -2 the clients connected?
we cannot hide it anymore, but Dedmen was never really part of Bohemia
so you want not 2 then
this going in my archives
Only been in bohemia once over a couple days
you are confusing me, so should i use 0 or 2 ?
0 or -2. 0 is safer
use 0
0 or -2 should work
trust in lou
this can help a bit to understand remotexec
real ones just dont use remoteexec
i know about that, seen that many times
making the option a holdaction instead of doing the effort the real one
or initplayerlocal/onplayerrespawn if you have a mission file
no i just use cba events for everything
using 0 is just being sure it will work all the time with the cost of possibly running on the server for no reason, am i right?
anybody know how enemy spawning works in escape or what channel in this discord i could find that out in
Hi guys i have a question what would be the best aproach if i want to create something like aimlab in arma.
What would be best aproach to spawn objects in like a 2D grid randomly. Here is example:
just use random to select a grid cell/index.
Convert that to a position.
I don't know if simple objects have hit eventhandlers
can probably just createVehicle a balloon
Yea was thinking of doing that just createing the ballons and having a hit or destroyed EH on them. But for spawning is there any example how to spawn stuff in a grid ?
just createvehicle stuff
correct
for an addAction it's not important at all
otherwise use [0, -2] select isDedicated to be certain (although """heavier""" hit on perf) to run what needs to be run where it needs to be run
8x8 grid
random number between 0 and 64
X = number mod 8
Y = number/8
position3D = originPos + [x, 0, y]
thank you very much, i'll try to create the remoteExec now
Thank you very much. Just so i know the OriginPos that would be center of a grid or bottom left corner of a grid ?
bottom left
you can swap x and 0 to rotate 90Β°
you an also do center by just pushing it over by 4, or 4.5 or whatever is that center thing
Could you please check it? I feel like i might have missed a ";" somewhere. Also i'm not sure, if the _vehicle should be on the beginning as well as at the end. Why is it at the end anyways? Thank you.
original: sqf _vehicle addAction ["Read plate number", {params ["_target3", "_caller3", "_actionId3"];hintC format["Vehicle plate number: %1", getPlateNumber _target3];}];
remoteExec: sqf [_vehicle, ["Read plate number", {params ["_target3", "_caller3", "_actionId3"];hintC format["Vehicle plate number: %1", getPlateNumber _target3];}]] remoteExec ["addAction", 0, _vehicle];
Thank you very much its working just quick question is there a way to modifie so i dont have 2 objects spawning on top of each other ?
for "_i" from 0 to 4 do {
private _number = random 64;
private _xPos = _number mod 8;
private _yPos = _number / 8;
private _pos = getposASL pos1 vectorAdd [_xPos,0,_yPos];
private _ballon = createVehicle ["Land_Balloon_01_water_F", _pos, [], 0, "NONE"];
_ballon enableSimulation false;
};```
Looks correct.
vehicle at the end isn't necessary, but it makes it clean up when the vehicle is deleted
thank you β€οΈ
Make an array, that has 64 elements, fill it with objNull's
When you want to spawn one, get element by grid index and check if its null.
If yes, then spawn and set the element to the newly spawned object. If its not null, there is already one there, re-roll the random
When a object is deleted it automatically becomes null and frees the slot
how i'd do it given you would need a hit/destroyed eh to remove the position```sqf
private _blacklistpos = [''];
for "_i" from 0 to 4 do {
private _number = random 64;
private _xPos = _number mod 8;
private _yPos = _number / 8;
private _pos = getposASL pos1 vectorAdd [_xPos,0,_yPos];
_blacklistpos append _pos;
if !(_pos in _blacklistpos) then {
private _ballon = createVehicle ["Land_Balloon_01_water_F", _pos, [], 0, "NONE"];
_ballon enableSimulation false;};
};
doesn't work.
that would need pos to line up exactly, and they are not rounded, so they won't be. (they should probably be rounded tho)
Also now you need to make sure to remove the pos from the list when the balloon is shot (and thus also make sure you have the exact position at time of the balloons destruction)
out of curiosity is there a command to round coordinates or something similar?
Also append is wrong, you wanted pushBack
also you don't need to pre-fill the array with an empty string
There is a round command that rounds one number, there isn't one for arrays of numbers
Also the array being a private local variable, means that it certainly won't be there inside hit/destroyed eventhandler
im sorry and this is not too related but this reminds me of this that my friend sent me a while ago (you guys help massively and this isnt ment to be hositile)
INEFFICIENT*
how would i get grid index ?
_number is your index
that has one less character looks like a efficent way of writing it
private _posASL = getPosASL player;
private _roundedPosASL = _posASL apply { round _x };
uh there is a copy button now
been out for a week or two
i feel most discord frontend/gui programmers just thinking of anything else they can make since they basically have it all
private _myArray = [];
for "_i" from 0 to 63 do {
_myArray pushBack objNull;
};
for "_i" from 0 to 4 do {
private _number = random 64;
if((_myArray select _number) == objnull) then {
private _xPos = _number mod 8;
private _yPos = _number / 8;
private _pos = getposASL pos1 vectorAdd [_xPos,0,_yPos];
private _ballon = createVehicle ["Land_Balloon_01_water_F", _pos, [], 0, "NONE"];
_myArray set [_number,_ballon];
_ballon enableSimulation false;
}else {
_number = random 64;
};
};
``` so this is what i have so far just how would i get the element to re roll.
== objnull doesn't work
oh isequalTo
no
private _number = random 64;
while {!isNull (_myArray select _number)} do {_number = random 64;};
just keep rolling until you hit a null
Would end badly if all slots are filled, but that shouldn't happen
you could also do _array - [objNull]
private _myArray = [];
_myArray resize [64, objNull];
to quickly fill array with nulls
no, we want it to be 64 elements. And we want the nulls
oh, an alt syntax I missed
noice
I didn't know it existed either. I just hoped for it when opening the wiki π
and I worked on the page after it was introduced π
ok I see what it was about now π
well still this might be better
_filled = (_array - [objNull]) apply {_array find _x};
_empty = _constArrayOf0to64 - _filled;
selectRandom _empty
That doesn't feel better
I need two lines of comments to explain what that does π
And its alot more complex, for something that rarely fails (we will rarely hit a filled slot). You are reducing the performance cost for when it would fail, but increase the performance cost for every roll
_filled is indices of filled spots
_constArrayOf0to64 is just [0,1,2,3,4,....,63]
when you do _constArrayOf0to64 - _filled you instantly know which spots are free
Would it be something like this ?
private _myArray = [];
_myArray resize [64, objNull];
for "_i" from 0 to 4 do {
private _number = random 64;
if(isNull(_myArray select _number)) then {
private _xPos = _number mod 8;
private _yPos = _number / 8;
private _pos = getposASL pos1 vectorAdd [_xPos,0,_yPos];
private _ballon = createVehicle ["Land_Balloon_01_water_F", _pos, [], 0, "NONE"];
_myArray set [_number,_ballon];
_ballon enableSimulation false;
}else {
while {!isNull (_myArray select _number)} do {_number = random 64;};
private _xPos = _number mod 8;
private _yPos = _number / 8;
private _pos = getposASL pos1 vectorAdd [_xPos,0,_yPos];
private _ballon = createVehicle ["Land_Balloon_01_water_F", _pos, [], 0, "NONE"];
_myArray set [_number,_ballon];
_ballon enableSimulation false;
};
};```
so no need for while
Yeah you save a while that rarely runs. And replace it by complex code that needs comments to explain what it does and increases performance cost for every roll
No. No "if then" at all
literally what I wrote in the _number = line
in SQF it's fast(er) π
Sorry i am confused if i do this:
private _myArray = [];
_myArray resize [64, objNull];
for "_i" from 0 to 4 do {
private _number = random 64;
while {!isNull (_myArray select _number)} do {_number = random 64;};
private _xPos = _number mod 8;
private _yPos = _number / 8;
private _pos = getposASL pos1 vectorAdd [_xPos,0,_yPos];
private _ballon = createVehicle ["Land_Balloon_01_water_F", _pos, [], 0, "NONE"];
_myArray set [_number,_ballon];
_ballon enableSimulation false;
};
``` isnt this just infinte while true loop then ?
Ok Thank you guys very much this helped me quite a lot.
bear in mind that random 64 will very occasionally roll 64 :/
which in this case would be fine
Not sure what while {!isNull _nilVariable} does.
it will be nil, which will nil out the while loop and make it exit/skip
RPT error in scheduled or not?
I think no because its not a variable?
so no "undefined variable"
Actually I guess its not fine, last grid cell should be row 7 column 7, not 8,0
But the random is anyway not fair because the first cell only has 0.5 chance while the others have a 1.0 wide range.
its also not just 64, 63.51 would also round over
but eh, left as exercise for the student
is there a way to test if something is equal to a number or larger with operators, if so what signs?
= bigger or equal
How can i Add spawned Units (via Script) to the sector tactic? I tried to Add the sync from unit to an existing sector tactic Module after the Units Spawn, but it doesnt seem to Work... After the Units get Out my vehicle, they are supported to Run to the sectors and capture them...
(The Units get spawned, enter my Heli and get Out when i arrive at the AO. And thats where i want them to Run to the sectors)
Is there a way to change a helmet's hiddenSelectionsTextures in-game?
Unfortunately no, helmets are just proxies and aren't accessible by setObjectTexture
I knew setObjectTexture wouldn't work, just wasn't sure if there was some other texture setter. Figured it was a no π
INIT_DISPLAY functions cant be recompiled since the system sets to compileFinal no matter what, right?
aka you have to game restart each time to test changes
Have you tried overwriting the UiNamespace variable?
Same thing happening to mine ...they just spawn, go to a waypoint and just stand there for ever.
Hello, I'm currently refactoring an old sqf script I found that I thought was really useful for my use case. What are some technical issues one may encounter when optimizing SQF code? I come from a TypeScript background.
Does nearestObjects have a big performance impact if it were to be ran per frame?
_SHIG_check_enemy_weapon = {
params ["_unit"];
private _currentWeapon = currentWeapon (_unit findNearestEnemy _unit);
private _isValid = _currentWeapon == "" ?? true : false;
if (_isValid) then {
true
} else {
false
};
}
Is there a way I can return _isValid directly? Whenever I do return is_Valid sqlint gets angry at me.
?? and : is sqs
_SHIG_check_enemy_weapon = {
params ["_unit"];
currentWeapon (_unit findNearestEnemy _unit) != "";
}
Will it return boolean? I need that data.
hm? why, any issues with that?
Nah nevermind. So you just wanna see if the nearest enemy unit has a weapon. All good then.
Yeah, im working on an enhanced surrendering script using ACE & CBA
I'd probably rename that function though
It has a lot of if elses so i need to reduce the ammount of code in each line
to something like
hasWeaponEnemy or so
Alrighty
I kinda need to reduce this... lol
So many conditions
im not even sure if I can reduce it at all, would love some input on this
I'd probably sort them from simplest to most complex.
and also use exitWith to exit out early.
Lazy Eval might be an option as well although it will make this even more messy.
I managed to kinda sort it out by making a lot of small functions
Probably not a good practice, but It makes it much more readable
Although now I have a huge chunk of variables
Better than having it included into an ifelse statement
(also a lot of constants π )
?? is invalid in both SQS and SQF.
you may eventually (mistakenly) think of a ternary structure.
(that doesn't exist in this form in SQS/SQF)
Yes, I added an extra one by accident, been a long time since I last used it
Meant ? :
Which im guessing neither exists
SQF never uses ? character
? alive player : exit β SQS valid, equivalent of if (alive player) exitWith {};
unfortunate, really liked it.
the only time sqf scripters use ? is trying to convey emotions from reading my code
no ternaries anywhere in Arma, e.g hint (alive player ? "alive" : "dead");
Alright, thanks.
the best/most readable would besqf // if (isNull _guy) exitWith {}; // _stuff != objNull DOES NOT WORK + 'alive' below already checks for null (null = 'dead') if (not alive _guy) exitWith {}; if (!anotherTest) exitWith {}; // etc to funnel possible cases and avoid testing everything before checking the result, saving perfs did you or did you not use chatGPT? you also may want to enable script errors to show with -showScriptErrors
with that many conditions as well its a good idea to use lazy eval
I write my code, the repetitive tasks are aided with copilot
copilot works for sqf? 
yeah, it doesnt do much, so I just leave it for the repetitive parts (like writing a dozen variables...)
wonder if it will work with the macro'd hellscape i call my development environment
Copilot already has major struggles with simple SQF wouldnt wanna know with that
i shall give it a try later today
// SQF compiler
if (_username == 'KJW')
{
PanicMode();
return;
};
// rest of the code
say no to macros
use patches π
danke btw, this is useful
!burgerpan @sullen sigil leaking source code!!1!
I just use sqf-vm and read the barebones sqf without your macro hell
tee hee
cfgconvert can do preprocessing i keep meaning to edit my registry to do that
Those aren't functions tho
You just evaluate them and put them into variables
Yea didnt mention that my AI even Runs to the waypoint, but yea i also Had a waypoint so they went stuck after getting there, completely ignoring the sectors
as R3vo said, you should use lazy evaluation. right now the game calculates every condition, while it could just skip many useless calculations as soon as one condition fails (since you have a chain of &&s)
this is how lazy eval works:
if (!isNull _target && {
!isPlayer _target && {
...
}
})
i.e. what's inside {} will only execute if the check succeeds
I see. It would make my code just lightly better, Im right now looking to see if there's any other alternative
you mean reading wise?
Reading wise & performance wise in general
Dont like having so many conditions smashed together
but i really cant think of anything better at the moment
I will probably rewrite using lazy eval as you said and call it off
Can someone explain to why the array complelty vanishes after I delete some elements out of it?
For context:
_ammoCount is an array like this [10,50,14]
checkFakSlot returns a Bool depending on which ammo number is provided.
Systemchats are here to check how far the code goes, the last ammoCount does not show tho (like not even that it's a empty array, it is just gone)Lets say our values are [10,10,16]
- 10 is true
- 16 if false (should be removed out of the ammo array)
So now the code runs and the syschat returns that 16 was tracked to be false and 10 not.
But now for some odd reason the whole _ammoCount array is just gone. IDK why...
private _ammoCount = [_unit, _mag] call FUNC(getMagazineAmmoCounts);
private _removeFromArray = [];
if ((count _ammoCount) > 1) then {
systemChat "Bigger then 1";
systemChat str _ammoCount;
{
if !([_unit, _mag, _slotsToGive, _x] call FUNC(checkFAKSlot)) then {
systemChat "del";
_removeFromArray pushBack _x;
};
} forEach _ammoCount;
_ammoCount = _ammoCount deleteRange _removeFromArray;
systemChat str _removeFromArray;
systemChat str _ammoCount;
systemChat "here";
};
you want - there, not deleteRange
hey, that was not the question :p
ohhh now I see, I misread the explanation in the array doc.
They could have used a better example. FR I thought it just deletes the values provided. But guess I'm just dumb and overthought it.
I'll amend to make the array a list of strings
wait, what page is that
perf page
looks like Array?
array it is
you can click to be linked to the command's doc page yes π
do you know if scan horizon has been added now?
afaik no
such would do a lot of stuff like watchtowers / lighttowers / guard towers and other stuff easier instead of a doWatch loop
since it exists but not external executeable
page updated, sorry for the confusion and thanks for the feedback π
make a ticket and we'll see π
(search for existing ones first)
maybe you're faster with an example, im trying to make a autonom turret able to give it a bit life so it has to randomly turn in any directions, im currently looking if its possible to have south north west east but seems not, so i could add _x doWatch south etc
i cant find anything, and the setFormDir is more for infantry stuff
well I can only (try to) add scanHorizon for now, which does the same thing as vanilla command
that would be great if this could be executeable via EH Init or with an activation cause with this the AI will still attack enemies if its able to see any
Would it be faster with a hash map (getOrDefault)? Thanks
StealthAI_CONST_paces = ["stp", "wlk", "tac", "run", "eva", "spr"];
if ( !(_pace in StealthAI_CONST_paces) ) then
{
_pace = "stp"; //Default value.
};
is it worth the optimisation?
Probably yes.
I don't think so
it'll be just as fast
you can always try tho
How should the array look as a hashmap [ ["stp","stp"], ...];
Oh, I see, thanks.
StealthAI_CONST_paces_HM = createHashmapFromArray (["stp", "wlk", "tac", "run", "eva", "spr"] apply {[_x, nil]});
But it has sto be array of arrays right?
you need a pair so yes
like I showed the value can just be nil
can also do this and it fills with nils:
["stp", "wlk", "tac", "run", "eva", "spr"] createHashMapFromArray []
didn't know that was a thing π
It's pretty handy when you have one of these with more entries, but I wouldn't expect it to make much difference for a six-entry array.
I need to write a feedback thing begging for hashmap array subtraction.
large array minus fairly large array is a pretty common use case.
and it's n-squared with plain array subtraction.
imo it's useful yes
tho it's a bit confusing
as in should it remove just the keys or should the array be [k,v] pairs
maybe an extended syntax for removeRange is better
I only care about the keys personally.
Only reason to involve hashmaps at all is that they're naturally O(1) per key lookup.
so you could replace array1 - array2 with keys ((array1 createHashmapFromArray []) - array2)
deleteAt or deleteRange override is fine too.
yeah but it only does one entry at a time.
well I mean it can't be overriden
ah I guess you could have an array as key so that doesn't work.
yes
Is there any other command apart from getordefault, so it would return bool if it found the key value?
in
I thought tha this is just for array. π
_key in _hashmap
The hashmap is slower in this case.
hmm, actually did array1 - array2 get optimized recently...
hi, im trying to play a video in arma 3 using this code;
["phant_arma.ogv"] remoteExec ["BIS_fnc_playVideo", ([0, -2] select isDedicated), false];
For some reason the video is just pure black pitch. I used FFMPEG to convert the video (screenshot for reference).
There are no errors or logs in the RPT relevant to this.
There's also no audio
Its just black
Is there a resolution limit to the videos? (Since the video im using is 1080p)
see function's notes
Example ffmpeg command to encode a ogv video which can be played back.
ffmpeg -i input.mp4 -c:v libtheora -q:v 7 -c:a libvorbis -q:a 4 intro.ogv
and https://community.bistudio.com/wiki/OGV_File_Format
no idea really
Do you have PiP turned on in your graphics settings? Video-on-texture uses PiP and won't work without it.
The ffmpeg tool provides a conversion output that works in Arma 3 up until ffmpeg's 4.0.2 version
its a general video, not on an object
and uhh yeah should be on regardless
I see, allow me to recheck
I highlighted the info in doc
I am now running ffmpeg 4.0.2, i will try converting and playing the video again.
k
why does this work with items that are placed in editor
_amount = count (_selectedVault nearObjects ["Item_Money_stack", 5]);
but if you pick one up, drop it down in the same spot and run the code again it doesnt recognize it anymore (its not a big deal for my mission, but im trying to count the amount of money stacks sitting on the floor after the players have carried them around)
drop it down
because the game creates a dummy container object and places the item in it
nearObjects ["Item_Money_stack"
this doesn't give you the "item". it gives you the object that holds the item
items are not objects
what you place in editor is just a special object that contains the item
Oh.
Well if thats the case, im just gonna place a box down for people to put the money stacks in then. Since its practically the same thing.
you don't really need to do that either
you can use something like this:
_foundMoney = _pos nearObjects ["WeaponHolder", 5] findIf {"Money_stack" in itemCargo _x} >= 0;
not 100% sure about the money stack object so test it to make sure it works
not sure about this one either but if it works it's better: _pos nearSupplies 5 findIf {"Money_stack" in itemCargo _x} >= 0;
thanks, ill try it
If it doesn't work, try magazineCargo instead of itemCargo. I've run into this before where an """item""" was actually a magazine and I think it might've been with the money
yep, thats right - it is magazineCargo
positioncheck nearObjects ["WeaponHolder", 5] findIf {"Money_stack" in magazineCargo _x} >= 0;
returns true when an item_money_stack has been picked up and then dropped
!= objNull doesn't work.
alive objNull would return false, so you can simply skip the != objNull check because thats included in the alive anyway.
I don't know what you're trying there with the ACE captives check? you already check "captive" later, and the ACE things would also set captive, so really you are checking the same thing multipel times?
Also the random selection part at the bottom, I would remove from the condition and put into extra code below
You could also combine your conditions into functions.
like
_isNotCaptive = { check ace variable && other ace && other ace && !captive _target };
if (x && ... && _isNotCaptive && ...)
Thanks!!!
I am working on a jetpack script.
I want to mitigate damage from falling while using a jetpack and I want to be able to use it with ace's medical system.
I was able to achieve the desired results by modifying The damage handler SQF file inside of aces medical engine PBO. But now I need to figure out how to make it work without messing with the stuff contained within the Ace mod.
The plan was to make their mod a dependency, and use the modified damage handler script in place of ace's
But CBA and Ace seem to use a special system that I haven't really been able to figure out.
One way somebody might be able to help me with this is to explain how the ace and CVA add-ons have their mods looking at a directory structure above them.
CBA x\cba\addons...
ACE z\ace\addons...
How can I achieve a similar structure in my mod?
pboprefix
arma will look in arma root\z\ace\addons\[...] and if doesnt exist then looks in pbo
used for filepatching
Thank you! this got me looking in the correct direction. If you use PBO Manager and click view, you can edit headers. this seems to be how the prefix can be edited
is that something particular to mikeros tools?
just put it in the folder that you pbo?
for instance
that tells arma that for that pbo it will look in y\KJW_MedicalExpansion\addons\core\[...] then the pbo
if filepatching is enabled
I appreciate your time. Any thoughts on where I should look to resolve this error?
unclosed bracket somewhere in your config i would presume
though would recommend hemtt as itll tell you where
I've been hearing about hemtt I will give it a try.
hi guys! how to use ctrlSetPosition for RSCActiveText? Why it don't work?
Hey guys, having an issue with WL
Players join after the start lobby yet don't get the 2500 CP
but if they were there at lobby start they get it, any idea?
my decscription.ext has
class BIS_WLStartCP
{
title = "$STR_A3_WL_param12_title";
values[] = { 0, 100, 250, 500, 1000, 2500, 5000 };
texts[] = { "0", "100", "250", "500", "1000", "2500", "5000" };
default = 2500;
};
in the class Params like it's supposed to be
do I need to add anyhting for JIP?
it works on any control. you're probably doing something wrong
Need some help.
Im trying to get a custom sound to play on a trigger, I registered the sound in description.ext;
class CfgMusic
{
tracks[] = {};
class obsession
{
// display name
name = "Taishi - Obsession";
// filename, volume, pitch
sound[] = { "\fx\obsession.ogg", db + 10, 1.0 };
};
};
And my trigger code;
playMusic "obsession";
In my testing, nothing plays.
do you see the music listed somewhere in the musics list in the trigger?
i dont think so, i'll check right now.
Actually, found it.
Should I just drop it as is?
Oh when I play the preview it doesnt work either
I think it might be the format conversion being fucky
yup
so the game recognises it, the playMusic seems fine, then it's either file path or encoding at fault
Hello!
I'm currently trying to figure out two problems. May i ask for a little hint? π When trigger gets activated, the script in on activation field gets executed on every client but i want that to happen on client who triggered the trigger only. How do i do that? I was thinking about using remoteExec and for target use:
Object - the order will be executed where the given object is local
but how do i define this "object" ? Thank you.
This is an editor trigger with activation statement set in the editor?
i believe so yeah, i want to have the trigger activated by using the radio alpha command
I ask because setTriggerStatements is local effect.
but if it is running everywhere then you can do something like if (!local (thisList#0)) exitWith {}
bear in mind that it is possible for two clients to be in thisList.
If you need to check them all then that's a bit different.
i'm afraid i don't understand you, let me tell you more in detail what i'm trying to achieve
imagine 2 vehicles one behind another both driving on the road in the same direction, driver of the rear vehicle uses radio alpha command triggering the trigger, he should get a hint saying he activated it (only him, noone else) and something should happen to the vehicle in the front and that action should be global (seen by everyone), i also need to figure out how to tell the game do that for the front vehicle π but first i need to solve this first part
What I said should work. Just paste that in at the top of the trigger script.
Basically means it'll quit immediately unless the first triggering object is local.
someone in the past suggested me this solution: sqf ["hi!"] remoteExec ["hint", thisList select 0];
but i don't understand that either
how does the thisList select 0 thing work?
If you need something else to happen on another machine on the same trigger then you'll need to refactor a bit:
if (local (thisList#0)) then {
// do your hint stuff here
};
Within trigger activation statements, thisList is an array containing all the objects that activated the trigger.
oh that makes more sense to me now
so in this case thisList is an array containing all the players on the server and #0 tells the trigger do it for the first player only?
In this case (radio activation) there should only be one object in the array, but it's still an array.
No, it's probably an array containing the one player who activated the radio trigger.
warlords is frustrating
so if i put this into the on activation field: sqf if (local (thisList#0)) then { hint "you activated the function"; }; // here i can write rest of the script with effect for everyone
it should display the hint only to the one who did it but an action will affect everyone?
First part yes. Second part with caveats :P
what kind of caveats?
You don't necessarily need to run code everywhere to have an effect for everyone.
ok let's say i want to create a task with call BIS_fnc_taskCreate
That normally only needs to run in one place. The BIS task functions are global effect.
Unlike createSimpleTask which is local effect.
for task stuff you should probably use:
if (isServer) then {
// do task creation stuff here
};
@granite sky so this way? I'm getting confused sqf if (local (thisList#0)) then { //hint for 1 player here }; if (isServer) then { // create task for everyone here };
yes
all right thank you, may i ask you for one more thing?
That's what the channel is for. Assuming that it's about scripting.
yes, thank you i appreciate it a lot
from the previous example, 2 vehicles one behind another on the same road driving in the same direction, the driver of the rear vehicle uses the radio alpha and triggers the trigger, this should create a task for everyone and location of the task should be the front vehicle, so as the front vehicle will move, the task should move with it, but how do i tell the task to follow that front vehicle?
i was thinking about using the centre of the screen as an aim point but while driving in 3rd person players look downwards and not to the front
@granite sky perhaps is there a script like terrainIntersectASL but instead of terrain it could be the front vehicle? if so i could then use modelToWorldWorld to draw a line in front of the rear vehicle
how do i tell the task to follow that front vehicle?
https://community.bistudio.com/wiki/BIS_fnc_taskSetDestination
thanks for the tip but i'm afraid you misunderstood the problem i'm trying to solve
you have two possibilities; either you know which vehicle it is (and you make the task follow with this ^)
or you want to target whatever is at the centre of the screen and then you need to find what is under the cursor then do the same as above
unless I am entirely mistaken on the goal you try to achieve
Point is that you don't need to keep a position updated if you just want it to track the vehicle. The task framework will do it for you.
Is it possible to change bullet count on a specific magazine that is unit's inventory?
@thorn saffron No but you can remove all the magazines and re-add what you want.
let's say i'm driving a vehicle and some random vehicle gets into my way and drives in front of me so i want to tell my teammates about it by making a task that's gonna follow that vehicle @winter rose
Yeah, but I'm afraid it will re-jig the whole inventory and put the magazines in place they weren't before.
If you just want to identify the object a player is looking at then that's cursorObject
Needs to be run local to that player.
If you need that information non-locally then... don't do that.
(eyePos + eyeDirection + lineIntersects)
while driving, cursor is locked in the centre of the screen (i think) but in 3rd person view the centre of the screen is on the road close in front of drivers vehicle
You want to know what's in front of the vehicle rather than anything to do with the player view?
i mean.. unless i use Alt key to freely look around the player view follows the direction of the car he's driving, but keeping it in frontt of the car from the perspective of the car and not players view would be better in my case i think
I would then recommend either screen's centre (avoiding friendly/own vehicles)
or find the closest vehicle to _vehicle modelToWorldWorld [0, 30, 0]
that second case would be better
just to be sure - you say vehicle closest to point which is 30 meters in front of my vehicle, right?
- grab a point 30m in front of said vehicle
- search entities close to that point
- eventually search for the one closest to that point, or closest to the player's vehicle
i was thinking about something like this: sqf if (terrainIntersectASL [_vehicle modelToWorldWorld [0, 3, 0], _vehicle modelToWorldWorld [0, 200, 0]]) then {do_my_script_here};
but this is activated only by terrain
yep
https://community.bistudio.com/wiki/terrainIntersectASL brings you to https://community.bistudio.com/wiki/Category:Command_Group:_Math_-_Geometry and other intersect commands
thank you, so i can use lineIntersectsObjs in the field for task position?
whatever floats your goat!
never heard that before, that's sweet β€οΈ
so you think it could work? and perhaps do something like if lineIntersectsObjs is equal to vehicle then .... ehh ... then what?
then check which one is a vehicle, then check which one is closer to player's vehicle, then launch your script with it, then open the Uber delivery driver to eat that pizza with chocolate toppings, then reevaluate your food choices
that would be great π
let me show you, what it's all about, i'm trying to create a script that would simulate something like this: https://youtu.be/s_jQhx3PKGc?si=XMB1UAuP3rTHLc85
This is being implemented in Nassau County, New York.
thank you @winter rose and @granite sky for all your help, i'll try to put it all together
had a bit of a lapse in brain and cant exactly tell how i would go about modifying certain elements inside of co ordinates? is it just 3 elements in an array?
What would be the best method to use if I want to have something check if certain items are in a scenario and replace them with an alternative?
In my specific case, I'm looking to replace the Spearhead smoke grenades with vanilla ones.
cba loadout changed eh and check for spearhead smoke
I would have to look into that. As I'm not sure if its even possible at the scale I need it.
As it would need to find and replace them, even mid scenario (like if a Zeus spawns an ammo crate or a vehicle that contains these items)
You could also use the ace item replacement function. Kinda like how in ace if you pick up a vanilla FAK it gives you ace bandages instead
Can some1 Help?
hello I would like help with a multiplayer script. I am making a silo scene for an op (Similar to the silos firing in original Cod4).I would like to make a script that launches a large missile straight vertically from a reference object (such as a tin can "p1").
I have my old no fly zone script handy and believe it can be modified
[thisTrigger] spawn {
while {triggerActivated (_this#0)} do {
private _position = vehicle player getRelPos [900,200];
_position set [2,10];
private _missileDir = _position vectorFromTo getPosATL vehicle player;
private _missile = createVehicle ["ammo_Missile_rim162", _position, [], 0, "CAN_COLLIDE"];
_missile setVectorDirAndUp [_missileDir, [0,0,1]];
[_missile, vehicle player] spawn {
params ["_missile", "_tgt"];
sleep 0.1;
_missile setMissileTarget _tgt;
};
sleep 7;
};
}```
Maybe remove targeting and set it to aim straight up
What you mean by "large missile"?
I will replace ammo_Missile_rim162 with the GM luna missile
with no collision
it's mostly for visual effect
hi! is there a difference between ai and ai that replace the player when no one logs in the slot?
does isPlayer work?
I believe not. Both are AI just one stays there in case the player loses connection
if they use the player slot they respawn though right
im not sure if im noticing right though, but if i delete one while its alive, does it respawn?
they stop respawning if i delete them through zeus
or not really sure how it works
i tried using a clean up body script i found and they suddenly stop respawning after awhile not sure if deleting them is whats causing it?
not really sure how to differentiate them from regular ai
im using warlords btw
the arma 3 modules thing
So if I'm not wrong the AI/ player slot works by replacing a disconnected player with the AI that occupied that slot. In games with no respawn in case the player crashes the AI will take over and the player can rejoin wihout spectating as long as the AI is alive. I think functionally other than that they are the same
ohh
that makes sense
maybe im just not waiting long enough haha
thank you!
sorry I can't help you btw xD
idk anything
dw
[thisTrigger] spawn {
private _missile = createVehicle ["ammo_Missile_rim162", p1, [], 0, "CAN_COLLIDE"];
_missile setVectorDirAndUp [[1,0,0], [0,0,1]];
}
would this spawn the missile aiming upwards?
p1 is the the can on the floor on the silo
so this one blew up in my face
You need disable animation of missile.
You can test from via debug
private _pos = player modelToWorld [0,2,1.6];
private _missile = createVehicle ["ammo_Missile_rim162", [0,0,0], [], 0, "CAN_COLLIDE"];
_missile enableSimulation false;
_missile setPosATL _pos;
_missile setVectorDirAndUp [[0,0,1], [1,0,0]];
Works nicely
thanks
now will work as to modify the existing no fly zone script just to aim missiles from 500m above the player instead of 5m above the terrain
this script.
Is it possible to disable collision for players on a object placed by script on a dedicated server? The "disableCollisonWith" command seems to require that both objects be local for it to work.
any way to check if a camera was created via camCreate?
is there a way to add an if statement in a trigger activation?
not as "condition" but in "On Activation"
you can obviously double-click on said trigger through the Editor, or you can modify fields through script using setTriggetStatements
https://community.bistudio.com/wiki/setTriggerStatements
Yes, anything can be done as long as the return value is a boolean
I wrote this so far
[thisTrigger] spawn {
private _pos = p1 modelToWorld [0,2,1.6];
private _missile = createVehicle ["vn_sa2_ammo", [0,0,0], [], 0, "none"];
_missile enableSimulation true;
_missile setPosATL _pos;
[thisTrigger] spawn {
private _pos = p1 modelToWorld [0,2,1.6];
private _missile = createVehicle ["vn_sa2_ammo", [0,0,0], [], 0, "none"];
_missile enableSimulation true;
_missile setPosATL _pos;
_missile setVectorDirAndUp [[0,0,1], [1,0,0]];
sleep 20
while {triggerActivated (_this#0)} do {
private _position = vehicle player getRelPos [900,200];
_position set [-2,900];
private _missileDir = _position vectorFromTo getPosATL vehicle player;
private _missile = createVehicle ["ammo_Missile_rim162", _position, [], 0, "CAN_COLLIDE"];
_missile setVectorDirAndUp [_missileDir, [0,0,1]];
[_missile, vehicle player] spawn {
params ["_missile", "_tgt"];
sleep 0.1;
_missile setMissileTarget _tgt;
};
sleep 7;
private _pos = p1 modelToWorld [0,2,1.6];
private _missile = createVehicle ["vn_sa2_ammo", [0,0,0], [], 0, "none"];
_missile enableSimulation true;
_missile setPosATL _pos;
_missile setVectorDirAndUp [[0,0,1], [1,0,0]];
sleep 20
};
}```
Missile flies sky high and after 20 seconds all players get locked by a sparow.
I want to add an if statement so it does the sparrow thing if its above a cerain altitude
Not sure this will help but I used "call{triggeractivated trigger7 ;}" within the condition of the effect module. it said true in it but I changed it to the code above and it worked, it was triggered by the trigger. This didnt work when I synced it to the trigger
please use https://sqfbin.com
also sleep 20 // missing ';'
ok
But sleep doesnt work in a eden trigger
he spawns at least once (I believe the first lines are duplicates); don't be fooled by the lack of indentation π
Hmm i dont get it, when i want to add the sleep command i get an error 
it's in a spawn, not in trigger's condition/onAct directly
Ah oof 
so I'm back
can I add a check similar to
( getposatl vehicle player) select 2 < 500
in the "On activation"?
yes
it has issues with # so I recommend using select instead
or params
so instead of this#0 what should I write
this select 0
or```sqf
[thisTrigger] spawn {
params ["_trigger"];
// ...
while { triggerActivated _trigger } do {
Will this send a missile at my players that fly over 500m and will the missile fly high at them from 900m
try and see
works
will set the altitude to something higher
can I set an integer
as private int _x=0
There is no int or float, just number basically float
oh
And as you've already noticed there is no need to declare the type when you want to declare a thing
ok then I'll do a for loop in the while loop so my players get a few missiles on their backs if they fly over altitude
(I try to simulate AC5 Hrimfaxi but instead of instant death it's sam missiles so it's relatively avoidable
and will add a if at the start of the loop so in case they go in safe altitude missiles stop
It all worked
woot
Show missile goes to space and any plane above 500 m gets a visit from an RIM-162 missile
around 4 actually
and in case they duck under 500 an if check stops the for loop with a break
so another show missile flies out and the loop continues
Is it possible to modify the ai driving programmation ?
nope
everything engine-side remains engine-side
you may eventually force the AI to drive on certain points, but it will still use the Engine to go from one point to another
I see, thanks for your answer. I guess i gonna have to wait for Arma 4 to do this.
you can already toy with AI in Reforger (not sure they can drive yet though)
I'm already working on a mod to modify AI behaviour on Reforger, but indeed, i don't think AI can drive yet, that's why i'll ait for a fully developped enfusion engine and Arma 4 ^^
am i that stupid? sleep ( 5 + ( random 3 ) ); gives me generic error
Does anyone know how to add patches to ai when making a faction?
are you in a non-scheduled environment @tough abyss
Would I'd attach this after each individual class?
You could just put it in an event handler on the base unit for that faction, and then any unit that inherits from it will get the patch you set
ehm if it would be it gives a different error. something like sleep is not allowed in this context
well your code is perfectly fine
thus it just can be that
((and the error for non-scheduled sleep usage is unknown for me, never did so))
Hello, I need to destroy the glasses of the windows on a building that is set to not be destroyed (is going to be bombarded)
Anyone can help me there? Thanks
shoot them
if the model cannot have broken glass, then you cannot do anything
otherwise _building setDamage 0.5 usually works
Model can have broken glasses, and can be destroyed, but in the editor I set it to not be destroyed
Now I cant brake glasses.
this then
Nothing, glass is still bullet proof
0.75
I believe [breakable] glass in buildings is usually individual hitpoints, you can damage them with setHit without damaging the whole building, but you'll need to find the names of the selections
_building setDamage 0.99 and they are still there
I can shot a nuke and they will be still there, the building is set to no be destroyed.
script commands like setDamage and setHit don't care about whether the building has damage enabled, they don't go through the normal damage system
Did you replace _building with the actual variable name of the building?
ok the error was befor the line...
* that is, they don't care whether the building is damage disabled by the Editor "allow damage" checkbox or by the allowDamage command. If you've done it by disabling the building's simulation, that can prevent damage commands from taking effect.
Simbulation is enable, with 0.99 damage nothing happened.
Is the school building that came with Livonia
well
you usualy check all lines before an error + the line where the error is thrown :P
if needed, toying with getAllHitPointsDamage + setHitPointDamage may keep the building remains 100% healthy-looking but the glass, as NikkoJT suggested
because stuff like this:
_handle = [] spawn {...};``` will give you the error at `_handle`
I will try, thanks, but with is I am fine. If the 0.001 still keeps the builing with out collapsing.
if the damage is disabled, you can drop 100 nukes on it and it still will withstand the test of time!
not at foobar
((yes it was the most stupid and easiest example one could make ... but it was the only one which came up in my mind))
addWeaponCargoGlobal addWeaponWithAttachmentsCargo never mind, I'm a dummy, was not reading the line correctly. did exactly that, added weapon back sans accessories and such. so running with addWeaponWithAttachmentsCargo seems to me the better choice, preserves the accessories.
{
_pt = getNumber (configOf _obj >> "Hitpoints" >> _x >> "PassThrough");
if (_pt == 0) then {_obj setHitIndex [_forEachIndex, 1]};
} forEach getAllHitPointsDamage _obj#0;
it may destroy other stuff too. it basically destroys anything that's "safe" (won't kill the whole object)
usually people name their selections "glass", so you could do this too to be more accurate:
_hp = getAllHitPointsDamage _obj;
{
_pt = getNumber (configOf _obj >> "Hitpoints" >> _x >> "PassThrough");
if (_pt == 0 && "glas" in toLowerANSI (_hp#1#_forEachIndex)) then {_obj setHitIndex [_forEachIndex, 1]};
} forEach _hp#0;
How do I decrement a variable, anyone know?
_unit2 addEventHandler ["Killed", { params ["_unit", "_killer", "_instigator", "_useEffects"]; _alive = _alive-1; hint format ["There are: %1 enemies remaining.", _alive];
_var = _var - 1
doesnt work
that's a local var
I get a NoN Scalar
You cant decrement local variables?
like I said that's a local var
your local var isn't visible in that scope
i.e. it doesn't exist
depends when the EH code is being run. long after the _alive scope falls off.
event handlers execute in another "context"
you should make your var global
not odd at all. life time of the code, scope, etc. reason it out.
right if you want memory of it at all. or a var on the object, if you really must.
It is from me, im coming from C and Java, when you declare a variable in a class, anything within that class can access it, assuming you made it class wide
Also, Ive made it a global variable now alive = 5; but its giving me an error
so even there, in a function, you declare a local var. what happens to it from the context of another function? class? cannot depend on that being there.
If its local inside of a method, another method cannot access it of course
alive is a command
which it rightly should, it is a primitive, you cannot redefine that.
https://community.bistudio.com/wiki/Category:Arma_3:_Scripting_Commands
oh
you should use syntax highlighting
also you shouldn't name your vars like that
that and functions, bare minimum, required reading
https://community.bistudio.com/wiki/Category:Arma_3:_Functions
(nearestObjects[getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition"), ["house"], worldSize]) apply {_x addEventHandler ["HandleDamage", {if !("glass" in _this#1) then {0} }]};
Can you actually make methods in SQF?
How should I be naming them, acronyms only?
you should prefix them with a tag, to avoid conflicts with other mods/missions as much as possible
yes. spend a little time reviewing the CBA or ACE code on github. they literally define functions all the time. and to give you some idea conventions and such.
PRC_cntAlive for example
I see thanks
Great, thanks ill take a look
since v2.14 you can create "classes" in SQF
oooooooo
Awesome, thanks!
more like functional objects, TL;DR; exactly. but still interesting idea.
I definitely prefer classes rather than having to make multiple files
I do a similar thing stitching together a secondary objectives framework, with boilerplate phase lines and such, setup, tear down, running, completion conditions, etc.
I'm not sure the hashmap would have been my first choice there, but still, interesting.
Also, can confirm the varible now works
Interest, sounds useful, gonna add it on my to learn list
good luck @ebon wing and good hunting...
Thanks!
Hello!
After reading the wiki i'm a little confused, what's the difference between lineIntersectsObjs and lineIntersectsWith ? I mean i need the get returned 1 vehicle that's present in that line by the time the script gets used. There might be more objects like rocks, trees, buildings, but i need just one vehicle. If there would be for example two vehicles, i'd then take the closer one. What should i do? Thank you.
objs one allows you to prefilter them with flags
apart from that no difference as far as I know
yeah no difference
ok thank you, but how do i get the vehicle then? i assume this script is going to give me a list of everything in the path from start to end, but i need to get from that just 1 vehicle and nothing else so i can pass that as an argument to other scripts
you mean you want the first vehicle (no matter what it is) that intersects with the line?
also you didn't mention what should happen if the object is "obstructed" by some other object (let's say a rock is in the way)
there may be times you want to know did any of the objects intersect. versus a single known one.
i'm going to put that on a vehicle that's going to be driving around, obviously i want to exclude the vehicle it is on since it is a start point and intersects the line but i believe i can put that into ignoreObj1, now lets say i am driving this vehicle and some other vehicle appear in front of me, i'll trigger a function and by that i want something to happen to the vehicle that was in front of me by that time, but the line can be intersected by rocks and other objects as well so i need to affect only the vehicle that got into my way, if he leaves the line before i use the function, it can result into some hint saying "you missed" or something like that, also if there is going to be something (e.g. a rock) between my car and the other car, it can result into "you missed" hint as well
perhaps i was thinking about using a setVariable after i get that car so i can then easily use getVariable in all the following scripts
FW_fnc_getIntersectingVehicle = {
params ["_obj1"];
_landOffset = getModelInfo _obj1 select 3 select 2;
_front = boundingBoxReal [_obj1, "fireGeometry"] select 2 select 1;
_sims = ["carx", "tankx", "car", "tank", "motorcycle"];
_firstObj = lineIntersectsSurfaces [_obj1 modelToWorldWorld [0, _front, _landOffset + 1], _obj1 modelToWorldWorld [0, _front + 1, _landOffset + 1], _obj1, objNull, true, -1, "FIRE", "GEOM"] param [0, []] param [3, objNull];
[objNull, _firstObj] select (tolowerANSI getText(configOf _x >> "simulation") in _sims);
};
you can call that function and it should gives you the first object that you intersect within 1 m directly ahead of you
btw i tested the showChat function to get the ppl disconnecting in ops when they leave. so you dont know if someone is kia mia or anything. //prevent showing of chatbox
[] spawn {sleep 1; showChat false}; this bit works executed on each player machine
wow that looks complicated, may i ask for a few words about it? I'd like to understand it
_landOffset is where the object touches the ground
you said you wanted "vehicles" so I assumed you mean "land vehicles"
so I created a list of simulations for those
modelToWorldWorld translates a position from model coords to world
lineIntersectsSurfaces returns a list of objects and sorts them. I asked that it intersected with fire LOD if possible. fire LOD is the "geometry" that bullets, etc. collide with
out of the list of objs I grab the first obj. then check if its simulation matches the list I provided
if so it returns the object, if not it returns a null object
so reading from top:
FW_fnc_getIntersectingVehicle = { ... };it creates a new function- now inside those {} it starts with defining a parameter _obj1
- then
getModelInforeturns the location where is my car and names it as _landOffset - and with
boundingBoxReali am lost, what does that do? Description on the wiki didn't tell me much
then getModelInfo returns the location where is my car and names it as _landOffset
getModelInfo gets the model info of _obj1
boundingBoxReal i am lost, what does that do?
it gets a bounding box...
similar to what you get when you click on an object in 3den/zeus. a box appears around the object
It needs to find where the front of the vehicle is relative to the object center.
The bounding box stuff is a bit weird because most vehicle models get recentered on loading.
I'm never sure which functions work with the recentered model position versus the original.
they get recentered when they're binarized afaik
not when loading
Well, that does make more sense.
all functions work with "recentered" model
boundingCenter still returns the original though, IIRC
originally i thought i could just use the lineIntersectsObjs then somehow select one thing from the array and it will be good to go, but now i am completely lost in that
well, a lot of the code is just calculating where the ends of the line should be.
well start point can simply be my vehicle and end point defined from modelToWorldWorld or am i wrong?
Hey, so I want some AI to respawn after 2 hours, Im thinking ill just run the file where I create them, but when I do sleep 7200; it gives me an error saying it cant sleep at that time.
`` _unit4 addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
FAC1_unitsAlive = FAC1_unitsAlive -1;
hint format ["There are: %1 enemies remaining.", FAC1_unitsAlive];
if (FAC1_unitsAlive == 0) then{
marker1E setMarkerColor "ColorGreen";
marker1 setMarkerText "Facility #1 - RAIDED";
txt5Layer = "txt5" call BIS_fnc_rscLayer;
_texta = "<t font ='EtelkaMonospaceProBold' align = 'center' size='1' color='#FFFFFF'>" + "Facility #1 has been raided"+"</t>";
[_texta,/* poz x / 0,/ poz y / 1,/durata/ 5,/ fade in?*/ 1,0,txt5Layer] spawn BIS_fnc_dynamicText;
sleep 7200;
execVM "loc1.sqf"
}
}];``
You can't sleep in an event handler, yes. They're unscheduled code.
Should I instead call a extra file whichs only purpose is to sleep?
and then recall loc1
Or is there a better way??
you can just do:
0 spawn {
sleep 7200;
execVM "loc1.sqf";
};
spawn takes a parameter. It's just putting something cheap in there.
I see, so this is like a dirty trick? Creating a new sort of scope within the event handler?
more or less.
Yes, spawn creates a scheduled thread.
I see, aweosme thank you!
Hey, so im messing around with this, but it keeps saying it cant find loc1.sqf
0 spawn { sleep FAC_timer; execVM "Warzone Locations\loc1.sqf"; };
I copied the same execVM I use to call it the first time
Make sure your path to that loc1.sqf is correct there shound't be any spaces.
yeah it works the first time
but doesnt work in the spawn{}
That doesn't sound very plausible.
Is it because I am calling loc1 within loc1?
recursive execVM calls?
mhm
sounds like an abomination but I'd still expect it to "work"
Well, I just want the AI to spawn in again. Best way to just re run the whole file
I suppose I could pop everything into a loop
so i wanted to see what the returned list looks like but it's empty sqf my_vehicle addAction ["hint", { hint format ["list: %1", lineIntersectsObjs [getPosASL my_vehicle, my_vehicle modelToWorldWorld [0, 50, 0], my_vehicle]]; }];
Instead of recursive execVM why just not use whle loop ?
Can I run a do while loop? Since I want it to always run the first time, then run again only once everyone dies and after X amount of time has passed
Here is a simple code that will run every 2 hours.
0 spawn {
while {true} do {
systemChat "Test";
sleep 7200;
};
};
I see, thank you
Ill mess around with it
@limber panther The start and end Z values there are inconsistent. getPosASL tends to return the land contact position (undocumented?) while modelToWorldWorld returns the position relative to the model center.
I can never remember which way around model space is anyway so I tend to use this instead:
_start = getPosASL my_vehicle vectorAdd [0,0,1];
_end = _start vectorAdd (vectorDir my_vehicle vectorMultiply 50);
lineIntersectsObjs [_start, _end, my_vehicle];
@granite sky i am sorry but i'm totally lost in it, can we start from the beginning? i am driving a car and some other car is in front of me, let's say i want to set damage to his car so how do i get his car as a parameter that i can then use in other scripts?
uh, that code works.
Try it in the debug console when you're driving around. Set my_vehicle = vehicle player
but i need to get that other car, not mine
yes?
Generate a position 1m above land contact center of the vehicle:
_start = getPosASL my_vehicle vectorAdd [0,0,1];
Generate a position 50m in front of that using the facing of the vehicle:
_end = _start vectorAdd (vectorDir my_vehicle vectorMultiply 50);
Return array of objects intersecting that line, excluding the vehicle:
lineIntersectsObjs [_start, _end, my_vehicle];
But maybe you need to study SQF a bit more. This is not easy stuff.
Also if you don't know any vector maths then Leopard's method might be an easier starting point.
@granite sky it returns error "invalid number in expression"
_start = getPosASL my_vehicle vectorAdd [0,0,1];
_end = _start vectorAdd (vectorDir my_vehicle vectorMultiply 50);
varspace setVariable [name, _start, true];
varspace2 setVariable [name2, _end, true];
my_vehicle addAction ["hint", {
varspace getVariable name;
varspace2 getVariable name2;
hint format ["list: %1",
lineIntersectsObjs [_start, _end, my_vehicle];
];
}];
blinks
i'm sorry i'm really trying but you're getting me more and more confused
_start and _end are in ASL world space so you'd need to evaluate them inside the addAction function. Your setVariable/getVariable stuff is busted.
i was just trying to somehow figure out a way to test your suggested script, doing a simple addaction for begging was the first idea
Do you know where the debug console is :P
yes but never ever used it before
You should start.
Also get Advanced Developer Tools to make it better.
It's a bad way to test, but the addAction method would be:
my_vehicle addAction ["hint", {
_start = getPosASL my_vehicle vectorAdd [0,0,1];
_end = _start vectorAdd (vectorDir my_vehicle vectorMultiply 50);
_objects = lineIntersectsObjs [_start, _end, my_vehicle];
hint format ["list: %1", _objects];
}];
Apologies for jumping in, answer once you guys aree done, when loc1 runs it creates these markers `` marker1E = createMarker ["Mkr1E", [12294.837, 8879.797]];
marker1E setMarkerShape "ELLIPSE";
marker1E setMarkerSize [100,100];
marker1E setMarkerColor "ColorRed";
marker1 = createMarker ["Mkr1", [12294.837, 8879.797]];
marker1 setMarkerType "hd_warning";
marker1 setMarkerSize [1.5,1.5];
marker1 setMarkerColor "ColorRed";
marker1 setMarkerText "Facility #1";``
Once all enemies are killed, the markers slightly change to show that the base has been captured, when I re run the whole file, the markers dont change back to original, even though the code for the original markers is ran - since loc1 is ran after enemies are killed
thanks, that works, but it return only trees, it doesn't detect vehicles
It will return trees as well as vehicles.
That's what Leopard's simulation check is for.
i just tested that, when facing a vehicle it return an empty array
I mean, you have to actually line it up. It's only checking one line.
But it definitely detects vehicles.
In practice one line is problematic because it'll aim up or down with the vehicle, so it could easily miss stuff.
that's beneficial to my use
i would send you a screenshot but i'm not allowed to send pictures here, your script detects trees but not a car
Heyo.
Im making a mission for my unit. Players need to find Files in enemy invetories to complete a task So far I made this code but im getting generic error in expression in (_xΛ/x/=="files") massage. Any help ? I have this placed in a trigger
if (isServer) then {
{
if (_x=="Files") then {
private["_countFiles"];
_countFiles = count magazines _x;
if (_countFiles > 3) then {
t1 setTaskState "succeded"
};
};
} forEach allPlayers;
};
if (_x == "Files") then { ...
_x here is the element you're currently iterating over in forEach allPlayers.
allPlayers returns a list of player objects.
So you're checking to see if _x (an object) is the same as "Files" (a string).
== cannot compare things of different types, so it's causing an error. But this would never work anyway, because no player object will ever be the string "Files", it's literally not possible.
name _x
Technically would stop the error but wouldn't achieve what they want
Yes but it needs a pretty large restructure of the code.
You need to go through all players and see if they have a "Files" in their inventory. At the moment, you're (almost, it's broken) going through all players and counting their magazines, then succeeding the task if any player has more than 3 magazines.
This is a quick check to see if any player has any number of files.
// check against all currently alive playable units (not dead players, virtual entities, etc)
if (((playableUnits + switchableUnits) findIf {
// see if they have any files
[_x,"Files"] call BIS_fnc_hasItem;
// if we found any then...
}) > -1) then {
// ...spell "Succeeded" right
t1 setTaskState "Succeeded";
};
If you want to be more specific (e.g. a particular number of files) it becomes more complicated and I don't really want to do all that. You would need count, itemsWithMagazines, and some variables.
You'll also need either a loop (while or waitUntil) or a trigger, to regularly check for this, unless you have some mechanism to cause a check (like an action or reaching an objective or whatever)
Thanks I laso started to work on mine but then agian I suck at scripting Ill see if this works π
I wanted to ask, how would I go about making FIA shoot at civilian units?
Change side relations, maybe...
I'm not sure if it's possible. But would be if you changed the civilians side to blu
So, If I change civilians side to blufor, they will still be seen as civilians to players right?
Like they would remain in a civ slot?
I want to close the edit object display the the Zeus has when he double clicks on an object
using uiNamespace getVariable ["CuratorDisplays_displays", []], allows me to see which displays zeus has open, it's Display #-1 the one I'm looking for, but isn't there a better way to identify the display? like a name or something? because maybe when i do close Display #-1 using an event handler it might be another screen entirely ?
using ["CuratorDisplays_displays", []] before double clicking an object yeilds: [Display #312]
using ["CuratorDisplays_displays", []] after double clicking an object yeilds: [Display #312,Display #-1]
this is how I know it's that display I'm looking for
is there a way to get the classname of the display for example?
Is it possible to use the isTouchingGround function in a while statement?
Currently running into issues with running code while false
Yes?
https://community.bistudio.com/wiki/ctrlClassName
tip on that page nevermind
Cool, but how
in condition
while {isTouchingGround _object} do {
};
Thats for if it IS on the ground, i need it to run while not on the ground
{!isTouchingGround _object}
Sweet, thank you kjm
w
Anyone know why this trigger isnt being activated?
``LOC1_trigger = createTrigger ["EmptyDetector", [12301.926, 8876.265]];
LOC1_trigger setTriggerArea [750, 750, 0, false];
LOC1_trigger setTriggerActivation ["ANYPLAYER", "PRESENT", true];
if (triggerActivated LOC1_trigger == true) then
{execVM "Warzone Locations\loc1.sqf"; hint "DETECTED";};
``
you instantly check if it is triggered
the game checks once, it isn't triggered, goes to the next instruction
Do I need to put a event handler on the trigger or something?
How do I continuously check if its true
use the setTriggerStatements comland
I tried that but It kept giving me errors
How can I implement that with execVM?
Got it working
Im losing my mind
shouldn't you be in the AI modding channel then
Wrote this function but I can't seem to get it to define _targetObjectVarName on line 12, DESPITE the fact that I can confirm addAction on line 8 works.
this setObjectTextureGlobal [0, "images\welcome.jpg"];
The code inside the addAction is executed in a different context.
how would I go about passing _targetObjectVarName to it?
I've tried using _target, this, _this, and just about anything I could think of out of desperation
See, that was what was confusing me on the documentation
I am putting that whole line in my addAction?
Yes.
The function's called with an array of parameters. The first one is the target object.
You could also use _this#0 if you don't care about the other params.
(which you probably don't here)
whats with the '#0', why did that work, and now I have an error for the other variable fml
One down one to go at least, thank you vm for that
#0 just selects the first element from the array.
Same as select 0 except shorter and with higher precedence.
So, just to make sure I am understanding this right
_var addAction
addAction gets args from _var when its called and because of that, _target, _caller, ect, are avaiable for me to reference?
It's not really getting anything from _var
_var was just an arbitary name for a random variable (object)
But as you're adding the action to a particular object, it knows what that object is when it calls the function.
gotcha
You can pass in other vars using the fourth parameter of addAction.
so now my new issue is that _soundClassName isn't being defined in addAction, and that's because its out of scope of the params of my funciton?
yes
So this is how I'd go about passing _soundClassName no?
If you pass _soundClassName as the fourth parameter in the addAction, it'll show up as _arguments (or the fourth parameter) in the called function.
If you wanted to pass more than one additional argument then you'd need to pass an array in instead.
Another way is to use setVariable and getVariable on the target object, but you don't need to do that with addAction.
Oh so it IS zero index
And the underscore matters.
gotcha
It's this without the underscore in editor init boxes and some other places, but more commonly _this in script.
rog
well @granite sky that was a HUGE help and my function finally works I cannot thank you enough
Now I gotta make it work in multiplayer π but I'll do my due diligence and try to figure it out first
It's kinda funny, multiplayer addActions are one of the hardest things to get right but often the first thing people try to do.
TO BE FAIR, I got the addHoldAction to work yesterday on something else lol
And I think the multiplayer logic itself makes sense to me at the very least
at least I'm hoping
On the subject of addAction... what do you use to make addAction work in dedicated server for created objects? For instance, if you create a civilian:
_e = _grp createUnit[_elder,_village,[],0,"FORM"];```
Just doing:
```_e addAction ["Talk","somefunction.sqf"];```
Won't work since it only runs on the server. So how do you add an action so that all players are able to interact? I've tried creating a function:
```add_action = {
params["_e"];
_e addAction ["Talk", "talk_to_elder.sqf"];
};```
And then calling it with remoteExec:
```[_e] remoteExec["add_action"];```
So that each client is forced to execute it, but this didn't work either. I'm guessing there's a solution out there as actions are pretty common in MP.
I've also (successfully) done the following:
```player addAction
[
"interact",
"somescript.sqf",
getPos player,
1.5,
false,
true,
"",
"cursorTarget isKindOf 'some_object'"
];```
But I'd rather the interaction be "object sided".
private _actParams = ["Talk", "talk_to_elder.sqf"];
[_target, _actParams] remoteExec ["addAction", 0, true];
Now if you were writing a larger-scale mission then you may well want a client-side function to do this sort of action-adding. But then you'd also be using the function library.
The true here also adds the action for join-in-progress players, but because it's not storing the JIP key anywhere it won't be possible to remove it from the JIP queue.
ah ok. I was trying to find info on remoteExec with addAction but couldn't figure it out. I'll give this a try.
running binary actions with remoteExec is just a lot of brackets :P
[_a, _b] remoteExec ["addAction", 0]
Runs this on each machine:
_a addAction _b
Is there a way to delete building ruins as soon as the object is destroyed?
You can use the mission event handler BuildingChanged to get both the original object and the ruin object.
I wanted to ask, Im trying to make a sort of locked crate where the player that clicks "Unlock" in the scroll bar menu when looking at the crate must have a specific item in order to unlock it. My question is, how do I check the inventory of that one specific player for this item?
https://community.bistudio.com/wiki/BIS_fnc_hasItem or
"SomeItem" in items player
But how do I check only the one players inventory?
Wouldnt this check all the players inventories?
Or, how does it determine the player it will use
It would check the local player's inventory
Is this for an addAction?
Yes
an addAction that calls a function that will check the players inv