2015-03-12 21:21:51 +00:00
|
|
|
/**
|
2016-08-04 23:14:13 +00:00
|
|
|
Dynamite Igniter
|
2015-03-12 21:21:51 +00:00
|
|
|
Can be used to ignite dynamite from a distance.
|
2016-08-04 23:14:13 +00:00
|
|
|
|
2015-03-12 21:21:51 +00:00
|
|
|
@author Newton
|
|
|
|
*/
|
2010-02-12 23:33:00 +00:00
|
|
|
|
2010-03-02 16:24:51 +00:00
|
|
|
#include DynamiteBox
|
2010-02-22 16:03:26 +00:00
|
|
|
|
2016-08-04 23:14:13 +00:00
|
|
|
local ignited;
|
|
|
|
local dynamite_sticks;
|
|
|
|
local wires;
|
|
|
|
|
|
|
|
/*-- Engine Callbacks --*/
|
|
|
|
|
|
|
|
func Hit()
|
2010-02-12 23:33:00 +00:00
|
|
|
{
|
2015-12-13 21:14:55 +00:00
|
|
|
Sound("Hits::Materials::Metal::DullMetalHit?");
|
2010-02-12 23:33:00 +00:00
|
|
|
}
|
|
|
|
|
2016-08-04 23:14:13 +00:00
|
|
|
// Only the main dynamite box is stored.
|
|
|
|
public func SaveScenarioObject() { return false; }
|
2015-03-12 21:21:51 +00:00
|
|
|
|
2016-08-04 23:14:13 +00:00
|
|
|
/*-- Callbacks --*/
|
2010-02-12 23:33:00 +00:00
|
|
|
|
2016-08-04 23:14:13 +00:00
|
|
|
public func OnFuseFinished()
|
|
|
|
{
|
|
|
|
if (Contained() != nil)
|
|
|
|
return ResetClonk(Contained());
|
|
|
|
return RemoveObject();
|
2015-03-12 21:21:51 +00:00
|
|
|
}
|
2010-02-12 23:33:00 +00:00
|
|
|
|
2016-08-04 23:14:13 +00:00
|
|
|
/*-- Usage --*/
|
|
|
|
|
|
|
|
public func HoldingEnabled() { return true; }
|
2010-02-12 23:33:00 +00:00
|
|
|
|
|
|
|
public func ControlUse(object clonk, int x, int y)
|
|
|
|
{
|
2015-03-12 21:21:51 +00:00
|
|
|
if (clonk->GetAction() != "Walk")
|
|
|
|
return true;
|
2016-08-09 21:44:14 +00:00
|
|
|
if (ignited)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
ignited = true;
|
|
|
|
|
2015-03-12 21:21:51 +00:00
|
|
|
// The clonk has to stand.
|
2010-02-12 23:33:00 +00:00
|
|
|
clonk->SetAction("Stand");
|
|
|
|
clonk->SetXDir(0);
|
|
|
|
|
2015-03-12 21:21:51 +00:00
|
|
|
var ignite_time = 40;
|
2015-10-11 12:08:14 +00:00
|
|
|
clonk->PlayAnimation("DoIgnite", CLONK_ANIM_SLOT_Arms, Anim_Linear(0, 0, clonk->GetAnimationLength("DoIgnite"), ignite_time, ANIM_Hold), Anim_Const(1000));
|
2016-01-29 04:47:53 +00:00
|
|
|
PlayAnimation("Ignite", 1, Anim_Linear(0, 0, GetAnimationLength("Ignite"), ignite_time, ANIM_Hold));
|
2010-02-22 16:03:26 +00:00
|
|
|
|
2015-03-12 21:21:51 +00:00
|
|
|
ScheduleCall(this, "Ignite", ignite_time, 1, clonk);
|
2010-02-12 23:33:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-02-22 00:18:45 +00:00
|
|
|
|
2015-03-12 21:21:51 +00:00
|
|
|
public func Ignite(object clonk)
|
2010-02-12 23:33:00 +00:00
|
|
|
{
|
2015-03-12 21:21:51 +00:00
|
|
|
if (wires[0])
|
|
|
|
wires[0]->StartFusing(this);
|
2010-09-13 15:27:48 +00:00
|
|
|
else
|
2010-05-04 16:17:35 +00:00
|
|
|
for (var obj in FindObjects(Find_Category(C4D_StaticBack), Find_Func("IsFuse"), Find_ActionTargets(this)))
|
2010-05-02 14:24:22 +00:00
|
|
|
obj->~StartFusing(this);
|
2010-04-13 13:13:47 +00:00
|
|
|
|
2015-03-12 21:21:51 +00:00
|
|
|
ScheduleCall(this, "ResetClonk", 12, 1, clonk);
|
|
|
|
return;
|
2010-02-22 00:18:45 +00:00
|
|
|
}
|
2010-02-12 23:33:00 +00:00
|
|
|
|
2015-03-12 21:21:51 +00:00
|
|
|
public func ResetClonk(object clonk)
|
2010-02-22 00:18:45 +00:00
|
|
|
{
|
2015-03-12 21:21:51 +00:00
|
|
|
// Reset animation of the clonk.
|
2010-03-30 16:48:38 +00:00
|
|
|
clonk->StopAnimation(clonk->GetRootAnimation(10));
|
2010-02-12 23:33:00 +00:00
|
|
|
clonk->SetAction("Walk");
|
|
|
|
clonk->DetachObject(this);
|
2015-03-12 21:21:51 +00:00
|
|
|
// Reset animation of the igniter and remove it.
|
|
|
|
StopAnimation(GetRootAnimation(1));
|
2010-02-22 00:18:45 +00:00
|
|
|
RemoveObject();
|
2015-03-12 21:21:51 +00:00
|
|
|
return;
|
2010-02-12 23:33:00 +00:00
|
|
|
}
|
|
|
|
|
2016-08-04 23:14:13 +00:00
|
|
|
/*-- Production --*/
|
2013-12-22 22:47:40 +00:00
|
|
|
|
2011-10-15 09:25:44 +00:00
|
|
|
public func IsTool() { return true; }
|
2015-12-27 22:24:27 +00:00
|
|
|
public func IsChemicalProduct() { return false; }
|
2011-10-15 09:25:44 +00:00
|
|
|
|
2016-08-04 23:14:13 +00:00
|
|
|
/*-- Display --*/
|
2015-03-12 21:21:51 +00:00
|
|
|
|
2016-08-04 23:14:13 +00:00
|
|
|
public func GetCarryMode()
|
|
|
|
{
|
|
|
|
return CARRY_BothHands;
|
|
|
|
}
|
2015-03-12 21:21:51 +00:00
|
|
|
|
2016-08-04 23:14:13 +00:00
|
|
|
public func GetCarryPhase() { return 250; }
|
|
|
|
|
2016-08-09 21:44:14 +00:00
|
|
|
public func GetCarryTransform()
|
|
|
|
{
|
|
|
|
if (ignited)
|
|
|
|
return Trans_Mul(Trans_Rotate(0, 1), Trans_Translate(-1000));
|
|
|
|
}
|
|
|
|
|
|
|
|
public func GetCarrySpecial()
|
2016-08-04 23:14:13 +00:00
|
|
|
{
|
|
|
|
if (ignited)
|
|
|
|
return "pos_hand2";
|
|
|
|
}
|
|
|
|
|
|
|
|
func Definition(def)
|
|
|
|
{
|
2011-12-31 12:01:39 +00:00
|
|
|
SetProperty("PictureTransformation",Trans_Mul(Trans_Rotate(-25, 1, 0, 0), Trans_Rotate(40, 0, 1, 0)), def);
|
2010-03-15 21:50:11 +00:00
|
|
|
}
|
2016-08-04 23:14:13 +00:00
|
|
|
|
|
|
|
/*-- Properties --*/
|
|
|
|
|
2010-09-09 21:29:11 +00:00
|
|
|
local Name = "$Name$";
|
2010-09-11 17:30:45 +00:00
|
|
|
local Description = "$Description$";
|
2016-08-04 23:14:13 +00:00
|
|
|
local Collectible = true;
|