#arma3_scripting

1 messages Β· Page 186 of 1

meager granite
#

It should as animate is global so server will control the door without clients being involved

molten barn
#

Right will check that now then to make sure.

formal grail
#

Instead of hard coding 22, you can also:
private _doorNumber = getNumber (configFile >> "CfgVehicles" >> typeOf _building >> "numberOfDoors");

meager granite
#
_MaxDoorsInHouse = 22;          //<----------------------- Maximal number of doors in da house - current 22 doors - CAN CHANGE!!!!
```I just used Open Door Module approach, I guess `numberOfDoors` wasn't a thing back then
#

The most proper way would be finding exact animation names you want to use and just iterating through that

#

but brute forcing 1 to 22 isn't a big deal either

molten barn
#

Worked with server only ticked. Again thank you so much for the help.

meager granite
molten barn
#

Right, will do

#

Worked as well.

#

Minor note, is there a way to get rid of the "Open Door" option on the door it self?

granite sky
#

IIRC you can disable simulation on the building, but then that would probably interfere with your direct open/close.

meager granite
#

Hmm, have it as simple object and use animateSource instead?

#

Never tried it

formal grail
mint flame
#

Yo guys is there any script to make a bomb fall precisely on a building , i have drongos mod but the plane drops the bomb in a dumb way not accurately, like GPS

#

but physical plane needs to be involved

charred monolith
#

Maybe with Zeus enhanced ? I know You can place module that spawn a plane and it drop the projectile where you want it to be of course you want it to be scripted but maybe you can find what you want in the code ?

rugged spindle
#

Group was the first thing I checked, it's only in the unit. The weird part is the error message changes.

But good call about the tags, might be some conflict. I'll try that later today. Thanks!

meager granite
#

Also depending on a bomb you can spawn target and setMissileTarget the bomb to it

mint flame
meager granite
#

Maybe it can work without valid target, there is alt syntax with force now

#

Basically, try setting you missile target to your target building after you fire it

mint flame
#

okay so do i have ti modify thr mods funcs

#

it lets me select a bomb and target, and then drops it, but it drops it in a dumb wsy

#

so i have to make it like set missile target within the mods funcs

#

I want to do it as UAV controller/jtac

meager granite
#

How do you drop it right now? Some kind of own script?

mint flame
#

I have FIR AWS mod and Drongos air Operations

#

I can command the plane to bomb somewhere and then if its LGB i can lase with UAV

meager granite
#

No idea about these mods

#

I just want to know what you do script wise in your mission

mint flame
#

But if its GPS, the mods dont knoe how to put thr GPS target on the pylon

#

I hsve no scripts atm i use mods completely for this

#

I was trying to set te GPS data by script on thr pylon beforr bombing but im not able to decipher this mods functions

meager granite
#

As a test concept, try putting needed setup in editor and add Fired event handler to the plane

#

And see if this command actually fixes it for you

mint flame
#

You see ?

#

This UI only works for the plane locally

#

I m not able to set another planes pylons and targets

(Singleplayer)

meager granite
#

No idea about these mods, never used them to tell

mint flame
meager granite
#

Sure, you get all kind of info in Fired event handler

mint flame
#

so i can say if drongos air op mod brings this jet and makes him drop X bomb he needs to setmissile target that i set with the mod

meager granite
#

You'll need to see how that mod sets the target to get it in Fired

mint flame
#

and then I can bypass the mods GPS guidance and the bomb will go there

meager granite
#

No idea if you can, maybe it does some manual guidance magic and it will ignore missile target

mint flame
#

Wrll it would just be easier if we can set GPS data for the bomb

#

Then all we do is drop it

meager granite
#

Thing is, guided projectiles can be manually assigned a target through script nowadays and you can try using that

#

You'll need to figure out how these mods work to integrate into them

#

Can't help you with that

mint flame
#

Yeah, i still wanna use the mods becus of their UIs

mint flame
meager granite
#

Nope, sorry

#

There might be people willing though

mint flame
#

Okay nice

hushed turtle
#

Do I need to set AI subskills individually or setskill 0 alone does the job?

remote cobalt
#

Hey folks, I have a question and maybe you have already a way better / good way to handle it.

My problem is when I have a Yes/No question dialog (with BIS_fnc_guiMessage) that is called by an HoldAction, most of the times you trigger the default answer because you were holding the space bar a tiny bit to long.

I solve this right now by putting in a little 0.5 sleep. It feels somewhat unresponsive but it is the only way I know to handle this. Is there any better way to handle this?

cosmic lichen
#

Not really. It's because the button is set to default = 1

#

you can try to set the focus to a different control as soon as the UI is available but that might be too late already.

#

Alternatively you can try BIS_fnc_3DENShowMessage

remote cobalt
proven charm
mint flame
#

@formal grail eow really ?

timber shore
#

would it be better to have my code in missionfile or in an external addon?

#

as for execution speed

jade abyss
#

Yes

timber shore
#

yes, missionfile?

hushed turtle
# proven charm setskill sets the sub skills to same value so no need for anything extra

That's what I think, but I was talking about it with ChatGTP and he was convinced, that doing it individually leads to different results, despite me telling him, that both skill and skillFinal return same values, regardless if set individually or not.

It seems to me that AI skill in this game can be all over the place. Like playing same mission multiple times, same settings, same everything. But sometimes balance feels just fine and other times AI is like wiping floor with me

atomic niche
jade abyss
#

Banana!

cyan thunder
#

the last argument to say3D isn't working, _songObject = _vehicle say3D [_songName, 300, 1, 0, 0, false]; (last false) if I'm reading the docs right should disable doppler shifting yet it still happens, it's exactly the same as if that argument is true - what stupidity am I commiting here?

timber shore
#

cake is nice

jade abyss
#

(iirc, it doesn't rly matter)

#

Yeah, that also!

proven charm
hallow mortar
cyan thunder
#

mostly so I can very quickly switch the AI skills based on whether players are curb stomping them or getting flattened by them

#

also lets me have automatic profiles applied for infantry, units I've marked as "spec ops" (skills boost) - to the point where when players see a boat screaming towards a beach they scream "SPEC OPS" on the radios 😈

hushed turtle
cyan thunder
#

I've seen similar things in zeused ops, sometimes four players can clear a town and take one uncon, the next town they can get utterly smashed vs the same amount of AI with the same profile - it's fog of war/luck I suspect

#

yeah I don't get this say3D thing at all either it's not applying the argument to the call or it's simply not doing the thing the way I'm reading the docs that it should

hushed turtle
#

So it looks like it's not just my imagination, if other people have similar experience

cyan thunder
# hushed turtle So it looks like it's not just my imagination, if other people have similar expe...

in those cases since it's a mission I built and I'm in the zeus slot, I know that setSkill isn't been touched - it's purely down to small variations in how the AI is perceiving players (I use lambs, I've turned debug on and watched it's evaluation loop), like (with lambs at least), if a unit spots you, it'll "inform" other units within range (which is configurable) - so if you get spotted a little earlier you are gonna have a completely different fight πŸ™‚ - I actually like that variance, the less predictable it is for a player the more fun it is

cyan thunder
hallow mortar
cyan thunder
#

damnit, then how do I disable the doppler shifting πŸ₯Ή

#

it's far far too aggressive, the pitch shift is way out of whack, a car passing at 10m/s ish shouldn't shift the audio that much

hushed turtle
#

There should be some variance, otherwise things might be to predictable. But shouldn't difficulty itself stay more consistent? It's a bit weird to easily clear town one time and other time get utterly smashed

granite sky
#

I've played a lot of Arma and I don't know what you're talking about tbh.

cyan thunder
hallow mortar
#

AI effectiveness doesn't depend only on the AI's skill. It's heavily affected by the players' skill. If they get themselves into a bad situation, or just fail to make their shots count, then they will die.

granite sky
#

The obvious difficult gradients in Arma are things like static weapon vs small arms accuracy.

hallow mortar
#

I've seen plenty of missions turn south in seconds because 3 guys in a row decided to feed themselves to an HMG

cyan thunder
granite sky
#

Shoot the guy with the HMG a second too late and your squad is dead. Run around like an idiot in front of a few riflemen, no problem.

cyan thunder
#

I spent a lot of time tuning my missions so that the players have an average K:D of ~5 (+/- 1) because they/we play as mercs and dying costs them money, and killing the AI earns them money πŸ˜„ I wanted it to be relatively neutral so that they have to be smart to make a profit

hushed turtle
granite sky
#

I've not properly tested it, but apparently suppression has a pretty strong effect. So if you start shooting first then it makes a big difference to AI accuracy.

cyan thunder
#

so does courage/fleeing

granite sky
#

For that reason it's really important to cut LOS to any enemies that you're not shooting at.

#

Leave one guy to shoot at you for free and things go badly.

#

Another weird Arma thing is that AI accuracy is very strongly dependent on the weapon they're using.

cyan thunder
#

it's why makeSniper does some horrible things in my code πŸ˜„ 😈

granite sky
#

There's a general principle that sniper/marksman rifles get much lower dispersion, but that means in some modsets the "basic weapons" are 5+ times more accurate then in others.

#

G3s in 3CB Factions for example.

cyan thunder
#

lets me make the AI lay in a bush wearing a ghille, shoot accurate, never fires tracer, never throws smoke (as lambs love to do because no sniper is popping smoke from their OP) - I've had 5 players bogged down for 25 minutes trying to find the sniper πŸ˜„

hallow mortar
granite sky
#

I don't think many modders actually realise that weapon dispersion directly affects AI accuracy.

#

you can fix it with the AI multipliers but they don't.

cyan thunder
#

dispersion in CfgWeapons is all over the place between mods as well, RHS and CUPS often have completely different values for the same basic weapon πŸ€·β€β™‚οΈ is what it is, mixing CUPS/RHS is always pain - you end up having to carefully tune ACE medical or you get terminator Russians with their body armour

#

I don't care how good they say it is, it shouldn't take 7-9 5.56 center mass to put them down, I tune for ~3 max because no one is taking 3 5.56 to the chest wearing a vest and shrugging that off

thin fox
cyan thunder
# thin fox Cool simple code, gonna use that

hey man, I think I know you from the lib discord (small world), ```sqf
params ["_unit", "_defaultStance"];

if(!(_unit isKindOf "Man" && alive _unit)) exitWith {true};

_newGuard = _unit;

// Set to watchful but not combat;
(group _unit) setCombatMode "YELLOW";

// Clear any existing event handlers
_newGuard removeAllEventHandlers "AnimChanged";

_guardUnitPosture = "";
switch (_defaultStance) do
{
case "prone": { _guardUnitPosture = "DOWN"; };
case "crouch": { _guardUnitPosture = "MIDDLE"; };
case "stand": { _guardUnitPosture = "UP"; };
default { _guardUnitPosture = "UP"; };
};

// Stop them moving around
_newGuard disableAI "PATH";

// Make them lie down
_newGuard setUnitPos _guardUnitPosture;
_newGuard setBehaviour "SAFE";

// If they try to stand up/crouch, make them lay the fuck back down
_newGuard addEventHandler ["AnimStateChanged",
{
params ["_unit", "_anim"];

if (canStand _unit) then {
    _unit setUnitPos _guardUnitPosture;
}; 

}];``` similar thing but makes them guards (just a quick way to make them stay in one spot, in one animation state and not move off) - handy for guard towers or where you want to stick a dude with a PKM somewhere and have him not move

thin fox
#

that trick with that EH I know xD very useful indeed

cyan thunder
#

I'll have nicked it from somewhere as well, - taking mods apart to see how they do what they do is like 80% of how I figured out how to do the things I wanted to do πŸ˜„

#

(rest was biki and the forum...if they ever fix it πŸ™ˆ )

#

man Drongo does good work, he's released a mod that does a far better version of the thing I was gonna build this week for our next op 😁 - now I just need to integrate my stuff into it

pale wagon
#

Drongo does everything good

cyan thunder
broken pivot
#

Hey there ^^
Does anybody know a way to get the units of the createVehicleCrew

Thats how Ive did:

_sascha_crew_fzg1_grp = _sascha_crew_fzg1 createVehicleCrew _sascha_konvoi_fzg1;

_sascha_crew_fzg1_fahrer = units _sascha_crew_fzg1_grp select 0;
hint format ["%1", _sascha_crew_fzg1_fahrer];

But Im getting the return "any"

cyan thunder
hushed turtle
#

Also you can crew _vehicle

broken pivot
#

OMG hahaha

broken pivot
hushed turtle
#

) after select 0

broken pivot
#

What do the ( ) part do? return " any "

granite sky
#

It doesn't do anything. The precedence was already correct.

#

If that's returning nil then createVehicleCrew failed to create a group with units in it.

broken pivot
#

I can see them

#
_sascha_crew_fzg1_fahrer = crew _sascha_konvoi_fzg1 select 0;
hint format ["%1", _sascha_crew_fzg1_fahrer];

Return "any"

cyan thunder
# broken pivot I can see them
_classes = (crew _this) apply { typeOf _x};
systemChat str _classes;``` if you want the array of classes for the crew works (I just tested it from zeus hence the `_this`)
granite sky
broken pivot
#
_sascha_konvoi_fzg1 = createVehicle ["rhs_tigr_sts_msv", [3430.88,12672.6,4.76837e-07], [], 0, "CAN_COLLIDE"];
_sascha_konvoi_fzg1 setDir 210;
_sascha_konvoi_fzg1 setVehicleLock "LOCKEDPLAYER";
cyan thunder
#

so if I was doing it, I'd just cheat, spawn a vic of that class off map somewhere, spawn the crew, grab the classes of the crew (as above) then delete both

#

I've done worse things πŸ˜„

broken pivot
#

Ill have to read about apply and typeOf

granite sky
#

no, your code should work. Checking it.

broken pivot
cyan thunder
# broken pivot Ill have to read about apply and typeOf

apply is just map in any other language, takes an array, applies a function to it, creates a new array with the result of applying that function to each element, (hence why it's called map most of the time, it maps an arrary via a function to a new array) πŸ™‚

#

typeOf is just the class that was used to create the _entity - both are super common when working with units/vehicles via scripts

granite sky
#

Works fine in debug console:

_sascha_konvoi_fzg1 = createVehicle ["rhs_tigr_sts_msv", getPosATL player, [], 0, "NONE"];
_sascha_crew_fzg1_grp = createVehicleCrew _sascha_konvoi_fzg1;

_sascha_crew_fzg1_fahrer = units _sascha_crew_fzg1_grp select 0;
_sascha_crew_fzg1_fahrer;
#

But yeah, if you're just trying to get the classname of the unit then you're doing it wrong.

#

You can get that without even spawning the vehicle.

broken pivot
#

I want to select the driver to do an doFollow with the driver of another vehicle

#

At all its a convoy

cyan thunder
#

I think Does anybody know a way to get the units of the createVehicleCrew was what he asked, I took that to mean he wanted the actual classes of the composition of the crew but it looks like he just wanted the group that was created maybe

cyan thunder
broken pivot
#

#knowledgeGap

cyan thunder
#

api surface on arma is vast πŸ™‚

#

been screwing with it for a year and I still find functions I've never seen before - usually from reading mod source code and a "huh...didn't know you could do that"

hushed turtle
#

DoFollow works for convoys? tanking

cyan thunder
#

@broken pivot https://community.bistudio.com/wiki/moveInDriver is handy in some contexts as well - I have a function that takes an array of crew classes and cargo classes (passengers) and will fill the vehicle (correctly getting the slots for crew/cargo because that's wonky) and I use that there to specify which crew unit drives the vehicle

cyan thunder
granite sky
#

doFollow just switches units back to their default behaviour of following the group leader.

cyan thunder
#

probably want forceFollowRoad and setConvoySeparation

left haven
#

Hello everyone, hope you're doing well. Dipping my toe into the world of writing some scripts myself, using various resources online. Long story short, I'm trying to create a mod that creates sectors which will be contested over by an attacking force and a defending force. Currently having issues with it; so basically my PBO structure looks as above with the PBO manager (I packaged this via Arma 3 Tools), my config file looks a bit like the 2nd image. However, when i start the game, i get "Script functions\fn_genSec.sqf not found". Any pointers?

granite sky
#

In theory you can make a convoy by putting all units in multiple vehicles into one group and then using setFormation to get them into a column.

#

IIRC it works extremely poorly though.

cyan thunder
granite sky
#

To be fair they do that even if it's a single vehicle.

#

There's a road south of Therisa where some vehicles do that tree lurch pretty consistently :/

cyan thunder
#

players saw the destroyed vics, drove straight through the minefield.... πŸ™ˆ

hushed turtle
#

I tried convoy just recetly. Vehicles in same group, formation for convoys, safe behaviour, limited speed for leading vehicle and it looked great

cyan thunder
#

that seems to be the most reliable way, is simple enough I never bothered to automate it

broken pivot
cyan thunder
#

if you have two vehicles grouped together, then you can just get unit that is the formation leader with formLeader on any vehicle - that's why you have to sync "behind" vehicles to the "leader" vehicle to use the Convoy Parameters stuff in zeus πŸ™‚

broken pivot
#

Haha im now reading about setLead

cyan thunder
tender fossil
cyan thunder
#

one day I'll add a !convoy command to my command line but it has pain written all over it (and I don't do it enough) that the time spent automating it will never be paid back from using it πŸ˜„

#

I already have enough commands (bottom left), πŸ™ˆ

broken pivot
#

There is a diffrent between groups and teams?

left haven
#

at first i thought i wasn't referencing, sorry

hushed turtle
tender fossil
hallow mortar
# broken pivot There is a diffrent between groups and teams?

In Arma technical terms, yes. A Group is a proper group as displayed in the Editor. A Team is a sub-unit of a Group, but it's a system that was never really fully implemented and isn't useful for anything.
Team Member is a unique data type and isn't interchangeable with an ordinary Unit, so watch out for that if a command requires it.

#

Sometimes, in general usage, a Group will be referred to as a "team", e.g. "sniper team", but this is a doctrinal description, not technical.

split ruin
#

you can split squad to fireteams and if you don't use it for some tactics its bad for you, very basic strategy is to make blue fireteam take good position and red team to harass enemies and lure them where blue fireteam take them out

hushed turtle
hallow mortar
#

Basic colour teams aren't the same as the Teams system

split ruin
#

you assign them, then choose what fireteam to do what you want, what else u need ?

hallow mortar
#

I'm talking about a specific technical thing, not the general principle of a sub-team.
The colour team system accessible from the commanding menu is not the same thing as the system I'm talking about.

split ruin
#

you have all the space you want to tell us about the system u need

hallow mortar
split ruin
#

so thats it, a name instead of a color

hallow mortar
#

There is a partially-implemented system for teams, with a unique Team Member data type, which was added in Arma 2 but never properly integrated into the game. It's not accessible through normal gameplay and is not very well-documented or generally used. However, script commands for it still exist, and they occasionally trip people up because of confusion over the difference between a Team and a Group.

cyan thunder
#

which is how it is in practice

#

quotes because it's all just groups

#

two hard problems in computer science, cache invalidation, naming things and off by one errors πŸ˜„

split ruin
#

yes, because colors are better, fireteams are for tactics in the squad, not to make anoher squad inside the one existing

#

the only thing to improve is to access fireteams faster with a hotkeys

atomic niche
hallow mortar
# split ruin yes, because colors are better, fireteams are for tactics in the squad, not to m...

That might be why development of the Teams system was abandoned. Or maybe they just couldn't make it work. We don't really have much information about it.
The idea could have been to make Groups work for larger elements, so instead of having a platoon of several Groups each representing a subunit of the platoon, you would have the platoon as one Group made up of several Teams. In theory, that would let the platoon work as one cohesive unit, instead of the standard system of Groups being basically unaware of each other. But I don't know for sure.

split ruin
#

uh yeah, splitting squad to blue, red, etc fireteam has nothing to do with fireteams, but your name is green so you are porbably right

hallow mortar
#

In technical terms, the colour team system has nothing to do with the other Teams system, which is what the original question was about. Again, not really a discussion about the general concept of "a team".

split ruin
#

@hallow mortar first try to command a squad, then think about platoons

hallow mortar
#

Just to make it clear, I'm talking about the internal workings of the Arma engine and the AI. This isn't about doctrine or tactics. This is about a specific actual system that exists in the engine.

candid narwhal
#

does

side cursorTarget;

give me the side of what I am looking at
like:

_some_ai_side = side cursorTarget;
//_some_ai_side ~== EAST

meaning I could eval:

side player != side cursorTarget;
// if they are not the same thi is true

???

#

thx

broken pivot
#

Good evening. Im puking about everything at the moment. What the fuck is wrong with the game if your tryna do a convoy.
There is a follow waypoints thats still on the Beta state of the game. Its just called "Waypoint" in every language...

If you try to attach waypoint then he wont refresh new positions. So hes driving to the point where its created and not move to the attached object.

Guys how can I let one unit follow the other? (Diffrent groups)
It feels like a gap in the engine... Or am I using "waypointAttachObject/Vehicle" wrong?

hushed turtle
#

Do you really need vehicles in individual groups?

#

How do you attach waypoint? I don't think you can do that

candid narwhal
#

So..... why does this action only show up on things that are on my side???

[
    player,                                            // Object the action is attached to
    format ["<t color='#0000FF'>%1</t>", "force"],                            // Title of the action
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_secure_ca.paa",    // Idle icon shown on screen
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_secure_ca.paa",    // Progress icon shown on screen
    "cursorTarget isKindOf 'Man' && alive cursorTarget",    // Condition for the action to be shown
    "player distance cursorTarget < 5",                        // Condition for the action to progress
    {},    // Code executed when action starts
    {},    // Code executed on every progress tick
    {
        [cursorTarget, player] remoteExec ["pada_fnc_force_surrender", 2];
    },// Code executed on completion
    {},    // Code executed on interrupted
    [],                                                    // Arguments passed to the scripts as _this select 3
    1,                                                    // Action duration [s]
    100,                                                    // Priority
    false,                                            // Remove on completion
    false                                                // Show in unconscious state
] call BIS_fnc_holdActionAdd;
winter rose
candid narwhal
#
"cursorTarget isKindOf 'Man' && alive cursorTarget",    // Condition for the action to be shown

this is what makes the action "visible" and I do not see why it is behaving this way

winter rose
#

cursorTarget is sensitive to whether or not you are "aware" of said entity

PS: use "CAManBase" instead of "Man" as "Man"… can also be a rabbit πŸ˜„

candid narwhal
#

copy, will try. ItΒ΄s a "knows about" thing?

And copy, will adjust to CAManBase

winter rose
candid narwhal
broken pivot
hushed turtle
#

What power?

#

Vehicles of different speeds?

#

Accornig to wiki waypointAttachObject doesn't work in A3

broken pivot
broken pivot
hushed turtle
broken pivot
winter rose
broken pivot
hushed turtle
#

And what's wrong with that?

broken pivot
#

It wont follow

#

It stops

#

Example:
Vec1 is at posA
waypointAttachObject triggers
Vec2 goes to posA during Vec1 goes on
Vec2 reaches posA waypoint is completed
WHAT DA FAQ

winter rose
#

they should move, but the waypoint should not complete if the attachment is done

however
you are linking that to a trigger - that's a different command!

#

waypointAttachObject is to e.g attach a "destroy" waypoint to a building
I will add a disambiguation to the page πŸ™‚

hushed turtle
#

Name of the command sounds to me like attaching object to the waypoint rather than other way around

#

Was wondering what the command is for

#

But whatever, back to the convoy. Why can't you put all convoy vehicles into the same group?

broken pivot
# winter rose (or https://community.bistudio.com/wiki/synchronizeWaypoint)

Like that: ?

_sascha_crew_fzg1_wp0 = _sascha_crew_fzg1 addWaypoint [[3079.82,12357.8,-3.8147e-06], 0, -1, "start"];
_sascha_crew_fzg1_wp1 setWaypointType "MOVE";
_sascha_crew_fzg1_wp1 setWaypointBehaviour "SAFE";
_sascha_crew_fzg1_wp1 setWaypointFormation "COLUMN";
_sascha_crew_fzg1_wp1 setWaypointSpeed "LIMITED";
_sascha_crew_fzg1_wp2 = _sascha_crew_fzg1 addWaypoint [[3664.38,11968.4,0], 0, -1, "start"];
_sascha_konvoi_fzg1 limitSpeed 50;
_sascha_crew_fzg1_wp3 = _sascha_crew_fzg1 addWaypoint [[4206.58,12238.2,2.28882e-05], 0, -1, "start"];
_sascha_crew_fzg1_wp4 = _sascha_crew_fzg1 addWaypoint [[4675.77,12859.3,2.86102e-05], 0, -1, "start"];
_sascha_crew_fzg1_wp5 = _sascha_crew_fzg1 addWaypoint [[5018.1,13686,0], 0, -1, "start"];
_sascha_crew_fzg1_wp6 = _sascha_crew_fzg1 addWaypoint [[5176.24,14480.6,1.33514e-05], 0, -1, "start"];
_sascha_crew_fzg1_wp7 = _sascha_crew_fzg1 addWaypoint [[6780.75,15433.5,0], 0, -1, "start"];
_sascha_crew_fzg1_wp8 = _sascha_crew_fzg1 addWaypoint [[7395.99,15425.9,-9.15527e-05], 0, -1, "start"];
_sascha_crew_fzg1_wp9 = _sascha_crew_fzg1 addWaypoint [[8893.38,14723.7,-0.000225067], 0, -1, "start"];
_sascha_crew_fzg1_wp10 = _sascha_crew_fzg1 addWaypoint [[9132.5,15786.8,-3.8147e-05], 0, -1, "start"];
_sascha_crew_fzg1_wp11 = _sascha_crew_fzg1 addWaypoint [
_sascha_crew_fzg1_wp12 = _sascha_crew_fzg1 addWaypoint [
_sascha_crew_fzg1_wp13 = _sascha_crew_fzg1 addWaypoint [[9078.48,16015,0], 0, -1, "start"];
systemChat "WP erstellt";
        
_sascha_crew_fzg2_wp0 = _sascha_crew_fzg2 addWaypoint [[3079.82,12357.8,-3.8147e-06], 0, -1, "start"];
_sascha_crew_fzg2_wp1 setWaypointType "MOVE";
_sascha_crew_fzg2_wp1 setWaypointBehaviour "SAFE";
_sascha_crew_fzg2_wp1 setWaypointFormation "COLUMN";
_sascha_crew_fzg2_wp1 setWaypointSpeed "LIMITED";
_sascha_crew_fzg2_wp2 = _sascha_crew_fzg2 addWaypoint [[3664.38,11968.4,0], 0, -1, "start"];
_sascha_konvoi_fzg2 limitSpeed 50;
_sascha_crew_fzg2_wp0 synchronizeWaypoint _sascha_crew_fzg1_wp0;
winter rose
#

well, maybe πŸ˜„

broken pivot
#

Love you ❀️

#

The second vehicle just turned around after a while and started the waypoints from 0

hushed turtle
#

Is it even possible to do convoy where each vehicle has it's own group?

broken pivot
#

I dont know but I do this for the case the players fale in ambushing so the convoy can continue after dismounting

#

But I gues thats tought too easy.

hushed turtle
#

You could split them into separeted groups once convoy gets ambushed, if you really want to

broken pivot
#

At first I need to fix that they dont complete the waypoint

#

It just happens

#

Ahhh, if I synchronize them, all members need to complete the waypoint before the next begins.

#

Only logical to let the 1st vehicle stop so the following ones cant complete their ones AHHHHHHHHHHHHH

hushed turtle
broken pivot
#

Yeah, thats that

#

Ill put them now into one group so we can copy your variant

#

Im getting aggressiv after 13 hours of this shit

#

This should do:

(units _sascha_crew_fzg2 ) join _sascha_crew_fzg1;
(units _sascha_crew_fzg3 ) join _sascha_crew_fzg1;
(units _sascha_crew_fzg4 ) join _sascha_crew_fzg1;
(units _sascha_crew_fzg5 ) join _sascha_crew_fzg1;
(units _sascha_crew_fzg6 ) join _sascha_crew_fzg1;
(units _sascha_crew_fzg7 ) join _sascha_crew_fzg1;
(units _sascha_crew_fzg8 ) join _sascha_crew_fzg1;
#
waitUntil {unitReady [_sascha_grp1_1, _sascha_grp1_2, _sascha_grp1_3, _sascha_grp1_4, _sascha_grp1_5];};
systemChat "Ready";
if (unitReady [_sascha_grp1_1, _sascha_grp1_2, _sascha_grp1_3, _sascha_grp1_4, _sascha_grp1_5])
    then {
_sascha_crew_fzg1_wp0 = _sascha_crew_fzg1 addWaypoint [[3079.82,12357.8,-3.8147e-06], 0, -1, "start"];
        _sascha_crew_fzg1_wp0 setWaypointCompletionRadius 15;
        _sascha_crew_fzg1_wp0 setWaypointType "MOVE";
        _sascha_crew_fzg1_wp0 setWaypointBehaviour "SAFE";
        _sascha_crew_fzg1_wp0 setWaypointFormation "COLUMN";
        _sascha_crew_fzg1_wp0 setWaypointSpeed "LIMITED";
        _sascha_crew_fzg1_wp2 = _sascha_crew_fzg1 addWaypoint [[3664.38,11968.4,0], 0, -1, "start"];
        _sascha_crew_fzg1_wp0 setWaypointCompletionRadius 15;
        _sascha_konvoi_fzg1 limitSpeed 50;
        _sascha_crew_fzg1_wp3 = _sascha_crew_fzg1 addWaypoint [[4206.58,12238.2,2.28882e-05], 0, -1, "start"];
...
hushed turtle
broken pivot
#

Thats done

#

But how do they keep distance if the speedUp is diffrent from vehicle to vehicle

hushed turtle
#

Make sure first vehicle is slowest, you can do that using limitSpeed

#

Set it to something little smaller tham speed of slowest vehicle, so it can catch up if needed

broken pivot
#

Already in code. But if they drive up an mountain the acceleration fucks the formation

#

Im using 30km/h

hushed turtle
#

Yeah heavy vehicles like tanks are gonna be a lot slower up hill

broken pivot
#

Thats my result. Chaos

#

They are driving diffrent directions, wont stay in order

hushed turtle
#

Formation is column and behaviour safe?

broken pivot
#
_sascha_crew_fzg1_wp0 = _sascha_crew_fzg1 addWaypoint [[3079.82,12357.8,-3.8147e-06], 0, -1, "start"];
        _sascha_crew_fzg1_wp0 setWaypointCompletionRadius 15;
        _sascha_crew_fzg1_wp0 setWaypointType "MOVE";
        _sascha_crew_fzg1_wp0 setWaypointBehaviour "SAFE";
        _sascha_crew_fzg1_wp0 setWaypointFormation "COLUMN";
        _sascha_crew_fzg1_wp0 setWaypointSpeed "LIMITED";
        _sascha_crew_fzg1_wp2 = _sascha_crew_fzg1 addWaypoint [[3664.38,11968.4,0], 0, -1, "start"];
        _sascha_crew_fzg1_wp0 setWaypointCompletionRadius 15;
        _sascha_konvoi_fzg1 limitSpeed 30;

So positiv

hushed turtle
#

Maybe they not in correct order?

broken pivot
#

How to correct?

#
(units _sascha_crew_fzg2 ) join _sascha_crew_fzg1;
(units _sascha_crew_fzg3 ) join _sascha_crew_fzg1;
(units _sascha_crew_fzg4 ) join _sascha_crew_fzg1;
(units _sascha_crew_fzg5 ) join _sascha_crew_fzg1;
(units _sascha_crew_fzg6 ) join _sascha_crew_fzg1;
(units _sascha_crew_fzg7 ) join _sascha_crew_fzg1;
(units _sascha_crew_fzg8 ) join _sascha_crew_fzg1;

fzg=vehicle

hushed turtle
#

Ok this seems to be correct

#

I thought one might be trying to overtake other to get into formation

broken pivot
#

Thats also my gues, but I cant find some hints that thats true

#

FunFact:
They do a shit after fucking up+

hushed turtle
#

If you have them placed on the road and first is fzg1, second fzg2 and so on then it should be fine

broken pivot
#

Thats the confusing part

#

I tripple check

#

Nothing

hushed turtle
#

In my testing they were driving just fine, staying on the road, not hitting anything

broken pivot
#

Ill send you the script

#

Maybe its my pc

hushed turtle
#

It might be them trying to overtake vehicle, which should be behind them

broken pivot
#

Please say that Im a massive idiot

hushed turtle
#

Group members have numbers, those which you can select by pressing F keys, those same numbers determine where is units place in formation. Unit number two will be behind leader, unit number 3 bwhind number 2 and so on

broken pivot
#

so I say like:

driver _sascha_konvoi_fzg1 setToNumber? 1-8```
hushed turtle
#

Also it might be them trying to get into formation, if formation is not column, but is seems like it is column based on your script

#

You dont need any special commands for that, just spawn them at correct order

broken pivot
#

Play the video in slow motion. They are

#

One by one from first to last car is getting filled up

hushed turtle
#

Ok

broken pivot
#

I cry

#

I dont want this shit over and over again

#

Nothing just works or is kinda logic in this game

#

And no one is able to even imagine

#

Senceless

#

Another 14hours wasted

hushed turtle
#

When I was doing convoy it took me couple of minutes and it looked just fine

granite sky
#

You were lucky :P

broken pivot
#

They are not even driving on the fucking fuck fuck speed limit Ive set to them.

what can go wrong with a ```sqf
_sascha_konvoi_fzg1 limitSpeed 30;

#

Just senceless to do something in this game. I always thought that the issues come from the players that fill the sandbox. But what the fuck

#

Please explain me

#

# Please someone

granite sky
#

It's travelling at 11km/h with a limit of 30? What's wrong with that?

broken pivot
#

Did Ive understood something wrong about this really simple looking command?

hushed turtle
#

Isn't that group? LimitSpeed wants object

broken pivot
#

I think because setWaypointSpeed "limited" for not doing full throtle

granite sky
#

limitSpeed only caps the speed. It doesn't force it.

broken pivot
broken pivot
granite sky
#

I dunno, that's pretty much how I remember vanilla convoys working :P

hushed turtle
#

I'm in bed, but I saved the scenario where I was trying that convoy

granite sky
#

Maybe skip the waypoints for now. Just set them up with commands (setFormation, limitSpeed) and give the group a move order.

broken pivot
#

Is that a troll?

granite sky
#

But I remember the Antistasi convoys used to use that shit and it never worked. I chucked it away eventually.

broken pivot
#

Removing waypoints and give move order is the same isnt it?

hushed turtle
#

No

granite sky
#

I don't know. Waypoints are an extra black box layer.

#

Some of them are clearly fucked, like GETOUT.

broken pivot
#

Black Box Layer?

tulip ridge
broken pivot
#

What the fuck youve did there @ArmaDevelops... why isnt there a follow command? The game engine is 20+ years old...
Those shitty vehicles cant even drive in a formation...

split scarab
#

Anyone know if it's possible/how to make a #lightpoint or #lightreflector have this kind of effect?

#

This is my current

private _reflector = "#lightreflector" createVehicleLocal [0, 0, 0];  
_reflector attachTo [vehicle player, [0, 6, -2.5], "light_l"];  
_reflector setLightColor [1, 1, 1];  
_reflector setLightAmbient [1, 1, 1];  
_reflector setLightIntensity 1e6;  
_reflector setLightConePars [50, 10, 1];  
private _vector3D = [[[0, 1, 0], [0, 0, 1]], 0, -45, 0] call BIS_fnc_transformVectorDirAndUp;  
_reflector setVectorDirAndUp _vector3D;  
  
private _light = "#lightpoint" createVehicleLocal [0, 0, 0];  
_light attachTo [vehicle player, [0, 6, -2.5], "light_l"];  
_light setLightColor [1, 1, 1];  
_light setLightAmbient [1, 1, 1];  
_light setLightUseFlare true;  
_light setLightFlareSize 5;  
_light setLightFlareMaxDistance 500;  
_light setLightBrightness 1000;  
_light setLightIntensity 10;
warm hedge
#

Yes, tldr you need to find or make a P3D

#

ConeShape or something is the keyword to find the command

split scarab
#

Nice okay, do you know if I'd have to add that as a 3rd light or add it to the first light?

warm hedge
#

It is a spotlight exclusive feature

split scarab
warm hedge
#

Yes, unpack it

tulip ridge
#

Advanced Developer Tools mod also has a file browser and you can render models with it

split scarab
broken pivot
#

Tip for convoys:
Turn the AI into bots.

thin fox
split scarab
#

Does including a memPoint in the attachTo function make the attached object more stable/stick better to the parent object?

If so, how would I go about finding all the "memPoints" for a modded vehicle? Cause right now the faster the vehicle goes the further ahead the attached objects drift :/

lime rapids
split scarab
lime rapids
split scarab
#

They're attached the same way as I do the floodlight

lime rapids
split scarab
#

It appears perfectly when the helicopter is at a standstill, when it starts moving that's when the lights drift away (further away the faster it's going)

lime rapids
split scarab
#

Oooooh, didn't know there was a attach function for lights specifically, I'll give that a go thanks!

warm hedge
#

No. That command is outdated and you should be able to attachTo normally

lime rapids
#

is there a way to assign a variable to a listbox item added via lbadd?

warm hedge
#

lbSetData or lbSetValue

hushed turtle
#

What is purpose of Game Logic object? Is that something I can use to spawn objects on, so I can see(and easily move it) in editor where the position is?

split scarab
sharp grotto
#

might be the simulation type of the light or so, wasn't there a workaround of attaching something else in between with a different (faster) simulation type?!
I had similar problems with AI helis lifting a crate, before this update some years ago that fixed the desync for vehicle lifting, it was fine.
After the update, for AI the crate is desyncing in front of the helicopter, but for players it worked fine.

warm hedge
pallid palm
#

why would they make Game Logics, if it does nothing, that don't make sense, i think it does way more then nothing,,,,,

#

you think they said oh, lets put Game Logics in the game, so it does nothing

winter rose
#

yet POLPOX is right! it is a virtual entity.

pallid palm
#

so your saying virtual entitys do nothing

atomic niche
#

no not nothing but not a lot

pallid palm
#

then why even put Game Logics in the game

pallid palm
#

so we could just use a marker and not mess with Game Logics

atomic niche
pallid palm
#

my point is why would they put Game Logics in the game, there must be a reason

warm hedge
#

You could ask it two decades ago

sturdy sage
pallid palm
#

agree

atomic niche
pallid palm
#

agree

#

thats a lot more then nothing imho

atomic niche
pallid palm
#

ok i see your point

#

ill think of it as like a reference object within the mission that can be used to store variables, call scripts or be linked to triggers as a comparative module game logic

atomic niche
#

Its basically the same as putting a hidden cube on the map somewhere, but slightly cleaner

pallid palm
#

oh we like cleaner

#

so you can give waypoints to a game logic ( virtual entity )

proven charm
#

back in the day (OFP) game logics could be used to script and help in mission making. But that was long a go so I cant remember any examples

pallid palm
#

oh yes i remember OFP big time

#

Some times i would put a game logic on the map named (Server)

proven charm
#

yes

pallid palm
#

i think whats so cool about this game is there is many ways to do the same thing, some ways are better then others

#

kinda like real life or like the Golf swing he he

#

its so nice texting with all you Awsome people here in discord, i learned so much love you guys,!

hushed turtle
#

I could use it to move other object on it from script. Using game logic's position and direction. While I can see in editor where it is placed, which can't be said about positions stored in array in SQF script.

#

Hidden markers could be used like that, but that's not marker's purpose. Also you have to use string to find marker rather than having variable referencing that object

open hollow
#

also 3den enhanced allows you to execute scripts on editor

#

in the end, the editor is just an scripted UI over the game

#

so scripting work almost the same ( there are some diferences) but on a really simple level, its almost the same... you can use create vehicle and set pos... and that wont be saved on the mission ( unless you told so)

hushed turtle
#

I have entire mission logic in scripts and I want to move objects to some positions from scripts. What are my options to store potential positions? I could use array, but that doesn't allow me to see where the position is in the editor and it's not convenient if I decide to change the position. Game Logic objects seems to be pretty good solution.

open hollow
#

you can use any object, that wont be saved in the sqm

#

use create vehicle and setposatl to move in the desired positions.

i dont know how fluent you are with sqf to do all this from the debug console

#

i strongly recomend you to use either leopards dev tools or you can also use execvm to a file

hushed turtle
open hollow
#

you want to see the positions randomly generated from a script? or you have the exact positions?

hushed turtle
#

Exact positions I hand picked in the editor

open hollow
#

if you already know the positions, what you want to see in the editor?

digital hollow
#

empty type of marker is suitable for this

real tartan
#

looking for generating unique id for name for marker created by script. Want to create n number of markers on object/position.

private _marker = createMarkerLocal [ format [ "TAG_%1", _object call BIS_fnc_netId ], getPosASL _object ];

maybe use time + random, but that is not true unique

proven charm
#

id use global variable and increment it's value. but there may be better ways

still forum
#

diag_tickTime could also work

granite sky
proven charm
#

what if you get systemTime/diag_tickTime inside a each frame event or another nonsuspening event, could the time remain same for that frame?

granite sky
#

If you generate two markers in a row in the same script then it'll probably be in the same millisecond...

#

But in that case you'd use an increment so I'm not sure why the question exists. Needs more detail anyway.

#

Locality & timing of creation, specifically.

proven charm
#

yeah just run this code and it seems to be that way: ```sqf
isnil
{
systemchat format ["-- %1 %2 %3", time, systemTime, diag_tickTime ];
systemchat format ["-- %1 %2 %3", time, systemTime, diag_tickTime ];
};

hallow mortar
#

If you're generating a certain number of markers, then you're probably using forEach, for or similar commands. Normally they have access to an index (_i, _forEachIndex etc) and you can add that to your marker name to make it unique within that sequence.

granite sky
#

In other cases you might use a global variable to store the last index.

#

Sometimes it's even valid to just generate a random number until you get a name that doesn't already exist.

copper badger
#

anyone able to help write code for arma reforger mods on a dedicated server

hallow mortar
jade abyss
#

Anybody knows (on the fly), how the "Weight" of the Gear of Vehicles is beeing calculated (for example, the Bar in the Gearmenu)? (erm, i hope you get what i mean)

split scarab
#

Gonna try asking a 2nd time cause I'm desparate and have tried a bunch of things now without success :/

I have 1x #lightpoint and 2x #lightreflector attached to a helicopter which look perfect when the helicopter is still but once it's moving the lights drift ahead of the vehicle (like shown in the picture)
I've tried attachTo (with/without memPoints), lightAttachObject
I've also tried attaching a IR strobe grenade to the helicopter and attaching the lights to the IR strobe grenade hoping that the positioning would be more consistent or update faster but it didn't change.

Really hope someone knows a way to fix it otherwise I'll just have to live with it unfortunately looking silly

private _lightDecoration = "Land_FloodLight_F" createVehicle  [0, 0, 0];
_lightDecoration disableCollisionWith _object;
_lightDecoration attachTo [_object, _spotlightLocation, _memPoint];
private _decVector3D = [[[0, 1, 0], [0, 0, 1]], 90, -45, 0] call BIS_fnc_transformVectorDirAndUp;    
_lightDecoration setVectorDirAndUp _decVector3D;
    
private _lightSpot = "#lightpoint" createVehicle [0, 0, 0];    
_lightSpot attachTo [_object, _spotlightLocation, _memPoint];    
// other _lightSpot settings..
private _reflector1 = "#lightreflector" createVehicle [0, 0, 0];    
_reflector1 attachTo [_object, _spotlightLocation, _memPoint];    
// other _reflector1  settings..
private _refl1Vector3D = [[[0, 1, 0], [0, 0, 1]], 0, -55, 0] call BIS_fnc_transformVectorDirAndUp;    
_reflector1 setVectorDirAndUp _refl1Vector3D;   
private _reflector2 = "#lightreflector" createVehicle [0, 0, 0];    
_reflector2 attachTo [_object, [0, (_spotlightLocation select 1) + 2.5, (_spotlightLocation select 2) -3], _memPoint];    
// other _reflector2  settings..
_reflector2 setLightVolumeShape ["a3\data_f\VolumeLight_searchLight.p3d", [4, 2, 4]]; 
private _refl2Vector3D = [[[0, 1, 0], [0, 0, 1]], 0, 128, 0] call BIS_fnc_transformVectorDirAndUp;    
_reflector2 setVectorDirAndUp _refl2Vector3D;
granite sky
#

Hmm. Does it render the lights further ahead when the heli is travelling faster?

split scarab
granite sky
#

Not jumpy, completely smooth?

split scarab
#

A little jumpy but I'd much rather deal with the jumpyness than the drifting

granite sky
#

Just trying to work out what sort of bug it is.

split scarab
#

If I used lightAttachObject for example it's a lot more jumpy

#

Yeah ofc, sorry didn't mean it like that hehe

#

Fyi the "other light settings" I hid is just stuff like this due to character limit and _spotlightLocation is currently [0, 0, 0]; due to using memPoint

setLightColor   
setLightAmbient
setLightUseFlare
setLightFlareSize
setLightFlareMaxDistance
setLightBrightness 
setLightIntensity
frozen seal
# split scarab Gonna try asking a 2nd time cause I'm desparate and have tried a bunch of things...

sorry just randomly stumbled upon this.
Haven't tried it but my next idea would be to try to update the light position every frame manually instead of attaching it to the helo.
Seems like you already have relative position and direction of the light relative to the helo, next I would add an event handler oneachframe or whatever it's called and in there update the positions of the light.
vectorModelToWorld should help with rotation, modelToWorld with position

#

arma being arma I give it a low chance of working but maybe worth a try

sick karma
#

sorry to be out of the blue but does anyone know how to make an explosive able to explode multiple times?

(Im trying to make an orb that explodes and dont want it to just be a one time thing)
so far it has a satchel charge with a hidden model that takes damage when you interact with the right thing, is there a way to keep the satchel charge?

granite sky
#

Why not just spawn another one?

sick karma
#

in short, i dont want to keep having to respawn the same object manually

granite sky
#

We can't always have what we want.

granite sky
#

I'm not really sure what you're trying to do or why, but maybe put the addAction on a different object and have that spawning the explosives.

tulip ridge
#

I've tried this same idea for cabin lights in vehicles

granite sky
#

IIRC addActions even work on hidden objects, so you can disguise.

sick karma
#

i mean is the object destruction of the explosive on taking damage hard coded or can that be changed

granite sky
#

As far as I know it's hardcoded. I might be wrong.

#

If you were going to change that, it'd be in config rather than script, which is not an easy thing to get into if you've only done editor scripting.

tulip ridge
hallow mortar
tulip ridge
#

You get the same behavior with local only lights as well

sick karma
tulip ridge
#

createVehicle with the CfgAmmo class iirc

sick karma
#

i tried looking at the createVehicle page on the BI but it didnt make much sense, im ngl.
whats the CfgAmmo class?

granite sky
#

Probably easiest to place one and find the class with nearestObjects.

#

Although if it's vanilla there's not that much stuff in CfgAmmo.

hallow mortar
granite sky
#

I think if an object class has a # then it's created locally only, even if you use createVehicle.

tulip ridge
#

Yeah
Each client gets a copy

Not sure about server, never tested

hallow mortar
#

Even if that's the case, the object references will still be different on each machine and need to be stored locally for any later manipulation

tulip ridge
#

No one said not to handle them locally

broken pivot
#

# Hey people ^^
I want to change the behaviour of a group and cant continue since a while
Im using this this code:

//Group
sascha_grp1 = createGroup east;

//Waypoint
{_x disableAI "TARGET"} forEach units sascha_grp1;
sascha_grp1_WP_passiv = sascha_grp1 addWaypoint [[9078.48,16015,0], 0, -1, "PassiverZustandBesatzung"];
sascha_grp1_WP_passiv setWaypointType "HOLD";
[sascha_grp1, 0] setWaypointBehaviour "SAFE";
sascha_grp1_WP_passiv setWaypointFormation "STAG COLUMN";

//Return
_text = {behaviour _x} forEach units sascha_grp1; 
hint format ["%1", _text];

And get the "AWARE" return from the [PHOTO1]

meager granite
#

You probably meant units sascha_grp1 apply {behaviour _x} ?

#

If you wanted to see behaviour of each unit*

hallow mortar
# meager granite You probably meant `units sascha_grp1 apply {behaviour _x}` ?

This is correct - your forEach implementation is only showing the return from the last unit checked, not all of them.
Also, there are a couple of different levels of AI behaviour mode, and it's possible you're checking the wrong one. The vehicle does have its lights on, which suggests the AI thinks it's in SAFE mode on some level; usually they'll go lights-off in AWARE or COMBAT mode.
You could try checking the combatBehaviour of the group instead.

granite sky
#

setWaypointBehaviour appears to set unit behaviour rather than group behaviour.

#

Oddity in the code is that it's setting waypoint behaviour for a waypoint that isn't declared.

#

We don't know from the code which waypoints are activated and when.

#

setWaypointBehaviour may not apply immediately anyway. Waypoint progression happens at intervals.

#

If you just want to set the behaviour now, then set it now.

hushed turtle
broken pivot
broken pivot
still forum
#

It needs code. Either a variable with code, or a code block directly

faint burrow
broken pivot
#

Copy confirm. Thanks a lot πŸ˜„

broken pivot
broken pivot
#

Hey @hushed turtle πŸ‘‹

hushed turtle
#

Maybe change to behaviour wasn't applied yet?

#

You could try sleep 3; and test it behaviour little later

broken pivot
#

Im trying to disableAI "TARGET" at a later point at the moment

hushed turtle
#

It also seems like you are not aware of the fact that you can just change the behaviour on the group. Changing bahaviour though waypoints isn't the only way

broken pivot
broken pivot
hushed turtle
runic delta
#

Can we find the max range of artillery

hushed turtle
gleaming onyx
#

I have a script that makes a "mobile" respawn point.
and that is in a InitServer.sqf
and contains:
[west,"Base"] call
BIS_fnc_addRespawnPosition;

how do I set up so I can have 2 mobile spawnpoints?

proven charm
#

if you want to make vehicle a respawn point just pass that vehicle as second argument to BIS_fnc_addRespawnPosition

broken pivot
gleaming onyx
broken pivot
proven charm
#

if you pass a string thats a marker name

gleaming onyx
tulip ridge
thin fox
#

it returns an array of [min range, max range]

granite sky
#

Oh, someone found my code :P

#

Drop the +/-100 line if you want to replicate artillery computer ranges.

thin fox
cyan thunder
#

Just drop a rock in the water - that'll work πŸ˜„ (if you know you know)

runic delta
#

Thanks

gentle hill
#

Hey everyone, new here and excited to find others to help. I need to know if someone has the script to auto open (animate) and close the deck bay doors on the LPD-36 Amphibious warship. You can manually open the doors so I know the function exists, but checking the Config viewer and I'm kind of lost, help would be greatly appreciated, thankyou!

Ideally I'm wanting the door (big white square door in pics) to auto open and close based on a trigger

sly cape
gentle hill
sly cape
#

I was thinking about something else. That's what happens when my brain is on autopilot.

gentle hill
#

Youll have to forgive me, I've come pretty far in editor but still learning so im not sure what that is

gentle hill
gentle hill
sly cape
#

Shouldn't it be ship1 animateDoor ["Door_3", 1], not 0?

icy ridge
# gentle hill Hey everyone, new here and excited to find others to help. I need to know if som...

Hey peepo_hey

You have several options to initiate animations on options, animate, animateDoor and animateSource. As the wiki entries for animate/animateSource both state, animateSource is the better option over animate.

To find the actual animation names, you can simply use animationNames (https://community.bistudio.com/wiki/animationNames) to get an array containing the names of all animations for an object.

gentle hill
gentle hill
#

Nope, I've got to be off by the tiniest amout

icy ridge
#

What is the return value of animationNames ? Perhaps you've got the wrong animation.

hallow mortar
#

You'll have trouble doing it directly because the ship is actually composed of multiple parts. The thing you place in the Editor is actually a proxy base object that automatically generates the ship parts from itself.

gentle hill
gentle hill
#

Found what i believe is the part in the config viewer, and tried to adjust my code but still no dice, I can confirm the "hangar door" is the door in question

hallow mortar
icy ridge
#

I have personally had very mixed results with these composite objects. I usually steer clear of using them outside of background props.

#

Especially when it comes to animations

gentle hill
icy ridge
# hushed turtle Empty array

The return value will vary depending on which part of the object you're checking.. For instance on the Destroyer you will get different (or no) animation names depending on whether you're checking the hull, interior etc.

hallow mortar
#

You just need to find the other part. You know what type of object it is, so it's actually fairly simple as long as you don't have any other ships of the same type nearby.

gentle hill
hallow mortar
#
private _shipPart = nearestObject [ship1, "Land_EF_LPD_hull_02"];
_shipPart animateSource ...```
#

Actually, if you'd like to make this slightly more complicated, you can find with certainty the exact object belonging to this ship, which will avoid any problems with nearby similar ships

#

The function that generates all the ship parts stores references to them in a variable on the base object, for pretty much exactly this purpose, so you can retrieve it from that variable

gentle hill
#

Where do i plug that script?

icy ridge
gentle hill
#

I was just looking in that comp folder in the config viewer btw, its the only mention of hangar door in the entire compositie, so I believe it lives where you found in that _02

hallow mortar
# gentle hill Where do i plug that script?

Wherever you're trying to do whatever it is you're trying to do. In your trigger or whatever. This is the script you need to do the thing (except for animateSource being a placeholder for your actual animation thing)

icy ridge
#

I haven't got EF running at the moment, for reference: The Destroyer stores the references for all parts in bis_carrierparts.

hallow mortar
gentle hill
#

Oof my brain is short circuiting. So what is it I need to do from here?

#

Let's dumb it down and do this Barney style

hushed turtle
#

There multiple animations for those doors

hallow mortar
#

Either way, this is the script that does the thing. You put it in your trigger and it does the job. Don't overthink it.

#

Actually it's more complex than that for some reason. They don't just store the object in the array, they store something else too πŸ€” first one will still work fine with no other nearby ships, I just need a second to fix the more complicated version.

icy ridge
#

Yeah that's exactly what I'd go with as well.. lol

private _object = ((ExampleDestroyer_1 getVariable ["bis_carrierparts",[]] select { (typeOf(_x#0)) isEqualTo "Land_Destroyer_01_hull_04_F" })#0#0);

(obviously this works with the Destroyer, not the EF ship but same principle)

hushed turtle
#

This code does it, you could use just "door_hangar_1" alone, but that's not proper way.

private _shipPart = nearestObject [ship, "Land_EF_LPD_hull_02"];
_shipPart animate [ "door_hangar_3", 1 ];
_shipPart animate [ "door_hangar_2", 1 ];
_shipPart animate [ "door_hangar_1", 1 ];
icy ridge
hallow mortar
gentle hill
#

Theres on for open and one for close (though its the difference in code between a 1 and a 0)

icy ridge
#

But it should be animateSource instead of animate, for the reasons stated on the wiki.

hallow mortar
hallow mortar
icy ridge
#

Oh, well, haven't tested it yet. I'm likely wrong then.

#
private _object = ((YOUR_SHIP getVariable ["bis_carrierparts",[]] select { (typeOf(_x#0)) isEqualTo "Land_EF_LPD_hull_02" })#0#0);
_object animateSource ["door_hangar_source",1];
icy ridge
gentle hill
#

HOW DO YOU GIVE YOU KUDOS IN THIS GROUP?

hallow mortar
#

The code I initially posted would also have worked fine for most scenarios fwiw :U

icy ridge
#

Well the kudos belong to @hallow mortar.

gentle hill
#

Its incredibly infurriating

icy ridge
#

I was wrong about animationSource, given I haven't used it in a while and his Idea with nearestObjects would work just as well unless a ship was placed half way inside the ship you were trying to animate πŸ˜…

hushed turtle
#
private _shipPart = nearestObject [ship, "Land_EF_LPD_hull_02"];
_shipPart animateSource ["door_hangar_source",1];

Moves all three parts at the same time

gentle hill
#

@icy ridge & @hallow mortar dropped a kudos for yall in editor, thanks again

hushed turtle
pale wagon
#

I would like some help making a basic script. I have a Commander unit with the variable name of unCMDR, I need a trigger to check if he is dead, then display a hint "The UN Commander is dead!" when he dies. I am trying to make my own but it seems to just not be working.

#

(Granted I am using a trigger, so shrug )

icy ridge
#

Any particular reason, why you would need to use a trigger for this?

A far simpler solution would be to add a killed eventHandler:

pale wagon
icy ridge
#

Alright, no problem. We all started out new pepe_shrug

#

Eventhandlers can be added to objects, units etc. and get triggered when a certain event happens. Hence the name event handler.

pale wagon
#

Wicked

icy ridge
#

Important question before i continue: Are you building a mission meant to be played in Multiplayer or Singleplayer?

pale wagon
#

Multiplayer

icy ridge
#

Alright. Does the unit get added during the mission or is it already present in the editor?

pale wagon
#

It is already present

#

I don't need anything super complex, as this op is literally just "go here and wipe out two faction leaders" lol

icy ridge
#

In that case you're still good with a regular killed eventhandler, as the unit's init field is the same for every player. In the init field of the leader unit you can simply add:

this addEventHandler ["Killed", {
    params ["_unit", "_killer"];
    hint parseText format ["The UN leader <t color='#3062b1'>%1</t> was killed by <t color='#b52600'>%2!</t>",(name _unit),(name _killer)];
}];
pale wagon
#

Wicked! Thank you

icy ridge
icy ridge
# icy ridge In that case you're still good with a regular killed eventhandler, as the unit's...

@pale wagon To quickly explain what this does, as I think there is little learned from copying something blindly, a breakdown:

  • this, inside an init field, refers to the object itself and is thus more convenient than giving the object a variable name and then using that.
  • addEventHandler is the initialization command for a new eventhandler. It is used by first giving it a target (in our case we use thisas explained above) and then after the command the actual parameters are passed: type, which is a pre defined Eventhandler type (you can find a list of them here: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers) and code where the actual code that gets run when the event is triggered gets defined.
  • params is used to parse arguments that get "sent" to a function into pre defined variables. In this case the Eventhandler passes two parameters when triggered the killed unit and the unit who did the killing which is parsed into _unitand _killer respectively using params.
  • hint is a command you are more than likely familiar with already. It's used to display a string or Structured Text in a dynamically scaled window in the top right corner if a client's screen.
  • parseText is used to generate a piece of Structured Text (basically a string but you can specify stuff like color, font, alignment etc.)
  • format is used to insert variables into a string or Structured Text by referencing it with %index and adding the variable after the string inside the parameter array in the case of this example the names of the killed unit as well as the killer are inserted into a piece of Structured Text highlighting the names with a defined color (hex color code).

So put together it is an Eventhandler waiting for the unit to be killed and once it is it displays "The UN leader NAME_IN_BLUE was killed by KILLER_NAME_IN_RED!".

pale wagon
#

Oh wow, thank you! Very informative

icy ridge
split scarab
#

I doubt it's a thing, but is there a simple way for Zeus/Curators to see all chat messages? Primarily sideChat

icy ridge
#

Side chats of other factions?

split scarab
#

Yeah

icy ridge
#

Outside of RCON I'm not aware of a simple way to achieve that ..

hallow mortar
#

You could do something horrifying with a HandleChatMessage mission EH but I wouldn't describe that as a simple approach

split scarab
#

Nah seems too convoluted and the wiki of that event says risk of recursion if you send additional specific types of chats within it

#

Was hoping there was some kind of toggle function you could do to allow them to see all chats, from a moderation standpoint

#

But I guess I'll just add some sideChat remoteExecs where necessary for the curator to see

icy ridge
icy ridge
hallow mortar
#

I think a handlechatmessage system would be quite reliable if properly designed, and not too taxing on performance as chat messages are relatively infrequent. I have a pretty solid idea of how I would approach it. It would just be annoying to make and certainly isn't a simple toggle.

split scarab
#

Hmm, any particular reason why this _x moveTo _randomPos; doesn't work on dedicated server? The logic is all server side and worked perfectly on local MP

[trig_guard_dog_init] spawn { 
 params ["_trig"];  
 sleep 2; 
 while {triggerActivated _trig} do {  
  { 
   _randomPos = [["dog_area"], ["water"]] call BIS_fnc_randomPos; 
   _randomPos = _randomPos findEmptyPosition [0, 5]; 
   _x moveTo _randomPos;
  } foreach nearestObjects [_trig,["animal"],100]; 
  sleep 30; 
 }; 
};
#

The dogs completely ignore the "moveTo" order and just wander freely

tulip ridge
split scarab
#

If it's a dog spawned from the Ambient Animals module, wouldn't that be the server?

hallow mortar
broken pivot
#

# Hey guys πŸ˜„
Im into digging to the Big Bang..

Very simple question:
If sascha_math = 2 and I want to turn the value into 1 can I just do:

if (alive player
) then {
  sascha_math -1;
};
warm hedge
#

No

broken pivot
#

Simple question. Simple anwser.

warm hedge
#

There is no sascha_math++ equivalent in SQF either

broken pivot
#

So no calculation at all

#

So its impossible to change the sascha_math value? Or did I misunderstood?

ivory lake
#

you just do
sascha_math = sascha_math - 1;

warm hedge
broken pivot
#

Waw

broken pivot
#

End of headsrcatching. But its only logic to first take the value I want to edit..

warm hedge
#

It uses very common way to operate such math in almost every programming languages

broken pivot
#

Im honest that Im a newbie. But Im motivated to learn. And YES I know Enfusion Engine is coming. But I want to learn also Digital Reality because there are more people like you who can help me to understand the basics who are always kinda the same.

So thanks bro πŸ˜„

#

I was now able to easiesy do my first automated calculations
I got a problem by reading out the return because Im only able to check it once with this:

if (!sascha_insassen_passiv 
    ) then {sascha_mathe = sascha_mathe -1
    } else {sascha_mathe = sascha_mathe +1
};
hint format ["Sascha Mathe ist %1", sascha_mathe];    

My only idea is a while state to detect permanent. The problem would be that also the
value gets always higher permanent

Could this somehow work?

while {sleep 5; sascha_insassen_passiv;
    } do {systemChat "Einheiten passiv";
    sascha_mathe = sascha_mathe 1;
    } else {systemChat "Einheiten aktiv";
    sascha_mathe = sascha_mathe 0;
    };
fleet sand
# broken pivot I was now able to easiesy do my first automated calculations I got a problem by ...

It would be like this:
You would have infinite loop
(while true) loop witch will run with a delay of 5 seconds.
And then check your condition and increment or decrement the number and print the number.
Also because you are using sleep command it needs to be in scheduled environment.

Also instead of having infinite loop that will run indefinetly have it so it incresses or decresses on EH or basicly when something happends.

sascha_insassen_passiv = true;
sascha_mathe  = 2;

0 spawn {

    while {true; sleep 5;} do {
        if(!sascha_insassen_passiv) then {
            sascha_mathe = sascha_mathe - 1;
        }else {
            sascha_mathe = sascha_mathe + 1;
        };
        
        hint format ["Sascha Mathe ist %1", sascha_mathe];
    };
};
broken pivot
#

The problem is that I only accept 1 for driving. 0 for stoping and fighting

#

If I understand it right it infinite adds values so if we stay 20 secs in driving we have a total value of 4.
So we would need to be 20 secs in battle to finaly achieve battle mode

cosmic lichen
#

What exactly do you want?

fleet sand
#

Yea i am confused as well ?

broken pivot
#

Ohh boy

#

Wait.

cosmic lichen
#

If you only have two states you can use a Boolean or flip the int between 0 and 1

broken pivot
#

You will regret hahahaha

#

Im in line 348 - 373

#

Dont care about the rest -> It works and I need to be finished today

broken pivot
# cosmic lichen What exactly do you want?

What has to happen:
The AI is in aware "SAFE" so sascha_insassen_passiv == true
Then the sascha_mathe needs to be on 1 -> 1 means driving because it triggers Start&Stop if-Cause.

If "SAFE" changes to "AWARE" or "COMBAT" the sascha_mathe turns to 0 -> 0 means stop&combat

cosmic lichen
#

Then post the relevant code. No one wants to download a file. Especially not on mobile.

broken pivot
hallow mortar
#

If you use pastebin, people can at least read it without downloading anything

broken pivot
#

Ill read about

fleet sand
broken pivot
fleet sand
broken pivot
#

I guesed something and wanted to learn about calculation

#

Now Ive learned about and see that its maybe not the best way haha

#

Ill work something together and let you look about. Gimme a sec

cosmic lichen
#

Looking at the code. You also wann learn about loopsmeowsweats

fleet sand
cosmic lichen
#

πŸ˜„

broken pivot
#

hey hey

#

Im learning

#

hahahahhaaha

#

But it works!

#

Somehow...

#

Scheduled in hell

#

Fired at god mode servers that accept mistakes

#

It was a really nice moment Ive learned that forEach only takes the last value of an array you insert...

winter rose
broken pivot
#

Aaaaahahahahhahahahahahaaaa

#

We should bring all people together

winter rose
#
private _myArray = [1,2,3];
{
  hint str _x;
} forEach _myArray;
```outputs "1", "2", "3"
broken pivot
#

And if:

Array1 = [1], [2];
Array2 = [3], [4];

{count} forEach [Array1, Array2];
or
{count} forEach (Array1, Array2);
or
{count} forEach Array1, Array2;
but not
{count} forEach {Array1, Array2};
that would be code and launch it and return the result of <any>

Can this work?

hallow mortar
winter rose
#

you may be meaning Array1 = [1, 2]; or Array1 = [[1], [2]];

fleet sand
hallow mortar
#
_return = { str _x } forEach [1, 2]; // _return contains "2"
_return = [1, 2] apply {str _x}; // _return contains ["1", "2"]```
winter rose
hallow mortar
hallow mortar
broken pivot
fleet sand
winter rose
#

(and don't forget semicolons)

broken pivot
# broken pivot Ill work something together and let you look about. Gimme a sec

Im back with something here it is:

sascha_kampf = false;

while {true; sleep 5;
    } if (sascha_insassen_passiv
    ) then {systemChat "Einheiten passiv";
    sascha_kampf = sascha_kampf false;
    } else {systemChat "Einheiten aktiv";
    sascha_kampf = sascha_kampf true;
    };

//Start&Stop    
sascha_anhalten = if (sascha_kampf
) then {stop script
};

sascha_anhalten = if (!sascha_kampf
) then {driving things
};
broken pivot
broken pivot
winter rose
#

your lines 26/27 are nonsense, delete them

broken pivot
#

Into it

minor agate
#

Hi People o/. How can i remove a magazine from a players weapon when taking a weapon out of a normal Arsenal?

#

Remove Magazines doesnt seem to work for ammo in the gun

broken pivot
# winter rose your lines 26/27 are nonsense, delete them

Thats there Ive used them:

{_x setBehaviour "SAFE"} forEach sascha_gruppen_array;
{_x setFormation "STAG COLUMN"} forEach sascha_gruppen_array;
{_x disableAI "TARGET"} forEach units sascha_gruppen;

If I remember right the other format wont work

winter rose
#

that is because the last foreach is in the wrong format

broken pivot
#

the units part

winter rose
#
{
  private _group = _x;
  {
    _x disableAI "TARGET"
  } forEach units _group;
} forEach sascha_gruppen_array;

#

you have to go through groups and inside that go through its units

#

the sascha_gruppen variable was just sascha_grp_1 here

broken pivot
broken pivot
hushed turtle
winter rose
broken pivot
#

Okay then I stay with -> {code}

#

OMG

#

hahaha It was late yesterday. Now I understand exactly why my sascha_gruppen was so heavy nonesense

#
sascha_gruppen_array = [sascha_grp1, sascha_grp2, sascha_grp3, sascha_grp4,
                    sascha_grp5, sascha_grp6, sascha_grp7, sascha_grp8];
return == sascha_gruppen
#

lol nothing changed

hushed turtle
#

What is return?

broken pivot
#

If would grab it. -> Execute

broken pivot
broken pivot
#

Or why not just using _x ?

hushed turtle
#

It loops though all units from all groups from sascha_gruppen_array array

winter rose
broken pivot
hushed turtle
# broken pivot Or why not just using _x ?

Using private _group = _x; allows you to use _group rather then _x, which makes code more readable. Also every forEach has it's own variable _x, which means that you can't access variable _x of outer forEach code from within inner forEach code.

broken pivot
#

So you split content

winter rose
#

you can write this, it works```sqf
{
{
_x disableAI "TARGET" // _x is unit
} forEach units _x; // _x is group
} forEach sascha_gruppen_array;

#

however, in the innermost scope, you cannot access the "_x group value" because "_x" is unit

broken pivot
hushed turtle
winter rose
hushed turtle
#

Yeah, it took me some time to understand that when I saw that for the first time πŸ˜†

broken pivot
#
while {true; sleep 5;
    } do {
        if (sascha_insassen_passiv
        ) then {systemChat "Einheiten passiv";
        sascha_kampf = sascha_kampf false;
        } else {systemChat "Einheiten aktiv";
        sascha_kampf = sascha_kampf true;
        };
    };

I gues Im doing something wrong in changing the values

winter rose
#

sascha_kampf = sascha_kampf false; wat

sascha_kampf = false; OK

#

also indentation

while { true; sleep 5; } do
{
    if (sascha_insassen_passiv) then
    {
        systemChat "Einheiten passiv";
        sascha_kampf = false;
    }
    else
    {
        systemChat "Einheiten aktiv";
        sascha_kampf = true;
    };
};
#

also logic

while { true; sleep 5; } do
{
    if (sascha_insassen_passiv) then
    {
        systemChat "Einheiten passiv";
    }
    else
    {
        systemChat "Einheiten aktiv";
    };

    sascha_kampf = !sascha_insassen_passiv;
};
hushed turtle
#

Does that even work? while { true; sleep 5; }, sleep won't return true, right?

broken pivot
#

Your right.

winter rose
#

correct, should be while { sleep 5; true }

broken pivot
#

My chat isnt raped

hushed turtle
#

I would put sleep either into start or end of the do code honestly

broken pivot
#

Why is my chat spamed 10 times a sec with this code:

while {true;
    } do {sleep 5;
        if (sascha_insassen_passiv
        ) then {systemChat "Einheiten passiv";
        sascha_kampf = false;
        } else {systemChat "Einheiten aktiv";
        sascha_kampf = true;
        };
    };

This also effects nothing:

while {sleep 5; true;
    } do {
        if (sascha_insassen_passiv
        ) then {systemChat "Einheiten passiv";
        sascha_kampf = false;
        } else {systemChat "Einheiten aktiv";
        sascha_kampf = true;
        };
    };
winter rose
broken pivot
#

Server Site

#

With debug

#

Later on a headless with remoteExec

winter rose
#

server-side how?

broken pivot
#

Debug Console and execVM

winter rose
#

debug console cannot run that - try wrapping it in

0 spawn {
  // code here
};```
broken pivot
#

0 spawn {execVM "EBER\Erweiterungen\Konvoi\EBERStadt-Agios.sqf";}; ?

winter rose
#

no, the code above (while true stuff)

broken pivot
#

Ill read about spawn after

#
0 spawn {
while {sleep 5; true;
    } do {
        if (sascha_insassen_passiv
        ) then {
        systemChat "Einheiten passiv";
        sascha_kampf = false;
        } else {
        systemChat "Einheiten aktiv";
        sascha_kampf = true;
        };
    };
};

Still under message-fire

#

But if I got spawn right it just effects anything if the scheduler is busy

hushed turtle
#

Don't worry about scheduler

broken pivot
#

I just dont understand why the sleep isnt working

#

Dont matter if I add it to while itself or the do command it effects

hushed turtle
#

It should work within spawn

broken pivot
winter rose
#

close Eden, reopen it, retry

broken pivot
#

Pull out -> Plug in

#

Simple as a rock

#

Worked

winter rose
#

my guess was that you ran it multiple times in Eden

the thing is, all the threads will keep running, they won't be "overridden" by the next one

#

so you kept creating threads messaging every 5s πŸ˜„

hushed turtle
#

So those threads are still running on the server? πŸ˜‚

broken pivot
winter rose
hushed turtle
#

You could use for block to limit number of cycles

winter rose
#

but again, we don't know what you want to do

broken pivot
#

I just want to check if the unit is AWARE or COMBAT and if so I want to stop the convoy

hushed turtle
#

Or you can create global variable keepRunning = true; and then use while {keepRunning} and when you do keepRunning = false it will stop running

#

Until you finish your script

broken pivot
#

I totally forgot to bring back:

        sascha_combat_cond = ({behaviour _x} forEach units sascha_grp1 == ("AWARE") or {behaviour _x} forEach units sascha_grp1 == ("COMBAT"))
        && ({behaviour _x} forEach units sascha_grp2 == ("AWARE") or {behaviour _x} forEach units sascha_grp2 == ("COMBAT"))
        && ({behaviour _x} forEach units sascha_grp3 == ("AWARE") or {behaviour _x} forEach units sascha_grp3 == ("COMBAT"))
        && ({behaviour _x} forEach units sascha_grp4 == ("AWARE") or {behaviour _x} forEach units sascha_grp4 == ("COMBAT"))
        && ({behaviour _x} forEach units sascha_grp5 == ("AWARE") or {behaviour _x} forEach units sascha_grp5 == ("COMBAT"))
        && ({behaviour _x} forEach units sascha_grp6 == ("AWARE") or {behaviour _x} forEach units sascha_grp6 == ("COMBAT"))
        && ({behaviour _x} forEach units sascha_grp7 == ("AWARE") or {behaviour _x} forEach units sascha_grp7 == ("COMBAT"))
        && ({behaviour _x} forEach units sascha_grp8 == ("AWARE") or {behaviour _x} forEach units sascha_grp8 == ("COMBAT"));
        hint format ["%1", sascha_combat_cond];

Into the script...

hushed turtle
#

In the end it should have condition which stops it once unit is aware or combat

broken pivot
#

Creates a Bool about behaviour from every group

hushed turtle
#

Is there a reason why are you trying to check for unit's behaviour rather than group's?

broken pivot
#

Thats the part with the forEach thing again... That part is from yesterday

hushed turtle
#
combatBehaviour sascha_grp1 == "AWARE" || combatBehaviour sascha_grp1 == "COMBAT"

This line returns true if sascha_grp1's behavior is "AWARE" or "COMBAT"

#

And you should be using arrays to store multiple related variables

broken pivot
#

My brain slowly melts

broken pivot
winter rose
#

yes, because this code is nonsense

#

also, does it need to be a global variable or do you only use it in this script?

hushed turtle
#

I think there are bigger errors right now...

broken pivot
#

I use it only here but thought its nicer to work with

winter rose
#
private _areAllGroupsAwareOrCombat = sascha_gruppen_array findIf { behaviour _x != "AWARE" && behaviour _x != "COMBAT" } == -1;
hushed turtle
#

When writting you could be using global variables to see them more easily and change them to locals once you are done

broken pivot
hushed turtle
#

behaviour only takes OBJECT as argument

broken pivot
hushed turtle
#

Yes, units

#

And units are objects

broken pivot
hushed turtle
#

It won't work for other types of object

winter rose
#

findIf gets the index of the first found case where it's different from aware or combat
if index is -1, it means "nothing was found", so all groups are aware or combat

broken pivot
#

Alright. That makes it easier

winter rose
#

but

private _areAllGroupsAwareOrCombat = sascha_gruppen_array findIf { behaviour _x != "AWARE" && behaviour _x != "COMBAT" } == -1;

should indeed be```sqf
private _areAllGroupsAwareOrCombat = sascha_gruppen_array findIf { combatBehaviour _x != "AWARE" && combatBehaviour _x != "COMBAT" } == -1;

hushed turtle
#

Indeed

broken pivot
#

So Im only getting a return if unit is in combat?

hushed turtle
#

It will alwayas return something

#

Either true or false

hushed turtle
#

behaviour only works on units and not groups

broken pivot
#

How does it effect cars?

#

In wich way

hushed turtle
#

Only units and groups have behaviour

winter rose
#

cars are inert objects πŸ‘€

broken pivot
#

Ahhhhh

#

The diffrence are units and groups

#

Thats all

winter rose
#

yes
engine-wise a unit is an Object

broken pivot
#

a group is a group

winter rose
broken pivot
winter rose
#

please don't πŸ˜„

#

(I don't mean "don't stay alive" :p I mean "don't rely on coffee to stay alive" :D)

broken pivot
#

Weed feeds my mood

#

This is true freedome
Because Im happy

broken pivot
# broken pivot Weed feeds my mood

Honestly I dont believe in the shakespeer theory that it makes creative. It just release drivin in thinking whise. Sometimes not helpful.
But thats not the right place. Lets continue progress

#

Somehow it makes me happy somehow it depress me that Im not that far on my own.

broken pivot
# winter rose well, if you create a thread, it runs *especially* with a "while true"

How can I stop it? My first thought: giving the while state a globe var and turn this one false like:

loop = 0 spawn {
while {sleep 5; true;
    } do {        
        if ((sascha_insassen_passiv && !_LouMontana_combat_cond)
        ) then {
        hint format ["Battle cond is %1", _LouMontana_combat_cond];
        systemChat "Einheiten passiv";
        sascha_kampf = false;
        };
        if ((!sascha_insassen_passiv or _LouMontana_combat_cond)
        ) then {
        hint format ["Battle cond is %1", _LouMontana_combat_cond];
        systemChat "Einheiten aktiv";
        sascha_kampf = true;
        if (isNil "sascha_konvoi_fzg1"
        ) then {
        loop false;
        };
        };
    };
};

Now its "finished"

#

Can this work?

cosmic lichen
#

Loop is a script handle not a boolean

broken pivot
#

Then this cant work

cosmic lichen
#

You want to have a boolean variable in you while condition.

#

While {myVar}...

If ....
MyVar = false

broken pivot
#

That would be a if-Cause

cosmic lichen
#

Also naming variables LouMontana makes the script run 42% slower.

broken pivot
#

EBER-Tags neutralize all negativ effects

regal kraken
#

test

#

huh thats weird i just sent a message but it told me i couldn't

#

I two questions regarding help with scripting.. both involving a dedi unfortunately. I'll start with the more simple question

I have a supply truck driving back and forth from an airbase to an fob, it involves a random so it could either one of the two locations on the map. As per usual, it works fine on a singleplayer and listen server, but on dedi it doesn't work at all.

I believe it might be the IF statements.. as the vehicle just goes Straight to the last waypoint and fails to fire the executable. is there something I've done wrong for it not to work on a dedi?

#
 _waypoint1 = _group1 addWaypoint [getPosASL _randomLocation, 1];
                _waypoint1 setWaypointType "MOVE";
                _waypoint1 setWaypointBehaviour "CARELESS";
                _waypoint1 setWaypointStatements ["true", "[[27, _driver], 'scripts\crate_script.sqf'] remoteExec ['execVM'];"];
                _waypoint1 setWaypointTimeout [2, 3, 4];
                
                if (_randomLocation == RESUPPLY_WP_LOGIC_DEPOT_FOB) then
                {
                    _randomlocation2 = RESUPPLY_WP_LOGIC_DEPOT_FOB_LEAVE;
                    _waypoint2 = _group1 addWaypoint [getPosASL _randomLocation2, 1];
                    _waypoint2 setWaypointType "MOVE";
                    _waypoint2 setWaypointBehaviour "CARELESS";
                }
                else
                {
                    _randomlocation2 = RESUPPLY_WP_LOGIC_DEPOT_NAVY_LEAVE;
                    _waypoint2 = _group1 addWaypoint [getPosASL _randomLocation2, 1];
                    _waypoint2 setWaypointType "MOVE";
                    _waypoint2 setWaypointBehaviour "CARELESS";
                };
                
                _waypoint3 = _group1 addWaypoint [getPosASL RESUPPLY_WP_LOGIC_DEPOT_BASE, 1];
                _waypoint3 setWaypointType "MOVE";
                _waypoint3 setWaypointBehaviour "CARELESS";
                _waypoint3 setWaypointStatements ["true", "[[_driver], 'scripts\logistics\supply_script.sqf'] remoteExec ['execVM'];"];
                };```
winter rose
digital hollow
regal kraken
#

oh boy.. I did the if statements and completely removed the random array

digital hollow
#

I guess you gotta buy a BI plush to help you with rubber duck debugging =)

regal kraken
#

honestly i need to just post this stuff on a discord before asking questions, as soon as its on here - it sticks out like a sore thumb

#

on that same script however, it execs the crate_script.sqf which I know works because it was the last way point being triggered anyway.. but it's supposed to set a variable for "Cash" - I've noticed that even though I have it set to All machines, it doesnt really want ot set the variable for cash at all

#

I have it currently set as

_killpot = KILL_POT1;
_killpotcash = _killpot getVariable ["Cash", true];
_Cost = 1500;
_NewFunds = _killpotcash + _Cost;
_killpot setVariable ["Cash", _Newfunds, true];
#

sorry thats the full line for context

#

now from what i understand that True is global

#

is there any type of magic i need to do for that to work for an AI?

digital hollow
#

that is being run on every machine by remoteExec? seems like it should only run on a single machine

regal kraken
#

well i have it set to remoteexec 2 but I havent actually tested it now since the whole forgetting the random array

#

i'll just test that first before asking more, i think it was just wanting to make sure it was sound but with the code failing to trigger on dedi anyway i need to test it

#

Okay last question, I promise i'll leave for a month after this πŸ˜…

#

doing a weapon gui - works great on single and listen, usual speech
however on the dedi, everything displays correctly - it just doesnt give the player the weapon

BuyWeaponGUI = 
{
    params["_Control","_Player"];
    _WeaponData = _Player getVariable "WeaponChoice";
    _Price = _WeaponData select 0;
    _Weapon = _WeaponData select 1;
    _Mag = _WeaponData select 2;
    _wItem1 = _WeaponData select 3;
    _wItem2 = _weaponData select 4;
    
    _Cash = _Player getVariable "Cash";
    if(_Cash>=_Price)then
    {
        _NewCash = _Cash - _Price;
        _Player setVariable["Cash", _NewCash, true];
        [_Player,_Weapon,_Mag,_wItem1,_wItem2] remoteExecCall ["GivePrimary", _Player];
    };
};```
#

now that last 'give primary' was originally

[_Player,_Weapon,_Mag,_wItem1,_wItem2] call GivePrimary;
#

but when it failed to give the weapon we changed it to RemoteExecCall because we thought the description fit the function but that too has flopped

#

just dedicated servers out to kill me apparently

digital hollow
#

I'm no gui pro, but I would assume it's running local to the client and not on the server?

regal kraken
#

I believe so as its called via hold action

#

I know you said you arent a gui pro - but should i change the call from execVM to remote execute?

icy ridge
#

What does the fnc GivePrimary look like?

#

And whats your use case looking like?

In other words, how does a player interact with your code?:

  • How does he open the GUI?
  • Where are the functions declared?
  • Does the server handle anything during the interaction?
broken pivot
#

Can someone say me how I can return the units:


sascha_gruppen_array = [sascha_grp1, sascha_grp2, sascha_grp3, sascha_grp4,
                    sascha_grp5, sascha_grp6, sascha_grp7, sascha_grp8];

sascha_gruppen_units = {{units _x} forEach units _x} forEach sascha_gruppen_array;    
icy ridge
south swan
#

and don't forget to declare/initialize the units array with sascha_gruppen_array = []; before the loop blobdoggoshruggoogly

icy ridge
#

forEach returns, as stated on the wiki:

Return Value: Anything - will return the value of last executed statement

icy ridge
digital hollow
#

Can also do this

_units = flatten _groups apply {units _x};
south swan
#

eyyy code golf

proven charm
#

i had to put ```sqf
flatten (allgroups apply {units _x});

south swan
proven charm
#

i wonder how fast that is

granite sky
#

Very fast. In general array manipulations are fast.

#

Similarly the difference between deleteAt 0 and deleteAt N-1 is usually smaller than calculating N-1

broken pivot
split scarab
#

I don't get why this is giving me an error, both _dog and _randomPos exist, cause the dog is playing the animation I want and moving to _randomPos, how come distance2D won't work?

waitUntil { sleep 0.5; (_dog distance2D _randomPos) <= 1};
south swan
#

what are the contents of variables? Error message kinda looks like you try to give it an empty array blobdoggoshruggoogly

split scarab
#

I figured it would have plenty of room to get a "empty" position

south swan
#

welp, your assumptions are challenged by harsh reality πŸ™ƒ

split scarab
#

What about that? (updated code), that should make it keep trying to get a position until it succeeds right?

south swan
#

good enough. Still has an assumption of "it will find the position eventually", but i suppose it's much less likely to fail πŸ™ƒ

digital hollow
#

Maybe increase the search area on each iteration

split scarab
#

So I fixed the _randomPos stuff but the damn _dog moveTo _randomPos; doesn't work using dedicated server...

randomDogPos = {
    private _randomSafePos = [];
    while { count _randomSafePos == 0 } do {
        private _randomPos = [["dog_area"], ["water"]] call BIS_fnc_randomPos; 
        _randomSafePos = _randomPos findEmptyPosition [0, 10]; 
    };
    _randomSafePos;
};

[] spawn { 
    sleep 15;
    _dogArray = ["Fin_sand_F", "Fin_blackwhite_F", "Fin_ocherwhite_F", "Fin_tricolour_F", "Fin_random_F", "Alsatian_Sand_F", "Alsatian_Black_F", "Alsatian_Sandblack_F", "Alsatian_Random_F"];
    _dogs = [];
    for "_i" from 0 to 1 do {
        _dogs pushBack (createAgent [selectRandom _dogArray, ([] call randomDogPos), [], 0, "CAN_COLLIDE"]);
        (_dogs select _i) setVariable ["BIS_fnc_animalBehaviour_disable", true];
    };
    [[sideLogic, "Base"], "Guard dogs spawned."] remoteExec ["sideChat", allCurators];

    {
        [_x] spawn { 
            params ["_dog"]; 
            private _animMovement = ["Dog_Walk", "Dog_Run"];
            private _animStop = ["Dog_Stop", "Dog_Sit"];

            while { alive _dog } do {
                _randomPos = [] call randomDogPos;
                _dog playMoveNow (selectRandom _animMovement);
                _dog moveTo _randomPos;
                waitUntil { sleep 0.5; (_dog distance2D _randomPos) <= 1};
                _dog playMoveNow (selectRandom _animStop);
                sleep ([15, 60] call BIS_fnc_randomNum);
            };
        };
    } foreach _dogs;
};
#

I tried [_dog, _randomPos] remoteExec ["moveTo", -2]; as well, didn't work either

proven charm
#

where do u run the code?

split scarab
#

In initServer.sqf

tame lion
#

Having some what seems to be weird behavior here and wanted to know if someone more experienced could help. I am writing code which will populate an area w/random civs walking around. I want some of these civs to have a weapon slung over the shoulder to emulate an eastern market kinda thing where not everyone with a weapon is a bad guy. However, every time i spawn the unit and give them a gun, they do not sling it and instead attack blufor with it. Here is the quick code I wrote to do this:

_civ = (createGroup Civilian) createUnit [(selectRandom C_civilians), (player modelToWorld [0,15,0]), [], 1, "FORM"];
sleep 0.5;
_weap = selectRandom C_weapons;
_mag = compatibleMagazines _weap;

_civ addMagazineGlobal (selectRandom _mag);
_civ addWeaponGlobal _weap;

_civ action ["SwitchWeapon", _civ, _civ, -1];
//C_civilians is an array of civilian classnames. C_weapons is an array of weapons which they will spawn with for ref.
#

Nevermind, fixed it with this:

civilian setFriend [west, 1];
west setFriend [civilian, 1];

However if anyone knows how to force a unit to sling its weapon to shoulder apart from how i'm doing it above, that input would still be appreciated

proven charm
#

try sleep 1 before "SwitchWeapon"

tame lion
#

negative, at most he appears to be starting the animation, but doesn't get further than lifting the weapon from lowered state

proven charm
#

what if u do _civ setBehaviour "SAFE"; first, i have that in my code, then sleep

tame lion
#

still no luck, only thing that seems to happen is now he begins the animation twice but doesn't complete and keeps the weapon lowered

#

ttried "CARELESS" behavior too to see if that helped.. No luck

#

the only workaround I can think of is spawning a weapon holder on the ground and hoping to attachTo it to the civ. but that is a lot of extra work for not the payoff that I want

proven charm
#

this code works for me (I put officer on the map in editor): ```sqf
this spawn {
params["_npc"];
_npc setBehaviour "SAFE";
_npc removeWeapon (primaryweapon _npc);
sleep 1;
_npc action ["SWITCHWEAPON",_npc , _npc ,-1];
};

tame lion
#

I think that the difference in your code and mine is that you are removing the equipped weapon, leaving the unit no choice but to be unequipped. Whereas I am trying to make the unit unequip their weapon and shoulder it

digital hollow
#

That only works for sidearms on AI, not primary

tame lion
#

sounds like there is no easy way to accomplish what I want. Only other way i can think is by doing something like attaching a groundholder w/the weapon in it to the units back

#

I wonder how ACE/CBA accomplishes it πŸ€”

south swan
#

i mean NPC switches to the sholdered primary when i remove equipped secondary even after ```sqf
c disableAI "ALL";
c enableAI "ANIM";

tame lion
#

might just scrap the idea

south swan
#

inb4 backpack with weaponholder model

tame lion
#

eh that sounds like i gotta make a mod to get this gamemode to work

digital hollow
#

make a launcher version of every rifle

digital hollow
tame lion
digital hollow
#
_simpleObject hideSelection ["zasleh", true];
mint flame
#

Whats a script for making an ai gunner in a mortar fire at a specific position ?

mint flame
#

do i need to make ai select firing mode for distance too?

#

or will this cmd do that for me?

#

if i have a position to fire at, rounds, ammo

thin fox
#

it requires you to have: position, type of ammo (class) and rounds (number)

mint flame
#

but what about firing mode?

#

if u try to hit a palce 5km away with firing mode 0 with max distance 1km, it wont work right

thin fox
#

πŸ€”

mint flame
#

Do u know about firing modes

thin fox
#

no, maybe someone else knows

thin fox
mint flame
#

yeah

#

but some mods add lots

thin fox
#

oh, no, you don't need that

#

for that command

mint flame
#

ok well i did doartilleryfire and the guy is firing like, the shell very close whislt target is 1km away

#

with single1, first mode

thin fox
#

well for me always worked fine, even with mods

#

don't know what kind of mods do you use for mortars

tidal idol
#

Is there a way to see the internal code on waypoint types such as SEEK AND DESTROY? Config viewer doesn't point to anything useful in cfgWaypoints.

mint flame
#

doartilleryfire really not making ai fire anything

thin fox
tidal idol
digital hollow
# tame lion Close lol, but the simpleObject has the fired animation as part of the model. Th...

Something like this

params ["_unit"];

private _primaryWeapon = primaryWeapon _unit;
if (_primaryWeapon == "") exitWith {};

private _loadoutPW = getUnitLoadout _unit param [0];
_unit setVariable ["C_loadoutPW", _loadoutPW];

private _model = getText (configFile >> "CfgWeapons" >> _primaryWeapon >> "model");

private _simpleObject = createSimpleObject [_model, [0,0,1000]];
_simpleObject hideSelection ["zasleh", true];
_simpleObject attachTo [_unit, [0.45,0.550,-0.25], "weapon", true];
_simpleObject setVectorDirAndUp [[1,0,0],[0,0,1]];

_unit setVariable ["C_holsteredPW", _simpleObject];
_unit removeWeapon _primaryWeapon;
_unit action ["SwitchWeapon", _unit, _unit, 299];
modern plank
#

Hy guys, back in SQF coding business, I fail to understand why I cannot easily put an "addAction" into a loop... it looks like a kind of lazy evaluation issue since all actions defined will behave like the last one...

I would like to write:

tv addAction["<t color='#1155BB'>Atelier 1</t>", { [[3513.02,6785.48,0], [3295,17620]] call atmtk_tgt_teleport;} ];
tv addAction["<t color='#1155BB'>Atelier 2</t>", { [[11312.8,5834.11,0], [11720,15209]] call atmtk_tgt_teleport;} ];
tv addAction["<t color='#1155BB'>Atelier 3</t>", { [[8322.2,14081.6,0], [9130,24795]] call atmtk_tgt_teleport;} ];
tv addAction["<t color='#1155BB'>Atelier 4</t>", { [[18614.9,4942.91,0], [17403,15848]] call atmtk_tgt_teleport;} ];```

in something more generic like:

teleport_locations = [
[[15728.2,12417.2,0], [15705,22658]],
[[3513.02,6785.48,0], [3295,17620]],
[[11312.8,5834.11,0], [11720,15209]],
[[8322.2,14081.6,0], [9130,24795]],
[[18614.9,4942.91,0], [17403,15848]]
];

{
loc = _x;
tv addAction["<t color='#1155BB'>Atelier " + str(_forEachIndex + 1) + "</t>", { loc call atmtk_tgt_teleport;} ];
} forEach teleport_locations;


The issue is all actions from Atelier 1 to 4 will teleport to the latest location, namely   [[18614.9,4942.91,0], [17403,15848]]. Any idea?
faint burrow
#

loc stores the latest position. Pass position through arguments param.

modern plank
#

Thank you!

Works better with:

tv addAction["<t color='#1155BB'>Atelier " + str(_forEachIndex + 1)+ "</t>", { (_this select 3) call atmtk_tgt_teleport;}, loc];

faint burrow
#

You don't need loc global var:

{
  tv addAction [
    format ["<t color='#1155BB'>Atelier %1</t>", _forEachIndex + 1],
    {
      _location = _this select 3;

      _location call atmtk_tgt_teleport;
    },
    _x
  ];
} forEach teleport_locations;
modern plank
#

Sure, I just hurried to test 😊

regal kraken
# icy ridge And whats your use case looking like? In other words, how does a player interac...

Sorry mate, had to run out earlier

  • the Gui is opened with the Holdaction call
    however we have tried using execVM and remoteexec to call it

Functions wise, hes did it in a sqf which is called by the button in the controls
we're currently on action = "[_this, player] remoteExecCall ['BuyWeaponGUI', 2]"; which seem'd to be working for taking money but not working for giving the players the weapon

the server is handling alive and stuff ontop of it but the other GUI is working, its just not wanting to give a player magazines or weapons

we thought it was because it wasn't set to Global, however its now no longer taking the money

#

we're fried with it at this point, it works perfectly fine on listen and single but dedi just seem's to not want to work and we've been at it for hours now

#
call{[ 
this, 
"OPEN VENDING MACHINE", 
"\a3\ui_f\data\IGUI\Cfg\simpleTasks\types\meet_ca.paa", 
"\a3\ui_f\data\IGUI\Cfg\simpleTasks\types\use_ca.paa", 
"true","true", 
{hint "Shop Status: Loading..."}, 
{}, 
{ 
hint "Shop Status: Complete"; 
[0, player] execVM "scripts\WeaponGUI.sqf"; 
}, 
{hint "Shop Status: Interrupted"}, 
[], 
0.5, 
nil, 
false, 
false] call BIS_fnc_holdActionAdd;  
this setVariable ["R3F_LOG_disabled", true]; };```
#

thats the holdaction we're now back to using

#

it was this

call{[ 
this, 
"OPEN VENDING MACHINE", 
"\a3\ui_f\data\IGUI\Cfg\simpleTasks\types\meet_ca.paa", 
"\a3\ui_f\data\IGUI\Cfg\simpleTasks\types\use_ca.paa", 
"true","true", 
{hint "Shop Status: Loading..."}, 
{}, 
{ 
 hint "Shop Status: Complete"; 
 [[0, player], "scripts\WeaponGUI.sqf"] remoteExec ["execVM"]; 
}, 
{hint "Shop Status: Interrupted"}, 
[], 
0.5, 
nil, 
false, 
false] call BIS_fnc_holdActionAdd;  
this setVariable ["R3F_LOG_disabled", true]; };```
mint flame
#

Guys why is my ai mortar gunner so inaccurate he cant fire the 120mm pm 43 properly at trh target its always missing by 100s ofmeters

granite sky
#

@regal kraken

Functions wise, hes did it in a sqf which is called by the button in the controls
we're currently on action = "[_this, player] remoteExecCall ['BuyWeaponGUI', 2]"; which seem'd to be working for taking money but not working for giving the players the weapon

Should just be [_this, player] call BuyWeaponGUI. I don't see anything in there that should be remoteExec'd.

#

The cash is handled by a global setVariable anyway.

regal kraken
#

okay i've changed that back to [_this, player] call BuyWeaponGUI;

granite sky
#

I don't see anything here that initially sets the cash variable on the player, so that might be an issue.

regal kraken
#

that is handled in the initplayerserver
its literally just this

_GROUNDFUNDS = (paramsArray select 10);

if (_GROUNDFUNDS == 1) then 
{
    _PlayerUnit setVariable ["Cash", 10000, true];
    if ( _PlayerUnit in Nothem ) exitwith {};
};

if (_GROUNDFUNDS == 2) then 
{
    _PlayerUnit setVariable ["Cash", 5000, true];
    if ( _PlayerUnit in Nothem ) exitwith {};
};

if (_GROUNDFUNDS == 3) then 
{
    _PlayerUnit setVariable ["Cash", 2500, true];
    if ( _PlayerUnit in Nothem ) exitwith {};
};

if (_GROUNDFUNDS == 4) then 
{
    _PlayerUnit setVariable ["Cash", 1000, true];
    if ( _PlayerUnit in Nothem ) exitwith {};
};

if (_GROUNDFUNDS == 5) then 
{
    _PlayerUnit setVariable ["Cash", 500, true];
    if ( _PlayerUnit in Nothem ) exitwith {};
    
};
#

we're trying to work towards persistant cash which is why it looks.. particularlly messy

modern plank
#

Ouch. Whenever you duplicate several times the same thing, it means that it is time to use arrays or loops instead.

regal kraken
#

yeah i completely agree this could be entirely more optimised

granite sky
#

So what's the issue at this point?

regal kraken
#

when the player uses the Gui - it takes the cash, displays everything
but it doesnt give you the weapon you chose

modern plank
#

You should define an array like:

cash = [0, 10000,5000,2500,1000,500];

Then do it once :

... setVariable ["Cash", (cash select _GROUNDFUNDS), ...

granite sky
keen stream
#

BigWilk made a nice forum post and mod about that.

regal kraken
#

going to test it one more time just to double check

cobalt pier
#

Hey all, I'm looking for a way to attach an object to the turret of a tank and have it rotate with the turret independed of the tank it's overall attached to. Anyone able to help?

broken pivot
hallow mortar
cobalt pier
#

Sorry I'm new to this, what am I doing exactly?

granite sky
#

New as in "never written SQF"?

#

Or new as in "wtf is a selection?"

cobalt pier
#

both

#

for attachto I'm using

BIS_fnc_attachToRelative

#

never been really all there with Arma scripting

hallow mortar
#

A basic attachTo looks like this:

_childObject attachTo [_parentObject];```
That's the minimum. With this, the child object will be attached to the "base" of the parent object, not any of its sub-parts.
There are additional optional parameters for `attachTo` which give you more advanced functionality. You need to use them to do what you want.
The first is the **offset**. This specifies a 3D distance, relative to the parent object, to position the child object after attaching. In principle, we don't need it for attaching to sub-parts, but we have to provide it in order to reach the next optional parameter.
Next is the **memory point**. Arma models contain memory points and selections, which are used as reference points, proxies, animated bones, and texture selections. `attachTo` can attach things to memory points within a model. We're going to attach your object to a memory point that's part of the turret.
Finally, there's **follow bone rotation**. By default, when you attach something to a memory point that can move relative to the model base (such as one on the turret), the child object follows the memory point's _position_, but not its _rotation_. Rotation stays locked to the model base. This parameter makes the child object follow the mempoint's rotation.

A complete `attachTo` looks like this:
```sqf
_childObject attachTo [_parentObject, _offset, _selectionName, _followBoneRotation];```
cobalt pier
#

ahh right I see

#

and how would I go about finding the specific bone?

#

i'm assuming it's MainTurret?

hallow mortar
#

It might be, it depends on the vehicle you're using. You can use e.g. copyToClipboard selectionNames cursorObject in the debug console to see all the options, then try different ones until you get a good one.

cobalt pier
#

QAV's Challenger 2 is the specific one I'm using

#

but I'll have a try at the mentioned method

hallow mortar
#

The offset is going to depend on where you want the child object to sit, relative to the target memory point. You can do some 3D position maths with selectionPosition, modelToWorld*, and vectorDiff to base it on the current relative position of the objects, or you can specify a position [x, y, z] to do it manually.

#

The follow bone rotation parameter is a simple boolean and we want to set it to true.

cobalt pier
hallow mortar
#

classic

#

Well you might as well just do selectionNames cursorObject and copy it from the return line, it's less annoying than stringifying the output

cobalt pier
#

that worked, thanks

#

yea its mainturret

#

Quick Q

do I NEED the full
_parentObject, _offset, _selectionName, _followBoneRotation

or can I just use?

_followBoneRotation

hallow mortar
#

You must have them all. Some of them are things we specifically need to make this work (the parent object, the selection name), and the offset must be specified because the array of parameters is interpreted sequentially. The game knows that the third parameter is the selection name; if you skip one before that, it'll be wrong.

warm hedge
#

You cannot skip one to write later ones

cobalt pier
#

rodger that

#

thanks

#

what would the selection name be?

#

or where would i find it?

hallow mortar
#

Well, according to your investigation, it's "mainturret"

cobalt pier
#

apologies for all the questions, I actually haven't a clue what the fuck I'm doing lmao

#

So

this attachTo [CR2, _offset, mainturret, mainturret];

#

is that correct?

hallow mortar
warm hedge
#
this attachTo [CR2, [0,0,0], "mainturret", true];```
hallow mortar
# cobalt pier So ***this attachTo [CR2, _offset, mainturret, mainturret];***

You're getting there.

this attachTo [CR2, _offset, "mainTurret", true];```
Note that `_offset` needs to be replaced with an actual offset `[x, y, z]`, either by dynamically doing maths to generate one, or by specifying one like POLPOX showed. (Probably don't use `[0, 0, 0]` exactly, for the reason I mentioned above)
cobalt pier
#

Yea just tested it, it worked but rotated the item on it's 0,0,0 position but that's fine I can fix that

#

thanks so much troops, mega

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```
↓

// your code here
hint "good!";