k0br4 0 Posted July 14, 2020 Hi everyone, Hoping you can help me with something that's probably fairly straightforward. I have an MP mission that is triggered via "destroyartillery.sqf" - essentially, this script creates and assigns a task to players, spawns in 3 artillery units and then checks if they are alive, once destroyed, the task succeeds. I want the spawned artillery to fire, only once the players enter the vicinity (the mission is some distance away and its required for ambience), to do that, I've created a second script "Artyfire.sqf", which forces the artillery once the player enters a trigger area. If I put the artyfire script into the destroyartillery script, it does work, but it fires straight away before the trigger is activated. If I put it into it's own script, and have the script run off a trigger, I get an "undefined variable" error. I assume it's because I'm spawning in wit _name and then trying to call it in a different script? Here's how it should work: 1. Player assigns mission 2. Task asigned via destroyartillery.sqf 3. Artillery spawned 4. Wait until checks to see if they are alive, if they are not, task completes. 5. Players approach the units and enter a trigger area 6. Artyfire.sqf runs to force artillery to fire 7. Once artilery is destroyed, the wait until check in the first script, completes the task. I think there is a simple solution to this but I cant find it - If I put the artyfire script into the first one, it fires straight away. I've tried adding a check for "triggerActivated", but that doesnt seem to work either. DestroyArtillery.sqf ArtyFire Any help is appreciated. Thanks, Jay Share this post Link to post Share on other sites
pierremgi 4906 Posted July 14, 2020 Make an artyFire.sqf call it by [_arty1,_arty2,_arty3] execVM "artyFire.sqf"; inside the destroyArtillery.sqf , after creating them of course. In artyFire.sqf just add: params ["_arty1","_arty2","_arty3"]; as first line (so the variables are defined here also) and then waitUntil {sleep 0.5; triggerActivated yourTriggerName }; .... your script Share this post Link to post Share on other sites
Joe98 92 Posted July 14, 2020 As a test, instead of spawing arty, place the arty on the map, run your script and see if the script works then. Share this post Link to post Share on other sites
Larrow 2823 Posted July 15, 2020 There should be no need for the player presence trigger. If you know the players and the distance that is all you need to check in relation to the artillery. Spoiler //Create task [ true, "task3", [ "Destroy Artillery", "Destroy Artillery", "Artillery" ], [ 3996.7, 5144.11, 0 ], "Assigned", 1, true, "destroy" ] call BIS_fnc_taskCreate; setDate [2020, 7, 24, 23, 0]; //Create Artillery _artillery = []; { _arty = createVehicle[ "I_Truck_02_MRL_F", getMarkerPos _x, [], 0, "NONE" ]; createVehicleCrew _arty; _artillery pushBack _arty; }forEach[ "artyspawn1", "artyspawn2", "artyspawn3" ]; //distance players need to be within for artillery to start firing _activationDistance = 1000; //Await players presence waitUntil{ sleep 1; allPlayers findIf{ _p = _x; _artillery findIf{ _p distance _x < _activationDistance } > -1 } > -1 }; _h = [ _artillery ] spawn { params[ "_artillery" ]; //While artillery is still alive while { { alive _x }count _artillery > 0 } do { //Make Artillery fire { for "_i" from 0 to 3 do { if ( alive _x ) then { if ( canFire _x ) then { _x commandArtilleryFire[ [ 2983.13 ,10741.3, 0 ], "12Rnd_230mm_rockets", 3 ]; sleep 10; }else{ //replenish vehicle ammo _x setVehicleAmmoDef 1; }; }; }; }forEach _artillery; }; }; //Await artillery destruction waitUntil{ { alive _x }count _artillery == 0 }; //Complete task [ "task3", "SUCCEEDED", true ] call BIS_fnc_taskSetState; Share this post Link to post Share on other sites
k0br4 0 Posted July 16, 2020 Great stuff thank you @Larrow, I'll definitely be using that as a template going forward. Many Thanks, Jay Share this post Link to post Share on other sites