Jump to content

[Release] Mining for Epoch Origins


Recommended Posts

Hi guys,

 

haven't release anything till now but found already a lot of useful stuff. Epoch has a great community and I would like to give a bit back :-)

This release is a small mining system I wrote yesterday. I did not spent time looking at existing mining scripts so maybe it equals others...

 

Anyway, let's start.

mission.sqm

class Mission {
    ...
    class Sensors {
        items=27;
        ...
	class Item24 {
            position[]={8331.79,0,8908.07};
            activationBy="WEST";
            repeating=1;
            interruptible=1;
            age="UNKNOWN";
            name="mineA";
            expCond="(player distance mineA) < 2;";
            expActiv="DZE_MiningWest=true;";
            expDesactiv="DZE_MiningWest=false;";
            class Effects {};
        };
        class Item25 {
            position[]={8343.87,0,8920.31};
            activationBy="WEST";
            repeating=1;
            interruptible=1;
            age="UNKNOWN";
            name="mineB";
            expCond="(player distance mineB) < 2;";
            expActiv="DZE_MiningWest=true;";
            expDesactiv="DZE_MiningWest=false;";
            class Effects {};
        };
        class Item26 {
            position[]={17382.6,0,8062.4};
            activationBy="WEST";
            repeating=1;
            interruptible=1;
            age="UNKNOWN";
            name="mineC";
            expCond="(player distance mineC) < 3;";
            expActiv="DZE_MiningEast=true;";
            expDesactiv="DZE_MiningEast=false;";
            class Effects {};
        };
    };
    ...

Keep in mind that ItemXX should be the next following number so if the last entry was 23 then 24 as start would be correct. Do not forget to set Items to the right value. Correct is the number from the last ItemXX entry + 1 (because Item starts counting with 0).

 

Create custom/mining.sqf

waitUntil{!isNull player};

handle_fired = {
	if (!((_this select 1) == "MeleeSledge")) exitWith {};
	_player = (_this select 0);
	_dir = round(getDir _player);
	_doProcessing = false;
	if (DZE_MiningWest) then {
		if (_dir > 80 && _dir < 180) then {
			_doProcessing = true;
		};
	} else {
		if (_dir > 50 && _dir < 150) then {
			_doProcessing = true;
		};
	};
	// do magic
	if (_doProcessing) then {
		// todo add pickaxe sound if you want
		_return = "";
		if ((random 10) <= 2) then {
			_ores = ["PartOre","PartOreSilver","PartOreSilver","PartOre","PartOreGold","PartOreSilver","","PartOre","PartOre","PartOre"];
			_return = _ores call BIS_fnc_selectRandom;
			if (_return == "" && (random 10) <= 1) then {
				_gems = ["ItemTopaz","ItemObsidian","ItemSapphire","ItemAmethyst","ItemEmerald","ItemCitrine","ItemRuby"];
				_return = _gems call BIS_fnc_selectRandom;
			};
			if (_return != "") then {
				_pos = getPosATL _player;
				if (_pos select 2 < 0) then {
					_pos set [2,0];
				};
				_radius = 1;
				// find closest WeaponHolder
				_item = nearestObject[_player,"WeaponHolder"];
				if (!(isNull _item)) then {
					if ((_player distance _item) > 1) then {
						_item = objNull;
					};
				};
				if (isNull _item) then {
					_item = createVehicle ["WeaponHolder", _pos, [], _radius, "CAN_COLLIDE"];
					_item setposATL _pos;
				};
				_text =	getText (configFile >> "CfgMagazines" >>_return >> "displayName");
				cutText [format ["You have discovered a %1",_text], "PLAIN DOWN"];
				_item addMagazineCargoGlobal[_return,1];
				_player reveal _item;
			} else {
				// lets have a small chance to break the hammer
				if ((random 10) <= 1) then {
					cutText ["Oups, this was your sledge hammer :-/", "PLAIN DOWN"];
					[_player,"MeleeSledge",1] call BIS_fnc_invRemove;
					// todo add broken sound
				};
			};
		};
	};
};

while {alive Player} do {
	waitUntil{DZE_MiningEast||DZE_MiningWest};
	if (isNil "min_firedEH") then {
		min_firedEH = 0;
		sleep 0.025;
		min_firedEH = player addEventHandler ["Fired",{
			[_this select 0, _this select 1] call handle_fired;
		}];
	};
	waitUntil{!DZE_MiningEast && !DZE_MiningWest};
	player removeEventHandler ["Fired", min_firedEH];
	min_firedEH = nil;
	sleep 1;
};

Open init.sqf and add the following code. The variables could also be added in variables.sqf if you have a custom one already. Just make sure they are initialized very early!

...
DZE_MiningEast = false;
DZE_MiningWest = false;
if (!isDedicated) then {
   ...
   [] execVM "custom\mining.sqf";
};
...

This should be it. I am probably not as good as others when it comes to releases so if you have trouble I will try to help :-).

 

Ah about how it should work...

Go to 173170 or 083161. Use your sledge hammer and hit the door. You need to be kind of close to it and look into the right direction. From time to time you will gain ore's and sometimes even jewels. I tried to make the chance not to high. At least for my server this settings are OK.

 

Regards,

SuluHuntsmen

Link to comment
Share on other sites

  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...