SEKO72 5 Posted January 6, 2022 Hi there, first : Happy new Year to all of you. I made good progress with my coding skills but ran into a problem I just can't solve on my own. May be some of you had this problem before and know an easy answer. I made a mission in wich a car / heli chase is prevalent. Player is in heli and has to shot the cars engine with a .50 cal. Everything fine. The car stops smoke comes out of the engine and the enemy Troop (6 units) disembark. I also wrote a code for the so they would leaveVehicle only if player is near the vehicle. This also works flawlessly. But the problem is: The disembarked AI wont attack the player. No matter what I try, they just dont or do so with massive delay. It feels just so unrealisitc. I tried deleting the MOVE waypoint and add a "SAD" waypoint on player, tried to force the enemy group to supress player. I just want them to attack the player as soon as they leave the vehicle. May be some code helps to clarify: Start of the heli chase sequence beginHeliChase.sqf Spoiler waitUntil { {alive _x} count allPlayers == {alive _x && _x in GH1} count allPlayers; }; GH1 setBehaviour "CARELESS"; while {speed ruscar1 >2} do {GH1 doMove (ruscar1 modelToWorld [100,20,20]); sleep 0.2}; chaseFinal.sqf Spoiler ruscar1 addEventHandler [ "hitpart", { ruscar1 setfuel 0; doStop ruscar1; deleteWaypoint [killercommando, 1]; smoke="test_EmptyObjectForSmoke" createVehicle position ruscar1; smoke attachTo [ruscar1, [0,2.5,-1]]; execVM "HeliLanding.sqf"; ruscar1 removeEventHandler ["hitpart",_thisEventHandler]; } ]; HeliLanding.sqf Spoiler //landing waitUntil {sleep 1; speed ruscar1 <= 2}; attackPad = createVehicle ["Land_HelipadEmpty_F", (ruscar1 modelToWorld [50,50,0]), [], 5, "NONE"]; sleep 5.0; null = [] spawn { _heli = GH1; _heliGrp = group _heli; _posToLand = getPos attackPad; _wp = _heliGrp addWaypoint [_posToLand, 0]; _wp setWaypointType "MOVE"; _wp setWaypointBehaviour "CARELESS"; _wp setWaypointCombatMode "GREEN"; _wp setWaypointSpeed "FULL"; _wp setWaypointFormation "COLUMN"; _wp setWaypointStatements ["true", "(vehicle this) land 'LAND'"]; }; //Enemy AI get out of car and attack player waitUntil {sleep 1; (player distance ruscar1) <60}; ruscar1 allowCrewInImmobile false; killercommando leaveVehicle ruscar1; //generate Intel and let player pick it up killer4 addEventHandler ["killed", { Intel = createVehicle ["Land_Laptop_F", killer4, [], 1, "NONE"]; Intel addAction ["take laptop", {deleteVehicle Intel; ["takeIntel", "SUCCEEDED"]call BIS_fnc_taskSetState; Test1 =true;}]; } ]; //get in Heli with Intel and back to back to base waitUntil {sleep 1; !alive killer4;}; Intel addEventHandler ["Deleted", { Test2 = true; }]; waitUntil { sleep 1; {alive _x} count allPlayers == {alive _x && _x in GH1} count allPlayers; }; GH1 setFuel 1; _null = [] spawn { _heli = GH1; _heliGrp = group _heli; _posToLand = getPos HPad1; _wp = _heliGrp addWaypoint [_posToLand, 0]; _wp setWaypointType "MOVE"; _wp setWaypointBehaviour "CARELESS"; _wp setWaypointCombatMode "GREEN"; _wp setWaypointSpeed "FULL"; _wp setWaypointFormation "COLUMN"; _wp setWaypointStatements ["true", "(vehicle this) land 'LAND'"]; }; GH1 addEventHandler ["GetOut", { GH1 setFuel 0; }]; //delte dead material sleep 120; _killers= [ruscar1, smoke, killer1, killer2, killer3, killer4, killer5, killer6]; { deleteVehicle _x } forEach _killers; Cheers SEKO Share this post Link to post Share on other sites
JohnKalo 657 Posted January 6, 2022 You can just use the doTarget and doFire commands but one thing that is weird is how does the enemy AI follow their move waypoints while there is a friendly helicopter chasing them? Unless the driver is in careless mode they should just be driving right and left without any logic path. You must have already checked it out but a Combat mode could help for the killercommando group. Best of luck 👍 Share this post Link to post Share on other sites
SEKO72 5 Posted January 6, 2022 Hi JohnKalo, I will try what that out. Quote how does the enemy AI follow their move waypoints while there is a friendly helicopter chasing them? I set the waypointBehaviour to "AWARE" but made them stay inside the vehicle with >> _vehicle allowCrewInImmobile true;<<. I set the speed to normal so the vehicle uses roads and it works like a charm. If I get the whole thing to work as intended, I will post here how I did it and explain what I did in detail. Cheers 1 Share this post Link to post Share on other sites
SEKO72 5 Posted January 9, 2022 So I did it 😁! The fallowing script was -of course- not only written by me. It is a composition of many different .sqf files I found, done by different authors. I changed it for my purpose and added some lines of code here and there. It is very likely by no means perfect but it works. What does it do? - a car/heli chase -car can be stopped by a hit anywhere (smoke will come out the engine) -> the player(s) sit in the heli and shoot the car during the chase sequence -heli will land when car is stopped (create invisible helipad with the heli "LAND") -crew of vehicle will disembark when player is near and attack the player (that was a pain to achieve. Enemies will always look for the Heli due to target priority "AIR") -there is also a eventHandler on the vehicle, so the players can search for a laptop wich will be created after 5 seconds of searching Known issues - the heli has to be disableDamage because otherwise it will sometimes land and explode -the heli does not fly how it should! Even if it is told by the code to fly on the right of the vehicle it does not do so. During the chase you will get opportunities to fire on the car, but it is -unfortunately- not like that for the whole sequence . May be someone here knows how to optimize that 😊. Code You need three .sqf files. Name them what ever seems fitting to you. 1 Quote beginChase.sqf //will start the Chase sequence if all players are in the Heli (GH1). The chased car is named ruscar1 in this example waitUntil { {alive _x} count allPlayers == {alive _x && _x in GH1} count allPlayers; }; GH1 setBehaviour "CARELESS"; Chase=true; while {Chase} do {GH1 doMove (getPosATL ruscar1); [150,-10,10]; sleep 1.0}; //this is somehow not accurate. The heli will fly behind the car in a more ore less straight line. Don't know how to achieve a proper chase with the heli flying to the right/left of the chased car. 2 Quote chaseFinal.sqf //will add an EventHandler to the car (ruscar1). The car will stop and the next script (HeliLanding.sqf) will be executed. ruscar1 addEventHandler [ "hitpart", { ruscar1 setfuel 0; doStop ruscar1; deleteWaypoint [killercommando, 1]; smoke="test_EmptyObjectForSmoke" createVehicle position ruscar1; smoke attachTo [ruscar1, [0,2.5,-1]]; execVM "HeliLanding.sqf"; ruscar1 removeEventHandler ["hitpart",_thisEventHandler]; } ]; 3 Quote //HeliLanding.sqf - landing the Heli if car is stopped. Disembark enemies form car (group "killercommando", consists of killer1 - killer6) and attack hunt/player. You can search the car for a laptop and pick it up. After the player gets back in heli and is on the way back to base the car, smoke and killers will be deleted to optimize performance. //ladning Heli waitUntil {sleep 1; speed ruscar1 == 0}; Chase=false; attackPad = createVehicle ["Land_HelipadEmpty_F", (ruscar1 modelToWorld [50,100,0]), [], 5, "NONE"]; sleep 5.0; _null = [] spawn { _heli = GH1; _heliGrp = group _heli; _posToLand = getPos attackPad; _wp = _heliGrp addWaypoint [_posToLand, 0]; _wp setWaypointType "MOVE"; _wp setWaypointBehaviour "CARELESS"; _wp setWaypointCombatMode "GREEN"; _wp setWaypointSpeed "FULL"; _wp setWaypointFormation "COLUMN"; _wp setWaypointStatements ["true", "(vehicle this) land 'LAND'"]; }; //Enemy AI get out of car and attack player waitUntil {sleep 1; (player distance ruscar1) < 60;}; killercommando leaveVehicle ruscar1; ruscar1 allowCrewInImmobile false; killercommando setBehaviour "AWARE"; killercommando setSpeedMode "FULL"; killercommando setCombatMode "RED"; _wp= killercommando addWaypoint [getPos player, 0]; _wp setWaypointType "SAD"; while {alive ruscar1} do { _killercommando=[killer1, killer2, killer3, killer4, killer5, killer6]; { _x reveal [player, 0]; sleep 1; _x doWatch player; sleep 1; _x doSuppressiveFire player; _x suppressFor 20; sleep 1; } forEach _killercommando; ;sleep 1}; //search Vehicel for Intel, generate Intel, Pick up Intel, Get new Mission ruscar1 addAction ["Search for the Intel", { [5, [], {Intel = createVehicle ["Land_Laptop_F", position ruscar1, [], 0, "NONE"]; Intel addAction ["Take Laptop", {deleteVehicle Intel; ["takeIntel", "SUCCEEDED"]call BIS_fnc_taskSetState; Test1 =true;}]; Intel addEventHandler ["Deleted", {Test2 = true;}]; }, {hint "Failure!"}, "Searching..."] call ace_common_fnc_progressBar; }, nil,1.5,false,true,"",""]; //get in Heli with Intel and back to back to base waitUntil { sleep 1; {alive _x} count allPlayers == {alive _x && _x in GH1} count allPlayers; }; GH1 setFuel 1; _null = [] spawn { _heli = GH1; _heliGrp = group _heli; _posToLand = getPos HPad1; _wp = _heliGrp addWaypoint [_posToLand, 0]; _wp setWaypointType "MOVE"; _wp setWaypointBehaviour "CARELESS"; _wp setWaypointCombatMode "GREEN"; _wp setWaypointSpeed "FULL"; _wp setWaypointFormation "COLUMN"; _wp setWaypointStatements ["true", "(vehicle this) land 'LAND'"]; }; GH1 addEventHandler ["GetOut", { GH1 setFuel 0; }]; //delete dead material sleep 120; _killers= [ruscar1, smoke, killer1, killer2, killer3, killer4, killer5, killer6]; { deleteVehicle _x } forEach _killers; So you got this. What do you need besides? In the init of the car you need this disableAI "MOVE"; this allowCrewInImmobile true; and ofcourse you need to add a Waypoint (MOVE, Careless) to the car. You need Triggers. 1st Trigger should eneblaAI "MOVE" the car 2nd Trigger execVM "beginChase.sqf"; execVM "chaseFinal.sqf"; Thats it. And once again: If somebody has an idea how to optimize, how to get the chasing heli to fly besides the chased car or anything else, please let me know. Cheers. 1 1 Share this post Link to post Share on other sites
johnnyboy 3797 Posted January 10, 2022 Looks like you're having fun and learning a lot. That's great! On 1/9/2022 at 2:38 AM, SEKO72 said: while {Chase} do {GH1 doMove (getPosATL ruscar1); [150,-10,10]; sleep 1.0}; Is this your actual line of code above for the chase? What is " [150,-10,10]; " for? I'm guessing you want that to be a position relative to the moving car. If so you can use modelToWorld for that, like this: while {Chase} do { GH1 doMove (ruscar1 modelToWorld [150,-10,10]); sleep 1.0 }; Good luck man! If you have time, post a little video of your chase. 🙂 Share this post Link to post Share on other sites