#arma3_scripting
1 messages · Page 548 of 1
I love that
@winter rose , oh, sure, there is a left align but it's for a text. Thanks for looking though.
already asked this question a few days ago, but didn't get any response, so will try again ;)
I'm trying to get ACE Interactions (and specifically the explosives module) to work with/through UAV's. With the new UAV's in the Contact DLC, and a mod I'm working on which includes a EOD bot, it would be great to be able to defuse mines and place and arm explosives. However it seems that ACE Interact doesn't work at all since you're technically inside the terminal (not even a vehicle).
Does someone has an idea how to either script or use configs properly to make it possible to use ACE Interact through an UAV?
I would tell you to maybe try the ACE Discord/Skype/ICQ/whatever 😐
As far as I can tell it's a "missing feature", so I already made a feature request on github. However since most hardcore devs are around this Discord I'm hoping someone already has a solution or tried their luck in avail
How do I do something like this in a non-retarded manner?
if (_x isKindOf "CAManBase") then {_icon = taro_HUD_ManIcon;};
if (_x isKindOf "AIR") then {_icon = taro_HUD_AirVehIcon;};
if (_x isKindOf "Ship") then {_icon = taro_HUD_WaterVehIcon;};
if (_x isKindOf "StaticWeapon") then {_icon = taro_HUD_StaticIcon;};
if (_x isKindOf "LandVehicle") then {_icon = taro_HUD_LandVehIcon;};
non-retarded manner? not in SQF 😁
switch (true)``` yeah
private _icon = switch (true) do {
case (_x isKindOf "CAManBase"): {taro_HUD_ManIcon};
case (_x isKindOf "AIR"): {taro_HUD_AirVehIcon};
};
so on
dang, he's fast
also depending on which things you can expect to be in _x most of the time you can optimize by making these things be on the top
as it checks from top to bottom.
not 100% sure that it really stops checking after first find as it's arma but logic says it should.
So I would put CAManBase first, LandVehicle second
Although also be aware that some classes inherit others, so make sure that the parent classes are lower than the children. Otherwise you will get the parent instead of child.
The checks seem work fine, I didn't get anything mislabeled yet. I'll check with the switch version
hmm, it seems that statics are a type of land vehicle, so I might put them above that so they return true first
@hollow thistle The switch stops on first find, just tested it.
👍
what sound do I need to fade to 0 if I want to disable direct coms voices?
does that count as "radio"?
do you want to disable them smoothly (i.e. actually use fade?)
i'm fairly sure if you want it to just instantly stop working you can use enableChannel? no experience personally though.
also, my own question:
I have a script that only works correctly on a dedicated server or a singleplayer game. What's the best way to stop the mission from running otherwise?
@winter rose so I've managed to significantly lower the flickering. Some while do loops without proper sleeps made it flicker, so I've just sleeped them. Still blinks when new units (zombies) are being spawn from the underground, but only for a few seconds which is ok-ish I think.
won't isServer & hasInterface return true for player hosted servers too?
https://community.bistudio.com/wiki/BIS_fnc_getNetMode foudn this, seems to work if anyone else has this problem
@errant patio see Multiplayer Scripting page too
yeah, spent a while there but my specific issue is pretty niche (doing some nasty things with setDate lol)
server only you monster 👀
i wanted an area that was indoors with nice lighting but to not have to force all players to be there at once, so i made them all set their own dates when they're in there... problem is if the host does it then the rest of the players get that value propagated to them lol
that's no good since it darkens the whole scene right? I have lights that I want to look right
don't play locally with dates though, friendly advice for your hair 😁
Can 0 and 1 stand in for false and true in sqf?
hmm, I want to have a bitmask and I'm trying to figure out how can I have a neat CBA setting that uses checkboxes to enable particular parts of the bitmask.
I wanted to do it like this:
_bool1 = 1; //true
_bool2 = 0; //false
bitmask = 1* _bool1 + 4*_bool2;
Quick question, do all event scripts only fire for missions and not mods?
@thorn saffron https://community.bistudio.com/wiki/BIS_fnc_bitflagsCheck ?
@willow basin …sorry, what?
I tried to add init.sqf and initPlayerServer.sqf to my mod. Both are not fired / called. Do they not work for mods?
Same with initPlayerLocal
ah yeah, no (afaik)
Ah okay then, thanks for the quick answer ^^
👍
@willow basin You need to set that as post init function, so it gets fired after the mission starts
init.sqf is engine called so it should always execute, initPlayerLocal/Server.sqf is scripted so can be overridden by mods @willow basin
Hello. Just wondering if there is a way to turn all players on a server into BLUFOR. Example: I join OPFOR but when I enter the game I'm BLUFOR.
Is it possible with a simple debug script that I can execute locally?
. . . . . why?
trying to make a 48/2 server into a full BLUFOR one.
48/2 = 24
what's a 48/2 server?
Oh it's the Zeus 3 side server. Independent, OPFOR and BLUFOR.
just place 48 blufor units?
Doing a pvp mission and they'll all be gathered for a short briefing. Just need to make them all BLUFOR for a few minutes, and then turn them back. I guess I can figure out the latter just need to figure out how to actually turn them all into BLUFOR:
Ai will be involved. Are you sure there isn't a way of just turning OPFOR into BLUFOR?
AI won't shoot if others are captive and believe me, it's faster/simpler/everything-er
you could setFriend maybe
Wont that count as "rouge" or what ever the game sees purple as.
*rogue?
rouge means red 🇨🇳
I'll take a look on the wiki. Appreciate the help so far.
👍
west setFriend [resistance, 1]; and then I just remotexec with JIP activated and it should work.
So incase players leave and come back they dont turn back into OPFOR
oh really? Alright sweet.
don't forget to do the opposite too
Oh yeah thanks for reminding me. Would've forgotten that for sure.
resistance setFriend [west, 1]```
else the resistance will shoot on sight and west will be friendly 😁
Yeah haha
setFriend from wiki:
Sets how friendly side1 is with side2. For a value smaller than 0.6 it results in being enemy, otherwise it's friendly. Intended to be used on mission start. Changing value during mission can cause unexpected errors in AI behavior. See also Side relations.
Typically if you want to change side of unit, you create a new group of needed side, then group the unit into this group
Although hell knows, it might work as well with setFriend 🤷
Yeah, I echo Sparker's suggestions... It is the group you are in that determine your side.
Hi everyone !
I'm trying to make a free cam with limited range around your character, i use BIS_fnc_EGSpectator but i can't get the cam position to calculate distance from the character
cameraOn maybe?
Basically getPos player return the same thing, wether i am in camera mode or not
Mmh cameraOn doesn't seems to work
wether i use the object itself or its position
I just saw camcreate, i'm gonna try
Ok i managed to make it work with camCreate, camEffect and camDestroy
Herre is the code if anyone is interested :
camera = "camcurator" camCreate playerPos;
camera cameraEffect ["internal", "BACK"];
loop = true;
while {loop} do {
cameraPos = getPos camera;
distanceToPlayer = cameraPos distance playerPos;
if (distanceToPlayer > 200) then {
camDestroy camera;
loop = false;
};
sleep 1;
};```
Bizzarely, if you destroy the cam but still try to calculate the distance, the game considers the cam to be at 0,0,0 coords
Yes, because that's what getPos objNull returns
Noted
Is there a point to lazy evaluation with additional OR conditions?
if (isServer || {!hasInterface}) then {
Isn't it checking each condition separated by || left to right until a true condition is found?
I might be wrong but i believe Arma checks all Or even though one is already matched
Should take you two seconds to test if you have the game running
For cases like that I'm not sure if lazy eval has any point though of memory. Generally it's just used for bit more complicated function calls
I do know that for And it'll still check the second statement even if the first is false
From the wiki
["true || { false || {false}}", nil, 100000] call BIS_fnc_codePerformance; // 0.00080 ms
["true || {false} || {false} ", nil, 100000] call BIS_fnc_codePerformance; // 0.00105 ms
["false || false || false ", nil, 100000] call BIS_fnc_codePerformance; // 0.00123 ms
["true || false || false ", nil, 100000] call BIS_fnc_codePerformance; // 0.00128 ms
["false || {false} || {false} ", nil, 100000] call BIS_fnc_codePerformance; // 0.00200 ms
Hello, trying to make a simple script to make AI OPFOR aircraft find the nearest player, and issue a DESTROY waypoint on them.
this findNearestEnemy || addWaypoint "DESTROY";
Something like this, but I don't know how to translate that into something tangible. Any help much appreciated!!
Hello everyone, I'm having issues with a coding error adding a supply box for a custom faction. Removing the Class Box_NATO_ gives an error stating that the Class needs to be defined while, leaving the code gives an error stating that the member is already defined. Is there something I'm missing?
class Box_NATO_Ammo_F; // CUP_USBasicAmmunitionBox
class Box_NATO_Wps_F; // CUP_USBasicWeaponsBox
class Box_NATO_Support_F; // CUP_USSpecialWeaponsBox
class Box_NATO_WpsLaunch_F; // CUP_USLaunchersBox
class Box_NATO_Uniforms_F; // CUP_USBasicWeaponsBox
class B_SupplyCrate_F; // CUP_USVehicleBox
class TA_O_WDL_AmmoBox : Box_NATO_Ammo_F {
author = "Mik92";
displayName = Custom Faction Ammo Box;
class TransportMagazines {
mag_xx(Chemlight_blue,50);
mag_xx(MiniGrenade,50);
mag_xx(rhs_mag_an_m14_th3,50);
mag_xx(rhs_mag_m7a3_cs,50);
mag_xx(rhs_mag_an_m8hc,50);
mag_xx(rhs_mag_m18_green,50);
mag_xx(rhs_mag_30Rnd_556x45_M855A1_PMAG,50);
mag_xx(rhs_mag_20Rnd_556x45_M855A1_Stanag,50);
mag_xx(RPG32_F,50);
mag_xx(rhs_mag_M441_HE,50);
mag_xx(rhs_mag_m713_Red,50);
mag_xx(UGL_FlareCIR_F,50);
//more mag_xx
};
class TransportWeapons {
};
class TransportItems {
};
);
Have you defined mag_xx
I have defined mag_xx in the config.cpp```c
#define mag_xx(a,b) class xx##a {magazine = ##a; count = b;}
#define weap_xx(a,b) class xx##a {weapon = a; count = b;}
#define item_xx(a,b) class xx##a {name = a; count = b;}
excuse me ,Who has some tutorials about The-Programmer mobile phones? tks!
better chances on a Life Discord @runic quest
@winter rose tks!
I had a crashdump and now a .mdmp file available. How to investigate this file?
it's a memory dump (mdmp), I think only BI can but I might be wrong
only BI can
Is there a way to play a voice line sound so the radio effects are applied? The radio protocol sounds do not have any radio effects baked in, so game has to add them on its own. Is there a way to use that in scripted voice lines?
@thorn saffron well yeah, groupRadio, globalRadio etc
I remember that in Contact when you got a message with some plot stuff it came through radio, but when I got close to the person saying it the radio effect was gone and it smoothly transitioned to direct speech
I don't remember.
I have two arrays, both contain the same data, but in other order. How i can compare them? I tried sorting, but and then compare but with no success.
The only solution that comes to me, is to subtract them from each other, and then compare the differences in both cases.
arrayIntersect
Compare how? What is the goal?
I want to force AI helicopter to wait for all players, before take off.
In addition, there is more than one vehicle.
So how do you want to compare arrays, give an example of content and expected comparison result
Ok, fixed, thanks for help.
_players = playableUnits select {alive _x && side _x == west};
(_cargoCrew arrayIntersect _players) isEqualTo _players```
The _cargoCrew includes all players, but with no order.
That won’t work
Or rather in the order they got in.
Both arrays should have same order and in your case it is not guaranteed
Seems like you want to know if all players are inside a vehicle
Vehicles*
playableUnits always has same order.
[a,B Alpha 1-1:2,B Alpha 1-1:3,B Alpha 1-1:4,B Alpha 1-1:5,B Alpha 1-1:6,B Alpha 1-1:7,B Alpha 1-1:8,B Alpha 1-1:9,B Alpha 1-1:10,B Alpha 1-1:11,B Alpha 1-1:12]```
Just iterate through all players and check if inside a vehicle and if any one is not, abort
(_players count {_x in vehicleA or _x in vehicleB}) == count _players
if (isNull objectParent _x) exitWith {...fail...}
hello i search how to create a script to attach a trailer to a car
how realistic you want it to be?
if its possible most realistic
its not a probleme if its not most realistic if i can attach trailer and trailler can move and turn its good
none of them turn very good.
UPDATE - 22.10.2015 (or: 10/22/15) Okay, finaly i found some time, to make a Standalone Version of that wobblewobblething (aka Truck and Trailer): 1st of all: Keep in mind, that the Truck and Trailer are just a Test-Objects! There are Textures missing, Wheels are not 100% p...
this is perhaps the most advanced one
but it still has quite big flaws due to the game engine just not having enough features for this
you are not the first one to want make trailers
it is howver proven to be extremely difficult to make look good
that could be made with geometry pin and hole mechanic
its much older method
but does not work with AI
the trailer have physic
perhaps you need to ask those guys how they made it
they don' t want to do that ^^
all those scripted trailers look silly in MP
Unfortunate side effect of life mods, they take but dont share. Then you proably just have to learn how the engine works and figure out a new solution
yes
I think it's an axis that works behind the wheel and that the whole trailer is part of the axis can like the sterring
@errant jasper
(_players count {_x in vehicleA or _x in vehicleB}) == count _players
findIf would be much more efficient there
Im not sure if this is the right place but i need a bit of help.
Hello all....was wondering if i would get a bit of help. Im getting some Member already defined error pop ups on loadin....
These are the two that have the same (ExileClient_gui_selectSpawnLocation_show =)
ExileClient_gui_selectSpawnLocation_show = "xs\spawn\Overwrites\ExileClient_gui_selectSpawnLocation_show.sqf";
ExileClient_gui_selectSpawnLocation_show = "Custom\baserespawn.sqf";
my question is how do i remedy this? Do i combine these two into one something like this....
(ExileClient_gui_selectSpawnLocation_show = "xs\spawn\Overwrites\ExileClient_gui_selectSpawnLocation_show.sqf";, "Custom\baserespawn.sqf";)
https://i.imgur.com/xWUx8CA.png
https://gist.github.com/XCSVs/a25ef5f90eeba4ddd83de17dc4daa496
if _cargoCrew holds units of "In addition, there is more than one vehicle.", then this will do:
private _areInside = playableUnits findIf {!(_x in _cargoCrew) && {side _x isEqualTo west}} == -1
@pseudo kernel
@zinc pulsar you might get better answers in Exile discord
Yeah i already asked in there and not getting an answer....guess everyone is sleep. lol.
So, I'm trying to use allowCuratorLogicIgnoreAreas to stop Zeus placing modules (the intended use of the command). According to the wiki, the command can only be executed on the server, so I've used an if isServer to ensure that happens. However, while it works fine in a local test, on a dedicated server it has no effect and Zeus can use modules freely. This seems...wrong.
@zinc pulsar you post help questions without a rpt as what the rules in exile discord wants you to. I think that is why you aren't receiving much help.
There are no errors in my rpt ...that is why i did not post it...and thats not why nobody is responding. Dont be an ass hole.
Error can be in either client or server rpt
Ive already fixed it myself by the way. So no help needed...thanks anyway.
But then again, not my rules
Basically those 2 scripts are incompatible because the xs spawn includes basespawn so i just needed to delete the basespawn call.
Hey sorry about asking this but I am very new to scripting. Stuff like buildings, and world objects, I have it setup but every single time I start the mission the objects are still there. How do I make it so each and every single time I intialize the mission this script will be activated
Any script called from init.sqf, or placed in a unit or object's Init line, should be run on mission start, every mission start.
But...your message doesn't make it quite clear what you're actually trying to do.
check your dms
hey, how could i record and show live stats of kills for a specific side within a running mission?
with event handlers @tough abyss
yea that i got so far working
im using if (side _killer == west) then ...
is there some more elegant way to check if _killer side is not _killed side? sorry im a total noob in scripting
how do i find a range for an if statement?
example:
if (100 >= _myinteger >= 0) then
{
hint "success";
};
uh? do you want your number to be within some interval?
yes
use an &&
thanks
if (_myNumber >= 0 && _myNumber <= 100) then {}
Hi guys, do you know if it's possible to trigger a hide/unhide animation on a weapon with a script ?
If model supports it, there will be hide/unhide animation you could trigger with animate or animateSource
Hi there everyone, I'm having a bit of a trouble with a mission I'm making (I know it might not be the right channel, but my issue is about scripting a certain sequence at the start)
I need to make a AI entity attached to a tank, in sitting animation, arriving, then make the AI play the disembark animation and start briefing.
Here are my trouble :
-SetDir doesn't apear to work when under animation & attached
-When under the animation effect the entity will not move with the tank
-I tried using a chair to make it watch the correct orientation and follow with the tank. Only the orientation modification worked.
So I'd like a bit of help if anyone can help me doing this.
Here's a simplified pattern :
AttachTo Tank, orientated to the side > Sit animation > Tank advances > Tank stops > AI "disembark" animation > Start briefing.
SetVectorUp and setVectorDown are the right ones for setDir
I tried those too, didn't worked either for the player when under the animation effect, it somehow locks itself pointing towards the front of the object, I tried a bit with some memory point like a chair as reference, didn't changed anything. (I could be doing it wrong)
Is there a way to A) create a directional light via scripting or B) hide the GM spotlight w/o hiding the light effect?
whats the thing you want to do?
Put a bigass spotlight on vehicles and turrets and such
hello, i'm trying to find ` key code but can't - arma kay codes page is not show
this? it shows for me.
https://community.bistudio.com/wiki/DIK_KeyCodes
ah, i find
sorry
i used that ```sqf
(findDisplay 46) displaySetEventHandler ["KeyDown", "hint str _this"];
oh ` / tilde key , yeah didn't find it on that page either. Yeah its 41 . I don't remeber how to find the hex value though.
@mortal wigeon maybe create a spotlight, then disable simulation of it and move it somewhere else
@winter rose If this is what you mean: I tried disabling sim on the GM searchlight and the light effect would remain in-place after that. I could move the model around with attachTo but the light effect stayed still.
so it works?
it doesnt if he wants to attach it to vehciles that move
Id wager you need your own invisible spotlight object for that kind of stuff
Why not just create a lightsource and attach it?
lightsource is not directional
I'm reading on hash tables. Any idea what hash function is used in arma's mission namespace?
Or in these get/setVariable commands. I assume it's same.
Guys, anyone knows a way to prevent player connecting to a specific UAV? I mean something other than:
while {true} do
{
if !(isNull getConnectedUAV player) then
{
if (<player_is_restricted_to_connect>) then
{
// do something
};
};
sleep 10;
};
@quartz pebble https://community.bistudio.com/wiki/disableUAVConnectability
@winter rose thx. That solves 80% of the task. The remaining 20% - is to make it work with JIP players. Think scanning all the ingame UAVs on JIP client side would do the trick.
that or remoteExec with JIP
@mortal wigeon there is new directional light sources called reflectors with the newest Arma update, you can try to use that as a spotlight
@tough abyss
If model supports it, there will be hide/unhide animation you could trigger with
they can't support it, because you can't access them. Atleast unless simpleObj
@astral dawn It's in intercept, what do you need it for? Shall i find it for you?
Hey guys, does anyone of you knows any way or hint on how I can get the type of a road. The data has to be somewhere (as the map can read it). I tried surfaceType and found out, that it refers to the ground under the road, I tried getting the width to find out all road segments are 10 meters width (at least all I tested). I just need something to sort "highways" from all other roads, more would be nice, but is not needed
not really any engine mechanics for that I think
None? I guess I am not the first one to get this info, noone ever really did it?
I know about these, but they return the road object (or boolean for isOnRoad), none of them return the type of a road (main road, road and so on)
I want to know which kind of road I am having
try checking the road config, idk if it is there such as path, road, highway etc
Ok, I checked to config viewer and have not found a road config for the world data, but I may have missed it, where can I find it?
somewhere in config, I don't know the config tree. use your google-fu on this one
with road position, direction, roadAt, you can assume the roads' width, for example, or directly the config value for the road segment. your call
Thanks, I will have a look
@tough abyss I know do to that's with an object but here i talk about a weapon, i can't select the weapon as an object to trigger an animation with "animate" :/
Is there is a way to get the type of road a vehicle is on? Asphalt Paved roads show as #GDTSoil, the concrete paved side roads are #GDTConcrete, and dirt roads are #GDTSoil. Ive tried different getPos (getPos, getPosASL, getPosATL, getPosATLVisual, etc) I can use isOnRoad to ...
Im a bit curious what that info can be used for. As I can think of anything that needs it
@weary yarrow check the link above (by The Tall Man), I give working code there to measure road width. We used that in the old antistasi.
There are many usages for that. We determined roadblock type to create them dynamically. Also now I use it to modify a cost-function in a custom A* algorithm to make AI prefer main road a bit more. Another guy used it in his A* for an addon which emulated GPS functionality for a user.
@still forum thx I'll try to find that. I was just curious, but now that I think of it, maybe with that knowledge I can generate collision-free hashes somehow.
ah in that kind of stuff it does sound useful
maybe with that knowledge I can generate collision-free hashes somehow
If you want collision free stuff use something like sha256
Yes but I cant change the algorithm in arma. But thx I'll keep it in mind if I ever will need to choose a hash fn.
How should I check whether memoryPointsGetInCargo is typed as string or array? Could be defined both ways.
memoryPointsGetInCargo = "pos cargo";
memoryPointsGetInCargo[] = {"pos Cargo R", "pos Cargo L", "pos Cargo L", "pos Cargo R"};
Thanks. Hmm. But it's way slower than just using getText then checking with isEqualType. Guess I'll just do it the dumb way xD
I think getText can only get text
I meant isEqualTo ""
I don't do cfgs much but they should have more convenient scripted functions for getting cfg values
That is fancy! Good for readability, however literally 3x as long as doing both getText and getArray xD
Hey @astral dawn :D Saw this thread earlier, but this roads are mostly 10 meters width (like all of them), but I think I found a way to determine the road type exactly. I am using it for an A* pathfinding too (trying to simulate attacks in Antistasi :D) , but I would like to have better data. Should I give you a message once I found a way, you may want it for Project 0?
efficiently
Lou Montana told me to check the road config of the map itself, there is a list which selects the type (1-7) for road indexes, and a file setting a name for every 1 - 7 type. I am currently working on a way to extract this, but I have to see how this works, as given is a four digit road index and roads are numbered by a six digit code
I expect something like four digit road index plus two digit segment index
Interesting
Thinking more of it, probably one can cache road types into an array
Or maybe into a namespace 🤔 should work too
My system is caching most of the data, are you creating the grid on the fly?
I'm not doing it, another guy was doing it, I don't know exactly. I think he initializes road database at mission start.
@finite jackal I did some Googling but I'm not finding info on that. Got any pointers?
Does anybody know if there is a way to prevent ACE3 from ignoring other Mods damage event handlers? I do nothing else but to return a reduced the damage value via handleDamage. But ACE3 simply ignores that :/ and according to their docs have no own eventhandler you can register for that. Heard that for some stuff they use CBA EventHandlers, are they maybe "at fault" or provide a solution here?
Is there a way to use doMove without have to remove the AI from their group? they will come back to their possition afther complete the doMove, I was thinking about use waituntil with the doMovecomplete but I don't want to spawn the code for a small thing like that.
Instead you can spawn one 'thread' which will monitor how your AIs are performing the doMove
But I agree it's a PITA
Maybe there's a way though, I am not sure
And that can get urgly if there is allow of units doing that
If I want code to constantly search for an object apearing (specifically the "simple object" of blood) I understand that it is a poor idea to use a while loop, is the best way to do this using event handlers?
I've never used event handlers but I have heard they are used for some senerios similar to this
yes, you either poll the game world for some event (periodic checks in an infinite loop), or use event handlers to make the game notify your code that smth has happened
@surreal peak how will you be spawning the object?
add a hit event handler to the units that you want to check the blood for, then you can simply use nearest object to find the blood like this (sorry ill read the script in a second)
_Unit AddEventHandler["Hit",
{
params ["_Unit", "_Weapon", "_Damage", "_Shooter"];
_Blood= NearestObjects [GetPos _Unit, ["BloodClassName"], 5];
}];
when a unit is hit it will check for the blood within 5 meters of the unit that was hit
ooo that sounds like a good idea
should be efficient since it will only be checking when a unit is shot instead of continually checking a big area
so I just wana check, an event handler is a piece of code which will execute a piece of code whenever the thing it is checking for is fired
such as in this case, the code will execute when a "hit" is fired
correct, for example this event handler is called Hit, so the code inside of {//here} when the unit that has this event handler is Hit which fires the event handler
if the event handler was called Fired, then the event handler would only run when the unit shoots, it just triggers some script to run when the specified event happens
What shouuld I do if I want every unit (player/non player, even those who spawn after code executes) to have the event handler?
how are you spawning the units? what you could do for players is put the script in a sqf file called initPlayerLocal (this .sqf file runs automatically when a player joins the mission), if you have the players respawning then(depending on how you have their respawn set up) you would have to add the script to another .sqf file called onPlayerRespawn (this .sqf file runs automatically when a player dies and respawns)
Im planning on using this script for zeusing on a unit I play with so I cant edit the sqf files
All I can think of which will not harm server preformance that much would be using CBA framehandlers
and check every 30 seconds or so
im unfamiliar with working with zeus, do you know if you are able to add script to an object as zeus?
you can edit an objects inits
and add scripts to that object
and with achilles there is an execute code module
which allows you to execute any sqf code as if it is in the console
in the objects inits you could change _Unit to this(this refers to the objects whos init your in) and add the event handler to them that way. if you can use the achilles(again unfamiliar with it) to execute sqf code, you could do this
{
_x AddEventHandler["Hit",
{
params ["_Unit", "_Weapon", "_Damage", "_Shooter"];
_Blood= NearestObjects [GetPos _Unit, ["BloodClassName"], 5];
}];
} ForEach AllUnits;
this will loop through all the units and add the event handler to them
That seems like a good idea, will there be any conflicts if I keep adding Event Handlers to the same unit?
yes, heres how you can fix that
removeFrameHandler?
so if you add an event handler twice to the same unit, it will fire twice since the unit has 2 event handlers on him. so what you can do is store the event handlers Index into a variable on the unit like this
{
_x SetVariable ["HitIndex", -1, false];//false is whether or not its local or global
} ForEach AllUnits;
{
if ((_x GetVariable "HitIndex" == -1) then
{
_Index = _x AddEventHandler["Hit",
{
params ["_Unit", "_Weapon", "_Damage", "_Shooter"];
_Blood= NearestObjects [GetPos _Unit, ["BloodClassName"], 5];
}];
_x SetVariable ["HitIndex", _Index, false];//false is whether or not its local or global
};
} ForEach AllUnits;```
Is setVariable a way to add a custom variable that is stored in the object it is set to?
this create a variable on every unit spawned (you would want to add it in the initPlayerLocal for new joining players and or to respawning AI's inits(not sure how your mission is setup)
then it checks if the unit has an Event Handler (because of the HitIndex variable) and if its -1 then the unit does not have the event handler so it adds it, if its something other than -1 then it does not add the event handler since the unit already has the event handler on them
correct yes
sweet, thanks for the help! Can I put the _x setVariable ["HitIndex", -1, false];//false is whether or not its local or global in the other forEach allUnits loop
like I did here:
{
_x setVariable ["HitIndex", -1, false];//false is whether or not its local or global
if ((_x getVariable "HitIndex" != -1) then
{
_Index = _x addEventHandler["Hit",
{
params ["_Unit", "_Weapon", "_Damage", "_Shooter"];
_Blood= nearestObjects [getPos _Unit, ["BloodClassName"], 5];
}];
_x setVariable ["HitIndex", _Index, false];//false is whether or not its local or global
};
} forEach allUnits;
you wont want to do that as that would remove the point of the code shown above and it would make it so the event handler is always going to be added(btw i made an error and corrected it above, it should be == -1 not != -1)
ah I see
so your checking if the unit has a variable that equals -1, if your setting the variable to equal -1 everytime then we wouldnt be able to determine if the unit has the event handler or not, make sense?
np man, goodluck
Anyone here have some experience with inidbi2 databases? having trouble getting one to read from the ini file.
I've had (a hard time) working with it once, a few years ago, probably I don't remember anything though
@rocky mortar might help you cause he made it 😄
yeah, he's my buddy on steam but i think he's sleeping hehe!
ive got it writing perfectly to the ini file, but cant for the life of me figure out how to load it
I'll have to wait and hit up code34 when he's around next unless someone else wants to chime in!
I can only have a look at the old code we made with it long time ago...
https://github.com/A3Antistasi/antistasi-1.x/blob/develop/AntistasiOfficial.Altis/Save/fn_saveDataINIDBI.sqf
https://github.com/A3Antistasi/antistasi-1.x/blob/develop/AntistasiOfficial.Altis/Save/fn_loadDataINIDBI.sqf
(sorry probably it doesn't help much)
@tough moth i have tutorials on it, if your still struggling after the tutorials let me know, once you do something with it once it starts to make sense. just remember to keep all the reading/writing on the server and not the clients(unless for some reason you want it to be on the clients as well)
https://www.youtube.com/watch?v=O-N2M7UnB1w&list=PLnHeglBaPYu_ao9OtMEKbBfTEGzEq7_X4
@tame socket Hey man! was literally watching your videos! Mind if I PM you? Appreciate any help with this thing.
for example, lets say you have a client and the server, the client wants to load in his old gear from when he last left the server(assuming it was saved). the client makes a call to the server, the server searches for that clients file, if found it sends the data the client wants back to him
sure
awesome. thanks @astral dawn as well!
been trying to get my AddPublicVariableEventHandler to work on ALiVE Spawned units, any tips?
about to kill myself
been staring at this for about 4-5 hours lol
https://community.bistudio.com/wiki/addPublicVariableEventHandler
Alt syntax of this command doesn't work as intended
Yeah I even did a post on the Alive thread to hopefully get a response, i've checked almost all forums _ i've tried loops i'm just not sure how to get it to run on spawned AI, eventhandlers sure but i've never messed with publicvariables - is it the same sort of deal
all i know is we used it a while back to make civilians flee from nearby fire (before that was integrated into ALiVE)
function was in sqf run at startup, looked like this
_ai = _this select 0;
if ((side _ai == civilian) and (!isPlayer _ai)) then {
_ai addEventHandler ["FiredNear", {
_unit = _this select 0;
_gunner = _this select 7;
see the system i got is with the initserver.sqf
Playermoney = 0;
"PlayerKilled" AddPublicVariableEventHandler
{
Private ["_information"];
Private _PlayerMoneyBonus = 0;
_information = (_this select 1);
_unit = (_information select 0);
_unitside = side _unit;
_killer = (_information select 1);
_ClientID = Owner _Killer;
_distance = _unit distance _killer;
_PlayerMoneyBonus = _distance + 50 * 1.5;
PlayerClient = _PlayerMoneyBonus;
_ClientID publicVariableClient "PlayerClient";
} foreach Allunits;
I followed a tutorial since 'gotta learn somewhere' but still trying to get the basic idea
i just don't know how to transfer that into spawned AI
I even did the description Extended_Init_Eventhandlers but it just didn't seem to kick off
Is there any way to do this in a less weird way? I basically want to check if X and Y are between select values, but when I tried min<X<max I got script errors when the X wasn't in the range.
if ((_minX<_Xpos) && (_Xpos<_maxX) && (_minY<_Ypos) && (_Ypos<_maxY)) the {}```
@thorn saffron https://community.bistudio.com/wiki/inArea
nope, what you are linking is for trigger areas, I'm just checking a couple of numbers to see if they stay withing specified range
not really, it doesn't have to be trigger, it also works for numbers
_width = 20;
_height = 10;
[_x, _y] inArea [[_xMid, _yMid], _width/2, _height/2, 0, true]
Might be convenient in some cases (when you have (x, y) of center and width and height) and inconvenient in others...
not feeling this one TBQH
alt syntax 3 I mean
🤷 whatever
your way is the proper one
Might add some https://community.bistudio.com/wiki/Code_Optimisation#Lazy_evaluation too if you want
Your way is not weird at all, it's totally allright
Trying to make a texture marker on the map. Not working because I have no idea what I'm doing. Any help would be appreciated. Friend of mine helped me! The script under works!
EpicMarker = createVehicle ['Land_HelipadEmpty_F', [4159.83,5485.06,-185.933], [], 0, 'CAN_COLLIDE']; EpicMarker setPosWorld [4159.83,5485.06,-185.97]; [EpicMarker, [[0,1,0], [-0,-0,1]]] remoteExecCall ["setVectorDirAndUp", 0, EpicMarker]; EpicMarker enableSimulationGlobal true;
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw",
{
_this select 0 drawIcon ["\a3\UI_F_enoch\Data\CfgUnitInsignia\Astra_ca.paa", [1,1,1,1], getPos EpicMarker, 200, 200, 0, "ASTRA", 1, 0.04, "TahomaB", "right"];
}];
Possibly, but I can't read plain text, only ```sqf
```
😉
Hey, me again, I took Lou Mantanas hint from yesterday and searched the road config in the map files. I found two files in the road folder, called roads.dbf and roadslib.cfg. I parsed the roadslib to transform a road class to a road type like
Roadclass 5 => Main road
and used a external program to transfrom the roads.dbf into a sqf array looking like this
roadTypes = [[1100,3],[1102,3],[1104,3],[1106,3],[1108,3],[1110,3],[1112,3],[1114,3],[1116,3],[1118,3],[1120,3],[1122,3],[1124,3],[1126,3],[1128,3]];
holding the road index and the road class. So far so good, now I just got the road names like 165797 and 165796 (two connected roads) and assumend the first four digits are the road index and the last two are segment indexes. But there is the problem. The road index 1657 is not in the array, there is a difference of 507 to 657 between them.
There seems to be a offset between it, which is not even the same for every road. I assume it has something to with the layers that are in the roads.dfb (Roads, Path, City Road), but I don't know the offsets and have not found a way to get them. Does anyone knows these offsets or knows how to get these? I hope my question got clear, if not I can explain it further.
TL:DR I trying to connect a road segment with a number like 165797 to a road in roads.dbf looking like this 1150. There seems to be a offset I can get nowhere
you will have to work with roadsConnectedTo
roadsConnectedTo is getting the connected road segments (not really reliable tho), but I am trying to connect a road name, gotten by str _roadSegment, to an index from the roads.dfb file
that's way too advanced for me, sorry!
Each road segment on Stratis is numbered around 160000 +/-, last two digit are for the segment, not the road, so every road is numbered 1600+/-. The world data contains a file called roads.dbf with all road, but there they are numbered 1100 +/-, there seems to be a offset between file road index and world road index
I would send a picture but it is disabled on this channel as it seems
Will do, posting only one should be ok,right?
or one post with 3 screens, but not 1 every hour I suppose ^^
Ok, but this one should be enough, it shows the roads.dbf and the four digit codes I assume are indexes for roads
I may be totally wrong and the number from str _roadSegment has nothing to do with the roads.dbf
Guys, any way to get ArmA definition files, whose values are used in the game config?
I mean, in config one might see:
class SomeAwesomeTank
{
scope = 2;
access = 1;
...
}
I thought there must be human readable definitions of those fields values (scope, access, type and so on) somewhere in the game SDK.
// type scope
#define private 0
#define protected 1
#define public 2
// type access
#define ReadAndWrite 0 //! any modifications enabled
#define ReadAndCreate 1 //! only adding new class members is allowed
#define ReadOnly 2 //! no modifications enabled
#define ReadOnlyVerified 3 //! no modifications enabled, CRC test applied
although most examples on BIKI also contains comments about what the values do...
although most examples on BIKI
@exotic flax I couldn't find it all in one place. Is there a page I missed?
somewhere in the game SDK
There is no SDK
I thought there must be human readable definitions of those fields values
There aren't
But there is https://community.bistudio.com/wiki/CfgVehicles_Config_Reference.. aw too late
sorry Dedmen 😉
@exotic flax @still forum I saw that config reference pages. I was hoping there is something I could download and directly fetch in my code without writing it by hand.
Those definitions are only to make it readable, but are not a part of Arma itself.
Apparently they do disappear after binarization and not shipped with the game.
But there could be a chance BI devs have shared something I missed🙂
makes sense, doesn't it 😉 binarization = binary = 0/1 😉
Where do you need it? In game?? Just do something like
["private", "protected", "public"] select (getNumber (_myConfig >> "scope"))
Just do something like
Also an option.
so the money system i was making doesnt actually work with multiplayer at all.. any suggestions?
Sure, if you provide some context on how it works @tough abyss
is there an easy way to make an AI more aggressive? Aka I have a chopper (AH-1Z) that should attack a target, however it does not use it's full potential and instead shoots a few rounds with the gun (M197)
yes, reveal targets to it @hollow lantern
I thought it would already know about it as I gave the eliminate order via ZEUS but sure can try that
it does not use it's full potential and instead shoots a few rounds with the gun (M197)
I think reveal would not help here. The AI already knows about the enemy... Otherwise he would not fire.
But I have no better idea, so try it out...
I will try that with reveal, maybe he starts firing earlier because he knows earlier
can't really know the situation, but you probably know that thing when you send one bullet to a chopper, then he knows where you are and you are terminated within next minute...
So I followed a tutorial that more or less does a publicvariable in the InitServer then it goes to the initplayerlocal and pretty much does the stuff locally i'm sure
I couldn't get it to work with ALiVE since it's just not wanting to work - but when I got somebody to jump on and test it - it just returns %any but it worked for me
I can link the tutorial if it helps, trying to learn this stuff a bit more rather than the basic stuff
I'd suggest you to make most, if not all, networking in your mission be based on remoteExecCall instead of publicVariable
would make debugging easier as well
as a bonus, you can still make things persistent and JIP-compatible with remoteExecCall
see that would be ideal
i'll try learn how to do that
presistence and JIP would be great aswell
Thanks Sparker
Arguments, Command e.g. sqf ["Angel loaded!"] remoteExecCall ["systemChat"]; just read a bit in https://community.bistudio.com/wiki/remoteExecCall
what tutorial did you watch? and you said it returns %any, what returns %any? is it a pile of money on the ground with a value set on it or is it set on a player or what
dats me 🙂
See it works perfectly fine on my end
was curious. in the SetVariable, did you make the variable public?
I can paste it if you want?
wait derp im thinking of something else
i mean its pretty much your script anyway right lol
so i made like a bunch of case scripts so I could make players earn money to buy grenade launcehrs for weapons, upgrade vehicles and stuff along with selling and buying their kit from various laptops using the holdspace functions - but I was having issues with it working with ALIVE since it just doesnt record the deaths - but also when people join it doesn't work either - i might have slipped up but heres the scripts
initserver.sqf
"PlayerKilled" AddPublicVariableEventHandler
{
Private ["_information"];
Private _PlayerMoneyBonus = 0;
_information = (_this select 1);
_unit = (_information select 0);
_unitside = side _unit;
_killer = (_information select 1);
_ClientID = Owner _Killer;
_distance = _unit distance _killer;
_PlayerMoneyBonus = _distance + 50 * 1.5;
PlayerClient = _PlayerMoneyBonus;
_ClientID publicVariableClient "PlayerClient";
} foreach Allunits;
initplayerlocal.sqf
PlayerMoney = 0;
{
_x addeventhandler ["Killed",
{
_unit = (_this select 0);
_killer = (_this select 1);
_Instigator = (_this select 2);
PlayerKilled = [_unit, _killer];
PublicVariableServer "PlayerKilled";
}];
} forEach AllUnits;
"PlayerClient" AddPublicVariableEventHandler
{
_PlayerMoneyBonus = (_this select 1);
_Playermoney = Playermoney;
PlayerMoney = (PlayerMoney + 50) + _PlayerMoneyBonus;
hint format ["Player Wallet: $%1", PlayerMoney];
};
ok so its just a basic (if player 1 kills player 2, give player 1 money) that your stuck on?
well I wanted it to be for AI since it's ALiVE
gotcha, do you want it to work when players kill other players and AI or just when a player kills AI?
as much as i'd like it to be players and AI i'm going to say player kills AI
not tested or anything but heres kind of how i would set things up since i like keeping everything i can on the server. this is using SetVariable and GetVariable to control the amount of Cash that is on the player and it is not exposed to the player either so this is stuff that you would want to run on the server (including the event handler and ControlPlayerCash Function). The server detects that a unit has been killed (since the killed event handler is on the server) so it calls the ControlPlayerCash function and passes in the killed unit and the killer. from there it simply adds 100 to the players cash and then prints a hint back to the player that is the killer telling him/her how much Cash he/she has
ControlPlayerCash =
{
Params [_DeadUnit, _Killer];
_KillersCash = _Killer GetVariable ["Cash", 0];
_CID = Owner _Killer;
//just to keep it simple for the example
_KillReward = 100;
_KillersCash = _KillersCash + _KillReward;
_Killer SetVariable ["Cash", _KillersCash, false];
[Format["You Have %1 In Cash", _KillersCash]] RemoteExec ["hint", _CID, false];
};
{
_Unit = _x;
_EHID = _Unit GetVariable ["KilledEHID", -1];
if (_EHID == -1) then//meaning the unit does not have the killed event handler
{
_EHID = _Unit AddEventHandler ["Killed",
{
params ["_Unit", "_Killer", "_Instigator", "_UseEffects"];
_Params = [_Unit, _Killer];
[_Params] Call ControlPlayerCash];
}];
_Unit SetVariable ["KilledEHID", _EHID, false];//set the event handler ID on the unit
};
} ForEach (AllUnits Select {!(IsPlayer _x)});//for all units that are not players
as AI respawn and such you can rerun the ForEach loop and it will add the event handler only to the AI that do not have the event handler already on them
what's the right approach to check if a unit has a weapon? hasWeapon? aka sqf _x hasWeapon (getNumber (configFile >> "CfgWeapons" >> _x) == 2)
damn Cody thanks, thats incredible
do you mean just check if a unit has any weapon at all?
im not 100% sure if this works on weapons in your weapon slots, but it should work on inventory. just Weapons, so
_WeaponList = Weapons _x;
if (Count _WeaponList > 0) then
{
hint "HAS WEAPON";
};
I'll give it a try now, thanks
let me know if it works if you dont mind, hopefully it does so you dont need to iterate through the configs
sure, loading my debug mission rn with it loaded
ah yeah 14:09:09 Error Undefined variable in expression: _x but I just fixed that like so: sqf _WeaponList = {Weapons _x} forEach allUnits;
seems to work then @tame socket
thanks
sweet
Is there a way to call code before and after a function call? Like aspects?
what do you mean exactly?
Well atm. I call code at the top of the function and at the bottom - I try to do some kind of function call stack
But I don't like to have this "meta" aspect in every function
I'd love to have it like hidden logic that nobody needs to care about when writing functions
cause it's always the same logic code
no clue, also not entirely sure what a function call stack is lol
Well I want to know what functions are called in what order
So I made an array where in every function __FILE__ is called. At the end of that function I pop that entry so it's saying like "leaving this function". That way I wanna log the function call hierarchy/order
is it for debug? ADE has dump callstack command
ye debug - cause my client crashes at some point and I wanna see around what function that happens
or you could make some #define with a header and footer in each your function
maybe there are better ways - but I am already zoned into making that stack 😄
use Arma Debug Engine, it dumps callstack and all the local variables at each level!
@astral dawn already doing but i dont like the Footer part
Arma Debug Engine is working? Never used it 😄
I simply don't script without ADE any more, it's so useful for analyzing crashes, takes 10 seconds to understand what was wrong
ofc it is
ah really
typically after I notice that it's broken and I poke Dedmen and he repairs it, but still, use it while it's still operational 😄
just don't forget to disable BE
to quickly see if it works at all, use ADE_dumpCallStack SQF command
yes it is
🤷 I think Dedmen told me about it
it can't
anyway, it will dump callstack automatically on any script error
BTW if you still want to add your code to start and end of each function, you can iterate through allVariables of missionNamespace, search for those which are code, covnert it to string, append your logic to start and end, then compile it back
I tried it and it fucks up line numbers unfortunately
well they are fucked up anyway lel
but that's nice hacky way
u described
will try that 😄
actually no, it will only work for adding header to functions
because they might exit with exitWith{}
actually yes, you can wrap old function into a call{} somehow and see what it returns...
well even if it exitsWith it still exits normally doesnt it? so after the func call I can still do some logic
is there a way to add a string to another string at a specific index?
like insertAt
Probably only through toArray and toString
alrighty
BTW I am not sure if you can overwrite functions made with compileFinal or with the cfgFunctions
I have lost the faith in Arma AI. Two AH-1Z Viper approach a SAM site and instead of eliminating the radar, they fire two rounds with their main canon on that radar and nothing. They are even 10m away from that radar. So reveal didn't helped that much. Maybe if I increase the range from 4 to something higher but 
or maybe there was some flag somewhere... can't remember
what range @hollow lantern ?
ah, the reveal parameter
had 4, testing with 20 now
but it's allright, almost everyone who has ever tried to make arma AI do something has lost faith in it at some point, typically within first several hours
I recall seeing some mod somewhere which adds an invisible vehicle at which AIs are very likely to shoot
lol interesting idea
@astral dawn are all cfgfunctions compiled with compileFinal ?
I don't remember, need to read the cfgFunctions wiki page
you can try to overwrite some existing function of yours or BIS and see if it works
_WeaponList = {Weapons _x} forEach allUnits;
seems to work then
This will only return weapons of the last unit in the allUnits array. What is the point?
@weary yarrow I don't think you are going to be able to translate an object ID to something related to the shapefiles. In A3 they added the ability to define roads on a terrain as shapefiles, instead of individual road objects/models. However if you provide a shapefile, the game will automatically split it up into different road objects/models on its own.
If you write a script to count the number of objects on Stratis it should come out to 163952. Then if you searched through all the road object IDs, the lowest one you should find is 163953. Meaning the road object IDs start immediately after the normal map object IDs. The number you have there (165797) is the object ID of that specific piece of road. You might be able to reverse engineer the logic of if there is a connection between which road has the first ID and some value in the shapefile or similar files, but I don't think you can go much further. It might not even be possible to figure out how many different objects will be created from a given shapefile because of the length between points and the angle between the points.
@tough abyss i think he possibly missunderstood the point of the foreach loop? it sounds like he doesnt need it at all but idk what hes trying to do
@tame socket I got the loop to work, I keep getting an error but with the first params [_deadunit, _killer]; but i've noticed if i put "_deadunit" and "_killer" - I had a Scalar Nan error, but without them - i get a error with the params and it doesnt save money
@tough abyss just got home, ill test it here in a bit
@tough abyss wait derp i see a mistake, in the function call, pass in _Unit and _Killer as separate parameters so
[_Unit, _Killer] Call ControlPlayerCash];
Hey I am looking for a script that plays a sound(Sound.Ogg) at certain time of day every day?
Any tips?
@native hemlock That was obviously not the answer I was looking for, but nevertheless thank you for it. I feared the id's could be unrelated, but hopped they weren't. So basically, as long as I don't want to parse the shape file, the only option would be to mark the streets manual
@royal marten this should play a sound globally for all clients to hear if they are within 100 meters of wherever the sound is playing. Change whateverTimeYouWantDuringTheDayToPlay to the time of day you want the sound to play in a 24 hour format. You want this to run on the server
_TimeToPlaySound = whateverTimeYouWantDuringTheDayToPlay;
While {true} do
{
if (DayTime >= _TimeToPlaySound && DayTime < _TimeToPlaySound + 0.1) then
{
_DistanceSoundCanBeHeardInMeters = 100;
_Pitch = 1;
_IsSpeech = false;
[_Position, ["SoundName", _DistanceSoundCanBeHeardInMeters, _Pitch, _IsSpeech]] RemoteExec ["say3D", 0, true];
};
Sleep 60;/check once a minute
};
like this?
{
_Unit = _x;
} ForEach (AllUnits Select {(Group _x) == (Group Player)});
nvm you removed the question lol
Thanks Yes ive find what i want ```sqf
((crew vehicle player) select {(group _x isEqualTo group player)}) apply {name _x};
that looks cleaner lol
@frigid raven that API command documentation is only for the json network api.
the script command is just a command.
ACE does callstacks by wrapping all their function calls in a macro, which then adds header/footer at call site.
unfortunately this function is breaking my logic
what mean?
are all cfgfunctions compiled with compileFinal ?
Yes unless you enable allow recompile
@still forum so when recompile is allowed I can recompile them? That would be cool cause I just need it to work on my local environment
unfortunately this function is breaking my logic
what mean?
Hard to explain tbh I added that command at the top of one of my Dialog Handlers. The dialog handlers screwed up afterwards. BUT I have to say that I use @queen cargo 's promise script which does some callback stuff. I can't tell if it's screwing up because of that. I stopped investigating and kept following my approach cause I felt it being simpler for me to use for now.
command shouldn't do anything besides freeze the game for a short moment to dump the callstack to RPT 🤔
do not bring me into this @frigid raven :D
i not even have any idea what you guys are talking about
you did it
Is there a command or workaround for aimPos/unitAimPositionVisual (which seems to return unit eye pos and scope pos), where it returns muzzle position?
aimPos is just center of body I think? It's the point AI's should preferably aim on
Don't know a way to get muzzle position, besides grabbing the players hand memory point and guesstimating from there
maybe you can spawn the weapon as simple object, and then get it's muzzle memory point, and the offset to the position where the hand is attached, and then use that to work from hand to muzzle
What i'm trying to do is create a fired EH, that if the unit is poking their weapon through a wall and there's an object intersecting, to delete the projectile. All the current commands return points which are behind the muzzle, by which time, the weapon can fire through the object. I'm running this to show the intersected object
if(lineIntersects[eyePos player, unitAimPosition player])then
{
[parseText format["<t size='0.9'>%1</t>",cursorObject],0,-0.2,5,0] spawn bis_fnc_dynamictext;
};```
You can try maybe intersect back from fired bullet to check if there is a surface between player and bullet
That I fear would be a lot of heavy lifting to do codewise
Try checkvisibility
If bullet cannot see player he must be on the other side of the wall then
@queen cargo did u ever noticed that your discord ID is #1337 ?
@tough abyss Will try that but I think it will still be enough for the unit to "poke" the muzzle through the wall to fire
What do you mean?
The bullet can see the target as the bullet is already on the other side of the wall. Using
if(lineIntersects[eyePos player,aimPos player])then
{
[parseText format["<t size='0.9'>%1</t>",cursorObject],0,-0.2,5,0] spawn bis_fnc_dynamictext;
};```
does, for the most part detect an object but there's a few cm where it doesn't and the weapon can fire through the object.
I guess I could create a position a few cm in front of the player and use that instead
The bullet can see the target
He said see the player, the shooter, not the target
I never said anything about bullet and target
however checkVisibility might fail if you shoot from inside a smoke grenade?
if(lineIntersects[eyePos player,aimPos player])then Just use eyePos plus viewDirection * 1 meter
a gun will probably not be longer than a meter?
It might not be visibility 1 but could be >0
This works
_aimPos = aimPos player;
_aimPosX = _aimPos select 0;
_aimPosY = _aimPos select 1;
_aimPosX = _aimPosX +0.43;
_aimPosY = _aimPosY +0.43;
_newAimPos = [_aimPosX,_aimPosY,_aimPos select 2];
if(lineIntersects[eyePos player,_newAimPos])then
{
[parseText format["<t size='0.9'>%1 aim pos %2</t>",cursorObject,_newAimPos],0,-0.2,2,0] spawn bis_fnc_dynamictext;
//and do something here
};```
_aimPosX = _aimPosX +0.43;
_aimPosY = _aimPosY +0.43;
but that might be behind the player, or to the right, or front, or left
_aimPosX = _aimPos select 0; _aimPosY = _aimPos select 1;
params
_newAimPos =
vectorAdd
if(lineIntersects[eyePos player,_newAimPos])then
doesn't that detect bushes too? I think shooting through a bush is legit
I can add a check for object type
aimPos btw returns the memoryPointAim from config
I think it might be better to just use the torso if you really don't want to just use eyepos
nah actually you are using eyepos.
so why aimPos too?
@tough abyss that should be redirected to @hollow lantern I think
trying to save positions relative to an object as an array, so I can use those positions with multiple buildings of the same types with simple objects.
private _positions = [];
private _building_classname = "Land_Offices_01_V1_F";
private _building_position = [5483.62,1749.19,-0.0141573];
private _bank_building = nearestObject [_building_position, _building_classname];
[
safe_1, safe_2, safe_3, safe_4
] apply
{
_positions pushBack [(_bank_building worldToModel (getPos _x)), (getDir _bank_building) - (getDir _x)];
};
copyToClipboard str _positions;
``` is what im using to output the positions.
```sqf
[
[[8.7031, 7.32751, -7.98319], 0],
[[9.6826, 7.33655, -7.99525], 0],
[[11.325, 7.35791, -7.98647], 0],
[[12.269, 7.37805, -7.99566], 0]
] apply
{
_x params ["_position", "_direction"];
private _spawnPosition = _bank_building modeltoworld (_x select 0);
_safe = "Lega_Safe" createVehicle _spawnPosition;
_safe setPosATL _spawnPosition;
_safe setDir (getDir _bank_building) + (_x select 1);
};
``` is what im using to spawn them back in , but its never on the same position, most of the time, it spawns in the floor of the building. any help would be greatly appreciated.
why are you using ATL with a AGL position?
Just use modelToWorldWorld and use setPosWorld
have you tried just logging if the positions you get out are the same on input/output?
will try that now.
also you are using getPos on the worldToModel, which returns PositionAGLS.
While worldToModel takes PositionAGL.
AGLS takes the surface into account, the objects between terrain and the object. In your example the building and the table
that could throw you off
yeah
only seems to be a 0.01 difference in height.
… position == getPos ?
no
wiki says so (and I am not the author)
maybe getPosASL and ASLtoAGL.
Or just don't use worldToModel at all and instead do a manual vectorDiff
[8.61523,7.33801,-7.97743] position
[8.7031, 7.32751, -7.98319] getPos
dat pos sh*t :D
I had the same issue spawning furnitures according to the model, but I finally got it sorted
I am not home though
Yeah I did it a long time ago for a similar script,
pity i didn't save the function I used to export the positions.
//Spawn teh safe
private _spawnPosition = _thisBank modeltoworld (_x select 0);
private _thisSafe = "Lega_BankSafe" createVehicle _spawnPosition;
//move teh safe.
_thisSafe setPosATL _spawnPosition;
_thisSafe setDir (getDir _thisBank) + (_x select 1);
``` i just have this left from spawning them back in
i think I got it.
ping me in ~5h if you don't figure it out before
Output positions
private _positions = [];
private _building_classname = "Land_Offices_01_V1_F";
private _building_position = [5483.62,1749.19,-0.0141573];
private _bank_building = nearestObject [_building_position, _building_classname];
[
safe_1, safe_2, safe_3, safe_4
] apply
{
_positions pushBack [(_bank_building worldToModel (ASLtoAGL getPosASL _x)), (getDir _bank_building) - (getDir _x)];
};
copyToClipboard str _positions;
Spawning them back in
private _safe = objNull;
private _building_classname = "Land_Offices_01_V1_F";
private _building_position = [5483.62,1749.19,-0.0141573];
private _bank_building = nearestObject [_building_position, _building_classname];
[[[8.6709,7.24011,-6.19784],-0.00293326],[[9.74805,7.2771,-6.19782],-359.999],[[11.2739,7.31226,-6.19784],-2.54479e-007],[[12.291,7.34351,-6.19677],-359.992]] apply
{
_x params ["_position", "_direction"];
private _spawnPosition = _bank_building modeltoworld (_x select 0);
_safe = "Lega_Safe" createVehicle _spawnPosition;
_safe setPosATL _spawnPosition;
_safe setDir (getDir _bank_building) + (_x select 1);
};
tyvm @still forum @winter rose
Guys, do simple objects support setObjectTexture ?
afaik yes
I hope so, as I coudln't make it work so far.
check the objects config. if it doesnt have hiddenselections you cant use setObjectTexture
@arctic quest thx. That was it.
execVM "description.ext";
https://forums.bohemia.net/forums/topic/225332-cfgmusic-error-cant-seem-to-get-it-working/
🤦
That is legit impressive.
@tame socket I got it working to some degree - it works pretty smooth - the only issue now is the money isn't saving? so it'll say you have 100 in cash but when I do the hint after 3 kills it just tells me I have any in cash - like its not recording - I'll try messing with it but it's just that last hurdle for me - thanks for the help!
this works in a trigger but not in a script, ideas? sqf { if ((side group _x) != US_GEN call BIS_fnc_friendlySides) then {} } forEach allUnits;
haven't written anything yet, about to start. Just tested this code block.
the error is sqf if (( side group _x) != US_GEN call BIS_fnc_friendlySides) th> 12:03:40 Error position: <!= US_GEN call BIS_fnc_friendlySides) th> 12:03:40 Error !=: Type Array, expected Number,String,Not a Number,Object,Side,Group,Text,Config entry,Display (dialog),Control,Network Object,Team member,Task,Location 12:03:40 File c:\users\aebian\documents\arma 3\missions\thelab.tanoa\initServer.sqf..., line 67
the condition works in a trigger
just not if I try to use it in a if
ah probably because BIS_fnc_friendlySides returns an array
BIS_fnc_friendlySides returns an array
if ( ! (( side group _x) in (US_GEN call BIS_fnc_friendlySides)) then {};
use the in operator, probably that's what you want
ah
the condition works in a trigger
sounds like it doesn't
it has no right to work there, can't compare a side and an array 🤷
it working makes no sense
maybe it returns nil or some garbage and somehow the trigger gets triggered 😄
@hollow lantern
Syntax:
toCheck call BIS_fnc_sortAlphabetically
Parameters:
toCheck - Side or Object: Side or object whose friendly sides should be returned
Return Value:
Array of Sides
Return Value:
Array of Sides
there is no way it worked in script
BIS_fnc_sortAlphabetically wat
LOL you tell me https://community.bistudio.com/wiki/BIS_fnc_friendlySides
wat 😮
typos ftw
example though player call BIS_fnc_friendlySides; // can return [FRIENDLY,WEST,GUER,CIV]
@cosmic lichen why? 😄
OMG he is gonna say it wasnt him
"ItemGPS" isKindOf "ItemGPS" gives me false
I want to check if unit has either GPS or any kind of UAV console. I thought that the isKindOf will be able to handle this.
main and alternative syntaxes support only CfgVehicles, CfgAmmo and CfgNonAIVehicles ItemGPS is CfgWeapons
derp
@thorn saffron alt syntax 2 allows you to check iirc
there is even an example
For some reason I have troubles getting this to work:
_assignedItems = (assignedItems player);
_hasGPS = false;
_hasRadio = false;
{
if ("ItemGPS" in ([(configFile >> "CfgWeapons" >> _x), true] call BIS_fnc_returnParents)) then {_hasGPS = true;};
if ("UavTerminal_base" in ([(configFile >> "CfgWeapons" >> _x), true] call BIS_fnc_returnParents)) then {_hasGPS = true;};
if ("ItemRadio" in ([(configFile >> "CfgWeapons" >> _x), true] call BIS_fnc_returnParents)) then {_hasRadio = true;};
} forEach _assignedItems;
systemChat format ["Has GPS/UAV console: %1",_hasGPS];
systemChat format ["Has Radio: %1",{_hasRadio];
privaaate
I was running the code through console, privates usually dont work there for some reason
it work there
private _assignedItems = (assignedItems _unit);
private _hasGPS = false;
private _hasRadio = false;
{
switch (true) do {
case ("ItemGPS" in ([(configFile >> "CfgWeapons" >> _x), true] call BIS_fnc_returnParents)): {_hasGPS = true;};
case ("UavTerminal_base" in ([(configFile >> "CfgWeapons" >> _x), true] call BIS_fnc_returnParents)): {_hasGPS = true;};
case ("ItemRadio" in ([(configFile >> "CfgWeapons" >> _x), true] call BIS_fnc_returnParents)): {_hasRadio = true;};
};
} forEach _assignedItems;```
if ([player, "ItemGPS"] call BIS_fnc_hasItem) then {hint "Fuck me, you have GPS!"};
it works for me
be sure private _assignedItems = (assignedItems _unit); that _unit is defined for debug console type private _unit = player; or private _assignedItems = (assignedItems player);
if (assignedItems player findIf {_x == "ItemGPS"} > -1) then {hint "Fuck me, you have GPS and it is equipped!"};
oh that findIf command is nifty, I never knew it was a thing
is there a way to get the name of the function you are executing code in? its for error handling. i have something causing a generic error some where so i want to put something at the top of a bunch of functions that is general to fire before the error so i know where it happened. im trying to avoid going to each function and putting something at the top that is specific for the function. i just want to do a mass find and replace.
@exotic tinsel _fnc_scriptName
See https://community.bistudio.com/wiki/Magic_Variables
@winter rose thx mate
You also assign friendly names: https://community.bistudio.com/wiki/scriptName
_thisScript is the script handle, it might output the whole content
_fnc_scriptName for functions, or as @finite dirge mentioned, scriptName
_fnc_scriptName?
yeah i got it from there but visual code is throwing error saying undefined variable.
Yeah, ignore those / don't use the error checking parts of things. It is undefined in that scope, it's MAGIC.
true
Danke Schön!
it seems it's one of the rare, if not the only one, to be able to compare to itself!
Even in SQF-VM it's true 💌
@queen cargo it's aliiiiiive! and it works Ö
Obviously sqf-vm is correct 🤔
^^
(tbh... Think there is no testcase yet)
I have an experiment where I want to enrich a function by aspects at the beginning of the call and at the end.
This is teh logicz so far:
private _beforeAspect = "call coopr_fnc_recordFuncCall;";
private _afterAspect = "call coopr_fnc_recordFuncCall;";
//private _cooprFunctions = allVariables missionNamespace select {["coopr_fnc_", _x] call BIS_fnc_inString };
private _functionString = str (missionNamespace getVariable "coopr_fnc_getSkills");
private _functionStringAsArray = toArray _functionString;
// stripping { and }
_functionStringAsArray deleteAt 0;
_functionStringAsArray deleteAt (count _functionStringAsArray) - 1;
// add aspects
private _enrichedFunction = [_beforeAspect, toString _functionStringAsArray, _afterAspect] joinString "";
_enrichedFunction;
missionNamespace setVariable ["coopr_fnc_getSkills", (compile _enrichedFunction)];
Now the main problem (already assumed by @astral dawn ) is that the _afterAspect is badly positioned at the end of the function call. Because it is preventing a return value.
Any ideas how to workaround that? String processing with SQF is a pain and I will not include some Regex Mod to have an easier approach here. Maybe you guys have a nifty hack to get that working. What I mean is a way to locate the last statement of an SQF script as safe as possible and therefore placing the _afterAspect before that statement.
PS: I know there is also an issue with exitWith returns. But I will focus on that later
sure, you must wrap the inner code into a call {}
and safe the return value?
it will also solve that
and then call teh afterAspect and after that return the value?
Fun fact just as you started to type I remembered u mentioned that wrapping call 😄
and a 💡 appeard
< we put header here>
private __ret = _this call {
(inner code which we don't modify)
(inner code which we don't modify)
if (true) exitWith {-666}; // Look, we can return that too!
(inner code which we don't modify)
};
<we put footer here>
__ret // now we return whatever the inner code piece wanted to return
gotya
You've got to check what happens if your function returns nothing though (nil or nothing), it might start b****ing that __ret is undefined or whatever, it can get tricky
Will see
but really, could you maybe replace all your calls to your functions with some macro of yours, which calls footer, calls your code, then calls the header?
I have an array with objects inside. I'm currently struggling what would be the best way to make the switch statement work because side obviously doesn't like arrays. Should I split the input array or what would you guys do? Code is ```sqf
params["_weapons"];
switch (side _weapons) do
{
case independent:
{
{ createVehicleCrew ("I_TargetSoldier" createVehicle (getPos _x)) } forEach _weapons;
};
case west:
{
{ createVehicleCrew ("W_TargetSoldier" createVehicle (getPos _x)) } forEach _weapons;
};
case east:
{
{ createVehicleCrew ("O_TargetSoldier" createVehicle (getPos _x)) } forEach _weapons;
};
}; ```
nor weapons do have sides 😄
I just stated that above
well it's up to him to make variable names 🤷 but as I see _weapons is an array of objects
stated that as well
yes
Quote me: I'm currently struggling what would be the best way to make the switch statement work because side obviously doesn't like arrays. Should I split the input array or what would you guys do
forEach?
{ // forEach _weapons
private _side = side _x;
switch (_side) do {
case west: { };
case east: { createVehicleCrew ("O_TargetSoldier" createVehicle (getPos _x)); };
default {}; // Aliens
};
} forEach _weapons;
(but _weapons is really a wrong var name in this matter)
well depends. Objects are a SAM Launcher and a SAM Radar
This discussion belongs to #style_discussions 😄 oh wait we don't have that
no moar channels plz
no moar channels plz
#new_channels_discussion
my bad then @hollow lantern ; may I suggest _samSite?
but what Sparker said (the forEach code, not the #new_channels_discussion!!)
@astral dawn
but really, could you maybe replace all your calls to your functions with some macro of yours, which calls footer, calls your code, then calls the header?
I could but I might wanna build a little aspect adding function for other cases, too.
hmm yeah probably need to learn more to use forEach, I'll test that right away, thanks
I'd even suggest this @hollow lantern
{ // forEach _weapons
private _objectHandle = _x;
private _side = side _objectHandle;
private _className = switch (_side) do {
case west: { "B_TargetSoldier" };
case east: { "O_TargetSoldier" };
default { "UFO_Soldier" }; // Aliens
};
createVehicleCrew (_className createVehicle (getPos _objectHandle));
} forEach _weapons;
uh oh ok, interesting
Or even this 🤔
{ // forEach _weapons
private _objectHandle = _x;
private _sideID = [WEST, EAST, INDEPENDENT] find (side _objectHandle);
if (_sideID != -1) then { // Sanity check
private _className = ["W_TargetSoldier", "O_TargetSoldier", "I_TargetSoldier"] select _sideID;
createVehicleCrew (_className createVehicle (getPos _objectHandle));
};
} forEach _weapons;
woah lol, 
hahaha if someone makes one better iteration of this, we can make a meme 😄
maybe something like
{
[side _x, getPos _x] call CBA_fnc_createInvisibleTarget;
} forEach _weapons;
If there was such a CBA command
would buy it /s
but yeah I use CBA in my test mission as well so it would work if there was one
Hi, I would like to ask about moving an animated entity while it's attached to a vehicle, and this vehicle moves.
As far as I've tried, the entity stays at the position where it was attached at the start when the vehicle moves. (and so not being "attached" anymore and just standing in the air)
Anyone got a way to script that properly ?
like moving in the back of a driving truck, or just moving as "placing it somewhere else"?
There was a mod for walkable moving ships or something liek that
I think he was messing with attachTo, not sure
More like Character is atop a tank, sitting animation, tank moves, guy plays the dismount animation, starts talking.
Thing is, character is in sitting animation, tank moves, guy stays in mid air instead of staying on the tank
I also was not able to change it's orientation and had to use a chair, but ended with the same issue.
well why don't you do attachTo?
hmm weird!
yup
what if you do attachTo on each frame then, while the animation is playing?
and yes, I tried using setDir and the other one specially made for attachTo
mmmm
that could work
though I have no idea how to make a loop in Arma's synthax
hopfully it's only at the start, so I guess ressource wise it's all good
addMissionEventHandler ["EachFrame", {
// no params
}];
Ho, I was looking for a simple DoWhile, but this seems perfect ahah.
no no, where would you put the while-do{} ?
in a spawn? should not put that into a spawn
I'd figure out something I guess
…show us your attachTo code and surroundings
Yeah maybe it's not attaching anything at all? 🤔
Hol' on
Cmd switchMove "Acts_NATOCommanderArrival_Commander_1";
Sleep 2;
detach Cmd;
Cmd switchMove "Acts_NATOCommanderArrival_Commander_1";
Cmd playMoveNow "Acts_NATOCommanderArrival_Commander_2";
I think you need to switchMove into some animation the AI can get out
like the generic walking animation
like if you add Cmd switchMove "AmovPercMstpSrasWrflDnon"; at the end, he will be able to recover from his animation
but I don't know animations, better ask in #arma3_animation maybe?? AFAIK a limited set of animations has transitions to other animations, and if there is no available transition, character gets stuck.
Correct me if I'm wrong.
I actually tried with the combat ambient anim "sit"
Like just for bug test, it's not that the animation doesn't play, it's that, it doesn't stick with the moving object despite being attached to it
but when not animated, it keeps attached to it and moves along it
weird, for me a guy gets attached to a tank and plays some animation
while I drive
then he detaches, you have a detach command there
yeah, but in the test I did not used an attach command
Basically, my test script was something like
AI attachTo Object [XX,YY,ZZ];
AI switchMove "SIT";
And then I'd drive the tank
AI attachTo Object [XX,YY,ZZ];
syntax is wrong
although it's right in your initial script 🤷
yeah, I just did that on the fly for the example, I don't remember all the synthaxing, but in the test it was the correct one.
oh wait
, it doesn't stick with the moving object despite being attached to it
what do you mean?
sooo is it attached or not?
or I don't understand
it is attached, but when the tank moves, for some reasons the AI under animation doesn't move with the tank and instead stay mid air at it's position of attach. (I know it's hard to understand, maybe I should take a screenshot)
as soon as this anim plays, the unit stays where it is in the air
But just attachTo is fine, even with the moving tank
(I suppose)
Here, let me give you a picturing, it's easier
https://imgur.com/a/HDjDglF
so which of the anims is that?
"SIT"
For the test, the AttachTo command is in the unit init
Really ? Damn, if it's that I'm feeling really dumb
ideally nothing in the init box
Welp, still the same issue through console and trigger execution
aaah wait
try without the anim
or attachTo (some time) after it
but first, let's try to get the attachTo working.
Okay, found it thanks to you
so, I need to animation first
Then sleep duing 0.02
Then attach
the BIS fnc attaches the unit to a gamelogic iirc, or something like that
Yeah, seems like I misunderstood how it was managed
glad to hear it works anyway 👌
Well, thanks for the help, now question is, can I use this to fix problem #2, being the orientation...
first attachTo, then setDir
yeah ^^'
?
no, just confirming
oh ok
setDir an attached object is relative to the direction of the object it is attached to: a.k.a setDir 90 = facing to the right of said object
not once attached, iirc at least
I mean we'll see, I'll input 260 and it should face west
270*
Details
Ah, you were right
Well, I mean right as correct, no as right. You get what I mean.
right
well thanks a lot, now it's coordinates playing time and syncing up with the player arrival for a cool intro
Purrfect! With pleasure 👍
🍪
hello im trying to simulate a sudden solar flare and i need all electronics to go off once a trigger is activated, ive looked for some things on the wiki but im sitting ducks here, id like so disable the GPS(not only on the map screen, but also on the quick view) and NVG googles. is that even possible?
@vernal jay something like this maybe?
while {_EMPActive} do
{
WaitUntil {CurrentVisionMode _Unit == 2 && _EMPActive};
_Unit action ["nvGogglesOff", _Unit];
};
while the EMP is active it will check if the player has their NVG's on(being used) and will turn it off if the player turns them on(it should anyways)
i tried it but it wont work, im sure im doing something wrong
what did you try
@exotic tinsel
its for error handling. i have something causing a generic error some where so i want to put something at the top of a bunch of functions that is general to fire before the error so i know where it happened.
Arma debug engine prints you a full call stack with all local variables on any error to RPT, without you having to add anything to your functions
14:17:06 "Error at L1 ()
Callstack:"
14:17:06 " [] L1 ()"
14:17:06 " [] L25 (A3\functions_f\Debug\fn_debugConsoleExec.sqf)"
14:17:06 " _this:[{st = 15 / 0;}]"
14:17:06 " [] L0 ()"
14:17:06 " [] L25 (A3\functions_f\Debug\fn_debugConsoleExec.sqf)"
14:17:06 " _x:any"
14:17:06 " [] L1 ()"
14:17:06 " _this:[]"
14:17:06 "CALLSTACK END;;;
"
14:17:06 Error in expression <st = 15 / 0;>
14:17:06 Error position: </ 0;>
14:17:06 Error Zero divisor
@astral dawn @frigid raven
You've got to check what happens if your function returns nothing though (nil or nothing)
Even worse, when the code returns nothing at all.
private _ret = call {
1 = 1;
}
Is error on the _ret = because you cannot assign anything to _ret because the call didn't return anything, because = is "bugged" and doesn't return anything.
@still forum isn't there any way to guard clause this somehow ?
So close but yet so far 😢
https://github.com/CBATeam/CBA_A3/pull/1214/files Like so I think
Ok I will try this 👍
Anyone know of a way to tell a group spawned in via script to get in a vehicle spawned at the same time that is part of said group?
@jaunty ravine you have to have this vehicle assigned to the group, then assign members to a seat, then allowGetIn them
The vehicle is already part of the group (rhs_group_rus_msv_btr70_squad).
then the other steps
https://sqfvm.arma3.io did a thing 🙃
It is bugged btw.
somehow it is not accepting changes when i switch to pretty sqf
uhm ...
wtf.
now it is?
what magic is this
I'm fixing it while youre testing 😄
prettyprint didn't actually write the script to file and used the file from last normal sqf
If more users gonna use this I probably shouldn't write everything into a single file
Does anyone know if there's a way to disable ACE fall damage on a unit by using a script in it's init?
Pulling me hair out, i can do it in vanilla but not with ACE
I somehow suspect you are -not- the real Danny DeVito
I like my MilSim between a shoot and the other
@winter rose Forgive me for pinging you but could you explain how I assign seats?
Okay, thank you.
Okay, so, and forgive my infinite ignorance, but how do I assign them as cargo to a vehicle that I'm about to spawn in? Just for context, here's my current code:
["Unit0","Unit1","Unit2","Unit3","Unit4","Unit5","Unit6","Unit7"] assignAsCargo ;
["Unit0","Unit1","Unit2","Unit3","Unit4","Unit5","Unit6","Unit7"] orderGetIn true;
Rwy_Bridges_1_QRF_Spawn = Rwy_Bridges_1_QRF addWaypoint [getMarkerPos "Rwy_Bridges_1_QRF_Spawn", -1];
Rwy_Bridges_1_QRF_Spawn setWaypointType "GETIN";
Rwy_Bridges_1_QRF_WP1 = Rwy_Bridges_1_QRF addWaypoint [getMarkerPos "Rwy_Bridges_1_QRF_WP1", -1];
Rwy_Bridges_1_QRF_WP1 setWaypointType "MOVE";
Rwy_Bridges_1_QRF_WP2 = Rwy_Bridges_1_QRF addWaypoint [getMarkerPos "Rwy_Bridges_1_QRF_WP2", -1];
Rwy_Bridges_1_QRF_WP2 setWaypointType "GETOUT";```
you can only assign as cargo after you've spawned the vehicle
My goal is to create a QRF that is a BTR-70 loaded with troop who spawn at Rwy_Bridges_1_QRF_Spawn and move to Rwy_Bridges_1_QRF_WP1 and unload at Rwy_Bridges_1_QRF_WP2.
Hold up let me test something.
immediately loaded with troops? movein* commands, moveInCargo etc
Yeah, either immediately loaded with troops or have the troops get in upon spawning.
also, ```sqf
player setDamage 1;``` → sqf player setDamage 1;
So far I've had the goal of making them spawn in then get in the BTR but it'd be preferable if they spawned already in the BTR.
"{alive _x} count allPlayers isEqualTo 0"
I usually use this to end the mission when all players are dead
if I wanted to make it blufor exclusive could I simply switch "allPlayers" with "BLUFOR" ?
all that instead of allPlayers right?
let me be lazy
allPlayers findIf { alive _x && side _x == blufor } == -1;```
wow I didn't even get close
thanks @winter rose and @still forum
Can anyone figure out why this piece of code spits out an error?
Rwy_Bridges_1_QRF_BTR setVehicleVarName "1_QRF_BTR";```
setVehicleVarName takes object, not array
https://community.bistudio.com/wiki/BIS_fnc_spawnVehicle spawnVehicle returns array
_enemy = allUnits select {!isPlayer _x && side _x == EAST};
is this ok to only select all ai east units?
@still forum kinda doubt it ... the discord bot also gets barely used 🤷
is there a universal value compare method? or do i have to actually figure out the datatype and use the proper compare method for each?
isEqualTo
it was already pinned in kp discord, chances are gud
player isEqualTo 1 // false "hello isEqualTo "Hello" // false 1 isEqualTo 1 // true
what about true isEqualTo ""?
prolly false
no error?
no error
don't think type juggeling is a thing
ok thanks
basically === of js/php or so
Next try for implementing these "aspects" around function calls fails by having undefined variables.
This is the "enriching" code snippet:
// given "_functionNameOrTags" = "coopr_fnc_getSkills"
private _function = missionNamespace getVariable _functionNameOrTags;
private _enrichedFunction = {
call _beforeAspect;
private _returnValue = call _function;
call _afterAspect;
_returnValue;
};
missionNamespace setVariable [_functionNameOrTags, _enrichedFunction];
When calling
coopr_fnc_getSkills it will return
{
call _beforeAspect;
private _returnValue = call _function;
call _afterAspect;
_returnValue;
}
Which surely is useless since every var in there is undefined.
I know that I have to have the code string to be written hardcoded in that codeblock for the _enrichedFunction but I have no idea how to do that. Also _beforeAspect and _afterAspect are surely misplaced here, too.
Here is the full function code: https://github.com/CoopR-Mod/CoopR-Mod/blob/294d2514051623af57b7be3fdd4434031cebf2f4/addons/core/helper/fn_addFunctionAspects.sqf#L64
you can use format to build it
your before/after/function will have to be global variables then
if they are global I only can run this function once right
no?
since another call would overwrite the globals again
better said give em another value/code
use format to build a string of code.
replace _function with %1 and use _functionNameOrTags
bam you now have the global variable name of your function in there
gotya
the before and after you probably want to make generic functions, where you just pass a argument to them
and the arguments values you again force into there using format
👍
that's an interesting bit of code, what is it supposed to accomplish?
callstack
to have a calltrace at some point
just pushback/popback on an array
something that ArmaDebugEngine already does with 0 effort 😉
just what i was about to say 😉
Yes I have suggested him ADE a lot of times but any way 🤷
I don't get it, which variables are undefined in your function xetra11? And why do you do private _returnValue = call _function; instead of private _returnValue = _this call _function; ?
Although... _this will still be passed into that probably
but why not just have something like this?
calltrace = {
params["_args","_fnc"];
trace pushBack [_args, _fnc];
_ret = _args call _fnc;
_ret;
};
[["hello"], { params["_msg"]; hint _msg; }] call calltrace;
diag_log str trace;
that would involve replacing each function call with a custom function call I guess
And he refused that
asking for a bit too much in my opinion 😄
replace call fnc = no go, memory based solution = no go, oof
{
call _beforeAspect;
private _returnValue = call _function;
call _afterAspect;
_returnValue;
}
ah ok, so _function is undefined. Why do you do it like this instead of the approach you took initially, which converted code to string, added strings at start and end, then compiled them back?
ah nevermind, it's the same as Dedmen suggested
Although... _this will still be passed into that probably
if you don't pass _this, Arma will just see the _this variable in the higher scope and use that, so passing _this is redundant
yes I see || the damn arma passing of local variables through a call ||
BTW format seems to have a character limit
#armadebugengine
_enrichedFunction = compile format ["'%1' call XTR_beforeAspect; private _returnValue = call %1; '%1' call XTR_afterAspect; if (isNil '_returnValue') then {nil} else {_returnValue}", _functionNameOrTags]
like this
before pushes onto callstack, after pops it
problem with that approach is, you need to keep the callstack seperate betwen multiple scripts
solution would be to store it in a local variable that you have created at the top level
but you don't really have control over that
actually. no real idea how to solve that
SQF doesn't have a way to see which script stack you are in
idk if i'm retarded but i still don't have any clue whats the point of this XD
achieve ADE callstack dump without ADE and without actually dumping variables
every spawned script has a seperate stack, or every eventhandler. There's not really a way to tell which you belong to
Are you gonna run ^^ what dedmen posted with like { _enriched.... } foreach allVars select {_x typeName == "code"}?
You will have to add a
_thisCallstack = [] variable, at the top of every new script that starts, and then just use it in the before/after functions and implicitly grab the variable from the higher scope to pushBack/popBack from it.
But... How are you gonna get the top of every new script? especially when your code is called from say a trigger, or some other function that you don't control
Ideally we'd want __FILE and __LINE macros in our callstack, but for that we would need to wrap every function call outside, not inside I guess
I think he only wants it for his own functions
Are you gonna run ^^ what dedmen posted with like { _enriched.... } foreach allVars select {_x typeName == "code"}?
That's what I suggested yeah
But I think thatI think he only wants it for his own functionsis the more likely case
Hmpf, interesting
Since thye're gonna be compileFinal'd for the production version anyways, so why not use ADE for debugging?
He doesn't want it for production
I would kindly ask everyone to run an ADE for easier debugging to be honest
Lack of callstack and memory dump in SQF is such an utter BS
You get a memory dump when a program crashes, why not have it for SQF >_>
{
call _beforeAspect;
private _returnValue = call _function;
call _afterAspect;
_returnValue;
}
{
//if callstack doesn't exist yet, create it. Otherwise use the _callstack that already exists in a higher scope
private _callstack = if (isNil "_callstack") then {[]} else {_callstack};
call _beforeAspect; //This will pushBack into _callstack
private _returnValue = call _function;
call _afterAspect; //this will delete last element from _callstack
_returnValue;
}
tada
You can just put diag_log everywhere but that's same as asking me to debug a js app without chrome dev tools...
that will create your callstack variable as high as possible
hmm wait
🚶
function a {
0 call fnc_b;
1 call fnc_c;
};
can u not just use _thisScript to seperate between files/threads?
They will push into callstack to
ah nvm, we retrieve from callstack when we leave the function call, im stupid 😄
nice idea!
But _thisScript doesn't work with non-spawned
doesn't matter tho, there can not be multiple unscheduled stacks running at same time
but I think that's a bit harder, you have to turn _thisScript into a variable name so that you can put an array into it
i'm so confused, you're trying to run a replace on all code variables to add a call to add it to a stack trade on those, why not just log the thread (if any) and function name, that way you'd have a full stack of scheduled and non scheduled scripts?
He wants to log the stack when he needs it
doesnt _thisScript return the file name and/or name passed to scriptName
not always flood the RPT with everything that's going on
https://discordapp.com/channels/105462288051380224/105462984087728128/619249373024616448
That doesn't work as you're replacing the function in the global variable, you want to do something like
setVariable [_functioNameOrTags+"_orig", getVariable _functionNameOrTags]
before, and then pass +"_orig" into the format.
@frigid raven
idk if it's just me getting too used to somewhat verbose error messages working with vue and other ts/js apps and the very (except c/pp link errors) verbose error msg's of visual studio, that i dont really get the point of this.
I just deploy my code in small bits that are easy to test for syntax errors, as well as run my code through my sqf git CI, so I've never had a need to call stacks and so on...
until your code breaks because some other function 5 levels up somehow got a variable set to the wrong value. then you have a error 5 levels down and don't know where that wrong input ever came from because your function is called from dozens of places which could all be wrong
I've never had a need to call stacks and so on...
Not even for ADE?
ADE saved me so many times, with callstacks not even 5 levels deep but much much larger, without it it would be impossible to solve many of the errors
with vue and other ts/js apps and the very (except c/pp link errors) verbose error msg's of visual studio
Yeah all these give you callstacks
SQF doesn't
ADE is a great help, but i've managed years without it :D
When it comes to functions a few lvls up and code sending fucked up args, idk somehow i have this very rarely in sqf, either since it's not as oop as other languages or because the apps written in it are generally smaller and less complex or because it's the last thing i added 😄
And i'm not saying callstacks are useless or any of that, i'm just saying if you're trying to accomplish callstacks without changing the call fnc or using ADE, mby the time could be spent a bit better?
that probably yes. Though it's still a nice learning experience I'd say
Yeah I agree, I'd be glad to share my solution to that but it's buried in Git history long time ago 🤣
Well not directly to the callstack problem, but I... I don't remember why, but I was trying to add footers and headers to functions
that's easy to do with cba style mods, because you have control over the whole compilation pipeline :3
This is what I'd prolly do if i had to do it in script:
{
_code = missionNamespace getVariable _x;
_newCode = format["
[%1, _this] call calltrace_before;
_ret = _this call %1;
[%1, _this, _ret] call calltrace_after;
_ret;
", _code];
missionNamespace setVariable [_x, _newCode];
} foreach (allVariables select {typeName _x == "CODE"});
Tho i'd realistically do it by detouring call, spawn and execVM in memory
(if i couldn't use ADE)
typeName _x == "CODE" isEqualType {}
Aha
I cant test it right now as im on my laptop, but does getVariable throw an error if you try to use it on an object which hasnt had a variable set to it yet?
@surreal peak there is the alternative syntax, allowing for a fallback
oooo I didnt see that, thank you very much!
no it doesn't
I didnt find the syntax lou said, but I just realised it allows for a default return value which is close enough to what I want
That is what he is referring to and the alt syntax.
alternatively you can check the returned value for isNil
Another question: What is the least resource intensive way to constantly check for a certain simple object being created? Right now im using a FrameHandler from CBA which is used to loop a check for #slop in allMissionObjects although I understand that this is not very resource friendly
So you are just looking for a type/class in there? Not for a specific global var or anything? How is the object being created?
To make it easier to explain ill show the script:
_handle = [{
_bloodObjects = allSimpleObjects [ace_drop_1,ace_drop_2,ace_drop_3,ace_drop_4];
systemChat str _bloodObjects;
{
_isBlood = _x getVariable ["bloodDropAction",0];
if (_isBlood != -1) then
{
_arrow = "Sign_Arrow_Green_F" createVehicle (getPos _x);
_arrow setPos (_arrow modelToWorld [0,2,0]);
_x setVariable ["bloodDropAction", -1, false];
hint "found blood and highlighted";
};
} forEach _bloodObjects;
}, 1, []] call CBA_fnc_addPerFrameHandler;
im constantly searching for ace_drop's which are created in the createBlood part of ace 3
ive got the code working, but I would like to optimise it in a way that will not make it too complicated to expand the code
btw, in the actual script im not gonna do it every second, thats just because im testing
Fair enough, that would have been the obvious and simple way to gain some performance 
yeah 😄 Origianlly I was gonna make this only fire on the on "hit" event handler, although I think ill fully complete the script before that so i can learn a bit more about event handlers before diving feet first into them
That's probably a better bet, but even then, having this run on every hit may be a bit much for your usage too though.
I guess I don't get the point of the script. Is this to find all on the map and highlight them with an arrow? How often do you want to do this? Does this need to be for all blood, or just in a small area (like around a player)?
the arrow is for testing, in the end Im gonna make another object which is small and invisible spawn on the object, this will allow me to use ace interaction in order to clean the blood
Im planning on using this in more stealthy zeus missions where hopfully there shouldnt be too much blood
Then running it on "Hit" would seem to make the most sense.
ok thanks!
But don't do it for all objects. Use nearestObjects: https://community.bistudio.com/wiki/nearestObjects
And use a small radius that the blood can be in.
I assume nearestObjects still works for simpleObjects?
If it has an associated config class it should.
hmmmm
blood = nearestObjects [player,["ace_drop_1","ace_drop_2","ace_drop_3","ace_drop_4"],100];```
doesnt see any of the ace_drop 's
although when I leave the bracket which the ace_drops are in empty (to return all nearby objects) the ace_drops show up
That may still be more performant to do so, not sure. Hmm. Seems it doesn't support simples at all, or just those aren't classed, not sure.
on further look it returns the ace_drops as a p3d file
as in ace_drop_1.p3d
in allSimpleObjects im not putting the ace_drops in a string, but I cant do that for nearestObjects
Correct, that's not how the function works. 😦
soooo guess im using the inefficient method...
on Hit then seems excessive. Maybe just a loop checking every few seconds?
since thats what im doing, that seems good