SHOW:
|
|
- or go back to the newest paste.
| 1 | - | //TreeCutter |
| 1 | + | //TreeCutter by HALV |
| 2 | private["_target","_txt","_Radius","_x","_findNearestTree","_i","_objName","_lenInfo","_objInfo","_point","_trees"]; | |
| 3 | _target = _this select 3; | |
| 4 | player removeAction s_Player_ClearTrees; | |
| 5 | _point = getpos _target; //Where to remove trees | |
| 6 | _Radius = 25; //Radius to remove trees | |
| 7 | _trees = ["t_picea2s_snow.p3d","b_corylus.p3d","t_quercus3s.p3d","t_larix3s.p3d","t_pyrus2s.p3d","str_briza_kriva.p3d","dd_borovice.p3d","les_singlestrom_b.p3d","les_singlestrom.p3d","smrk_velky.p3d","smrk_siroky.p3d","smrk_maly.p3d","les_buk.p3d","str krovisko vysoke.p3d","str_fikovnik_ker.p3d","str_fikovnik.p3d","str vrba.p3d","hrusen2.p3d","str dub jiny.p3d","str lipa.p3d","str briza.p3d","p_akat02s.p3d","jablon.p3d","p_buk.p3d","str_topol.p3d","str_topol2.p3d","p_osika.p3d","t_picea3f.p3d","t_picea2s.p3d","t_picea1s.p3d","t_fagus2w.p3d","t_fagus2s.p3d","t_fagus2f.p3d","t_betula1f.p3d","t_betula2f.p3d","t_betula2s.p3d","t_betula2w.p3d","t_alnus2s.p3d","t_acer2s.p3d","t_populus3s.p3d","t_quercus2f.p3d","t_sorbus2s.p3d","t_malus1s.p3d","t_salix2s.p3d","t_picea1s_w.p3d","t_picea2s_w.p3d","t_ficusb2s_ep1.p3d","t_populusb2s_ep1.p3d","t_populusf2s_ep1.p3d","t_amygdalusc2s_ep1.p3d","t_pistacial2s_ep1.p3d","t_pinuse2s_ep1.p3d","t_pinuss3s_ep1.p3d","t_prunuss2s_ep1.p3d","t_pinusn2s.p3d","t_pinusn1s.p3d","t_pinuss2f.p3d","t_poplar2f_dead_pmc.p3d","misc_torzotree_pmc.p3d","misc_burnspruce_pmc.p3d","brg_cocunutpalm8.p3d","brg_umbrella_acacia01b.p3d","brg_jungle_tree_canopy_1.p3d","brg_jungle_tree_canopy_2.p3d","brg_cocunutpalm4.p3d","brg_cocunutpalm3.p3d","palm_01.p3d","palm_02.p3d","palm_03.p3d","palm_04.p3d","palm_09.p3d","palm_10.p3d","brg_cocunutpalm2.p3d","brg_jungle_tree_antiaris.p3d","brg_cocunutpalm1.p3d","str habr.p3d","t_carpinus2s.p3d","t_fraxinus2s.p3d","t_fraxinus2w.p3d","t_larix3f.p3d","t_stub_picea.p3d"]; | |
| 8 | //took this part from epoch | |
| 9 | if (isNil "DZE_getModelName") then {
| |
| 10 | DZE_getModelName = {
| |
| 11 | _objInfo = toArray(str(_this)); | |
| 12 | _lenInfo = count _objInfo - 1; | |
| 13 | _objName = []; | |
| 14 | _i = 0; | |
| 15 | // determine where the object name starts | |
| 16 | {
| |
| 17 | if (58 == _objInfo select _i) exitWith {};
| |
| 18 | _i = _i + 1; | |
| 19 | } forEach _objInfo; | |
| 20 | _i = _i + 2; // skip the ": " part | |
| 21 | for "_k" from _i to _lenInfo do {
| |
| 22 | _objName = _objName + [_objInfo select _k]; | |
| 23 | }; | |
| 24 | _objName = toLower(toString(_objName)); | |
| 25 | _objName | |
| 26 | }; | |
| 27 | }; | |
| 28 | //find array of trees within the radius | |
| 29 | _findNearestTree = []; | |
| 30 | {
| |
| 31 | if("" == typeOf _x) then {
| |
| 32 | if (alive _x) then {
| |
| 33 | _objName = _x call DZE_getModelName; | |
| 34 | if (_objName in _trees) then {
| |
| 35 | _findNearestTree set [(count _findNearestTree),_x]; | |
| 36 | }; | |
| 37 | }; | |
| 38 | }; | |
| 39 | } foreach nearestObjects [_point, [], _Radius]; | |
| 40 | if (_target isKindOf "Air") then {
| |
| 41 | if (count _findNearestTree > 0) then { //Count the trees
| |
| 42 | disableuserinput true; | |
| 43 | player playActionNow "Medic"; //play animation | |
| 44 | [player,"chopwood",0,false] call dayz_zombieSpeak; | |
| 45 | [player,50,true,(getPosATL player)] spawn player_alertZombies; | |
| 46 | sleep 3; | |
| 47 | [player,"chopwood",0,false] call dayz_zombieSpeak; | |
| 48 | [player,50,true,(getPosATL player)] spawn player_alertZombies; | |
| 49 | sleep 3; | |
| 50 | [player,"chopwood",0,false] call dayz_zombieSpeak; | |
| 51 | [player,50,true,(getPosATL player)] spawn player_alertZombies; | |
| 52 | disableuserinput false; | |
| 53 | diag_log ("TreeCutter: Trees found: " + str(count _findNearestTree));
| |
| 54 | {
| |
| 55 | _x setDamage 1; //Set damage to trees so they wont get in the way | |
| 56 | diag_log ("TreeCutter: setDamage to " + str _x);
| |
| 57 | } forEach _findNearestTree; | |
| 58 | diag_log ("TreeCutter: fucked " + str(count _findNearestTree) + " trees");
| |
| 59 | } else {
| |
| 60 | cuttext ["No trees within range!","PLAIN DOWN"]; | |
| 61 | }; | |
| 62 | } else {
| |
| 63 | _txt = (gettext (configFile >> 'CfgVehicles' >> (typeof _target) >> 'displayName')); | |
| 64 | cutText [format["%1 is not an Aircraft!",_txt], "PLAIN DOWN"]; | |
| 65 | }; |