Jump to content

HonzaVinCZ

Member
  • Content Count

    77
  • Joined

  • Last visited

  • Medals

Posts posted by HonzaVinCZ


  1. I wonder how can I find a unit (player in my case) in array of vehicles. I spent hell of a time on this one and couldn't find a solution. 
    Example array of my vehicles: 

     _vehicleList = [MGI802,MGI804,MGI809]

    I need to make it return boolean true/false if player is present in any of vehicles above. Vehicles in array can change so I can't hardtype "crew MGI802" and so on. 

    My further use for that is to set player's marker alpha depending if he is in a vehicle or not;
    (I know this one is propably extremely unoptimised but I wanted to try make vehicle and player markers on my own)

    while {true} do 
    {
        // Vehicle Markers
        _vehicleList = [MGI802,MGI804,MGI809,MGI810,MGI814,MGI815,MGI1843,MGI818,MGI823,MGI1504,MGI1507,MGI271,MGI253,MGI1847,MGI386,MGI1612,MGI836,MGI829,MGI1437,MGI835,MGI348,MGI824,MGI365,MGI369];
        {
            _name = getText (configFile >> "CfgVehicles" >> typeOf _x >> "displayName");
            _vehmark = vehicleVarName _x;
    
            if (getMarkerType _vehmark == "") then {
                _vehmark = createMarker [_vehmark, getPos _x];
                _vehmark setMarkerType "mil_arrow2";
                _vehmark setMarkerSize [0.4, 0.5];
                _vehmark setMarkerAlpha 1;
            };
            if (alive _x) then {
                if ((count crew _x) > 0) then {
                    _crewlist = "";
                    {
                        _crewlist = format ["%1%2 | ",_crewlist, (name _x)];
                    } forEach crew _x;
                    _vehmark setMarkerText ([_name, _crewlist] joinString " | ");
                } else {
                    _vehmark setMarkerText _name;
                };
                _vehmark setMarkerColor "colorWEST";
                _vehmark setMarkerDir (getDir _x);
                _vehmark setMarkerPos (getPos _x);
            } else {
                _vehmark setMarkerColor "colorGrey";
                _vehmark setMarkerText ([_name, "(Destroyed)"] joinString " ");
            };
        } forEach _vehicleList;
    
        // Player Markers
        _playermark = name player;
    
        if (getMarkerType _playermark == "") then {
            _playermark = createMarker [_playermark, getPos player];
            _playermark setMarkerType "mil_triangle";
            _playermark setMarkerSize [0.5, 0.8];
            _playermark setMarkerAlpha 1;
        };
        if (alive player) then {
            // HOW TO RETURN PLAYER PRESENCE BOOLEAN FROM _vehiclelist ?
            if (true) then {
                _playermark setMarkerText (name player);
                _playermark setMarkerColor "colorWEST";
                _playermark setMarkerDir (getDir player);
                _playermark setMarkerPos (getPos player);
                _playermark setMarkerAlpha 1;
            } else {
                _playermark setMarkerAlpha 0;
            };
        } else {
            _playermark setMarkerColor "colorGrey";
            _playermark setMarkerText ([name player, "(KIA)"] joinString " ");
        };
        sleep 1;
    };

     

    • Like 1

  2. On 10/16/2020 at 2:59 PM, Larrow said:

    Sorry miss understood your post.

     

    You can hide them...( test from debug console in preview )

    
    h = [] spawn {
    	player allowDamage false;
    	_pos = player getPos[ 10, getDir player ];
    	_bomb = "Bo_GBU12_LGB" createVehicle _pos;
    	waitUntil{ isNull _bomb };
    	_craters = _pos nearObjects [ "#crater", 5 ];
    	{ _x hideObjectGlobal true }forEach _craters;
    };

    ...remember hideObjectGlobal must be done from the server.

    No problem!

    Oh nice, but also I guess from your reply these explosion made craters can't be deleted individually or? 
    Btw sorry for late reply, I was busy during this week.


  3. 46 minutes ago, Larrow said:

    No need for creating missionNamespace(Global) variables for the craters, just pass them into the spawned code.

    
    [ _crater, _crater1, _crater2 ] spawn {
    	{
    		_x hideObjectGlobal false;
    	}forEach _this;
    	
    	sleep 60;
    	
    	{
    		deleteVehicle _x;
    	}forEach _this;
    };

     

    As for the crater mark not removing, it seems fine testing from debug console in Eden preview...

    
    _h = [] spawn {
    	_crater = "Crater" createVehicle ( player getPos[ 5, getDir player ] );
    	sleep 10;
    	deleteVehicle _crater;
    };

    Only thing that remains is the result of the grass cutter initiated by the crater object.

    Oh, that is cool and works perfectly, thank you!
    Btw the crater I create can be deleted but it won't delete the explosion crater mark, described below my thought

     

     

    32 minutes ago, gc8 said:

     

    Then the craters class is something else than "crater". you might get the crater class figured out by leaving the class name out from nearestObjects

    hint shows it's "krater.p3d" which is basically "Crater" but if I want to delete it, it just won't delete. Maybe it needs little delay beacause the crater don't get created that quick as the script runs. I left it without creating my own crater and left there the one which is created by the explosion itself, I'll try to code to remove at least that one.  

    Thank you both for your help, I couldn't continue my code without your help!

    • Like 1

  4. 3 minutes ago, gc8 said:

    Don't know but there's 60 sec delay

    Sure but it doesn't get deleted with the crater model. The crater mark is still on the ground when the crater gets deleted and the mark from the explosion of the IED should not be even there because just after it explodes, there is code below and after that the whole crater thing I want is created.

    {deleteVehicle _x}forEach nearestObjects[getPosATL _iedObj,["Crater"],4];

    Some of the crater markers is still there but idk which one. If that from IED of that I spawned by the code.
     


  5.  

    @gc8 I found one more thing I need to ask you or someone else about... This code creates crater when IED explodes but when there is more than one crater, it always deletes just one instead of each of them after 60s. The idea is each crater gets deleted after given time, not all of them at one time. It has to do something with the variables again and I do something wrong again too. The 0.5 sec sleep is to delay the hideObject true because otherwise the explosion gets blocked by the object and it doesn't damage anything. Then the 60 sec delay is for crater deletion, by default it'll be about 15 mins. I tried to use getVar and setVar but this time I use it propably wrong way. I didn't know what to attach the var when it is in [] spawn {}; 
    I have this code called in trigger, it is not all but I'm quite sure there must be the problem:


    EDIT
    I had typo in [] spawn {}; where I wrote crater instead _crater... Anyway it leaves crater on the ground even when I have this code after bomb gets spawned

    {deleteVehicle _x}forEach nearestObjects[getPosATL _iedObj,["Crater"],4];


     

    _crater = "Crater" createVehicle [0,0,0];
    _crater setDir (random 359);
    _crater enableSimulation false; 
    _crater allowDamage false;
    _crater hideObject true;
    _crater setPos (getPos thisTrigger);
    _crater1 = "Land_ShellCrater_02_small_F" createVehicle [0,0,0];
    _crater1 setDir (random 359);
    _crater1 enableSimulation false; 
    _crater1 allowDamage false;
    _crater1 hideObject true;
    _crater1 setPos (getPos thisTrigger);
    _crater2 = "Land_ShellCrater_02_debris_F" createVehicle [0,0,0];
    _crater2 setDir (random 359);
    _crater2 enableSimulation false; 
    _crater2 allowDamage false;
    _crater2 hideObject true;
    _crater2 setPos (getPos thisTrigger);
    [] spawn {_crater = missionNamespace getVariable 'crater'; _crater1 = missionNamespace getVariable 'crater1'; _crater2 = missionNamespace getVariable 'crater2'; sleep 0.5; _crater hideObject false; _crater1 hideObject false; _crater2 hideObject false; sleep 60; deleteVehicle _crater; deleteVehicle _crater1; deleteVehicle _crater2};
    missionNamespace setVariable ["crater", _crater];
    missionNamespace setVariable ["crater1", _crater1];
    missionNamespace setVariable ["crater2", _crater2];

     


  6. 4 minutes ago, gc8 said:

    try this old function of mine that I dug up from my project:

     

    
    getNearestLocation =
    {
    private ["_pos", "_loc", "_nearLocs"];
    _pos = _this;
    
    _loc = locationNull;
    // ignore these since they dont have name:  ["Hill"]
    _nearLocs = nearestLocations [_pos, ["Airport","NameCityCapital","nameCity","NameVillage","NameLocal"], 90000000];
    if(count _nearLocs > 0) then
    {
    _loc = _nearLocs select 0;
    };
    
    _loc
    };

     

    Usage:

     

    
    _loc = text (_pos call getNearestLocation);

     

    Woah, now this works! Thank you very much for all your help! 

    • Like 2

  7. 1 hour ago, gc8 said:

     

    use global variables. example:

     

    put this at the beginning of the script so that the variable is "defined"

    
    myGlobalVar = 777;

     

    then in tskCrt:

     

    
    hint format["var is %1", myGlobalVar ];

     

     

     

    Task Id is just a string or array with strings (array supposed to have two strings where the last one is parent task ID) so you don't need to import that. Just pass your task ID string to the task functions

     

     


    Sorry, I still have massive problems with variables here. Suffering with it over three hours today already and can't make it work. I do something wrong, I know, but I can't make it working, I just don't know how. I need variable for each weapon cache. Each weapon cache needs its position, task, marker and location name but it doesn't work the way I try all time. I changed the way weapon caches are recognized, I placed them on the map and used this to call the script for them: 

    20201015114511-1.jpg

     

    this is how it looks like on the map... tasks are creating at one same place and it seems like they get accomplished randomly when I destroy any of the caches.

    20201015114029-1.jpg

     

    actual script looks like this:
     

    // Lythium weapon caches script by HonzaVinCZ
    #define __dbug__
    _wCache = _this select 0;
    wCache = _wCache;
    _posATL_1 = _this select 1;
    _posATL_2 = _this select 2;
    _posATL_3 = _this select 3;
    _posATL = selectRandom [_posATL_1, _posATL_2, _posATL_3];
    _wCache setDir (random 359);
    _wCache setPosATL _posATL;
    _pos = getPos _wCache;
    _loc = text nearestLocation [_pos, ""];
    loc = _loc;
    tskCrt ={
    	taskwcache = [west, [format["task_%1",(random 1000)]], [format ['Destroy enemy weapon cache near %1', loc], format ['Destroy Weapon Cache near %1', loc], ''], wCache, 'CREATED', -1, true, 'destroy', true] call BIS_fnc_taskCreate;deleteVehicle thisTrigger};
    _trig = createTrigger ["EmptyDetector", _pos];
    _trig setTriggerArea [10,10,0,FALSE,10];
    _trig setTriggerActivation ["ANYPLAYER","PRESENT",false];
    _trig setTriggerTimeout [0,0,0,false];
    _trig setTriggerStatements[
    	"this",
    	"call tskCrt",
    	""];
    #ifdef __dbug__
    _mkrID=format["wCache_%1",_pos];
    _mkr=createMarker[_mkrID,_pos];
    _mkr setMarkerShape"ICON";_mkr setMarkerType"mil_dot";_mkr setMarkerBrush"Solid";_mkr setMarkerAlpha 1;_mkr setMarkerColor"ColorEast";_mkr setMarkerText format ["wCache %1", _loc];
    #endif
    _wCache enableDynamicSimulation true;
    waitUntil{sleep 1; !alive _wCache};
    	if (true) then {
      		[taskwcache,"SUCCEEDED"] call BIS_fnc_taskSetState;
      		"Bo_GBU12_LGB" createVehicle _pos;
      		deleteVehicle _wCache;
    	} else {
      		"Bo_GBU12_LGB" createVehicle _pos;
      		deleteVehicle _trig;
      		deleteVehicle _wCache;
    	};

     


  8. 1 hour ago, gc8 said:

     

    no need to use publicvariable on this, that's multiplayer stuff

    well the first thing to advice you is not to try get the return value of BIS_fnc_taskCreate because it only returns boolean

    instead define the task ID as the second parameter like you seem to have done already. Then use the ID in:

     

    _exists = ["wcachetask_"] call BIS_fnc_taskExists;

     

    (not 100% sure of the syntax)

     

    so you just refer to the task with the task ID (no need for variables...)

     

    will check this thread again later

    _exists = ["wcachetask_"] call BIS_fnc_taskExists;
    waitUntil {sleep 1; !alive _wCache};
    	if (_exists) then {
      		[["wcachetask_"],"SUCCEEDED"] call BIS_fnc_taskSetState;
      		"Bo_GBU12_LGB" createVehicle getPos _wCache;
      		deleteVehicle _wCache;
    	} else {
      		"Bo_GBU12_LGB" createVehicle getPos _wCache;
      		deleteVehicle _trig;
      		deleteVehicle _wCache;
    	};

    Sadly, it doesn't work. Shows no error but also the mission doesn't get accomplished as it should.

     

    1 hour ago, gc8 said:

    will check this thread again later

    ok, thank you.
    I'll also need some explain how to "import" the variables to that tskCrt, because I really need them there. Same with the task ID. 
     

    • Like 1

  9. 7 minutes ago, gc8 said:

    _taskwcache variable is inside tskCrt so it wont exist in the root scope. And when you call tskCrt the _taskwcache is local variable and doesn't exist anywhere else

    to fix you should use global variables or something

    That is what I thought. Can I ask you if you could show me example of that on my script please? I have really no idea how could I use publicVariable in this. :down:

    • Like 1

  10. Hello guys, I need your help with variables in this script:

    #define __dbug__
    _posATL_1 = _this select 0;
    _posATL_2 = _this select 1;
    _posATL_3 = _this select 2;
    _posATL = selectRandom [_posATL_1, _posATL_2, _posATL_3];
    _wCache = "CUP_BOX_TK_MILITIA_Wps_F" createVehicle [0,0,0];
    _wCache allowDamage false;
    _wCache enableSimulation false;
    _wCache setDir (random 359);
    _wCache setPosATL _posATL;
    _wCache enableSimulation true;
    _wCache enableDynamicSimulation true;
    _wCache allowDamage true;
    _pos = getPos _wCache;
    _loc = text nearestLocation [_pos, ""];
    tskCrt = {
    	_taskwcache = [west, ['wcachetask_'], [format ['Destroy enemy weapon cache near %1 found by our forces', _loc], format ['Destroy Weapon Cache near %1', _loc], ''], _wCache, 'CREATED', -1, true, 'destroy', true] call BIS_fnc_taskCreate;
    	deleteVehicle _trig;
    };
    _trig = createTrigger ["EmptyDetector", _pos];
    _trig setTriggerArea [10,10,0,FALSE,10];
    _trig setTriggerActivation ["ANYPLAYER","PRESENT",false];
    _trig setTriggerTimeout [0,0,0,false];
    _trig setTriggerStatements[
    	"this",
    	"call tskCrt",
    	""];
    
    #ifdef __dbug__
    cacheMkrs=[];
    _mkrID=format["wCache_%1",_loc];
    _mkr=createMarker[_mkrID,_pos];
    _mkr setMarkerShape"ICON";_mkr setMarkerType"mil_dot";_mkr setMarkerBrush"Solid";_mkr setMarkerAlpha 1;_mkr setMarkerColor"ColorEast";_mkr setMarkerText format ["wCache %1", _loc];
    cacheMkrs pushBack _mkr;
    #endif
    
    _exists = [_taskwcache] call BIS_fnc_taskExists;
    waitUntil {sleep 1; !alive _wCache};
    
    	if (_exists) then {
      		[[_taskwcache],"SUCCEEDED"] call BIS_fnc_taskSetState;
      		"Bo_GBU12_LGB" createVehicle getPos _wCache;
    	} else {
      		"Bo_GBU12_LGB" createVehicle getPos _wCache;
      		deleteVehicle _trig;
    	};

    Basically when player enters the trigger, it creates a task but variables I set on the beginning of the script doesn't work in the task creation line - the place in the desc and title shows as "any". Also when I want to check if task exists in the end of the script, it says _taskwcache variable doesn't exist. What do I do wrong please? Thank you.


  11. So I have solved half of the problem. Now I have problem with mission variable. If I place two objects with same init, the script can't make variable for each object when creating mission ID. Any idea how can I make mission ID variable, please?
     

    _ied = _this select 0;
    _iedPos = getPosATL _ied;
    _table = nearestObject [_iedPos, "Land_WoodenTable_small_F"];
    
    _iedTrig1 = createTrigger ["EmptyDetector", _iedPos , true];
    _iedTrig1 setTriggerArea [10, 10, 10, false, 5];
    _iedTrig1 setTriggerActivation ["WEST", "PRESENT", false];
    _iedTrig1 setVariable[ "ied", _ied ];
    _iedTrig1 setVariable[ "iedPos", _iedPos ];
    _iedTrig1 setTriggerStatements [
    	"this && (thisTrigger getVariable 'ied') mineDetectedBy west && alive (thisTrigger getVariable 'ied')",
    	"[west, ['mission_'], ['Our forces found enemy IED factory, your task is to destroy it.', 'Destroy IED factory'], thisTrigger getVariable 'iedPos', 1, 3, true, 'destroy', true] call BIS_fnc_taskCreate;",
    	""];
    
    _iedTrig2 = createTrigger ["EmptyDetector", _iedPos , true];
    _iedTrig2 setTriggerActivation ["NONE", "PRESENT", false];
    _iedTrig2 setVariable[ "ied", _ied ];
    _iedTrig2 setVariable[ "iedTrig1", _iedTrig1 ];
    _iedTrig2 setTriggerStatements [
    	"!alive (thisTrigger getVariable 'ied') && triggerActivated (thisTrigger getVariable 'iedTrig1')",
    	"['mission_', 'SUCCEEDED', true] call BIS_fnc_taskSetState;",
    	""];
    
    waitUntil {triggerActivated _iedTrig2};
    deleteVehicle _iedTrig1;
    deleteVehicle _iedTrig2;

     


  12. 7 hours ago, Larrow said:

    Both these references (_iedPos, _ied) will be undefined. Store the values needed on each of the triggers and reference the values from there instead.

      Hide contents
    
    
    _iedTrig1 setVariable[ "iedPos", _iedPos ];
    _iedTrig1 setTriggerStatements [
    	"this",
    	"
    		[west, ['iedFactoryTask_'], ['Our forces found enemy IED factory, your task is destroy it.', 'Destroy IED factory'], objNull, 1, 3, true, '', true] call BIS_fnc_taskCreate;
    		['iedFactoryTask_', thisTrigger getVariable 'iedPos'] call BIS_fnc_taskSetDestination;
    		deleteVehicle thisTrigger;
    	",
    	""];
    
    //** snip
    
    _iedTrig2 setVariable[ "ied", _ied ];
    _iedTrig2 setTriggerStatements [
    	"!alive ( thisTrigger getVariable 'ied' )",
    	"
    		['iedFactoryTask_', 'SUCCEEDED', true] call BIS_fnc_taskSetState;
    		deleteVehicle thisTrigger;
    	",
    	""
    ];

     

     

     

    Thank you very much, I thought these vaules are undefined in trigger but had no idea how to define them in trigger. So if I want define any values in trigger, I must define them by _trigg setVariable ... ? Also does it work for multiple values? For example if I wanted to store two values, I just write more setVariable ? 

    • Like 1

  13. Hey guys, today I have problem with this script. I have been working on this thing for like 4 hours now and can't make it work without problems. I have tried many different ways to solve the described problem below but without effect. 
    Basically this script is executed from init field of IED and if player enters proximity of 5 meters around the IED (IED is placed on table), it will create task informing player he found IED factory and it must be destroyed. 
    The problem is, there are no errors popping out when mission is started and task is created well as it should but the task missing place and if the IED is destroyed or disarmed, mission is not succeeded.

    Btw ignore the _table, I'm working on it.

    _ied = _this select 0;
    _iedPos = getPosATL _ied;
    _table = nearestObject [_iedPos, "Land_WoodenTable_small_F"];
    
    _iedTrig1 = createTrigger ["EmptyDetector", _iedPos , true];
    _iedTrig1 setTriggerArea [5, 5, 0, false, 5];
    _iedTrig1 setTriggerActivation ["WEST", "PRESENT", false];
    _iedTrig1 setTriggerStatements [
    	"this",
    	"[west, ['iedFactoryTask_'], ['Our forces found enemy IED factory, your task is destroy it.', 'Destroy IED factory'], objNull, 1, 3, true, '', true] call BIS_fnc_taskCreate;
    	['iedFactoryTask_', _iedPos] call BIS_fnc_taskSetDestination;
    	deleteVehicle thisTrigger;",
    	""];
    
    _iedTrig2 = createTrigger ["EmptyDetector", _iedPos , true];
    _iedTrig2 setTriggerActivation ["NONE", "PRESENT", false];
    _iedTrig2 setTriggerStatements [
    	"!alive _ied",
    	"['iedFactoryTask_', 'SUCCEEDED', true] call BIS_fnc_taskSetState;
    	deleteVehicle thisTrigger;",
    	""];

     

×