Jump to content
Sign in to follow this  
lkincheloe

Procedually spawning loot on clearing EOS Marker issue

Recommended Posts

Hey there,

I'm currently working on a mission using the EOS script pack, and as part of it I want to spawn various items as a reward for clearing individual AOs out. But instead of doing a trigger for each marker I'm trying to hook into the EOS script itself to get when a marker is "cleared" (turns green), and then spawning the goodies based on the marker's name.

At the moment here is how I have it set up: In EOS, at the part where it turns the marker green (debug Zone Captured), I have a global variable set to take the contents of _mkr in order to port it into my script, which I have on call with preprocessFileLineNumbers in openMe.sqf. The script I've made to spawn the loot is based loosely upon a concept Kylania made, here's a copy of my script and the changes made to the EOS_Core script:

EOS_Core:

else{
	_mkr setmarkercolor VictoryColor;
	_mkr setmarkerAlpha _mAN;
	lootVariableTest = _mkr;
	call Kinch_LootReward;
	if (_debug) then {hint "Zone Captured";};
};

My Script:

if (!isServer) exitWith {};

_MarkerName = lootVariableTest;

// Prepare Variables
private ["_MarkerName","_rewardBasic","_rewardCommon","_rewardMedium","_rewardRare","_rewardAir","_chance","_prob","_box","_lootMarker","_villageMarker","_townMarker","_towerMarker","_baseMarker","_airfieldMarker","_cityMarker","_BasicLoot","_CommonLoot","_MediumLoot","_RareLoo

t","_AirLoot"];

// Array of Markers/AOs
_villageMarker = ["village_1_1","village_1_2","village_1_3","village_1_4","village_2_1","village_2_2","village_2_3","village_2_4","village_2_5","village_2_6","village_2_7","village_2_8","village_3_1","village_3_2","village_3_3","village_3_4"];
_townMarker = ["town_1_1","town_1_2","town_1_3","town_1_4","town_1_5","town_1_6","town_1_7","town_2_1","town_2_2","town_2_3"];
_towerMarker = ["tower_1","tower_2","tower_3"];
_baseMarker = ["base_1_1","base_1_2","base_1_3","base_1_4","base_1_5"];
_airfieldMarker = ["airfield_1_1","airfield_1_2","airfield_1_3","airfield_1_4","airfield_1_5","airfield_1_6"];
_cityMarker = ["city_1","city_2","city_3"];

// Array of loot
_BasicLoot = ["Box_Ind_Ammo_F","B_G_Offroad_01_F"];
_CommonLoot = ["Box_IND_Wps_F","IG_SupplyCrate_F","I_MRAP_03_F",I_Truck_02_covered_f","B_G_Offroad_01_armed_F","Box_IND_Grenades_F","I_HMG_01_high_F"];
_MediumLoot = ["Box_NATO_Wps_F","Box_IND_WpsLaunch_F","I_MRAP_03_hmg_F","B_G_Mortar_01_F","I_GMG_01_high_F"];
_RareLoot = ["Box_NATO_WpsSpecial_F","Box_IND_WpsSpecial_F","Box_East_WpsSpecial_F","I_APC_Wheeled_03_cannon_F","B_APC_Tracked_01_CRV_F","I_MRAP_03_gmg_F"];
_AirLoot = ["B_Heli_Light_01_F","B_Heli_Light_01_armed_F","I_Plane_Fighter_03_CAS_F"];

{
// Determine what type of AO we have
	if _MarkerName == _villageMarker then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName};

	if _MarkerName == _townMarker then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
	_rewardCommon = _CommonLoot select floor(random count _CommonLoot) createVehicle getMarkerPos _MarkerName;
	};

	if _MarkerName == _towerMarker then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
	};

	if _MarkerName == _baseMarker then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
	_rewardCommon = _CommonLoot select floor(random count _CommonLoot) createVehicle getMarkerPos _MarkerName;
	_rewardMedium = _MediumLoot select floor(random count _MediumLoot) createVehicle getMarkerPos _MarkerName;
	_rewardRare = _RareLoot select floor(random count _RareLoot) createVehicle getMarkerPos _MarkerName;
	};

	if _MarkerName == _airfieldMarker then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
	_rewardCommon = _CommonLoot select floor(random count _CommonLoot) createVehicle getMarkerPos _MarkerName;
	_rewardMedium = _MediumLoot select floor(random count _MediumLoot) createVehicle getMarkerPos _MarkerName;
	_rewardAir = _AirLoot select floor(random count _AirLoot) createVehicle getMarkerPos _MarkerName;
	};
};

However when I clear out the markers, the debug message in Core fires but nothing spawns. Would anybody be able to provide suggestions for making this work?

Share this post


Link to post
Share on other sites

hi LKincheloe,

first this should be put in MISSION EDITING & SCRIPTING, maybe ask a mod about moving it.

Now to your script. :)

The first part in EOS_Core is technically ok but cleaner would be

else{
	_mkr setmarkercolor VictoryColor;
	_mkr setmarkerAlpha _mAN;
	0 = [_mkr] call Kinch_LootReward;
	if (_debug) then {hint "Zone Captured";};
};

in the second part you try to validate an STRING variable with an ARRAY and wherefore should use "in" instead of "==", as they are not the same.

// Prepare Variables
private ["_MarkerName","_rewardBasic","_rewardCommon","_rewardMedium","_rewardRare","_rewardAir","_chance","_prob","_box","_lootMarker","_villageMarker","_townMarker","_towerMarker","_baseMarker","_airfieldMarker","_cityMarker","_BasicLoot","_CommonLoot","_MediumLoot","_RareLoot","_AirLoot"];

_MarkerName = _this select 0;

// Array of Markers/AOs
_villageMarker = ["village_1_1","village_1_2","village_1_3","village_1_4","village_2_1","village_2_2","village_2_3","village_2_4","village_2_5","village_2_6","village_2_7","village_2_8","village_3_1","village_3_2","village_3_3","village_3_4"];
_townMarker = ["town_1_1","town_1_2","town_1_3","town_1_4","town_1_5","town_1_6","town_1_7","town_2_1","town_2_2","town_2_3"];
_towerMarker = ["tower_1","tower_2","tower_3"];
_baseMarker = ["base_1_1","base_1_2","base_1_3","base_1_4","base_1_5"];
_airfieldMarker = ["airfield_1_1","airfield_1_2","airfield_1_3","airfield_1_4","airfield_1_5","airfield_1_6"];
_cityMarker = ["city_1","city_2","city_3"];

// Array of loot
_BasicLoot = ["Box_Ind_Ammo_F","B_G_Offroad_01_F"];
_CommonLoot = ["Box_IND_Wps_F","IG_SupplyCrate_F","I_MRAP_03_F",I_Truck_02_covered_f","B_G_Offroad_01_armed_F","Box_IND_Grenades_F","I_HMG_01_high_F"];
_MediumLoot = ["Box_NATO_Wps_F","Box_IND_WpsLaunch_F","I_MRAP_03_hmg_F","B_G_Mortar_01_F","I_GMG_01_high_F"];
_RareLoot = ["Box_NATO_WpsSpecial_F","Box_IND_WpsSpecial_F","Box_East_WpsSpecial_F","I_APC_Wheeled_03_cannon_F","B_APC_Tracked_01_CRV_F","I_MRAP_03_gmg_F"];
_AirLoot = ["B_Heli_Light_01_F","B_Heli_Light_01_armed_F","I_Plane_Fighter_03_CAS_F"];

{
// Determine what type of AO we have
	if (_MarkerName in _villageMarker) then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName};

	if (_MarkerName in _townMarker) then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
	_rewardCommon = _CommonLoot select floor(random count _CommonLoot) createVehicle getMarkerPos _MarkerName;
	};

	if (_MarkerName in _towerMarker) then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
	};

	if (_MarkerName in _baseMarker) then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
	_rewardCommon = _CommonLoot select floor(random count _CommonLoot) createVehicle getMarkerPos _MarkerName;
	_rewardMedium = _MediumLoot select floor(random count _MediumLoot) createVehicle getMarkerPos _MarkerName;
	_rewardRare = _RareLoot select floor(random count _RareLoot) createVehicle getMarkerPos _MarkerName;
	};

	if (_MarkerName in _airfieldMarker) then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
	_rewardCommon = _CommonLoot select floor(random count _CommonLoot) createVehicle getMarkerPos _MarkerName;
	_rewardMedium = _MediumLoot select floor(random count _MediumLoot) createVehicle getMarkerPos _MarkerName;
	_rewardAir = _AirLoot select floor(random count _AirLoot) createVehicle getMarkerPos _MarkerName;
	};
};

for a list with all commands with examples look here:https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3

greetings Na_Palm

Edited by Na_Palm
typo

Share this post


Link to post
Share on other sites

Hey Na_palm,

I have no idea how this ended up in user missions, I'm pretty sure I originally posted to mission and script editing. Oh well, could a mod move this back please?

Made the changes you suggested, still nothing. I checked to make sure the call was going through by substituting the script, that works.

I'm thinking it's going wrong either because it can't resolve the marker type or the actual marker name isn't transferring over so all the equations return a nil value for _MarkerName. I'm not seeing anything in the .rpt file that would point the way.

Here's where I'm at with lootReward.sqf after your changes and further revisions to bring it closer to the Kylania example:

_MarkerName = _this select 0;

// Array of Markers/AOs
_villageMarker = ["village_1_1","village_1_2","village_1_3","village_1_4","village_2_1","village_2_2","village_2_3","village_2_4","village_2_5","village_2_6","village_2_7","village_2_8","village_3_1","village_3_2","village_3_3","village_3_4"];
_townMarker = ["town_1_1","town_1_2","town_1_3","town_1_4","town_1_5","town_1_6","town_1_7","town_2_1","town_2_2","town_2_3"];
_towerMarker = ["tower_1","tower_2","tower_3"];
_baseMarker = ["base_1_1","base_1_2","base_1_3","base_1_4","base_1_5"];
_airfieldMarker = ["airfield_1_1","airfield_1_2","airfield_1_3","airfield_1_4","airfield_1_5","airfield_1_6"];
_cityMarker = ["city_1","city_2","city_3"];

// Array of loot
_BasicLoot = ["Box_Ind_Ammo_F","B_G_Offroad_01_F"];
_CommonLoot = ["Box_IND_Wps_F","IG_SupplyCrate_F","I_MRAP_03_F","I_Truck_02_covered_f","B_G_Offroad_01_armed_F","Box_IND_Grenades_F","I_HMG_01_high_F"];
_MediumLoot = ["Box_NATO_Wps_F","Box_IND_WpsLaunch_F","I_MRAP_03_hmg_F","B_G_Mortar_01_F","I_GMG_01_high_F"];
_RareLoot = ["Box_NATO_WpsSpecial_F","Box_IND_WpsSpecial_F","Box_East_WpsSpecial_F","I_APC_Wheeled_03_cannon_F","B_APC_Tracked_01_CRV_F","I_MRAP_03_gmg_F"];
_AirLoot = ["B_Heli_Light_01_F","B_Heli_Light_01_armed_F","I_Plane_Fighter_03_CAS_F"];

// Prepare Variables
private ["_rewardBasic","_rewardCommon","_rewardMedium","_rewardRare","_rewardAir"];

if (isServer) then {
// Determine what type of AO we have
	if (_MarkerName in _villageMarker) then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName};

	else if (_MarkerName in _townMarker) then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
	_rewardCommon = _CommonLoot select floor(random count _CommonLoot) createVehicle getMarkerPos _MarkerName;
	};

	else if (_MarkerName in _towerMarker) then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
	};

	else if (_MarkerName in _baseMarker) then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
	_rewardCommon = _CommonLoot select floor(random count _CommonLoot) createVehicle getMarkerPos _MarkerName;
	_rewardMedium = _MediumLoot select floor(random count _MediumLoot) createVehicle getMarkerPos _MarkerName;
	_rewardRare = _RareLoot select floor(random count _RareLoot) createVehicle getMarkerPos _MarkerName;
	};

	else if (_MarkerName in _airfieldMarker) then {
	_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
	_rewardCommon = _CommonLoot select floor(random count _CommonLoot) createVehicle getMarkerPos _MarkerName;
	_rewardMedium = _MediumLoot select floor(random count _MediumLoot) createVehicle getMarkerPos _MarkerName;
	_rewardAir = _AirLoot select floor(random count _AirLoot) createVehicle getMarkerPos _MarkerName;
	};
	else then {PLAYER SIDECHAT "I have no idea what kind of marker this is.";
};

Share this post


Link to post
Share on other sites

if it is for SP try:

hint format["%1", _MarkerName];

for MP:

diag_log format["%1", _MarkerName];

directly under:

_MarkerName = _this select 0;

so you can see whats in variable _MarkerName.

Share this post


Link to post
Share on other sites

Made a little progress on this, I rewrote it to use switch do cases instead of the "if" thing. Now it works, if a little too well. Now it won't stop spawning stuff!

So now I need some system to turn the spigot off once I've got the goods spawned in, at the moment I'm thinking of adding it to an array where nothing spawns (so if the AO were to flip back to red, it can't spawn more stuff when re-cleared) and remove the marker from it's respective type array. The only thing I need to work out is if I can get away with one array to hold all the green markers or if I need an array for each type again.

As usual, the current revision of lootReward:

// Array of Markers/AOs
_villageMarker = ["village_1_1","village_1_2","village_1_3","village_1_4","village_2_1","village_2_2","village_2_3","village_2_4","village_2_5","village_2_6","village_2_7","village_2_8","village_3_1","village_3_2","village_3_3","village_3_4"];
_townMarker = ["town_1_1","town_1_2","town_1_3","town_1_4","town_1_5","town_1_6","town_1_7","town_2_1","town_2_2","town_2_3"];
_towerMarker = ["tower_1","tower_2","tower_3"];
_baseMarker = ["base_1_1","base_1_2","base_1_3","base_1_4","base_1_5"];
_airfieldMarker = ["airfield_1_1","airfield_1_2","airfield_1_3","airfield_1_4","airfield_1_5","airfield_1_6"];
_cityMarker = ["city_1","city_2","city_3"];

// Array of loot
_BasicLoot = ["Box_Ind_Ammo_F","B_G_Offroad_01_F"];
_CommonLoot = ["Box_IND_Wps_F","IG_SupplyCrate_F","I_MRAP_03_F","I_Truck_02_covered_f","B_G_Offroad_01_armed_F","Box_IND_Grenades_F","I_HMG_01_high_F"];
_MediumLoot = ["Box_NATO_Wps_F","Box_IND_WpsLaunch_F","I_MRAP_03_hmg_F","B_G_Mortar_01_F","I_GMG_01_high_F"];
_RareLoot = ["Box_NATO_WpsSpecial_F","Box_IND_WpsSpecial_F","Box_East_WpsSpecial_F","I_APC_Wheeled_03_cannon_F","B_APC_Tracked_01_CRV_F","I_MRAP_03_gmg_F"];
_AirLoot = ["B_Heli_Light_01_F","B_Heli_Light_01_armed_F","I_Plane_Fighter_03_CAS_F"];

_MarkerName = _this select 0;

// Determine what type of AO we have
if (isServer) then {
switch (true) do {
	case (_MarkerName in _villageMarker):
		{_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName};

	case (_MarkerName in _townMarker):
		{_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
		_rewardCommon = _CommonLoot select floor(random count _CommonLoot) createVehicle getMarkerPos _MarkerName};

	case (_MarkerName in _towerMarker):
		{_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName};

	case (_MarkerName in _baseMarker):
		{_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
		_rewardCommon = _CommonLoot select floor(random count _CommonLoot) createVehicle getMarkerPos _MarkerName;
		_rewardMedium = _MediumLoot select floor(random count _MediumLoot) createVehicle getMarkerPos _MarkerName;
		_rewardRare = _RareLoot select floor(random count _RareLoot) createVehicle getMarkerPos _MarkerName};

	case (_MarkerName in _airfieldMarker):
		{_rewardBasic = _BasicLoot select floor(random count _BasicLoot) createVehicle getMarkerPos _MarkerName;
		_rewardCommon = _CommonLoot select floor(random count _CommonLoot) createVehicle getMarkerPos _MarkerName;
		_rewardMedium = _MediumLoot select floor(random count _MediumLoot) createVehicle getMarkerPos _MarkerName;
		_rewardAir = _AirLoot select floor(random count _AirLoot) createVehicle getMarkerPos _MarkerName};
	};
};

Share this post


Link to post
Share on other sites

If it's all the desired stuff it spawns for you, try to make a global var of type BOOL and, initialise it with "false", change it to "true" if the condition for spawning is met and check it before you fire the script.

In this way the script will only run once.

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  

×