#arma3_scripting
1 messages ยท Page 368 of 1
So
Sleep (user defined time);
Or
Waituntil { time < (user defined time) }
Sorry no
jup...
But waitUntil would actually be worse than your while loop. So.. use Sleep
time cannot bdefined?
ignore that nigel ^^
missionNamespace setVariable ["time", 10]
might work ... not sure right now
Thanks for your help @robust hollow & @still forum
Does not work, says "reserved variable in expression"
another thing i never tried
thats why i cannot recall any ref here
I think the catch with setVariable was that it compares case-sensitively.. tImE might work
You actually can
last time I told someone to overwrite switch as a test he reported it did indeed break scripts containing switch
Variable stuff has nothing Rly to do with the command stuff
but.... sadly noone told BI
oO wut
ages ago I started working on an ambient life script, never really finished it. I'm about to give that another shot.
within reason
i dont really care what they do in their little houses
as long as it seems a bit more realistic when the fighting starts
not more than usual ^^ It's arma after all
I believe I've seen my fair share of script-related madness over the years.
hmm good point
maybe its best to have them move around a little as possible xD
atleast until they have to run and hide somewhere
its annyoing when they run all over the place all the time
many scripts do that
one thing i'd really like to implement is to give them homes
and to actually make them run inside and lock the door behind them
that should add a nice touch
a totally underused feature in my eyes
is there a discord channel dedicated to SQF and Arma scripting topics specifically?
nice
well... this is a scripting channel for arma, so this one?
do you guys know how to force the AI boat driver to hit the sand? he stops on the edge of the beach.
@robust hollow nah, I'm looking for something more topic-oriented, like "Dialogs", "Displays", "AI behavior", "Anims", "coordinates", etc. where there's a channel for each so to say tag / topic in A3 scripting
sort of all falls under scripting
because I want to discuss or get help for something specific and don't want it to get buried under everything else?
I dunno, that's my preference ๐
BIF sucks ๐
ask the question, make it the topic of the channel ๐
Usually stuff doesn't get burried here
compared to the steam forums, no it doesnt ๐
unless your question is so effortless and dumb that everyone ignores it
I mean, the forum itself sucks for me, however, the community is pretty nice
I've got nothing against it
``nah, I'm looking for something more topic-oriented, like "Dialogs", "Displays", "AI behavior", "Anims", "coordinates", etc.
Dialogs&Displays are configs usually #arma3_config
AI behaviour #arma3_ai
Anims #arma3_animation
coordinates... uh.. what?
don't really have time to explain, but coords is for all the position porn in Arma 3, modelPosToWorld, etc
scripting
oh right, havent really tried messing with ctrlCreate yet
todo list is getting longer and longer :/
- any ctrl type you define in ur mission
๐ค
i use it to make premade control groups for HUDs and stuff
god, if only SQF had objects as an abstraction in the first place, it'd make all ctrl bullshit more bearable
and the syntax much more readable and maintainable
oh my... just looked at my previous attemt at ambient life and noticed its from 2013. time passes way too quickly oO
Theres no direct translation to that
You tell em to move to a position
And theyll try their best
or, they will stop and do nothing
Thats their best, then
in my case is a boat, he dont wanna hit the land
In that case, a little bit of setVelocity might to the trick
Or unitCapture? Or the other new move command where you give an array of positions?
unit capture won't match waves
Good catch on the waves
https://community.bistudio.com/wiki/addForce <-- this is also pretty cool
i did something like that a while ago, setting a velocity to be sure the boat reaches the beach
bitch
Youd need a little loop i guess
no boat for the bitch then ? ๐ฏ
๐
_initMag = vectorMagnitude _initVel; <--- why not simply "speed" ?
params pls
Because speed is not necessarly == vectorMagnitude
make params great again
I guess
and because speed is in km/h
and only relative speed on Y axis
So actually a completly different thingymabob
ah, right
that along its forward axis thing, cant decide if brilliant or retarded
i get it about params... it's an old script...
i made params great again
didn't really needed private, it was in a "spawn" with nothing else
Hey would anyone be able to help me with a little issue im having with a script?
EDIT: https://hastebin.com/mitupaviza.cpp its susposed to give you that you found a weapon but it just gives you the "you didnt find anything" hint whether or not you did find anything but the "rare item" part works fine...
thanks ๐
@slender halo as soon as you have a single call infront of your script private gives performance benefit... But doesn't really matter if you don't have a loop in there.
oops thats not the whole script my Copy Paste broke
wtf is with that indentation :U
I don't have time for waiting :u
i put the new link on my older post ๐
if your lootChance is between 7 and 175, youd get two hints. is that intended?
no
code actually looks good...
its susposed to be if its less than 7 or above 175
If you get the "You didn't find stuff" hint that means it worked.. But you just didn't find anything
your code is written to do that, since its two separate if statements
Yeh but dedmen i actually did find something when i look in my inv
theres two chances the code after else will run
Oh right
thats my issue ๐
Because if you hit <7 the first statement will give you loot.. the second one will overwrite your "you found stuff" hint with a "you found nothing" hint
its the two hints
oh i had no clue lol im very new to arma sqf
Oh, how would i fix that? i was thinking i could use a switch do but i had no idea how it works from BI Wiki
I like
// switch(FETCH_CONST(life_donorlevel)) do
// {
// case 1: {_lootChance = random(170);};
// case 2: {_lootChance = random(150);};
// case 3: {_lootChance = random(130);};
// case 4: {_lootChance = random(110);};
// case 5: {_lootChance = random(90);};
// default {_lootChance = random(200);};
// };
@haughty scarab Put the second if statement into the else of the first
ok will try that thank ๐
alternatively exitWith when true
theres no more code after, anyway, except for setting that variable to false
Right ok, im gonna try it now thanks for the help guys
also, select floor random count --> selectRandom
why is the chance to find a rare higher than to find a weapon ?
the rare isnt actually rarer than the weapon thanks for pointing that out haha gotta edit the hint
I like that donor's can't find rare's ๐
switch (selectRandomWeighted [
"nothing", 65,
"weapon", 25,
"rare", 10
]) do
{
case "nothing":
{
/* STATEMENT */
};
case "weapon":
{
/* STATEMENT */
};
case "rare":
{
/* STATEMENT */
};
};
thats an attractive code block...
that's not how it works
lol
sigh
`
i wouldnt select directly in the switch, dat shits ugly
๐
i agree nick ๐
good call on that command tho
probably not useful for his specific case though
hmmm
@haughty scarab the parameter to increase lootchance
lowers the random value
private _type = (random 100) call {
if (_this > 65) exitWith { "nothing" };
if (_this > 25) exitWith { "weapon" };
"rare";
};
because you can
that would make rare items actually less probable
what do you mean? (sorry lol this is only my first week doing any scripting at all)
_lootChance = (round(random(200)) + 1) - (missionNamespace getVariable ["mav_ttm_var_lootIncreased", 1]);
You know we also have https://community.bistudio.com/wiki/selectRandomWeighted ?
someone called disableAI on him?
He noticed that he is a Arma AI and now also want's do behave like one
make an example
kill him
remove him
replace him
๐
that'll teach em not to disobey your orders
AI lives matter
oh
enableSimulation?
give him a push with setVelocity?
did you gave the pilot a waypoint ?
try setVelocity [0, 1000, 0]
i mean, it won't help but its always funny to play with set velocity
is it scared?
enablefleeing / CARELESS behaviour
turn off the radars?
gently talk to it using positive words
ah wait
you do that on the vehicle
try it on the crew also
wait you dont
read wrong im a pickle
i count the collision lights as a win personally
give him a landing waypoint on an invisible helipad far away?
delete the pilot unit and immediately spawn in and move in a fresh one
im magic
figured the engine might be in a special behaviour
cool to see it works
what caused it to land in the first place, tho
Params ๐ช
I dont think its actually attempting to land, just forcing a subroutine to boot
[] call selectRandomWeighted [
{
// do something
}, 65,
{
// do something else
}, 25,
{
// or this
}, 10
];
that command is fun ^^
Any idea why this CBA settings checkbox doesn't show up in the settings? @little eagle send help```SQF
[
QGVAR(doWaypoint),
"CHECKBOX",
["Custom Waypoint", "Toggle custom, distance indicator-less waypoint."],
"A3 Overrides",
true,
true
] call CBA_Settings_fnc_init;
No errors.
Nope.
does the script file they are in get called?
what file is that? pre/postInit?
preStart?
XEH_preInitClient.
I've done the same thing in another addon, only with sliders and editboxs ๐
Works flawlessly.
then i propose the addon isnt loaded, that XEH isnt included in the config.cpp or other shenagigans
you can make sure its loaded by adding a cheeky diag_log
CfgEventHandlers isn't the same as CfgEventhandlers?
and if #include doesn't find the file your game kills itself
config names are also case insensitive
How do I return the element location in an array
what?
goal:
select a random array element with kinda weighted array, but I want weights to change once they have been selected
you want the chance of picking a random element to change after a random element has been picked?
Yes
I just thought of a way
array with 2 elements
and then i convert it to 2 arrays
value/weight
@still forum - still doesn't work. preInitClient is indeed loading.
Yes, that's what Im gonna use, I just need to change the weights once it's used
selectRandomWeighted [ [0,"something"],1, [1,"something1"],1.5, [2,"something2"],5 ];
So the more it's used, the less it will appear. so in the end I would have a large variety
selectRandomWeighted should have only had weights required and just returned selected index
true
Sure you can just send an array of indexes but that's more data thus bit slower
@peak plover use find to turn element into array index
_array = [
[1,"wurst"], 12,
[3,"kรคse"], 3,
[5,"zwiebel"], 9,
[7,"pizza"], 1
];
(selectRandomWeighted _array) params ["_i","_result"];
systemChat _result;
_array set [_i, (_array select _i) - 1];
why the 3 numbers?
ughh wait
That looks wrong to me somehow.
Yes, but having the index as first element is just weird. Why not make it an array with multiple copies of Kรคse?
selectRandom ["elem1", "elem1", "elem2"]
he wants to change the weights depending on which element was selected
private _array = [
"wurst", 12,
"kรคse", 3,
"zwiebel", 9,
"pizza", 1
];
private _result = selectRandomWeighted _array;
systemChat _result;
private _index = (_array find _result) + 1;
_array set [_index, (_array select _index) - 1];
i think that's what commy is talking about
The way I posted has a cleaner array without duplicated information.
well... why waste resources to find something that you already know ?
So you don't have arrays with redundant information. Less error prone.
you might need to reset weights every once in a while, too
not sure what happens when all chances are 0
and if you have numbers in the array instead of Kรคse
you'll run into troube using "find"
That's true.
#define PROBABILITY_LOSS 0.5
private _weights = [1, 9, 5];
private _classnames = ["classname1", "classname2", "classname3"];
private _classname = _classnames selectRandomWeighted _weights;
private _index = _classnames find _classname;
_weights set [_index, (_weights select _index) - PROBABILITY_LOSS];
use the alternative syntax
Interesting.
private _cargoArray = [["medsSmall",30],["generic",25],["pistol",30],["smg",15],["rifle",10],["mg",3],["at",5],["custom1",5],["custom2",5],["custom3",5],["ammo",1]];
_boxes = _boxes select {
if (random 100 >= 75) then {
private _cargoTypes = [];
private _weights = [];
private _nul = {
_cargoTypes pushBack (_x select 0);
_weights pushBack (_x select 1);
false
} count _cargoArray;
private _cargo = _cargoTypes selectRandomWeighted _weights;
private _change = _cargoArray select {(_x select 0) isEqualTo _cargo};
_cargoArray set [(_cargoArray find _change),[_change select 0,(_change select 1)-1]];
_x setVariable ["unit_loadout_faction",east];
_x setVariable ["unit_loadout_cargoType",_cargo];
};
};
you could also generate the ids in the array instead of writing them by hand
zgmrvn looks clean
Nah, I like zgmrvn's version the most.
you might want a minimum weight of 1, though
bready sure it can't be nigative
yeh that -1 was just an example
i still dont like the idea of having to search the array to ge the index
yup
Return Value: Anything - random weighted value or Nothing if array is empty or all weights are 0
Sounds reasonable.
So if I always remove 1 it wil lend up being 0, so I don't need min/max
until everything is 0 and you get nil
so youll need some logic to maintain what you deem a reasonable minimum distribution
I'll my array variant, and add a third variable
Did it mention if it works with non integers?
non negative real numbers
or however the hackers call them.
dollars?
haha
floaties
โ+
๐ฎ
yea
magnificent
"Floats" sounds to me like those simple boats you put together from tree trunks. ยฏ_(ใ)_/ยฏ
โ0
Not โ+
im rusty on my sets
Raft! That's what I'm thinking of.
private _change = _cargoArray select {(_x select 0) isEqualTo _cargo};
_change set [1,(_change select 1)-1];```
โ includes negative numbers tho
Floร
Yup.
Really??
๐
I meant Dedmen.
hmm...
should
๐คฃ
select CODE
does copy the array
ah because it returns an array with all fitting elements
Yes.
yeah okay that sucks
Agreed, apply and select shouldn't copy the arrays ideally. Because you could just add a + to achieve that. But, oh well.
No one listens to me.
@peak plover you could by doing something like
(_array select 5) = 32.5
you cant do that in sqf, tho
what does that mean
you can maybe vectorAdd if arma allows you to cheat that
in order languages that would modify that array index directly
but sqf doesnt let you access array elements like that
apply/select have to copy the array.. except if the condition is always true for select. Or always returns the same values that were there before with apply
its wierd since its just the elements, youd expect it to simply use the pointer instead of explicitly making a copy
ah, engineland territory then
_var = 35;
_var2 = _var;
_var2 is not a copy. It's a reference to the same value
But if you modify it you create a new value
โ
_a = [1,2];
_b = [3,4];
_c = [_a,_b];
_d = _c select 1;
_d set [1,9];
``` would modify _b tho?
yes
Then engineland must be different when writing values to arrays
hmm btw. @peak plover
private _nul = {
_cargoTypes pushBack (_x select 0);
_weights pushBack (_x select 1);
false
} count _cargoArray;
ew
this does the same
_cargoTypes = _cargoArray apply {_x select 0};
_weights = _cargoArray apply {_x select 1};
If you broadcast nil on a variable will it remove it from the JIP queue?
yes
CBA = MacroManiacs ยฏ_(ใ)_/ยฏ
i see little need to use it nowadays
extendes EHs are nice
but not necessary either
Is there also a way to disable automatic assigning of tasks after your current asks succeeds/fails etc
@tough abyss copyToClipboard ((supportInfo "") joinString toString[13,10]);
should also work ๐
endl is new
The answer is: Yes.
That implies that you have to drink at least 4-5L of Coffee ^^
pretty Strong Brew. And before that happens -> Brown Flood will happen ๐
Good point
wish there was a way to completely remove/hide doors on vanilla buildings
always feels weird to breach a door and have it swing open towards you
@tough abyss diag_log has a length limit. CBA_fnc_debugLog get's around that limit
? in BIS_FNC_ConsolidateArray
Why is the following used..
_cntNil = count (_this - _this);
I dont see how _cntnil can return anything other than 0 ?
Can someone please explain this useage
Full code
#include "..\paramsCheck.inc"
paramsCheck(_this,isEqualType,[])
private _cnt = count _this;
private _cntNil = count (_this - _this);
private _ret = [];
{_ret append [[_x, _cnt - count (_this - [_x])]]} count (_this arrayIntersect _this);
if (_cntNil > 0) then {_ret pushBack [nil, _cntNil]};
_ret
civ_1 switchmove "Acts_Kore_Introducing";
this animation for some reason is verry bugy
the character jerks around on the ground doing other animations
buggy ?
have you tried using it with "playMoveNow" ? so it gets a proper transition ?
maybe its having a fit, afterall, all ai now have their own brains , only the leader used to have one ๐
player disableAI "BREATHE";
RIP
did u ask a medic to look at the ai ?, maybe its suffering from epilepsy
i am the medic
he is supouse to do a set of animations afhter being revived
0 = this addEventHandler ["HandleHeal", {
[_this select 0, _this select 1, _thisEventHandler] spawn {
params ["_injured","_healer", "_EH_Handle"];
_startDamage = damage _injured;
waitUntil {damage _injured != _startDamage};
if (damage _injured < 0.2) then {
_injured call BIS_fnc_ambientAnim__terminate;
Sleep 1;
_injured switchMove "AmovPpneMstpSnonWnonDnon_AmovPercMstpSnonWnonDnon";
Sleep 1;
_injured disableAI "PATH";
_injured call BIS_fnc_ambientAnim__terminate;
Sleep 1;
_injured setFormDir (_injured getDir _healer);
Sleep 2;
_injured switchmove "Acts_Kore_IdleNoWeapon_in";
Sleep 2;
_injured switchmove "Acts_Kore_Introducing";
Sleep 4;
_injured switchmove "Acts_Kore_IdleNoWeapon_out";
Sleep 2;
_injured enableAI "PATH";
_injured call BIS_fnc_ambientAnim__terminate;
_injured removeEventHandler ["HandleHeal", _EH_Handle];
};
};
}];````
but, all he does is jerk around on the ground with other animations
with cba logging using trace you get file, linenumber, variable name and value printed
it's kinda superior to diag log
@astral tendon Some animations just don't work when beeing called
is there a way to make it work or is it hard coded?
HardCoded
Rip
Those type normaly work:
AmovPpneMstpSnonWnonDnon_AmovPercMstpSnonWnonDnon
Those: Acts_Kore_IdleNoWeapon_in mostly not (especialy in MP)
What cuel said. TRACE_n you can at least leave inside your code and it will be removed at compile time when not in debug mode. Unlike diag_log which you either have to remove yourself or have SQF checks for it which is kind of expensive.
lol, did the TestDance anim get forcefully screwed up? Won't even play in anim viewer, player's hands just kind of get stuck inside their back
The anim is called "test" so maybe.
Well sure, but it had worked ingame a while back. Not sure if that has actually changed since Alpha. Haven't looked at it since
civ_1 playActionNow "gestureYes";
is not working, i did something wrong?
neider is playAction working
Command doesn't seem to be functional
Where?
Well, maybe the thing appears in config, but has no actual gesture linked to it. That's just how these things are.
"This is War"
can someone quickly tell me if
private _var = nil still privatizes the variable?
Time's up. I went with private _var = scriptNull instead
yes it does
trying to save positions of containers (IE ammo crates) whats the bes type of pos to use? currently using getPosATL
@grizzled spindle ATL will be just fine unless you've got that object out on the sea obviously. (getPosASL in that sense, Above Sea Level)
Yeah, For some reason got em spawning sometimes outside houses
What do you mean? How are they created?
What format do you save them?
And you're saying, if the object was inside a house then it spawns them outside?
Sometimes inside
sometimes bottom floow (when should be top) sometimes outside haha
getPosATL
Then setPosATL will place them at the same position.
Thats what i thought
You sure you don't use position or getPos?
yeah
I need help, how to get speed and damaging power of any bullet that flyby near me within 50 meters. please help me if anyone know, how to do it
that doesnt do what you think it does
FireNear?
I mean unless you've got something better
no but thats certainly not a solution
"damaging power"
nearObjects
@subtle ore thanks! i already tried it but still not getting how to implement this to get speed and damage power of any bullet flown near me
Firstly
There is no "damaging power"
Damage power
@indigo snow yes! you are right
velocity _bullet
@subtle ore when bullet come close
Will nearObjects check for bullets commy?
@little eagle but how to detect taht bullet is coming close to me
or rather, filter for bullets
Why wouldn't it?
because bullets are cfgAmmo and those are wierd
Not quite sure. My first though was that it was because it's defined as a magazine, not a vehicle.
but how to detect taht bullet is coming close to me
Instead of moving away? Calculate the angle between the velocity vector of the bullet and the vector from the bullet to the player.
can we treat bullet as a vehicle in script ???
If the angle is sufficiently small enough, the bullet is incoming.
@little eagle you are damn intelligent ๐
oka but how we can get speed and damage power after detecting ??
vectorMagnitude velocity _bullet
That will give you the absolute velocity in m*s^-1
Dunno about "damaging power". I guess the closest is the hitconfig entry of the bullets CfgAmmo class? But that is also multiplied by the current velocity devided by the typicalSpeed entry of the magazine.
yes correct
can we use init_speed variable of arma 3 to get current speed ?
init_speed given in ammocfg
No, that would be the speed it exits the muzzle, not the current speed.
oka
thanks for valuable info..will ask for help i stuck on that again..:)
here is my sound mod pls sub it and give me feed back
I don't have Arma on this machine, nor Steam.
oka np once u have subt it ๐
this addEventHandler ["respawn", {this enableFatigue false;}];
this is supouse to remove Fatigue of the player that respawn
is o its init
but is not working
this is no longer the object in the respawn eventhandlers code. The respawned units is passed as argument instead in _this instead. As first element.
this addEventHandler ["respawn", {_this enableFatigue false;}]; ?
No, read the wiki. _this is almost always an array.
how?
this addEventHandler ["respawn", {[_this] enableFatigue false;}];
still errors
and the wiki have no exemple of arrays
i dont know
maybe is the unit that is holding the init code?
why are you guessing?
you should be finding out
look it up on the wiki, or log the value some way
systemChat str _this
systemChat _this wouldn't work would it? don't think systemChat can convert an array to a string
^^
yeah there you go
this addEventHandler ["respawn", {player
enableFatigue false;}];
i copy that to all playable units, this will work or there can be only one "player"
no, that wouldn't work in MP
in SP this would be fine
but unless it's local to the unit (which it's not if it's in the unit init) then this won't work
There is no respawn in SP.
you missed the point commy. { player enableFatigue false;}]; player
in the unit init?
You said this would work in SP, but it's a respawn eh, so no by default.
๐คฆ
Am I wrong?
No you're not. But my point was that using the player in SP would work, but not in MP. Or at least not when the unit is not local
2 letters.
wasn't talking about the eh
^^
In a way I can see this working with player. But it's absolute garbage code. And it didn't bring any understanding of what's happening.
how about inside a onPlayerRespawn.sqf?
ahk IS so good
What?
I assume commy was talking about AutoHotKey?
Yes. Adding the math symbols and sub and superscript right now.
Will be so much easier to write that stuff soon.
addMPEventHandler MPkilled vs addEventHandler Killed. If other players don't need to know who killed who or that someone died....Can I just use addEventHandler and have a script connected to that to handle everything?
@tulip cloud addMpEventHandler is added on every machine, iirc it can also be local to that machine in some cases
If you don't wan't others knowing, then a mp event handler shouldn't be your choice
Has anyone measured the impact difference of the 2 scripts?
yeah.
I doubt there would be a difference, but i can check for you if you are un available to do so
I'm unsure how you would test it. Seems you would need a full server and test the performance impact. If I'm correct using MPEventhandler mpkilled fires on all machines including the server. So he more clients the bigger the impact.
Am I reading the documentation wrong?
EH code will trigger globally on every connected client and server.
@tulip cloud The performance impact should be super tiny
If I am correct, that command also registeres the eventhandlers in the case of JIP, so that would be the only real performance impact it could have
yeah jip
even if we are talking 0.1120 ms vs 0.073 ms....it is significant enough to consider it.
Yeah then it bloats up the list abit which gets run down when you join in progress, but apart from that it's one-time network execution and then everyone handles the trigger locally
In what case do you need this performance gain?
Just making sure every script is as efficient as possible.
That's really not necessary ๐
call me OCD
JustinWaters, you are OCD ๐
you should see my spreadsheets....
I'm slightly curious now
Spread sheets now? Do you happen to wear a tinfoil hat too ? ๐
lol, nah. But thanks for your guy's support. (Don't want the hammer coming down for being too far offtopic.)
Psshhh. #arma3_scripting is about as offotpic as it gets
so, i am trying to make units run from the area ignoring the firefight
the civilians intead stop in the middle of it doing nothing
so, if i put they on careless thet walk in the middle of the bullets
and i put this set of commands
this disableAI "AUTOTARGET";
this disableAI "SUPPRESSION";
this disableAI "AUTOCOMBAT";
this disableAI "COVER";
this disableAI "TARGET"; ```
and they still behave like that
also diabled FSM and seens like they are even dumbier
they are all in the same group
what i am missing?
https://community.bistudio.com/wiki/allowFleeing
I'd assume allowFleeing 1 would be more what you want, but this is arma ๐คท
@astral tendon
@tulip cloud It all depends on what you do with them and at what scale. MPEHs simply send network message when appropriate event fires somewhere locally which tells everyone else to execute the event handler too, unless you have thousands of vehicles constantly getting these events triggered, having few network messages from time to time and simple event scripts executed should be a drop in the ocean.
It all depends on your approach in designing the mission. If you absolutely sure that certain vehicle will never change locality then just add local event on client that will own it. If locality might be all over the place then MP events might be okay but you can always just add same EH on all clients, it will be pretty much the same thing as having MPEH, minus said microscopic network impact.
Yeah MPHit might be worst of them all considering how often it might end up running
But again it all depends on what you do
Well, it depends. Having heavy script on EntityKilled might not be worth it if you need Killed\MPKilled just on few entities
Just add the hit eh on all machines... It's the same as killed. It will only fire on the machine that owns the object, and that will be exactly one machine every time.
grr
๐ค
@tulip cloud If other players don't need to know who killed who or that someone died you mean only the server needs to know ?
you mean south of lakatoro?
why is it that, when the server adds items to a crate (when the crate is initialized), the client can see the items but cant take them. only items added by the client can be taken by him?
@tough wharf use the global version of add..cargo
@simple solstice i used addItemCargoGlobal
@tough abyss seems like its just a bush?
Did you disable the simulation of the ammo box?
nope
i can open the inventory, i can see the items added by the server, but i cant take them
only the items added by the client
What item?
backpacks weapons items, a mixed variety
shooo
Anyone stopping civilians ?
_x spawn {
sleep (0.5 + random 4.5);
doStop _this;
_this stop true;
sleep random 10;
_this stop false;
};
shoot them. @peak plover
But I am the polcei
put a gun next to the corps
I'll make a script that youcan interact with dead bodies and "plant evidence?"
Yeah
you could disableAI "ANIM" then set them in the animation of your choice
or maybe disableAI "PATH"
does doStop stops a unit with a smooth transition? f.e. stopping him while he's sprinting? will it be an instant stop or will the unit slow down gradually?
you could always do switchMove aswell on the unit
isn't switchmove instant while playmove is smooth?
I was replying to nigel, saying it should be more instant
good question actually
how do you open the arsenal without it adding the damn addaction? i need this [] spawn BIS_fnc_arsenal; but without addaction. it seems to automatically add a scroll action, if you call the code from your own addaction. weird
nvm. got it. for some reason the addaction param is in the addvirtualinventory functions
@polar folio could you share the solution maybe? ๐ in code, if possible.
well you jsut call it like above or like this ["Open",false] spawn BIS_fnc_arsenal; to get the arsenal with only what you have and your virtual inventory
just make sure to use the virtual inventory functions with the addaction param set to false beforehand
[player, getUnitLoadOut _x, false, false] call BIS_fnc_addVirtualWeaponCargo; // first bool
making a class based arsenal that draws the available stuff from editor placed units
actually you have to init it differently it seems. jesus this is confusing. will post it on the forums once it all works
wait waahh
is there no fucken way to open this shit with your own virtual inventory NOT using the premade addaction? going crazy over this shit
Copy the function @polar folio and put it into your own file...
Then remove everything
trying to avoid that. thx for the hint though
Hello! So... Is there an EventHandler or some prefered way to detect when a player changes his current weapon? Don't want to have to check if _oldWeapon isEqualTo currentWeapon player every damn frame. So... Is there anything like that? Couldn't find it in the EH documentation.
I have one, but want to avoid clugging it with useless stuff
Gonna try checking on the AnimChanged EH and check if the anim contains a reloading sequence
CBA does that.. It checks every damn frame and fires a scripted eventhandler
@still forum I'm avoiding CBA or any addons :(
And anyways, that just feels wrong, I do that with some things, but only extremelly needed stuff and in 0.2s-1.0s loops (not every frame)
Well.. Dozens of mods can just keep their own loops and recheck their things.. Or they all use the same framework and only a single loop exists..
Better that way, I prefer to have control and kill the loops whenever needed
And anyway, found a way to filter the reload anims
Found a regex and it seems that depending of a few leters at fixed position you can determine if it's a change of weapon or any other thing
Someone should index that thing out
Gonna index them out
Reloading doesn't fire AnimChanged etc. for rifles. They use gestures, not animations - and those are different things in this game. The animation names have a pattern, but there are exceptions to those, so idk how safe it is to rely on them.
My units keep reacting to firefights, is there a way to force they to ignore it?
the civilians are supouse to flee to a safe area instead they stop in the midle of the firefight
No idea if there's a way to make them completely ignore it, but I've found that allowFleeing 0 and disableAI "FSM" makes them pretty reliably reach their destination at least
They'll stop for a bit when they hear gunfire, but continue pretty quickly instead of running in a random direction or starting crawling
i set they to careless and seens to work
and put this
this getSpeed "FAST";
on their waypoint
seens to work right
I thought you can't get units to anything but walk with careless?
they do
but puting that on the waypoint make they run
seens to not work if i stuck it on the units init
is anyone having adding items to a virtual ammo box?
I am adding items to the box, and the function returns that they were added sucessfully
but there is nothing in there
weapons and such are fine
but just items that I'm having problems with
[] spawn
{
{
waitUntil{!isNull _x};
sleep 1;
private _box = _x;
if(isServer) then
{
clearWeaponCargoGlobal _x;
clearMagazineCargoGlobal _x;
clearItemCargoGlobal _x;
clearBackpackCargoGlobal _x;
} else {
clearWeaponCargo _x;
clearMagazineCargo _x;
clearItemCargo _x;
clearBackpackCargo _x;
};
{
[_box,(configName _x),false,true] call BIS_fnc_addVirtualWeaponCargo;
{[_box,(configName _x),false,true] call BIS_fnc_addVirtualMagazineCargo;} forEach (getArray(configFile >> configName _x >> "magazines"));
} forEach ("isClass _x" configClasses(configFile >> "CfgWeapons"));
{
_items = [_box,(configName _x),false,true] call BIS_fnc_addVirtualItemCargo;
if(count _items == 0) then {hint "broke"; };
_box setVariable["Weap",(configName _x)];
} forEach ("((isClass _x) && (configName _x) isKindOf 'Vest_Base_F')" configClasses(configFile >> "CfgVehicles"));
} forEach (entities "B_supplyCrate_F");
};
@little eagle Thanks for the info! (sorry for late reply ๐ฆ )
Anyone can guess what it will output in RPT? ```sqf
["test1", "test2"] call {
24;
call {
diag_log [_this];
}
}
heheheheh
๐
lol wtf
I may have cheated
[["test1","test2"]]
I'm not sure how that gets wrapped at all
Oh, the brackets around _this, idiot me
Looks like _this just doesn't get redefined for the second call so it uses the previous _this
Well, ye
Exactly
I noticed it cause I was getting an error on a parameter which was expecting a boolean but got a display
Since a display was passed into it, from the other script
Unary this just reuses current this
That's why you put nil or an array in front of it
What's the deal again with including game files from the missionfile? I must have forgotten what the issue is with it again...
Randomly results in crashes while on other machines it works fine, strange to me
@rotund cypress Without reading further down the chat, [["test1", "test2"]].
@queen cargo If you use nil call {...}, the code block will not be executed and no error will occur in both scheduled and unscheduled environment. Also unary call does not reuse _this. It just doesn't overwrite it with a new one. Which also means that it's not set to private in the code block.
I made this ages ago, maybe helps understanding unary vs. binary call: https://gist.github.com/commy2/bf74c199070be8877de94c58fb6cbe8c
@tame portal It crashes the dedicated server when choosing the mission from the mission select screen as admin, preventing the mission to load.
https://i.imgur.com/KStsfHQ.png ~_~ Why is the lamp a house?
Why is a snake a man?
"Snake_random_F" isKindOf "Man" //true
Because one class inherits from the other.
I mean, If i'm trying to create a list of, well, houses, i'm going to need to filter out some of those things
What kinds of houses do you need for your list?
Well what i'm doing is using the config coded locations of cities, then creating a marker with a 200m radius and counting the total number of buildings in that marker area. If the array created using "House" also includes lamps, its not going to be accurate for what I want. And I want houses, enterable or not at this stage
Have you tried nearestTerrainObjects? Because that one uses the same logic as the map for it's filter.
Would that no still have the same issue of using "House" filter?
It doesn't use classes as filter, but another sort of type unrelated to class inheritance.
Oh, interesting.
_types = ["NameCityCapital","NameCity","NameVillage","NameLocal"];
_objectives = [];
{
_a = [_x] call EO_listLocations;
_objectives = _a + _objectives;
} forEach _types;
systemchat str(_locPos);
{
_locPos = LocationPosition _x;
_nearBuildings = nearestTerrainObjects [_locPos, ["House"], 200];
if ((count _nearBuildings) < 10) then {
_c = _c + 1;
systemChat str(_c);
_objectives = _objectives - [_x];
};
} forEach _objectives;
_objectives
Is what i'm using to create the locations at this stage
Possible type names:"TREE", "SMALL TREE", "BUSH", "BUILDING", "HOUSE", "FOREST BORDER", "FOREST TRIANGLE", "FOREST SQUARE", "CHURCH", "CHAPEL", "CROSS", "BUNKER", "FORTRESS", "FOUNTAIN", "VIEW-TOWER", "LIGHTHOUSE", "QUAY", "FUELSTATION", "HOSPITAL", "FENCE", "WALL", "HIDE", "BUSSTOP", "ROAD", "FOREST", "TRANSMITTER", "STACK", "RUIN", "TOURISM", "WATERTOWER", "TRACK", "MAIN ROAD", "ROCK", "ROCKS", "POWER LINES", "RAILWAY", "POWERSOLAR", "POWERWAVE", "POWERWIND", "SHIPWRECK", "TRAIL"
And those might be more accurate.
Use other properties to tell house from general building like doors or windows in config, maybe check if it has buildingPos positions
Cities and villages should already have locations on the map.
They do yea, but some of them on Altis for example are very small but are considered a City
Or Village
I want larger areas for this portion
Actually checking doors, windows or positions might not work for A2 terrains with non-enterable buildings
Checking if they existed or the config entry for them would surely still function though @meager granite
Aren't some gates or even fences have config entries too?
I'd say you try nearestTerrainObjects with HOUSE, BUILDING, LIGHTHOUSE, CHURCH and CHAPEL and see if that get's rid of your lamppost problem.
Yea it seems more effective so far. I'm now trying to think where to even begin with trying to increase the marker size to the "edge" of a city
something like gradually increasing circle size if theres still buildings
You can get the center by adding up all x positions and y positions and dividing by the number of houses.
I've actually been thinking about same problem for some time now, to have Wasteland mission automatically parse island and try to find what can be considered a city\village
@little eagle Thats an interesting idea, I thought of that for really simple towns similar to say "Paros" on altis where a simple circle would easily conform like that. But for an area like Kavala, where it'd need to be an Ellipse shape is where i'd believe to run into issue with that
@meager granite Thats essentially the idea. I'm populating cities and areas with enemies. Trying to improve performance on spawning in large areas in comparison to what i'm doing currently, which is creating a "grid" for each building
True. You can get an ellipse with this, but it will always be aligned with the maps north and east.
I wish we could create several profile namespaces so you don't have to save ton of data to disk when you change 0.01% of it.
A better data saving method for persistence would be a nice thing for ArmA 4
If you want to turn all cities in ellipses... You'd need to find the axis with which the cities longest side is angled towards the maps east... ๐ค This should be possible somehow.
Yea I essentially need to create a relatively accurate ellipse around all cities (well, the ones I'm filtering as decently sized)
For some reason, Oreokastro on Altis isn't being considered in the list as having enough buildings ๐ค
Find the y center by the method I described.
Find the x center of all houses above the y coordinate.
Find the x center of all houses below the y coordinate.
Connect and you have an axis.
Too bad I don't have Arma atm to try this out.
I'll try that out, it might take me a while aha, my usage of Maths in SQF/ArmA is quite an interesting escapade
Maybe you can do the same with reversed x and y. And then you get two non-orthogonal axis (plural?). Pretty sure that can be turned into an ellipsis.
Where's the interesting part?
Well, there are lots of algorithms and approaches for this task, so whatever you find interesting for yourself.
I can't find the one that would solve this problem.
I'd go with something like this
We don't have markers like this do we? But we have triangles, right? So you could make one out of this I guess.
Build such tree, find two buildings farthest from each other, draw a circle between them
You'd do that on both Axis Sa-Matra no?
Might be bit more complicated if you want ellipse, but very easy if you want a circle around all objects
I mean, the circle situation is solveable, its really when doing ellipses for places like Kavala that are long not simply circular
Googled "ellipse around cluster", plenty of articles and posts on this topic
Are you trying to find out if bounding boxes intersect or something?
Bounding boxes are very unreliable and might not represet actual object's size
Take Zamak for example, it has bounding box extended forward by a lot
The Hunter is the same
ah, you're using lineInterects
Should they be always the same four _i ?
I mean the bottom plane. Should be two iterations for it and they should always be the same index.
@little eagle - aren't animals under CAManBase?
No, they are not under CAManBase, which is why you should always use CAManBase as filter and not Man.
๐
I do, but going through walls handled differently, corpse follows your path so it rarely ends up going through walls
And I need surface checking because I manually set corpse Z each frame
Both
Corpse is actually a ragdoll
So when drag stops, it falls down into ragdoll
Its pretty compliated with lots of crutches to avoid arma bugs, but somewhat works
Bugs like this: https://www.youtube.com/watch?v=eUI04HTyXOU
Armanormal activity
They just need to play their game in multiplayer sometime
Various ragdoll bullshit happens in 100% multiplayer games
there is a rule on what needs to be local or global?
i wanna play around with RNG especially puting units to spawn in radown places
but im afraind that in a server that may not work right
There are these icons on the top left. AL EG. Those tell you how to use a command in MP.
but i have this situation
it does say noting about it
it does say noting about it
i was testing with my friend and see that those comands dont really work right
but if i put this ```if (isServer) then { [[this, selectRandom ["PRONE_INJURED_U1", "SIT_LOW_U", "PRONE_INJURED"],"ASIS"],BIS_fnc_ambientAnim] remoteExec ["call"] };````
seens to work for us
we see the animation
if i add that ```remoteExec ["call"]```` its seens to make it work
that maybe work to all other global commands?
If you remoteExec a global effects command, like addItem, you'd end up with 5 items if 4 players are connected to a server.
that means RIP performace?
No, it means too many items.
then the animations will be playing to all players in the server?
can i take this example to any other command?
like
[<unit>,<morestuff>] remoteExec ['anycommand',0];
};```
that is some good piece of info, i will save those examples
i dont know if you can anser that, but why AI seens to be random in MP?
in my last mission, when playing in coop the AI drives act totaly diferent
In SP they seens to work fine
it was this one
http://steamcommunity.com/sharedfiles/filedetails/?id=1150897167
yuck i see so much remoteExec call lately
even when its just a single command that could be used with remoteexec directly
maybe ppl are just too lazy for that
call for one command is silly.
is there a way to remotely switch on laser designator?
QS, it's not about performance (or traffic here really), but making twice as many keystrokes for something that in the end looks more ugly than it has to be.
@dim terrace What kind? A player holding a laser designator in his hands. Or that remote controllable thing that was added in Marksman dlc?
@dim terrace action fire should do
last time i did that was in OFP, and I think it worked
this one
or actually
_unit forceWeaponFire ["Laserdesignator","Laserdesignator"];
try this
.
has anyone tried disabling certain AI sections for unarmed civilians?
I wonder if there could be performance gained from it
@cunning nebula forceWeaponFire works great - thank you ๐
Hey, does anyone know why my custom vehicle texture dissapears after 5 seconds ? after 5 seconds half the car is invisble
@haughty scarab same behavior in both SP and MP?
couldnt test , basiaclly im on life mod so when i buy the vehicle its fine when i store and retrieve from garage it goes invis after 5 seconds
could be your life mod's bug or some bullshit conflict causing one thing to override another, or idk... this is Arma ๐
haha
sounds like the path for the texture is stored wrong
here is the texture path : "Textures\CopSUV.paa"
I guess you can try debugging it with showScriptErrors param in the launcher
well sure... the question is what the garage does with that
so the game can scream freely at you if you're doing smth wrong
I think you shouldn't even be here if you have showScriptErrors disabled ๐
good ๐
haha, agreed, another thing is to check the rpt logs?
but i dont get any errors at all every other texture works fine its just this one its custom
haven't played Arma in a while though, don't remember their exact loc
erm i cant actaully open my rpt logs
"File size is to large for notepad to open"
sad face
try notepad++?
the script that restores the vehicle when you take it out of the garage
delete it or restart arma
ill delete it and retest
lol, run a bash script that will shred that file into pieces?
@indigo snow is right though, just delete it so it resets on next launch of Arma (i believe that's how it works)
ok thanks ๐
@timber ridge it will create a new rpt file every launch on windows
if its a server.rpt, you need some fiddling if youre on linux
Anyone know the sqf command for testing actionNamedSel (new engine tech used for door/ladder changes). nm found it was getCursorObjectParams
no erros in my rpt
Dose anyone have a teleportor script that teleports me on to the carrier?
setPosASL
this is what i am dealing with---> _tele = _this select 0;
_caller = _this select 1;
_caller setPos (getpos (BacktoBase));
hint "Player has teleported to Base.";
Thx
hey, i am a noob in scripting but i wanna link a modul to a player when he is selecting it on an objekt
this AddAction ["modul1","modul1.sqf"];
and i have no idea what to write in the .sqf ??? what i know is that i need the player attachTo [modul1, [0, 0, 0] ];
open that
press ctrl + F
search for "sync"
find this: synchronizeObjectsAdd
also, bookmark that url ๐
you'll need it alot
@winged narwhal
I'd use setPosASL and getPosASL instead. Both commands work in the ASL format.
If you use getPos and setPos, you have to commands that surprisingly work in different formats. AGL vs AGLS. That means that you'd spawn inside buildings or on the waves if the BackToBase object is on a house/stone or on an aircraft carrier.
This can be avoided by using the mentioned ASL commands.
thx for the help guys i already got it to work thx to @still forum
does CBA has assoc array functions ?
let me check
hashGet/hashSet
looks like what i was looking for
If im looking to run something server side that is going to be in a while{true} loop should I use spawn or execVM. I want the task to be executed with 0 delay
and this loop will last throughout the server
Scheduled (spawn\execVM) loop without delay might execute several times a frame
If you want precise per frame execution, use addMissionEventHandler ["EachFrame", {call mycode}]
thanks ๐
A while loop without delay in scheduled WILL execute 3ms a frame basically it will run as often as it can in that frame. And then it will not execute till all other scheduled scripts ran atleast once
spawn/execVM is both the same essentially
And what would you recommend if I want something to run exactly every 5 minutes
Using CBA for most basic scripting tasks ๐
Yep nano second and yes I have CBA
impossible
_unit = _this select 0;
if ({!alive _x} count crew _unit == 0) then {_unit setDamage 1}
}];````
But as you have CBA just use https://cbateam.github.io/CBA_A3/docs/files/common/fnc_waitAndExecute-sqf.html
i am forgeting someting?
yes
nextExecutionAt = 0;
addMissionEventHandler ["EachFrame", {
if(diag_tickTime >= nextExecutionAt) then {
nextExecutionAt = diag_tickTime + 5 * 60;
// Something that happens exactly each 5 minutes
};
}];
@meager granite You just rewrote something that CBA already has. Benefit being none. And you are now running one more EachFrame handler.
Its better to have engine go through list of events
Rather than script go through script array
@meager granite Actually wrong in this case
your code is getting recompiled every frame
which is very bad
and very much slower than a script going through an array
That is how it works
engine only stores eventhandlers as strings.
which get compiled before every execution
Code is compiled even before it has anything to do with addMissionEventHandler
{call my_fnc}
instead of
{my many lines of cunction}
@astral tendon Why don't you call it _vehicle then?
maybe if ({!alive _x} count (crew _unit) == 0) then {_unit setDamage 1;};
@meager granite Repeat. Engine turns your code back into string. And stores that. And compiles it back to code before every execution.
Probably a leftover from SQS times.. I reported it to BI over a year ago
Pretty sure there is a feedback ticket for that somewhere
@still forum - Classic BIS.
Dwarden added a comment.Feb 14 2017, 6:41 PM
thanks, we will take look into this
๐
I could fix it in a couple hours.. But they don't let me ofcause
@biminions hire dedmen
So if you have CBA. And want to do something that CBA can already do. Please don't try to reimplement something that's already there
Should still be faster than iterating script array
compiling functions.. noo by far not
It'd be great if BIS hired Dedmen.
Also the CBA array is sorted. So it doesn't iterate past the first element if that's not due yet
@still forum still nothing
9000 fps servers, EH perforamnce gains, what's not to love
Recompiling a couple hundred chars of code is not faster than checking one number in one array element in SQF
All your CBA logic is definitely slower than compiling single expression string
single expression string.. maybe.
But that CBA stuff doesn't have a lot of logic.
And you not only compile the string. you execute it too
and at that point...
Wasn't there a graph with CBA vs vanilla
Also the CBA loop is already running. Adding a new loop won't make that first one disappear
You could always just remove the CBA :P
Really wish it didn't use Macros, it really makes trying to find out were a BE log snippet came from alot harder.
nextExecutionAt = 0;
fnc = {
if(diag_tickTime >= nextExecutionAt) then {
nextExecutionAt = diag_tickTime + 5 * 60;
// Something that happens exactly each 5 minutes
};
};
addMissionEventHandler ["EachFrame", {call fnc}];
then
Yep.. Makes the compile overhead lower.. But..
Still one extra loop.. doing essentially the same work that CBA does
So should I start using more cba to save performance on stuff Bohemia broke?
Yes
Atleast before you are going to reimplement something that's already there.. Just use CBA
CBA was made by people who know ALL the SQF quirks and most definetly made a better job at implementing that than you could ever do
CBA is basically sex.
does anyone know how to block the arma cheat codes like endmisson and flush etc: https://community.bistudio.com/wiki/ArmA:_Cheats
Doesn't CBA each frame handlers calculate deltas and other stuff for each handle?
I think so yeah
@barren magnet About a dozen people asked that over the past month.. Afaik no.. not really
You can
That is a pity ... cause they should reall be disabled in MP ...
I just check shift and numpad minus at the same time
onCheat is only for that one cheat. Not for endmission/flush
Well at this scale there would be no performance gain then
Screws with a few players
Yep. Add a keyhandler is a way
i do so too and tell arma that is was handled, but it does not care what my keyhandler does
@barren magnet Crash their game as they're about to type it
10/10 solution XD @meager granite
@meager granite Yes. No performance gain by using CBA functions.
But if every mod has it's on eachFrame loop performance get's worse
๐
Seriously, just track key presses and crash before last symbol
Lol
Even better, instead of crashing use saveprofilenamespace in a loop, burn a hule in their HDD
I freeze my players
We had players duping with endmission. Had to block it
^
https://feedback.bistudio.com/T121356 There you have a crash if you need one
@grave torrent then how did you do it?
Key up event handler