#arma3_scripting
1 messages · Page 138 of 1
"mission event handler" means it is added to the mission overall, as opposed to a specific object. Most mission event handlers are not server-specific.
playerViewChanged must be added on whichever machine you want to detect the player's view changing for. It only detects the local player. (A dedicated server doesn't have a player, so it won't do anything if only added on the server and run on DS)
yeah that part i got. but then adding it to the player leaves me with non local vehicles not being passed by the _vehicleIn param. since the player doesn't "know" the vehicle (??)
Good news: this will be fixed in 2.18 (https://feedback.bistudio.com/T127838)
well thats a relieve. i've spent quite some time banging my head creating the UI (1st timer) and hoping "imma make a loopless view distance script!". but it would be worth adding that objectParent has the same issue. if you exec objectParent player (on the player machine) while inside a non local vehicle, you get the player itself as parent. that also seems quite wrong.
also, a dedi server DOES "know" var named players. i can server run objectParent "varname" and it does return the correct parent.
objectParent is used for detecting vehicles a player is in (including as a passenger so non-local) in a system I've worked on, and I've never seen any failure to detect vehicles on that basis
running objectparent player (on local) while on a non local vehicle also returns the player itself.
always talking dedi server here.
btw, be careful about drawing conclusions from the text representation of objects references. For example, if a vehicle doesn't have its own variable name, its text representation will be that of its driver (or possibly effective commander, not sure which). However, the actual object reference is still to the vehicle.
Try returning the objectparent's type with typeOf rather than just the object reference
typeof objectParent player is the quick workaround.
ohhhhh.. well then. i take it all back. im guessing its only an issue with the playerViewChanged EH then?
Note that the game's comparison systems (==, isEqualTo) compare the object reference, not its text representation, so the typeOf check is just for human-readability in debugging, not needed for the script's functioning, unless you actually need the type for something
this all comes VERY handy. thank you so much
i've "smelled" some other tasty commands for 2.18 baking in the oven while browsing commands.
Can you help me how to write a script to add a second rifle with optics to the backpack?
backpackContainer player addWeaponWithAttachmentsCargoGlobal [...]
thanks dude 🙂
not sure where to ask this, but regarding the tac ops DLC, this part says "And More – Listen to newly composed music tracks, unlock additional Steam Achievements, and take advantage of new scripted systems to help create advanced custom Arma 3 scenarios."
new scripted systems in the DLC? what exactly does it have?
modules like civilian presence and so on
!code
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
ah ok but they are platform updates so not actually needed to purchase the DLC
Thanks
Bit of a long shot here, trying to spawn static weapons on rooftops
Does anyone have a copy of https://forums.bohemia.net/forums/topic/170066-rooftop-static-weapons-script/
Can't seem to find any mission with it that I could salvage it from
Rooftop Static Weapons Script (overly long demonstration video)What it IsAs the name suggests, this script will take a given area (defined by a marker) and spawn static weapons (such as DShKMs or KORDs) on rooftops. Taking inspiration from Insurgency for Arma 2, rooftop static weapons add much mo...
what's the best way to detect key input considering that the key you check maybe bind to some action? Im using KeyDown to check the key input
Hello!
I'm making a script for a randomised flyby, and am fairly happy with the results, number and type of planes, start and end positions all work. However towards the end of the plane's flight path, the FPS drops rapidly down to about 30 FPS, for both client and server. I have verified that this is not an issue with the BIS_fnc itself, but seems to be some element of the script that chugs the performance at the end. I have no clue what this could be however, any thoughts?
Thanks in advance!
while {true} do { // While loop, will run the script from exec to mission end
// sleep (300 + random 600); // Waits at least 5min + random value up to 10min
sleep 10; // Added for testing reasons
private _amount = selectRandom [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; // array for how many vehicles should be spawned (array number + 1)
private _startpos = selectRandom ["flyby1s", "flyby2s", "flyby3s", "flyby4s"]; // array for start positions of the flyby, picks a random one when called
private _endpos = selectRandom ["flyby1e", "flyby2e", "flyby3e", "flyby4e"]; // array for end positions of the flyby, picks a random one when called
private _planes = selectRandom ["LIB_P39_w", "LIB_Pe2_2_w"]; // array for the vehicles desired for the flyby, picks a random one when called
for "_i" from 0 to _amount do {
private _existingVehicles = vehicles select {_x isKindOf "air"}; // array of current air vehicles, used later
[getMarkerpos _startpos, getMarkerpos _endpos, 300,"FULL", _planes] call BIS_fnc_ambientflyby;
private _createdVehArray = ((vehicles select {_x isKindOf "air"}) - _existingVehicles); // array of all current air vehicles minus _existingVehicles
if (_createdVehArray isNotEqualTo []) then {
private _amountGroup = selectRandom [1, 2, 3, 4, 5]; // array for how many vehicles should be spawned in a group (array number + 1)
private _createdVeh = _createdVehArray #0;
_createdVeh setVelocityModelSpace [0,150,0];
sleep ([2,15] select (_i == _amountGroup));
};
};
};
are those planes deleted anywhere?
the ambientFlyBy function deletes them at the endpoint
ok
for action detection itself its much better to do inputAction detections. Works for both vanilla actions and custom defined ones.
so how do you check that H key is pressed, make it custom action or something?
If you want the specific H press, then yes, a keydown is better, but if there is an action binded to H, check the action instead.
Assuming that you action is defined, it makes more sense to check for the action due to rebinding.
i dont even know how to define actions 😬
Vanilla actions and inputActions:
https://community.bistudio.com/wiki/Arma_3:_Actions
https://community.bistudio.com/wiki/inputAction/actions
How to create new actions and bind them:
https://community.bistudio.com/wiki/UserActions - Mod only
https://community.bistudio.com/wiki/Arma_3:_Modded_Keybinding (This is specially relevant since this one is not binded to an unit class) - Mod only
How to check actions using EH:
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#UserAction_Event_Handlers
You can technically check actions added by the addAction command by just checking the shortcuts defined for them (if any)
thx for the link will read those! i thought this might have something to do with addAction but I guess not
np, hope that help you
so actions can be created only via mod?
no, scripts too
totally new defined action yes, but as mentioned before, you can technically check for an action created by addAction by using the shortcut instead, as those are not able to have a named reference, only numerical reference that is binded to the object itself
ok thx
addAction command
working on that 😐
oh, actions as in unit action [] - yes
well i guess using addaction and mapping Use Action 1 to that works. havent yet figured how to make more input actions via script
It's a bit of a faff to set up but it seems to work well.
Ah never mind, was scrolled up.
Hey lads! I have problem with a function that works perfectly fine in local test but naturally behaves awkwardly on dedicated server. In summary what function does it:
-
Removes all actions on object which creates action and calls some other function to get an array of string values from inidb2 DB - function is fine as different script also relies on it and gets data just finde, confiremd by diag_log. DB output is something like that ["RTT","RTT","Tank"] and then it self intersect so for later use we have ["RTT","Tank"]
-
Creates an action on object (panel). Upon interaction it removes original action (using removeAllActions) and then creates an action for each unique item in DB output (in this example we'd have 2 actions)
-
On interaction a function to spawn a vehicle is called and this one is tested as well. On interaction the function is also called again to start over
The problem is on server the function only seems to go to certain piece of code and does not execute further addActions
The function is at first called from object init field like this
null = [this] spawn {waitUntil {!isNil "DNT_phantomSpawn"}; [(_this select 0), phantSpawn] call DNT_phantomSpawn};
Functions seems to be stopping here
params ["_spawnPanel", "_spawnLocation"];
private _garageVehicles = call DNT_clientReadsVicsFromDb;
private _garageVehiclesDistinct = _garageVehicles arrayIntersect _garageVehicles;
private _casperVehicles = ["Delta Starfighter", "Y-Wing", "ARC-170", "LAAT C", "LAAT I", "V-Wing", "Z-95 HeadHunter", "Nu A-Class Shuttle", "Transport Ship"];
_garageVehiclesDistinct = _garageVehiclesDistinct - _casperVehicles;
removeAllActions _spawnPanel;
_spawnPanel addAction ["Login to vehicle dispenser...",{
params ["_target", "_caller", "_actionId"];
private _garageVehiclesDistinct = _this select 3 select 0;
private _spawnLocation = _this select 3 select 1;
private _actionText = "";
removeAllActions _target; // Does not seem to go any further
...
Rest of code
_actionText = format ["Select %1", _x];
_target addAction [_actionText,{
params ["_target", "_caller", "_actionId"];
private _vicType = _this select 3 select 0;
private _spawnLocation = _this select 3 select 1;
private _subTypesClasses = [_vicType, _target, _actionId] call DNT_phantomSpawnActions;
removeAllActions _target;
{
_actionText = format ["<t color = '#ff0000'>Deploy %1</t>", _x select 0];
_target addAction [_actionText, {
params ["_target", "_caller", "_actionId"];
private _vicClass = _this select 3 select 0;
private _spawnLocation = _this select 3 select 1;
[_spawnLocation, _vicClass] remoteExec ["DNT_spawnVehicleFromGarage"];
[_target, _spawnLocation] remoteExec ["DNT_phantomSpawn"];
},[_x select 1, _spawnLocation],1.5,true,true,"","true",10,false,"",""];
}forEach _subTypesClasses;
},[_x, _spawnLocation],1.5,true,true,"","true",10,false,"",""];
}forEach _garageVehiclesDistinct;
},[_garageVehiclesDistinct, _spawnLocation],1.5,true,true,"","true",10,false,"",""];
Does call DNT_clientReadsVicsFromDb actually work from the client?
I assume the forEach is running on _garageVehiclesDistinct.
Ah whatever. It feels like you're making assumptions about where the code "stops working". Put more diag_logs in there.
Actually managed to fit in the rest
It does, there are no "diag_logs in above code as I wanted it to be more clear but it does return expected values when checking RPT file
It's really hard to read nested addActions anyway, especially when your indentation is messed up.
Lol, it doesn't really matter as it seems it works now xD
Idk even why but I'll take it as it is lol
good link, thx. im gona go with custom controls - user action 1. for now
the smallest
🧠
@undone flower use debug console to test script speeds
The debug console tells you the numbers, but it doesn't tell you what the numbers mean, which was the question
yea i know, but you can do your own comparisons then
exactly, i got the numbers but I don't know if it's good or bad
E.g. the game's builtin script scheduler assigns maximum of 3 ms time slice for script execution per frame (for scheduled scripts). Maybe that helps as some kind of reference
Also while the Big O notation / time complexity is often very useful thing when optimizing code performance, it doesn't take e.g. the hardware part into account. Things like cache coherence can speed up the execution of seemingly slower code so that it actually beats the theoretically faster solution
then I should be good
thanks
For https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#HandleDamage, directHit seems to always be true for non-local explosive projectiles instead of the expected false. Example would be an artillery round falling near the player, if the round is local, you get directHit as false. If the round is non-local, you get directHit as true.
tbf, HandleDamage has a disclaimer for remote units. If you are going to check damage, check on the machine to which the unit is local to, saves you troubles.
oh nvm, I misunderstood lol
is it possible to get magazine for current weapon and then add it?
currentMagazine and addMagazine
ty
"error reserved variable in expression" error line is apparently the onframehandle
_startPos = getposATL fr_frigate;
_endPos = getPosATL fr_end;
_controlPointATL = getposATL fr_controlpoint;
fromcontrolpointoffset = _controlPointATL vectorDiff _startPos;
tocontrolpointoffset = _endPos vectorDiff _controlPointATL;
t1 = time;
t2 = time + 30;
onEachFrame = {
timeremaining = linearConversion [t1, t2, time, 0, 1];
fr_frigate setVelocityTransformation [
_startPos vectorAdd (fromcontrolpointoffset vectorMultiply interval),
_controlPointATL vectorAdd (tocontrolpointoffset vectorMultiply interval),
[0,0,0],
[0,0,0],
[0,1,0],
[1,0,0],
[0,0,1],
[0,1,0],
timeremaining
];
};
yeah because you are trying to overwrite an engine command "onEachFrame"
name it something else
ahh i see
also, use the EH version
whats the EH versions name?
something like this?
addMissionEventHandler ["EachFrame", {
timeremaining = linearConversion [t1, t2, time, 0, 1];
fr_frigate setVelocityTransformation [
_startPos vectorAdd (fromcontrolpointoffset vectorMultiply interval),
_controlPointATL vectorAdd (tocontrolpointoffset vectorMultiply interval),
[0,0,0],
[0,0,0],
[0,1,0],
[1,0,0],
[0,0,1],
[0,1,0],
timeremaining
];}];
and it also returns a handle that you can use to remove it as well
just given it one
got a new error now
setvelocitytransformation "0 elements provided, 3 expected"
What's the limit on arrays that was introduced in 1.54? I've got some code involving some very large arrays and "setVariabble" (global) that suddenly started failing with 1.54
is that a position related error?
_startPos = getposATL fr_frigatephys;
_endPos = getPosATL fr_end;
_controlPointATL = getposATL fr_controlpoint;
fromcontrolpointoffset = _controlPointATL vectorDiff _startPos;
tocontrolpointoffset = _endPos vectorDiff _controlPointATL;
t1 = time;
t2 = time + 30;
fr_event = addMissionEventHandler ["EachFrame", {
interval = linearConversion [t1, t2, time, 0, 1];
fr_frigatephys setVelocityTransformation [
_startPos vectorAdd (fromControlPointOffset vectorMultiply interval),
_controlPointATL vectorAdd (toControlPointOffset vectorMultiply interval),
[0,0,0],
[0,0,0],
[0,1,0],
[1,0,0],
[0,0,1],
[0,1,0],
interval
];}];
Your _startPos and _controlPointATL variables are private variables defined the script that adds the EH; they are not available in the EH code because it's a separate scope.
so what do i do to push it into the scope
I guess. You should use more unique names for global variables, though. Generic names can potentially get overwritten by other scripts by accident.
You could also consider saving them in the object's namespace with setVariable/getVariable, rather than leaving them in the overall mission namespace. That would let you have multiple objects being operated on at once without conflict.
Oh you changed your post while I was typing that :U
It should have, as long as you changed them to global vars in all instances
However, there is a better way
https://community.bistudio.com/wiki/addMissionEventHandler
addMissionEventHandler supports passing arguments to the EH which can then be retrieved in the EH code
That would be the best method as it's fast, convenient, and doesn't require anything to be global
You should be able to change everything except interval (because it has to be modified and persist between firings) to be passed as arguments
interval should get a more unique name and possibly be moved into the object namespace, though
so override the interval constantly through setvariable and then retrieve it on the interval line
is there a more efficient way to slowly scale the interval?
linear conversion stutters alot
that's probably not the issue. Your code for that looks fine.
any idea then?
Is your testbed SP or DS+client?
oh actually, you do need to set a velocity that makes sense.
DS just adds extra problems.
i figured
how on earth would i set a velocity that makes sense when i just want it to move from point a to b
with a nice curve
You're moving from a known point to a known point in 30 seconds, right
yes
Client 1:
hs = createHashMapFromArray [["a", 1], ["b", 2]];
hs2 = createHashMapFromArray [["one", hs], ["two", hs]];
publicVariable "hs2";
hs2 get "one" set ["a", 100];
hs2
``` => `[["two",[["a",100],["b",2]]],["one",[["a",100],["b",2]]]]`
Client 2:
```sqf
hs2 get "one" set ["a", 100];
hs2
``` => `[["two",[["a",1],["b",2]]],["one",[["a",100],["b",2]]]]`
Interesting property of hashmaps and I guess arrays after network deserialization
I assume there is no way to instantly reload the magazine without re-adding the weapon?
with a condition of "call {true}" and an activation of
call{{if ((side _x) == east) then {_x addEventHandler ["FiredMan", {_shotPos = [_this select 6,(random 4), (RANDOM 360)] call BIS_fnc_relPos; _this select 6 setPos [_shotPos select 0, _shotPos select 1, _shotPos select 2];}];}} forEach allUnits;}
how much can something like this impact performance in large scenarios?
as far as im aware EH's are very performance friendly but i cant help but think this is alot to process for the CPU
Don't know how triggers work much, but I assume you execute this code only once?
If you do, if you'll have more units afterwards they won't have this event handler on them
Btw this code is pretty weird, you'll end up with bullets inside walls and such, could be very bad for say missiles
If you want to degrade accuracy you can do something like:
private _shot = _this select 6;
private _degrade = 5;
_shot setVelocityModelSpace (velocityModelSpace _shot vectorAdd [_degrade/-2 + random _degrade, 0, _degrade/2 + random _degrade]);
Its on a repeatable trigger i should have mentioned
What's your idea for it? Add event handler to all units?
essentially yes my initial idea was to reduce accuracy for all units,but yes i noticed too high values resulted in infantry firing a rifle forward and the guy standing to his left recieving the bullet 😄
With repeatable you'll end up adding the event handler over and over
so each shot does like 100 repositions
I essentially just want to add a dispersion to enemy vehicles now
and static turrets
so terrible idea right?
Maybe it could be done with triggers but I don't use them to tell exactly how
this can be added directly to a units init>?
This is for Fired/FiredMan event handlers
How I'd do it: Make a preInit function that executes:
addMissionEventHandler ["EntityCreated", {
if(_this isKindOf "CAManBase") then {
if(side group _this == opfor) then {
_this addEventHandler ["FiredMan", {
private _shot = _this select 6;
private _degrade = 5;
_shot setVelocityModelSpace (velocityModelSpace _shot vectorAdd [_degrade/-2 + random _degrade, 0, _degrade/2 + random _degrade]);
systemChat str [diag_frameno toFixed 0, "Degraded shot for", _this select 0];
}];
};
};
}];
hey can someone help me out with this:
if !(isNil _mags) then {_holder addMagazineCargoGlobal [_mags, _count2];}
else {diag_log format["Bad magazine array for: %1",_loot];}
for some reason i keep getting this in the log:
"Bad magazine array for: bin\config.bin/CfgWeapons/sgun_aa40_snake_Holo_IR_snd_lxWS"
when the magazine that should have been added to _holder should have been "8Rnd_12Gauge_AA40_Smoke_Snake_lxWS"
I'm not sure if adding EntityCreated in preInit will have editor placed stuff go through it, but I think it should
Did you mean !isNil"_mags"?
very interested in something simple now just for vehicle gunners, would this apply to a vehicle init or gunner ai?
private _shot = _this select 6;
private _degrade = 5;
_shot setVelocityModelSpace (velocityModelSpace _shot vectorAdd [_degrade/-2 + random _degrade, 0, _degrade/2 + random _degrade]);
Check if unit is inside a vehicle before doing thata
am i supposed to put the variable name in doublequotes like that?
Yes, there is isNil STRING and isNil CODE
isNil _mags will check if variable with NAME contained inside _mags exists
isNil"_mags" will check if variable NAMED _mags exists
Ahhh i see thank you!
private _var_to_check = "_somevar";
isNil _var_to_check; // Checks if _somevar exists => false
isNil"_var_to_check"; // Checks if _var_to_check exists => true
isNil{_var_to_check}; // Checks if _var_to_check exists => true
With FiredMan its much easier to apply to man
You can also do it with Fired too but you'll need to add it to every vehicle instead
addMissionEventHandler ["EntityCreated", {
if(_this isKindOf "CAManBase") then {
if(side group _this == opfor) then {
_this addEventHandler ["FiredMan", {
if(!isNull objectParent(_this select 0)) then {
private _shot = _this select 6;
private _degrade = 5;
_shot setVelocityModelSpace (velocityModelSpace _shot vectorAdd [_degrade/-2 + random _degrade, 0, _degrade/2 + random _degrade]);
systemChat str [diag_frameno toFixed 0, "Degraded shot for", _this select 0];
};
}];
};
};
}];
if(!isNull objectParent(_this select 0)) then { will check if unit is inside a vehicle before applying the accuracy degradation
adding it to every vehicle is doable,its for pre placed units
so the above on each vehicle but not gunner right?
Do a this call someFuncToAddMyEventHandlers instead of whole code
Its for every opfor unit, but each shot is checked if unit is inside a vehicle and only then does a degradation
ohh i see
can it be a simplified version of fired,that i can apply to a a specific unit/vehicle?
i just have 20 vehicles on opfor i want to edit essentially
to reduce their accuracy by ANY means
Add Fired in each init field
or better call function that adds Fired
So you don't have to copy-paste same stuff over and over
Read the wiki entry on arrays
"arrays are limited to maximum of 999999 (sometimes 1000000) elements"
thanks man. im more familiar with using the editor,and unit inits and working right from there, iv decided to alter my original and use it on a per unit init basis such as tank gunner/commander without the needs of triggers
this addEventHandler ["FiredMan", {_shotPos = [_this select 6,(random 10), (RANDOM 360)] call BIS_fnc_relPos; _this select 6 setPos [_shotPos select 0, _shotPos select 1, _shotPos select 2];}];
random 10 being configurable
Move this into a function and have units call the function
So you don't have to copy-paste same thing exactly
thanks
Define your function, the call it in init field
bout time i learned that
If you have a mission you can also be lazy and fast and add functions via init.sqf / initPlayerlocal.sqf / initServer.sqf in your missionfile.
{
missionNamespace setVariable [(_x #0), compileScript [_x #1]];
} forEach
[
["ABC_fnc_A1","ClientCode\ABC_fnc_A1.sqf"],
["ABC_fnc_A2","ClientCode\ABC_fnc_A2.sqf"]
];
its really simple once you know what part does what
its not even that hard as well
No, but you can produce similar behaviour by other means
how?
If you give me 20 seconds to type it I'll tell you :U
sorry. take your time
#arma3_scripting message
The messages from me and Sa-Matra here describe the main ways you can do it
thanks
SPEAK!
Thanks! I didn't even think to look at that, that's how bad BIS have usually been with updating the wiki :P (in the past, the last few months were a really nice change :) )
I have a question is there a command that would be gettting AGL inseatd of ASL or ATL
I read something about just getpos
the counter-question would then be: why?
I want it for my calculations of altitude of my players for code I did like if you are above ground under 1700m but under 10m (they are landed on the runway ) the code doesn't do anything. If you are over 1700m then the code does thing 1, if under 1700m the code does thing 2. Actually writing this I realize it could be cheesy to do so
and taxing probably to the server
I thought what if someone flies like the way the provided diagram in wiki shows
is it dumb
what type does arma use for plane altitude in the gui
i think its a combination of ASL and ATL..?
The wiki has been on point for at least the last two years in my experience. If not BIS updating it, it would be KK and the other splendid contributors
Yeah. I guess scripting has been covered quite well for some time now, it's a shame that config/toolchain stuff doesn't get the same love :(
I did not understand what you want
you could use
params ["_posASL"]; // getPosASL _vehicle
if (surfaceIsWater _posASL) then
{
_posASL select 2;
}
else
{
(ASLToATL _posASL) select 2;
}
Hi there, how do I pass a variable to selection in addAction? It requires string, but I want to make dynamic code without making separate function for every door.
I tried {format ["Door_%1", _doorNum]}both with and without quotes, tried "{format ['Door_%1', _doorNum]}", and nothing works.
Uhm, I thought I tried this, thank you
Also, all this info here http://foxhound.international/development.html should probably be somewhere on the wiki, too! Btw, thanks to @tribal crane for writing those, great ressources! :)
Is there a way to automatically escape strings with brackets in it?
Example:
Instructions:
'["vn_fnc","x-coordinates","y-coordinats","response","ammo_type"]
"vn_fnc" can ONLY be one of these three: "vn_fnc_artillery_arc_light","vn_fnc_artillery_plane" and "vn_fnc_artillery_heli".
The user will try and call a grid reference most of the time existing of 6 numbers. You need to split it into x-coordinates and y-coordinates.
DO NOT CHANGE THE NUMBERS you split.
"response" is always a forward air controller talking to forward observer on the ground.'
I know how to escape in python but not sure how to make it work in arma.
sorry im not sure what you mean but maybe this helps: https://community.bistudio.com/wiki/parseSimpleArray
Is there an opposite of this?
array to string?
Doesn't SQF have else if?
no
No
I'm confused
literally scroll up a bit
Good afternoon
I create a "Titan_AT" projectile and set it via the player's "setShotParent".
However, for some reason in Kill eventhandler both killer and instigator are zero
What could be the matter?
where is setshotparents executed
[_missile, [_player, _player]] remoteExec ["setShotParents", 2];
Crime Alley
can someone point out the syntax error and explain why?
this addAction
["skip 5 hours", {skipTime 5},
"_this distance _target < 5"
];
works ok but im getting "bool" error
_this is an array as explained in https://community.bistudio.com/wiki/addAction
this addAction [
"skip 5 hours",
{ skipTime 5 },
"",
nil, // arguments
1.5, // priority
true, // showWindow
true, // hideOnUse
"", // shortcut
"true", // condition
5 // radius - here is where you may be interested
];
@bleak mural ↑
mismatched } detected
real quick question how do I get the class name of a vehicle
typeOf _vehicle, in a script.
If you're in the Editor, you can mouseover it, or rightclick and select Log > Log Classes to Clipboard.
What does it mean?
any way to make this forEach better?
AllowedVehicleClasses in an unsorted string array
{
if(_x in _category) exitWith{
_canAttach = true;
}
} forEach FABHH_mmv_AllowedVehicleClasses;
I'm hitting 0.01ms in my PC, but I have no idea if that's any good
findAny
What's the best way to disable teamswitch in an SP/MP scenario? enableTeamSwitch = 0 has no effect in SP
disable how? end game on death?
Totally.
Prevent access to the menu.
I guess I have to use an EH + disable the button in the pause menu
i wish i could help you but im under impression the team switch is not even enabled by default
It is a reference to Bruce Wayne's parents ^^
does anyone know what config specifies or is used to calculate in game velocity of a projectile? Let's say of 40mm grenade, ammo G_40mm_HE, mag 1Rnd_HE_Grenade_shell? (that is used in example in RHS M4)
I believe it's the ammo initSpeed combined with something from the weapon config (representing barrel length). Then over time the ammo's drag config, and acceleration if it has it, also affects it.
its initSpeed in the magazine for the muzzle velocity
airFriction is how much the speed is reduced and is in the cfgammo
weapons can modify initspeed too
@ivory lake and @hallow mortar thanks, I'll give it a try
initSpeed being magazine instead of ammo makes me very sad
Hey! I'm working on a pretty classic vehicle ambush where a convoy's lead vehicle getting blown up by an IED is an initiator for an ambush. How do I ensure the enemy infantry don't open fire until the lead vehicle is destroyed?
https://community.bistudio.com/wiki/disableAI quick n dirty method
Then use a trigger that relies on a !Alive vehiclename to re-enable and maybe a look at or do target
They will track but won't shoot. Vehicle goes up in flames they open up
{ _x setCombatMode "GREEN" } forEach _groups;
waitUntil { sleep 0.1; not canMove truck1 };
{ _x setCombatMode "YELLOW" } forEach _groups;
```of course, can be adapted
(https://community.bistudio.com/wiki/setCombatMode)
I use a couple of AI enhancing mods which I think will, unfortuntely, mess with that. Do you think it'd be a better idea to set them as civilian?
Got it
maybe this?
{_x disableAI "TARGET";} forEach (allUnits select {side _x == east});
waitUntil {damage leadVehicle >= 1};
{_x enableAI "TARGET";} forEach (allUnits select {side _x == east});
Where would you run this? Gamelogic?
(please use my waitUntil, waiting on disabled/destroyed vehicle)
Got it.
What happens if you pubVar "hs"? Same result?
Didn't test but I bet it wont be same hs inside original hs2
It seems it's not bug or glitch because after deserialization there are two separate copies of the same array which aren't affected by the SET command
so we have two references which linked to the two different arrays
it's a bit inconsistant to send the local reference over the network
so basically we have this:
pseudo:
array1 = [1, 2];
array2 = [array1, array1];
IS
array1 = [number(1), number(2)];
array2 = [unique_ref_array1, unique_ref_array1];
publicVariable "array2";
array2 is [unique_ref_unnamed_array_7345, unique_ref_unnamed_array_2948d];
a real life pseudo code user?
as unique_id_unnamed_array_7345 is not linked with unique_id_unnamed_array_2948d anymore, they refer to the separate arrays after transfering to the other machines.
As workaround you can utilize EH which accepts unique_ref_array1
and assembles array2 locally from the received data. As an advantage - it saves network bandwidth / performance by not sending the whole array2, but only part of the data (array1).
publicVariable article on the BIS Wiki:
It is not possible (and illogical) to transfer a local entity reference, such as scripts, displays or local objects.
Also, note that Team Member is not supported.
Is there some kind of eventhandler to connect the terminal to the drone?
do you want to connect the terminal to the drone, an EH on terminal connection, or an EH on drone usage ?
I want to deny access to some of the drones, depending on the variable on them. To do this, I'm trying to find a way to catch the terminal's connection to the drone, so that I can turn it off later
/* player addAction ["Get in the turret"]; {Player moveInGunner AATurretOlive_1}; */
hmm
wat
nvm, i figured it out
was just trying to use the syntax bot to see where my code was wonkey 😅
Paste it into the Advanced Developer Tools console, works pretty well.
is it possible to know, through the fired event handler, on a dynamic loadout vehicle, which pylon was used?
Seems that's a no. What is your goal to get the pylon?
regenerate ammo on pylons after a certain time
for that I check if the magazineTurretAmmo is 0
then I iterate through getAllPylonsInfo using the _magazine from the fired EH to find the magazine that is also used by the pylons
{
if (_magazine == _x select 3) then {
_thisvehicle setAmmoOnPylon [_forEachIndex+1, 9000];
systemChat format["set ammo on pylon %1", _forEachIndex+1];
};
} forEach getAllPylonsInfo _thisvehicle;
but current implementation is kinda glitchy
magazineTurretAmmo behaves very strangely when there's two or more of the same pylon in a vehicle
that sounds fail proof but at the same time a mess to work with
IIRC magazineTurretAmmo issue is known. I can't think up any workaround
looks like I gotta use ammo instead
oh if only bohemia added pylonindex to the fired EH....,.,..........................
Probably a ticket worthy thing
ok I gotta try something else
I have an A-164 wipeout with two pylons with one falchion missile each. the hud on the top right says I have two missiles, that is correct
however player ammo currentMuzzle player returns 1
is there a well known autonomous way/EH or script thats easily applied to an Ai vehicle that detects if they are on their side or roof,and then sets there direction back to normal? Im going to delve into making something if not as iv figured out how to prevent disembark from damage,in water,and upside down
but wanted to ask here first if anyone knows a quick n easy method
im unsure what im looking at here theres many pages on this
never mind, got something working.
Can someone point out the syntax error, im unsure why this isnt working
if !(isServer) exitWith {};
private ["_allVehicles","_vehicle","_fnc_flipVeh"];
_fnc_flipVeh = {
params[ ["_object",objNull,[objNull]] ];
waitUntil {
sleep 1;
(_object nearEntities ["Man", 10]) isEqualTo [] || !alive _object
};
if (!alive _object) exitWith {};
_object allowDamage false;
_object setVectorUp [0,0,1];
_object setPosATL [(getPosATL _object) select 0, (getPosATL _object) select 1, 0];
_object allowDamage true;
};
while {true} do {
_allVehicles = (entities [["LandVehicle"], [], false, true]) select {
(getNumber (configFile >> "CfgVehicles" >> typeOf _x >> "hasDriver")) isEqualTo 1 &&
{(crew _x) isEqualTo []}
};
{
_vehicle = _x;
(_vehicle call BIS_fnc_getPitchBank) params ["_vx","_vy"];
if (([_vx,_vy] findIf {_x > 80 || _x < -80}) != -1 && {!canMove _vehicle}) then {
0 = [_vehicle] spawn _fnc_flipVeh;
};
} forEach _allVehicles;
sleep 4;
};
getting errors with "if (!alive _object) exitWith {};"
which is needed to check if vehicle is still alive,looks ok but erroring
This is because the missiles are two magazines of one missile each, and ammo returns the number of rounds in the magazine
Post full error
'....exitwith {};
_object allowdamage false;
|# | _object setvectorup [0,0,1];
_object...'
ERROR invalid number in expression
file C: \Users\PC\documents\Arma3\mission ......
Line16
but the set vector up is written correctly here
Add logging to see what's going on
diag_log ["_object", _object];
and other vars
then check RPT
cheers
i took a simpler approach
con: vectorUp v1 select 2 < 0
act: v1 setVectorDirAndUp [[1,0,0], [0,0,1]];
repeatable trigger
does anyone know if you can add height using this function "setVehiclePosition"?
doesnt look like it according to wiki. if you want to place something in air just use setPosATL
from wiki: "Normally only x and y are considered, unless "CAN_COLLIDE" is used for special placement"
so thats another option
I know how to skip a waypoint using a trigger, but how do I skip a waypoint using a script?
thanks for the quick help, im using setVehiclePosition to be able to spawn objects on 2nd floor in buildings, but using setposATL at the same time doesnt work with it, all im trying to do is spawn them with alittle bit of height so that spawned objects dont drown underground/floors
then i guess CAN_COLLIDE could work but you need the z of the current floor you are placing them. building position would give you the z
building pos is actually quite handy if you want to place them at random positions in the house
Not sure what channel this should go in, but how do I get a helicopter to land on a position and stay there? I've got a land WP, and then a hold WP that is on a radio trigger. But after landing, the helicopter hovers at the hold wp
the code is somewhere "line 264" this is going to tough if anyone wants to help, but i got stuck for days trying to figure out how to increase the height of the spawned loot inside buildings
i tried setVehiclePosition on a box but it just moves a box to random pos in the house
what is exactly what you want to do?
the sqf works 99% fine, the only downside is that loot sometimes spawns underground making it invisible, so im trying to give alittle elevation to stay above the ground
ok
i tried this "_itembox setPosATL [_posToSpawnLoot select 0, _posToSpawnLoot select 1, 1];"
but then cancels the setVehiclePosition not allowing spawns on 2nd floor in buildings
hmmm
i think u need to sync the radio trigger to the WP, if u want to set off waypoints using triggers
u might also need to name the heli and use the "disableAI "MOVE";
for a good explanation look at this video https://www.youtube.com/watch?v=GjFNCceuSDg
How to activate waypoints via triggers in Arma 3.
i solved by something so stupid
i just had to change from this _itemBox setVehiclePosition [_posToSpawnLoot, [], 0, "CAN_COLLIDE"]
to this _itemBox setVehiclePosition [[], [], 0, "CAN_COLLIDE"]
it gives me an error but it still works, im getting Arma'd
Can addAction "condition" parameter access variables defined within addAction scope? Example
_someobj addAction ["Some action", {
private _someVariableName = "TAG_some_missionNamespaceVariable";
},[],6,true,true,"","!isNil _someVariableName", 10,false,"",""];
Not local scope variables. Global variables, yes.
Shame but I expected that much, thx
private _currPos = getPosATL _object;
private _heightAboveTerrainLevel = 5;
private _newPos = _currPos vectorAdd [0, 0, _heightAboveTerrainLevel];
_object setPosATL _newPos;
cheers that looks nice piece of code that makes things abit easier, will definitely use it
technically it's _heightAboveCurrentPos
private _currPos = getPosATL _object;
private _heightOffset = 5;
private _newPos = _currPos vectorAdd [0, 0, _heightOffset];
_object setPosATL _newPos;
```**or**```sqf
private _posATL = getPosATL _object;
private _altitudeATL = 5;
_posATL set [2, _altitudeATL];
_object setPosATL _posATL;
I'm altering a very old script from 2014 for a bomb defusal but the script doesn't activate the "BOMB ARMED" timer whenever you disarm before the timer starts on screen. I've been trying to figure out how to get it to work but no success. I'm not sure where to call the start of the 5 second timer. (same goes for taskSetState but I think I can figure that out later..)
init.sqf
CODEINPUT = [];
CODE = [(round(random 9)), (round(random 9)), (round(random 9)), (round(random 9)), (round(random 9)), (round(random 9))]; //6 digit code can be more or less
WIRE = ["BLUE", "WHITE", "YELLOW", "GREEN"] call bis_fnc_selectRandom;
DEFUSED = false;
ARMED = false;
codeHolder = [lAPTOP1, LAPTOP2, LAPTOP3, LAPTOP4] call BIS_fnc_selectRandom;
codeHolder addAction [(("The Code")),"DEFUSE\searchAction.sqf","",1,true,true,"","(_target distance _this) < 3"];
caseBomb addAction [("Defuse the Bomb"),"DEFUSE\defuseAction.sqf","",1,true,true,"","(_target distance _this) < 5"];
//Mission Task
if (isServer) then {
[ west, "Task_Defuse", ["Find the code and defuse the bomb before it explodes.", "Defuse the bomb.", "DEFUSE"], caseBomb, TRUE ] call BIS_fnc_taskCreate;
};
// Hide helper arrows
{hideObject _x} forEach allMissionObjects "Helper_Base_F";
[] spawn {
waitUntil {DEFUSED};
caseBomb removeAction 0;
hint "";
["Task_Test", "Succeeded"] call BIS_fnc_taskSetState;
};
[] spawn {
waitUntil {ARMED};
caseBomb removeAction 0;
hint "";
["Task_Test", "Failed"] call BIS_fnc_taskSetState;
};
fn_bombTimer.sqf
private ["_bomb", "_time"];
_bomb = [_this, 0, objNull, [objNull]] call BIS_fnc_param;
_time = [_this, 1, 0, [0]] call BIS_fnc_param;
//Validate parameters
if (isNull _bomb) exitWith {"Object parameter must not be objNull. Accepted: OBJECT" call BIS_fnc_error};
while {_time > 0 && !DEFUSED} do {
_time = _time - 1;
hintSilent format["Bomb Detonation: \n %1", [((_time)/60)+.01,"HH:MM"] call BIS_fnc_timetostring];
if (_time < 1) then {
_blast = createVehicle ["M_Mo_82mm_AT_LG", position _bomb, [], 0, "NONE"];
{
if (_x distance _bomb <= 15) then {_x setDamage 1};
} forEach allUnits;
};
if (ARMED) then {
_time = 5;
ARMED = false;
};
sleep 1;
};
//Return Value
_bomb
Is there a way to lock a weapon or prevent the user of a turret to fire ?
I could remove the weapon, but i need the player to be able to see how many ammunitions are left
Hi sorry if this is a redundant question but im trying to set Ai (hmgguner1) to enter the vehicle as gunner (hmg1). I set the command on activation hmggunner1 moveInGunner hmg1; but the ai just walks to the car and stand still, what did i do wrong?
wait nvm, I changed to move and it works, but vehicle get in doesnt work?
In arma 3 using sqf or one of the commands how to check that batteleye anti cheat is on?
I cant seem to get BIS_fnc_ambientAnim to work correctly on dedicated server +hc.
I have the the following code:
params["_unit", "_chair", ["_combat", true]];
if(!local _unit) exitWith {};
//BIS_fnc_ambientAnim do not work from init, add sleep
sleep 2;
private _cPos = getPos _chair;
private _cDir = (getDir _chair) + 180;
_unit disableCollisionWith _chair;
_chair disableCollisionWith _unit;
_unit setPos _cPos;
_unit setDir _cDir;
[_unit, "SIT2", "ASIS"] call BIS_fnc_ambientAnim;
if(_combat) then
{
(group _unit) addEventHandler ["CombatModeChanged", {
params ["_group", "_newMode"];
if(_newMode == "COMBAT") then
{
{
_x spawn
{
sleep random 3;
_this call BIS_fnc_ambientAnim__terminate;
_this setUnitPos "UP";
};
} forEach (units _group);
};
}];
};
do i need a longer sleep? is it a locality issue? if i understood the wiki right it is supposed to be executed where the unit is local only
works fine in the editor
From where are you executing that code?
init of the unit (solo)
ah, it is a function containing the above. the actual init has [this, c6, false] spawn FLO_fnc_sitOnChair;
the unit is just sent to the chair location, fixed in place and wont react and only loop some jerky buggy animation
You should use getPosASL / setPosASL or ...ATL rather than plain getPos/setPos. getPos and setPos don't use the same position format so combining them can introduce an error.
You don't need to do disableCollisionWith both ways; it's already a bidirectional command.
thanks, i have updated and will try it out
no jerky movement now, but they are still just standing still on the chair pos.
I have dynamic sim enabled for these units and they start outside the range, could that break it?
Yes
so should i keep them simulated all the time, or is it enough to toggle it on before i issue the command?
or will it break as soon as i turn it off again?
l = getUnitLoadout player; l set [5, nil]; player setUnitLoadout l; l select 5
``` => `["B_UAV_01_backpack_F",[]]`
😠
setUnitLoadout modifies the array without asking
Wanted it to avoid creating the backpack
scratch that, apparently i had already disabled dyn-sim on them and forgot.
Set it to an empty string?
I don't get it. What are you trying to do?
yeah that might be impossible.
hmm
I wonder if setUnitLoadout is much slower when there's a backpack in there.
I remember empty and full loadouts being vastly different costs.
Hi! I've setup a wasteland server for me and my friends and i'd like to edit it to add modded cars to the static spawns around the map, i endded up finding the spawn script and the variable used to define the vehicle type but i dont get where you find what's the vehicle type..
Hope i dont interupt your convo 🙃
here's the code for the vehicle type variable
private ["_createRandomVehicle", "_totalRadius", "_carPerMeters", "_townThreads", "_startTime"];
_createRandomVehicle =
{
private ["_pos", "_minrad", "_maxrad", "_counter", "_vehicleType", "_mindist"];
_pos = _this select 0;
_minrad = _this select 1;
_maxrad = _this select 2;
_counter = _this select 3;
_vehicleType =
[
[A3W_smallVehicles, 0.30],
[civilianVehicles, 0.40],
[lightMilitaryVehicles, 0.15],
[mediumMilitaryVehicles, 0.15]
!code
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
Thought I found a hack how to quickly take the backpack until we have actionNow, but it takes random amount of frames to complete
Stupid take animation
how do i fix this
hint format ['"Health: %1",(((1-_Health)*100)-((1-_Health)*100 mod 1))\n%1\nThirst\n%2\nHunger\n%3', health, thirst, hunger];
random burst of bad maths in the middle of the string
yeah I noticed, the ammo count on the HUD is the sum of all respective mag ammo counts
is there a way to easily get that number?
I only know really bad ways. The pylon stuff is a mess.
Basically iterate over the pylons, check the magazine types and add the current ammo.
oh my god
actually it's worse than that :P
Trying to figure magazine commands in SQF is like doing a puzzle
Also you can delete the magazine from the vehicle yet getAllPylonsInfo will still show that magazine and ammo in it
Whoever wrote our pylon code decided that there wasn't a way to determine the remaining ammo on a pylon, so it generates the full value on init and reduces it with Fired EHs :P
Looks like pylon commands simply return last known magazine values instead of real magazines or something
forgive me coding masters, for I shall iterate a lot.....................
But yeah, magazines in Arma are generally bad. Pylons are even worse.
I love that pylons exist but technically they're a forking disaster
magazines are at least doable... ish
but you can't do much with them specially in vehicles
if you add a magazine to the turret it'll still count as 0 if you try to get ammo from the magazine because it's fetching from the first, now empty mag
so you must delete the old empty mag
Magazines used to be worse, I think. JNA has some pretty crazy methods for what are simple operations with commands added since.
Yeah, you had very little control over vehicle magazines some years ago
Some stuff is still impossible
Like loading particular magazine or setting ammo to particular magazine
oh no no that ain't gonna work 💀
also magazine stuff sometimes breaks AIs because they simply don't acknowledge that they got a new mag
maybe you can force them to reload the magazine so they acknowledge the new mag then force reload to their old mag
maybe
but this sounds extra terrible
uh oh I need to define if a vehicle's weapon is dynamic loadout or not
hm
because, of course, if you use the normal magazine scripting commands on pylon weapons, it'll break them
If not accounting for this bug you can get all magazines with magazinesAllTurrets then delete magazines from getAllPylonsInfo and that will be your non-pylon magazines
doable but i'll try finding something in the weapon config to determine if a weapon is pylon or not
at all or right now?
walk through all pylons, get their weapon class, check if weapon is in that turret
Mag >> pylonWeapon
thing is using mags is somewhat bug prone because some vehicles can have both non-pylon weapons and pylon weapons that use the same mag
yeah, I have a note about that on some pylon-stripping code.
Might be useful:
private _turrets = [[-1]] + allTurrets _veh;
private _toRemove = [];
{
private _turret = _x;
private _baseWeapons = getArray (([_veh, _turret] call BIS_fnc_turretConfig) / "Weapons");
private _weapons = (_veh weaponsTurret _turret) apply { toLower _x };
// Avoiding array subtract in case there's a pylon and non-pylon copy of the same weapon
// RHS has case bugs (zu-23 notably) so we force everything lower
{ _weapons deleteAt (_weapons find toLower _x) } forEach _baseWeapons;
{ _toRemove pushBack [_x, _turret] } forEach _weapons;
} forEach _turrets;
Trace_1("Removing pylon weapons: %1", _toRemove);
{ _veh removeWeaponTurret _x } forEach _toRemove;
thanks, will take a look
For missiles you can probably assume that everything's a pylon though.
Hello
I need to add all the commands that allow you to kill a player in the battleye filters, I added setDamage, setVehicleArmor and all setHits commands. Do you know any more?
I have added the setPos filters too.
yeah that's kinda safe, I guess I'll play with mag comparison as I'm for sure hoping that magazines in pylon weapons and non-pylon are slightly different
For guns there are absolutely cases where the same magazine is used for pylon and non-pylon weapons.
i'm extra painfully aware of this
There are still existing vehicle classes, from before pylons were added, that use missiles, and who knows what mods do
but the occasion is rare enough for me to not tear my hair off because of it for now
I also need to find a workaround for manualfire
_mmvEHIndex = _vehicle addEventHandler ["Fired", {
params ["_thisvehicle", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
// Attention: ADD SUPPORT FOR MANUAL FIRE - "_gunner" can be NULL!'
if (_thisvehicle magazineTurretAmmo [_magazine, _thisvehicle unitTurret _gunner] == 0) then {
_currentTurretPath = _thisvehicle unitTurret _gunner;
_thisvehicle removeMagazineTurret [_magazine, _currentTurretPath];
_thisvehicle addMagazineTurret [_magazine, _currentTurretPath];
_thisvehicle loadMagazine [_currentTurretPath, _weapon, _magazine];
};
}]; //end EH
Is _gunner null when you use manual fire?
Anyway I was looking into manual fire few days ago
yeah
another method(if you have similar issue in future) is something i used to to when i "ported" dayz map into Arma3 and buildings had no positions for loot. i hand placed containers(which had positions) into every building on the map,set them to hide, and my loot script picked up the container pos,and spawned loot,above the floor as container was slightly above when placing via editor. Alot of work,as u can imagine but worked
What is needed to check if you can manual fire
isManualFirecommand returningtrue/enableManualFire=1in vehicle config to know if its possible at all- You can manual fire from
primaryObserver=1turret or driver if no turret has it - You manual fire a first turret that has
primaryGunner=1
i'm thinking of just overriding _currentTurretPath with [0] if isManualFire returns true, it'll fix 99% of the cases
or find a way to somehow know the turretPath manual fire takes control of
Its primaryGunner=1 turret
thats cool idea, although the script im using pretty much spawns any loot to any unknown building from mods or whatever, so far i've never seen it fail once, script is called "sccloot" u can look it up on google if u wanna try it
// Params: [Vehicle, String (Property), Code (Condition)]
// Returns: Array (Turret)
both_func_vehicles_findTurretProperty = {
if(_this select 0 isEqualType objNull) then {
_this set [0, typeOf(_this select 0)];
};
call both_func_vehicles_findTurretPropertyC;
};
both_func_vehicles_findTurretPropertyC = {
both_vehicles_findTurretPropertyCache getOrDefaultCall [_this, {
params ["_vehicle", "_property", "_condition"];
if(isNil"_condition") then {_condition = {getNumber(_this) > 0}};
private _trts = configFile >> "CfgVehicles" >> _vehicle >> "turrets";
private _turret = (for "_i" from 0 to count _trts - 1 do {
if(((_trts select _i) >> _property) call _condition) exitWith {[_i]};
private _trts2 = (_trts select _i) >> "turrets";
private _subturret = (for "_j" from 0 to count _trts2 - 1 do {
if(((_trts2 select _j) >> _property) call _condition) exitWith {[_i, _j]};
});
if(!isNil"_subturret") exitWith {_subturret};
});
if(isNil"_turret") then {[-1]} else {_turret};
}, true];
};
both_vehicles_findTurretPropertyCache = createHashMap;
// Params: Vehicle
// Returns: Array (Turret)
both_func_vehicles_getPrimaryTurret = {
both_vehicles_getPrimaryTurretCache getOrDefaultCall [typeOf _this, {
[typeOf _this, "primaryGunner"] call both_func_vehicles_findTurretPropertyC;
}, true];
};
both_vehicles_getPrimaryTurretCache = createHashMap;
// Params: Vehicle
// Returns: Array (Turret)
both_func_vehicles_getPrimaryObserverTurret = {
both_vehicles_getPrimaryObserverTurretCache getOrDefaultCall [typeOf _this, {
[typeOf _this, "primaryObserver"] call both_func_vehicles_findTurretPropertyC;
}, true];
};
both_vehicles_getPrimaryObserverTurretCache = createHashMap;
```You can have code I use
cached turret config look up
probably could be optimized a bit but its cached so its fine
Oh wow, true, probably not fixed for backwards compatibility or something
I stopped using Fired for a while now, always use FiredMan and it always has gunner and vehicle regardless of manual fire or even UAV control
Is there any way to get the highest point on earth?
I need to press the object to the ground, taking into account houses, stones, etc.
is there any reason that a gameLogic would be removed or something on dedicated servers?
I am trying to run this on all players
player setPosATL (getPosATL nameOfGameLogic)
the logic is just placed and named in the editor. This used to work fine, even on dedicated, but not i end up at 0,0
When are you doing this?
huh?
a trigger after the game is running
Do some logging
diag_log ["nameOfGameLogic", nameOfGameLogic, getPosATL nameOfGameLogic];
I remember vehicle var names being unreliable
will do, at least it still works in editor. so must be something with locality
Roughly speaking, I have an object and I want to press it to the highest surface in the position
theyre unit names for some reason?
You mean on top of everything?
You'll need to cast a ray downwards
a trillion raycasts...
unfortunately I can't really use FiredMan on what i'm trying to do, as it will trigger for units with FFV
plus other things I thought about and forgot for now
oh yeah a total rewrite... maybe later
indeed, this time it worked and it shows up in the log for both me and server..
any way to force it to sync? or would placing a hidden object be more reliable
You can try having something like nameOfGameLogic = this in Logic's init
to make sure that variable contains it
FiredMan for FFV will have unit in both gunner and vehicle (source, instigator)
will try that, thanks!
rewriting everything to use firedman will be the very last option for now
my god this pylon stuff is a thing of nightmares
Sounds like what I'm looking for. But my experiments did not lead to success.
I am not sure if I should be proud of myself with these hacks i'm pulling off to make things work
I want to make a script to give me random missions and exfil how would I go about that thanks
I know there is mods and scripts for this but I want to learn how to do it so I can customize
How far are you into learning scripting?
Hi, does anyone know if its possible to adjust player/AI small fire weapon elevation? (to fire at a certain angle), or if it's possible to make AI adjust elevation to perform indirect fire using GL launcher via SQF
i'm using spawn yet the sleep statement inside the function says suspending is not allowed
🤔
why is a function spawned from initServer not allowed to suspend
It is. You must be doing something else. Maybe an EH?
yeah but i found a way to not use sleep altogether
I was using the group created EH, but entitycreated works too
and better, no need to wait for the units to fill the group
that was my pain point
Code in an EH is run in unscheduled context.
how do I move an entire collection/ layer with a setpos? I have a composite collection I wantr to move across the map from one static pos to another. Is there a nifty little way to move entire collections, or do I have to respawn every piece with specific coordinates and stuff?
yeah I totally missed that
skill issue from my part
I have a question. I made a script and want to know how it will work if it is encapsulated in foreach player
the code is in acomposition so it runs locally from zeus
I swear we went over this a few weeks ago
where's the documentation for Config.cpp
mostly this: https://community.bistudio.com/wiki/CfgPatches
it helps a little
already took a look
Is it possible to disable damage to details in vehicles, such as the track or turret? and that he would receive the damage as a whole?
use an event handler on the vehicle then use a scripting command to automatically heal that part
this is where I would start
OK, thank you i try
do you know how to make it so that when AI goes into combat mode, it still goes to waypoint a? now he stopped and started shooting (tanks)?
- Don't let them go into combat mode.
man add-on builder is ignoring all my functions/script files
dunno what i'm doing wrong
Are you using the UI or command line?
UI
I tried, but it still happens. maybe it's some addon's fault? (cfg)
Add their extensions to "list of files to copy directly".
Disabling binarization may also work. I forget. That's the only way with the command line version because the exclude seems to be bugged.
yeah that was it
There is no good way. Do you want to know the really bad way?
In general Arma AI does what it wants and you shouldn't fight it unless it's really important.
finally got my add-on working in game
OK I understand. 🙂
So can anyone help me get on the right track to make random mission generation
A lot of scripting knowledge and more. There is no one-stop guide or anything about it
Start reading here
Could someone help me write a script to prevent the tank's gun from getting damaged? or turn off hit points ??. But the tank would still be destructible ??? plese
Use the handle damage event handler, filter it by the selection name for the gun barrel, and set the return value to 0.
I have a question. Is it possible to set a custom loadout on a plane to carry 2 VLS cruise missiles? I know you can set custom weaponry but I don't know how
Unfortunately, I can't write something so advanced :(. Could you help me?
I found something like this. But this is probably the other way around, because this script only gives damage to selected parts. and I would like it to skip selected parts _unit addEventHandler ["HandleDamage", {
private _unit = _this select 0;
private _hitSelection = _this select 1;
// If the part is in ["head", "face_hub"], allow damage to it, otherwise return the part's original damage with none in addition
if (!(_hitSelection in ["head", "face_hub"])) then {
_damage = if (_hitSelection isEqualTo "") then {damage _unit} else {_unit getHit _hitSelection};
};
_damage
}];
first run getAllHitPointsDamage cursorObject on your vehicle to see what the selection and hitpoint names are.
@fair drumok says nothing about making a random mission script ...I would have to see a video or written tutorial to understand that.
I already know what these parts are called. it's about a vanilla tank. but I don't know how to write it so that, for example, the cannon or tower would not be damaged. 😦
What it does tell you is how to start getting into scripting. You stated you wanted to learn it, so I'm giving you the starting steps. A lot of this journey is going to be reading. Luckily, Arma 3 is very well documented. You need to understand the
task system
https://community.bistudio.com/wiki/Arma_3:_Task_Framework
Scheduler
https://community.bistudio.com/wiki/Scheduler
Loops, variables, arguments, parameters, initialization files, etc.
You want the customization, but it comes with the overhead price of learning a lot of this.
Read what I linked originally, then start moving to the other things I linked
I have been using chatgpt to show me ways of making dynamic missions but none of the code works
Chatgpt is straight garbage for sqf
There isn't enough data out there for it to learn on. Its going to always be wrong.
ok like I said though I learn better from a video
Not much out there at the moment that is up to date unfortunately.
For your specific goal
I feel lost just looking at the different codes and what they do I have to see it in action
Instead, try starting with some smaller simpler tasks. Things like, learning how to teleport a unit, or creating a vehicle. Small things first, that will eventually lead to the big thing you want
is there a way to take a mission and look inside it to see how the scripts are written
I made this mission with some code
I don't remember exactly where workshop missions are stored, but yes, your computer has a copy of everything it downloads.
took like 2 days to make this mission but I think it turned out ok
Many missions and mods have public githubs you can go to. Just don't copy paste the stuff, but you can see how people did things.
I dont do that I just watch how its done and change stuff I like
So how do I open these missions up in the editor
Unpack the pbo, take the folder and place it in the missions folder in your documents
Should be something like
Missionnamehere.mapname
ok...So ever since I have been playing the western shara dlc I like how that mission plays out and gives you different obj and money for the work, and I like how old man missions worked
Dlc stuff is locked behind a .ebo file until after some time and then BI unlocks it. You might not be able to look at their stuff for sahara
I have been playing tarkov and gray zone and have been trying figure out how I can make a mission where you go stuff and get new weapons or money
Start smaller. Learn how to even spawn random stuff in a crate first.
I wanted to make my own gray zone as it where cause I like how that missions works then I found Dlc extraction which really is like gray zone
The mission I put in this post I made the whole thing and learned triggers and putting stuff on a computer to make you get intel
I already found the solution if anyone needs it. it sounds like this to aUnit addEventHandler ["Hit", {
params ["_target"];
_target setHitPointDamage ["pointname",0];
}];
Good, now keep learning. Break your future idea into pieces and figure each piece out first. Start small. Things like "how do I spawn a vehicle via script". This is my final comment on the topic for now.
ok Thanks for your help
is it feasable to script something that can force organically AI GL users to fire flare rounds at enemies at night?
i remember seeing AI using flares before years ago im just not sure what triggered it
@meager granite I'm wondering, can the game engine automatically reassemble the array / hashmap transfered over the network and consisted from the references pointing on the same array?
arr = [];
refArr = [];
// Generate array with the actual data
for "_i" from 0 to 1023 step 1 do
{
// [0, 1, 2, 3, 4, ..., 1023]
arr pushBack _i;
};
// Generate array with the references
for "_i" from 0 to 1023 step 1 do
{
// [arr, arr, arr, arr, ..., arr]
refArray pushBack arr;
};
// Transfer
publicVariable "refArr";
// ???
// How much data will be sent?
// [[0, 1, 2, ..., 1023], [0, 1, 2, ..., 1023], [0, 1, 2, ..., 1023], ...]
// OR
// [[0, 1, 2, ..., 1023], ref_to_0, ref_to_0, ref_to_0, ...]
// where `ref_to_0` is just reference to element 0
// ???
Doesn't seem so, looks like serialization doesn't support references like this?
I wonder if it also doesn't for save games so references will be lost after loading the game? 🤔
I mean.... hm I was unclear. It's pretty obvious those references aren't transfered over the net but how the game serialize the two (or more) references pointing on the same array? Does the game just straight forward transfer the arrays or it sends kind of (meta-) references and recreates the array from the scratch making separate unlinked arrays?
It probably makes a copy of referenced contents during serialization
well if so, it's very unoptimized, waste of traffic (and CPU cycles)
Well, you gotta keep this in mind when designing data structures that will be sent over network
Use hashmap keys instead of references if you don't want data copied
I still wonder if same limitation applies to save games and other serialization like profile namespaces
storing into profileNamespace also unlinks arrays
they are just two separate copies of the same array.
yeah its probably same/similar serialization everywhere
singleplayer save game also affected by this behaviour, just tested.
5 hours in trying to move backpack from a dead body to alive unit with as less frames as possible
Arma fun
R&D success, to instantly take backpack from another unit at any moment in the game you need:
- Frame 1: Make unit\body drop the backpack with
addBackpackcommand - Frame 2: Move player into some vehicle
- Frame 3:
player action ["TakeBag", _backpackObject], move out player and teleport back
I think you can combine Frame 1 and 2 actually
Doing actions inside vehicle and moveOut is a substitute for 2.18's actionNow
Doesn't work with PaperCar, needs proper vehicle, works with C_Quadbike_01_F
Probably has to do with animations or something
Now I can revive players by respawing them, giving them their exact previous backpack entity so it retains their weed-colored drone 😎
anyone has a good animation/a reliable way to get you from unconscious on the ground to kneeling position (not standing up)
you probably have tried _man setUnconscious false; already
this makes him turn over on the ground
yea i thought it did something 😄
Try _unit playActionNow "Crouch"? after setUnconscious false
anyone how might I go about disabling the menu overlay via script manually when opening the arsenal (Normally would just hit backspace, but I am displaying text and want to force it off)? Want to delay it from appearing until BIS_fnc_blackIn is called.
_NUP_playerFace = face player;
_NUP_playerVoice = speaker player;
_NUP_playerInsignia = [player] call BIS_fnc_getUnitInsignia;
// Create an Arsenal unit at the location of NUP_arsenalHelper
_NUP_arsenalUnit = createAgent [typeOf player, (getPosATL NUP_arsenalHelper), [], 0, "CAN_COLLIDE"];
[_NUP_arsenalUnit,true] remoteExecCall ["hideObject",[-2,-clientOwner],_NUP_arsenalUnit];
_NUP_arsenalUnit disableAI "ANIM";
_NUP_arsenalUnit disableAI "MOVE";
// Store the Arsenal unit reference in player's variable
player setVariable ["NUP_arsenalUnit", _NUP_arsenalUnit];
// Set Arsenal unit's loadout, face, voice, and insignia
_NUP_arsenalUnit setUnitLoadout (player getVariable ["Saved_Loadout",[]]);
_NUP_arsenalUnit setFace _NUP_playerFace;
_NUP_arsenalUnit setSpeaker _NUP_playerVoice;
[_NUP_arsenalUnit, _NUP_playerInsignia] call BIS_fnc_setUnitInsignia;
_NUP_arsenalUnit setDir 90;
["Open", [true, NUP_arsenalHelper, _NUP_arsenalUnit]] spawn BIS_fnc_arsenal;
playMusic "EventTrack02b_F_Tacops";
// Open the custom arsenal presentation
["NUP_blackout", false] call BIS_fnc_blackOut;
sleep 1;
[
["MISSION:","<t valign='center' shadow='1' size='1.5'>%1</t><br/>"],
["SUBTEXT","<t align='center' shadow='1' size='1.5'>%1</t><br/>"]
] spawn Bis_printText;
sleep 3;
["NUP_blackout", TRUE, 5] call BIS_fnc_blackIn;```
Is there any way to manually (via Scripts) reduce the accuracy of AI tank shots???
via Skype?!?!?
I'm hoping they meant "via SQF" and got autocorrected
hahahaha sorry ;p
You could use a Fired EH or ProjectileCreated mission EH to slightly adjust the projectile velocity, which would affect accuracy. You could also try turning down the AI accuracy skill for tank crews specifically.
thank you, I will look for these options 🙂
Could you give me a small example of such an EH for a tank??/ please??. I'm just starting to write scripts myself and I'm still a novice
tank addEventHandler ["Fired",{
hint str _this;
}];```This may give you an idea
I wrote clearly that I'm just starting and I don't know how to build full scripts yet. and I see that you only refer to links, and that is not very helpful . sorry
...Link? What link?
not for me, in other replies to requests. OK, never mind.
Here's a link: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Fired
// Add an event handler to the tank that fires when the tank fires
tank addEventHandler ["Fired",{
// retrieve the information about the event
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
// Get the existing velocity of the projectile, relative to the projectile
private _oldVelocity = velocityModelSpace _projectile;
// Add a small randomised adjustment to the velocity vector (numbers may need tweaking)
private _newVelocity = _oldVelocity vectorAdd [random [-1, 0, 1], random [-1, 0, 1], random [-1, 0, 1]];
// Apply the new velocity to the projectile
_projectile setVelocityModelSpace _newVelocity;
}];```
That's one of the ways to do it. For changing the skill of tank crews, see <https://community.bistudio.com/wiki/setSkill>. The ProjectileCreated mission EH would be similar to the Fired EH method, but you'd have to add a filter to detect whether it was the right kind of projectile to act on, whereas the Fired EH definitely only applies to projectiles fired by the tank you added it to.
oh, that's exactly what I was talking about. this is helpful. Thank you very much 🙂
Hi!
Can someone explain to me why my code don't work as intended?
I'm working on a practice scenario for my unit.
So, I'v created one FSM for a conversation function where I also want it to show different "slides" when player interacts with different sentences. But my issue here is that when I schoose a sentence the "slide" is one static picture, and it don't change when I change sentence.
This is parts of my code.
. . . please use pastebin or something
hintSilent parseText _hintText;```
any possible fix for this? it shows the "\\" and "n" marks on hint hud how can i remove them
<br>?
formatText also 🙂
Is there a way to rename the display name of an item? I would like to rename a mobile phone item to "Bomb Tracker" to make it more clear for my players. Is it even possible?
- Addon
- Hacky stuff with changing strings on UI
Kinda what I thought, I think I'm better off adding piece of intel lying around that indicate that a phone is used for that. Just for 1 mission it's not worth it I guess. THanks
you could draw text above the object if you want to make it obvious to the players its the mission object
or create task
As a graphic designer I actually like the idea of making some leaflets and explaining how they made the bomb. But I'll keep that in mind, thanks.
You work at BI but have no role in Discord?
how do i put it together? i tried replacing the "t" with br but nothing changes
Literally <br> instead of \n
Unlike HTML, Arma's Structured Text requires /
i did that but now thirst hunger are gone lol
What is your code now then?
_hintText = format ["<t size='1.0'>Health: %1<br>Thirst: %2<br>Hunger: %3</t>", _formattedHealth, thirst, hunger];
You need /
https://community.bistudio.com/wiki/Structured_Text#Line_break
Do we? ...Maybe I misrecalled
Yeah it treats <br> as unclosed tag and it eats everything inside it
hintSilent parseText "111<br>222</br>333"; => 111\n333
So you need <br/>
oh i see
there it is, it worked : D cheers, couldnt have done it without this beautiful community
_hintText = format ["<t size='1.0'>Health: %1<br/>Thirst: %2<br/>Hunger: %3</t>", _formattedHealth, thirst, hunger];
this is how it looks now
the beauty of arma is the hacks i guess 
meanwhile i'm on day 185 of trying to make pylons make sense
maybe comparing old/new ammo values on each pylon would do the trick, but no... I remembered that pylons can change at any moment so there goes my idea
wait, what was your idea again? (for the record, I already regret asking 😄)
You could delete your post if you regret
no
I recall it was related with resupplying a pylon, after (few secs?) it fires
make pylon ammo regenerate after its magazine empties
so after a few seconds it's full ammo again
Once its depleted?
Otherwise you can just walk through all pylons X seconds after last shot and set full ammo to each
Thing is Fired EH doesn't return which pylon was used. But if the question is about resupply the pylon after it is empty, the script could be more easier
here's the source code so far
I sure hope bohemia adds that sometime 🥴
*Dedmen
I sure home Dedmen adds that sometime 🥴
😄
Probably just iterate ammoOnPylon on all pylons, and if it returns 0, resupply the pylon
So your idea is to set magazine ammo to full ammo when it was fully depleted after some delay?
yes pretty much
_gunner ammo _muzzle == 0 is also unreliable in this case
i've tried magazineTurretAmmo too
ammoOnPylon?
the pylon is not known at this moment, and there's the chance i'm firing a non-pylon weapon
you can store the current pylons and their ammo and compare
Well, I mean, if it should be instantly refill once it reaches 0, which means that 0 is the only pylon that potentially fired in that moment
Fired event
→ is a pylon empty?
- no = carry on
- yes = (store the pylon index and) reload (later)
You want only pylons or any vehicle mags?
since vehicles can have both pylon weapons and non-pylon weapons those need to be treated accordingly because if you use addMagazineTurret and loadMagazine on a pylon weapon, it'll break. so the type of weapon (pylon or not) must be known
All that for a weed colored drone?
Of course not, its to retain orginal packed vehicle with its all variables, damage and ammo states
If you delete and add backpack again the packed vehicle deletes and creates a new one when unpacked next time
Packed drone also keeps the textures 😎
oh this is why your name sounded so familiar, you the guy who made koth 🥴
This is why I think we should start encouraging making threads, or use discords forum function
does increasing the number in this option make the imprecision greater or less? aiDispersionCoefY =
is there a command to add ammo to a magazine?
or you gotta get and set...
apparently there's no good way to do this
Yeah its a get, delete, and recreate
with that I could create a battlefield-esque ammo regenerator where it gives you X ammo every T seconds
Topic closed, I already solved it 🙂
you don't want to be part of the ("I solved it" - without giving the solution) group innit 👀 😄
and I'm sorry ;p. so I just edited the bullet settings by changing the "dispersion" value = 0.00299; larger and tank shells began to miss more often.
Is there a way to attach a camera to a physics object but prevent the camera from rotating with the object (football) if the object moves?
Set positions each frame
Is there a keypad UI available for vanilla? Sort of "addaction, input code, returns true/false" kind of deal?
I did it like below, it works, although I don't know if that's what you meant
params ["_object"];
_cam = "camera" camcreate [0,0,0];
_cam cameraeffect ["internal", "back"];
showCinemaBorder false;
_cam setPosATL (getPosATL _object vectorAdd [0, -4, 0.5]);
while {alive _object} do
{
_cam setPosATL (getPosATL _object vectorAdd [0, -4, 0.5]);
sleep 0.01;
};
okay thank you
Difference is that dispersion changes both AI and player accuracy, while aiDispersionX/Y only change AI accuracy. Also dispersion is read from the fire mode while aiDispersion is read from the weapon, but everyone puts them in both for some reason.
oh, I understand it better now, thank you 🙂
in the dispersion value itself it is written, e.g. 0.00xxx and in dispersion x\x as 1 etc., what is the difference? is this a multiplier?
Doesn't matter how it's written. Some mods use a calculation that gets evaluated to produce a number.
With the module framework, do I need to have it packaged as a pbo to enable in 3DEN, or is it possible to have everything inside the mission folder? Trying to follow along with https://community.bistudio.com/wiki/Modules but having a bit of difficulty with the latter approach, so not sure if it's possible.
ah okay. thank you for your advice. I'll start messing around with this configuration soon 😉
catch UI element on inventory open or inside the loop, find its control and change the name
ideally - make an addon
it says here that it is a multiplier for normal AI. ):
The dispersion measured in the radians. One circle is 2pi radians or 360 degree. 00029088 rad is 1 Minute of Angle. MOA unit is commonly used in the military than rads (unless it's very long range sniping) because it allows quickly convert the visible angle of the target to the distance without using the calculator.
Just for the reference.
1 rad is an angle where arc is equal to its radius.
https://i.imgur.com/tcjFfDN.png
I'm using these macro to convert the units. You can use it in your config.cpp
// Angular unit conversion
#define MRAD_TO_MOA(d) ((d) * 3.43774677) // Conversion factor: 54 / (5 * PI)
#define MOA_TO_MRAD(d) ((d) * 0.29088821) // Conversion factor: (5 * PI) / 54
#define DEG_TO_MOA(d) ((d) * 60) // Conversion factor: 60
#define MOA_TO_DEG(d) ((d) / 60) // Conversion factor: 1 / 60
#define DEG_TO_MRAD(d) ((d) * 17.45329252) // Conversion factor: (50 * PI) / 9
#define MRAD_TO_DEG(d) ((d) / 17.45329252) // Conversion factor: 9 / (50 * PI)
#define MOA_TO_RAD(d) ((d) * 0.00029088) // Conversion factor: PI / 10800
yes it's multi, also keep in mind the dispersion is set for the each muzzle individually. Your vehicle can have shitty 7.62 MG with 3 MOA and "masta-blasta" Railgun with 0.01 MOA but only for the player controlled gun.
I just checked in game. thank you gentlemen for your help. I already know how to go about it... best regards!!
private _isPylonWeapon = "Pylon" in str(getArray (configFile >> "CfgWeapons" >> _muzzle >> "magazines"));
how hacky is this?
this looks ugly but is possibly fast
you might have inspiration from this (its not optimized tho):
`// NER_units_unitIsOutOfAmmo
params["_unit", ["_checkAllMags",true] ];
private _currentWeapon = currentWeapon (vehicle _unit);
private _currentMuzzle = currentMuzzle (vehicle _unit);
private _countMags = {
params ["_unit", "_weapon", "_muzzle"];
private _mags = magazinesAmmoFull (vehicle _unit);
private _compatMags = [_weapon,_checkAllMags] call CBA_fnc_compatibleMagazines;
private _count = 0;
{
_x params ["_magName", "_ammoCount", "_ammoType"];
if(_ammoCount > 0 && _compatMags findIf {_x == _magName;} != -1) then {
_count = _count + 1;
};
} forEach _mags;
_count
};
private _magCount = [_unit, _currentWeapon, _currentMuzzle] call _countMags;
_magCount > 0;`
I've decided on storing the muzzle class on a variable, if the muzzle is in that array, then it's a normal weapon instead of a pylon weapon
thank you very much dude 🙂
hello,
I have created a task to kill a commander but the player won't know what they look like unless they pick up an intel document. Is there a way to update the current "Kill commander" task with new lines after the intel has been picked up rather than create another task?
Use https://community.bistudio.com/wiki/BIS_fnc_taskDescription to get the current description, add your new line to it and update it with https://community.bistudio.com/wiki/BIS_fnc_taskSetDescription
also, how to place an intel object in the inventory of a vehicle so it can retrived by the player causing the task to be updated?
this may seem like a bit of a random question but I was wondering if AI pathfinding implements the Dijkstra’s Algorithm.
I'd be very surprised if it didn't.
But we don't know. Arma AI is a black box full of shit spaghetti.
@granite sky Good one - and thanks for the reply
is there any way to fix existing buildings/AI pathing dynamically. these buildings are still not usable by AI
"Land_Cargo_Tower_V3_F" "Land_Cargo_Patrol_V3_F" "Land_Cargo_HQ_V3_F"
FOR example CBA defend is used in these pictures, AI "can" path to these positions but 90% of the time dont do it. is there anyway to make the positions easier to reach?
is it possible to change position of titleText or cutText on screen?
probably not but you can create your own layer using cutRsc
is this correct if I want to append a value to an existing variable?
_nameSpace setVariable ["varName", ((_nameSpace getVariable "varName") + [_x]), true];
if (_nameSpace getVariable "varName") is array then yes
yeah it's an array
forgot to mention that
You can also use pushback or pushbackUnique
From what I could tell, the navgrids on these buildings are correct but the algorithm is bugged.
It tends to re-calculate the path when it enters different sections, and on those recalculations it breaks the Z-value.
I gave up trying to isolate the bug though. There are just too many of them.
the only good thing arma 3 ai is good at is headshotting me with a 50 cal while i'm flying at 800km/h in a plane
They are genuinely quite good at leading targets :P
the dispersion coeff for a lot of guns while being used by AI is insanely accurate, vanilla config barely gives them "recoil" to put it in a way too
The whole accuracy system seems to be based on random dispersion rather than systematic error too. In practice when people fire an HMG they're typically drawing a line of bullets, while Arma is just random spray around a point.
Can someone please help me with a problem, I want to execute a code after a random sleep duration but the random duration is not the same random duration for everyone I guess I need a seeded random but I don't know how that would work.
when manual firing, is there a way to know which turret path is being manual fired?
Any good reason not to do the random sleep on the server and then remoteExecCall?
So execute the whole Script from the server?
// server
private _random = random 5;
[_random] remoteExec ["my_fnc_name"];
// .... in that function ....
params ["_random"];
hint "thing 1";
sleep _random;
systemChat "thing 2";```
Alternatively:
```sqf
[] remoteExec ["my_fnc_part1"];
sleep random 5;
[] remoteExec ["my_fnc_part2"];```
yes, do the sleep in server and remote to clients
the first one should be the way to go, less bandwidth usage = better
It depends. You might have other parameters to pass that need to be determined after the sleep in order to be up-to-date. And if it's a long sleep, you might want to have the second part run on any clients that JIP'd during the gap.
doesnt remoteexec has a flag for JIP?
Yes, but that would start the whole sequence at the beginning for JIP clients, which might not be what you need
If this is a high-frequency event then yes reduce broadcasts as much as possible, but one extra function RE won't kill anyone. It's fine to do that if you need the flexibility. Function broadcasts are very cheap as long as you're not sending big arguments with them.
when was it introduced? i dont think that bug always was that bad
I wouldn't know. I haven't been working with Arma for that long.
I didn't even consider that it's an introduced bug, but I guess it's plausible that they added the path recalculations to fix something else.
Also the behaviour's so bad now that it's hard to see how it would have passed initial testing.
agreed
i just spent 30 mins trying to get AI into malden bunkers pre placed
you need to set a certain elevation or they dont even recognize the positions
also(whats more anoying) buildings hidden on the map still generate their positions in session
so AI move into "garrison" nothing
the more you try make Arma3 dynamic the more you realise it needs to be heavily scripted and picture perfect to obtain what you envisioned
Yeah easy.
Realize that its not a forEach but rather a findif.
You are checking if a thing is found in the array. So use findIf.
_canAttach = FABHH_mmv_AllowedVehicleClasses findIf {_x in _category} != -1;
huh nice find.
Indeed "ReplaceNilsInArrayWithLinkedItems" is ran on the array.
We even have documentation for that 😄
yes they will.
Only entities are stored as references
i'm using this, thanks. one less foreach
This also gets you SImpleVM so it'll be nice and fast. I think it would reject the exitWith
Everyone missed my findAny reply? :P
I chose to ignore it
thank god arrays can sometimes have 1000000 instead of 999999 elements
any ideas why this script http://pastebin.com/3ZdxZA5F (for creating a camera and following a target for 5 seconds) is fine the first time you call it, but subsequent times the camera is all jittery?
Is it possible to script in the CAS missions from the fire support modules in zeus. The function on the wiki sorta lacks all the info needed
does _follow ever get set to false?
If the wiki lacks, go to the function viewer and search for it. Every module has its own function internally.
Part of the problem is idk what the classname for the zeus modules is so idk what search for in the function/config viewer
scopeCurator > 1 tells you you can access it in zeus
that was it, thanks very much!
Is there a difference between one Draw3D EH and severals EHs?
When we split different logic by several EHs and when we put all logic in one EH.
What approach is better?
Context?
can someone help me understand how to define units in this code?```sqf
_group = _this select 0;
{
_x addEventHandler ["FiredMan", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
_all = [];
_side = side _unit;
_groups = allGroups select{
side _x isEqualTo _side
&& alive leader _x
};
_groups apply {_all append units _x};
// copyToClipboard str _all;
{
If(!isPlayer _x)then{
If(isNull _x)exitWith{};
if(isNil {_x getVariable "Var_GF_doMove"})then{_x setVariable ["Var_GF_doMove",false];};
if(_x getVariable ["Var_GF_doMove",true])exitWith{};
_x setVariable ["Var_GF_doMove",true];
_x allowFleeing 0;
_x stop false;
_x doMove (position _unit);
};
}foreach _all;
systemchat "fired";
}];
}forEach units group _group;
i believe here is where i enter variable name sof units who i want this script to apply to: _groups apply {_all append units _x};
// copyToClipboard str _all;
iv tried alot of variations with trings but im not getting any errors,it just isnt working
calling this on the init of a group leader
_group = _this select 0 is the same as params ["_group"] if that helps you.
you need to just do [_group] call thisFunction
actually
there is an error on this anyways
last line, remove the group command
so }forEach units group _group; to }forEach units group; ?
forEach units _group;
now if you are just copy pasta this into your code, you don't even need the first line. just have the _group ready
how do i define what units are affected by this though?
are you copy pasta'ing this into your file?
the code above is supposed to ,when called via a units init, call defined other groups to move to their position. so a group is calling the script through its init with 0=[this] execVM "GF_Support.sqf";
and any units defined in the script(which im unsure how to define) should move to the position
well the way he wrote it is meh with naming his variables. he mentions _group but what he actually wants is the _leader. If you do this as is, in the leader's init, it would be
if (isServer) then {
this execVM "GF_Support.sqf"
};
the file should be fixed though to accommodate both the leader and the group:
params [["_group", grpNull, [grpNull, objNull]]];
if (_group isEqualType objNull) then {_group = group _group};
and the last line would be:
forEach units _group;
ok im half understanding
say i wanted just one unit, "vehicle1" to be the support unit,how to i write this in the syntax?
or do you have a better alternative to get a unit to move to another units position on a combat event handler?
essentially i wana ditch the Guard wp in favour of making something that has an array of vehicles,move to support a few different groups of infantry
the code above looks like it makes every unit on the unit's side move to that location, is that what you want
no i just want a few defined vehicles to act as support
vic1 vic2 vic3 etc
i thought this part of the syntax allowed me to do that :groups apply {_all append units _x};
// copyToClipboard str _all;
_groups = allGroups select{
side _x isEqualTo _side
&& alive leader _x
};
_groups apply {_all append units _x};
this is taking all groups in the game, filtering for friendly side, an alive leader, then taking all of those and sticking them in _all, which is then iterated over later. So basically all friendly units are responding
aka, time to write your own that is more inline with what you want
i thought all apend was allowing some sort of array
that i had to define
ok man cheers
_all is created in that event handler. hes initializing the variable with an empty []. You can't touch that. Its local in that event handler as it is in a different scope
got it
quick question. is it posible to create an array of potential positions(ie groups as target positions) with such: addWaypoint [position group1, 0];
editing to something like addWaypoint [position group1,group2.group3, 0];
private _positions = [];
for "_i" from 0 to 100 do {
private _group = missionNamespace getVariable [format["group%1", _i], grpNull]; //group1,group2,group3,etc
if (isNull _group) then {continue};
_positions insert [-1, [
[getPosATL leader _group, 0]
]];
};
// example output
[
[[3834.82,6287.92,0.00143909],0],
[[3790.36,6273.17,0.00143909],0],
[[3838.84,6210.04,0.00143909],0],
[[3912.23,6206.82,0.00143909],0],
[[3910.28,6269.1,0.00143909],0],
[[3891.55,6323.78,0.00143909],0],
[[3821.9,6348.96,0.00143909],0],
[[3766.74,6338.15,0.00143909],0],
[[3738.48,6249.23,0.00143909],0],
[[3759.27,6189.55,0.00143909],0]
]
Yeah, except it still recreates the backpack which is bad for assemble-able backpacks. Guess this is worth reporting.
Kinda expected nil to mean "do not touch the backpack"
Ticket with repro script and I'll fix it next week
debug console script should be sufficient
if(backpack player == "") then {player addBackpack "Bag_Base"};
oldBP = backpackContainer player;
systemChat str ["oldBP", oldBP];
l = getUnitLoadout player;
l set [5, nil];
player setUnitLoadout l;
newBP = backpackContainer player;
systemChat str ["newBP", newBP];
systemChat str ["newBP == oldBP", newBP == oldBP];
thanks man i just finished work il have a look
I have a problem, I want the bomb to detonate in the air in a helicopter. but then the bomb spawns and flies to the ground. How to make it explode right after spawning in the air? bomb="Bo_GBU12_lgb" createVehicle (getPos heli1)
triggerAmmo
thx, working 🙂
Hypoxic, iv tried to make my own version through experimenting with the EH, iv got this so far:
this addEventHandler ["CombatModeChanged", {
params ["_group", "_newMode"];
if (_newMode == "COMBAT") then
{
_wp = vic1 addWaypoint [position yy5, 50]; _wp setwaypointtype "SAD"; _wp = vic2 addWaypoint [position yy5, 50]; _wp setwaypointtype "SAD"; };
}]; yy5 attachTo [this, [0,0,0]];
yy5 is a trigger attached to the group this syntax has in its init
it sort of serves my needs and im gona go with it,as im still learning alot about scripting
any feedback to make it better in a manner of speaking?
this sends vehicle 1 and 2 to support a group when they get into combat. id be applying this on each group with a further 3 vics in the mix. each group in combat is sent support(with SAD WP) and once its done it moves onto the next group that generated a combat state and supports it
I tried using "OR" for randomly choosing a vic,seeing the error pop up i assume thats not the way "OR" works. anyway id love feedback and knowledge. cheers
hi,
would like the script that checks if any civilians in the map have been killed and if so will display a hint
mission ends if a certain number of civilians are killed
Use a entitykilled mission event handler.
SelectRandom?
can you give an example please
I am on my phone..so..no😄
It's...not a terribly complicated command. https://community.bistudio.com/wiki/selectRandom
private _selectedVic = selectRandom [vic1, vic2, vic3];```
You could also subtract the selected vic from the array using `-` to ensure the same vic doesn't get selected twice.
thanks im looking now
3Den has this built in
under one of the menu's
yeah i've come across that option, just need in addition to that a hint to display everytime a civilan dies
e.g.
// somewhere during initialisation
ra_var_supportVics = [vic1, vic2, vic3];
// .... EH
if (_newMode != "COMBAT") exitWith {};
if (count ra_var_supportVics < 1) exitWith { systemChat "No support available."};
private _selectedVic = selectRandom ra_var_supportVics;
ra_var_supportVics = ra_var_supportVics - [_selectedVic];
_selectedVic addWaypoint [leader _group, 50];```
I'm very dubious about your trigger attachment. `CombatModeChanged` is a Group EH and must be added to a Group; you can't attach things to a Group because it's not a real object. So either you're adding CombatModeChanged to a Unit (wrong) or trying to attach a trigger to a Group (also wrong). That needs adjusting and I'd question whether you actually need the trigger at all.
i tried the following but gave me an error:
civDead = 0 ;
addMissionEventHandler ["EntityKilled",
{
params ["_killed", "_killer", "_instigator"];
if (isNull _instigator) then {_instigator = UAVControl vehicle _killer select 0}; if (isNull _instigator) then {_instigator = _killer};
if ((isPlayer _instigator) and (side group _killed == civilian )) then {civDead = civDead + 1; hint "A civilian died. WATCH YOUR FIRE!"
}];
thanks this is why im running by those more knowledgable. So to clarify,iv added this to the group init:
yy attachTo [this, [0,0,0]]; this addEventHandler ["CombatModeChanged", {
params ["_group", "_newMode"];
if (_newMode == "COMBAT") then
{
_wp = vic1 addWaypoint [position yy, 400]; _wp setwaypointtype "SAD"; _wp = vic2 addWaypoint [position yy, 400]; _wp setwaypointtype "SAD"; _wp = vic3 addWaypoint [position yy, 400]; _wp setwaypointtype "SAD"; _wp = vic4 addWaypoint [position yy, 400]; _wp setwaypointtype "SAD"; _wp = vic5 addWaypoint [position yy, 400]; _wp setwaypointtype "SAD"; };
}];
and i have a trigger(though i could use a invisible helipad or whatever)
attached to the group
the trigger is just reference point for the wp
yy is the trigger name in the above
400 random pos
You can't use attachTo to attach things to Groups because Groups do not physically exist. They don't have positions.
And you don't need a trigger as the reference point for the waypoint; just use the group leader's position as in my example.
but it is attached
Are you absolutely certain this is in the group's init and not the group leader's init?
tf
i even killed leader, and moved the group to a new location, tested and wp's were correctly given to new pos
Tested. Objects attached via the group init field this are actually just attached to the group leader.
ah
It's kind of wild that that actually works at all
you learned sth new? id be quite shocked but this is Arma afterall
It's completely undocumented and I never tried it since groups aren't real objects
no hold up
you are correct. i did move the group but leader dead body was also moved
seems it is attached to leader
so bare with me because i am trying to understand this. this goes into a group init?
The var definition goes somewhere...uh probably initServer.sqf and then publicVariable it, if this is MP, otherwise init.sqf for SP.
The rest of it goes inside your CombatModeChanged EH, whereever that is.
I'm not sure about the locality of group EHs. If they only fire where the group is local, then all fine, otherwise you also need a if !(local _group) exitWith {}; at the start of the EH to prevent conflicting responses from different machines.
its sp
Is it staying SP or are you just testing in SP for now?
MP is a long way away for now so just sp
baby steps
so this in the init.sqf detects when a combat EH has fired essentially?
calls the defined vics
No
The variable definition ra_var_supportVics = .. goes in init.sqf because that only needs to happen once, at the start
yes i did that
All the rest of the code goes in the CombatModeChanged EH. Literally take it, and put it into the EH code. Inside the EH. It replaces the code previously in the CombatModeChanged EH.
It's not fully complete, you need to add setting the wp type to SAD, but I think you can figure that part out
this addEventHandler ["CombatModeChanged", {
params ["_group", "_newMode"];
if (_newMode != "COMBAT") exitWith {};
if (count ra_var_supportVics < 1) exitWith { systemChat "No support available."};
private _selectedVic = selectRandom ra_var_supportVics;
ra_var_supportVics = ra_var_supportVics - [_selectedVic];
_selectedVic addWaypoint [leader _group, 50];
}];
looking ok so far
out of 5 vics,one got the wp to move to support
How many vics do you want to assign to each group?
(I suggest a number that divides cleanly into the number of available vics...)
for "_i" from 1 to 3 do {
if (count ra_var_supportVics < 1) exitWith { systemChat "No support available."};
private _selectedVic = selectRandom ra_var_supportVics;
ra_var_supportVics = ra_var_supportVics - [_selectedVic];
_selectedVic addWaypoint [leader _group, 50];
};```
from 1 to 3 is giving a random number between that count to assign?
5 vics and 6 groups of infantry
No, it means run this iteration 3 times. It's like a procedurally generated forEach - same effect as { } forEach [1, 2, 3]
got it got it. i think at this low number its perfect
il further experiment with this and adding more to the syntax,still quite confusing but understanding this much today and how it works was big step. thanks alot
can titles created using rscTitles be obtained by using findDisplay?
I've been trying a couple things, but it seems that Im only able to get controls from within a title if I have an uiVariable with the display object instead of being able to find it by numeric reference.
you mean like onLoad = "uiNamespace setVariable ['CnQOverlay', _this select 0];"; in the overlay class?
storing the display like that is what i use, not sure if there is any other way
iv found one issue(apolagies i should have explained in depth what i was looking to achieve). i understand it now that the vics are being technically assigned,once to a firendly group position,but after that they never get a new position when another combat EH happens. the mission is dynamic and lasting two hours,im hoping to have these vics continuously look for the EH firing and generate new wp's. is it possible to tweak that?
so IE one vic would be able to support any number of groups over a long duration of time. like a Guard wp essentially
when you determine the vehicle is available again (condition up to you, but it should give enough time for the vehicle to have responded to its first mission), you can do ra_var_supportVics pushbackUnique _vehicle to add it back to the array of available vehicles
so pushback re adds items/units etc to an array selection?
is this " ra_var_supportVics pushbackUnique _vehicle" simply added to the init on new line or edit original line?
ra_var_supportVics = [vic1, vic2, vic3,vic4,vic5];
pushback and pushbackUnique add anything to the end of an array (pushbackUnique just makes sure it doesn't get added again if it's already in there)
Don't put it in any init field. You need to run that code when the vehicle becomes available after finishing its assignment. Init fields are for stuff that happens on mission start.
How you determine when the vehicle has "finished its assignment" is something you need to decide.
thats tricky. off top of my head and easiest way would be a simple timer(based on how mission is set up)
original support requester group in aware is another idea but less reliable
and not sure if possible to identify.
id go with a simple timer
so simply running " ra_var_supportVics pushbackUnique _vehicle" on a trigger activation is doable?
Try adding this after the part that adds the waypoint:
[_selectedVic, waypointPosition _waypoint] spawn {
params ["_vic","_pos"];
waitUntil {sleep 5; (_vic distance _pos) < 200)};
sleep 90;
ra_var_supportVics pushbackUnique _vic;
};```
yeah, its what i've been doing recently.
I was just looking for a confirmation whenever you could use IDD reference with findDisplay for the stuff defined as a resource in rscTitles, but looks like thats not the case.
Yes as long as you have a reference to the vehicle available in the trigger context.
Just to clarify, pushback/Unique is not specifically for re-adding things. We're calling it re-adding because we're working with vehicles that were previously in the array, but it can add anything to the array, there's no requirement that it had been in the array before. You could, for example, use it to make more or replacement vehicles available later in the mission.
fixed missing _
tried adding it to the end of original code,after wp reference
this addEventHandler ["CombatModeChanged", {
params ["_group", "_newMode"];
if (_newMode != "COMBAT") exitWith {};
if (count ra_var_supportVics < 1) exitWith { systemChat "No support available."};
private _selectedVic = selectRandom ra_var_supportVics;
ra_var_supportVics = ra_var_supportVics - [_selectedVic];
_selectedVic addWaypoint [leader _group, 50]; [_selectedVic, waypointPosition _waypoint] spawn {
params ["_vic","_pos"];
waitUntil {sleep 5; (_vic distance _pos) < 200)};
sleep 90;
ra_var_supportVics pushbackUnique _vic;
};
}];
getting error missing ;
Oh, I thought you would've saved a reference to the waypoint for changing its type to SAD. You do need a reference to the waypoint in order to...refer to it later.
Also we need to work on your indentation :U
this addEventHandler ["CombatModeChanged", {
params ["_group", "_newMode"];
if (_newMode != "COMBAT") exitWith {};
if (count ra_var_supportVics < 1) exitWith { systemChat "No support available."};
private _selectedVic = selectRandom ra_var_supportVics;
ra_var_supportVics = ra_var_supportVics - [_selectedVic];
private _waypoint = _selectedVic addWaypoint [leader _group, 50];
_waypoint setWaypointType "SAD";
[_selectedVic, waypointPosition _waypoint] spawn {
params ["_vic","_pos"];
waitUntil {sleep 5; (_vic distance _pos) < 200};
sleep 90;
ra_var_supportVics pushbackUnique _vic;
};
}];```
Oh, there's a ) in the wrong place
fixed
thanks im trying now, i decided no SAD was needed as just proximity should be ok and vics on SAD just have more chance of running over low walls and sticking(rhino on any Altis wall)
Oh, hold on, let me make this more clever
go ahead, what are you thinking?
type group, expected object error with the above syntax on EH happening
is that because some of the named vics are dead/deleted?
No, that wouldn't cause a wrong type like that. The possibility of them dying is what I'm working on handling though.
was the error type group, expected object or type object, expected group?
And are vic1, vic2 etc the vehicle objects, or the crew groups?
error distance : type group, expected array,object,location
vic names are not on vehicle,rather they are in the group init
group variable name
that's annoying
Change them to be the vehicle objects, and try this:
this addEventHandler ["CombatModeChanged", {
params ["_group", "_newMode"];
if (_newMode != "COMBAT") exitWith {};
private _selectedVic = objNull;
while {isNull _selectedVic} do {
if (count ra_var_supportVics < 1) exitWith {};
private _tempSelected = selectRandom ra_var_supportVics;
ra_var_supportVics = ra_var_supportVics - [_tempSelected];
if (alive _tempSelected && {canMove _tempSelected}) then {
_selectedVic = _tempSelected;
};
};
if (isNull _selectedVic) exitWith {systemChat "No support available."};
private _waypoint = group _selectedVic addWaypoint [leader _group, 50];
_waypoint setWaypointType "SAD";
[_selectedVic, waypointPosition _waypoint] spawn {
params ["_vic","_pos"];
waitUntil {sleep 5; ((_vic distance _pos) < 200) or (!alive _vic)};
if !(alive _vic) exitWith {};
sleep 90;
ra_var_supportVics pushbackUnique _vic;
};
}];```
still in middle of testing however... no errors, vics are obtaining new SAD orders fluidly without issue
gud
There are some more checks that could be added during the vicfinding phase, like "has ammo", "has crew", "has fuel" (canMove doesn't check that because ???)
{sleep 5; ((_vic distance _pos) < 200) the sleep is 5 sec's after starting SAD wp? and 200 meters is what?
taken care of in other ways
Alternatively you can set the ammo and fuel during that phase if you don't care too much about #realism
yeah i have EH's for everything else to make life easier
crew cant disembark in water,broken vic or upside down. they are there for life as short as it may be. ammo is resupplied by script.
sleep 5 means the waitUntil checks its condition every 5 seconds rather than "as fast as possible". It's better for performance and we don't need instant response.
The waitUntil is checking whether the vehicle is within 200 metres of the SAD waypoint position.
They could be killed by a penetrating hit without destroying the vehicle
love realism but i also have full time job i just want my AI self sufficent and "believable". with this "support" wp that is one huge step closer
no. crew have EH damage aswell
infact if they blow up they bail,they are then a mission task for helo pilot to rescue
youve helped make my scenario a million times better. the Guard WP ,i found too many flaws and this is perfect! big thanks
Beautiful 
where is the editor category and subcategory defined for weapons? I've looked in CfgWeapons and it's definitely not there
unless there's no definition and weapons are assigned to their respective categories by script

CfgWeapons weapons aren't placeable in the Editor (or creatable in the world at all apart from simple objects using their models)
The things in the Editor aren't true weapons, they're just ground holder objects (invisible containers) that come preloaded with a weapon
How to check if battleye is on?
