Home   Help Search Login Register  

Author Topic: Saving marker locations in a campaign  (Read 3116 times)

0 Members and 1 Guest are viewing this topic.

Saving marker locations in a campaign
« on: 26 Aug 2011, 23:32:20 »
I've got an idea for a mission that you have to spot targets for artillery/airstrike for a future mission. Where the player must click the map at certain locations where targets are.

But I'm not entirely sure how to save the marker locations so that I can access them in future missions, I don't want to save the location of the actual targets because I want the player to possibly mess the locations up.

Is it possible to save a marker location for access in future missions?

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Saving marker locations in a campaign
« Reply #1 on: 27 Aug 2011, 08:25:06 »
Heya!

Yes, it should be possible. AFAIK, user-placed markers will be named something akin to "USER_DEFINED_#" (with # being based on number of markers already in mission); at least they were in OFP (check out this script: clickety by snYpir). However it's always possible the naming convention will have changed in Arma 2, in which case we're in a bit of a pickle.

Anyway, if you CAN collect the user markers using for instance the script above, it's simple a matter of collecting the info on the marker's pos and saving them in a global var and then loading them in the next mission :) Apparently snYpir's script goes ga-ga if you delete markers though, which I can totally understand.

An easier method, incredibly enough, might actually be to use a onMapSingleClick-based script to create your own markers, which removes the need to collect data about user-made markers. Then you'll have all the info you need already. You could for instance have a radio command, "Report in target positions", which would begin the script (adding an action/radio command "Finish report"). While the script is running it'd monitor onmapsingleclicks, and add those to the target arrays. Handling mis-clicks could be done e.g. through the radio screen as well (remove latest etc.). It'd be a pretty complex script, but I think players of your mission would really appreciate it! And if you get it done, feel free to post it here as well :D

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Re: Saving marker locations in a campaign
« Reply #2 on: 27 Aug 2011, 18:19:32 »
Think the radio/onmapsingleclick is probably the better option, will have to give it a bit of a play around for the most efficient way of doing it including erasing markers...

Thanks for the help will definitely post up the script once I've got it all working.

How do I save the position into a variable? Do I just give the created marker a variable and save that or do I need to save the marker location specifically?

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Saving marker locations in a campaign
« Reply #3 on: 27 Aug 2011, 20:32:28 »
Well, saving the marker data would be elementary, really. HOW exactly you want to do it depends on you. I'd place them in an array inside a global var. Since you're doing it via onMapSingleClick, you really only need to worry about the marker position (not e.g. text, colour, type and so on which would be an issue with player-placed markers). So for example:

Code: [Select]
_entry = getMarkerPos _yourmarkername;

ALWR_SavedMarkers = ALWR_SavedMarkers + [_entry];

...

//End of script

SaveVar "ALWR_SavedMarkers";

Now you can read and recreate those positions in the init.sqf of your next mission easily with something like:

Code: [Select]
{
_newmarker = createMarker [(str _x), _x];
}
foreach ALWR_SavedMarkers;

The only thing there is the name of the marker - above I just used the actual array of numbers and turned it into a string. Not a very pretty marker name, but only the system knows about it anyway, so if you're not planning on using it then you'll be fine. Otherwise, just add some kind of system to it, like a for...do or while...loop that names them via "marker_" + str(_i) or something like that. Or since they're there in the global var anyway, you can always use them from there as well. :)

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Re: Saving marker locations in a campaign
« Reply #4 on: 28 Aug 2011, 00:26:49 »
I get it now, will have to give it a little play to find the best method of doing this though.

Just a quick thought, does ArmA still have a exit.sqs file like OFP had? I think it was called exit.sqs at least and if so would exit.sqf just the .sqf alternative to it?

Cheers

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Saving marker locations in a campaign
« Reply #5 on: 28 Aug 2011, 08:32:53 »
Not sure if that is still in use, I'd imagine yes. But I suggest you do the saving-of-markers in a separate script nonetheless - you don't want the game to shut off right in the middle of everything. Just place down your end trigger and give it a condition like "END_1", and then at the end of your saving-markers-script you add a END_1 = true. That way you can be sure everything is saved before carrying on :)

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Re: Saving marker locations in a campaign
« Reply #6 on: 29 Aug 2011, 11:49:21 »
Yeah will stick to just a normal script to save the variables, apparently too long of an exit.sqs script means only some of it is actually ran.