Jump to content
Sign in to follow this  
Guest

How to make objective marker follow a moving target?

Recommended Posts

Guest

Here is my problem...

I have a task which involves having to secure a man. I want the objective marker to stay on the man at all times.

I have this atm

tsk2 setSimpleTaskDestination (getPos man1); 

The above sets the marker on him but when he moves, the marker just stays in the same place...:confused: I need it to follow him!

Any ideas on what I can do?

Thanks in advance:)

Share this post


Link to post
Share on other sites

yes ,

you have to write a file which set the marker on him every second for example.

in init line of man1 for example

this exec "marker.sqs"

marker.sqs

#start

"markername" setMarkerPos getPos man1

~1

goto "start"

Share this post


Link to post
Share on other sites

Or you can try this in your init.sqf:

[] spawn {
 while {sleep 0.5; alive man1} do {
   tsk2 setSimpleTaskDestination (getPos man1);
 };
};

If it doesn't like to work with the destination command, you'll have to remove that and create a normal marker on top of him and update it like:

[] spawn {
 while {sleep 0.5; alive man1} do {
   "markerName" setmarkerpos getPos man1;
 };
};

Share this post


Link to post
Share on other sites

i think shk´s way should be the better solution! ( if its working , i did not try)

just an idea:

You could set a "waypoint" on him also?!

Share this post


Link to post
Share on other sites
Guest

Okay, Divancy81...

I tried your idea and the dot marker followed him but the actual orange objective marker doesn't follow...

Any ideas?

Share this post


Link to post
Share on other sites

Did i understand right? You have two marker? whats name of second marker?

#start

"markername1" setMarkerPos getPos man1

"markername2" setMarkerPos getPos man1

~1

goto "start"

EDIT:

ah ok i know what you mean. sry :j:

hm.. im not sure how to handle the mission objective marker

do the marker have a name?

Edited by davincy81

Share this post


Link to post
Share on other sites

Did SHK's first code not work? Assuming you have the correct task handle? Pretty sure that's the way to get the "task marker" to move.

Share this post


Link to post
Share on other sites
Guest

The objective maker is this:

tsk2 setSimpleTaskDestination (getMarkerPos "hostagemkr1"); 

hostagemkr1 is the dot marker.

---------- Post added at 09:19 PM ---------- Previous post was at 09:18 PM ----------

Did SHK's first code not work? Assuming you have the correct task handle? Pretty sure that's the way to get the "task marker" to move.

I'm going to try that out in a min and hope for the best:o

Share this post


Link to post
Share on other sites

I got this working for me:

Map: Utes

T72 spawned on west side, get's waypoint to east end. Also get's name=target.

Init line of player:

theTask = player createSimpleTask ["Destroy T72"]; 0 = [] spawn {while {sleep 1.0; true} do {theTask setSimpleTaskDestination (getPos target)};};

Share this post


Link to post
Share on other sites

Argh, cleanse this thread of the scourge that is SQS! Confusion and obsolescence will reign! :butbut::eek::confused:

Share this post


Link to post
Share on other sites
Guest

hmm... I couldn't get shk's idea to work...

Muzzleflash, yours worked, follows the man nicely:)

Would it work for multiplayer? Also, would it work for all players?

Thanks

Edited by Guest

Share this post


Link to post
Share on other sites

It would only show on the peoples computers that you add them to. And it may get trickier if you want JIP.

What I would do, for example, is create a trigger with condition:

local player

and on act:

0 = [] execVM "playerJoined.sqf";

And in your playerJoined.sqf do something like this:

//Add the [b]task[/b]
...........
//[b]Spawn [/b]the marker-follow code
....

Share this post


Link to post
Share on other sites
Guest

Like this?

// The hostage follow task
tsk2 = player createSimpleTask ["Secure German"];

// The hostage follow script spawned
0 = [] spawn {while {sleep 1.0; true} do {tsk2 setSimpleTaskDestination (getPos man1)};}; 

Sorry, I'm not great at all this...

Thanks for the help so far:)

Share this post


Link to post
Share on other sites

Yes put that in a file, eg. playerJoined.sqf, and make the trigger I suggested where you run the script.

If you put this in a script file you don't need the "0 = " part in front. That was just to get the editor to accept it in the initialization line.

Share this post


Link to post
Share on other sites
Guest

Ok, I just tried it on LAN and it was following the man correctly for me but it created the task twice in the tasks menu...

I'm guessing it's because of the "joinplayer.sqf" having the task load aswell as the "briefing.sqf".

Any idea of a way around this?

Also, I have 8 players in my mission, here are the names: (p1,p2,p3,p4,p5,p6,p7,p8,). How could I allow the follow script to work for all players?

Thanks

Share this post


Link to post
Share on other sites

Don't call both the briefing.sqf and joinplayer.sqf. Either move the part in to the briefing.sqf, or, separate it this way:

The briefing.sqf only contains the task creation and other notes you create (eg. createDiarySubject or similar). In the playerJoined.sqf you run the briefing.sqf like this for example:

call preProcessFile "briefing.sqf";

//****** Add the "task marker" follow script below.

If you do this then obviously you don't add the task here aswell, that is dealt with by briefing.sqf. And stop the init.sqf/unit-initialization-line from calling the briefing.sqf if you do this.

Share this post


Link to post
Share on other sites
Guest

ah of course, I understand. Works great:)

The only thing left now is allowing all 8 players in my mission to see the follow script...

Where would I have to put their names (p1,p2,p3,p4,p5,p6,p7,p8) for it to work?

Thanks for all the help so far, I will give you credit once it is publicly released;)

Share this post


Link to post
Share on other sites

Nah you don't have to give credit to me..

Well if you used trigger method I suggested then you don't need to ;).

The condition "local player" is when a player joins (whether from the start or JIP), and thus it will run 'joinplayer.sqf' for all players when they join. If you have 2 sides or multiple groups with different objectives then you would need to do some checks, however if that is not the case, then it should work as it is.

Share this post


Link to post
Share on other sites
Guest

I only have 1 playable group and 1 playable side so it's all good as it is:yay:

Thanks so much for helping all this time, really appreciate it!

Share this post


Link to post
Share on other sites
I got this working for me:

Map: Utes

T72 spawned on west side, get's waypoint to east end. Also get's name=target.

Init line of player:

theTask = player createSimpleTask ["Destroy T72"]; 0 = [] spawn {while {sleep 1.0; true} do {theTask setSimpleTaskDestination (getPos target)};};

To expand on what muzzleflash said, this is the the way to do it. all you are doing is replacing the normal setSimpleTaskDestination with this line

for example:

tskchase = player createSimpleTask ["Chase the second in command"]; 0 = [] spawn {while {sleep 1.0; true} do {tskchase setSimpleTaskDestination (getPos car1)};};.

at the end it should look this this but with your objective:

tskchase = player createsimpletask ["Chase the 2nd in command"];
tskchase setsimpletaskdescription ["Chase the 2nd in command", "Chase 2nd in command", "Chase"];
tskchase = player createSimpleTask ["Chase the send in command"];
0 = [] spawn {while {sleep 1.0; true} do {tskchase setSimpleTaskDestination (getPos car1)};};
tskchase settaskstate "assigned"; player setcurrenttask tskchase; taskhint ["Chase the 2nd in command", [1,1,1,1], "taskcurrent"]; 
taskhint ["Chase the second in command", [1,1,1,1], "taskcurrent"];

Hope this has helped, pls reply if any more help is needed.

Share this post


Link to post
Share on other sites

AWESOME!

this is what I needed! just one question.

If I change the sleep time from 1.0 to 0.1 will it cause lag or something? (its a 4 player co-op mission) it will only be active for about a minute, and i like the fluid look it has

0 = [] spawn {while {sleep 0.1; true} do {tskobj_2 setSimpleTaskDestination (getPos c1)};};

EDIT:

also now that I read more closely, if its 4 player map i need to write a .sqf file for it? putting the above in a trigger activated by c1 wont set a waypoint for all four players?

Edited by BLQQD

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  

×