dayZ (arma) AI Controlled Bus Route.

wut wut wut?
the file above worked (hence Proof of Concept), all it required was separating the two parts to serverside and clientside. So we take the busroute.sqf for serverside and add a script that constantly updates the bus location and a clientside that constantly updates the marker. So we need two very simple, short and easy bits of code.

add this to the bottom of your busroute.sqf, any busroute should work ... actually any item at all you want to track could use this
Code:
while {true} do{
    thebuslocation = getpos thebus;
    publicvariable "thebuslocation";
    sleep 3;
    };

move the marker script to its own file busmarker.sqf and exec it from the init.sqf
Code:
if (isserver) exitwith{};
_markerpos = createmarker["busmarker",theBuslocation];
_markerpos setMarkerType "mil_dot";
_markerpos setMarkerColor "ColorRed";

while {true} do {
    "busmarker" setMarkerPosLocal theBuslocation;
    sleep 3;
    };

Untested but should work. Next features would be to give different orders at certain waypoints. Like have them pull up at the fuel pump, get out and stand by the pump as if they are pumping. Or run into the general store and buy cigarettes ...
 
Last edited:
wut wut wut?
the file above worked (hence Proof of Concept), all it required was separating the two parts to serverside and clientside. So we take the busroute.sqf for serverside and add a script that constantly updates the bus location and a clientside that constantly updates the marker.
added this to the bottom of the busroute.sqf
Code:
while {true} do{
    thebuslocation = getpos thebus;
    publicvariable "thebuslocation";
    sleep 3;
    };
move the marker script to its own file busmarker.sqf and exec it from the init.sqf
Code:
if (isserver) exitwith{};
_markerpos = createmarker["buslocation",theBuslocation];
_markerpos setMarkerType "mil_dot";
_markerpos setMarkerColor "ColorRed";

while {true} do {
    "buslocation" setMarkerPosLocal theBuslocation;
    sleep 3;
    };


Here is the entire busroute.sqf file I had, but you can just tack top bit of code to the bottom of any busroute you have.
Code:
_this = createCenter civilian;
_center_2 = _this;
_grpBlue = createGroup _center_2;

//driver
if (true) then
{
  _this = _grpBlue createUnit ["Policeman", [1616.7765, 2233.0764, 1.4383841e-007], [], 0, "CAN_COLLIDE"];
  _unit_2 = _this;
  _this setUnitAbility 0.60000002;
  _grpBlue selectLeader _this;
       _this setVariable ["Sarge",1,true];
    _this allowDammage false;
     _this addEventHandler ["HandleDamage", {false}];

     };



if (true) then
{
  _this = createVehicle ["Ikarus", [1599.1127, 2242.4331, -2.3079338e-008], [], 0, "CAN_COLLIDE"];
  theBus = _this;
  _this setDir -71.269524;
  _this setPos [1599.1127, 2242.4331, -2.3079338e-008];

};

_this = _grpBlue addWaypoint [[1594.5338, 2244.3137, 2.1127926e-007], 0];
_this setWaypointType "GETIN NEAREST";
_this setWaypointCombatMode "RED";
_this setWaypointSpeed "FULL";
_this setWaypointBehaviour "CARELESS";
_waypoint_0 = _this;

_this = _grpBlue addWaypoint [[732.96844, 1893.0231, -1.8595892e-007], 0];
_waypoint_1 = _this;

_this = _grpBlue addWaypoint [[678.28821, 1865.5563, 2.2065069e-007], 0];
_this setWaypointBehaviour "COMBAT";
_waypoint_2 = _this;

_this = _grpBlue addWaypoint [[650.99005, 1850.6868, 1.8210267e-007], 0];
_waypoint_3 = _this;

_this = _grpBlue addWaypoint [[690.61407, 1848.1786, 4.1011663e-007], 0];
_waypoint_4 = _this;

_this = _grpBlue addWaypoint [[790.48114, 1920.0989, 1.1124575e-007], 0];
_this setWaypointBehaviour "CARELESS";
_waypoint_5 = _this;

_this = _grpBlue addWaypoint [[1830.3545, 2214.7742, 1.029548e-007], 0];
_this setWaypointBehaviour "CARELESS";
_this setWaypointTimeout [10, 10, 10];
_waypoint_6 = _this;

_this = _grpBlue addWaypoint [[4517.0571, 2445.3359, 2.1862797e-007], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_7 = _this;

_this = _grpBlue addWaypoint [[6348.7422, 2429.8325, 7.1187969e-008], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_8 = _this;

_this = _grpBlue addWaypoint [[6566.2964, 2864.8196, 5.2154064e-008], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_9 = _this;

_this = _grpBlue addWaypoint [[9966.5996, 2052.2791, -5.9138983e-008], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_10 = _this;

_this = _grpBlue addWaypoint [[10408.438, 2246.1348, 1.0544318e-007], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_11 = _this;

_this = _grpBlue addWaypoint [[10800.207, 2567.8381, 0.057557106], 0];
_waypoint_12 = _this;

_this = _grpBlue addWaypoint [[12009.484, 3479.1714, 7.6106517e-008], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_13 = _this;

_this = _grpBlue addWaypoint [[13386.558, 5383.3008, 0], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_14 = _this;

_this = _grpBlue addWaypoint [[13461.66, 6236.2959, -1.139706e-007], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_15 = _this;

_this = _grpBlue addWaypoint [[13282.458, 6982.1265, 1.7404091e-007], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_16 = _this;

_this = _grpBlue addWaypoint [[12989.876, 8336.4756, 0], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_17 = _this;

_this = _grpBlue addWaypoint [[13100.437, 10335.808, 0], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_18 = _this;

_this = _grpBlue addWaypoint [[13072.771, 10375.53, 0], 0];
_this setWaypointBehaviour "COMBAT";
_waypoint_19 = _this;

_this = _grpBlue addWaypoint [[12998.04, 10327.238, 0], 0];
_this setWaypointBehaviour "CARELESS";
_waypoint_20 = _this;

_this = _grpBlue addWaypoint [[12832.215, 9958.292, 0], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_21 = _this;

_this = _grpBlue addWaypoint [[12308.234, 9552.7021, -2.1222513e-007], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_22 = _this;

_this = _grpBlue addWaypoint [[12151.067, 9043.1436, -1.3522804e-006], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_23 = _this;

_this = _grpBlue addWaypoint [[12823.489, 8593.7803, -2.8405339e-008], 0];
_waypoint_24 = _this;

_this = _grpBlue addWaypoint [[12916.135, 8521.3438, -2.2631139e-007], 0];
_this setWaypointBehaviour "COMBAT";
_waypoint_25 = _this;

_this = _grpBlue addWaypoint [[13277.846, 6979.3608, -1.8641003e-007], 0];
_this setWaypointBehaviour "CARELESS";
_this setWaypointTimeout [10, 10, 10];
_waypoint_26 = _this;

_this = _grpBlue addWaypoint [[13455.297, 6232.3125, 1.2273085e-007], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_27 = _this;

_this = _grpBlue addWaypoint [[13383.92, 5478.1475, -7.1246177e-008], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_28 = _this;

_this = _grpBlue addWaypoint [[12045.63, 3488.9026, -1.3016688e-007], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_29 = _this;

_this = _grpBlue addWaypoint [[10888.996, 2773.6587, 1.6269041e-007], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_30 = _this;

_this = _grpBlue addWaypoint [[10332.829, 2159.7454], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_31 = _this;

_this = _grpBlue addWaypoint [[6424.7744, 2705.928, 0], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_32 = _this;

_this = _grpBlue addWaypoint [[4570.7388, 2434.6482, -3.9755832e-008], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_33 = _this;

_this = _grpBlue addWaypoint [[3581.5159, 2454.2285, -1.2641249e-007], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_34 = _this;

_this = _grpBlue addWaypoint [[1853.936, 2230.4497, 1.0876101e-007], 0];
_this setWaypointTimeout [10, 10, 10];
_waypoint_35 = _this;

_this = _grpBlue addWaypoint [[1657.6793, 2222.6558, -1.6621925e-007], 0];
_waypoint_36 = _this;

_this = _grpBlue addWaypoint [[1633.3134, 2230.5825, 9.9928002e-008], 0];
_this setWaypointType "CYCLE";
_waypoint_37 = _this;

while {true} do{
    thebuslocation = getpos thebus;
    publicvariable "thebuslocation";
    sleep 3;
    };
soz to post jack I was just posting they way I did it using axemans scripts

I tested your version and it also works :) using axemans original code
 
I can confirm this. Just tested it and it works wonderful.
Many thanks for your patience and nice work!

So, I'm using this way now:
just add this
Code:
        //Create marker for bus
        deleteMarker "BUSMarker";
        _BUSMarker = createmarker ["BUSMarker", position _axeBus];
        _BUSMarker setMarkerText "Bus";
        _BUSMarker setMarkerType "DOT";
        _BUSMarker setMarkerColor "ColorRed";
        _BUSMarker setMarkerBrush "Solid";
        _BUSMarker setMarkerSize [1, 1];
        BUSMarker = _BUSMarker;
into this section in init_bus.sqf
Code:
        //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;
        };
//ADD CODE HERE

    sleep 3;
    };

And yet another idea comes in mind...
It's easy to set markers in the mission.sqm for showing where the bus stops.
Don't worry this is a thing I managed already many times before :)
I wonder if it's possible to draw it's route on the map, like a line to show the way it goes?
 
Back
Top