forked from Mirrors/openclonk
priming wire has now fixed length and warning
parent
713818fca1
commit
19072d8be6
|
@ -79,13 +79,15 @@ public func SetFuse()
|
||||||
SetAction("Fuse");
|
SetAction("Fuse");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func Reset()
|
||||||
|
{
|
||||||
|
SetAction("Idle");
|
||||||
|
}
|
||||||
|
|
||||||
private func Fusing() {
|
private func Fusing() {
|
||||||
// Effekt
|
// Effekt
|
||||||
if(GetActTime() < 120)
|
if(GetActTime() < 120)
|
||||||
{
|
CastParticles("Spark",1,20,0,0,15,25,RGB(255,200,0),RGB(255,255,150));
|
||||||
var h = GetDefHeight()/2;
|
|
||||||
CastParticles("Spark",1,20,Sin(GetR(),h),-Cos(GetR(),h),15,25,RGB(255,200,0),RGB(255,255,150));
|
|
||||||
}
|
|
||||||
// Explosion
|
// Explosion
|
||||||
else if(GetActTime() > 140)
|
else if(GetActTime() > 140)
|
||||||
DoExplode();
|
DoExplode();
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*-- Dynamite Igniter --*/
|
/*-- Dynamite Igniter --*/
|
||||||
|
|
||||||
|
#include DYNB
|
||||||
|
|
||||||
private func Hit()
|
private func Hit()
|
||||||
{
|
{
|
||||||
Sound("WoodHit"); //TODO Some metal sond
|
Sound("WoodHit"); //TODO Some metal sond
|
||||||
|
@ -31,6 +33,8 @@ public func ControlUse(object clonk, int x, int y)
|
||||||
PlayAnimation("Ignite", 1, Anim_Linear(0, 0, GetAnimationLength("Ignite"), iIgniteTime, ANIM_Hold), Anim_Const(1000));
|
PlayAnimation("Ignite", 1, Anim_Linear(0, 0, GetAnimationLength("Ignite"), iIgniteTime, ANIM_Hold), Anim_Const(1000));
|
||||||
|
|
||||||
ScheduleCall(this, "Ignite", iIgniteTime, 1, clonk);
|
ScheduleCall(this, "Ignite", iIgniteTime, 1, clonk);
|
||||||
|
|
||||||
|
RemoveEffect("IntLength", this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,20 @@ local fHasMessage;
|
||||||
|
|
||||||
protected func Initialize ()
|
protected func Initialize ()
|
||||||
{
|
{
|
||||||
|
SetProperty("LineColors", [RGB(100,50,0), RGB(1,1,1)]);
|
||||||
// Put the first to vertices on the actual position
|
// Put the first to vertices on the actual position
|
||||||
SetVertex(0,0,GetX()); SetVertex(0,1,GetY());
|
SetVertex(0,0,GetX()); SetVertex(0,1,GetY());
|
||||||
SetVertex(1,0,GetX()); SetVertex(1,1,GetY());
|
SetVertex(1,0,GetX()); SetVertex(1,1,GetY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func SetColorWarning(fOn)
|
||||||
|
{
|
||||||
|
if(!fOn)
|
||||||
|
SetProperty("LineColors", [RGB(100,50,0), RGB(1,1,1)]);
|
||||||
|
else
|
||||||
|
SetProperty("LineColors", [RGB(200,100,0), RGB(1,1,1)]);
|
||||||
|
}
|
||||||
|
|
||||||
public func Connect(pTarget1, pTarget2)
|
public func Connect(pTarget1, pTarget2)
|
||||||
{
|
{
|
||||||
SetAction("Connect", pTarget1, pTarget2);
|
SetAction("Connect", pTarget1, pTarget2);
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
/*-- Dynamite box --*/
|
/*-- Dynamite box --*/
|
||||||
|
|
||||||
|
static const DYNA_MaxLength = 400;
|
||||||
|
static const DYNA_MaxCount = 5;
|
||||||
|
|
||||||
public func Initialize()
|
public func Initialize()
|
||||||
{
|
{
|
||||||
iCount = 5;
|
iCount = DYNA_MaxCount;
|
||||||
aDynamites = [0,0,0,0,0];
|
aDynamites = CreateArray(iCount);
|
||||||
aWires = [0,0,0,0,0];
|
aWires = CreateArray(iCount);
|
||||||
SetGraphics("5", this, 1, GFXOV_MODE_Picture);
|
for(var i = 0; i < iCount; i++)
|
||||||
|
{
|
||||||
|
aDynamites[i] = 0;
|
||||||
|
aWires[i] = 0;
|
||||||
|
}
|
||||||
|
SetGraphics(Format("%d", DYNA_MaxCount), this, 1, GFXOV_MODE_Picture);
|
||||||
}
|
}
|
||||||
|
|
||||||
private func Hit()
|
private func Hit()
|
||||||
|
@ -36,6 +44,9 @@ public func ControlUse(object clonk, int x, int y)
|
||||||
}
|
}
|
||||||
if(pWire)
|
if(pWire)
|
||||||
pWire->Connect(aDynamites[iCount], pDyna);
|
pWire->Connect(aDynamites[iCount], pDyna);
|
||||||
|
// First? then add Timer
|
||||||
|
else
|
||||||
|
AddEffect("IntLength", this, 1, 10, this);
|
||||||
|
|
||||||
pWire = CreateObject(PIWI);
|
pWire = CreateObject(PIWI);
|
||||||
pWire->Connect(pDyna, this);
|
pWire->Connect(pDyna, this);
|
||||||
|
@ -59,6 +70,59 @@ public func ControlUse(object clonk, int x, int y)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local fWarning;
|
||||||
|
local fWarningColor;
|
||||||
|
|
||||||
|
func FxIntLengthTimer(pTarget, iNumber, iTime)
|
||||||
|
{
|
||||||
|
var iLength = 0;
|
||||||
|
var i = GetLength(aWires)-1;
|
||||||
|
while(i >= 0 && aWires[i])
|
||||||
|
{
|
||||||
|
iLength += aWires[i]->GetLineLength();
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
if(iLength > DYNA_MaxLength*4/5)
|
||||||
|
{
|
||||||
|
fWarning = 1;
|
||||||
|
Message("Line too long! %d%%", this, iLength*100/DYNA_MaxLength);
|
||||||
|
if( (iTime % 5) == 0)
|
||||||
|
{
|
||||||
|
var fOn = 1;
|
||||||
|
if( fWarningColor == 1) fOn = 0;
|
||||||
|
fWarningColor = fOn;
|
||||||
|
for(var i = 0; i < GetLength(aWires); i++)
|
||||||
|
if(aWires[i]) aWires[i]->SetColorWarning(fOn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(fWarning)
|
||||||
|
{
|
||||||
|
fWarning = 0;
|
||||||
|
for(var i = 0; i < GetLength(aWires); i++)
|
||||||
|
if(aWires[i]) aWires[i]->SetColorWarning(0);
|
||||||
|
}
|
||||||
|
if(iLength > DYNA_MaxLength)
|
||||||
|
{
|
||||||
|
var iMax = GetLength(aWires)-1;
|
||||||
|
aWires[iMax]->RemoveObject();
|
||||||
|
aDynamites[iMax]->Reset();
|
||||||
|
SetLength(aWires, iMax);
|
||||||
|
SetLength(aDynamites, iMax);
|
||||||
|
Message("Line too long,|lost dynamite!|%d left.", this, iMax);
|
||||||
|
if(iMax == 0)
|
||||||
|
{
|
||||||
|
Message("Line broken.", Contained());
|
||||||
|
RemoveObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func FxIntLengthStop(pTarget, iNumber, iReason, fTmp)
|
||||||
|
{
|
||||||
|
for(var i = 0; i < GetLength(aWires); i++)
|
||||||
|
if(aWires[i]) aWires[i]->SetColorWarning(0);
|
||||||
|
}
|
||||||
|
|
||||||
func Definition(def) {
|
func Definition(def) {
|
||||||
SetProperty("Collectible", 1, def);
|
SetProperty("Collectible", 1, def);
|
||||||
SetProperty("Name", "$Name$", def);
|
SetProperty("Name", "$Name$", def);
|
||||||
|
|
Loading…
Reference in New Issue