Jump to content
Reeveli

Prevent map centering on player at mission start

Recommended Posts

I am making mission where the players don't know where on the map they are starting from. Disabling the center map on player function was easy enough. However there is another problem. Both in the mission briefing screen and after the mission start when the player opens his map for the first time the map starts zoomed in and centered on the player's location. Is there any way of preventing this, like having the map camera focused on an invisible marker somewhere? Any tips will be appreciated.

Share this post


Link to post
Share on other sites

First remove the itemMap from the player's loadout (Editor)

Second, add it in initPlayerLocal.sqf:

 

waitUntil {!visibleMap};

player linkIItem "itemMap";

 

Then, here is a script opening map on origin. You can replace [0,0,0] by any position you want

and add a variable to enable/disable this script: instead of while {true} for example: while {!("ItemGPS" in assigneditems player)}

 

0 = [] spawn {
  while {true} do {
    waitUntil {visibleMap};
    (findDisplay 12 displayCtrl 51) ctrlMapAnimAdd [0, 0.05, [0,0,0]];
    ctrlMapAnimCommit (findDisplay 12 displayCtrl 51);
    waitUntil {!visibleMap};
  };
};

 

  • Like 3

Share this post


Link to post
Share on other sites

To expand on Pierre's example, instead of [0,0,0] for the map's focus point, get the middle of the map with:

[worldSize / 2, worldsize / 2, 0]

 

  • Like 1

Share this post


Link to post
Share on other sites

Make sure you have disabled the player's mapclick waypoint as well, it's not too difficult to figure out your location using it.

Share this post


Link to post
Share on other sites

Alright thank you  I am making progress here. Couple of things:

 

First of all for anyone going for the same thing as I am this is what I use in the initPlayerLocal.sqf:

waitUntil {visibleMap};

player linkItem "itemMap"; 
[]execVM "scripts\Map.sqf";

Notice the difference in {visibleMap}. If you use {!visibleMap} the map is still present in the briefing screen and centered on the player. Reversing the condition makes the briefing a black screen which suits my purposes.

 

Secondly there is a slight problem with Pierre's script. The camera will focus on the specified position every time player opens the map. This will get annoying to the players and is not necessary after the first time map is opened. Doing something like an event handler that the server changes after mission start would terminate this script. But the problem is that any players joining after that would start their maps centered on their location. Anyone have any ideas how to terminate Pierre's script individually for each player after they have opened the map once?

Share this post


Link to post
Share on other sites

One way could be to use a time check in the while condition:

 

 

11 hours ago, pierremgi said:

0 = [] spawn {

  while {time < 1} do {
                  
    waitUntil {visibleMap};
    (findDisplay 12 displayCtrl 51) ctrlMapAnimAdd [0, 0.05, [0,0,0]];
    ctrlMapAnimCommit (findDisplay 12 displayCtrl 51);
    waitUntil {!visibleMap};
  };
};

 

 

Share this post


Link to post
Share on other sites
2 hours ago, Reeveli said:

 

Secondly there is a slight problem with Pierre's script. The camera will focus on the specified position every time player opens the map. This will get annoying to the players and is not necessary after the first time map is opened. Doing something like an event handler that the server changes after mission start would terminate this script. But the problem is that any players joining after that would start their maps centered on their location. Anyone have any ideas how to terminate Pierre's script individually for each player after they have opened the map once?

 

I gave you an alternate solution, breaking the script when your player has got a GPS.

If your aim is purely to see the player's position at the "second time" (seems to me weird because your player can do that without delay), you just have to script:

0 = [] spawn {

  waitUntil {visibleMap};

   (findDisplay 12 displayCtrl 51) ctrlMapAnimAdd [0, 0.05, [0,0,0]];

   ctrlMapAnimCommit (findDisplay 12 displayCtrl 51);

};

Without a loop.

 

The good question is: what do you want exactly? What could be  the "second time", when, on your mind?

 

 

 

Share this post


Link to post
Share on other sites

It would be better to run the code upon button click instead of that nasty while loop. Just need to find the correct IDC, etc then can use a UI EH.

 

EDIT: On second read, I think I am on about second different. The center button in top right of map screen.

  • Like 1

Share this post


Link to post
Share on other sites
28 minutes ago, HazJ said:

It would be better to run the code upon button click instead of that nasty while loop. Just need to find the correct IDC, etc then can use a UI EH.

 

EDIT: On second read, I think I am on about second different. The center button in top right of map screen.

 

This "nasty" while loop seems not supposed to loop for a long time... as far as @Reeveli tell us more about the "second" opening.

You can EH something on each frame... as there is no "map" action, no "map" EH except when you click on it...  I'm sure you're on it. :f:

 

 

 

Share this post


Link to post
Share on other sites
On 10/29/2018 at 3:30 PM, pierremgi said:

I gave you an alternate solution, breaking the script when your player has got a GPS.

Giving the player GPS kind of defeats the point of them not knowing where they are don't you think?

 

Anyway just removing the loop worked just perfect as you suggested.

 

 

Share this post


Link to post
Share on other sites
1 minute ago, Reeveli said:

Giving the player GPS kind of defeats the point of them not knowing where they are don't you think?

 

Anyway just removing the loop worked just perfect as you suggested.

 

 

I think it's up to you to decide when your player(s) can find a GPS and grab it. Player could start without it, as wall as no map, GPS coming in a crate or as reward during the game... but for sure having a GPS is a good moment to know his position. This was an example. I'm not suppose to change your scenario. But, what I don't understand is the fact you just want the player to re-open the map to cease the code. It's immediate and easy.

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

×