forked from Mirrors/openclonk
make sure all items use the RejectUse callback
parent
30a70d9e3e
commit
77e8d77921
|
@ -15,6 +15,13 @@ func Hit()
|
|||
Sound("GeneralHit?");
|
||||
}
|
||||
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
// Duplicate check from Clonk::Bridge. This was done instead of an additional CanBridge callback in the Clonk because that would most likely stay the only usecase of that callback.
|
||||
var proc = clonk->GetProcedure();
|
||||
return (proc != "WALK") && (proc != "SCALE");
|
||||
}
|
||||
|
||||
// Item activation
|
||||
func ControlUseStart(object clonk, int x, int y)
|
||||
{
|
||||
|
|
|
@ -5,20 +5,30 @@
|
|||
For planting wheat or to get flour
|
||||
*/
|
||||
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
// General inability?
|
||||
if(clonk->GetProcedure() != "WALK") return true;
|
||||
if (GBackSemiSolid(0, 0)) return true;
|
||||
/*
|
||||
This check might make sense, so that you can just hold the button and walk over the ground until the soil is fitting.
|
||||
However, you would never get the $NoSuitableGround$ message in that case.
|
||||
// Check soil below the Clonk's feet
|
||||
var ground_y = clonk->GetDefBottom() - clonk->GetY() + 1;
|
||||
if (GetMaterialVal("Soil", "Material", GetMaterial(0, ground_y)) == 0) return true;
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
public func ControlUse(object clonk, int x, int y, bool box)
|
||||
{
|
||||
if(clonk->GetAction() != "Walk") return true;
|
||||
// Search for ground
|
||||
x = 0; y = 0;
|
||||
if (GBackSemiSolid(x,y)) return true;
|
||||
var i = 0;
|
||||
while (!GBackSolid(x,y) && i < 15) { ++y; ++i; }
|
||||
if (!GBackSolid(x,y)) return true;
|
||||
if (GetMaterialVal("Soil", "Material", GetMaterial(x,y)) == 1)
|
||||
var ground_y = clonk->GetDefBottom() - clonk->GetY() + 1;
|
||||
|
||||
if (GetMaterialVal("Soil", "Material", GetMaterial(0, ground_y)) == 1)
|
||||
{
|
||||
// Plant!
|
||||
clonk->DoKneel();
|
||||
CreateObjectAbove(Wheat, x, y, clonk->GetOwner())->SetCon(1);
|
||||
CreateObjectAbove(Wheat, 0, ground_y, clonk->GetOwner())->SetCon(1);
|
||||
RemoveObject();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -2,9 +2,14 @@
|
|||
|
||||
local user;
|
||||
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
// Disallow if directly above ground or water or if the Clonk is already holding onto something.
|
||||
return GBackSemiSolid(0,15) || clonk->GetActionTarget() != nil;
|
||||
}
|
||||
|
||||
func ControlUseStart(object clonk, int ix, int iy)
|
||||
{
|
||||
if(GBackSolid(0,15) || GBackLiquid(0,15) || clonk->GetActionTarget() != nil) return 1;
|
||||
var balloon = CreateObjectAbove(BalloonDeployed,0,5);
|
||||
balloon->SetSpeed(clonk->GetXDir(),clonk->GetYDir());
|
||||
|
||||
|
|
|
@ -82,20 +82,20 @@ func ControlJump(object clonk)
|
|||
return true;
|
||||
}
|
||||
|
||||
func ControlUseStart(object clonk, int x, int y)
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
// forward control to item
|
||||
if(clonk->GetProcedure()=="ATTACH") return false;
|
||||
// If the Clonk is on the boompack, we won't stop the command here, but forward it later.
|
||||
if (clonk->GetProcedure() == "ATTACH") return false;
|
||||
// Only allow during walking or jumping.
|
||||
return clonk->GetProcedure() != "WALK" && clonk->GetProcedure() != "FLIGHT";
|
||||
}
|
||||
|
||||
|
||||
func ControlUse(object clonk, int x, int y)
|
||||
{
|
||||
// forward control to item
|
||||
if(clonk->GetProcedure()=="ATTACH") return false;
|
||||
|
||||
// only use during walk or jump
|
||||
if(clonk->GetProcedure()!="WALK" && clonk->GetProcedure()!="FLIGHT") return true;
|
||||
|
||||
var angle=Angle(0,0,x,y);
|
||||
Launch(angle,clonk);
|
||||
|
||||
|
|
|
@ -18,6 +18,11 @@ public func GetCarryTransform()
|
|||
return Trans_Mul(Trans_Rotate(-90, 0, 0, 1), Trans_Translate(-4000,3500));
|
||||
}
|
||||
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
return !clonk->HasHandAction();
|
||||
}
|
||||
|
||||
public func ControlUse(object clonk, int iX, int iY)
|
||||
{
|
||||
var angle = Angle(0,0,iX,iY);
|
||||
|
@ -37,17 +42,14 @@ public func ControlUse(object clonk, int iX, int iY)
|
|||
// otherwise try to fill bucket
|
||||
if(GBackSolid(x2,y2))
|
||||
{
|
||||
if (clonk->HasHandAction())
|
||||
{
|
||||
var mat = GetMaterial(x2,y2);
|
||||
var mat = GetMaterial(x2,y2);
|
||||
|
||||
if(GetMaterialVal("DigFree","Material",mat))
|
||||
{
|
||||
Sound("SoftTouch2");
|
||||
var amount = DigFree(GetX()+x2,GetY()+y2,5, true);
|
||||
FillBucket(mat, amount);
|
||||
PlayAnimation(clonk);
|
||||
}
|
||||
if(GetMaterialVal("DigFree","Material",mat))
|
||||
{
|
||||
Sound("SoftTouch2");
|
||||
var amount = DigFree(GetX()+x2,GetY()+y2,5, true);
|
||||
FillBucket(mat, amount);
|
||||
PlayAnimation(clonk);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -34,9 +34,13 @@ local ParticleCount;
|
|||
|
||||
local grabber;
|
||||
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
return !clonk->GetContact(-1);
|
||||
}
|
||||
|
||||
public func ControlUse(object clonk, int x, int y)
|
||||
{
|
||||
if(!clonk->GetContact(-1)) return true;
|
||||
// Unroll dir
|
||||
var dir = -1;
|
||||
if(x > 0) dir = 1;
|
||||
|
|
|
@ -35,11 +35,13 @@ public func IsToolProduct() { return true; }
|
|||
|
||||
/*-- Usage --*/
|
||||
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
return !clonk->HasHandAction();
|
||||
}
|
||||
|
||||
public func ControlUse(object clonk)
|
||||
{
|
||||
// Only do something if the clonk can do an action.
|
||||
if (!clonk->HasHandAction())
|
||||
return true;
|
||||
// Attach the torch if the clonk stands in front of tunnel material.
|
||||
if (GetMaterial() == Material("Tunnel"))
|
||||
{
|
||||
|
|
|
@ -60,15 +60,13 @@ local MuzzleUp; local MuzzleFront; local MuzzleDown; local MuzzleOffset;
|
|||
|
||||
protected func HoldingEnabled() { return true; }
|
||||
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
return !clonk->HasHandAction();
|
||||
}
|
||||
|
||||
func ControlUseStart(object clonk, int x, int y)
|
||||
{
|
||||
// if the clonk doesn't have an action where he can use it's hands do nothing
|
||||
if(!clonk->HasHandAction())
|
||||
{
|
||||
holding = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// nothing in extraslot?
|
||||
if(!Contents(0))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue