Update: attachment updated to ver. 01b
------------------------
Ok, these are my first attempts at any kind of "real" scripting.
No demo mission yet, although I'll work on it.
The JTDCity_init should be run at initialization, or at the beginning of a mission.
Credit goes to OFPEC, hoz, Spooner, and DMarkwick.
From the comments/readmes.
Readme for JTDCityPosition.sqf function.
By Trexian/hoz
The purpose of the JTDCityCenter function is to determine the location of a city area. It is almost a direct rip of the FindClosestTown function by hoz, available at OFPEC. All I did was change the elements returned, and tweaked the mechanism for creating the array, as suggested by Spooner. All credit for this function really goes to hoz.
Readme for JTDCityCenter.sqf function.
By Trexian
The purpose of the JTDCityCenter function is to roughly determine the center of a city area. It starts with the position passed to it (likely the config location of the city), and determines the densities of the areas in each direction. If one of the densities is larger than the inital, that becomes the temporary center. The search is repeated until the script reaches a position that has no higher density in the surrounding area. That position is returned.
Readme for JTDCityBorder.sqf function.
By Trexian
The purpose of the JTDCityBorder function is to roughly determine the size of the city being analyzed. It first determines the baseline density for the center of the city. The analysis is different, depending on whether it is a high-density or low-density city. The script uses a circle of the given radius (_radius) to compare the density within the circle to the initial density in each cardinal direction. When it reaches a certain percentage (_densityCutoff) of the original ratio, it considers that the outer extent of that direction. The script uses the longer of North/South for the B radius, and East/West for the A radius. The _radiusFactor is basically something to increase/decrease the size of the radii by an artificial amount, depending on the needs of the developer. This can also be achieved by altering the returned elements in the calling script.
Also, within the script, the areas to tweak are:
- the first conditional determines the definition between "big" and "small" cities
- the _dist is the increment for the center of the search
- the _radius determines the size of the circle the search examines to determine the ratio to compare to the initial ratio
/*
JTD City Initialization script
by Trexian
Purpose: run the JTD City functions
Implementation: executed from init or mission.sqm
Future plans will include greater information exchange.
ooooooooooooooooooooooooooooooooooooooooooooooooooo
"JTDCityPosition.sqf"
- passed no parameters
- returns an array of all cities in the config, and the config positions
"JTDCityCenter.sqf"
- passed a position array (most likely from JTDCityPosition)
- determines the approximate center of the city, by density
- returns the position of the center
"JTDCityBorder.sqf"
- passed a position array (most likely from JTDCityCenter)
- determines an approximate geographic size of the city in X (radius A) and Y (radius B)
- returns radius A/B for use in marker or trigger
The markers are created to show the scenario developer the location and size of the parameters.
This particular script loads the centers and borders in additional global arrays that are indexed in the
same order as the city list taken from the config.
*/
Apologies if this stuff doesn't merit inclusion.
Edit 1:Correct zip included, although it still suffers from no demo mission and the style issues identified by Spooner.
Edit 2: attached pbo with scripts/functions that should better conform to the standards.
(This is my first attempt at exporting a mission as a pbo, so if I messed something up, let me know. Also, should I upload just the scripts/functions, too?)