Operation Scudhunt problem

Kill your comrades. Wholesale
Post Reply
Tweet
Posts: 4
Joined: Thu Jan 20, 2011 8:56 am

Operation Scudhunt problem

Post by Tweet »

Hi guys, I have been scripting for Sonsalts mission "Scudhunt" for the joint Folk and Marsoc session.

The idea is that both teams are given 3 possible locations for a scud that are being selected at random from a pool of 6 locations.
Also the guerilla start location is selected at random from a pool of 3 locations.

I have done this by placing a game logic that calls a script through the initline.

This script basically deletes the units and vehicles at the unselected locations, the issue I have is that for every player the locations selected are different and the gamelogic seems to be run local for everyone.
So atm this presents the issue where every player will run that script deleting different locations, so the more players are on the map the bigger chance of no locations being left.

I am rather new to scripting and I never got around localization issues like this so I would appreciate any help, if needed I can upload the mission file somewhere.

randomizeMission.sqf (through initline of gamelogic):

Code: Select all

// selecting start location guerilla side

gueStartLoc = round (random 2);

hint format ["gueStartLoc: %1", gueStartLoc];
sleep 10;

// selecting 3 possible scud locations out of the pool

_loc1 = round (random 5);
_loc2 = round (random 5);
_loc3 = round (random 5);
	
while {_loc1 == _loc2} do
{
	_loc2 = round (random 5);
};
	
while {(_loc1 == _loc3) or (_loc2 == _loc3)} do
{
	_loc3 = round (random 5);
};	

possibleScudLocations = [_loc1,_loc2,_loc3];

hint format ["%1, %2,  %3",_loc1,_loc2,_loc3];
sleep 10;

scudLocation = possibleScudLocations select (round (random 2));

hint format ["Scudlocation: %1", scudLocation];
sleep 10;

// deleting unnecessary Russian base markers

for [{_i=0}, {_i<6}, {_i=_i+1}] do
{
	if ( ! (_i in possibleScudLocations)) then
	{
		_deletingRussianMarkers = [_i] execVM "deleteRussianMarkers.sqf";
		waitUntil {scriptDone _deletingRussianMarkers};
	};
};

// setting up the Scud and trucks at remaining Russian bases

{
	if (_x != scudLocation) then
	{
		switch (_x) do
		{
			case 0 :
			{
				_pos = getPos rasmanScud;
				_dir = getDir rasmanScud;
				deleteVehicle rasmanScud;
				rasmanTruck = "KamazRefuel" createVehicle (_pos);
				rasmanTruck setPos _pos;
				rasmanTruck setDir _dir;
			};
			
			case 1 :
			{
				_pos = getPos lalezarScud;
				_dir = getDir lalezarScud;
				deleteVehicle lalezarScud;
				lalezarTruck = "KamazRefuel" createVehicle (_pos);
				lalezarTruck setPos _pos;
				lalezarTruck setDir _dir;
			};
			
			case 2 :
			{
				_pos = getPos mineScud;
				_dir = getDir mineScud;
				deleteVehicle mineScud;
				mineTruck = "KamazRefuel" createVehicle (_pos);
				mineTruck setPos _pos;
				mineTruck setDir _dir;
			};
			
			case 3 :
			{
				_pos = getPos jilavurScud;
				_dir = getDir jilavurScud;
				deleteVehicle jilavurScud;
				jilavurTruck = "KamazRefuel" createVehicle (_pos);
				jilavurTruck setPos _pos;
				jilavurTruck setDir _dir;
			};
			
			case 4 :
			{
				_pos = getPos anarScud;
				_dir = getDir anarScud;
				deleteVehicle anarScud;
				anarTruck = "KamazRefuel" createVehicle (_pos);
				anarTruck setPos _pos;
				anarTruck setDir _dir;
			};
			
			case 5 :
			{
				_pos = getPos garmsarScud;
				_dir = getDir garmsarScud;
				deleteVehicle garmsarScud;
				garmsarTruck = "KamazRefuel" createVehicle (_pos);
				garmsarTruck setPos _pos;
				garmsarTruck setDir _dir;
			};
		};
	};
} forEach possibleScudLocations;

// switch (scudLocation) do
// {
	// case 0 :
	// {
		// null = rasmanScud addEventHandler["fired"];
	// };
// };
deleteRussianMarkers.sqf:

Code: Select all

//selecting the base to delete

_russianBase = _this select 0;

// checking which base to delete and delete all object present in that base

switch (_russianBase) do
{
	case 0 :
	{
		deleteMarker "rasmanMarker";
	};
	
	case 1 :
	{
		deleteMarker "lalezarMarker";
	};
	
	case 2 :
	{
		deleteMarker "mineMarker";
	};
	
	case 3 :
	{
		deleteMarker "jilavurMarker";
	};
	
	case 4 :
	{
		deleteMarker "anarMarker";
	};
	
	case 5 :
	{
		deleteMarker "garmsarMarker";
	};
};

deleteRussianBase.sqf (called through initline of each unit/vehicle on the bases with parameters)

Code: Select all

waitUntil{scriptDone randomizeHandle};

_location = _this select 0;
_vehicle = _this select 1;

if (! (_location in possibleScudLocations)) then
{
	deleteVehicle _vehicle;
};
teleportToStartLocation.sqf (called through initline of the playable units on guerilla side):

Code: Select all

waitUntil{scriptDone randomizeHandle};

_falarMarkerPos = getMarkerPos "Falar";
_mulladostMarkerPos = getMarkerPos "Mulladost";

// setting up start location for Guerilla side
switch (gueStartLoc) do
{
	case 0 :
	{
		player setVehiclePosition [_mulladostMarkerPos,["Mulladost"], 25];
	};
	case 1 :
	{
		player setVehiclePosition [_falarMarkerPos,["Falar"], 25];
	};
};




User avatar
fer
Posts: 1586
Joined: Fri Jun 04, 2010 8:16 am
Location: Emotional wreck

Re: Operation Scudhunt problem

Post by fer »

Hi Tweet, the good news is that all the AI units will only be local to the server; this means your delete script only needs to run on the server (which automatically synchronises with all clients). In turn, this means you only need to do the random selection of locations on the server.

Something we agreed with Spirit was that missions would use the F2 MARSOC vs Folk framework. In addition to ensuring the platoons, loadouts and markers are correct, this approach should help you with your specific challenge in two ways:
  • You can trigger the location selection and unit removal scripts from the mission's init.sqf file (better than using a gamelogic)
  • You can re-purpose the format of the scripts in /f/server/ to ensure the commands only execute on the server
Hope this helps - let me know how you get on, and if you need a further hand :)

Tweet
Posts: 4
Joined: Thu Jan 20, 2011 8:56 am

Re: Operation Scudhunt problem

Post by Tweet »

fer wrote:Hi Tweet, ...

Something we agreed with Spirit was that missions would use the F2 MARSOC vs Folk framework. In addition to ensuring the platoons, loadouts and markers are correct, this approach should help you with your specific challenge in two ways:
  • You can trigger the location selection and unit removal scripts from the mission's init.sqf file (better than using a gamelogic)
  • You can re-purpose the format of the scripts in /f/server/ to ensure the commands only execute on the server
Hope this helps - let me know how you get on, and if you need a further hand :)
I have merged the missions, however in the Scudhunt mission the layout of the teams seems to be a bit different, I will check this with Sonsalt (for bluefor he selected SF guys for instance).

I looked at the scripts in /f/server/ but tbh I have no idea how they work or which scripts should go there, so if anyone could help me out in detail how to do this, maybe even get on TS to explain me why and how to solve this I am pretty sure that in the future I can pull this server-run-only-thing off :)

Tweet
Posts: 4
Joined: Thu Jan 20, 2011 8:56 am

Re: Operation Scudhunt problem

Post by Tweet »

ok, I feel a bit of an idiot now, I had seen the isServer command before but my tiny brain never made the connection that I could use that in a simple if-construction to let code only run on the server :D

Anyway I fixed that part, will test that as soon as I find someone to help me cause I can't test it without at least 1 other player connecting :)

For the layout I will talk to Sonsalt and will get that straightened out as well.

Thx for the help guys, and may the arma gods have mercy on your soul when Marsoc battles you again in an epic mission :P

Tweet
Posts: 4
Joined: Thu Jan 20, 2011 8:56 am

Re: Operation Scudhunt problem

Post by Tweet »

hmz, after testing it by going independent with 2 guys and 1 guy in bluefor, it seems only one of the independents gets moved.
I did however get an error in teleportToStartlocation.sqf stating that randomizeHandle was an unknown var.

I really dont have any clue anymore as how to fix it, so I would appreciate it if someone could take a look at the mission files, I zipped and uploaded them to this location:

www.translucent.be/Marsoc/tweet/Scud_hunt.Takistan.rar

thx in advance

Tweet

User avatar
fer
Posts: 1586
Joined: Fri Jun 04, 2010 8:16 am
Location: Emotional wreck

Re: Operation Scudhunt problem

Post by fer »

Tweet, I'll try to look at this over the weekend - but if any other comrade mission makers from Folk have time, please look also!

Post Reply