Jump to content
Dreadleif

Problem for good coders/people with logic skills

Recommended Posts

Hey, thanks for clicking on a noob's thread :). So, disclaimer: I'm not good with coding, but I've tried and read everything before I posted this, for many hours. This will probably take some of you gurus out there just one minute. I'll try to boil it down before I draw the whole picture below.

 

 

I have six cities on a side, which I use to move two markers between. And attack and a spawn marker. The spawn marker is always moved to the closest friendly city. The attack marker is always moved to the closest enemy city. I have triggers in each city detecting when a city changes side from friendly to enemy (condition in the script could be: triggeractivated x). I've been trying to build a script, and even doing it by triggers. This is above my understanding, and I've read a lot and experimented trying to get it to work, but alas.. :803:

 

 

 

It's confusing to explain so I drew this masterpiece in paint :wub: :

 

qqr7s8.jpg

 

I have read all about IF, conditions, and all the commands but I don't know how to pick between this many complicated options in a script. I started scripting not too long ago and have been stuck on this all day.

Share this post


Link to post
Share on other sites

I am very confused by your description of the problem and your picture.

I halfway understand it, but not enough to put anything together.

Try and explicitly explain each side, attackers and defenders, with all the conditions for each marker movement.

Share this post


Link to post
Share on other sites
Guest

If I understood well :

There are cities.

Each cities are controled by friendlies or ennemies.

He wants to spawn a friendly group in the friendly city and the same for the ennemy city.

Then each spawned group attack each others city to take the control.

Share this post


Link to post
Share on other sites

Thanks guys, and I get it :) . I think I found a simpler way to boil this down. All I need is a simple marker-movement system.

 

1. Create a list of markers A, B, C, D, E, F and G

2. Find the marker on the list closest to marker0

3. Move marker1 to THAT MARKER (edited, so sorry, messed up the logic)

 

Loop point 2 and 3.

 

:D

(I really hope some coding wiz can solve this cause I've been stuck for 10 hours)

 

 

(Even simpler still, maybe I can figure it out with just this information: Just explain how to find the marker from a list of markers which is closest to another marker.)

Share this post


Link to post
Share on other sites
_comparedMarker = _this param [0, "NULL", [""]];
_markerList = _this param [1, [], [[]], 1];

if (_comparedMarker == "NULL" || (count _markerList < 1)) exitWith
{
	["Invalid Parameters, param1 must be of Type-String, param2 must be of Type-Array with at least 1 element"] call BIS_fnc_error;
};

//seed data with the first marker in the list
_nearestMarker = markerList select 0;
_distance = (markerPos _nearestMarker) distance2D (markerPos marker0);
{
	_calcDistance = (markerPos marker0) distance2D (markerPos _x);
	if (_calcDistance < _distance) then
	{
		_distance = _calcDistance;
		_nearestMarker = _x;
	};
} forEach markerList;

//return array with the nearest marker and it's distance
[_nearestMarker, _distance];

save as function

  • Like 1

Share this post


Link to post
Share on other sites
_comparedMarker = _this param [0, "NULL", [""]];
_markerList = _this param [1, [], [[]], 1];

if (_comparedMarker == "NULL" || (count _markerList < 1)) exitWith
{
	["Invalid Parameters, param1 must be of Type-String, param2 must be of Type-Array with at least 1 element"] call BIS_fnc_error;
};

//seed data with the first marker in the list
_nearestMarker = markerList select 0;
_distance = (markerPos _nearestMarker) distance2D (markerPos marker0);
{
	_calcDistance = (markerPos marker0) distance2D (markerPos _x);
	if (_calcDistance < _distance) then
	{
		_distance = _calcDistance;
		_nearestMarker = _x;
	};
} forEach markerList;

//return array with the nearest marker and it's distance
[_nearestMarker, _distance];

save as function

 

 

I have no idea what you just did, but I am in awe. Testing and using it in every way I can (though I have NO idea how to)! :D

 

(if anyone is writing the "marker closest to" thing standalone, please don't hesitate to post it, it's super helpful)

 

 

UPDATE:

In the end, I solved it (for anyone understanding the challenge) by having scripts for each sets of 2 cities. The script checked if City 1 was friendly and City 2 was hostile, and then moved the two attack_spawn, and attack_target markers in a loop. This way the Attackers described above, were always attacking towards the enemy.

 

A little rough but it works. I'm making a Jagged Alliance map for eventual fans. :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×