Jump to content

pedeathtrian

Member
  • Content Count

    284
  • Joined

  • Last visited

  • Medals

Everything posted by pedeathtrian

  1. Thank you, but this is how I end with weapon copied from backpack to primary weapon slot. What I was asking is to copy weapon from one backpack to another backpack (or in general any container) with all corect attachments. Imagine example situation: player has MX rifle as primary weapon and Katiba (+ some custom attachments) in backpack. Now how do I write respawn handler (it has both references to new and old unit instances) to have both weapons with all attachments for new unit? So that MX is in primary weapon slot and Katiba + attachments in backpack? Correct me if I'm wrong, but for now I only can put "attachments" detached.
  2. If there were commands like addWeaponsItemsCargo/addWeaponsItemsCargoGlobal which could take array in the same form as weaponsItemsCargo returns, that would be great.
  3. pedeathtrian

    ExecVM gear

    Right. Must pass argument in array, my bad. _nil = [[this], "BNAE\Class\class1.sqf"] remoteExec ["execVM", this];
  4. This. Player grabs whatever he can see and puts it into backpack. I figured out how to restore weapons with all attachments in primary/secondary/handgun slots, but still no luck with weapons put into the backpack.
  5. That's great, but what if I need to add some weapons with attachments dynamically? Imagine unit having some weapon with attachments in its backpack. Unit dies, then we require to restore its loadout on respawn. Or the list of allowed weapons and attachments is regulated by mission parameters. Currently I have to add attachments to the backpack separated from the gun. But first I must check whether the gun itself has attachments. If I'm lucky and unit had all the same attachments as weapon in config file, I can simply add this weapon to backpack and it will have all attachments on it. But more likely I will need to put gun without attachments and all attachments separately. I can't have all weapons/attachments combinations in config. It's too much work, isn't it? And the result is still not as desired. Probably this theme was already discussed zillion of times, sorry.
  6. pedeathtrian

    Helpme please with function

    I put very bad desing into this function, I'm very sorry. I had costly operation nearEntities called at each _return position overwhelming amount of times, much more than it was needed. Now I fix my mistake: _fnc_pickUpEmpty = { scopeName "_pickUpEmpty"; private "_apCount"; _apCount = count _allpos; if (_apCount < 2) then { false breakOut "_pickUpEmpty"; }; private ["_notVisited", "_notVisitedR", "_nvCountR", "_i", "_idxR"]; _notVisited = []; _notVisited resize _apCount; for [{i=0}, {i < _apCount}, {_i=_i+1}] do { _notVisited set [_i, _i]; }; _notVisitedR = +_notVisited; _nvCountR = _apCount; while {_nvCountR > 0} do { // picking up second/return position _i = floor random _nvCountR; _idxR = _notVisitedR select _i; _return = _allpos select _idxR; _notVisitedR deleteAt _i; _nvCountR = _nvCountR - 1; private ["_notVisitedA", "_nvCountA", "_k", "_idxA", "_list"]; _notVisitedA = +_notVisited; _notVisitedA deleteAt _idxR; // filtering out return position _nvCountA = _apCount-1; while {_nvCountA > 0} do { // picking up first/anchor position _k = floor random _nvCountA; _idxA = _notVisitedA select _k; _anchor = _allpos select _idxA; _notVisitedA deleteAt _k; _nvCountA = _nvCountA - 1; if ((_anchor distance _return) >= 10) then { if (isNil "_list") then { _list = _return nearEntities [["Man", "Air", "Car", "Motorcycle", "Tank"], _size]; }; if ((count _list) == 0) then { true breakOut "_pickUpEmpty"; }; }; }; }; false }; Now nearEntites should not be called more than once for every _return position.
  7. pedeathtrian

    ExecVM gear

    Most of the commands take local arguments. UPD: You will have to use remote execution: _nil = [this, "BNAE\Class\class1.sqf"] remoteExec ["execVM", this];
  8. pedeathtrian

    Helpme please with function

    If it only were to pick two random position, then yes. But how about checking conditions for picked locations? Imagine you have a list of 50 locations. You can pick 50 location for the first one and 49 for the second. Since different conditions applied to first and second location, same location make up a different pair if in reverse order, i.e. [pos1, pos2] is not the same as [pos2, pos1]. Therefore you have a full set of 50x49=2450 possible pairs to check. Now imagine only one combinations fits all conditions. You can shuffle the array for quite a long time until right combination appears in right place. Whereas my variant never checks the same pair again.
  9. What is going on outside the function does not concern the function itself. So you don't specify outside variables inside the function. BTW, you don't call your function on object, you call it on array of 2 parameters, see your function description :) BTW2. See params biki page; you can use false as default value for _mskmh parameter and omit this line entirely: if (isNil _mskmh) then {_mskmh = false;}; BTW3. isNil takes string argument. so must be (isNil "_mskmh")
  10. Try this: // 1 is for WEST, see https://community.bistudio.com/wiki/CfgVehicles_Config_Reference#side _classes = 'getNumber(_x >> "side") == 1' configClasses (configFile >> "CfgVehicles" >> "Man");
  11. pedeathtrian

    Helpme please with function

    Place it right where your _fnc_pickUpEmpty inline function was defined -- on the same scope where _allpos, _anchor, _return and _size variables were declared, but before first use of function. Possible usage: if (call _fnc_pickUpEmpty) then { // successfully placed // ... do something } else { // could not find placement // ... do something else }; If you decide to make function not inline, don't forget you will need to return not only true/false status, but also updated _anchor and _return values (updated automatically in inline variant).
  12. You mean function updating some global variable inside function body? If so, this is bad practice and should be avoided.
  13. pedeathtrian

    Helpme please with function

    Ok, here's what I ended up with. _fnc_pickUpEmpty = { scopeName "_pickUpEmpty"; private "_apCount"; _apCount = count _allpos; if (_apCount < 2) then { false breakOut "_pickUpEmpty"; }; private ["_notVisited", "_notVisitedA", "_nvCountA", "_i", "_idxA"]; _notVisited = []; _notVisited resize _apCount; for [{i=0}, {i < _apCount}, {_i=_i+1}] do { _notVisited set [_i, _i]; }; _notVisitedA = +_notVisited; _nvCountA = _apCount; while {_nvCountA > 0} do { // picking up first/anchor position _i = floor random _nvCountA; _idxA = _notVisitedA select _i; _anchor = _allpos select _idxA; _notVisitedA deleteAt _i; _nvCountA = _nvCountA - 1; private ["_notVisitedR", "_nvCountR", "_k", "_idxR"]; _notVisitedR = +_notVisited; _notVisitedR deleteAt _idxA; // filtering out anchor position _nvCountR = _apCount-1; while {_nvCountR > 0} do { // picking up second/return position _k = floor random _nvCountR; _idxR = _notVisitedR select _k; _return = _allpos select _idxR; _notVisitedR deleteAt _k; _nvCountR = _nvCountR - 1; if ((_anchor distance _return) >= 10) then { _list = _return nearEntities [["Man", "Air", "Car", "Motorcycle", "Tank"], _size]; if ((count _list) == 0) then { true breakOut "_pickUpEmpty"; }; }; }; }; false }; BTW, your fnc_getRoadpos function may return nil (if roads are too far, then _roads stays empty and _allpos stays empty too), make sure you handle this case (like, I dunno, increasing _radius or so). UPD, sorry forgot about min distance, edited.
  14. pedeathtrian

    Helpme please with function

    Pick up two random positions from the list, satisfying specified conditions (min distance 10m, no vehicles near second position). Hold on, I'll be back with code.
  15. Does this make other community members voiceless? If there were a community in the first place which stands for its members there will be no need in obfuscation, encryption and all the stuff beyond appropriate licensing. I just walked in and I see there's no such. I also have not release any public code yet. Should I STFU and GTFO? Ok. Now, where's my jetpack?
  16. pedeathtrian

    hasweapon simple syntax problem

    If player has, for example, "srifle_GM6_LRPS_F" your check against "srifle_GM6_F" will fail. Better way is to use isKindOf to check whether some of (weapons player) has common ancestor class in its parents list: scopeName "yourScope"; private _hasGM6 = false; { private _weap = _x select 0; if (_weap isKindOf ["srifle_GM6_F", configFile >> "CfgWeapons"]) then { _hasGM6 = true; breakTo "yourScope"; }; } forEach (weapons player);
  17. I personally think you guys all concentrate on wrong direction in solving this problem. Technical ways of restriction of using some code are all half-measures. They all are to be overpassed eventually and not prevent stealing code and content. In my opinion what is right to do is to make licenses work. Ok, not everyone has money to go to court and go through all legal procedures to defend their rights. But that doesn't mean community has nothing to do with this. We should care more about licensing. We should make it common practice. Like remembering about them here and there. Encourage all content creators to think about licensing earlier in their project life. Make proper licensing policy a good practice in any project and any beginning. It does not confront community opennes and spirit. Did you know there's APL-SA license which is very well fitted for community and sharing? Not saying that CBA is released under GPLv2. We could encourage people using these licenses. Community could notice someone is using APL-SA-licensed content and say to this guy: "hey, are you aware you're using APL-SA-licensed code/content? you will be forced to release your work under this license too. If you disagree, remove all voilating code from your project." Something like this. What also community can do? Look at the Free Software Foundation. They collect information about free software licenses violations. And you know what? This is right thing to do. Because if you don't you leave your naked ass for the icy wind. Making content authors and maybe even BIS knowing about licenses violations. I dunno. Boycott violators and all this stuff. This mechanism is created for this kind of situation. And such kind of problem is by design should be solved this way. And excuse me for being idealistic. PS. Some kind of licenses are not for limiting users of content (or anybody at all), but for protecting content creators and openness and sharing spirit in the community!
  18. pedeathtrian

    append faster than pushBack?

    pushBack is for adding only one element to array, so when you use it you at the same time give the knowledge of amount of elements (one) to adding function. Whereas append works for array of arbitrary count of elements to add, so it must first do extra work of defining how much elements is passed for appending and so on. Not tested, but my bet is that append is faster for adding multiple elements than loop of pushBack's
  19. I disagree on this. params not only defines listed names as private variables, it also tries to parse them from _this variable. Although work ok for creating local variables, both param and params are not for this, but for simplifying parsing input arguments (compared to previously (and still) used BIS_fnc_param function). In fact, for variables not passed through _this, it is param and params who does extra work in this code: params ["_someName1", "_someName2"]; vs. this code: private ["_someName1", "_someName2"]; Also, if working with arguments passed through _this, there's absolutely no point of redefining them right after params: params ["_arg0", "_arg1"]; _arg0 = _this select 0; // already done by params! _arg1 = _this select 1; // already done by params! So, the best practice is let param and params only work with arguments passed through _this, and define all local variables by private: params ["_object","_mskmh"]; private ["_ret"];
  20. Check this topic. Also try search the forums first.
  21. https://www.bistudio.com/community/licenses then
  22. Justine67, _referencePos = getPosWorld player; //or whatever you want _sortedByRange = [vehicles,[],{_referencePos distanceSqr position _x},"ASCEND", {(_x isKindOf "Car") && (damage _x > 0.8)}] call BIS_fnc_sortBy; _sortedByRange params ["_nearestCar"];
  23. pedeathtrian

    Standalone GUI Dialog Editor

    Do you have at least some kind of specification for that software? Some (sufficient) collection of links on the topic. File formats, data types, required functionality, available API, all the stuff. Because now it looks like there might be some person who perfectly knows how to create dialogs in A3, and is a programmer at the same time, and is capable of writing crossplatform code. And he would kindly spend significant amount of time to create this software. You're asking for (almost) impossible. Or there might be some person who does not know how to create dialogs in A3, but is a programmer, and is capable of writing crossplatform code. And he would kindly spend more significant amount of time to first learn the theme and then create this software. This is also (almost) impossible. Or there might be some person who knows how to create dialogs in A3, but is not a programmer. And he would kindly spend even more significant amount of time to first gain some programming skills and then write some resemblance of required SW. It's funny but see this happening more often than previous. You can increase the chances for that software being eventually created by collecting all information and writing some speicifcations, thus doing part of the work that does not require programming skills. When done with community assistance it can provide a very good start point if in some time in the future some random programmer will have spare time for community project.
  24. Solution for editor. Place and invisilbe (in fact even visible will work, see below) heli pad (Empty -> Objects -> H (Invisible)). In its init write: lwh = "Library_WeaponHolder" createVehicle position this; lwh addWeaponCargoGlobal ["arifle_katiba_f", 1]; lwh enableSimulation false; // optionally change position relative to helipad lwh setPos (this modelToWorld [0, 0, 0.5]); // this is why you can place visible helipad deleteVehicle this; You will still have "Inventory" action, standard inventory dialog will open, but you will not be able neither to get this weapon nor to place something in the same weapon holder.
×