Jump to content
Sign in to follow this  
rossco5378

Need help editing a script

Recommended Posts

Hello,

I have asked on the epochforums but no one seems to want to help me. I'm trying to get a merlin to go from cherno > klen > bash > stary and back to cherno again in a loop sort of like a taxi. I want the heli to land for 1 minute and let people in and out before it takes off again to the next way point. This is for an epoch server.

Server file below:

private ["_axeBusUnit","_dir","_axWPZ","_unitpos","_rndLOut","_ailoadout","_axeBus","_axeBusGroup","_axeBuspawnpos","_axeBusWPradius","_axeBusWPIndex","_axeBusFirstWayPoint","_axeBusWP","_axeBusRouteWaypoints","_axeBusDriver","_axeBusLogicGroup","_axeBusLogicCenter"];

// Cords for heli pads
// Cherno [7262.95,2993.65]
// Stary  [6222.05,7808.89]
// Bash   [3999.16,11646]
// Klen   [11509.3,11319.4]	
_axeBusUnit = objNull;
_axeBusGroup = createGroup WEST; // Sets to BlueFor
_axeBuspawnpos = [13683.5,2909.92,0]; // Where the heli spawns
_unitpos = [13700.3,2934.12,0]; // Where the ai for the heli spawns
_axeBusWPradius = 10;//Waypoint radius

_axeBusDriver = objNull;

   //Load Bus Route
_axWPZ=0;
_axeBusWPIndex = 2;
_axeBusFirstWayPoint = [7262.95,2993.65,_axWPZ];
_axeBusWP = _axeBusGroup addWaypoint [_axeBusFirstWayPoint, _axeBusWPradius,_axeBusWPIndex];
_axeBusWP setWaypointType "MOVE";
_axeBusRouteWaypoints = [[11509.3,11319.4,_axWPZ],[3999.16,11646,_axWPZ],[6222.05,7808.89,_axWPZ],[7262.95,2993.65,_axWPZ]];

{
_axeBusWPIndex=_axeBusWPIndex+1;
_axeBusWP = _axeBusGroup addWaypoint [_axeBusFirstWayPoint, _axeBusWPradius,_axeBusWPIndex];
_axeBusWP setWaypointType "getout";
_axeBusWP setWaypointTimeout [20, 30, 35];
diag_log format ["BUS:Waypoint Added: %2 at %1",_axeBusFirstWayPoint,_axeBusWP];
} forEach _axeBusRouteWaypoints;

//Create Loop Waypoint
_axeBusWP = _axeBusGroup addWaypoint [_axeBusFirstWayPoint, _axeBusWPradius,_axeBusWPIndex+1];
_axeBusWP setWaypointType "CYCLE";

//Create Bus
_dir = 244;
_axeBus = "BAF_Merlin_HC3_D" createVehicle _axeBuspawnpos;
_axeBus setDir _dir;
   _axeBus setPos getPos _axeBus;
   _axeBus setVariable ["ObjectID", [_dir,getPos _axeBus] call dayz_objectUID2, true];
   _axeBus setFuel 1;
_axeBus allowDammage false;
//Uncomment for normal dayZ
//dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_axeBus];
//For Epoch - Comment out for normal dayZ | Credit to Flenz
PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_axeBus];
[_axeBus,"BAF_Merlin_HC3_D"] spawn server_updateObject;

//Make Permanent on some builds.. No Need really,
//dayzSaveVehicle = _axeBus;
//publicVariable "dayzSaveVehicle";

_axeBus addEventHandler ["HandleDamage", {false}];	
_axeBus setVariable ["axBusGroup",_axeBusGroup,true];
_axeBus setVariable ["isAxeAIBus",1,true];

//Create Pilot
"BAF_Pilot_MTP" createUnit [_unitpos, _axeBusGroup, "_axeBusUnit=this;",0.5,"Private"];

_axeBusUnit enableAI "TARGET";
_axeBusUnit enableAI "AUTOTARGET";
_axeBusUnit enableAI "MOVE";
_axeBusUnit enableAI "ANIM";
_axeBusUnit enableAI "FSM";
_axeBusUnit allowDammage true;
_axeBusUnit setCombatMode "GREEN";
_axeBusUnit setBehaviour "CARELESS";
//set skills
_axeBusUnit setSkill ["aimingAccuracy",1];
_axeBusUnit setSkill ["aimingShake",1];
_axeBusUnit setSkill ["aimingSpeed",1];
_axeBusUnit setSkill ["endurance",1];
_axeBusUnit setSkill ["spotDistance",0.6];
_axeBusUnit setSkill ["spotTime",1];
_axeBusUnit setSkill ["courage",1];
_axeBusUnit setSkill ["reloadSpeed",1];
_axeBusUnit setSkill ["commanding",1];
_axeBusUnit setSkill ["general",1];
_axeBusUnit assignAsCargo _axeBus;
_axeBusUnit moveInCargo _axeBus;
_axeBusUnit addEventHandler ["HandleDamage", {false}];
//End of create pilot

waitUntil{!isNull _axeBus};
//diag_log format ["AXLOG:BUS: Bus Spawned:%1 | Group:%2",_axeBus,_axeBusGroup];

//Monitor Bus
while {alive _axeBus} do {
//diag_log format ["AXLOG:BUS: Tick:%1",time];
	//Fuel Bus
	if(fuel _axeBus < 0.2)then{
	_axeBus setFuel 1;
	//diag_log format ["AXLOG:BUS: Fuelling Bus:%1 | Group:%2",_axeBus,_axeBusGroup];
	};

	//Keep Bus Alive - Shouldn't be required.
	if(damage _axeBus>0.4)then{
	_axeBus setDamage 0;
	//diag_log format ["AXLOG:BUS: Repairing Bus:%1 | Group:%2",_axeBus,_axeBusGroup];
	};

	//Monitor Driver
	if((driver _axeBus != _axeBusDriver)||(driver _axeBus != _axeBusUnit))then{
	//diag_log format ["AXLOG:BUS: Driver Required:%1",driver _axeBus];
	units _axeBusGroup select 0 assignAsDriver _axeBus;
	units _axeBusGroup select 0 moveInDriver _axeBus;
	};

sleep 3;
};

This script is based off this project "andgregor - dayZ-AI-Bus-Route"

Any help with this whatsoever would be much appreciated!

Share this post


Link to post
Share on other sites

You say it started as a bus script rather than a helicopter script.

1. Switch back to buses. Have the bus go from A to B then to C and end the script there

2. Once that is working, have the bus go from A to B to C to D to E.

3. Once that is working switch back to a helicopter. Like 1 above, have the helicopter from A to B to C

4. Once that is working like 2 above have the helicopter go from A to B to C to D to E.

Then you can work out exactly where the problem is.

Share this post


Link to post
Share on other sites
You say it started as a bus script rather than a helicopter script.

1. Switch back to buses. Have the bus go from A to B then to C and end the script there

2. Once that is working, have the bus go from A to B to C to D to E.

3. Once that is working switch back to a helicopter. Like 1 above, have the helicopter from A to B to C

4. Once that is working like 2 above have the helicopter go from A to B to C to D to E.

Then you can work out exactly where the problem is.

Thanks for the reply. The helis go to the way points fine when the setwaypointType is MOVE but then they don't land. This is the issue. I want them to land, Stay on the ground for 1 minute so players can get in/out and then continue to the next waypoint. I know this is possible because i played on a server a year ago using this exact script. But obviously it was edited.

Share this post


Link to post
Share on other sites

You will need to use the WaypointStatements

wpname  setWaypointStatements ["true", "vehicle this land 'land'"];

that will have it land but then you need to keep it on the ground.

You need to create another waypoint right next to the landing waypoint move type will do and add these lines.

wpname setWaypointStatements ["!isengineon vehicle this", ""];
wpname setWaypointTimeout [60, 60, 60];

when the engine is turned off the timer will start, although if you know who is getting in the chopper you could count the units and only have it take off when they are all on board.

Share this post


Link to post
Share on other sites
You will need to use the WaypointStatements

wpname  setWaypointStatements ["true", "vehicle this land 'land'"];

that will have it land but then you need to keep it on the ground.

You need to create another waypoint right next to the landing waypoint move type will do and add these lines.

wpname setWaypointStatements ["!isengineon vehicle this", ""];
wpname setWaypointTimeout [60, 60, 60];

when the engine is turned off the timer will start, although if you know who is getting in the chopper you could count the units and only have it take off when they are all on board.

Ok this works fine however now the heli will not start and move to the next defined location

//Load Bus Route
_axWPZ=0;
_axeBusWPIndex = 2;
_axeBusFirstWayPoint = [7262.95,2993.65,_axWPZ];
_axeBusWP = _axeBusGroup addWaypoint [_axeBusFirstWayPoint, _axeBusWPradius,_axeBusWPIndex];
_axeBusWP setWaypointStatements ["true", "_axeBus this land 'HeliH'"];
_axeBusRouteWaypoints = [[11509.3,11319.4,_axWPZ],[3999.16,11646,_axWPZ],[6222.05,7808.89,_axWPZ]];

{
_axeBusWPIndex=_axeBusWPIndex+1;
_axeBusWP = _axeBusGroup addWaypoint [_axeBusFirstWayPoint, _axeBusWPradius,_axeBusWPIndex];
_axeBusWP setWaypointStatements ["!isengineon _axeBus this", ""];
_axeBusWP setWaypointTimeout [60, 60, 60];
diag_log format ["BUS:Waypoint Added: %2 at %1",_axeBusFirstWayPoint,_axeBusWP];
} forEach _axeBusRouteWaypoints;

//Create Loop Waypoint
_axeBusWP = _axeBusGroup addWaypoint [_axeBusFirstWayPoint, _axeBusWPradius,_axeBusWPIndex+1];
_axeBusWP setWaypointType "CYCLE";

Any ideas?

Edited by rossco5378
code mistake

Share this post


Link to post
Share on other sites

you can't use _axeBus in a wp statement as it's local to the script, did you try it exactly as I wrote it _axeBusWP setWaypointStatements ["!isengineon vehicle this", ""];

Share this post


Link to post
Share on other sites
you can't use _axeBus in a wp statement as it's local to the script, did you try it exactly as I wrote it _axeBusWP setWaypointStatements ["!isengineon vehicle this", ""];

Yes, Same issue, It wouldn't take off to the next waypoint.

---------- Post added at 18:13 ---------- Previous post was at 18:07 ----------

Here is the code that is running the script:

private ["_axeBusUnit","_dir","_axWPZ","_unitpos","_rndLOut","_ailoadout","_axeBus","_axeBusGroup","_axeBuspawnpos","_axeBusWPradius","_axeBusWPIndex","_axeBusFirstWayPoint","_axeBusWP","_axeBusRouteWaypoints","_axeBusDriver","_axeBusLogicGroup","_axeBusLogicCenter"];

// Cords for heli pads
// Cherno [7262.95,2993.65]
// Stary  [6222.05,7808.89]
// Bash   [3999.16,11646]
// Klen   [11509.3,11319.4]	
_axeBusUnit = objNull;
_axeBusGroup = createGroup WEST; // Sets to BlueFor
_axeBuspawnpos = [13683.5,2909.92,0]; // Where the heli spawns
_unitpos = [13700.3,2934.12,0]; // Where the ai for the heli spawns
_axeBusWPradius = 2;//Waypoint radius

_axeBusDriver = objNull;

   //Load Bus Route
_axWPZ=0;
_axeBusWPIndex = 2;
_axeBusFirstWayPoint = [7262.95,2993.65,_axWPZ];
_axeBusWP = _axeBusGroup addWaypoint [_axeBusFirstWayPoint, _axeBusWPradius,_axeBusWPIndex];
_axeBusWP setWaypointStatements ["true", "vehicle this land 'HeliH'"];
_axeBusRouteWaypoints = [[11509.3,11319.4,_axWPZ],[3999.16,11646,_axWPZ],[6222.05,7808.89,_axWPZ]];

{
_axeBusWPIndex=_axeBusWPIndex+1;
_axeBusWP = _axeBusGroup addWaypoint [_axeBusFirstWayPoint, _axeBusWPradius,_axeBusWPIndex];
_axeBusWP setWaypointStatements ["!isengineon vehicle this", ""];
_axeBusWP setWaypointTimeout [60, 60, 60];
diag_log format ["BUS:Waypoint Added: %2 at %1",_axeBusFirstWayPoint,_axeBusWP];
} forEach _axeBusRouteWaypoints;

//Create Loop Waypoint
_axeBusWP = _axeBusGroup addWaypoint [_axeBusFirstWayPoint, _axeBusWPradius,_axeBusWPIndex+1];
_axeBusWP setWaypointType "CYCLE";

//Create Bus
_dir = 244;
_axeBus = "BAF_Merlin_HC3_D" createVehicle _axeBuspawnpos;
_axeBus setDir _dir;
   _axeBus setPos getPos _axeBus;
   _axeBus setVariable ["ObjectID", [_dir,getPos _axeBus] call dayz_objectUID2, true];
   _axeBus setFuel 1;
_axeBus allowDammage false;
//Uncomment for normal dayZ
//dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_axeBus];
//For Epoch - Comment out for normal dayZ | Credit to Flenz
PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_axeBus];
[_axeBus,"BAF_Merlin_HC3_D"] spawn server_updateObject;

//Make Permanent on some builds.. No Need really,
//dayzSaveVehicle = _axeBus;
//publicVariable "dayzSaveVehicle";

_axeBus addEventHandler ["HandleDamage", {false}];	
_axeBus setVariable ["axBusGroup",_axeBusGroup,true];
_axeBus setVariable ["isAxeAIBus",1,true];

//Create Pilot
"BAF_Pilot_MTP" createUnit [_unitpos, _axeBusGroup, "_axeBusUnit=this;",0.5,"Private"];

_axeBusUnit enableAI "TARGET";
_axeBusUnit enableAI "AUTOTARGET";
_axeBusUnit enableAI "MOVE";
_axeBusUnit enableAI "ANIM";
_axeBusUnit enableAI "FSM";
_axeBusUnit allowDammage true;
_axeBusUnit setCombatMode "GREEN";
_axeBusUnit setBehaviour "CARELESS";
//set skills
_axeBusUnit setSkill ["aimingAccuracy",1];
_axeBusUnit setSkill ["aimingShake",1];
_axeBusUnit setSkill ["aimingSpeed",1];
_axeBusUnit setSkill ["endurance",1];
_axeBusUnit setSkill ["spotDistance",0.6];
_axeBusUnit setSkill ["spotTime",1];
_axeBusUnit setSkill ["courage",1];
_axeBusUnit setSkill ["reloadSpeed",1];
_axeBusUnit setSkill ["commanding",1];
_axeBusUnit setSkill ["general",1];
_axeBusUnit assignAsCargo _axeBus;
_axeBusUnit moveInCargo _axeBus;
_axeBusUnit addEventHandler ["HandleDamage", {false}];
//End of create pilot

waitUntil{!isNull _axeBus};
//diag_log format ["AXLOG:BUS: Bus Spawned:%1 | Group:%2",_axeBus,_axeBusGroup];

//Monitor Bus
while {alive _axeBus} do {
//diag_log format ["AXLOG:BUS: Tick:%1",time];
	//Fuel Bus
	if(fuel _axeBus < 0.2)then{
	_axeBus setFuel 1;
	//diag_log format ["AXLOG:BUS: Fuelling Bus:%1 | Group:%2",_axeBus,_axeBusGroup];
	};

	//Keep Bus Alive - Shouldn't be required.
	if(damage _axeBus>0.4)then{
	_axeBus setDamage 0;
	//diag_log format ["AXLOG:BUS: Repairing Bus:%1 | Group:%2",_axeBus,_axeBusGroup];
	};

	//Monitor Driver
	if((driver _axeBus != _axeBusDriver)||(driver _axeBus != _axeBusUnit))then{
	//diag_log format ["AXLOG:BUS: Driver Required:%1",driver _axeBus];
	units _axeBusGroup select 0 assignAsDriver _axeBus;
	units _axeBusGroup select 0 moveInDriver _axeBus;
	};

sleep 3;
};

Share this post


Link to post
Share on other sites

I suspect it's in the way your using the waypoints, maybe the indexing.

I just made a test mission using editor placed heli and markers for waypoint locations and it works fine. It lands, holds for 60 seconds then takes off.

      _axeBusGroup = _this select 0;

      _axeBusWP0 = _axeBusGroup addWaypoint [getmarkerpos "mk0", 10];
      _axeBusWP0	setWaypointType "move";

       _axeBusWP1 = _axeBusGroup addWaypoint [getmarkerpos "mk1", 10];
_axeBusWP1 setWaypointType "move";
_axeBusWP1 setWaypointStatements ["true", "vehicle this land 'HeliH'"];

_axeBusWP2 = _axeBusGroup addWaypoint [getmarkerpos "mk2", 10];
_axeBusWP2 setWaypointType "move";
_axeBusWP2 setWaypointStatements ["!isengineon vehicle this;", ""];
_axeBusWP2 setWaypointTimeout [60, 60, 60];	

      _axeBusWP3 = _axeBusGroup addWaypoint [getmarkerpos "mk3", 10];
      _axeBusWP3 setWaypointType "move";

      _axeBusWP3 = _axeBusGroup addWaypoint [getmarkerpos "mk4", 10];
      _axeBusWP3 setWaypointType "cycle";

Share this post


Link to post
Share on other sites
I suspect it's in the way your using the waypoints, maybe the indexing.

I just made a test mission using editor placed heli and markers for waypoint locations and it works fine. It lands, holds for 60 seconds then takes off.

      _axeBusGroup = _this select 0;

      _axeBusWP0 = _axeBusGroup addWaypoint [getmarkerpos "mk0", 10];
      _axeBusWP0	setWaypointType "move";

       _axeBusWP1 = _axeBusGroup addWaypoint [getmarkerpos "mk1", 10];
_axeBusWP1 setWaypointType "move";
_axeBusWP1 setWaypointStatements ["true", "vehicle this land 'HeliH'"];

_axeBusWP2 = _axeBusGroup addWaypoint [getmarkerpos "mk2", 10];
_axeBusWP2 setWaypointType "move";
_axeBusWP2 setWaypointStatements ["!isengineon vehicle this;", ""];
_axeBusWP2 setWaypointTimeout [60, 60, 60];	

      _axeBusWP3 = _axeBusGroup addWaypoint [getmarkerpos "mk3", 10];
      _axeBusWP3 setWaypointType "move";

      _axeBusWP3 = _axeBusGroup addWaypoint [getmarkerpos "mk4", 10];
      _axeBusWP3 setWaypointType "cycle";

Okay i get where you're coming from but how do i implement this into the script. Could you put this into my code in the post above?

Share this post


Link to post
Share on other sites

It's a bit beyond my understanding I can't get my head around the indexing that's being used.

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  

×