Added sickle for harvesting

New callback in the plants library: SickleHarvesting
Set to false to allow harvesting via interact (e.g. Mushroom, Lichen)
stable-5.3
Felix Wagner 2012-10-14 15:43:00 +02:00
parent b851f4b3fa
commit 4235b9f42e
11 changed files with 139 additions and 1 deletions

View File

@ -0,0 +1,15 @@
[DefCore]
id=Sickle
Version=5,2,0,1
Category=C4D_Object
Width=10
Height=7
Offset=-4,-8
Vertices=2
VertexX=-3,3
VertexY=0,0
VertexFriction=50,50
Value=10
Mass=20
Components=Wood=1;Metal=1;
Rotate=1

View File

@ -0,0 +1,42 @@
// sickle genrated by blender2ogre 0.5.8
material sickle
{
receive_shadows on
technique
{
pass sickle
{
ambient 0.800000011920929 0.800000011920929 0.800000011920929 1.0
diffuse 0.6400000190734865 0.6400000190734865 0.6400000190734865 1.0
specular 0.5 0.5 0.5 1.0 12.5
emissive 0.0 0.0 0.0 1.0
alpha_to_coverage off
colour_write on
cull_hardware clockwise
depth_check on
depth_func less_equal
depth_write on
illumination_stage
light_clip_planes off
light_scissor off
lighting on
normalise_normals off
polygon_mode solid
scene_blend one zero
scene_blend_op add
shading gouraud
transparent_sorting on
texture_unit
{
texture sickle.png
tex_address_mode wrap
scale 1.0 1.0
colour_op modulate
}
}
}
}

View File

@ -0,0 +1,64 @@
/**
Sickle
Used for harvesting (wheat, cotton, ...)
@author Clonkonaut
*/
private func Hit()
{
Sound("WoodHit?");
}
public func GetCarryMode() { return CARRY_HandBack; }
public func GetCarryBone() { return "main"; }
public func GetCarryTransform() { return Trans_Rotate(270,0,1,0); }
public func ControlUseStart(object clonk, int x, int y)
{
// Can clonk use the sickle?
if (!clonk->IsWalking() && !clonk->IsJumping())
return true;
// If the clonk doesn't have an action where he can use it's hands do nothing
if (!clonk->HasHandAction())
return true;
var arm = "R";
var carry_bone = "pos_hand2";
if(clonk->GetHandPosByItemPos(clonk->GetItemPos(this)) == 1)
{
arm = "L";
carry_bone = "pos_hand1";
}
var animation = Format("SwordSlash2.%s", arm);
// Figure out the kind of animation to use
var length=15;
if(clonk->IsJumping())
animation = Format("SwordJump2.%s",arm);
clonk->PlayAnimation(animation, 10, Anim_Linear(0, 0, clonk->GetAnimationLength(animation), length, ANIM_Remove), Anim_Const(1000));
clonk->UpdateAttach();
// Search for harvestable plants
var crop = FindObject(Find_InRect(AbsX(clonk->GetX()-8), AbsY(clonk->GetY()-10), 16,20), Find_Func("IsHarvestable"), Find_Func("SickleHarvesting"));
if (crop)
crop->Harvest();
clonk->CancelUse();
return true;
}
public func IsTool() { return true; }
public func IsToolProduct() { return true; }
func Definition(def) {
SetProperty("PictureTransformation", Trans_Mul(Trans_Rotate(15, 0, 1, 0), Trans_Rotate(320, 0,0,1)),def);
}
local Collectible = 1;
local Name = "$Name$";
local Description = "$Description$";
local UsageHelp = "$UsageHelp$";
local Rebuy = true;

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -0,0 +1,3 @@
Name=Sichel
UsageHelp=Halte [Benutzen] gedrückt, um Pflanzen zu ernten.
Description=Die Sichel wird zum Ernten hartnäckiger Pflanzen (wie Weizen und Baumwolle) benötigt.

View File

@ -0,0 +1,3 @@
Name=Sickle
UsageHelp=Hold down the [Use] key to harvest plants.
Description=Without a sickle even a clonk can't harvest especially stubborn plants (such as wheat or cotton).

View File

@ -250,6 +250,15 @@ private func IsCrop()
return false;
}
/** Determines whether the plant can only be harvested when using a sickle.
These are very sturdy or economically important plants (like cotton or wheat).
@return \c true if the plant must be harvested with a sickle (default), \c false otherwise.
*/
private func SickleHarvesting()
{
return true;
}
/** Determines whether the plant is harvestable right now (i.e. is fully grown).
@return \c true if the plant is ready to be harvested.
*/
@ -260,7 +269,7 @@ public func IsHarvestable()
public func IsInteractable(object clonk)
{
return clonk->IsWalking() && IsCrop() && IsHarvestable() || _inherited(clonk);
return clonk->IsWalking() && IsCrop() && !SickleHarvesting() && (IsHarvestable() || _inherited(clonk));
}
public func GetInteractionMetaInfo(object clonk)

View File

@ -7,6 +7,7 @@ local grow_stage;
private func SeedChance() { return 1000; }
private func IsCrop() { return true; }
private func SickleHarvesting() { return false; }
protected func Initialize()
{

View File

@ -22,6 +22,7 @@ private func Initialize()
/* Harvesting */
private func IsCrop() { return true; }
private func SickleHarvesting() { return false; }
public func Harvest(object clonk)
{