Jump to content
zagor64bz

[SOLVED]Intel drop script help needed.

Recommended Posts

Hi, I have a wip scenario, where a pre-placed objects/units has an addAction that drop some intel, useful to reveal a location by calling this script:

Spoiler

private ["_HQLogicGrp","_hqObject","_m","_nikPos"];

//params ["player"];

sleep 0.2;

hint "TABLET FOUND";

sleep 0.2;

sendPhoneData = player addAction [
	"<t size='2' shadow='2' color='#ff9900'>UPLOAD FILES TO SIGINT FOR HACKING</t>", {
		params ["player"];
		player setVariable ["ZAG2_sendPhoneData",true,true];
		player removeAction sendPhoneData;

	},[],6,true,true,"","(_this == _target)"
];


waitUntil {
	sleep 0.5;
	(player getVariable ["ZAG2_sendPhoneData",false])
};
sleep 0.5;

_HQLogicGrp = createGroup sideLogic;
_hqObject = _HQLogicGrp createUnit [
    "Logic",
    [0,0,0],
    [],
    0,
    "NONE"
];
_hqObject globalChat "HQ:-RECIVING FILES...HOLD ON!";
sleep (5 + (random 15));
_hqObject globalChat "HQ:-TABLET HACKED, WE ARE TRIANGULATING POSITION OF STASH...";

sleep (15 + (random 15));

_hqObject globalChat "HQ:-SENDING STASH POSITION IN...3...2...1.. DATA UPLOADED. GOOD LUCK GHOSTS!";


_nikPos =(getPosWorld ZAG_BOX);


_m = createMarker ["NukeMarker", _nikPos];
_m setMarkerShape "ICON";
_m setMarkerType "hd_unknown";
_m setMarkerColor "ColorBlack";
_m setMarkerAlpha 0.75;

"STASH LOCATION REVEALED" HintC ["STASH POSITION HAS BEEN DISCLOSED","Look for a BLACK ''?'' ICON marker on your map for STASH location"];
 


 

where "ZAG_BOX" is the object the newly created marker is tied to. Work great. The problem is that the "ZAB_BOX" are 3 in total, spawning at random position.

 

What I need is to create a marker over ZAG_BOX, or over ZAG_BOX2 or ZAG_BOX3. Clearly, it need to check if a marker has been already created to any of the box, and if it has, create one over an undisclosed one. Am I clear enough?

 

Thank you ! 

  • Like 1

Share this post


Link to post
Share on other sites

You can use allMapMarkers and check for already existing markers, but I'm not sure to understand your way. Why don't you randomize the box place then the marker?

You could also place 3 markers, one for each box, and play with their alpha (transparent or not)

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, pierremgi said:

You can use allMapMarkers and check for already existing markers, but I'm not sure to understand your way. Why don't you randomize the box place then the marker?

You could also place 3 markers, one for each box, and play with their alpha (transparent or not)

Ok..let me be more informative:

 

There are 3 custom composition spawning randomly on an array of X-Y positions.

Example:

[ [[11362.9,14401.1,-0.0389652],[8327.75,14833.4,-0.0116882],[8479.59,12969.2,-0.625523],[4677.91,12731.8,0.065937],[3717.96,10416.1,0]] call BIS_fnc_selectRandom, random 360, weaponComposition ] call BIS_fnc_objectsMapper;

On each of the composition, there's a box, named box1 for comp. 1/box2 for comp.2 and box 3 for comp.3.

By killing some pre-placed units, or by picking up certain items you trigger the above script. Which will create a marker over one of the box, whichever is mentioned in the script.So far so good...

 

What I really need is this:

-script check if a marker as been created over one of the 3 boxes 

-if none, it create one over one of the box, whichever one is not important. 

-if a marker has been already created, lets say over box1, it create a marker over one of the remaining boxes.Same for the next one.

 

How to do that?

 

Thank you Pierre.

 

 

Share this post


Link to post
Share on other sites

{if (_x in ["box1","box2","box3"]) exitWith {true} } count allMapMarkers;  // true if a marker "box1" or "box2" or "box3" is already on map.

 

markers are not object but you can:

teleport them,

fade them (marker Alpha)

delete them

Don' forget you can't create two markers with the same name (so there is no danger creating one on an already existing one).

Share this post


Link to post
Share on other sites

Ok....I'll test and report back.

REALLY thank you in the meantime.

Share this post


Link to post
Share on other sites

Sorry man, I feel dumb.

WHERE exactly I have to put this

{if (_x in ["box1","box2","box3"]) exitWith {true} } count allMapMarkers;  // true if a marker "box1" or "box2" or "box3" is already on map.

in this?

private ["_HQLogicGrp","_hqObject","_m","_nikPos"];

//params ["player"];

sleep 0.2;

hint "TABLET FOUND";

sleep 0.2;

sendPhoneData = player addAction [
	"<t size='2' shadow='2' color='#ff9900'>UPLOAD FILES TO SIGINT FOR HACKING</t>", {
		params ["player"];
		player setVariable ["ZAG2_sendPhoneData",true,true];
		player removeAction sendPhoneData;

	},[],6,true,true,"","(_this == _target)"
];


waitUntil {
	sleep 0.5;
	(player getVariable ["ZAG2_sendPhoneData",false])
};
sleep 0.5;

_HQLogicGrp = createGroup sideLogic;
_hqObject = _HQLogicGrp createUnit [
    "Logic",
    [0,0,0],
    [],
    0,
    "NONE"
];
_hqObject globalChat "HQ:-RECIVING FILES...HOLD ON!";
sleep (5 + (random 15));
_hqObject globalChat "HQ:-TABLET HACKED, WE ARE TRIANGULATING POSITION OF STASH...";

sleep (15 + (random 15));

_hqObject globalChat "HQ:-SENDING STASH POSITION IN...3...2...1.. DATA UPLOADED. GOOD LUCK GHOSTS!";


_nikPos =(getPosWorld ZAG_BOX);


_m = createMarker ["NukeMarker", _nikPos];
_m setMarkerShape "ICON";
_m setMarkerType "hd_unknown";
_m setMarkerColor "ColorBlack";
_m setMarkerAlpha 0.75;

"STASH LOCATION REVEALED" HintC ["STASH POSITION HAS BEEN DISCLOSED","Look for a BLACK ''?'' ICON marker on your map for STASH location"];
 

Note: I put 3 markers named "box1" or "box2" or "box3" in the editor. As you sad, I could attach those to  the objects that spawn with the compositions, fulfilling my intent.

Share this post


Link to post
Share on other sites

I'm lost also into your objective. :dozingoff:

To be more efficient, just describe chronologically what you want. Something as:

blufor penetrate an area (trigger a script)

So server spawn a composition including now a box named box1

 or 3 compositions with box1 box2, box3

or the compositions already exist but I just want to place a marker on a box

 

so a script creates a marker, randomly on one of the three boxes positions.

this marker is named "nukemarker"  or "boxNumberSomething"...

 

I can't understand why you want to check if a marker is already existing.

If you have a repeatable action/trigger,

just deleteMarker "nukemarker"

createMarker again

or "nukemarker" setpos anewPosition

 

You can even "delete" a non-existing marker with no error:  I mean deleteMarker "nukeMarker"  is ok even if this marker doesn't exist yet.

 

Share this post


Link to post
Share on other sites

Ok sorry Pierre..I'll try to be more precise:

SP mission:

-you have to disclose the positions of 3 weapons caches by killing some officers,already placed in the mission,which has an addAction to "search body".This:

Spoiler

GOM_fnc_intelDrop = {

params [["_side",east]];//defaults to east if no side is given

//you can replace _enemies with an array of units that should drop the intel
//_enemies = allUnits select {alive _x and side _x isEqualTo _side};
_enemies = [intel,intel_1,intel_2,intel_3,intel_4];
_enemies apply {_x setdamage 1};
{

_x addAction ["<t size='1.5' shadow='2' color='#ff9900'>SEARCH BODY</t>",{

	params ["_object","_caller","_ID","_enemies"];

	_object removeAction _ID;

	_guaranteedIntel = {alive _x} count _enemies <= 3;//if 3 or less enemies are alive every kill will give intel

	if (random 100 < 100) then {

		systemchat "You found some intel!";
		[] execVM "intelFound_2.sqf";

	} else {

		systemchat "You found nothing";

	};


	},_enemies,6,true,false,"","!alive _target AND _this isEqualTo vehicle _this AND isPlayer _this",2];



} forEach _enemies;

 

When you do that, as you see, it call a script, (intelFound_2.sqf). This:

Spoiler

private ["_HQLogicGrp","_hqObject","_m","_nikPos"];

//params ["player"];

sleep 0.2;

hint "TABLET FOUND";

sleep 0.2;

sendPhoneData = player addAction [
	"<t size='2' shadow='2' color='#ff9900'>UPLOAD FILES TO SIGINT FOR HACKING</t>", {
		params ["player"];
		player setVariable ["ZAG2_sendPhoneData",true,true];
		player removeAction sendPhoneData;

	},[],6,true,true,"","(_this == _target)"
];


waitUntil {
	sleep 0.5;
	(player getVariable ["ZAG2_sendPhoneData",false])
};
sleep 0.5;

_HQLogicGrp = createGroup sideLogic;
_hqObject = _HQLogicGrp createUnit [
    "Logic",
    [0,0,0],
    [],
    0,
    "NONE"
];
_hqObject globalChat "HQ:-RECIVING FILES...HOLD ON!";
sleep (5 + (random 15));
_hqObject globalChat "HQ:-TABLET HACKED, WE ARE TRIANGULATING POSITION OF STASH...";

sleep (15 + (random 15));

_hqObject globalChat "HQ:-SENDING STASH POSITION IN...3...2...1.. DATA UPLOADED. GOOD LUCK GHOSTS!";


_nikPos =(getPosWorld ZAG_BOX);

_m = createMarker ["NukeMarker", _nikPos];
_m setMarkerShape "ICON";
_m setMarkerType "hd_unknown";
_m setMarkerColor "ColorBlack";
_m setMarkerAlpha 0.75;

"STASH LOCATION REVEALED" HintC ["STASH POSITION HAS BEEN DISCLOSED","Look for a BLACK ''?'' ICON marker on your map for STASH location"];

 

 

It will work OK if the ZAG_BOX was only one.But.....

The weapons caches (3) are spawned randomly on the map, using an array of X-Y-Z positions, since they are custom compositions. Within the compositions, I named one each of the objects, ZAG_BOX1,ZAG_BOX2,ZAG_BOX_3.

 

As stated above, I need the "intelFound" script to :

 

-script check if a marker as been created over one of the 3 boxes 

-if none, it create one over one of the box, whichever one is not important. 

-if a marker has been already created, lets say over box1, it create a marker over one of the remaining boxes.Same for the next one.

 

Hope I was clear enough. 

Share this post


Link to post
Share on other sites

Every term is important:

The weapons caches (3) are spawned randomly on the map

When? the three at once or progressively along with addAction?

 

I named one each of the objects, ZAG_BOX1,ZAG_BOX2,ZAG_BOX_3

What for?

 

-script check if a marker as been created over one of the 3 boxes

So, checking if a marker has been created  + find on which box? Probably.

That means: Do not use the same name for the markers (it's impossible. The first named makes the others fail). So, you need to identify your markers.

I suggest you to give them the stringed name of the created crate.

sequence:

spawn composition1; createMarker ["ZAG_BOX1", _position];

spawn composition2; createMarker ["ZAG_BOX2", _position];

spawn composition3; createMarker ["ZAG_BOX3", _position];

 

The further question is essential:

When do you want your marker appears or not?

 

NB1 : you could create tasks as well. The question is 3 at a time or sequently.

NB2: You can randomize an array several times without picking twice the same element:

 

Sorry id I didn't answer your question. Here is a hint to script something approaching:

It's an example for randomizing 3 objectives on 3 different crates, sequently:

 

[] spawn {
  _arrayOfCrates = [ZAG_BOX1,ZAG_BOX2,ZAG_BOX3];
  While {count _arrayOfCrates > 0 } do {
    _chosenBox = _arrayOfCrates deleteAt (floor random count _arrayOfCrates);
    _m = createMarker [str (_chosenBox), getPos _chosenBox];
    _m setMarkerShape "ICON";
    _m setMarkerType "hd_unknown";
    _m setMarkerColor "ColorBlack";
    _m setMarkerAlpha 0.75;
    _tsk = ["tsk"+str (_chosenBox), player, ["description", "title",str (_chosenBox)], getMarkerPos _m, "assigned", 1,true,false,"destroy",false] call BIS_fnc_setTask;
    waitUntil {sleep 0.5; ([_tsk] call BIS_fnc_taskState) == "Succeeded"};
  };
};

 

You need to script or add triggers for successful condition for each task, like this (in trigger):

!alive ZAG_box1

0 = ["tskZAG_box1","SUCCEEDED",true] spawn BIS_fnc_taskSetState;

deleteMarker "ZAG_box1";  // optional

 

 

 

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Sorry man!

Ok..here we go:

 

11 hours ago, pierremgi said:

The weapons caches (3) are spawned randomly on the map

When? the three at once or progressively along with addAction?

All 3 at once, at mission start by the INIT.sqf

 

11 hours ago, pierremgi said:

I named one each of the objects, ZAG_BOX1,ZAG_BOX2,ZAG_BOX_3

What for?

1-To be able to tie a marker to one each of the box.

2-as condition for a scripted

task =!alive BOX1= task SUCCEEDED 

11 hours ago, pierremgi said:

-script check if a marker as been created over one of the 3 boxes

So, checking if a marker has been created  + find on which box? Probably.

Affirmative.

 

11 hours ago, pierremgi said:

The further question is essential:

When do you want your marker appears or not?

I want the marker to appears once you collect the intel from a dead enemy.

 

11 hours ago, pierremgi said:

NB1 : you could create tasks as well. The question is 3 at a time or sequently.

I already did. The task is:

-" destroy ALL weapons caches"

( I don't want the player to know how many caches there is). Once he collect all the needed intel and blow up the crates a notification of "task completed" will let him know.

 

Sorry I wasn't more precise before Pierre.

Thank you for your time.

 

Share this post


Link to post
Share on other sites

So, your solution seems to me simple as:

- create your markers  "ZAG_BOX1","ZAG_BOX2","ZAG_BOX3"  in init.sqf, once the boxes are created:

- set marker alpha to 0 instead of 0.75;

- when you create your task, just add:
 

[] spawn {
   _arrayOfBoxes = [ZAG_BOX1,ZAG_BOX2,ZAG_BOX3];
   While {count _arrayOfBoxes > 0 } do {
     _chosenBox = _arrayOfBoxes deleteAt (floor random count _arrayOfBoxes);
     str(_chosenBox) setMarkerAlpha 0.75;
     waitUntil {sleep 0.5; (!alive _chosenBox};
    str(_chosenBox) setMarkerAlpha 0;
  };
};

 

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×