Jump to content

Dj Rolnik

Member
  • Content Count

    140
  • Joined

  • Last visited

  • Medals

Community Reputation

28 Excellent

About Dj Rolnik

  • Rank
    Sergeant

Profile Information

  • Location
    Poland

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Aaaahhh, I knew that there was a better and more optimized way of doing this and Larrow would be the one to show it. Damn you, sqf wizard! (in a positive sense!)
  2. Ok, fixed it myself while I was brainstorming this at work >.<". I was executing the code on the array and at the same time removing items from it, so it executed on one marker, removed one marker, executed on the next marker, removed the next one, and only one was left, so it just executed - this gave me three successful spawns. I simply added a separate array, the exact same as the original marker array but named different and executed the spawning code on each element of THAT NEW array. // Anomaly placement markers anomaly_spawners_main = [ "ra_1", "ra_2", "ra_3", "ra_4", "ra_5" ]; anomaly_spawners = [ "ra_1", "ra_2", "ra_3", "ra_4", "ra_5" ]; // Available anomalies anomalies = [ "anoamly_moduleElectra", // Electra "anoamly_moduleBurner", // Burner "anoamly_moduleFruitPunch", // Fruit Punch "anoamly_moduleMeatgrinder", // Meatgrinder "anoamly_moduleSpringboard" // Springboard ]; // Generating random anomalies losowe_anomalie = createGroup sideLogic; { randomAnomalies = selectRandom anomalies; randomSpawners = selectRandom anomaly_spawners; randomAnomalies createUnit [ (getMarkerPos randomSpawners) getPos [random 15, random 359], // <- THIS! losowe_anomalie, "this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true];" ]; anomaly_spawners deleteAt (anomaly_spawners find randomSpawners) } forEach anomaly_spawners_main; Now I just need to randomize the radius from the marker. I actually did that just as you suggested @_foley. Took me like a minute. That was satisfying! Thanks! ❤️
  3. Yeah, sorry, let me clear it up a bit. I want each marker to spawn one of the five anomalies. There will probably a few dozens of those markers but for all of them I want to have only one anomaly, randomly selected from the array of five. I mean "anomaly module" because they are in fact modules in the editor, not an object, so I cannot use createVehicle.
  4. Hey y'all, It's been a while since I've posted. I have been chugging along with the project, and mananged to get it pretty close to what I have in mind. I am currently struggling with randomizing some stuff spawning. What I want to do is: 1. Spawn a random anomaly module on a randomly selected marker 2. Have the anomaly spawn in a certain random vicinity from the marker (say +/- 15m, not on its exact position) I have done something like this before but I am mingling some things and cannot get it fully to work this time. What I have is the below, and when I run it, it only spawns in THREE anomalies instead of FIVE, and they always spawn on the exact position of the marker. I am pretty certain that the fact only three are spawning is due to the order in which code is being run, but the random placement, I have not yet been able to figure out. Thanks for your help in advance! // Anomaly placement markers anomaly_spawners = [ "ra_1", "ra_2", "ra_3", "ra_4", "ra_5" ]; // Available Anomalies anomalies = [ "anoamly_moduleElectra", // Electra "anoamly_moduleBurner", // Burner "anoamly_moduleFruitPunch", // Fruit Punch "anoamly_moduleMeatgrinder", // Meatgrinder "anoamly_moduleSpringboard" // Springboard ]; // Generating random anomalies losowe_anomalie = createGroup sideLogic; { randomAnomalies = selectRandom anomalies; randomSpawners = selectRandom anomaly_spawners; randomAnomalies createUnit [ getMarkerPos randomSpawners, losowe_anomalie, "this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true];" ]; anomaly_spawners deleteAt (anomaly_spawners find randomSpawners) } forEach anomaly_spawners;
  5. No, I get it now. I got a bit confused and forgot about the fact that the _randSel starts as empty and mixed up both arrays, my bad! I think I got it now, it sure is clever. Thank you Larrow 🙂
  6. Yes, both work just fine, thank you gentlemen! Didn't think it would be so simple. I am having some trouble figuring out what the heck happened though and I'd like to understand. So what I get is that the bracketed part deletes an element of the _mercTargets array selected randomly by the latter part of the bracket. The pushBack is confusing to me, but what I get is it pushes the removed item to the back of the array (?). That is then done 9 times so I understand that in the end the array still contains the same amount of items, but simply rearranged, so how does it produce just nine items? Thanks!
  7. Yo, Coming back at you with a different topic now. I am looking to convert the results of the following code into an array. I am planning to select nine random items from the below array and from then I will pull those items for other purposes. I found the bottom piece of code done for a similar purposes but it was displaying the results as systemChat messages, while I need an array of results. I tried using the toArray command but to no avail. I also tried using the compile command but no luck as well. Any suggestions on how to approach it? _mercTargets = [ loner_1, loner_2, loner_3, loner_4, loner_5, loner_6, loner_7, loner_8, loner_9, loner_10, loner_11, loner_12, duty_1, duty_2, duty_3, duty_4, bandit_1, bandit_2, bandit_3, bandit_4, sky_1, sky_2, sky_3 ]; for "_i" from 0 to 8 do { if (count _mercTargets == 0) exitWith {}; private _rindex = floor(random (count _mercTargets)); private _randSel = _mercTargets # _rindex; toArray hint str (_randSel); _mercTargets deleteAt _rindex; }; Cheers!
  8. Ok yes, that was it. Gosh I didn't think about bracketing the whole thing, my bad there... I did not fully understand the idea of addition of a variable to itself, you know, the x = x + something. I think I get it now: it simply returns the _itemCount * _itemValue for the corresponding item, then runs it again for all other items in the _presntItems array except the variable _sumScore is already a new value based on the previous calculation so it adds up the new corresponding points value. Thank you for that guys, I really appreciate it. I know I may be a slow learner, but I am really trying ">.>
  9. // Calculate item values _presentItems = _lootValues apply { _itemName = _x; _itemValue = _y; _itemCount = {_x isEqualTo _itemName} count magazineCargo chest1; _itemDisplayName = _lootNames get _x; [_itemName, _itemCount, _itemCount * _itemValue, _itemDisplayName] }; // Filter out missing items _presentItems = _presentItems select {_x select 1 > 0}; _sumScore = 0; _sumScore = {_sumScore + (_x select 2)} forEach _presentItems; Two problems: - It does not sum all the items in the chest, only displays the last item - if there are no items in the chest, it says <null> and says the _sumScore is undefined.
  10. Well, I added the previous line but it was only summing the last item on the list so it was missing something. Adding what you provided spews an error that the _sumScore is undefined and when the chest1 was empty, the hint displayed a scalar NaN string as an error.
  11. Ok, small update is that I managed to grab the total value of items and throw it into the hint Title, but I haven't yet added all the values. So far it only cycles through them (I assume) and then shows the last one. // Filter out missing items _presentItems = _presentItems select {_x select 1 > 0}; _sumScore = {_x select 2} forEach _presentItems; // Prepare hint text _hintLines = _presentItems apply { format ["%1: %2 - %3 RUB", _x select 3, _x select 1, _x select 2]; }; _hintTitle = format ["%1 - %2 RUB", name player, _sumScore]; So yeah, I do not know how to loop that so that I can add all those values together.
  12. Ok well, I spoke too soon. Turns out I am still too much in the dark when it comes to understanding it as I cannot figure out how to do the total value thing. I tried making new sections where I apply new code to the already filtered items and I tried to pull this data out somehow, even trying to change the _hintTitle to the same "apply" structure but apparently I cannot do that in the header of the hint? I am clueless and it hurts my ego to ask for a ready-to-go solution, so I would like to ask for a bit clearer explanation on where the heck I would put this total thing. Just to get on the same page, let me throw in the actual final code without placeholder variables and such, to make it easier to follow. // Display names hashmap _lootNames = createHashMap; _lootNames set ["ARMST_ART_control", "Altered Wheel"]; _lootNames set ["ARMST_ART_black_angel", "Angel"]; // Loot values hashmap _lootValues = createHashMap; _lootValues set ["ARMST_ART_control", 2000]; _lootValues set ["ARMST_ART_black_angel", 1000]; // Calculate item values _presentItems = _lootValues apply { _itemName = _x; _itemValue = _y; _itemCount = {_x isEqualTo _itemName} count magazineCargo chest1; _itemDisplayName = _lootNames get _x; [_itemName, _itemCount, _itemCount * _itemValue, _itemDisplayName] }; // Filter out missing items _presentItems = _presentItems select {_x select 1 > 0}; /*_sumScore = */ // Prepare hint text _hintLines = _presentItems apply { format ["%1: %2 - %3 RUB", _x select 3, _x select 1, _x select 2]; }; _hintTitle = format ["%1 - %2 RUB", name player/*, _sumScore*/]; // Show hint _hintTitle hintC _hintLines; // Hide regular hint at the end hintC_arr_EH = findDisplay 72 displayAddEventHandler ["unload", { 0 = _this spawn { _this select 0 displayRemoveEventHandler ["unload", hintC_arr_EH]; hintSilent ""; }; }]; It all seems to make sense when I read it, but for the love of me, I cannot process this and create it on my own.
  13. Oh God, I swear I almost felt your excitement there 😄 I almost took brain damage while trying to figure this stuff out but it's cool to finally understand something ^^" When I get back home I will try to put it into practie!
×