forked from Mirrors/openclonk
fix switching dynamite igniter while switching inventory (#1913)
parent
ed41426ef8
commit
2429ee6722
|
@ -7,11 +7,10 @@
|
|||
|
||||
#include DynamiteBox
|
||||
|
||||
local ignited;
|
||||
|
||||
/*-- Engine Callbacks --*/
|
||||
|
||||
func Hit()
|
||||
public func Hit()
|
||||
{
|
||||
Sound("Hits::Materials::Metal::DullMetalHit?");
|
||||
}
|
||||
|
@ -30,38 +29,75 @@ public func OnFuseFinished()
|
|||
|
||||
public func HoldingEnabled() { return true; }
|
||||
|
||||
public func ControlUse(object clonk, int x, int y)
|
||||
public func ControlUseStart(object clonk, int x, int y)
|
||||
{
|
||||
if (clonk->GetAction() != "Walk")
|
||||
return true;
|
||||
if (ignited)
|
||||
if (IsBeingIgnited())
|
||||
return true;
|
||||
|
||||
ignited = true;
|
||||
|
||||
// The clonk has to stand.
|
||||
clonk->SetAction("Stand");
|
||||
clonk->SetXDir(0);
|
||||
|
||||
var ignite_time = 40;
|
||||
var ignite_time = 32;
|
||||
clonk->PlayAnimation("DoIgnite", CLONK_ANIM_SLOT_Arms, Anim_Linear(0, 0, clonk->GetAnimationLength("DoIgnite"), ignite_time, ANIM_Hold), Anim_Const(1000));
|
||||
PlayAnimation("Ignite", 1, Anim_Linear(0, 0, GetAnimationLength("Ignite"), ignite_time, ANIM_Hold));
|
||||
|
||||
ScheduleCall(this, "Ignite", ignite_time, 1, clonk);
|
||||
// Launch the ignition effect.
|
||||
CreateEffect(FxScheduleIgnite, 100, ignite_time + 4, clonk);
|
||||
return true;
|
||||
}
|
||||
|
||||
public func ControlUseStop(object clonk, int x, int y)
|
||||
{
|
||||
var fx = GetEffect("FxScheduleIgnite", this);
|
||||
if (fx)
|
||||
fx->Remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
public func ControlUseCancel(object clonk, int x, int y)
|
||||
{
|
||||
var fx = GetEffect("FxScheduleIgnite", this);
|
||||
if (fx)
|
||||
fx->Remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
local FxScheduleIgnite = new Effect
|
||||
{
|
||||
Construction = func(object clonk)
|
||||
{
|
||||
this.clonk = clonk;
|
||||
},
|
||||
Timer = func()
|
||||
{
|
||||
Target->Ignite(this.clonk);
|
||||
return FX_Execute_Kill;
|
||||
},
|
||||
Destruction = func()
|
||||
{
|
||||
Target->ResetClonk(this.clonk, false);
|
||||
}
|
||||
};
|
||||
|
||||
public func IsBeingIgnited()
|
||||
{
|
||||
return !! GetEffect("FxScheduleIgnite", this);
|
||||
}
|
||||
|
||||
public func Ignite(object clonk)
|
||||
{
|
||||
// Ignite all connected wires
|
||||
for (var obj in FindFuses())
|
||||
obj->~StartFusing(this);
|
||||
|
||||
ScheduleCall(this, "ResetClonk", 12, 1, clonk);
|
||||
ScheduleCall(this, "ResetClonk", 12, 1, clonk, true);
|
||||
return;
|
||||
}
|
||||
|
||||
public func ResetClonk(object clonk)
|
||||
public func ResetClonk(object clonk, bool remove_igniter)
|
||||
{
|
||||
// Reset animation of the clonk.
|
||||
clonk->StopAnimation(clonk->GetRootAnimation(10));
|
||||
|
@ -69,15 +105,18 @@ public func ResetClonk(object clonk)
|
|||
clonk->DetachObject(this);
|
||||
// Reset animation of the igniter and remove it.
|
||||
StopAnimation(GetRootAnimation(1));
|
||||
RemoveObject();
|
||||
if (remove_igniter)
|
||||
RemoveObject();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*-- Production --*/
|
||||
|
||||
public func IsTool() { return true; }
|
||||
public func IsChemicalProduct() { return false; }
|
||||
|
||||
|
||||
/*-- Display --*/
|
||||
|
||||
public func GetCarryMode()
|
||||
|
@ -89,21 +128,22 @@ public func GetCarryPhase() { return 250; }
|
|||
|
||||
public func GetCarryTransform()
|
||||
{
|
||||
if (ignited)
|
||||
if (IsBeingIgnited())
|
||||
return Trans_Mul(Trans_Rotate(0, 1), Trans_Translate(-1000));
|
||||
}
|
||||
|
||||
public func GetCarrySpecial()
|
||||
{
|
||||
if (ignited)
|
||||
if (IsBeingIgnited())
|
||||
return "pos_hand2";
|
||||
}
|
||||
|
||||
func Definition(def)
|
||||
public func Definition(proplist def)
|
||||
{
|
||||
SetProperty("PictureTransformation",Trans_Mul(Trans_Rotate(-25, 1, 0, 0), Trans_Rotate(40, 0, 1, 0)), def);
|
||||
SetProperty("PictureTransformation", Trans_Mul(Trans_Rotate(-25, 1, 0, 0), Trans_Rotate(40, 0, 1, 0)), def);
|
||||
}
|
||||
|
||||
|
||||
/*-- Properties --*/
|
||||
|
||||
local Name = "$Name$";
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
Name=Zünder
|
||||
Description=Bring Dich in Sicherheit und drücke [Benutzen], um das Dynamit zu zünden.
|
||||
Description=Bring Dich in Sicherheit und halte [Benutzen] gedrückt, um das Dynamit zu zünden.
|
|
@ -1,2 +1,2 @@
|
|||
Name=Igniter
|
||||
Description=Take shelter and press [Use] to ignite the placed dynamite.
|
||||
Description=Take shelter and keep [Use] pressed to ignite the placed dynamite.
|
|
@ -92,11 +92,12 @@ public func ChangeToIgniter()
|
|||
ChangeDef(Igniter);
|
||||
SetGraphics("Picture", Igniter, 1, GFXOV_MODE_Picture);
|
||||
// Update carrier
|
||||
if (Contained())
|
||||
var container = Contained();
|
||||
if (container)
|
||||
{
|
||||
var pos = Contained()->~GetItemPos(this);
|
||||
Contained()->~UpdateAttach();
|
||||
Contained()->~OnSlotFull(pos);
|
||||
var pos = container->~GetItemPos(this);
|
||||
container->~UpdateAttach();
|
||||
container->~OnSlotFull(pos);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue