Jump to content

Adjust drop distance for AN2 mission


Recommended Posts

How can I adjust the drop distance for the AN2 mission? Right now it drops about 200m from the center of the mission.

 

I changed the AN2 to a random helicopter and I tried setting the <= 200 to 50 but it just caused the heli to hover and not drop it's load:

	if ((Alive _plane) AND (Alive _pilot) AND ((_plane distance _wp_pos) <= 200)) then {
		//Drop the package
		
		_dropDir = getDir _plane;
		_newPos = [(getPosATL _plane select 0) - 15*sin(_dropDir), (getPosATL _plane select 1) - 15*cos(_dropDir), (getPosATL _plane select 2) - 10];

Any suggestions?

Link to comment
Share on other sites

Honestly this mission is bugged and Ive removed it. Many times the mission doesn't update the correct position of the loot, especially if the plane gets shot down. And then you can't complete the mission so it just gets stuck.

 

I know that probably doesn't help you but I just thought I'd put my 2 cents in.

Link to comment
Share on other sites

just delete the AI spawn at the top of the script.

then, between the box setup and the wait for the killreq,

add the AI spawns.

 

like this:

 

//box setup
detach _box;
_box setpos [(getpos _box select 0), (getpos _box select 1), 0];
_boxFin = createVehicle ["USVehicleBox",[(getpos _box select 0),(getpos _box select 1), 0],[],0,"CAN_COLLIDE"];
deletevehicle _box;
deletevehicle _chute;
[[(getpos _boxFin select 0), (getpos _boxFin select 1), 0],"AN2 Cargo"] ExecVM DZMSAddMajMarker;
clearWeaponCargoGlobal _boxFin;
clearMagazineCargoGlobal _boxFin;
clearBackpackCargoGlobal _boxFin;
[_boxFin,"supply"] ExecVM DZMSBoxSetup;
[_boxFin] call DZMSProtectObj; 

//new AI coords
_coordsnew = [(getpos _boxFin select 0), (getpos _boxFin select 1), 0]; 

//DZMSAISpawn spawns AI to the mission.
//Usage: [_coords, count, skillLevel, unitArray]
_rndnum = (2 + round (random 3));
[_coordsnew,_rndnum,0,"DZMSUnitsMajor"] call DZMSAISpawn;
sleep 5;
[_coordsnew,3,1,"DZMSUnitsMajor"] call DZMSAISpawn;
sleep 5;
[_coordsnew,3,2,"DZMSUnitsMajor"] call DZMSAISpawn;
sleep 5;
[_coordsnew,2,3,"DZMSUnitsMajor"] call DZMSAISpawn;
sleep 5;

//Wait until the player is within 30 meters and also meets the kill req
[position _boxFin,"DZMSUnitsMajor"] call DZMSWaitMissionComp;

Link to comment
Share on other sites

I got it working in a different way:

 

instead of configuring the an2 drop distance, I made it so, that the AI spawns in when the lootbox is dropped, at the position where the box has landed.

works good. no more free loot boxes for my players.

That is excellent and in my opinion how it should work anyway. What about if the plane gets dropped en route to the mission, does the marker properly update and is the mission then completable?

Link to comment
Share on other sites

Its fairly simple and it doesnt change too much in the missionbody.

everythink else is still the same as in the standardmission: an2 flies in. drops box. marker moves to new location. AI spawns. done.

the standardmissionbody already covers for the case when the an2 gets shot down earlie/ over water.

Link to comment
Share on other sites

Its fairly simple and it doesnt change too much in the missionbody.

everythink else is still the same as in the standardmission: an2 flies in. drops box. marker moves to new location. AI spawns. done.

the standardmissionbody already covers for the case when the an2 gets shot down earlie/ over water.

 

Can you post the code you are using?

+1

Link to comment
Share on other sites

just remove the DZMSVehiclePatrol if you do no have that installed.

 

/*

    AN-2 Bandit Supply Drop by Vampire

    Example Code by Halv

*/



private ["_coordsnew","_rndnum","_missName","_coords","_plane","_aiGrp","_pilot","_wp","_wp_pos","_loop","_half","_newPos","_plane2","_chute","_box","_dropDir","_wp2","_fallCount","_boxFin","_playerpresent"];



//Name of the Mission

_missName = "Hero Mission: AN2 Supply Drop";



//DZMSFindPos loops BIS_fnc_findSafePos until it gets a valid result

_coords = call DZMSFindPos;



[nil,nil,rTitleText,"An AN-2 with supplies is flying in!\nGet to the location and capture the package!", "PLAIN",10] call RE;



//DZMSAddMajMarker is a simple script that adds a marker to the location

[_coords,_missname] ExecVM DZMSAddMajMarker;



//Lets get the AN2 Flying

_plane = createVehicle ["AN2_DZ", [0,0,500], [], 0, "FLY"];

[_plane] call DZMSProtectObj;

_plane engineOn true;

_plane flyInHeight 150;

_plane forceSpeed 175;



//Empty the plane

clearMagazineCargoGlobal _plane;

clearWeaponCargoGlobal _plane;



//Lets make AI for the plane and get them in it

_aiGrp = creategroup east;



_pilot = _aiGrp createUnit ["SurvivorW2_DZ",getPos _plane,[],0,"FORM"];

_pilot moveindriver _plane;

_pilot assignAsDriver _plane;



_wp = _aiGrp addWaypoint [[(_coords select 0), (_coords select 1),150], 0];

_wp setWaypointType "MOVE";

_wp setWaypointBehaviour "CARELESS";

_wp_pos = waypointPosition [_aiGrp,1];



_pilot addWeapon 'NVGoggles';

_pilot addWeapon 'ItemCompass';

_pilot addWeapon 'ItemRadio';

_pilot addWeapon 'ItemMap';

_pilot addWeapon 'ItemGPS';

sleep 5;



_loop = true;

_half = false;

while {_loop} do {

    if (!Alive _plane OR !Alive _pilot) then {

        sleep 5;

        

        // We are going to pretend the plane was shot down nearby

        deleteVehicle _plane;

        deleteVehicle _pilot;



        _newPos = [(_coords select 0) + (random(2000)),(_coords select 1) - (random(2000)),0];

        

        if (surfaceIsWater _newPos) then {

            //newPos is water, so lets just drop it on mark

            //This is a temporary fix for needed logic

            _newPos = _coords;

        };

        

        //Create the plane and kill it

        _plane2 = createVehicle ["AN2_DZ", [(_newPos select 0),(_newPos select 1),200], [], 0, "FLY"];

        [_plane2] call DZMSProtectObj;

        _plane2 engineOn true;

        _plane2 flyInHeight 150;

        _plane2 forceSpeed 175;

        sleep 2;

        _plane2 setDamage 1;

        

        //Update the location

        [_coords,"AN2 Wreck"] ExecVM DZMSAddMajMarker;

        [nil,nil,rTitleText,"The AN2 was shot down by UN Peacekeepers!\nGo Find the Supplies!", "PLAIN",10] call RE;

        

        _chute = createVehicle ["ParachuteMediumEast", [(_newPos select 0),(_newPos select 1),200], [], 0, "FLY"];

        [_chute] call DZMSProtectObj;

        _box = createVehicle ["USVehicleBox", [(_newPos select 0),(_newPos select 1),200],[], 0, "CAN_COLLIDE"];

        [_box] call DZMSProtectObj;

        _box attachTo [_chute, [0, 0, 1]];

        

        _loop = false;

    };

    

    if ((Alive _plane) AND (Alive _pilot) AND ((_plane distance _wp_pos) <= 1200) AND (!(_half))) then {

        [nil,nil,rTitleText,"The AN2 is only 1200m out from the drop point!", "PLAIN",10] call RE;

        

        //Keep on truckin'

        _plane forceSpeed 175;

        _plane flyInHeight 135;

        _plane setspeedmode "LIMITED";

        _half = true;

    };

    

    if ((Alive _plane) AND (Alive _pilot) AND ((_plane distance _wp_pos) <= 200)) then {

        //Drop the package

        

        _dropDir = getDir _plane;

        _newPos = [(getPosATL _plane select 0) - 15*sin(_dropDir), (getPosATL _plane select 1) - 15*cos(_dropDir), (getPosATL _plane select 2) - 10];



        [nil,nil,rTitleText,"The AN2 has reached the location and dropped off the cargo!", "PLAIN",10] call RE;

        

        _chute = createVehicle ["ParachuteMediumEast", _newPos, [], 0, "FLY"];

        [_chute] call DZMSProtectObj;

        _box = createVehicle ["USVehicleBox", _newPos,[], 0, "CAN_COLLIDE"];

        [_box] call DZMSProtectObj;

        _box attachTo [_chute, [0, 0, 1]];

        

        deleteWaypoint [_aiGrp, 1];

        _wp2 = _aiGrp addWaypoint [[0,0,150], 0];

        _wp2 setWaypointType "MOVE";

        _wp2 setWaypointBehaviour "CARELESS";

        _plane forceSpeed 350;

        _plane setSpeedmode "FULL";

        

        _loop = false;

    };

};



//The box was dropped, lets get it on the ground.

_fallCount = 0;

while {_fallCount < 45} do {

    if (((getPos _box) select 2) < 1) then {_fallCount = 46};

    sleep 0.1;

    _fallCount = _fallCount + 0.1;

};



detach _box;

_box setpos [(getpos _box select 0), (getpos _box select 1), 0];

_boxFin = createVehicle ["USVehicleBox",[(getpos _box select 0),(getpos _box select 1), 0],[],0,"CAN_COLLIDE"];

deletevehicle _box;

deletevehicle _chute;

[[(getpos _boxFin select 0), (getpos _boxFin select 1), 0],"AN2 Cargo"] ExecVM DZMSAddMajMarker;

clearWeaponCargoGlobal _boxFin;

clearMagazineCargoGlobal _boxFin;

clearBackpackCargoGlobal _boxFin;

[_boxFin,"supply"] ExecVM DZMSBoxSetup;

[_boxFin] call DZMSProtectObj;



_coordsnew = [(getpos _boxFin select 0), (getpos _boxFin select 1), 0];



//Spawn patrol

_patrol = ["patrol"] call DZMSGetVeh;

[_coordsnew,   //Position to patrol

_coordsnew, // Position to spawn

75, //Radius of patrol

10,                     //Number of waypoints to give

_patrol, //Classname of vehicle (make sure it has driver and gunner)

1 //Skill level of units

] call DZMSVehiclePatrol;



//DZMSAISpawn spawns AI to the mission.

//Usage: [_coords, count, skillLevel, unitArray]

_rndnum = (2 + round (random 3));

[_coordsnew,_rndnum,0,"DZMSUnitsMajor"] call DZMSAISpawn;

sleep 5;

[_coordsnew,3,1,"DZMSUnitsMajor"] call DZMSAISpawn;

sleep 5;

[_coordsnew,3,2,"DZMSUnitsMajor"] call DZMSAISpawn;

sleep 5;

[_coordsnew,2,3,"DZMSUnitsMajor"] call DZMSAISpawn;

sleep 5;





//Wait until the player is within 30 meters and also meets the kill req

[position _boxFin,"DZMSUnitsMajor"] call DZMSWaitMissionComp;



//Let everyone know the mission is over

[nil,nil,rTitleText,"The AN2 cargo has been secured by survivors!", "PLAIN",6] call RE;

        

diag_log text format["[DZMS]: Major SM2 AN2 Drop Mission has Ended."];

deleteMarker "DZMSMajMarker";

deleteMarker "DZMSMajDot";



//Let the timer know the mission is over

DZMSMajDone = true;

 

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
  • Advertisement
  • Discord

×
×
  • Create New...