forked from Mirrors/openclonk
Allow use of bucket, pickaxe, bow, club, grenade launcher, javelin and musket during scale/hangle.
Temporarily disables scale/hangle during usage of these items.objectmenu
parent
418964f6e8
commit
729712fa2f
|
@ -455,28 +455,36 @@ static const CARRY_Spear = 6;
|
|||
static const CARRY_Musket = 7;
|
||||
static const CARRY_Grappler = 8;
|
||||
|
||||
func HasHandAction(sec, just_wear)
|
||||
func HasHandAction(sec, just_wear, bool force_landscape_letgo)
|
||||
{
|
||||
// Check if the clonk is currently able to use hands
|
||||
// sec: Needs both hands (e.g. CarryHeavy?)
|
||||
// just_wear: ???
|
||||
// force_landscape_letgo: Also allow from actions where hands are currently grabbing the landscape (scale, hangle)
|
||||
if(sec && fBothHanded)
|
||||
return false;
|
||||
if(just_wear)
|
||||
{
|
||||
if( HasActionProcedure() && !fHandAction ) // For wear purpose fHandAction==-1 also blocks
|
||||
if( HasActionProcedure(force_landscape_letgo) && !fHandAction ) // For wear purpose fHandAction==-1 also blocks
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( HasActionProcedure() && (!fHandAction || fHandAction == -1) )
|
||||
if( HasActionProcedure(force_landscape_letgo) && (!fHandAction || fHandAction == -1) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
func HasActionProcedure()
|
||||
func HasActionProcedure(bool force_landscape_letgo)
|
||||
{
|
||||
// Check if the clonk is currently in an action where he could use his hands
|
||||
// if force_landscape_letgo is true, also allow during scale/hangle assuming the clonk will let go
|
||||
var action = GetAction();
|
||||
if (action == "Walk" || action == "Jump" || action == "WallJump" || action == "Kneel" || action == "Ride" || action == "BridgeStand")
|
||||
return true;
|
||||
if (force_landscape_letgo) if (action == "Scale" || action == "Hangle")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public func GetCarryTransform()
|
|||
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
return !clonk->HasHandAction();
|
||||
return !clonk->HasHandAction(false, false, true);
|
||||
}
|
||||
|
||||
public func ControlUse(object clonk, int iX, int iY)
|
||||
|
@ -154,3 +154,4 @@ local Name = "$Name$";
|
|||
local Description = "$Description$";
|
||||
local UsageHelp = "$UsageHelp$";
|
||||
local Collectible = true;
|
||||
local ForceFreeHands = true;
|
|
@ -40,7 +40,8 @@ static const Pickaxe_SwingTime = 40;
|
|||
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
return clonk->GetProcedure() != "WALK";
|
||||
var proc = clonk->GetProcedure();
|
||||
return proc != "WALK" && proc != "SCALE";
|
||||
}
|
||||
|
||||
func ControlUseStart(object clonk, int ix, int iy)
|
||||
|
@ -166,18 +167,6 @@ public func DigOutObject(object obj)
|
|||
clonk->~DigOutObject(obj);
|
||||
}
|
||||
|
||||
public func FxIntPickaxeStart(object clonk, proplist effect, int temp)
|
||||
{
|
||||
if (temp)
|
||||
return FX_OK;
|
||||
// Ensure ActMap is local and writable
|
||||
if (clonk.ActMap == clonk.Prototype.ActMap) clonk.ActMap = new clonk.ActMap {};
|
||||
// Disable scaling during usage.
|
||||
effect.actmap_scale = clonk.ActMap.Scale;
|
||||
clonk.ActMap.Scale = nil;
|
||||
return FX_OK;
|
||||
}
|
||||
|
||||
public func FxIntPickaxeTimer(object clonk, proplist effect, int time)
|
||||
{
|
||||
++swingtime;
|
||||
|
@ -198,15 +187,6 @@ public func FxIntPickaxeTimer(object clonk, proplist effect, int time)
|
|||
clonk->SetYDir(Cos(angle,-speed),100);
|
||||
}
|
||||
|
||||
public func FxIntPickaxeStop(object clonk, proplist effect, int reason, bool temp)
|
||||
{
|
||||
if (temp)
|
||||
return FX_OK;
|
||||
// Reset the clonk scaling entry in its ActMap.
|
||||
clonk.ActMap.Scale = effect.actmap_scale;
|
||||
return FX_OK;
|
||||
}
|
||||
|
||||
protected func ControlUseCancel(object clonk, int ix, int iy)
|
||||
{
|
||||
Reset(clonk);
|
||||
|
@ -248,3 +228,4 @@ local Name = "$Name$";
|
|||
local Description = "$Description$";
|
||||
local UsageHelp = "$UsageHelp$";
|
||||
local MaxPickDensity = 70; // can't pick granite
|
||||
local ForceFreeHands = true;
|
||||
|
|
|
@ -60,7 +60,7 @@ public func GetAnimationSet() { return animation_set; }
|
|||
public func RejectUse(object clonk)
|
||||
{
|
||||
// if the clonk doesn't have an action where he can use it's hands do nothing
|
||||
return !clonk->HasHandAction();
|
||||
return !clonk->HasHandAction(false, false, true);
|
||||
}
|
||||
|
||||
public func ControlUseStart(object clonk, int x, int y)
|
||||
|
@ -233,4 +233,5 @@ local Description = "$Description$";
|
|||
local UsageHelp = "$UsageHelp$";
|
||||
local Collectible = 1;
|
||||
local BlastIncinerate = 30;
|
||||
local ContactIncinerate = 5;
|
||||
local ContactIncinerate = 5;
|
||||
local ForceFreeHands = true;
|
||||
|
|
|
@ -67,7 +67,7 @@ local fAiming;
|
|||
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
return !CanStrikeWithWeapon(clonk) || !clonk->HasHandAction();
|
||||
return !CanStrikeWithWeapon(clonk) || !clonk->HasHandAction(false, false, true);
|
||||
}
|
||||
|
||||
public func ControlUseStart(object clonk, int x, int y)
|
||||
|
@ -99,6 +99,12 @@ public func ControlUseStop(object clonk, ix, iy)
|
|||
return true;
|
||||
}
|
||||
|
||||
public func ControlUseCancel(object clonk, ix, iy)
|
||||
{
|
||||
clonk->StopAim();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Callback from the clonk, when he actually has stopped aiming
|
||||
public func FinishedAiming(object clonk, int angle)
|
||||
{
|
||||
|
@ -245,3 +251,4 @@ local Collectible = 1;
|
|||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
local UsageHelp = "$UsageHelp$";
|
||||
local ForceFreeHands = true;
|
|
@ -65,7 +65,7 @@ protected func HoldingEnabled() { return true; }
|
|||
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
return !clonk->HasHandAction();
|
||||
return !clonk->HasHandAction(false, false, true);
|
||||
}
|
||||
|
||||
func ControlUseStart(object clonk, int x, int y)
|
||||
|
@ -201,4 +201,5 @@ func Definition(def)
|
|||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
local UsageHelp = "$UsageHelp$";
|
||||
local Collectible = 1;
|
||||
local Collectible = 1;
|
||||
local ForceFreeHands = true;
|
|
@ -42,7 +42,7 @@ public func GetCarryTransform() { if(aiming == 1) return Trans_Rotate(180, 0, 0,
|
|||
|
||||
public func RejectUse(object clonk)
|
||||
{
|
||||
return !clonk->HasHandAction();
|
||||
return !clonk->HasHandAction(false, false, true);
|
||||
}
|
||||
|
||||
public func ControlUseStart(object clonk, int x, int y)
|
||||
|
@ -229,3 +229,4 @@ func Definition(def) {
|
|||
local Collectible = 1;
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
local ForceFreeHands = true;
|
||||
|
|
|
@ -62,7 +62,7 @@ protected func HoldingEnabled() { return true; }
|
|||
|
||||
func RejectUse(object clonk)
|
||||
{
|
||||
return !clonk->HasHandAction();
|
||||
return !clonk->HasHandAction(false, false, true);
|
||||
}
|
||||
|
||||
func ControlUseStart(object clonk, int x, int y)
|
||||
|
@ -192,3 +192,4 @@ local Name = "$Name$";
|
|||
local Description = "$Description$";
|
||||
local UsageHelp = "$UsageHelp$";
|
||||
local Collectible = 1;
|
||||
local ForceFreeHands = true;
|
||||
|
|
|
@ -616,6 +616,9 @@ func StartUseControl(int ctrl, int x, int y, object obj)
|
|||
// but still catch command
|
||||
return true;
|
||||
}
|
||||
|
||||
// Disable climb/hangle actions for the duration of this use
|
||||
if (obj.ForceFreeHands && !GetEffect("IntControlFreeHands", this)) AddEffect("IntControlFreeHands", this, 130, 0, this);
|
||||
|
||||
obj->SetController(GetController());
|
||||
this.control.current_object = obj;
|
||||
|
@ -665,6 +668,9 @@ func StartUseDelayedControl(int ctrl, object obj)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Disable climb/hangle actions for the duration of this use
|
||||
if (obj.ForceFreeHands && !GetEffect("IntControlFreeHands", this)) AddEffect("IntControlFreeHands", this, 130, 0, this);
|
||||
|
||||
this.control.current_object = obj;
|
||||
this.control.using_type = DetermineUsageType(obj);
|
||||
this.control.alt = ctrl != CON_UseDelayed;
|
||||
|
@ -718,6 +724,8 @@ func StopUseControl(int x, int y, object obj, bool cancel)
|
|||
if (removal_helper.CommandTarget != this) continue;
|
||||
break;
|
||||
} while (true);
|
||||
|
||||
RemoveEffect("IntControlFreeHands", this); // make sure we can climb again
|
||||
|
||||
this.control.current_object = nil;
|
||||
this.control.using_type = nil;
|
||||
|
@ -918,6 +926,31 @@ func ControlMovement2Script(int ctrl, int x, int y, int strength, bool repeat, b
|
|||
|
||||
}
|
||||
|
||||
// Effect to free/unfree hands by disabling/enabling scale and hangle procedures
|
||||
public func FxIntControlFreeHandsStart(object target, proplist fx, int temp)
|
||||
{
|
||||
// Process on non-temp as well in case scale/handle effects need to stack
|
||||
// Stop current action
|
||||
var proc = GetProcedure();
|
||||
if (proc == "SCALE" || proc == "HANGLE") SetAction("Walk");
|
||||
// Make sure ActMap is writable
|
||||
if (this.ActMap == this.Prototype.ActMap) this.ActMap = new this.ActMap{};
|
||||
// Kill scale/hangle effects
|
||||
fx.act_scale = this.ActMap.Scale;
|
||||
this.ActMap.Scale = nil;
|
||||
fx.act_hangle = this.ActMap.Hangle;
|
||||
this.ActMap.Hangle = nil;
|
||||
return FX_OK;
|
||||
}
|
||||
|
||||
public func FxIntControlFreeHandsStop(object target, proplist fx, int reason, bool temp)
|
||||
{
|
||||
// Restore scale/hangle effects (engine will handle re-grabbing walls if needed)
|
||||
if (fx.act_scale) this.ActMap.Scale = fx.act_scale;
|
||||
if (fx.act_hangle) this.ActMap.Hangle = fx.act_hangle;
|
||||
return FX_OK;
|
||||
}
|
||||
|
||||
// returns true if the clonk is able to enter a building (procedurewise)
|
||||
public func CanEnter()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue