[Mission] _waitUntilSuccessCondition help

[Mission] _waitUntilSuccessCondition help

« posted: Sep 15, 2016, 07:10 PM »
Hello!

I'm trying to learn arma scripting and how to make missions for my Wasteland server, i've made a couple of working missions but im currently having some problems with understanding the syntax for _waitUntilSuccessCondition when creating a mission.

I want the mission to be successful once i transport vehicle to a certain location.

Currently i've tried;
Code: [Select]
_waitUntilSuccessCondition = {((_drugCar distance _drugBox) <5)}; and some other variations but i always get
Code: [Select]
19:13:43 Error in expression <tilExec = nil;
_waitUntilSuccessCondition = {((_drugCar distance _drugBox) <5)};

_fail>
19:13:43   Error position: <_drugCar distance _drugBox) <5)};

_fail>
19:13:43   Error Undefined variable in expression: _drugcar
19:13:43 File mpmissions\__cur_mp.Tanoa\server\missions\sideMissions\mission_drugRace.sqf, line 39
19:13:43 Error in expression <_failed = false;
_complete = true;
};

(_failed || _complete || (!_ignoreAiDeath>
19:13:43   Error position: <_failed || _complete || (!_ignoreAiDeath>
19:13:43   Error Undefined variable in expression: _failed
19:13:43 File mpmissions\__cur_mp.Tanoa\server\missions\missionProcessor.sqf, line 109
.

Other than that my script is running! Could anyone point me in the right direction?

My variable for _drugcar looks like this:
Code: [Select]
_drugCar = createVehicle ["C_Hatchback_01_sport_F", _missionPos, [], 5, "None"];

Re: [Mission] _waitUntilSuccessCondition help

« Reply #1 posted: Sep 16, 2016, 11:32 AM »
I got it working! A bit of error in my syntax..... ::) .
I cant belive i spend this much time because of ()..

Working code:
Code: [Select]
_waitUntilSuccessCondition = {(_drugCar distance _drugBox) < 5};

Re: [Mission] _waitUntilSuccessCondition help

« Reply #2 posted: Sep 16, 2016, 01:15 PM »
Ooh, I spent hours just because of one bloody , 

 ;D

So this mission is working? Sounds interesting ..

Re: [Mission] _waitUntilSuccessCondition help

« Reply #3 posted: Sep 16, 2016, 04:45 PM »
Yeah! It's working, a player will steal a car and deliver to said location and get a reward! I still got a lot of ideas i want to put in, right now im trying and failing but here is my Basic template.

Code: [Select]
if (!isServer) exitwith {};
#include "sideMissionDefines.sqf";

private ["_stealCar","_dropMoney","_dropPos"];

_setupVars =
{
_missionType = "Hijack!";
    _dropMoney = 8000;
};


_setupObjects =
{
    _missionLocation = ["Race_1","Race_2"] call bis_fnc_selectRandom;
    _dropLoc1 = ["dropOff_1","dropOff_2"] call bis_fnc_selectRandom;
_missionPos = markerPos _missionLocation;
_dropPos = markerPos _dropLoc1;
    _stealCar = createVehicle ["C_Hatchback_01_sport_F", _missionPos, [], 5, "None"];
   //   waituntil {player in _stealCar};
   //Somehow use this to get the dropoff marker to show AFTER player got in vehicle.
   //Also need to find a way to make mission fail if _stealCar is destroyed
    _dropMarker = createMarker ["DropOff", _dropPos];
_dropMarker setMarkerType "hd_dot";
_dropMarker setMarkerShape "ICON";
_dropMarker setMarkerSize [1, 1];
_dropMarker setMarkerText "Drop-Off";
_dropMarker setMarkerColor "ColorRed";

    _missionHintText = format ["BLAH blah mission text", sideMissionColor];
};

_ignoreAiDeaths = true;
_waitUntilMarkerPos = nil;
_waitUntilExec = nil;
_waitUntilCondition = {player in _stealCar};
_waitUntilSuccessCondition = {(_stealCar distance _dropPos) <5};


_failedExec =
{
// Mission failed
{ deleteVehicle _x } forEach [_stealCar];
deleteMarker "DropOff";
};


_successExec =
{
    for "_i" from 1 to 10 do
{
_cash = createVehicle ["Land_Money_F", _dropPos, [], 5, "None"];
_cash setPos ([_dropPos, [[2 + random 3,0,0], random 360] call BIS_fnc_rotateVector2D] call BIS_fnc_vectorAdd);
_cash setDir random 360;
_cash setVariable ["cmoney", _dropMoney / 10, true];
_cash setVariable ["owner", "world", true];
};

    { deleteVehicle _x } forEach [_stealCar];
    deleteMarker "DropOff";
   
    _successHintMessage = "You have delivered as promised! Take your rewards";
};

_this call sideMissionProcessor;

Re: [Mission] _waitUntilSuccessCondition help

« Reply #4 posted: Sep 16, 2016, 06:17 PM »
Gonna check it out. *thumbsup

edit: is it correct .. u have to edit the map and add markers, named ["Race_1","Race_2"] and ["dropOff_1","dropOff_2"]?

Do you have to add these markers in setupmissionarray like ..

Code: [Select]
RoadblockMissionMarkers = (allMapMarkers select {["Roadblock_", _x] call fn_startsWith}) apply {[_x, false]};
GasstationMissionMarkers = (allMapMarkers select {["Gasstation_", _x] call fn_startsWith}) apply {[_x, false]};

Re: [Mission] _waitUntilSuccessCondition help

« Reply #5 posted: Sep 18, 2016, 02:43 AM »
Yeah, the easiest way is to add markers, no need to add them to setupmissionsarray unless you want to

Re: [Mission] _waitUntilSuccessCondition help

« Reply #6 posted: Sep 20, 2016, 10:16 PM »
Hm. Doesn't appear ..  ::)
  • Offline JoSchaap
  • Developer
  • Mercenary
  • ******
  • Posts: 481
  • Had a life.. Got a modem.. (~1996)

Re: [Mission] _waitUntilSuccessCondition help

« Reply #7 posted: Sep 20, 2016, 11:07 PM »
Ooh, I spent hours just because of one bloody , 

 ;D


welcome to coding :)

Re: [Mission] _waitUntilSuccessCondition help

« Reply #8 posted: Oct 11, 2016, 02:40 PM »
Code: [Select]
if (!isServer) exitwith {};
#include "sideMissionDefines.sqf";

private ["_stealCar","_dropMoney","_dropPos"];

_setupVars =
{
_missionType = "Hijack!";
    _dropMoney = 8000;
};


_setupObjects =
{
    _missionLocation = ["Race_1","Race_2"] call bis_fnc_selectRandom;
    _dropLoc1 = ["dropOff_1","dropOff_2"] call bis_fnc_selectRandom;
_missionPos = markerPos _missionLocation;
_dropPos = markerPos _dropLoc1;
    _stealCar = createVehicle ["C_Hatchback_01_sport_F", _missionPos, [], 5, "None"];
   //   waituntil {player in _stealCar};
   //Somehow use this to get the dropoff marker to show AFTER player got in vehicle.
   //Also need to find a way to make mission fail if _stealCar is destroyed
    _dropMarker = createMarker ["DropOff", _dropPos];
_dropMarker setMarkerType "hd_dot";
_dropMarker setMarkerShape "ICON";
_dropMarker setMarkerSize [1, 1];
_dropMarker setMarkerText "Drop-Off";
_dropMarker setMarkerColor "ColorRed";

    _missionHintText = format ["BLAH blah mission text", sideMissionColor];
};

_ignoreAiDeaths = true;
_waitUntilMarkerPos = nil;
_waitUntilExec = nil;
_waitUntilCondition = {player in _stealCar};
_waitUntilSuccessCondition = {(_stealCar distance _dropPos) <5};


_failedExec =
{
// Mission failed
{ deleteVehicle _x } forEach [_stealCar];
deleteMarker "DropOff";
};


_successExec =
{
    for "_i" from 1 to 10 do
{
_cash = createVehicle ["Land_Money_F", _dropPos, [], 5, "None"];
_cash setPos ([_dropPos, [[2 + random 3,0,0], random 360] call BIS_fnc_rotateVector2D] call BIS_fnc_vectorAdd);
_cash setDir random 360;
_cash setVariable ["cmoney", _dropMoney / 10, true];
_cash setVariable ["owner", "world", true];
};

    { deleteVehicle _x } forEach [_stealCar];
    deleteMarker "DropOff";
   
    _successHintMessage = "You have delivered as promised! Take your rewards";
};

_this call sideMissionProcessor;

What I did was .. adding this to sidemission folder, edited setupmissionarray and placed markers Race_x and dropOff_ onto the map.

But the mission doesn't appear. Could anyone please point to what's missing? The author didn't answer pm.

EDIT: now it appears, but the moment u get in the vehicle, the mission fails.

WTF?  ???
  • Offline soulkobk
  • Hardened
  • ****
  • Posts: 100
  • soulkobk.blogspot.com.au

Re: [Mission] _waitUntilSuccessCondition help

« Reply #9 posted: Oct 13, 2016, 03:45 AM »
From a quick glance over the script you need to do the following to 'fix' it.

Change the line...

Code: [Select]
_waitUntilCondition = {player in _stealCar};
...to...

Code: [Select]
_waitUntilCondition = nil;
As this is triggering success as soon as you sit in the vehicle.

You only need the line...

Code: [Select]
_waitUntilSuccessCondition = {(_stealCar distance _dropPos) <5};
...which triggers 'success' once the _stealCar is within 5 meters of the _dropPos.

-soul

*EDIT... I ran over the script again and changed some code...

This should work (in theory)...

Code: [Select]
if (!isServer) exitwith {};
#include "sideMissionDefines.sqf";

private ["_stealCar","_dropMoney","_dropPos"];

_setupVars =
{
_missionType = "Hijack!";
    _dropMoney = 8000;
};

_setupObjects =
{
    _missionLocation = ["Race_1","Race_2"] call bis_fnc_selectRandom;
    _dropLoc1 = ["dropOff_1","dropOff_2"] call bis_fnc_selectRandom;

_missionPos = markerPos _missionLocation;
_dropPos = markerPos _dropLoc1;
    _stealCar = createVehicle ["C_Hatchback_01_sport_F", _missionPos, [], 5, "None"];

// added by soulkobk
[_stealCar,_dropPos] spawn { // spawn new thread for activation of _dropPos marker once player is in _stealCar
params ["_stealCar","_dropPos"];
waitUntil {(player in _stealCar) || (!alive _stealCar)}; // this line waits until a unit is in the _stealCar or the _stealCar is dead/destroyed
if (alive _stealCar) then // if _stealCar is still alive then create marker, else do nothing (exit thread).
{
_dropMarker = createMarker ["DropOff", _dropPos]; // create 'drop off' marker on _dropPos
_dropMarker setMarkerType "hd_dot";
_dropMarker setMarkerShape "ICON";
_dropMarker setMarkerSize [1, 1];
_dropMarker setMarkerText "Hijack - Drop Off Vehicle";
_dropMarker setMarkerColor "ColorRed";
};
};
////////////////////

    _missionHintText = format ["Hijack the vehicle and deliver it to it's destination marker.", sideMissionColor];
};

_ignoreAiDeaths = true;
_waitUntilMarkerPos = nil;
_waitUntilExec = nil;
_waitUntilCondition = {!alive _stealCar}; // changed by soulkobk - if vehicle is no longer alive (destroyed) then mission fail
_waitUntilSuccessCondition = {(_stealCar distance _dropPos) <5}; // if vehicle is less than 5 meters from the drop off position then mission successful

_failedExec =
{
{ deleteVehicle _x } forEach [_stealCar];
deleteMarker "DropOff";
};

_successExec =
{
    for "_i" from 1 to 10 do
{
_cash = createVehicle ["Land_Money_F", _dropPos, [], 5, "None"];
_cash setPos ([_dropPos, [[2 + random 3,0,0], random 360] call BIS_fnc_rotateVector2D] call BIS_fnc_vectorAdd);
_cash setDir random 360;
_cash setVariable ["cmoney", _dropMoney / 10, true];
_cash setVariable ["owner", "world", true];
};

    { deleteVehicle _x } forEach [_stealCar];
    deleteMarker "DropOff";
   
    _successHintMessage = "You have delivered as promised! Take your rewards";
};

_this call sideMissionProcessor;

-soul.

Re: [Mission] _waitUntilSuccessCondition help

« Reply #10 posted: Oct 14, 2016, 07:30 AM »
It does.

*thumbsup and a BIG thank you!

Re: [Mission] _waitUntilSuccessCondition help

« Reply #11 posted: Oct 16, 2016, 02:13 PM »
It does NOT.  :(

Tested on local server. Everthing's fine. But when launched "live" .. the destination marker don't appear after u get into the vehicle.

Code: [Select]
// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
// @file Version: 2
// @file Name: mission_Escobar.sqf
// @file Author: Spectryx
// @file Tanoa Edit: GriffinZS, soulkobk
// @file Created: Sep 2016

if (!isServer) exitwith {};
#include "mainMissionDefines.sqf";

private ["_stealCar","_dropMoney","_dropPos"];

_setupVars =
{
_missionType = "Escobar's Legacy";
    _dropMoney = 8000;
};

_setupObjects =
{
    _missionLocation = ["Race_1", "Race_2"] call bis_fnc_selectRandom;
    _dropLoc1 = ["dropOff_1","dropOff_2","dropOff_3","dropOff_4","dropOff_5","dropOff_6","dropOff_7"] call bis_fnc_selectRandom;

_missionPos = markerPos _missionLocation;
_dropPos = markerPos _dropLoc1;
    _stealCar = createVehicle ["C_Plane_Civil_01_F", _missionPos, [], 5, "None"];

// added by soulkobk
[_stealCar,_dropPos] spawn { // spawn new thread for activation of _dropPos marker once player is in _stealCar
params ["_stealCar","_dropPos"];
waitUntil {(player in _stealCar) || (!alive _stealCar)}; // this line waits until a unit is in the _stealCar or the _stealCar is dead/destroyed
if (alive _stealCar) then // if _stealCar is still alive then create marker, else do nothing (exit thread).
{
_dropMarker = createMarker ["DropOff", _dropPos]; // create 'drop off' marker on _dropPos
_dropMarker setMarkerType "hd_end";
_dropMarker setMarkerShape "ICON";
_dropMarker setMarkerSize [0.5, 0.5];
_dropMarker setMarkerText "Destination for Cocaine";
_dropMarker setMarkerColor "ColorRed";
};
};
////////////////////

 
_missionHintText = format ["<br/>600 kg of finest, columbian cocaine are waiting to be transported! <br/>Head to the <t color='%1'>Civil Plane</t>, get in and fly the cargo to the marked location!", mainMissionColor];

};

_ignoreAiDeaths = true;
_waitUntilMarkerPos = nil;
_waitUntilExec = nil;
_waitUntilCondition = {!alive _stealCar}; // changed by soulkobk - if vehicle is no longer alive (destroyed) then mission fail
_waitUntilSuccessCondition = {(_stealCar distance _dropPos) <5}; // if vehicle is less than 5 meters from the drop off position then mission successful

_failedExec =
{
{ deleteVehicle _x } forEach [_stealCar];
deleteMarker "DropOff";
};

_successExec =
{
    for "_i" from 1 to 10 do
{
_cash = createVehicle ["Land_Money_F", _dropPos, [], 5, "None"];
_cash setPos ([_dropPos, [[2 + random 3,0,0], random 360] call BIS_fnc_rotateVector2D] call BIS_fnc_vectorAdd);
_cash setDir random 360;
_cash setVariable ["cmoney", _dropMoney / 10, true];
_cash setVariable ["owner", "world", true];
};

    { deleteVehicle _x } forEach [_stealCar];
    deleteMarker "DropOff";
   
    _successHintMessage = "Well done! The cocaine has been delivered. Pablo would have been proud of you!";
};

_this call mainMissionProcessor;

Soul's outa time. Could anyone else tell, how to fix. Or how to TRY to fix?
  • Offline soulkobk
  • Hardened
  • ****
  • Posts: 100
  • soulkobk.blogspot.com.au

Re: [Mission] _waitUntilSuccessCondition help

« Reply #12 posted: Oct 16, 2016, 02:47 PM »
Yes, busy.

At least try to fix it yourself :/

Also, check your PM (a quick 5 min brainstorm).

-soul.
  • Offline soulkobk
  • Hardened
  • ****
  • Posts: 100
  • soulkobk.blogspot.com.au

Re: [Mission] _waitUntilSuccessCondition help

« Reply #13 posted: Oct 22, 2016, 05:35 AM »
Ok... so according to griffinZS, he was unable to 'fix' this missionEscobar script. Even though I did point him in the right direction (gave him the code needed) to correct it.

I just spent ~10minutes coding/testing in SP and MP environment on the 'fix' I suggested, and everything works as intended within 3DEN (therefore it SHOULD work in a dedicated environment).

The code that works is as follows...

Code: [Select]
// example code by soulkobk 1:43 PM 22/10/2016

_missionVehicles = selectRandom ["C_Offroad_02_unarmed_F"];
_missionLocation = selectRandom ["Race_1"];
    _dropOffLocation = selectRandom ["dropOff_1"];

_missionPos = markerPos _missionLocation;
_dropOffPos = markerPos _dropOffLocation;
    _missionVehicle = createVehicle [_missionVehicles, _missionPos, [], 5, "None"]; // create the vehicle at the mission position
_missionVehicle setDir (markerDir _missionLocation); // you don't really need this line (it sets the direction of the vehicle to the direction of the marker), delete it.

// added by soulkobk
[_missionVehicle,_dropOffPos] spawn { // spawn new thread for activation of _dropOffPos marker once player is in _missionVehicle
params ["_missionVehicle","_dropOffPos"];
waitUntil {(!isNull (driver _missionVehicle)) || (!alive _missionVehicle)}; // this line waits until a unit is in the driver seat of _missionVehicle or the _missionVehicle is dead/destroyed
_vehName = gettext (configFile >> "CfgVehicles" >> (typeOf vehicle _missionVehicle) >> "displayName"); // get vehicle display name eg, 'MB 4WD'
if (alive _missionVehicle) then // if _missionVehicle is still alive then create marker, else do nothing (exit thread).
{
_dropMarker = createMarker ["DropOff", _dropOffPos]; // create 'drop off' marker on _dropOffPos
_dropMarker setMarkerType "hd_end";
_dropMarker setMarkerShape "ICON";
_dropMarker setMarkerSize [0.5, 0.5];
// _dropMarker setMarkerText "DESTINATION FOR COCAIN"];
_dropMarker setMarkerText format ["DESTINATION FOR %1",_vehName]; // you don't really need this line, uncomment the above line, delete this one.
_dropMarker setMarkerColor "ColorRed";
hint format ["THE STEALCAR %1\nHAS A DRIVER %2, CHECK MAP!",_vehName, name (driver _missionVehicle)]; // you don't really need this line, delete it.
} // you don't really need this line, delete it.
else // you don't really need this line, delete it.
{ // you don't really need this line, delete it.
hint format ["THE STEALCAR %1\nWAS DESTROYED!\nMISSION FAILED!",_vehName]; // you don't really need this line, delete it.
};
waitUntil {(!alive _missionVehicle)}; // waits for the vehicle to not exist anymore (destroyed or successful mission)
deleteMarker "DropOff"; // deletes the "DropOff" _dropMarker (see above line)
};

I have commented the code to allow others see what does what. Some of the lines in there are not needed, and hence commented as such (debug code).

Attached is the mission I put together to test with. By all means test it yourself within SP and MP (3DEN), as it functions as required.

I hope with this code, the missionEscobar.sqf mission can be completed (and no, I will not complete it for you), please take this code and learn from it.

When it comes to coding, I tend come across as rather firm when dealing with others, but it seems a lot of people 'want' to create things within the A3WL mission, yet are too lazy to learn how... or just give up as soon as they encounter an issue (I had to learn everything myself also... no one taught me!).

Like I've said before... if someone is still stuck after giving it their BEST attempt at figuring it out... by all means msg me... explain the situations, and I may/can help... but I will NOT code it all for you no matter what.

Anyway... please take this code, test the code, implement the code into the missionEscobar.sqf for use within A3WL and report back (as from my own testing... everything works as intended).

-soul.

Re: [Mission] _waitUntilSuccessCondition help

« Reply #14 posted: Oct 22, 2016, 08:18 AM »
Well, thanks for this. But ..

Quote
I hope with this code, the missionEscobar.sqf mission can be completed (and no, I will not complete it for you), please take this code and learn from it.

First of all it's not for me. Maybe seemingly. But how many missions spreading over many other servers after some time? For example the mission "Hostage Rescue". There, the authors JoSchaap, AgentRev, GriffinZS, RickB & soulkobk are implemented.

Imo, this case here is a reparation of the original code by Spectryx (and yes, I tried to contact him). Because the IDEA is great - but his code shit. So I thought, it could be kinda community project. Remember the message, I sent u on Oct 11. It was an IDEA, to pay for gas. 6 days later, u presented your own purchase fuel.
Imo, development is a cooperation of different people with different qualifications - ideas, codes, improvements, immersive story telling ..

Anyway .. thought wrong.

Quote
When it comes to coding, I tend come across as rather firm when dealing with others, but it seems a lot of people 'want' to create things within the A3WL mission, yet are too lazy to learn how... or just give up as soon as they encounter an issue (I had to learn everything myself also... no one taught me!).

Still telling this?

I'm out here. This wouldn't have been MY mission in ANY way. Should others complete it.