Jump to content
mons00n

[RELEASE] Random Cache Placement module (RCP)

Recommended Posts

For my upcoming mission I scripted a Random Cache Placement module that allows the user to place an arbitrary number of weapon caches in random house positions throughout a a specified town.

Features:

  • town location & building search radius customizable
  • mission maker can customize the number of caches & their density (distance from one another)
  • markers automatically created for each cache (can be disabled for higher difficulty)
  • ^markers vary in size and are NOT centered on the cache, player must search the marked area
  • ^markers change color when a cache is destroyed
  • caches can only be destroyed by satchel charges
  • BLUFOR/OPFOR score is tracked on the server; once the majority of caches are destroyed the mission ends
  • Scroll wheel menu to check the score
  • tasks automatically created / completed for each side
  • no mod requirements
  • easy add to any mission
  • tested in SP/MP/Dedicated environments

To initialize the module the mission maker needs to place a marker near the town of their choice named "RCP", then add the following line to their init.sqf (see RCP\RCPinit.sqf for further customization options):

_null = [] execVM "RCP\RCPinit.sqf";

Download Module:

Sample Mission "Cachino Royale":

Edited by mons00n

Share this post


Link to post
Share on other sites
Guest

Release frontpaged on the Armaholic homepage.

==================================================

You are not registered on Armaholic, or at least not that we are aware of. Soon we offer the possibility to authors to maintain their own pages.

If you wish to be able to do this as well please register on Armaholic and let me know about it.

This is not mandatory at all! Only if you wish to control your own content you are welcome to join, otherwise we will continue to follow your work like we have always done ;)

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Just one suggestion:

(see RCP\RCPinit.sqf for further customization options):

_null = [] execVM "RCP\RCPinit.sqf";

That [] in front of your execVM will happily carry all the parameters that you've now defined inside your script:

	//DEFAULT VALUES
NCACHES             =   5;  // number of caches to place
_CACHECONCENTRATION =  35;  // how closely spaced should they be?
	_MARKER_R           =  50;  // how large should said markers be?  (0 off)
_RANGE              = 200;  // how far should we search from the center of town?

Using parameters instead allows you to reuse the same script with different settings, without ever having to edit the file. That makes it much more user-friendly.

Also, best avoid using global variables inside scripts, if possible.

This can be very useful for params:

https://community.bistudio.com/wiki/BIS_fnc_param

Share this post


Link to post
Share on other sites
Just one suggestion:

Using parameters instead allows you to reuse the same script with different settings, without ever having to edit the file. That makes it much more user-friendly.

You are correct, but the empty array is for the simplest execution. In the beginning of RCP\RCPinit.sqf I detail how to pass customizations parameters:

// USAGE:
//   Place a marker called "RCP" on your target town.
//   add the following line to your mission's init.sqf:
//   _null = [] execVM "RCP\RCPinit.sqf";
//
// OPTIONAL parameters:
//		           NCACHES - number of caches to place
//		CACHECONCENTRATION - how closely spaced are these caches?
//				  MARKER_R - how large should the cache markers be?
//					 RANGE - how far from the center of town to search for buildings?
//
// EXAMPLE call with optional parameters:
//   _null = [5,50,25] execVM "RCP\RCPinit.sqf";
//
// You do not need to pass all optional parameters, but you must pass them in order.
// For example, if you want to change the marker size via MARKER_R, you must also 
// pass NCACHES & CACHECONCENTRATION as in the above example.  
//
// The default values can also be edited below.

which are read in via:

_npassed = count _this;
if(_npassed > 0) then{NCACHES = _this select 0;};
if(_npassed > 1) then{_CACHECONCENTRATION = _this select 1;};
if(_npassed > 2) then{_MARKER_R = _this select 2;};
if(_npassed > 3) then{_RANGE    = _this select 3;};

Also, best avoid using global variables inside scripts, if possible.

I agree, but since it is used elsewhere in the module I left it as a global var.

This can be very useful for params:

https://community.bistudio.com/wiki/BIS_fnc_param

If you take a quick peek at my sample mission Cachino Royale I have options for all of the RCP parameters =) Thanks for keeping me on point!

Edited by mons00n

Share this post


Link to post
Share on other sites

I want to use this in a COOP mission without Blufor / Opfor scoring etc, how would I do this please?

Share this post


Link to post
Share on other sites
I want to use this in a COOP mission without Blufor / Opfor scoring etc, how would I do this please?

Do you just want the team to destroy all caches in order to win? If so all you need to do is modify the REQUIREDCACHES variable in RCP\RCPinit.sqf to look like so:

REQUIREDCACHES = NCACHES;

If you want to just have it as an objective and not actually end the mission comment out line 73 of RCP\RCPinit.sqf I believe (_null = [] execVM "RCP\victorycondition.sqf").

To get rid of the "Show Score" menu, comment out line 77-80 of RCP\RCPinit.sqf. To get rid of the hint when a cache is blown comment out lines 38-39 in RCP\RCPfuncs.sqf. Let me know if that's what you are looking for!

Share this post


Link to post
Share on other sites

Features:

  • caches can only be destroyed by satchel charges

first, This is something I have been looking for to make a mission for a while. Thank you for this module.

However I have 1 question: Where in the code can I change the requirements to blow the cashe? My community uses a mod that changes how our Explosive Ordinance work and is labeled.

Edited by Zenatsu

Share this post


Link to post
Share on other sites
first, This is something I have been looking for to make a mission for a while. Thank you for this module.

However I have 1 question: Where in the code can I change the requirements to blow the cashe? My community uses a mod that changes how our Explosive Ordinance work and is labeled.

Looks like on lines 68 and 143 of the RCPfuncs.sqf file you can change the classname of the charges that you need to blow the cache, if that's what your looking for?

Share this post


Link to post
Share on other sites

I did change them, but it seems the explosive still dose not trigger the score in the test mission.

I am using AGM, and I'm not sure what it dose to the satchel charges, if it replaces it to a new class name or if they just renamed it.

I also tried disabling the blocks or even removing those to see if it blows, but that didn't work either. An interesting effect happens when i block out the 2 groups of code, is that it dose it proper cook-off, jumps around the Z plane, then resets as if nothing happened. No score is recorded either.

So again, to reiterate, I'm not sure if AGM changes the class name of the satchel or just renames it, but even disabling it doesn't help.

Share this post


Link to post
Share on other sites
Looks like on lines 68 and 143 of the RCPfuncs.sqf file you can change the classname of the charges that you need to blow the cache, if that's what your looking for?
I did change them, but it seems the explosive still dose not trigger the score in the test mission.

I am using AGM, and I'm not sure what it dose to the satchel charges, if it replaces it to a new class name or if they just renamed it.

I also tried disabling the blocks or even removing those to see if it blows, but that didn't work either. An interesting effect happens when i block out the 2 groups of code, is that it dose it proper cook-off, jumps around the Z plane, then resets as if nothing happened. No score is recorded either.

So again, to reiterate, I'm not sure if AGM changes the class name of the satchel or just renames it, but even disabling it doesn't help.

Charges are tricky because they don't really tell who detonated them. You'll have to change the classname in three places actually:

1) in RCPfuncs.sqf where I add the EventHandler, this allows the cache to actually be destroyed:

	if(_this select 4 == "SatchelCharge_Remote_Ammo") then{
		if(_this select 2 > 1) then{
			[[_this select 0],"killcache"] call BIS_fnc_MP;			
		};
		_return = _this select 4;

if you're having trouble identifying the name of your charge, you can add a line before the above if statement to experiment in single player:

player sidechat format["%1",_this select 4];

and upon detonation it should spam some things at you.

2) Next is the trigger condition for each cache in RCPfuncs.sqf :

_trig setTriggerStatements["what = getpos thistrigger nearobjects [""SatchelCharge_Remote_Ammo"",10]; count what > 0;", 
						   format["_null = [%1,thislist] execVM ""RCP\nearestplayer.sqf"";",_unit], ""];

3) Lastly, to properly account for scoring you will need to modify nearestplayer.sqf. This script is executed when the above mentioned trigger is activated and records the nearest player to the cache at the time of planting. The local function you'll need to modify is:

_getNearestSatchel = {
_satchel = getPos _object nearObjects ["SatchelCharge_Remote_Ammo",10];
(_satchel select 0)
};

Let me know how it goes!

Edited by mons00n

Share this post


Link to post
Share on other sites

3) Lastly, to properly account for scoring you will need to modify nearestplayer.sqf. This script is executed when the above mentioned trigger is activated and records the nearest player to the cache at the time of planting. The local function you'll need to modify is:

_getNearestSatchel = {
_satchel = getPos _object nearObjects ["SatchelCharge_Remote_Ammo",10];
(_satchel select 0)
};

Let me know how it goes!

Everything worked besides updating the score. (probably because the charge is labeled "SatchelCharge_Remote_Ammo_scripted" which tells me there probably isn't an actual owner with how AGM handles explosive placement)

But for what I want, I don't need a score board. The markers updated beautifully, which is enough to signify that the cache has been destroyed proper.

Share this post


Link to post
Share on other sites
Everything worked besides updating the score. (probably because the charge is labeled "SatchelCharge_Remote_Ammo_scripted" which tells me there probably isn't an actual owner with how AGM handles explosive placement)

the vanilla charges don't have an owner either unfortunatelly, which is why I had to simply record the nearest player at the time of placement.

But for what I want, I don't need a score board. The markers updated beautifully, which is enough to signify that the cache has been destroyed proper.

good to hear! you can disable the score menu if you'd like via commenting out the following in RCPinit.sqf:

if(!isDedicated) then{
waitUntil {!(isNull player)};
_null = [] execVM "RCP\RCPaddactions.sqf";
};

let me know if I can be of further assistance!

Share this post


Link to post
Share on other sites

Hello. Can you add a function, like in Insurgency missions back in Arma2, with searching for intel that gives you directions to find a cache in coop mission?

  • Like 1

Share this post


Link to post
Share on other sites
Hello. Can you add a function, like in Insurgency missions back in Arma2, with searching for intel that gives you directions to find a cache in coop mission?

+1

Tvt its funny, but i would like to play again insurgency of arma 2 OA in arma 3. I think everyone liked a lot. Nice job with script, im triying to modify to adapt.

Thanks!!!

  • Like 1

Share this post


Link to post
Share on other sites
the vanilla charges don't have an owner either unfortunatelly, which is why I had to simply record the nearest player at the time of placement.

let me know if I can be of further assistance!

I'm doing the same thing with AGM, however I need the score menu to work, any idea how to get it working? The explosive I'm using is DemoCharge_Remote_Ammo_Scripted. The caches can be destroyed and the markers work which I did by replacing SatchelCharge_Remote_Ammo with DemoCharge_Remote_Ammo_Scripted. Thanks!

Share this post


Link to post
Share on other sites

Hey mons00n,

 

nice script you've conjured up. I've managed to remove the points system from my missions since I don't need it, but one particular problem is bothering me.

I want to create markers on the cache locations for opfor only, and hide the markers from blufor. How would I go about this?

 

I know how to hide markers generally, but I can't find what the names of the markers this script creates are, or alternatively the cache names, so I could create the markers on top of them myself, or remove them from Blufor.

 

I tried to put the //cachemarkers code into a if (sidePlayer == east) then {}; and change the "createMarker" to "createMarkerLocal", which works in SP, but I need dedicated support. The if (!isServer) exitWith{}; prevents me from inserting code into this part of your script which would delete markers from all blufor players, but I don't know if I can reference anything in this script outside it.

Share this post


Link to post
Share on other sites

Hello. Can you add a function, like in Insurgency missions back in Arma2, with searching for intel that gives you directions to find a cache in coop mission?

 

 

+1

Tvt its funny, but i would like to play again insurgency of arma 2 OA in arma 3. I think everyone liked a lot. Nice job with script, im triying to modify to adapt.

Thanks!!!

+1 as well!

Share this post


Link to post
Share on other sites

Hi is there anyway I could use this script on Takistan?  For some reason it's not recognizing the houses I believe... 

Share this post


Link to post
Share on other sites

Hello. Can you add a function, like in Insurgency missions back in Arma2, with searching for intel that gives you directions to find a cache in coop mission?

 

any update on this

Share this post


Link to post
Share on other sites
Quote

Hello. Can you add a function, like in Insurgency missions back in Arma2, with searching for intel that gives you directions to find a cache in coop mission?

 

Something about?

 

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

×