#arma3_scripting
1 messages ยท Page 258 of 1
rly? Oh boy^^
that class thingy looks trippy as fuck
Intercept is what we need, not that macro mess. ๐ฆ
^
Alright this is going to be the most useless and time consuming idea I'll ever present.
If we wrote an external DLL that could parse a "project" folder containing .cs files and return a ton of sqf code that is compiled and ran in game we could do stuff like...
class Main {
public static void Main(string[] args) {
ArmA3.SetDamage(ArmA3.Player,1);
};
};
---- this c# code block gets parsed into ----
Main__Main = {
params["_args"];
player setDamage 1;
};
Variables and functions could be formatted
Namespace_Class_Variable
Again, absolute waste of time, but it'd be cool lol
That or just writing a DLL that loads LUA into the game and makes calls to engine functions for scripting commands.
Having either, though useless, would open arma to more developers who have experience in other languages lol
Not that again t.t
There were also other guys, who did that before and stoped ๐
Why? Not worth the effort.
^ yeah i was being sarcastic lol
ah, kk.
Maybe one day someone will waste 6 months of their life and do it
It needs a "Sarcasm"-Sign for Text.
And in the end, they will notice: I wasted 6 Months ๐
I wonder why
$ <- better
lol
ยง I wonder why ยง
Any idea why a spawned NPC who is set to play a specific animation after an extremely short sleep would occasionally NOT play that animation?
_NPC disableAI "MOVE"; //wont move. sleep .1; _NPC switchMove "AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon"; //hands behind head.
works, occassionaly. Executed server side on init.
Not sure if you missed something when copying it, but you have NPC in one place, and _NPC in another
yeah its _NPC, missed the _ in copying.
the underscore*
.. so apparently underscore is a formatting thing lol. it's _NPC in all required places.
This is correct?
_objs = [
call compile "34623200# 19330: cargo_house_v2_f.p3d",
call compile "32b78f00# 117394: cargo_house_v2_f.p3d",
call compile "2c866400# 67508: cargo_house_v1_f.p3d",
call compile "2c83b900# 66500: cargo_house_v2_f.p3d",
call compile "2c7f0800# 66360: cargo_house_v1_f.p3d",
call compile "334c5600# 149655: i_stone_shed_v1_f.p3d",
call compile "29809600# 158269: slum_house01_f.p3d"
];
i converted objects to string and now want to transform then in real objects again and put then into a array.
for example this is an object in string format "29809600# 158269: slum_house01_f.p3d".
how can i turn it again to object type?
its an object native to the map
call compile "[0,0,0] nearestObject 19330",
for the first one
i don't think it's a great way of doing it though because the IDs change when they update the maps
Reason he wants the actual objects?
TypeOf()
easy to find after
Will get you the class name.
yes, thankyou
I think the best solution is to save the type and position, then you just need to look for the nearest object with those parameters.
I don't think you can do anything to convert the string for the object back to an object
What I mean is, you can't do anything with "29809600# 158269: slum_house01_f.p3d" once it is a string
yeh that won't work adjustmentteam, typeOf takes an object, not a string
yes. thankyou a lot. i'm precalculating some things on my mod for specifc maps. so i need to store map objects
@native hemlock you could use call compile "[0,0,0] nearestObject parseNumber ((((_string splitstring " ") select 1) splitstring ":") select 0),
to get the map object from a string
Feed it into _arry = []; {[_array pushBack typeOf(_x,getPosATL(_x); true;} count(nearestObkects);
but it would break when BIS updates the map
Yes, so that's not viable
yes it handle
i do some heavy calculations that result in a array of map objects. i will store those objects in Mysql or in a sqf file so dont need to calculate on every server start
_arry = [];
{
_array pushBack [typeOf(_x),getPosATL(_x)]
true;
} count(nearestObkects);
i go sleep
That should handle it
thankyou
np
Nice
Thumbs up
@velvet merlin Will we be getting an updated MP scripting tutorial anytime soon?
A lot has changed since PV days
And information about the subject is scattered?
not by me sorry
what is the safest way to know if something is a helicopter? will it always have simulation type "helicopterrtd" or can it be something else?
isKindOf "helicopter" should be safe.. but there is the possibility of people making them without any base classes (although I don't think anyeone does)
I think RTD is something to do with advanced flight model, so there's probably at least one more simulation type (maybe just helicopter or something)
isKindOf "helicopter" should work
according to the config dump simulation can be just "helicopter" too
isKindOf "helicopter" returns true for parachutes
@tough abyss no idea. my bet would BI is using them for Eden or some other stuff; other possibility its a fancy exercise for some of their scripters
[12:54 AM] Quiksilver: @halcyon crypt i dont think we need a scripting language for a scripting language
@tough abyss How is Intercept/C++ a scripting language for a scripting language?
Intercept sits between A3's native functions behind the SQF commands and your own native code.
Only downside is that it's sort of dead at the moment but it is/was functional for the biggest part.
yeah it sounded awesome, gave you the ability to bypass sqf altogether
i'd also try it if it was complete (and would somehow be supported in new arma versions.. don't know if it is already)
@lethal cave I think you might want to use Helicopter_Base_F to exclude parachutes.
See:
class ParachuteBase: Helicopter {
class Helicopter_Base_F: Helicopter {
Also, even Helicopter_Base_F includes quadrocopter UAVs
class UAV_01_base_F: Helicopter_Base_F {
class UAV_03_base_F: Helicopter_Base_F {
UAV 03 is the KH-3A Fenghuang drone, which doesn't even have rotors.
nvm. it's apparently a cute helicopter like drone
ta, i'll try that one
Is there ever a reason to set the lower levels of a multidimensional array as global if the parent is global? IE:
globalArr = [_localGroup1, __localGroup2]
vs
globalArry [group1, group2]
where values in group 1 and 2 would be modified regularly and acted on server side?
in case anyone gets also freezes he cannot explain in dev branch recently..
[Dev branch] Game freezes on pushBack command
https://feedback.bistudio.com/T120748
seems from string escaping or sth related to pushBack
@broken mural no. globalArr will be a global variable containing both groups either way. there is no difference, because the variables only represent their values inside the script. Properties of the variable (home scope or global) have no influence of the value.
@little eagle sounds like you're saying is that as long as globalArr is in the global space it's value(s) can be modified anywhere in the mission file and it will be updated?
@little eagle so if I add the string "1" to one of the sub arrays and then in a completely different script and call, I can check that index and get back "1"?
@broken mural http://lystic.net/2016/07/29/advanced-script-variable-hiding/
This covers how variables can be edited and accessed from any scope
The _get and _set functions would work with your globalArr as well. Again it just shows the idea, not in your exact circumstance
@broken mural I don't see any sub arrays in your example (globalArr = [_localGroup1, __localGroup2])
@spark phoenix
On the same client, yeh, but in his scenario it would just be easier to edit a global array, because he doesn't need to hide shit ๐ However, he needs it editing server side
@little eagle yeah sorry I was in a rush this morning. The multidimensional array structure would be similar to this;
allArrays = [group1, group 2, group3] Group1 = [subgroup1, subgroup2, subgroup3] Subgroup1 = [โ1โ, โ2โ, โ3โ];
the catch being the array is added to on initServer and items within the subgroups would be removed throughout the mission.
NOTE: This is ignoring all syntax and is not a representation of how I would like to globally state all of these. Just not sure, outside of allArrays what needs to be stated in global space, or if the global attribute applies to all elements of allArrays variable.
what needs to be stated in global space
nothing does, except the "allArrays" variable
or if the global attribute applies to all elements of allArrays variable.
there is no such thing as a global attribute for array elements. the array variable can be global or not, but the elements are only values. variables != values
god dam the wiki for arrays is awful
Has anyone got access to these bitwise functions to look at?
Could definitely benefit from user contributions. I'm gonna go with what you recommended. Its really just a division of arrays that contain strings. Nothing ground shaking.
@little eagle Anyone ever tried to implement data-structures in arma 3?
Other than arrays?
E.g Queues, Stacks, Deques,
Stack ... wouldn't that just be an array where you use pushBack and deleteAt 0 on ?
No. FIrst in First out datastructure Queue would be that
As a pushBack pushes it back to the beginning
_array = []; _array pushBack _otherdata;
reverse _array; _array pushBach _thing; reverse _array;
I have to look up these terms. I'm not a god damn hacker
Computer scientist.
Nor am I
It's a hobby.
Linked lists made using functions would probably be comparable to C
You won't find any fancy structures in arma.
At best someone abstracted it to either use arrays / or set/getVariables etc
Could you use a C function via callExtension?
yes, but you can only pass strings, numbers (floats) and arrays
callExtensions take a string & return a c string.
Each callExtension use also has a timer check, that you can't disable.
Thats not really a problem if you can type convert the strings to whatever other type
pain in the rear
No timeout, its just a time check. Outputs warning in RPT, you can't disable the time constructor/ diff check
Ah rightio. so timeout as in if it takes to long to complete it is terminated?
Nope read above
idk I never had this "problem"
But extensions are so so
They are essential for ACRE and TFAR
but everything else... meh
ACRE is so much math...
I am suprised arma 3 doesn't cry with all that differential calculus going on
it's to communicate with teamspeak
this is where the true purpose is
everything else will just annoy you as dev
every update the anti vir programs will block it
ACRE calculates god damn, Free space loss...
and when battle eye is offline yet again, you get a ton of usless issue reports too
idk what ACRE does calculate
but without DLL it wouldn't work at all
I looked at the .pbo
cause it has to communicate with TS
It's got so many formulas going on it's not funny
When you send a radio transmission
It is so computationally intensive it must drop peoples frames a lot..
Way more than TFAR
sure
I don't think linked lists will make much sense in Arma
I mean. If they were implemented natively
Just like those new bit operator functions. useless
Although I guess the bit operator functions do help to work with stuff like the radar types from config
or those ai ammo usage flags
I want to know something completely, is it better to execVM? spawn or call?
In the past I functions as files everything I wrote
And still do.
Which is best @little eagle ?
probably spawn or call
at least mid mission you should never use execVM
because it's better to precompile at game (or at least mission) start
I guess it doesn't make much difference for puny 10 liner scripts from mission makers
I don't use the scheduler much personally, so all I ever use is call
too unpredictable
caused too many issues in the past
and it's annoying that you can't reference undefined variables in scheduled env
and it's way slower : (
too much overhead from constant run time delta checks after each freaking command
I've used spawn {} to manage certain things within unscheduled environment
as suspending is sometimes needed or timing issues happen
the problem is that any shitty mission maker can break your addon
we had that problem all the time with AGM
mod wouldn't work with...
"heavily scripted" missions
...
Most missions are now heavily scripted?
And since I only make mods, I can't trust any mission maker
no, but there are some
it only needs one for you to get a ton of error reports
Although I don't see a lot of missions, using FSMs anymore.
FSMs are just a pain to work with
Even though they have one key thing function calls and spawns don't. They run completely unscheduled.
Ahhh now thats a distinction that isn't on the BI wiki
and you have to compile and load from disc every time you start a new FSM with execFSM
whats your opinion on the use of call compile preprocessfielinenumbers ?
to 1 single SQF script?
don't do that mid mission either
CBA has a system where you compile preprocessfielinenumbers on game start
and on mission start the cached variables get loaded into mission namespace
so my method of using cfgFunctions.hpp is good?
basically CfgFunctions where you can actually add and change the recompiling at every point
cfgFunctions is good, but the PREP system can actvate recompiling at any time
because it doesn't need config in the first place
CfgFunctions is fine though if you don't dig too deep
it's nice that it has the ingame functions viewer
How can I test the locality of mission scripts in debugging?
I've been having that as a problem recently.
no is there a way to return the context in which it's existing?
say if I put isServer in a script and assign it to a variable
will it tell me the execution context?
do you mean the script handle from spawn/execVM ?
No the script it self will it say true or false if the script is run say from initServer.sqf etc?
if a script is called from initServer.sqf it will only exist on the server
Can you tell code run from the initServer.sqf?
to run on the client using hasInterface ?
Yes
works with everything in CfgFunctions
it has some white / black listing shenanigans
Should I ever use publicVariables still?
not sure how that all works
Should I ever use publicVariables still?
probably not
I mean again. remoteExec is fine
But I personally use this framework:
https://github.com/CBATeam/CBA_A3/wiki/Custom-Events-System
which builds on publicVariable
publicVariable itself would be a pain to set up every time
Problem with remoteExec is similar to the scheduler
missions and other addons break it
due to the whitelisting
and stuff
It wasn't very reliable when it was introduced too
no idea if it's all fixed by now
I think there is a problem with huge overhead in certain cicumstances
Yeah I was told by someone to use a message passing design
where I use remoteExec or remoteExecCall on commands only
not functions.
say for example setting rain would be
remoteExec is equivalent to remoteExecCall when used with commands
[60,1] remoteExec ["setRain",-2,false];
it only makes a difference for functions
why -2 here?
-2 means it won't work on the local host in local hosted MP
[60,1] remoteExec ["setRain"]
Don't need to specify the number?
no. default is everywhere
which is what you want
and the JIP flag is default off
it wouldn't make sense with this command
The reason I used -2 was so the server never ran the weather update
only the clients
so state was only stored server-side as a number
the actual effect was sent to clients
I saw no need for the server to receive weather updates
It has no display...
@little eagle stupid idea?
it breaks local hosted and it doesn't really achive anything by leaving out the server
At all?
Reduce load on server?
setRain is negligibly
you might even be creating more overhead by specifying the target as -2 lol
Those ACRE calcs are done in a dll?
idk about ACRE, but the FCS from AGM/ACE is made via extension
the projectile ballistics aren't that bad, but recursive functions, iterations
SQF is too slow for that
hah. 600 iterations with that DLL. SQF did choke on 11
may be the new engine script language could be fast. its not compatible with SQF
but what could be so different...
New scripting engine I peeked at the PBO
I know bad me.
It's more akin to C++
and it also supports OOP
The DayZ Standalone
@tough abyss It's nothing like SQF
@little eagle Was it illegal for me to do that?
@south storm you believe it will be hard to port actual code to the new script language?
A lot hard yeah...
Why?
config classes arent OOP?
SQF has no OOP
ah, ok.
C, C+, C++, C#, Cbi
It's definitely more readable than SQF
What we can do with OOP that we can't do actually?
Change or create or delete classes on fly?
Nice!
Or classes definition
so once the class is finished running
The variable is inaccess outside the class
Which can be further abstracted inside methods
where a method means you can protect a variable inside that method only
which the outside can not even access the interior
But OOP will be more suitable for content creation?
Maybe.
I mostlly do functions.
that do stuff.
I create no content.
One teleport function.
Menu function.
Sell function.
May be mostlly not change. Lets see.
nice.
Okay quick one: how do you respawn a killed unit in it's position in a vehicle?
Jay, the unit have a assigned vehicle?
Because if the unit enter another vehicle, it will be assigned to this vehicle.
You can use "assignedVehicle _unit;" to get the assigned vehcle.
maybe let me rephrase
Okay quick one: how do you respawn a killed ai unit in it's position in a vehicle?
and "assignedVehicleRole _unit" to get the unit role in the vehicle
He died inside the vehicle?
or he died anywere?
died in the vehicle (gunner)
i have 3den enhanced + ace things, so i have the ability to run something ' on killed '
in the unit attributes
you need a Killed event handler that set the vehicle and position of the unit with "_unit setVariable " when he dies.
And after the unit respawn, if those variables exists on the unit, you move the unit to the vehicle and position (gunner, driver).
@tough abyss http://imgur.com/a/1pYMB
it ads an ' On Killed' execution to attributs
i edited above.
hmm
But if take some time to spawn, the position can get ocupied by another unit
not really, there's no backup
๐ just want that one unit to respawn in it's place
vehicle is locked for players anyways
could i not use the ' on killed ' part from the 3den enhanced for that?
it already looks for a killed eventhandler on that unit with that, i think
Not familiar with 3DEN enhanced so.
so just spawn a new ai in the vehicle's position would be easier
ugh, need to thin kclear for this, time to hit the bed
gn folks
//on killed
_veh = vehicle _this;
if (_this != _veh) then {
_this setVariable ["r_veh",[_veh,assignedVehicleRole _this]];
} else {
_this setVariable ["r_veh",[]];
};
//on respawn
_r_veh = _this getVariable ["r_veh",[]];
if (count _r_veh > 0) then {
_r_veh params ["_veh","_roleArr"];
_role = _roleArr select 0;
if (_role = "DRIVER") then {
_this moveInDriver _veh;
} else {
if (_role = "COMMANDER") then {
_this moveInCommander _veh;
} else {
if (_role = "CARGO") then {
_this moveInCargo _veh;
} else {
if (_role = "TURRET") then {
_path = _roleArr select 1;
_this moveInTurret [_veh,_path];
};
};
};
};
};
@clear tendon
the handler as far as I know
returns servreal things
not sure vehicle _ this would work
Yeah @tough abyss the addEventHandler ["Killed",{ } ]; returns 3 values
this
init area of vehicle:
_veh = vehicle _this; if (_this != _veh) then { _this setVariable ["r_veh",[_veh,assignedVehicleRole _this]]; } else { _this setVariable ["r_veh",[]]; };
..
need a [code] take for Discord..
tag*
Was it illegal for me to do that?
yes. punishment awaits
the code tag is 3 backticks ` ` `
Thanks for that lecks
without the spaces
@clear tendon
you can edit your message
Oh thats cool
{
_veh = vehicle _this select 0;
if (_this != _veh) then {
(_this select 0) setVariable ["r_veh",[_veh,assignedVehicleRole _this]];
} else {
(_this select 0) setVariable ["r_veh",[]];
};
}];
this addEventHandler ["Respawn",
{
_r_veh = (_this select 0) getVariable ["r_veh",[]];
if (count _r_veh > 0) then {
_r_veh params ["_veh","_roleArr"];
_role = _roleArr select 0;
if (_role = "DRIVER") then {
(_this select 0) moveInDriver _veh;
} else {
if (_role = "COMMANDER") then {
(_this select 0) moveInCommander _veh;
} else {
if (_role = "CARGO") then {
(_this select 0) moveInCargo _veh;
} else {
if (_role = "TURRET") then {
_path = _roleArr select 1;
((_this select 0) select 0) moveInTurret [_veh,_path];
};
};
};
};
};
}];
@clear tendon
I'm a littel OCD with the (_this select 0) sometimes
oops
Fixed
A question for you @little eagle when a variable is setVariable to an object?
is that local to the object only?
it's local where you set it
unless you use the 'public' parameter
ie (_this select 0) setVariable ["r_veh",[], true];
^ that true at the end would make it broadcast, including working JIP
Whats the benefits of using setVariable publically vs publicVariable?
i guess the main one is publicVariable only works for missionnamespace variables
setvariable can set vars on objects, etc
So publicVariable is now deprecated?
not sure if you can have like a 'publicVariableEventHandler' for setVariable though
the event handlers are they only thing i can think of that you can do with publicvariable but not setvariable
not sure about the performance implications of them though (don't know which is faster)
Interesting
I know its a little trick, but wich code will write a not empty array on the chat area?
systemChat str ((getPosWorld _obj) nearObjects [typeOf _obj,0.001]);
systemChat str ((getPosASL _obj) nearObjects [typeOf _obj,0.001]);
systemChat str ((getPosATL _obj) nearObjects [typeOf _obj,0.001]);
systemChat str ((getPos _obj) nearObjects [typeOf _obj,0.001]);
systemChat str ((position _obj) nearObjects [typeOf _obj,0.001]);
_obj is a building.
Answer is... ****
Answer is none....
Strange dont?
what position in object nearObjects use?
pris relpi!
this return the array with the object: systemChat str (_obj nearObjects [typeOf _obj,0.001]);
HAAAAAAAAAAAAAAAA! Solution:
systemChat str ((ASLToATL getPosWorld _obj) nearObjects [typeOf _obj,0.001]);
I will comemorate with food. Sorry for fllod!
you can even use 0 instead of 0.001!
64 bits precision!
Also @tough abyss Why were you using 0.001?
for the radius?
The radius is in meters
so 0.001M = 0.1 centimeters
or 1 millimeter
So you were giving it a bad radius
should have just done nearObjects [typeOf _obj,1];
As the smallest search radius
can anyone help with a UI question? Im trying to work out how the order is determined ie what is rendered on top and what is behind.. changing the order of the items in the GUI editor with Ctrl-L seems to make no difference
I believe it's ordered by ID
idc and idd
So your primary GUI is made using an idd
and your sub-elements IDCs
I am not sure but I think thats how it works
It also depends on them being a backgroundControl {} or a control {}
All GUI stuff falls back to sort of OOP
stuff
IDD's inherit all the data of IDCs
IDDs are the parent classes
IDCs are the child classes
Each one inherits from the next.
for anyone paying attention.. moving it to controlsBackground {} ended up much better than relying on IDC as "active" controls are brought to the front when you click on them
Hey! Is there a way to list all mods running (with -mod=) command line parameters with the path to those mods on the disk? (in SQF)
In theory, there is a way to find the mod names but if a mod has been enabled by -mod=c:\mySecretLocation\@Mod I won't be able to guess that location by the mod name alone.
As far as I know it's not possible to do so with SQF
For example, ACRE(2) uses an extension that gets the list of open handles by the A3 process and gets the path to the loaded .wrp from there
If I understood correctly
Wow, what a hack! ๐
Getting the path of all the loaded mods is probably easier since you should be able to get the arguments for a process fairly easy, but still requires an extension
I'm afraid that this won't be as straightforward because if you run it with -config (I think), then you would have to open that file and parse it yourself. That's not really hard, either, (just additional work) but I don't know how many other ways I'm still missing.
Anyway, I'm working on a python extension that would enable mods to run scripts in CPython (not IronPython, I know about armaext) and I would like to make it so the mods could have a directory python_code, for example, where those scripts would be stored.
So when my extension would be running, it would need to get a list of all the mods to look for the directory in their locations.
Anyway, thank you @halcyon crypt
is there some kind of event I can listen to for when the player has loaded a save?
@native hemlock the correct position to store is "ASLToATL getPosWorld _building;".
Since this is the exact position used to calculate distance on nearObjects, you just need to store the position, and not the building class, it will be quite unconnom to find the wrong building with that precision.
This will return a array with the building _obj: (ASLToATL getPosWorld _obj) nearObjects 0;
So i store the result of "str (ASLToATL getPosWorld _obj)".
Just not sure if str will lower the position precision.
It won't, no
@dusk sage thanks.
yes it will
str converts the number to a string with a maximum of 6 digits after the comma
the floats are more precise than that
there is a method to convert numbers into strings with keeping those "hidden digits"
No, str just converts it to a string. The number is rounded regardless @little eagle
that's wrong, BoGuu
yes, the debug console only displays a certain amount of digits
but the value can be more accurate
FLOAT_TO_STRING(num) IS more accurate than str
There even is a post about this on KKs blog
Your function will still be rounded
If you think he is more credible
If you stick 1.523523523523523 into it
Yes it will
It's not going to keep precision
But it's more accurate
Yes it will keep precision
as precise as FLOATs are
str introduces even more inaccuracy by cutting of a number of digits
You'll lose a slight amount of precision using str. And in the case of getPos, you'll certainly not lose any
if you want to serialize numbers without loosing precision, str is not enough
You'll lose a slight amount of precision using str. And in the case of getPos, you'll certainly not lose any
?
Hold on
if that weren't the case, floatToString could be simplified
I trust what nou is doing
[2409.31,6468.13,0.00143909]
What would be the reason for wanting this level of precision BoGuu?
Somebody was trying to store positions as strings, read above
There will be no issues with precision in this case, especially
what is str [100.12345678]?
Yeah I was thinking that too @little eagle Add the precision info yourself
Pardon?
But that would be less accurate than FLOAT_TO_STRING() then
The str command doesn't
and the debug console doesn't display it (probably using str internally)
But with tricks like the one I posted, you don't lose any precision
Do you need that? Maybe, idk
But the question was, do you lose precision with str
And the answer is yes, there are better methods
@BuGoo [2409.31,6468.13,0.00143909] the 0.000143909 is a little over a 16bit (half precision numbr)
the z value is a bad example though
it's very close to zero
But cutting off the third decimal at 2000,2000 can be a decimeter difference
Depends on what you're doing I guess
If you draw map markers, then no
if you place objects... they might bonk into each other thanks to splendid physx
well Donnovan was using nearObjects and was using 0.0001 as the radius
and as far as I know that only supports hole M numbers?
or whole integers in meters?
Don't think so
Well he found that 0.0001 wouldn't work
he had to use 0
So the level of precision it supports must be very low
Well that kind of makes sense. I guess more precision means more computation?
Sorry had to tend to food, .123 yep
.123 worked?
?
The getPos returns a position thats accurate to 2 decimal places or between 1 - 100CM
See what I said a few posts ago
Weirdly enough the Z axis has close to a little bit more than 16 bit precision
now try:
_fnc_fts = {str parseNumber (str (_this%_this) + str floor abs _this) + "." + (str (abs _this-floor abs _this) select [2]) + "0";};
[100.12345678 call _fnc_fts]
It should be alot more precise than that ๐
Yeh, I see @little eagle. Yet again more disappointment
:/
Do you guys know if we can directly invoke scripting commands via C++ ?
It's always 6 significant figures
@little eagle did you ever tested str [float]?
@little eagle How the hell did intercept find out how to interface with them?
is there the percision the same as str float?
we were just discussing that
Still 6 S.F @zealous solstice
ok ๐
format ["%1", 100.12345678];
I wonder
Will be exactly the same
Seem any loss of precision will only become an issue with values >= 1000 tbh
Yes, but maps are kilometers large
You need a string for that first ๐
parseNumber is backwards
The problem isn't FLOATs either like the ticket suggests
the problem is str, format etc. being extra shitty
Hey, on my side its easily fixed using "nearObjects 0.1" or even "nearObjects 1" instead of "nearObjects 0". you guys are discusing something a lot deeper.
that's always how it goes with this channel and discussions like these
Thats what I said Donnovan
1 would probably work as well as 0
Biggest issue though nearObjects 0
I think would return every single one?
the "nearObjects 0" was just a way to prove i found the exact object point used to measure distances in nearObjects function.
KK's solution obviously works but why do we have to go through all that trouble?
with precision
It's dirty....
They are discussing about precision, i also like that, just wanted to say the problem is solved for me.
Yeah we're trying to understand why we don't get full 32bit precision
with every operation.
It'd be nice if they gave you a choice to control the precision
Make simple scripting command
that says (converToHPrecision (getPos))
@little eagle sorry to interfer, just wanted to say i got the solution by changing 0 to 0.1.
You and BoGuu discunsion is a very nice read.
You shouldn't have any issues finding buildings with what you've got ๐
@little eagle I mean how hard would it be to add a high precision command?
They've added array operators among other things.
idk
High precision float command shouldn't be too dificult?
@south storm thanks for the info about getPos "The getPos returns a position thats accurate to 2 decimal places or between 1 - 100CM"
I remember that there actually was something on dev branch
not documented on the wiki
maybe I dreamed it
Wonder how hard it would be to make an expression parser in A3
searching for "ftoa arma"
I only found parseNumber with that.
getPos doesn't return something accurate to 2 d.p
but all the shitty search engines "correct" ftoa to some shitty words of some back woods languges
Would parseNumber format ["%1",getPos]; work?
no, that would always report 0
@dusk sage what does it return as?
As normal
is it 2 D.P or sigfigs?
I only said that str returns 6 SF
Todays 1.64 performance binaries disable xx setVariable ["", somevalue]. You can no longer assign a value with setVariable to an empty string. CBA for example throws an error now.
could anyone help me with my addon server keys? seems no matter what I do with DSSign a dedi server will hang or CTD at mission selection or just after... unless I verifySignatures=0
I am signing all PBOs with my key, including that key with the addon, and putting that key inside the keys folder on server as I do with other addons
not the private key the bikey
not sure about the relevance to the float to string discussion but I felt like dropping https://community.bistudio.com/wiki/toFixed here ๐
yeah but it is in Dev currently ๐
@bright coral I know. Fixed already on master
Thank you @halcyon crypt . That was what I was looking for
I knew there was something. javascript huh. I swear it was ftoa from C++
randVehicle = ["ESCORT_1","ESCORT_2","HVT_1","HVT_2","HVT_3"] call BIS_fnc_selectRandom;
smoketheEngine = "SmokeShell" createVehicle (position _randVehicle); smoketheEngine attachto [_randVehicle, [0,0,-1]];
Gives an error: error position: type String, expected Object,location
it should add a smokeshell to a random selected from the array
_randvehicle is a string
maybe you meant
[ESCORT_1,ESCORT_2,HVT_1,HVT_2,HVT_3] call BIS_fnc_selectRandom;
why cant it use the "" in that array?
you can, but then you get strings, not objects
has been educated again
you could do
_randVehicleName = ["ESCORT_1","ESCORT_2","HVT_1","HVT_2","HVT_3"] call BIS_fnc_selectRandom;
_randVehicle = missionNamespace getVariable _randVehicleName;
ah, turn the string into a var
please use https://community.bistudio.com/wiki/selectRandom thanks
what's the difference?
Can you add an empty array to a multidimensional array? For example, say I initialize an array to originally have zero elements, and foreach object in an area I want to add an array for later use; That array hasn't gotten values just yet, though! The problem: The objects refer to a specific index in that array, so if I start with object that points to index 3, I need to create 3 empty arrays in the array.
for the record; it doesnt like the syntax arr pushback [] or arr pushback [nil];
also doesn't like _var = []; arr pushback _var for.. obvious reasons. Generic error in expression given for pushback in all cases.
@broken mural this works fine? arr = []; arr pushBack [];
arr becomes [[]]? Im not getting that result
welp that points to a different problem
huh.. okay then. Its in a for loop to meet the count; so index of 3, whatever the difference is between the count and 3, pushback [] so [] becomes [ [], [], []]
testing a change..
alright this worked. I changed the for loop parts around and it appears to have fixed the issue.
Add a padding check
if (isNil "_array") exitWith {};
or tell it to goto another then block
if (count > 0 && < 3) then { _array pushBack []; }:
That sort of thing?
@broken mural
if (count > 0 && count < 3) then { }
I actually went with this;
@south storm
if (count _array < _objectNumber) then { for [{count _array},{count _array < _objectNumber},{count _array}] do { _array pushback []; }; };
but there's a bit of a problem with this propegating to different indexes that I'm gonna work out tomorrow.
could simplify that to for [{},{count _array < _objectNumber},{}] do { _array pushback []; };
some guy posted in the BIKI:
Player unit weight in kilograms:
_weight = (((loadAbs player)*0.1)/2.2);
Player unit weight in pounds:
_weight = ((loadabs player)*0.1);
is that correct? from what i remember BI made it a mix of weight and size
@broken mural
@broken mural
Can you add an empty array to a multidimensional array? For example, say I initialize an array to originally have zero elements, and foreach object in an area I want to add an array for later use; That array hasn't gotten values just yet, though! The problem: The objects refer to a specific index in that array, so if I start with object that points to index 3, I need to create 3 empty arrays in the array.
private _array = [];
_array resize 3;
_array = _array apply {[]};
result: [[],[],[]]
Does anyone know the most simple way to script in waypoints based on another unit's waypoint?
For example, if I had an AI group that I called PlatoonHQ, and I had AI groups FirstSquad, SecondSquad, and ThirdSquad, and PlatoonHQ was set to use BIS_fnc_tskPatrol or whatever when it spawned, how could I have the other three AI groups get HQ's waypoint every time it was created, and then create their own waypoints based on it.
@halcyon crypt
I searched a bit more, and found the original code for enumerating open file handles that the ACRE guys have reused in their code.
I'm posting it here in case someone might be interested.
Enumerating windows handles:
http://forum.sysinternals.com/howto-enumerate-handles_topic18892.html
Full sample code attached at the bottom of the article.
Thanks again for pointing me into the right direction.
Nice ๐
That's the code without all the stuff the ACRE guys have added
Might come in handy at some point
Shower thought here, what happens to a global marker (createMarker) but you use the xxxLocal family of commands? Will it only adjust the attributes of the global marker locally (as somewhat expected) or is there undefined behaviour?
Let me check
I'm messing with callExtension right now anyways
one thing I hate is that it takes forever to actually load the game -.-
Yep, empty string
And doesn't get logged
Seems it just ignores it
What u trying to do anyways?
Hey guys! I need some help!
Someone here? ๐
Well, I've got some sort of problems dealing with object intersections
Okay, I have this teleport script,
[] spawn {
//Let's asume... This vars aren't like this but lets set them here for clarity's sake...
last_teleport = 0;
teleport_delay = 5;
if(last_teleport + teleport_delay < time) then {
_origin = (eyePos player); //Get origin
_multiply = 30; //Teleport distance (in meters)
_delta = (eyeDirection player) vectorMultiply _multiply; //Get direction to teleport XY (height get's ignored IDK why)
/* And below is the problem.
* I'm trying to block teleports through objects, trying to detect an intersection and setting the point of intersection
* as the maximum teleport target, but 'lineIntersectsObjs' DOESN'T want to deliver. It get or random objects or
* none at all.
*/
while {(count lineIntersectsObjs [_origin,_delta,objNull,objNull,true,32]) > 0 && _multiply > 0} do {
_multiply = _multiply - 1;
_delta = (eyeDirection player) vectorMultiply _multiply;
};
if(_multiply <= 0) then { hint "Can't teleport. Collision";};
player setPos (_origin vectorAdd _delta);
last_teleport = time;
};
Sorry, missing one closure }
I've commented the problem inside, I been at it a few hours but can't get a way to avoid teleporting through collidables
And the thing is that this code actually triggers the "Can't teleport" condition but still teleports 30 meters front, 30 meters up (and kills you)
I shouldn't do that, as delta vector is multiplied by 0
Can't, it's supposedly an hability you could use anywhere, but it's too great of an ability
So it should be limited to visual contact
(Btw, this is a stripped down script that summarices everything)
It's trigged by a displayEH["KeyDown"]
Okay, thanks anyway ๐
@icy raft
Try this
The first problem you talk about:
And the thing is that this code actually triggers the "Can't teleport" condition but still teleports 30 meters front, 30 meters up (and kills you)
Is because you haven't privated your _delta variable. The changes made to it in the while loop, will not reflect in the if parent scope, hence _delta still uses the 30 multiplier.
This is a consequence of not exiting when multiply <= 0, you instead just hinted, then execution continues
Also, the reason you're teleporting in the sky, is due to the fact eyePos returns PositionASL (above sea level), whereas setPos will use PositionATL (while on land), which in this case will teleport you z metres above the ground
I sounds possible that's the problem, I just asumed _delta would become 0 so didn't bother doing an exitWith
Yeah! That one I just figured it out!
Read up on https://community.bistudio.com/wiki/private
Just addeda ASLtoAGL a few minutes ago and worked (sort of)
Still teleports about a meter over the floor, but no problems, will be fixed
You can just stick the z component of the position to 0, which when used in setPos will just set you at ground level
like in the hastebin
Hmm.. The thing is that I want them to be able to get to roofs and that kind of thing
Then converting it is the way to go
I forsee some quite unfortunate accidents though ๐
Nah, I did manage to do a //jetpack// script a few months ago
Managed to avoid death (most of the time)
Hey BoGuu, I love you
I did work
It actually fixed everything, fucking scopes
It does avoid teleporting through objects
๐
Well... Most of the time.
These bunch of commands are always iffy
Yep, and rotation is even worse
I managed to rotate a cube once... And physics arround it rotated with it
Like, you put you crosshair straight to it and it just aligned with his updir
onChildDestroyed = " _nextMission = uinamespace getvariable ['RscDisplaySingleMission_nextMission',''];_nextMission call bis_fnc_log; if (ctrlidd (_this select 1) == 50 && _nextMission != '') then {(_this select 0) closedisplay 2; playMission['',_nextMission];}; ";
is that onChildDestroyed new?
class Bitwise
file = "A3\functions_f\Bitwise";
class bitwiseAND
class bitwiseOR
class bitwiseXOR
class bitwiseNOT
class bitflagsSet
class bitflagsUnset
class bitflagsFlip
class bitflagsCheck
class bitflagsToArray
class Combat
class fireSupportCluster
description = "Virtual fire support - cluster shell.";
class Inventory
class limitAmmunition
class limitItems
class limitWeaponItems
class Objects
class attachToRelative
class Vectors
file = "A3\functions_f\Vectors";
class vectorDirAndUpRelative
class weaponDirectionRelative
removed
so maybe sqf cmds for bitwise after all?
Question for the hackers here
Would these btwise operators even work on signed floats?
With that I mean
Would the numerical representation be predictable?
apparently yes, since the first bits make up the mantissa http://kipirvine.com/asm/workbook/floating_tut.htm
am i nuts?
_veh = vehicle this;
hint format ["Vehicle is %1",_veh];
_returnRoadPos = roadAt getPosATL (_veh);
vector_x = ((getpos (_veh select 0)) + random(round 30)) * cos (getDir(_returnRoadPos));
vector_y = ((getpos (_veh select 1)) + random(round 30)) * sin (getDir(_returnRoadPos));
_veh setPosATL (vector_x,vector_y,(getPosATL (_veh select 2)));
it still complains that at the last line _veh is an undefined variable
Error?
yes
Rpt
'|#|_veh setPosATL (vector_x,vector_x,(getPo...
Error Undefined variable in expression _veh
script is called; this addEventHandler ["killed", {_this exec "scripts\deleteme.sqf"}]
Change 'this' for '_this select 0'
Maybe's that
Cos it seems that this without underscore is nothing
so something like
_veh = _this select 0;
hint format ["Vehicle is %1",_veh];
_returnRoadPos = roadAt getPosATL (_veh);
vector_x = ((getpos (_vehicle select 0)) + random(round 30)) * cos (getDir(_returnRoadPos));
vector_y = ((getpos (_vehicle select 1)) + random(round 30)) * sin (getDir(_returnRoadPos));
_veh setPosATL (vector_x,vector_y,(getPosATL (_veh select 2)));
could try either, really
well atleast the hint correct now
still gives the error w/ just the edit from bernts
How is this supposed to be? --> 'this' addEventHandler ["killed", {_this exec "scripts\deleteme.sqf"}]
it's on the vehicle's init
ah ok
let me try to add this select 0 in the init
this addEventHandler ["killed", {_this exec "scripts\deleteme.sqf"}]; should work as it declares de object in 'this' without underscore
yeah, that worked, still get the error it doesn't know what _veh is
try _veh = (_this select 0);
or maybe _veh = vehicle (_this select 0);
im not sure, tbh
the last makes more sense to me
now it doesn't know what vector_x is
what the hell
Hmm...
vector_x = ((getpos (_veh select 0)) + random(round 30)) * cos (getDir(_returnRoadPos));
vector_y = ((getpos (_veh select 1)) + random(round 30)) * sin (getDir(_returnRoadPos));
๐
_veh setPoATL (|#|vector_x,....
error undef var in exrp. vector_x
Arma VooDooโข
ยฌ_ยฌ
it's a random move to x/y to 'move' it of the road on killed
else the escort - stupid ai - wont continue as the road is blocked..
should probably have a sleep on it, so that it waits a few seconds before moving it
vector_x = ((getpos (_veh)) select 0) + random(round 30)) * cos (getDir(_returnRoadPos));
vector_y = ((getpos (_veh)) select 1) + random(round 30)) * sin (getDir(_returnRoadPos));
```
this script looks totally wrong
vector_x = (((getpos (_veh)) select 0) + random(round 30)) * cos (getDir(_returnRoadPos));
vector_y = (((getpos (_veh)) select 1) + random(round 30)) * sin (getDir(_returnRoadPos));
sorry, missed one parenthesis
@little eagle any input is welcome
@little eagle i believe so, as long as it works
Wanna see some random cr*p?
there is:
origin getPos [distance, heading]
so:
private _pos = _veh getPos [30, getDir _returnRoadPos];
round 30 does nothing
meant to be round random 30 ?
yeah that might be it
then what makes sense
every line is wrong and the script makes no sense : (
Vehicle go boom
move vehicle if on the road
by random x/y
jay is happy
make sure it's not 'on' the road
i wouldn't renamed it to thisisabananscsript.sqf
"deleteme" has nothing to do with moving wrecks off the road
well
you have to make clear what you're doing
that way it's much easier to find errors
really, really dont care about the naming aproach, im testing one code, if that works. rename it.
might not be ideal, im sure.
you are doing it wrong
#riot
I'm telling you that this mindset is your problem
you're kinda sticking it to me as it's a set rule to do for a single script mate. I'm not making an arma mod here. Just a script. No need to go holy on naming approaches or way of doing namings. Hell, maybe i like bananas and name my script banana_on_the_road_MOVE.sqf...
--.--
wrong mindset
^
OMG
I'm not dumb
it's the name. you care about the name of the script
That's it, mute
Again, you are wrong
i mean, if i call it myponiesareawesome.sqf, why is that a problem
No, I do not care about the script name
I'd suggest u just to block him, he's on a toxic rage
Name it whatever you want, but I'm telling you that it should describe what you're doing
because you seem to have problems with it
that was like stage 5 autism right there
thanks
๐ค
So is this where shit sqf scripts get obliterated by commy
Where the scripts go die
This is the formula he is using @little eagle
_returnRoadPos = roadAt getPosATL (_veh);
_vehicle_3DPos = getPosATL _veh;
_vehicle_xPos = _vehicle_3DPos select 0;
_vehicle_yPos = _vehicle_3DPos select 1;
_vehicle_zPos = _vehicle_3DPos select 2;
_RoadDir = getDir(_returnRoadPos);
vector_x = _vehicle_xPos + random(round 30) * cos _RoadDir;
vector_y = _vehicle_xPos + random(round 30) * sin _RoadDir;
_veh setPosATL [vector_x,vector_y,_vehicle_zPos];
calculates the vector_x and vector_y displacement
I wrote it.
I also agree with @little eagle @clear tendon Script descriptions is best.
I normally name them what they're actually doing.
name the script what you initially intend it to do, write code, test, refactor
i agree the name isn't conventional, but really, as a generic non-coder here, making a single script, it just goes beyond me why the first thing that gets pointed out is the name of the script, and not the script itself...
If the script were easier to understand, it would be easier to fix
^
The one I sent to him is:
_veh = vehicle (_this select 0);
_pos = getPosATL _veh;
hint format ["Vehicle is %1",_veh];
_returnRoadPos = roadAt _pos;
vectorXYZ = [
(round random(30)) * cos (_pos getDir _returnRoadPos),
(round random(30)) * sin (_pos getDir _returnRoadPos),
0
] vectorAdd _pos;
_markerstr = createMarker ["markername",vectorXYZ];
_markerstr setMarkerShape "ICON";
_markerstr setMarkerType "hd_dot";
_veh setPosATL vectorXYZ;
_markerstr setMarkerText "The vehicle should be here!";
The marker thingy is just for debugging
but still does somekind of error
second to last line: vectorXYZ not defined
otherwise two vehicles dieing would make it possible for both script instances to interfere with each other
makes sense
I let it that way for debbuging
the getDir wouldn't work properly.
but yeah, should remove markers and make vector private for production
So _vectorXYZ or vectorXYZ is undefined
As the way road data is returned is it's aligned a specific way.
hmm
I guess it does the same error for the line above then?
I learned that one the hardway.
vectoxyz is becoming undefined
wreckKill = {
_veh = vehicle (_this select 0);
_pos = getPosATL _veh;
hint format ["Vehicle is %1",_veh];
_returnRoadPos = roadAt _pos;
vectorXYZ = [
(round random(30)) * cos ((_pos vectorFromTo _returnRoadPos) select 0),
(round random(30)) * sin ((_pos vectorFromTo _returnRoadPos) select 1),
0
] vectorAdd _pos;
_markerstr = createMarker ["markername",vectorXYZ];
_markerstr setMarkerShape "ICON";
_markerstr setMarkerType "hd_dot";
_veh setPosATL vectorXYZ;
_markerstr setMarkerText "The vehicle should be here!";
};
cursorTarget addEventHandler ["Killed", wreckKill];
@south storm hit up on the arrowkeys to edit your last message ๐
then this expression:
[
(round random(30)) * cos (_pos getDir _returnRoadPos),
(round random(30)) * sin (_pos getDir _returnRoadPos),
0
] vectorAdd _pos;
returns nil
wreckKill = {
_veh = vehicle (_this select 0);
_pos = getPosATL _veh;
hint format ["Vehicle is %1",_veh];
_returnRoadPos = roadAt _pos;
vectorXYZ = [
(round random(30)) * cos ((vectorNormalized (_pos vectorFromTo _returnRoadPos)) select 0),
(round random(30)) * sin ((vectorNormalized (_pos vectorFromTo _returnRoadPos)) select 1),
0
] vectorAdd _pos;
_markerstr = createMarker ["markername",vectorXYZ];
_markerstr setMarkerShape "ICON";
_markerstr setMarkerType "hd_dot";
_veh setPosATL vectorXYZ;
_markerstr setMarkerText "The vehicle should be here!";
};
cursorTarget addEventHandler ["Killed", wreckKill];
๐ค ๐ซ
Just personal preference here. I separate my functions and other stuff into lots of separate files using cfgFunctions.hpp
This is for realtime testing
I still think
origin getPos [distance, heading]
would make this way easier
I have my own compiling method
it reports ATL too
how would that be implented there @little eagle
Never knew about that one commy
Since Arma 3 v1.55.133361
Yeah pretty new
yes
I missed that one
But still, you would have to calculate the direction
Heading is number ๐ฆ
You have to get off the road
preferably
how to get the _roadDir though?
i should just move the wreck on kill, away from the road so the stupid ai can keep moving hahaha
yup
So it will align it to the actual road
but how to get _roadDir in the first place?
Wouldn't be easier to just nuke the wreck.........?
but not as fun
mission realism, the wreck stays there
just nudges out of the way for ai to keep moving
a floatting wreck hahaha
I think writing a function to get the "roads direction" would be step 1
the moving stuff is easy with the new getPos
also, the script should probably do nothing if the vehicle is killed in the open field
they're hard stuck on the road through 3den enhanced
direction of the road (as in the real road not the segments) would be _road1 getDir _road2
_road1 and _road2 are the first two objects in roadsConnectedTo _road0
and _road0 would be roadAt position _wreck
exit if _road0 is a null object
add 90 or - 90 degree randomly
setPosASL with that new getPos
done
use isEqualType to check the data type
#overmyhead
then you can use roadAt
if it returns an array
then I'd use apply to sort the data
for the closest point to the car
doesn't sound too bad tbh
how apply works?
array apply {_x} you mean
Yeah
apply returns an array and the elements of it are made of the return values of your code
[1,2,3] apply {0};
-> [0,0,0]
?