Random Territories setup on server restart

Random Territories setup on server restart

« posted: May 02, 2017, 12:17 AM »
I was brainstorming with both Matt and Agent and Agent found the answer to this. The question was;

Is there a way to setup multiple territories in a file or in multiple arrays and randomly call a file or array with each restart of the server? Reason: So the territory marker will not be in the same place on server restarts.

The Answer from AgentRev as I was looking too far deep into the territory setup he was able to figure it out:

If you look in \config.sqf, there's this line for territories:

Code: [Select]
config_territory_markers = compileFinal preprocessFileLineNumbers "mapConfig\territories.sqf";
So basically, what you can do is create multiple territories.sqf and have the config script pick a random filename when that line is called.

For example:

Code: [Select]
_territoryFile = selectRandom ["territories1", "territories2", "territories3"];
config_territory_markers = compileFinal preprocessFileLineNumbers format ["mapConfig\%1.sqf", _territoryFile];


Thank you AgentRev and thank you Matt for giving me info on other servers who has this setup in similar ways. After looking at theirs and the one above I can verify the one above is way, way better as there is no changing in the default_config.sqf like other servers has done. So the way above will be a true random but of course we all know with random there is a chance the same file could be chosen again, that is the way random is. I remember in Visual Basic it was the same way whenever I use to code using VB6 and Access. So don't be surprised if the same file gets chosen twice in a row but it most likely won't be chosen three times a row.

Re: Random Territories setup on server restart

« Reply #1 posted: May 04, 2017, 12:16 PM »
if you refer to the territories implementation (A, B, C Territories) which lodac and me wrote together: the reason we did it as a config parameter is that you can change the current territory set easily in the main_config.sqf. that way you can force a specific territory/territory set in the config file without touching the mission.

Re: Random Territories setup on server restart

« Reply #2 posted: May 04, 2017, 02:21 PM »
if you refer to the territories implementation (A, B, C Territories) which lodac and me wrote together: the reason we did it as a config parameter is that you can change the current territory set easily in the main_config.sqf. that way you can force a specific territory/territory set in the config file without touching the mission.

Okay wiking I found yours and lodac's github change and will try it for now until selectRandom can get fixed. I just feel the more I can stay away from the stop and restart buttons then better and 64 bit Arma 3 is allowing this to happen now.

EDIT;

Wiking I just seen this:

_currentGroup = A3W_territoryAllowed call BIS_fnc_selectRandom;

So basically its doing the same thing I was trying to do. I now see what you were talking about.

I also see that our guys, before I came on board, used TOPArma's PBO whenever they originally setup their server.

Re: Random Territories setup on server restart

« Reply #3 posted: May 06, 2017, 02:34 AM »
I want to say thanks to you and Lodac for the script. I did know the idea I had was already done. It works and I figure I can group my territories by grouping them in the Territory_0, Territory_1, Territory_2 and so on and keep their same names even though they may be in a different part of the map. What I don't want to see is 1 territory chose that only has 3 markers. So I figure grouping them using the Territory_number is the best way to correct this.
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2313

Re: Random Territories setup on server restart

« Reply #4 posted: May 06, 2017, 10:05 PM »
I don't know if you still have the selectRandom problem you PM'ed me about, but I figured it out; config_territory_markers is defined independently on each computer, it is not network-synced. So if you put selectRandom in the definition, the outcome could be different between client and server. That's why you were seeing inactive territories.

The solution is:
Code: [Select]
if (isServer) then
{
_territoryFile = selectRandom ["territories1", "territories2", "territories3"];
config_territory_markers = compileFinal preprocessFileLineNumbers format ["mapConfig\%1.sqf", _territoryFile];
publicVariable "config_territory_markers";
};

Re: Random Territories setup on server restart

« Reply #5 posted: May 07, 2017, 07:27 PM »
Okay AgentRev I will give it a try as I still have both TOPARMAS and the A3W version in a back up directory for testing purposes.

Thanks a million..

Re: Random Territories setup on server restart

« Reply #6 posted: May 07, 2017, 08:08 PM »
I don't know if you still have the selectRandom problem you PM'ed me about, but I figured it out; config_territory_markers is defined independently on each computer, it is not network-synced. So if you put selectRandom in the definition, the outcome could be different between client and server. That's why you were seeing inactive territories.

The solution is:
Code: [Select]
if (isServer) then
{
_territoryFile = selectRandom ["territories1", "territories2", "territories3"];
config_territory_markers = compileFinal preprocessFileLineNumbers format ["mapConfig\%1.sqf", _territoryFile];
publicVariable "config_territory_markers";
};

Okay Rev it works but there is a problem.


It now chooses the territories1.sqf, territories2.sqf or territories3.sqf randomly like it should which is great. Territory markers also appear and can be captured.

The only problem I am seeing is that even though it chooses a random territory marker its still placing a Flag and Territory name of territories that was not chosen down on the map. So if if territories3.sqf was randomly chosen, those territories work fine but any FLAG and Territory names that are in territories1 or territories2 still show up on the map even though they cannot be captured. (I know I stated it twice above but wanted to make sure it was understood)

How can I hide the flags and names of territories that were not chosen?
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2313

Re: Random Territories setup on server restart

« Reply #7 posted: May 07, 2017, 10:10 PM »
If you replaced the original config_territory_markers line with my solution, normally inactive territories will not show up. I tested it yesterday.

Re: Random Territories setup on server restart

« Reply #8 posted: May 08, 2017, 12:04 AM »
If you replaced the original config_territory_markers line with my solution, normally inactive territories will not show up. I tested it yesterday.

I think I see what the issue is. In our mapConfig directory there is a directory called territories. Inside that directory I have 9 sqfs with each territory information that creates the territory by script. I am guessing this is TOPARMAs solution of creating the territories by script because inside one of the sqfs for example is the info:

Code: [Select]
_pos = [1651,18788.1,0 ];
_marker = createMarker ["TERRITORY_0_SOUTH_RIEDELBACH_RUINS_A", _pos];
_marker setMarkerShape "ELLIPSE";
_marker setMarkerBrush "DiagGrid";
_marker setMarkerSize [35, 35];
_marker setMarkerDir 0;
_marker setMarkerColor "ColorYellow";
_marker setMarkerType "Empty";

_pos = [1651,18788.1,0];
_marker = createMarker ["Flag_0_SOUTH_RIEDELBACH_RUINS_A", _pos];
_marker setMarkerType "mil_flag";
_marker setMarkerText "SOUTH RIEDELBACH RUINS A";
_marker setMarkerSize [.5, .5];
_marker setMarkerColor "ColorYellow";

Like I stated this was like this whenever I joined this group and I am guessing they used their pbo originally which creates the territory by script. What I do whenever I convert a map is just create one marker and move it into position where I want just to get the coordinates. Then I copy this info into each sqf as showing above.

I am guessing your original setup did not have the markers created by script and they were placed manually in the map editor?

If so then this is most likely I am still seeing the FLAGs and the Territory Name on the map even though there is no capture marker (ELLIPSE DiagGrid) thats visible)...

Are my thoughts correct in thinking this?

Either way both yours and TOPARMAs scripts works the same way except they scripted the territories to be created by script on server start while yours calls for the markers to be setup in the map editor...
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2313

Re: Random Territories setup on server restart

« Reply #9 posted: May 08, 2017, 12:08 AM »
I have never had territories created by script, I do not support such a redneck approach. I only deal with editor markers. This is what the config scripts should look like, I will not assist any other method.

Re: Random Territories setup on server restart

« Reply #10 posted: May 08, 2017, 05:39 PM »
iirc: we also use editor markers (101, 102, 103, ...) the current territory set is a global variable sent to all jip clients. all markers for inactive territory sets are deleted on the clients on jip.

Re: Random Territories setup on server restart

« Reply #11 posted: May 09, 2017, 06:05 PM »
Okay I understand and don't know who set this up like this. Whenever I updated their release from 1.2 to 1.3b I just copied over the mapConfig directory.

wiking.at if you guys also use editor markers then why do you have for example a territories directory in mapConfig directory of your PBOs (chenarus & altis for examples) which is what I mentioned above?  Go look at your Github they are there. Also look at line 83 of your init.sqf you will see its being processed with:

Code: [Select]
call compile preprocessFile "mapConfig\territories\init_external.sqf";
I will delete this line and the directory and manually place the markers on the map. I don't know who started this originally and why but AgentRev your right, its redneck because it takes 5 times as long just to setup territories.

Re: Random Territories setup on server restart

« Reply #12 posted: May 09, 2017, 07:16 PM »
forget that git repo - it wasn't updated for a long time.

Re: Random Territories setup on server restart

« Reply #13 posted: May 09, 2017, 07:26 PM »
okay so you guys were TOPARMA but now Armajunkies....Gotcha..

Re: Random Territories setup on server restart

« Reply #14 posted: May 09, 2017, 09:29 PM »
no  - actually toparma was l0dac's project. we worked together on the territory stuff but l0dac stopped last year.