Jump to content

[patch] Points for pilots


Vaulter
 Share

Recommended Posts

Hi there! Hope you're well!

 

Just want to share small script that i made for ahoy world invade&annex to give some points to pilots for transporting fellows from base to mission spots

 

1. in aw_unitSetup.sqf we need to invoke this script for any Air unit:

if ( _unit isKindOf "Air" ) then { 
	_unit execVM "scripts\a3rc_PilotsPoints.sqf";
};

2. script itself:

/** points for pilots */
if (isDedicated) exitWith {};

//, "_countPoints", "_getClosestObjective"  ];
PFP_count_players = 0.0;
PFP_getins = []; // array of players getins
//centerposition for distance coef
PFP_max_distance = [0,0,0] distance getArray(configFile/"CfgWorlds"/worldName/"centerPosition");

// [_from, _srcObj, _to, _dstObj ]

PFP_getPenalty = {
	private ["_from","_to","_srcObj","_dsstObj"];
	_from = _this select 0;
	_to = _this select 1;
	_srcObj = _this select 2;
	_dstObj = _this select 3;

	//format ["PFP_getPenalty: dist1 %1, dist %2, penalty: %3", (_from distance _to), 
	// (_srcObj distance _dstObj), (_from distance _to) / (_srcObj distance _dstObj) ] call BIS_fnc_log;

	(_from distance _to) / (_srcObj distance _dstObj)
};

// argument - from 
PFP_getClosestObjective = {
	private ["_from", "_min_dist", "_objs", "_d"];
	_from = _this;
	_min_dist = PFP_max_distance;
	_objs = [ markerPos "respawn_west" ];
	// AHOY
	if (!isNil("currentAOUp")) then { if (currentAOUp) then {_objs set[ count _objs, getMarkerPos currentAO ];}; };
	if (!isNil("priorityTargetUp")) then { if (priorityTargetUp) then { _objs set[ count _objs, markerPos "priorityMarker" ]; }; };
	if (!isNil("sideMissionUp")) then { if (sideMissionUp) then { _objs set[ count _objs, getPos sideObj ]; }; };
	
	{ 
		_d = _this distance _x;
		if ( _d < _min_dist ) then { _min_dist = _d; _from = _x };
	} forEach _objs;
	//format ["from %1 closest is: %2", _this, _from ] call BIS_fnc_log;
	_from
};

PFP_countPoints = {
	private ["_points", "_landedAtPos", "_filtered_getins"];
	_landedAtPos = (position player) call PFP_getClosestObjective;
	_points = 0.0;
	_countGroup = 0;
	_filtered_getins = [];
	_remove = [];
	{
		_getInOutPos = (_x select 1) call PFP_getClosestObjective;

		if ( count _x > 2 && (_landedAtPos distance _getInOutPos) > 0 ) then { //  && 

				if ( (_x select 2) > 0 ) then {
					_points = _points + (_x select 2);
				};
				_countGroup = _countGroup + 1;
			//_remove set [ count _remove, _x ];

		} else {
			_filtered_getins set [count _filtered_getins, _x];
		};
		//format ["PFP_countPoints: x= %1, points =%2", _x, _points] call BIS_fnc_log;
	} forEach PFP_getins;
	
	PFP_getins =+ _filtered_getins;
	//format ["PFP_countPoints: points= %1, getins= %2", _points, PFP_getins] call BIS_fnc_log;
	[ round _points, _countGroup ]
};

//Passed array: [vehicle, position, unit]
PFP_heliOnGetIn = {
	// this player is on drive place
	if (driver (_this select 0) == player) then {
		// but player getin not me
		if ( _this select 2 != player ) then {
			_passageer = _this select 2;
			_idx = count PFP_getins;

			for "_i" from 0 to count PFP_getins step 1 do {
				if ( (PFP_getins select _i) select 0 == _passageer ) exitWith {
					_idx = _i;
				};
			};

			PFP_getins set[ _idx, [ _passageer, position _passageer ] ];
		};
	};
};

//Passed array: [vehicle, position, unit]
PFP_heliOnGetOut = {
	private ["_destObj", "_srcObj", "_idx", "_from", "_points"];
	// this player is on drive place
	if (driver (_this select 0) == player && alive player) then {
		if (_this select 2 != player && alive (_this select 2) ) then {
			_passageer = _this select 2;
			_isIn = { (_x select 0) == _passageer } count PFP_getins;
			if !(isIn) exitWith {};
			
			_idx = [];

			{
				if ( (_x select 0 ) == _passageer ) exitWith {
					_idx = _x;
				};
			} forEach PFP_getins;

			if ( count _idx == 0 ) exitWith {};

			//format ["PFP_heliOnGetOut: _idx= %1, PFP_getins=%2", _idx, PFP_getins] call BIS_fnc_log;
			//PFP_getins = PFP_getins - _idx;
			//format ["PFP_heliOnGetOut: _idx= %1, PFP_getins=%2", _idx, PFP_getins] call BIS_fnc_log;
			
			_from = _idx select 1;

			// drop too close to load
			if ( _from distance (position player) <= 100 ) exitWith {};

			_srcObj = _from call PFP_getClosestObjective;
			_destObj = (position player) call PFP_getClosestObjective;

			_penalty = [_from, position player, _srcObj, _destObj ] call PFP_getPenalty;

			/// 1 point for PFP_max_distance / 2.
			_points = (_srcObj distance _destObj) * _penalty * 2 / PFP_max_distance;

			//hint format["src->dst: %1, _penalty:%2, max: %3. points: %4", 
			//	(_srcObj distance _destObj), _penalty, PFP_max_distance,  _points];
			_idx set[ 1, position _passageer ]; //save dest
			_idx set[ count _idx, _points ]; // [ _passageer, position _passageer, _points ]
			//PFP_getins set[ count PFP_getins, _idx ];
			//format ["PFP_heliOnGetOut: PFP_getins= %1", PFP_getins ] call BIS_fnc_log;
		};
	};
};


//Passed array: [plane, airportID]
PFP_heliOnLandedTouchDown = {

	if (driver (_this select 0) == player && alive player) then {
		_points = call PFP_countPoints;
		//format ["PFP_heliOnLandedTouchDown: points= %1, getins= %2", _points, PFP_getins] call BIS_fnc_log;

		if ( (_points select 0) > 0 ) then {
			addToScore = [player, (_points select 0)]; publicVariable "addToScore";
			["ScoreBonus", [format ["Transported group of %1 soldiers.", _points select 1], _points select 0]] call bis_fnc_showNotification;
		};
	};
};

_this spawn {
	private ["_unit"];
	_unit = _this;
	waitUntil {sleep 0.5; alive player && alive _unit};

	_unit addEventHandler[ "GetIn", PFP_heliOnGetIn ];
	_unit addEventHandler[ "GetOut", PFP_heliOnGetOut ];
	//_unit addEventHandler[ "LandedTouchDown", PFP_heliOnLandedTouchDown ];
	player addEventHandler[ "Respawn", { PFP_getins = []; } ];

	while {true} do {
		sleep 10;
		if ( vehicle player != player ) then {
			[(vehicle player),0] call PFP_heliOnLandedTouchDown;
		};
	};
};

(https://a3rc.googlecode.com/hg/scripts/a3rc_PilotsPoints.sqf)

 

Hope this will be included to AW I&A.

 

Link to comment
Share on other sites

well we tested this out just a couple minutes ago with about 7 people and it didn't seem to work. could you explain basically what you have going on or how exactly the pilot recieves the points? If i am reading it correctly, they get the points once they return to the point that they pick them up, after of course they drop people off at one of the objectives.

 

Also initially we got an error on line 22

(_from distance _to) / (_srcObj distance _dstObj)

to to be exact. raz said it was something along the lines of "error zero divisible" or the such.

 

If you want to take another look and see if you maybe missed something or are misplacing a ; we would all love to have this implemented.

Link to comment
Share on other sites

Wait, we are implementing points for the CHAIR FORCE?

If those "two beer queer" flyboys want points they need to hump a rifle and ruck like the rest of us.

What's next "its not gay if its underway", Navy Campaign Ribbon?

 

Suggested prerequisites for awarding points for pilots.

 

1. Be able to adjust Air Conditioning in Bachelor Officers Quarters.

2. Be able to order a Apple/Cranberry Martini @ the Club.

3. Be able to determine what's on HBO tonight.

4. Ability to secure funding from congress for assets with defense contractors political contributions.

5. Will to declare said assets "Strategic" never deploying to an active combat zone, while regularly crashing said assets into the Gulf of Mexico.

6. Ability to hurry to attend an 13:45 Tee Time on the Base Course.

7. Ability to retire to an outstanding position (ie. Vice President of Fiddle Fucking) with the defense contractor whose budget process you previously oversaw.

 

;)

Link to comment
Share on other sites

points counting algorithm:

  1. save when someone gets in your heli where you're pilot
  2. count possible points when soldiers gets out alive near another point rather than source point
  3. when your heli is near different point of point in pt.2 - script gives you counted points.

so. you need transport squad and back alive.

 

Paraclete - for some pilots it's a real challege to drop troops in safe zone and return to base alive.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Forum Statistics

    11k
    Total Topics
    66.2k
    Total Posts
×
×
  • Create New...