Jump to content
Sign in to follow this  
katipo66

Map or editor created locations as waypoints

Recommended Posts

Ok I've been looking for a couple of days but can't find many clues, is it possible to use map locations / citycentres as waypoints maybe utilizing Taskattack taskdefend and taskpatrol? Or even a simple move.

Anyway if anyone has or knows of something specific that would be great.

Share this post


Link to post
Share on other sites

Cheers bro, trust me I've been searching and have both Those saved as reference, And using that nearest locations option was interesting, there is an option that also shows neighbors, and I was wondering if they could also be latched onto as waypoints... gold at http://www.ofpec.com/COMREF/index.php?action=read&id=231#locations

I probably didn't explain properly but I was wanting to know is there a Specific command or function to make groups move to the citycenters, I understand markers as waypoints etc.

i.e. Allgroups move nearestlocation 2000 call bis_fnc_taskattack / bis_fnc_taskdefend

Share this post


Link to post
Share on other sites

Here mate. I knew I had something on Citycenters somewhere. Just dug it out and had a look.

Not my code.... but might help. Many thanks to whoever wrote it.

Did not play with it much... but seems to return stuff you'd be interested in.

private ["_list", "_typeVar", "_neighbors", "_name"];

waituntil {!isnil "bis_fnc_init"};
//[] call BIS_fnc_help;

_list = ["CityCenter",[position player,4000],true] call bis_fnc_locations;

hint format ["list = %1", _list];

sleep 2;
{

hint format ["element %1 = %2", _x, getPos _x];
sleep 2;
_typeVar = _x getVariable "type";
_neighbors = _x getVariable "neighbors";
_name = _x getVariable "name";
hint format ["neighbours: %1\ntypevar: %2\nname: %3", _neighbors, _typeVar, _name];
sleep 2;

} forEach _list;

Share this post


Link to post
Share on other sites

Cheers bro,

Yes ive used that script, and this variation from ofpec, also mention of a 'Dynamic Route module'

private ["_list", "_JTDMarker"];

_JTDMarker = createMarker ["marker", getPos player];
_JTDMarker setMarkerColor "ColorGreen";
_JTDMarker setMarkerShape "ELLIPSE";
_JTDMarker setMarkerSize [50, 50];

_list = ["CityCenter",[position player,1000],true] call bis_fnc_locations;

hint format ["list = %1", _list];

sleep 1;
{
_JTDMarker setMarkerPos getPos _x;   // marker for debugging

hint format ["element %1 = %2", _x, getPos _x];
sleep 5;
} forEach _list;

Yeah i probably need to look at it again, also i think the answers are within the warfare module which im going through now and then i might have some idea on what to ask for.

This has ceased being a game and become some form of puzzle investigating and tinkering software, dangerous place for the ill equipped :p

Share this post


Link to post
Share on other sites
This has ceased being a game and become some form of puzzle investigating and tinkering software

The trap has been sprung! LOL!

Share this post


Link to post
Share on other sites

How can i make this run on every group as opposed to just UNITNAME?

[uNITNAME, LOCS] execVM "SCRIPTNAME.sqf";

Share this post


Link to post
Share on other sites

Like this...

[[url="http://community.bistudio.com/wiki/allGroups"]allGroups[/url], LOCS] execVM "SCRIPTNAME.sqf";

Share this post


Link to post
Share on other sites

I tried that, but not sure how to include the array into it... i.e.

{((leader _x), LOCS) execVM "script.sqf";} forEach allGroups

EDIT*

{(leader _x),[_x, LOCS] execVM "script.sqf";} forEach allGroups;

Shot bro :D

Edited by Katipo66
Found it

Share this post


Link to post
Share on other sites

It should work like this....

{[leader _x,LOCS] execVM "script.sqf"} foreach allGroups;

EDIT:-

Another way.... same result...

for "_i" from 0 to ((count allGroups)-1) do {
   _group = allGroups select _i;
   _leader = leader _group;
   [_leader,LOCS] execVM "script.sqf";
   sleep 0.01;
};

Edited by twirly
Added code

Share this post


Link to post
Share on other sites

It did work like this

{(leader _x),[_x, LOCS] execVM "script.sqf";} forEach allGroups;

But maybe these other options are more optimized? i try them later.

Share this post


Link to post
Share on other sites

Well I'm not sure how or why that works! It either should not work at all or should give weird results!

The proper syntax according to the Wiki for execVM is either (passing multiple variables)...

_handle = [b][a,b,c][/b] execVM "script.sqf";

or (passing single variable) ...

_handle = [b]player[/b] execVM "script.sqf";

Edited by twirly
Clarity

Share this post


Link to post
Share on other sites

it would appear that this part :

(leader _x),
is being ignored by the script since its a clear error, and then the remaining [_x, LOCS] is being used and _x is the group and LOCS is what they are. thus making it work..

but yeah, that should "not work", but stranger things have happened... :)

Share this post


Link to post
Share on other sites

@Katipo66

Change your code to the proper stuff Bro.... even if what you have works don't use it. It will only cause confusion in the future.

Share this post


Link to post
Share on other sites

I have been trying the proper code which didnt work, but with this

{(leader _x),[_x, LOCS] execVM "script.sqf";} forEach allGroups; 

i have units running around Utes with nothing in thier init's :D

but yes agree that its obviously not correct and will cause issues later, mind you it gives no error from showScriptErrors?

when i just tried

[_x, LOCS] execVM "script.sqf";} forEach allGroups; 

i got script errors tellin me _X is not defined?

ill upload details later, i managed to find a solution from hacking and slashing one of Wolffy's missions... so from my scripting ignorance ive inadvertently got it to work.

Edited by Katipo66

Share this post


Link to post
Share on other sites

Ah.... I see a gremlin which may be my fault from much higher up in the thread. Maybe try this then. Include the nul=

{[b]nul =[/b] [leader _x,LOCS] execVM "script.sqf"} foreach allGroups;

Share this post


Link to post
Share on other sites

{nul = [leader _x,LOCS] execVM "crB_WaypointPatrol.sqf"} foreach allGroups;

worked, cheers.

So what i did was grab 2 scripts from Wolffys ctb_co16_boersplain_1-7.takistan

LocationsZone.sqf:-

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: (AEF)Wolffy.au [2CAV]
// Created: 20090910
// Contact: http://creobellum.org
// Purpose: Identify locations within a rectangular marker
///////////////////////////////////////////////////////////////////
if (!isServer) exitWith{};

waituntil {!isnil "bis_fnc_init"};

_marker = _this select 0;
_loc_types = _this select 1;

_pos = markerPos _marker;
_size = markerSize _marker;
_sz = _size select 0;
if (_sz < _size select 1) then {_sz = _size select 1;};
_locs = [_loc_types, [markerPos _marker, _sz]] call BIS_fnc_locations;
_newlocs = [];
{
_p = position _x;
if ((_p select 0) >= (_pos select 0) - (_size select 0)  &&
(_p select 0) <= (_pos select 0) + (_size select 0) &&
(_p select 1) >= (_pos select 1) - (_size select 1) &&
(_p select 1) <= (_pos select 1) + (_size select 1)) then {
	_newlocs = _newlocs + [_x];
};
} forEach _locs;
//hint str _newlocs;
_newlocs;

And crB_WaypointPatrol.sqf: -

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: (AEF)Wolffy.au [CTB]
// Created: 20090719
// Modified: 20100713
// Contact: http://creobellum.org
// Purpose: Setup and cache random waypoint patrols
///////////////////////////////////////////////////////////////////
if (!isServer) exitWith {};

_vehicle = _this select 0;
_locs = _this select 1;
_grp = nil;
if(typeName _vehicle == "GROUP") then {
_grp = _vehicle;
_vehicle = leader _grp;
} else {
_grp = group _vehicle;
};
_veh = vehicle _vehicle;
_drv = assignedDriver _vehicle;

while {true} do {
_pos = _locs select floor(random count _locs);
_wp0 = _grp addWaypoint [_pos, 0];
_wp0 setWaypointCompletionRadius 100;
switch{side _drv} do {
	case civilian: {
		_wp0 setWaypointBehaviour "SAFE";
	};
	case east: {
		_wp0 setWaypointCombatMode "RED";
		_wp0 setWaypointFormation "COLUMN";
		_wp0 setWaypointSpeed "LIMITED";
		_wp0 setWaypointBehaviour "SAFE";
	};
};
waitUntil{currentWaypoint _grp != 0 || vehicle _drv == _drv};
if(side _drv == civilian) then {
	_veh setDamage 0;
	_drv setDamage 0;
	_veh setPos (getPos _veh);
	[_drv] orderGetIn true;
};
sleep random 120;
};

And stripped out the init.sqf so it only has this: -

_locs = ["AO", ["CityCenter"]] call compile preprocessFileLineNumbers "LocationsZone.sqf";

hint str _locs;
_i = 0;
{
	_i = _i + 1;
	_n = format["x_%1", _i];
	_m = createMarker [_n, position _x];
	_m setMarkerType "Dot";
	_m setMarkerColor "ColorRed";
} forEach _locs;

LOCS = _locs;
publicVariable "LOCS";

waitUntil{!isNil "LOCS"};
waitUntil{typeName LOCS == "ARRAY"};

//{(leader _x),[_x, LOCS] execVM "crB_WaypointPatrol.sqf";} forEach allGroups; this works also?

{nul = [leader _x,LOCS] execVM "crB_WaypointPatrol.sqf"} foreach allGroups;

leaving the hint function in so i can see all the towns on the map that will be patrolled.

Then in on Utes i created a marker named AO covering the whole island, and now when i place units down they automatically run off and patrol from town to town, therefore creating some cool dynamic battles using Demonized support script :yay:

Anyway i dont think its the best way to go about it and theres probably a more efficient way as it maybe wasnt designed for this, but i cant find it? there are other locations other than city area's like StrongpointArea, FlatArea, FlatAreaCity and FlatAreaCitySmall or even neighbors... exciting potential imo

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
Sign in to follow this  

×