Bus Route

Stealth

Member
Has anyone successfully created a mod where and AI controlled bus runs a set route picking up and dropping of survivors at certain preset stops along the way?, i.e. Balota Airport to NW Airport stopping at Zelengorsk, Potoshka and Vybor.
All trash and wrecks have already been cleaned of the roads.
I would be interested in this script and how it works.
I would also like to know if the bus could be mad stronger or even invinsible to pre existing NPC's.

Thankyou In Advance To Anyone Who Can Help.
 
Axeman made the exact same script but i don't think it's finished yet, few issues with players killing the driver and stealing the bus to work out
 
I have and the latest version is running a bus service along the coast road on my server. Give it a go, have been trying to bribe people on my server to hijack it, willing to swap a permanent vehicle for it :)
 
I have and the latest version is running a bus service along the coast road on my server. Give it a go, have been trying to bribe people on my server to hijack it, willing to swap a permanent vehicle for it :)
Yeh tried to enter your sever, but as I am in Australia my ping is way to high, o_O.
 
Awesome job on this script axeman :) I was trying to do something similar with a train.
I tried to play with it but i am a bit confused.
You have driverKilled.sqf but you are not using it, and from what i can read, it spices up things a bit :)
Why did you disable it ? And if i want to enable it should i just replace
Code:
_driverKilled = busUnit addEventHandler ["killed", {_this+[axBus] execVM "busroute\crewKilled.sqf"}];
with ......busroute\driverkilled.sqf ?

And also in order for the busmate to take the wheel if the driver is dead, i gotta remove the /* */ comments in monitorBus.sqf and also do the above tweak ?

Also i thought i read somewhere that if the player takes the driver seat, after he leaves the bus, the driver (if alive) will take over. So far i cant find that piece of code anywhere. Is this true ? cause its not happening when i run the server.

And a final note, uh...i can only eject when the bus slowly stops at waypoints....How can i make stop just a tiny bit...like 2 secs...cause its quite dangerous the way it is now....It ran me over twice so far..lol

Thanks again.
 
might want to make it so you cant be the driver lol

also it seems it also stops for zombies when they are in front of it and it wont go until you kill the zombie
 
The bus does stop when zombies stand infront, they seem to get 'sucked' under the front of the bus after about 30 seconds. You can jump into the drivers seat but the driver, or drivers mate, should jump back in and drive off if you get out of the drivers seat.

I have tried making the driver invincible, doesn't work for headshots or persistent shooting, not sure if this is related to being in the vehicle. I didn't really want to make the vehicle and AI passengers invulnerable, i prefer the realism, which is why I spawned the troops to come and attack people killing the driver.

With that in mind attaching a waypoint to the player, who killed the driver, wasn't happening, so I created a Search And Destroy waypoint, in the area, and made the spawned AI enemies of players, until the player dies (i think). This also gives the player a chance to escape, though the AI retaliation is pretty ruthless and accurate..

The AI retaliation won't get into the bus (needs adding) and the existing bus occupants may just run off if the bus is incapacitated. haven't yet worked on re-spawning the bus service (upon bus destruction) am relying on server restarts to deal with that.

Generally, I have found that the AI retaliation has kept people from hijacking the bus, though we do have lots of vehicles.. Have learnt a fair bit on eventhandlers and am experimenting with vehicleoninit..

Have been a bit busy with the new website and integrating that into the game server, especially the in-game activation confirmation, be back on the bus and lighting this week :)

Awesome job on this script axeman :) I was trying to do something similar with a train.
I tried to play with it but i am a bit confused.
You have driverKilled.sqf but you are not using it, and from what i can read, it spices up things a bit :)
Why did you disable it ? And if i want to enable it should i just replace
Code:
_driverKilled = busUnit addEventHandler ["killed", {_this+[axBus] execVM "busroute\crewKilled.sqf"}];
with ......busroute\driverkilled.sqf ?

And also in order for the busmate to take the wheel if the driver is dead, i gotta remove the /* */ comments in monitorBus.sqf and also do the above tweak ?

Also i thought i read somewhere that if the player takes the driver seat, after he leaves the bus, the driver (if alive) will take over. So far i cant find that piece of code anywhere. Is this true ? cause its not happening when i run the server.

And a final note, uh...i can only eject when the bus slowly stops at waypoints....How can i make stop just a tiny bit...like 2 secs...cause its quite dangerous the way it is now....It ran me over twice so far..lol

Thanks again.

@Sandbird, did I give you some code to try or this from the mission files ? I am using most of those functions. The 'driver replacement' is run from the bus monitor, it looks for crew and places them back in the drivers seat. I had to make sure they were assigned to the right place (driver or cargo) to get it to work correctly and dispose of dead bodies. Arma really has some weird nuances, quite often the AI will just sit there or bugger off down the road without looking at the bus..?!?
 
@ axeman

hey mate ive been looking into your bus route and ive got a few issues

1. i caint join your server im aussie and my ping is around 350ish so i get kicked before i can get in or even show on your website.

i really wanted to test this out so i coped your pbo from my cache and run it on my home server and heres what ive found

2. when i get on the bus and move to drivers seat then get out or move to the back seat the ai just sits there not getting back into the drivers seat :/

otherwise the ai is working and so is sendsupport when you kill the crew "shitabrick when i got shot lol"
so then i thought about making the bus and crew invincible, i succeed in doing this by commenting out the hitpoints and adding in some eventhandlers after call fnc_vehicleEventHandler; for the bus like so

Code:
  // _hitpoints = axBus call vehicle_getHitpoints;
    _dam = 0;
    axBus setFuel 1;
    axBus call fnc_vehicleEventHandler;
    axBus allowDammage false;
    axbus addEventHandler ["handleDamage", { false }];
    axBus addEventHandler ["Hit","(_this select 0) SetDammage 0"];
    axBus addeventhandler ["hit", {(_this select 0) setdamage 0;}];
    axBus addeventhandler ["dammaged", {(_this select 0) setdamage 0;}];

and for the crew

Code:
        busUnit allowDammage false;
        busUnit addEventHandler ["handleDamage", { false }];

but without a known way to remove default actions from a vehicle "to remove move to driver" this just leaves a invincible bus for people to steal and the ai are not stealing it back yet so i removed the godmode stuff.

and is there any good tuts on placing waypoints , i tryed to make a run up to nwaf in the editor putting my cords in between [10498.9,2320.29,_axWPZ] and [10888.2,2772.58,_axWPZ] ecpecting to turn off at electro on the way back up the coast but the script just fails to run :(
 
I was having the same issues with making stuff indestructible which is why I went down this path, plus i prefer it to feel real.

There should be an eventhandler (set to Engine) on the bus in bus_driver.sqf that calls monitorBus.sqf . This was the best way I could find of triggering the file as init doesn't work on dynamically created vehicles.

monitorBus.sqf should look like this
Code:
private["_survivors","_beepcount","_array","_engOn","_crew","_busGroup","_unitpos","_magazines"];
axBus = _this select 0;
_engOn = _this select 1;
axBusDriver = driver axBus;
_busGroup = group axBusDriver;
_beepcount=0;
//diag_log format ["BUSCREW: Looking for survivors from: %1 | This: %2 | Bus Group: %3",axBus,_this,group axBus];
 
while {alive axBus} do {
 
//Look for near by survivors.
_survivors = (position axBus) nearEntities [["Survivor1_DZ","SurvivorW1_DZ","Survivor2_DZ","SurvivorW2_DZ","Camo1_DZ","Sniper1_DZ"],450];
 
if ((count _survivors) > 0)then{
{
if(_x distance axBus >10 && _beepcount<4)then{
axBusDriver action ["useWeapon",axBus,driver axBus,0];
_magazines = getArray(configFile >> "CfgVehicles" >> "Ikarus_TK_CIV_EP1" >> "magazines");
//axBusDriver action ["engineOff", axBus];
_beepcount=_beepcount+1;
//diag_log format ["AIBUSDRIVER: Beeping Horn at %1 with: %2",_x,_magazines];
sleep 2;
};
}forEach _survivors;
};
 
if(_beepcount>2)then{
_beepcount=0;
};
 
//Check if driver not AI
if(group (driver axBus) != _busGroup)then{
_crew = crew axBus;
 
if(count (group axBus) > 0)then{
//Clean up assignments
{
_x assignAsCargo axBus;
}forEach _crew;
 
//diag_log format ["BUSCREW: Driver Replacement Required in %1 | Crew found: %2",axBus,_crew];
 
//Try and fill with crew
       //Old method of doing it !
/*
(_crew select 0) assignAsDriver axBus;
sleep 2;
(_crew select 0) moveInDriver axBus;
//_driverKilled = (_crew select 0) addEventHandler ["killed", {[_this,axBus,"",_crew] execVM "busroute\driverKilled.sqf"}];
diag_log "BUSCREW: Driver Found in Crew - Moving passenger into drivers seat !";
}
else{
diag_log "BUSCREW: Crew Empty !";
*/
 
//Assign nearby AI units to driver and crew
if(count (group axBus) > 0)then{
(group axBus select 0) assignAsDriver axBus;
(group axBus select 0) moveInDriver axBus;
};
if(count (group axBus) > 1)then{
(group axBus select 1) assignAsCargo axBus;
(group axBus select 1) moveInCargo axBus;
};
};
};
 
sleep 2;
};

The commented out stuff is previous work and stuff i may put back in. Essentially that file tries to beep the horn at nearby survivors (which works only when the drivers seat is empty ?). I also want to get the bus to slow stop for a bit when near survivors, i intend to go as far as checking if armed etc. to give the driver a bit of intelligence in who he stops for..

It then checks if the driver is NOT a member of the group and assigns all the AI units to cargo, as they should be in the passenger seats anyway (this is if a survivor gets in the back of the bus and then jumps in the drivers seat).

The final bit looks for AI units in the group and assigns them as the driver and one crew member. I am hoping that this will include the support units (when the driver is killed) as after the finish their task they join the bus group.. (Not fully tested).

Essentially, someone can get in the bus and take over driving but the units will sit and wait patiently, when the driver gets out to do a bit of pillaging (or gets back in a crew seat), the AI unit hops back in and drives away into the sunset.. (Additions here: add a variable to the survivor who stole the bus to mark him as someone not to stop for, maybe even lock the bus to them)

There is a debug diag_log commented out to test if this is running.. This by no means perfect and I am sure I can make the whole process more efficient. I am looking at using setVehicleInit for one. Some more work to be done on this yet..
 
Waypoints: They are created in a line, if you look at the loop creating them
Code:
axBusWP = axBusGroup addWaypoint [_x, axBusWPradius,axBusWPIndex];
they have an index set (axBusWPIndex), this is what decides the order of the waypoints.

My positions are basically a line of waypoints set at bus stops along the coast road and back, you will notice the bus stops at the bus stops on the wrong side of the road, UK left hand driving :oops:

You also need the final CYCLE waypoint set exactly on top of the first MOVE waypoint to get them to loop.

To get them to keep to the roads the AI units need to be set to CARELESS or one of the others: http://community.bistudio.com/wiki/AIBehaviour
 
thanks for the reply mate so the driver replacement works on your server?

there is

Code:
axBus addEventHandler ["engine", {_this execVM "busroute\monitorBus.sqf"}];

called just before the sleep, and monitorBus is the same code as you posted so im not sure ill upload the my pbo im sure im calling it all the same as you

and re waypoints i understand how it works so i started adding new waypoints in i think maybe i didnt add them in right for corners ect and it coulnd not connect the path so it errored " i think i seen you need two waypoints on ether side of corners on the road and i got lazy at some point lol" well i hope so as im going to try again tomorro to add a run to the airfeilds and back in so i might start small and then go big ie deviate down a road a little bit and come back and test and go larger scale with the waypoints.
 
That pbo looks ok. I will double check the driver getting back into the drivers seat, was working on my test server.. You don't need loads of waypointss, I initially created loads thinking they would stop at each bus stop, which they do, but not for long enough, am looking at another way of doing that. The AI follow the roads pretty well when in the right mode.. The bus also drives straight through the junk on the roads, as it is created client side..
 
thanks again

been playing abit more and i can confirm that when the driver is killed and other crew member takes over but when i get in the bus and move to drivers seat and move back it or get out both ai just sit's there , other then that the bus goes very well i have the streamlocation nop'd out so didnt think about the clutter but i have noticed it stops for zombies and cows ect sometimes they just disappear "magic zombie yumbus :0" other times you must get out and shoot the offending road block before the bus will proceed.


on the stop delay how about an insert of "setWaypointTimeout" in the forEach of axBusRouteWaypoints like this maybe ?
Code:
    {
    axBusWPIndex=axBusWPIndex+1;
    axBusWP = axBusGroup addWaypoint [_x, axBusWPradius,axBusWPIndex];
    axBusWP setWaypointType "MOVE";
    axBusWP setWaypointTimeout [3, 5, 10];
    diag_log format ["BUS:Waypoint Added: %2 at %1",_x,axBusWP];
    } forEach axBusRouteWaypoints;

excuse me if im way off track ive only started playing with arma2 code in the last 2 weeks but i'll test this and let you know :)


Edits: Yep that worked had to set it to axBusWP setWaypointTimeout [10, 17, 30]; "min,avg,max in sec's" to really notice it but thats the ticket try it out and let me know what you think xD
 
Can confirm the driver and mate just sitting there. Found my bus last night, out of fuel and them just sitting there..
 
Back
Top