Jump to content
Sign in to follow this  
Sneakers O'Toole

Need help with custom objective please

Recommended Posts

I got the basic outline of the 1st bit of the code, and I thought I'd take out some repetition in a switch. I only needed 2 variable names to pass to the create vehicle command. So why when I move this bit of code (last 4 lines) out of the switch and into the main process, do the variables become any and it doesnt work?

Specifically the variable _vehVAR in the create vehicle command becomes any and breaks the program. But if I run it in the case in the switch it works ok.

//custom mission - 'Acquire the requested vehicle, repair and fuel it, then leave it at instructed postition'

_vehCLASSname = ["SUV_PMC","BAF_OFFROAD_W","Ural_TK_CIV_EP1","ATV_US_EP1","AH6J_EP1"];				//Vehicle classname
_vehTXTArray = ["an SUV","a Land Rover","a Civillian Ural","an ATV","a LittleBird Helicopter"];		//Text version of vehicle name for speech bubble.
//_vehHINTpos = ;					//Area where a vehicle of the required type may be found.
//_vehPARKpos = ;					//Place to leave vehicle after it has been fully repaired and refuelled.

_vehSEL = (floor(random 1));		//Random selection of vehicle.
switch (_vehSEL) do 
{
case 0:
	{
	_vehVAR = _vehCLASSname select 0; 		//select 0 simply selects the first entry ("SUV") from _veh_classname's array.
	_vehTXT = _vehTXTArray select 0;		//Selects the corresponding entry in the vehicle text description array.
	//_veh_actual = createVehicle [_vehVAR, position player, [], 0, "NONE"];	//Need to make the spawn position random and >5000m away.
	//_veh_actual setFuel (random .2);
	//_veh_actual setDamage (random .8);
	};
case 1:
	{
	_vehVAR = _vehCLASSname select 1; 		//BAF_OFFROAD_W
	_vehTXT = _vehTXTArray select 1;		//
	};
case 2:
	{
	_vehVAR = _vehCLASSname select 2; 		//Ural_TK_CIV_EP1
	_vehTXT = _vehTXTArray select 2;		//
	};
case 3:
	{
	_vehVAR = _vehCLASSname select 3; 		//ATV_US_EP1
	_vehTXT = _vehTXTArray select 3;		//
	};
case 4:
	{
	_vehVAR = _vehCLASSname select 4; 		//AH6J_EP1
	_vehTXT = _vehTXTArray select 4;		//
	};		
};

_veh_actual = createVehicle [_vehVAR, position player, [], 0, "NONE"];	//Need to make the spawn position random and >5000m away.
_veh_actual setFuel (random .5);
_veh_actual setDamage (random .8);

//NPC Speech bubble triggered by 3m editor trigger.
Hint format ["Hi, I have need of %1. I heard there was one near %2. I want it fully repaired and full of gas. Leave it at %3",_vehTXT,_vehHINTpos,_vehPARKpos];

Share this post


Link to post
Share on other sites

Why not do away with the switch case and do a line like this to select the random vehicle.

_r =  floor(random count _vehCLASSname);
_vehVAR = _vehCLASSnameselect _r;
_vehTXT = _vehTXTArray select _r;

Share this post


Link to post
Share on other sites

Excellent, thats works perfectly. 40 lines distilled into 3!:cool:

Thanks. I was reusing what little knowledge I have to so it helps me enormously when people offer new information and concepts. Much appreciated.

What would be the best method to randomly define a vehicles position on the map. I would like to be able to specify the minimum distance from the player to something like at least 6000metres. I want it to be literally anywhere on the map with a general area hint, so you have to go search and pick it up with a heli.

I am looking at shk pos, or making an array with random positions, or I saw a townlist feature of civillian module, but then I dont want to limit it to a town location.

---------- Post added at 03:36 ---------- Previous post was at 01:39 ----------

Actually shk_pos is working quite well.

But I cannot understand the required syntax to make a marker in code.

I created a marker so I could see the details from the mission.sqf.

How can I turn these details into a marker in code?:

//class Item1
//		{
//			position[]={2753.0801,207.70134,5314.5542}; //NOTE: I have a variable name to replace this
//			markerType="ELLIPSE";
//			type="Empty";
//			colorName="ColorBlue";
//			fillName="DiagGrid";
//			a=1500;
//			b=1500;
//		};

Share this post


Link to post
Share on other sites
_m = createMarkerLocal ["TownM",[[color=#000000][color=#FF8000]2753.0801,207.70134,5314.5542[/color][/color]]];
_m setMarkerShapeLocal "[color=#000000][color=#FF8000]ELLIPSE[/color][/color]";
_m setMarkerColorLocal "[color=#000000][color=#FF8000]ColorBlue[/color][/color]";
_m setMarkerBrushLocal "[color=#000000][color=#FF8000]DiagGrid[/color][/color]";
_m setMarkerSizelocal [[color=#000000][color=#FF8000]1500[/color][/color],[color=#000000][color=#FF8000]1500[/color][/color]];
_m setMarkerDirlocal 0;

Edited by Iceman77

Share this post


Link to post
Share on other sites

Allright, thanks.

I made the marker big so that it would take a little bit of effort searching for the actual vehicle, but really you can just look at the epicenter of the marker to know where it is.

So I made a random number variable that is the radius of the marker. And I want to add it to the vehicle spawn location variable, then use this variable to define the center of the marker. I tried this, but predictably the syntax is wrong:

_vrnd = (floor(random 750)); 	//How to add this to shk_pos distance value?
_vehMARKoff = (_vrnd + _vehpos);

I also tried:

_vehMARKoff = (_vehpos + (floor(random 750)));

I looked at examples in random scripts but that just confused me more cos i saw things that i already tried but for me failed.

But also, don't i need 2 numbers for lat/long?

---------- Post added at 19:57 ---------- Previous post was at 19:48 ----------

Oh, I see another thread with something similar. But I dont know what to put for vehname, because is a marker not a vehicle

"_mkr" SetMarkerPos (VehName ModelToWorld [5,0,0]); // [x,y,z]

_mkr = createMarkerlocal ["Vehicle Intel.",_vehPOS]; //doesnt show name
_mkr setMarkerShapelocal "ELLIPSE";
_mkr setMarkerColorlocal "ColorBlue";
_mkr setMarkerBrushlocal "DIAGGRID";
_mkr setMarkerTextlocal "SETMARKERTEXT"; //doesnt show name
_mkr setMarkerSizelocal [1500,1500];

Share this post


Link to post
Share on other sites

_dist = 50 + random 1450;
_dir = random 360;
_markerPos = [(getPos vehName select 0) + (sin _dir) * _dist, (getPos vehName select 1) + (cos _dir) * _dist, 0];
_mkr setMarkerPos _markerPos;
//OR
//"VehicleIntel1" setMarkerPos _markerPos;

---------- Post added at 11:02 ---------- Previous post was at 10:57 ----------

That's how I did a "downed UAV" mission. To let the players know via marker where the uavs general area was.

Edited by Iceman77

Share this post


Link to post
Share on other sites

The random direction is good for this. Is it able to generate negative values also? I would like to incorporate it if I may?

I presume vehname select 0 is a variable from a custom array you made? You also have vehname select 1.What is the second variable? Presumably the 1st one is the actual vehicle location?

Share this post


Link to post
Share on other sites

getpos vehName select 0 selects the x-axis of the vehicle pos, select 1 the y-axis. select 2 the z-axis.

Share this post


Link to post
Share on other sites

Ah, ok makes sense, cheers.

I know it's hard to believe, but I am having yet more problems. :)

I am having a hard time understanding the trigger functions in script form. I need to create a trigger that:

* Waits for the presence a vehicle 'veh_actual'

* Also checks that the heath and fuel is full.

* And to only be satisfied when the player has left the trigger area. (So that you cannot just hover over it with the vehicle attached).

So far I got:

_trg_BZD1 = createTrigger["parkpos1berezinoDock",[13227.516,2.8859138,9958.4219]];

_trg_BZD1 setTriggerArea[4,6,5.7897902,true];

_trg_BZD1 setTriggerActivation ["ANY","PRESENT",false];

_trg_BZD1 triggerAttachVehicle [_veh_actual];

But I don't know what to put for the condition, or on act., or on de act.

and for the activation:

if (triggeractivated _trg_BZD1) then

{

//debug

Hintc format ["trigger satisfied"];

};

Unsurprisingly my ham-fisted attempt doesn't work.

Share this post


Link to post
Share on other sites

Why exact xyz numbers? Also, why use an exact number for the angle (5.789xxx) in setTriggerArea. Your trigger is 4x6 atm. Also use "Hint "trigger done"" (without extra ""). formats only real use is if you have a variable and need to pass it to a hint, as it converts everything to a string, similar to str. Like this:

_number = 6;
hint format ["%1",_number]; // Displays 6

Share this post


Link to post
Share on other sites

Well I use exact co-ords because the drop location is quite specfiic, like this:

image1ojc.jpg

Thanks for the tip about hints. But how do i make the triggger wait for the presence a vehicle?

Do I use =true for the vehicle variable and =false for the player. I dont know the format for this.

Share this post


Link to post
Share on other sites

You need to group the trigger with the vehicle in question. The trigger will activate when the vehicle is in the trigger area.

Share this post


Link to post
Share on other sites

Is there a reason why the switch doesnt pass _pPOSmk and _pPOSdir outside of the switch? The hint at the bottom returns any and any.

_vehPARKpos = ["ppBZD1","ppED1","ppCD1","ppDC1","ppBM1","ppGM1","ppOH1"];				
_vehPARKposTXT = ["Berezino Dockyard","Elecktro Dockyard","Chernarus Dockyard","Devil's Castle","Black Mountain","Green Mountain","Olsha Hill"];	

//Select random park position from array
_p =  floor(random count _vehPARKpos);
_vehPARK = _vehPARKpos select p;
_vehPARKtxt = _vehPARKposTXT select _p;

switch (_p) do 			// Switch-statement which uses the variable _p to select a case.
{ 
case 0:
{
_pPOSmk = [13227.456,9958.4902];
_pPOSdir = 7;
};
case 1:
{
_pPOSmk = [10108,1667];
_pPOSdir = 97;
};
case 2:
{
_pPOSmk = [7030,2209];
_pPOSdir = 80;
};
case 3:
{
_pPOSmk = [6860,11430];
_pPOSdir = 0;
};
case 4:
{
_pPOSmk = [10293,12061];
_pPOSdir = 70;
};
case 5:
{
_pPOSmk = [3728,6011];
_pPOSdir = 120;
};
case 6:
{
_pPOSmk = [12904,12759];
_pPOSdir = 90;
};
};

hint format ["_pPOSmk = %1 - _pPOSdir = %2",_pPOSmk,_pPOSdir];

Share this post


Link to post
Share on other sites

First glance it looks like you're trying to subtract _pPOSdir from _pPOSmk

If that's not it, try removing the local variables from the format, and just use:

hint format ["POS: %1, DIR: %2",_pPOSmk,_pPOSdir];

Edited by panther42

Share this post


Link to post
Share on other sites

Place this at the top of the script otherwise they will only exist within the scope of the switch

private ["_pPOSmk","_pPOSdir"];

Share this post


Link to post
Share on other sites
Place this at the top of the script otherwise they will only exist within the scope of the switch

private ["_pPOSmk","_pPOSdir"];

So this is just like making it a global variable, just that it's local? Like, it exists within the whole script even though it was only defined within a scope?

Share this post


Link to post
Share on other sites
Place this at the top of the script otherwise they will only exist within the scope of the switch

private ["_pPOSmk","_pPOSdir"];

 

Awesome. Exactly right. Thanks.

---------- Post added at 13:09 ---------- Previous post was at 13:06 ----------

I'm nearly finished now. But I did this:

if (_tr_ACT = 1 && _vehDMG < 0.05 && _vehFuel > 0.9 && _pdis > 2000) then

But I got this error message:

"error missing )"

After seeing this as an example (wasteland mod)

if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then 

I changed it to this:

if ((_tr_ACT = 1) and (_vehDMG < 0.05) and (_vehFuel > 0.9) and (_pdis > 2000)) then

But I still get the same error.

Share this post


Link to post
Share on other sites

_tr_ACT == 1, a single = defines the variable, two == compare it.

Share this post


Link to post
Share on other sites

yeah, spot on, cheers.

How do you make multiple commands in the activation portion of settriggerstatements?

_trg setTriggerStatements ["this", "hint 'ACTIV'", ""];

As well as the hint, i want to add this: tr_ACT = 1

Share this post


Link to post
Share on other sites

I'm trying to set a variable in a trigger statement but searching in this forum I get two conflicting answers.

You can have has many local variables you like, the only things that you cannot use within a trigger statement (and event handlers) are the sleep command and waitUntil.

neokika

This will not work because of variable scope. The variable _type is local only to the script, and thus cannot be used in the trigger statement.

Big Dawg KS

I am trying

_trg setTriggerStatements ["this", "tr_ACT = 1", ""];  

but it is not returned. I have tried it when it is a private ["tr_ACT = 1"] and not.

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
Sign in to follow this  

×