Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Toasticuss

Help with a randomization

Recommended Posts

How would I specify for a unit a random specific position that uses X,Y,Z in a location.

Say I have the unit spawn in one random specific position, how do I make it so it can spawn at another location with another set of specific coordinates?

Share this post


Link to post
Share on other sites

if i understand you right you could have an array of the positions and then do a random select.

_posarray = [[x1,y1,z1],[x2,y2,z2]];
_n = count _posarray;
_i = floor(random _n);
_possel = _posarray select _i;
unitname setpos _possel;

and you would run that once. Is that what you were looking for?

Share this post


Link to post
Share on other sites
if i understand you right you could have an array of the positions and then do a random select.

_posarray = [[x1,y1,z1],[x2,y2,z2]];
_n = count _posarray;
_i = floor(random _n);
_possel = _posarray select _i;
unitname setpos _possel;

and you would run that once. Is that what you were looking for?

Umm, this is what I want to accomplish

Mission Starts

NPC spawns at 1 of the 3 places, each place has its own unique coordinates for the NPC to spawn at, how do i specify each positions for each marker?

I need to find a way to put the "setPos [x,y,z]" on each marker so the game knows where to put the unit at.

Edited by Toasticuss

Share this post


Link to post
Share on other sites

Just move the markers to the spots you want and group the NPC with them. He'll spawn at one of the three spots.

Share this post


Link to post
Share on other sites
Just move the markers to the spots you want and group the NPC with them. He'll spawn at one of the three spots.

Yes I figured that part out, I just want to know how to specify him into a specific position at each marker.

Share this post


Link to post
Share on other sites

if your using markers to get there position you just use

getmarkerpos "markername";

and to setpos with some variation you do

unitname setpos [(getpos unitname select 0)+10,(getpos unitname select 1)+10,0];

Edited by Ghost

Share this post


Link to post
Share on other sites

Move the markers into position in the init.sqf or something:

"markername" setMarkerPos [0,0,0];

Share this post


Link to post
Share on other sites
Move the markers into position in the init.sqf or something:

"markername" setMarkerPos [0,0,0];

This is what I was looking for thank you.

Also for a trigger how could I make it so anyone in a certain group will activate it?

Edited by Toasticuss

Share this post


Link to post
Share on other sites

Not sure you can, since you tie it to a group by grouping with it. Why is the trigger grouped to the object again?

Share this post


Link to post
Share on other sites
Not sure you can, since you tie it to a group by grouping with it. Why is the trigger grouped to the object again?

That was an error, trigger was not supposed to be grouped to the object, its supposed to be grouped to one of the units right?

Would the condition be

"[unit1,unit2,unit3,unit4] in thislist;"? Or does that make it so all of those names must be in the trigger to activate?

Share this post


Link to post
Share on other sites

if you specify all those units in the array then all need to be inthislist

Share this post


Link to post
Share on other sites
if you specify all those units in the array then all need to be inthislist

I looked on a trigger I saw before and saw this

(unit1 in list triggerName) or (unit2 in list triggerName) or (unit3 in list triggerName) or (unit4 in list triggerName)

That would work right?

Share this post


Link to post
Share on other sites

yes, if any of those units are in the list trigger would fire

Share this post


Link to post
Share on other sites
yes, if any of those units are in the list trigger would fire

Great thanks guys.

Minor problem, I am trying to trigger an objective to be complete after a object is destroyed but its not triggering.

I currently have a trigger grouped to it that as the condition

conditon - damage cache > 0.7

activation is - tskbomb setTaskState "SUCCEEDED";

Any ideas?

Edited by Toasticuss

Share this post


Link to post
Share on other sites

dont group a trigger to the object you are detecting as being destroyed and try (damage cache) > 0.7

for the marker pos it should work but maybe try only two positions [x,y]

Share this post


Link to post
Share on other sites
dont group a trigger to the object you are detecting as being destroyed and try (damage cache) > 0.7

for the marker pos it should work but maybe try only two positions [x,y]

Alright thanks, also the marker Pos error was because I still had setPos in his init. Its working fine now.

Ill try the (damage cache) thing you said.

Update: I believe its working but nothing is popping up on screen about it being accomplished. What do I need to put in the trigger to make a taskhint pop up?

Thanks for the reply.

Edited by Toasticuss

Share this post


Link to post
Share on other sites
Great thanks guys.

Minor problem, I am trying to trigger an objective to be complete after a object is destroyed but its not triggering.

I currently have a trigger grouped to it that as the condition

conditon - damage cache > 0.7

activation is - tskbomb setTaskState "SUCCEEDED";

Any ideas?

That trigger will work even if it's not grouped.

Share this post


Link to post
Share on other sites
That trigger will work even if it's not grouped.

Yeah got that part down, what is the command to pop up that an objective has been completed?

I am currently using mk_taskhint script - http://www.ofpec.com/forum/index.php?topic=33768.0

and am using this in the triggers activation

tskbomb setTaskState "SUCCEEDED";[tskbomb] call mk_fTaskHint;

I don't think the condition is firing off correctly

condition -

(damage cache) > 0.7

Edit: Condition is working fine, I think I figured it out.

Edited by Toasticuss

Share this post


Link to post
Share on other sites

That looks correct, you have the

mk_fTaskHint = compile (preprocessFileLineNumbers "fTaskHint.sqf");

in your init.sqf right?

Share this post


Link to post
Share on other sites
That looks correct, you have the
mk_fTaskHint = compile (preprocessFileLineNumbers "fTaskHint.sqf");

in your init.sqf right?

Yeah, this is my init

while {true} do {
 hintsilent format["X: %1 : Y: %2 : Z: %3",position player select 0,position player select 1,position player select 2];
 sleep 0.2;
};

"warmark1" setMarkerPos [4094.33,4103.17,0.00144005];
"warmark2" setMarkerPos [3974.51,4200.78,0.00144005];
"warmark3" setMarkerPos [4070.73,4281.11,0.00143814];

sleep 2;

mk_fTaskHint = compile (preprocessFileLineNumbers "scripts\tasks\mk_fTaskHint.sqf");


if (time < 10) then {
titleCut ["", "BLACK FADED", 999];
[] Spawn {
	waitUntil{!(isNil "BIS_fnc_init")};

	// Info text
	[str ("Operation Iron Fury") ,  str(date select 1) + "." + str(date select 2) + "." + str(date select 0), str("Delta Six One")] spawn BIS_fnc_infoText;

	sleep 3;
	"dynamicBlur" ppEffectEnable true;   
	"dynamicBlur" ppEffectAdjust [6];   
	"dynamicBlur" ppEffectCommit 0;     
	"dynamicBlur" ppEffectAdjust [0.0];  
	"dynamicBlur" ppEffectCommit 5;  
	titleCut ["", "BLACK IN", 5];
};
};

execVM "Briefing.sqf";



sleep 2.5;

unit1 setCurrentTask tskObj1; // assign a task to the player
unit2 setCurrentTask tskObj1;
unit3 setCurrentTask tskObj1;
unit4 setCurrentTask tskObj1;
[tskObj1] call mk_fTaskHint; // apprise the player that a task ahs been assigned to him

_xhandle = a10 spawn {_pos = getpos _this; _this setpos [0,0,0]; sleep 600; _this setpos _pos};

Update: I moved execVM "Briefing.sqf" and

mk_fTaskHint = compile (preprocessFileLineNumbers "scripts\tasks\mk_fTaskHint.sqf");

to the very top and its working great now.

There's just one problem, if I were to set the task as my current task it puts a waypoint 6000m away.

How to I set the waypoint for one of the markers it randomly spawns at?

Edited by Toasticuss

Share this post


Link to post
Share on other sites

Your code will never get past:

while {true} do {
 hintsilent format["X: %1 : Y: %2 : Z: %3",position player select 0,position player select 1,position player select 2];
 sleep 0.2;
};

Share this post


Link to post
Share on other sites
Your code will never get past:

while {true} do {
 hintsilent format["X: %1 : Y: %2 : Z: %3",position player select 0,position player select 1,position player select 2];
 sleep 0.2;
};

Yep figured that out, there's just one problem, if I were to set the task as my current task it puts a waypoint 6000m away.

How do I set a proper markerPos in the briefing for one of the random markers it randomly spawns at?

This does not work

"tskbomb setSimpleTaskDestination (getMarkerPos "bomb1,bomb2,bomb3");"

bomb1, bomb2, bomb3 are all possible markers in the editor for where the object can spawn at.

This doesn't work either

"tskbomb setSimpleTaskDestination (getMarkerPos "bomb1","bomb2","bomb3");"

Edited by Toasticuss

Share this post


Link to post
Share on other sites

tskbomb setsimpletaskdestination getpos bomb?

Assuming the object being moved is named bomb.

Share this post


Link to post
Share on other sites

[] spawn {
while {true} do {
	hintsilent format["X: %1 : Y: %2 : Z: %3",position player select 0,position player select 1,position player select 2];
	sleep 0.2;
};
};

That would work to keep the debug position thing and continue along the init.sqf.

As for the marker thing, you can't have three destinations, nor can you have three locations for a single waypoint.

Either just tell the player "The bombs might be in the blue marked areas" or have separate tasks for each one if you must provide waypoints/locations for them. Most players are smart enough to figure it out though, so skip waypoints/destinations and just say something like "one of the markers is where the bomb is". Or what shk said, but that of course would do away with the point of the other two markers. :)

Share this post


Link to post
Share on other sites
tskbomb setsimpletaskdestination getpos bomb?

Assuming the object being moved is named bomb.

That worked perfectly, but the bomb is no longer moving.

---------- Post added at 05:14 AM ---------- Previous post was at 05:13 AM ----------

[] spawn {
while {true} do {
	hintsilent format["X: %1 : Y: %2 : Z: %3",position player select 0,position player select 1,position player select 2];
	sleep 0.2;
};
};

That would work to keep the debug position thing and continue along the init.sqf.

As for the marker thing, you can't have three destinations, nor can you have three locations for a single waypoint.

Either just tell the player "The bombs might be in the blue marked areas" or have separate tasks for each one if you must provide waypoints/locations for them. Most players are smart enough to figure it out though, so skip waypoints/destinations and just say something like "one of the markers is where the bomb is". Or what shk said, but that of course would do away with the point of the other two markers. :)

So if i do what shk said it will no longer randomly spawn? Nevermind, works fine. I accidentally un grouped the markers.

Thanks a lot for that Coordinates script update it works just fine.

UPDATE: EVERYTHING IS WORKING GREAT NOW, THANKS GUYS.

Edited by Toasticuss

Share this post


Link to post
Share on other sites
Sign in to follow this  

×