Jump to content
  • 0

Adding pumpkin and sunflower fields


Schultz

Question

Hello,

 

I was trying to set up additional pumpkin and sunflower fields for the players to harvest.

 

I did it by placing an additional .sqf in the server files, the problem is that the harvesting doesn't work with additional plants!

 

The code is like this:

_bldObj_124 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_p_Helianthus", [839.17688, 5410.8218, -1.5258789e-005], [], 0, "CAN_COLLIDE"];
  _bldObj_124 = _this;
  _this setDir 25.792568;
  _this setPos [839.17688, 5410.8218, -1.5258789e-005];
};

I also tried this:

_vehicle_127 = objNull;
if (true) then
{
  _this = createVehicle ["MAP_p_Helianthus", [839.28632, 5408.5059], [], 0, "CAN_COLLIDE"];
  _vehicle_127 = _this;
  _this setDir 45.481831;
  _this setPos [839.28632, 5408.5059];
};

but everytime the game says that I need to be close to a plant to harvest it.

 

Any clues?

 

And also, how can I spawn fiberplants (weed)? What's the classname? I know the model is p_fiberPlant_EP1.p3d but I looked into the editor and there's no fiberplant. I tried manually adding both p_fiberPlant_EP1 and MAP_p_fiberPlant_EP1 but they don't work.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I have the same question about adding pumpkins.  I'm able to create them with "MAP_pumpkin" and "MAP_pumpkin2", but they are not harvestable.

 

The relevant code seems to use the model names:

 

dayz_code/actions/player_harvestPlant.sqf

// allowed trees list move this later
_trees = ["pumpkin.p3d","p_helianthus.p3d","p_fiberplant_ep1.p3d"];s

Any idea how to add them as harvestable?

Link to comment
Share on other sites

  • 0

Bump for 1.0.3.1 version.

 

Weed vehicle is fiberplant:

_vehicle_63 = objNull;
if (true) then
{
  _this = createVehicle ["fiberplant", [1323.4087, 2361.9385, -0.00018822122], [], 0, "CAN_COLLIDE"];
  _vehicle_63 = _this;
  _this setDir -88.084061;
  _this setPos [1323.4087, 2361.9385, -0.00018822122];
};

I spawn them on the map, but when the player uses his knife it says You must be close to a plant to harvest.
Is this even working ? : _objName = _x call DZE_getModelName; in 1.0.3.1 ?!

 

Because the model is : p_fiberplant_ep1.p3d   but for some reason its not recognized.

 

I know that in 1.0.4.1 there is an array DZE_trees but i dont want to update to 1.0.4.1 yet.

 

 

EDIT: Ok i am spawning my trees from the day_server.pbo like any custom building....but i think the client is not aware of the objects.

I did this in the player_harvestPlant.sqf:

    if("" == typeOf _x) then {
        diag_log format["DEBUG TREES_x: %1", _x];   

and in the log its not returning anything around me...while it does return values when i am next to normal trees.

"DEBUG TREES_x: 531530: t_picea2s.p3d"  <--- when next to tree
"DEBUG TREES: []"                       <--- when next to fiberplant

How can i let the client be aware of objects i am spawning from day_server.pbo ?

I dont want to add these to my mission.pbo...

I thought spawning buildings etc from dayz_server automatically makes the clients aware of the objects....how come i can 'hit' objects and interact with them (doors etc) but its not aware of them with foreach nearestObjects [getPos player, [], 10];

Link to comment
Share on other sites

  • 0

Morning,
did have the same difficulties.
I don't know if you got yourself an answer or not, but i will post my results for others, when needed.
We are talking about the 1.0.4.2 Epoch version now.
 
I came up with an solution, at least for the pumpkins and sunflowers so far.
 
 
@ Sandbird the client is aware of the objects, but the Type of self-added objects, through the editor is NOT empty ( "" ), like it is required for this script!
 
I added a log output bevor the if-condition, too.

diag_log format["DEBUG TREES_x All: %1, Type: %2", _x, typeOf _x];
if("" == typeOf _x) then {
        diag_log format["DEBUG TREES_x Empty Type: %1, Type: %2", _x, typeOf _x];

There you will get something like this, when you are near a self-added sunflower.

"DEBUG TREES_x All: 2c61b200# 979406: p_helianthus.p3d REMOTE, Type: MAP_p_Helianthus"

Here you can see that, the type is not empty, so it won't recognise the sunflower as harvestable plant!
 
So what i did was to simply check not only for empty types, but also for the specific types of the wanted plants.
The full code in the forEach clause from line 21 to 42 is as follows. I marked the newly added or changed lines with a "//NEW" behind the line, or enclosed the clause with it.

scopeName "searchTree";	//NEW
	
diag_log format["DEBUG TREES_x All: %1, Type: %2", _x, typeOf _x];	//NEW
_curType = typeOf _x;	//NEW
	
if("" == _curType) then {	//NEW
	diag_log format["DEBUG TREES_x Empty Type: %1, Type: %2", _x, typeOf _x];	//NEW
	if (alive _x) then {
				
		_objName = _x call DZE_getModelName;

		// Exit since we found a tree
		if (_objName in _trees) then { 	//NEW
			_findNearestTree set [(count _findNearestTree),_x];

			_index = _trees find _objName;

			_itemOut = _treesOutput select _index;

			_countOut = 1; 

			breakOut "searchTree";	//NEW
		};
	};
//NEW
} else {
	if (_curType in _treesTypes) then {
		diag_log format["DEBUG TREES_x Right Type: %1, Type: %2", _x, typeOf _x];
		if (alive _x) then {
			_findNearestTree set [(count _findNearestTree),_x];

			_index = _treesTypes find _curType;

			_itemOut = _treesOutput select _index;

			_countOut = 1; 
				
			breakOut "searchTree";
		};
	};
//NEW
};

The addition of the breakOut commands considering the set namespace is important, because the exitWitch command from default script doesn't work like it should.

The exitWith command did only exit the scope of the if-condition, so the scope one step above, not the forEach loop!

This has the effect, if you harvest a sunflower, which is directly located next to you and also a pumpkin plant is located in a max distance of 10m, the sunflower will be cut off, BUT you will get the pumpkin item!

So the new added breakOut command, will stop the forEach loop, if a proper plant is found.

 

You also need to add the _treeTypes Array above it between the other _trees Arrays.

_trees = ["pumpkin.p3d","p_helianthus.p3d","p_fiberplant_ep1.p3d"];
_treesTypes = ["MAP_pumpkin","MAP_p_Helianthus"];//,"fiberplant"];	//NEW
_treesOutput = ["FoodPumpkin","FoodSunFlowerSeed","ItemKiloHemp"];

The fiberplant is at the moment not included, because there is a problem with it, when harvested.

I explain it at the end of the post.

 

Last step is to change the condition at line 110. Otherwise it won't destroy the plant after harvesting and you could endlessly harvest one plant...

_curType = typeOf _tree;	//NEW
if ("" == _curType or (_curType in _treesTypes)) then {	//NEW
	_tree setDamage 1;
};

Don't forget to add the new added Variables in the private Array at the top!

"_curType","_treesTypes"

 
 
The problem with fiberplant is, when added to the map like above mentioned,

_vehicle_63 = objNull;
if (true) then
{
  _this = createVehicle ["fiberplant", [1323.4087, 2361.9385, -0.00018822122], [], 0, "CAN_COLLIDE"];
  _vehicle_63 = _this;
  _this setDir -88.084061;
  _this setPos [1323.4087, 2361.9385, -0.00018822122];
};

and harvesting it, the script will setDamage to 1 at line 111.

_tree setDamage 1;

The object will crash like a building with the same sound and animation and will probably kill the player, like it did to me, as i tested it.... :D.
 
For pumpkins and sunflowers it is NOT like this, there it works like it should be.

Edited by ABLGDayZ
Link to comment
Share on other sites

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
  • Advertisement
  • Discord

×
×
  • Create New...