fin_soldier 82 Posted October 22, 2020 Hello, I'm working on a 4 player coop, in which there should be more enemies depending on the amount of players. Let's say for example that there's a enemy group of four, and one enemy for each 4 players. So if there's only one player there's only one enemy in that group. I tried to do something with condition of presence, but without success. In init I executed "player1 = true" if player 1 exists, then I put in the condition of presence of the enemy "player1". Then that enemy should exist right? I'm not sure if this is the right way to do this. If someone could enlighten me, I'd be very happy. Thanks in advance! Share this post Link to post Share on other sites
Alert23 215 Posted October 22, 2020 Hmm Maybe try: waitUntil { !(isNull player1) }; 1 Share this post Link to post Share on other sites
ZaellixA 383 Posted October 22, 2020 First of all, if you intend to use a waitUntil loop, I strongly suggest adding a sleep command in it to save some CPU usage. This would look like waitUntil { sleep 2; // Wait 2 seconds before checking again !(isNull player); // Check if player exists }; 1 Share this post Link to post Share on other sites
fin_soldier 82 Posted October 22, 2020 5 hours ago, Alert23 said: Hmm Maybe try: waitUntil { !(isNull player1) }; 33 minutes ago, ZaellixA said: First of all, if you intend to use a waitUntil loop, I strongly suggest adding a sleep command in it to save some CPU usage. This would look like waitUntil { sleep 2; // Wait 2 seconds before checking again !(isNull player); // Check if player exists }; Both of these just say "Error Invalid number in expression" in the unit's condition of presence. Share this post Link to post Share on other sites
pierremgi 4886 Posted October 22, 2020 On dedicated, player doesn't mean anything. If you want to wait for a specific player, just use the condition: isPlayer player1 2 Share this post Link to post Share on other sites
Casio91Fin 31 Posted October 22, 2020 Luotko vihollisen scriptinä? Share this post Link to post Share on other sites
fin_soldier 82 Posted October 22, 2020 20 minutes ago, Casio91Fin said: Luotko vihollisen scriptinä? En luo scriptinä, ihan perus unit placement. Share this post Link to post Share on other sites
ZaellixA 383 Posted October 22, 2020 @Casio91Fin and @fin_soldier would you mind using English on public posts as per the guidelines? You could PM other users and use whatever language you wish. 2 Share this post Link to post Share on other sites
Larrow 2822 Posted October 23, 2020 Some form of...? ( place down enemy groups as need for max players ) Spoiler //initServer.sqf //Wait for the mission to start waitUntil{ time > 0 }; //Mission max player count _maxPlayerCount = 4; //<-- Change to max player count for your mission //Get the ratio of players to max players _playerCountRatio = count ( allPlayers - entities "HeadlessClient_F" ) / _maxPlayerCount; //For all groups { //If the side of the group is enemy( change east to your liking ) if ( side _x isEqualTo east ) then { //Get the group size minus group size times max players ratio _numUnitsToRemove = count units _x - floor(( count units _x ) * _playerCountRatio ); //Get the units in the group( minus the leader ) _units = units _x - [ leader _x ]; //Reverse them so we remove them from the back of the formation reverse _units; //Select units to remove _units = _units select[ 0, _numUnitsToRemove ]; //Delete the units { deleteVehicle _x; }forEach _units; }; }forEach allGroups; //<-- Could change this to be more specific if needed So if there are 4 players divided by max players = 1, no units will be deleted. if there are 2 players divided by max players = 0.5, half of the units in each group will be deleted if there are 3 players divided by max players = 0.75, a quarter of the units in each group will be deleted etc Think that works out right math wise. 1 1 Share this post Link to post Share on other sites
kaleb c0d3 8 Posted October 29, 2020 @fin_soldier , I've made a balancing mod (in beta ATM). Because I play with a closed small group (8 members max), I have the same issue. My approach was this (before converting the code into a module): Sync AI groups to be balanced to an empty logic object. Used a function that has these parameters: the logic, minimum players, maximum players, delta, timeout. the logic: as explained above minimum players: if player count goes below this value, remove "delta" units from synced groups. maximum players: if player count goes above this value, add "delta" units to synced groups. delta: the amount of units to be added or subtracted when balancing. timeout: number of seconds to wait until balancing. The function must run server side only. The logic init code is something like this: [this, 4, 6, 1, 300] call GLMFW_fnc_globalBalance; I'm sorry that i cannot share code right now (I don't have access to my terminal ATM). Basically, I've got this scenario: After some time, the script will kick in and balance AI's based on players connected at that moment. If we are between min and max threshold, nothing happens. If we are below min, each synced group gets "delta" units deleted at random (if delta is 1, one unit is deleted per missing player). If we are above max, each synced group gets "delta" added units (duplicating one random group member). I hope this gives you an approach to make your balancing script. As soon as I get home, I will share my code with you. Take care and good luck. (Please excuse my english) 2 Share this post Link to post Share on other sites
kaleb c0d3 8 Posted October 29, 2020 @fin_soldier as promised: download this mod and give it a try (Systems -> GravisLudum Mission Framework -> Dynamic Balance). If you want to go deeper, decompile GL_DynamicBalance.pbo ; then take a look at fn_globalBalance.sqf and fn_adjustGroup.sqf I've made the english translation (Spanish & English atm). We don't have a public Git yet, but feel free to use, modify & adapt it as you see fit (we have a Creative Commons licence CC BY-NC-SA 4.0, https://creativecommons.org/licenses/by-nc-sa/4.0). Good luck and happy coding! 1 Share this post Link to post Share on other sites