forked from Mirrors/openclonk
Reworked tree splitting.
Moved the logic from the axe to the tree library for better handling. Also, dual splitting with two players is effective now (hasn't been before).heavy-resources
parent
a6bb804350
commit
a5b8caab9d
|
@ -238,13 +238,10 @@ func FxIntSplitTimer(object clonk, effect, int time)
|
||||||
|
|
||||||
//Create the woodchip particle
|
//Create the woodchip particle
|
||||||
clonk->CreateParticle("WoodChip", x, 4, PV_Random(-12, 12), PV_Random(-13, -6), PV_Random(36 * 3, 36 * 10), Particles_WoodChip(), 10);
|
clonk->CreateParticle("WoodChip", x, 4, PV_Random(-12, 12), PV_Random(-13, -6), PV_Random(36 * 3, 36 * 10), Particles_WoodChip(), 10);
|
||||||
}
|
|
||||||
// Tree split!
|
// Split tree!
|
||||||
if ((axe_swing_time * 12) / time == 1)
|
effect.tree->Split();
|
||||||
{
|
if (!effect.tree) return -1;
|
||||||
var wood_count = effect.tree->GetComponent(Wood) / 2;
|
|
||||||
CastObjects(Wood, wood_count, 5, AbsX(effect.tree->GetX()), AbsY(effect.tree->GetY()));
|
|
||||||
effect.tree->RemoveObject();
|
|
||||||
}
|
}
|
||||||
//Make sure the clonk does not move
|
//Make sure the clonk does not move
|
||||||
clonk->SetComDir(COMD_Stop);
|
clonk->SetComDir(COMD_Stop);
|
||||||
|
@ -368,7 +365,6 @@ func FxAxeStrikeStopTimer(pTarget, effect)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public func IsTool() { return true; }
|
public func IsTool() { return true; }
|
||||||
public func IsToolProduct() { return true; }
|
public func IsToolProduct() { return true; }
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,12 @@ public func IsStanding()
|
||||||
/** Maximum damage the tree can take before it falls. Each blow from the axe deals 10 damage.
|
/** Maximum damage the tree can take before it falls. Each blow from the axe deals 10 damage.
|
||||||
@return \c the maximum amount of damage.
|
@return \c the maximum amount of damage.
|
||||||
*/
|
*/
|
||||||
private func MaxDamage()
|
func MaxDamage()
|
||||||
{
|
{
|
||||||
return 50;
|
return 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected func Damage()
|
func Damage()
|
||||||
{
|
{
|
||||||
// do not grow for a few seconds
|
// do not grow for a few seconds
|
||||||
var g = GetGrowthValue();
|
var g = GetGrowthValue();
|
||||||
|
@ -123,3 +123,30 @@ func FxTreeFallTimer(object target, proplist effect)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Splitting */
|
||||||
|
|
||||||
|
local split;
|
||||||
|
|
||||||
|
/** Amount of axe strikes needed to split the tree into its components.
|
||||||
|
@return \c the amount of strikes.
|
||||||
|
*/
|
||||||
|
func Toughness()
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Call to add another strike to the split routine.
|
||||||
|
*/
|
||||||
|
func Split()
|
||||||
|
{
|
||||||
|
split++;
|
||||||
|
if (split > Toughness()) SplitDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called when the tree is split using an axe. Default behaviour is Split2Components();
|
||||||
|
*/
|
||||||
|
func SplitDown()
|
||||||
|
{
|
||||||
|
Split2Components();
|
||||||
|
}
|
Loading…
Reference in New Issue