priming wire has now fixed length and warning

stable-5.1
Richard Gerum 2010-02-22 17:03:26 +01:00
parent 713818fca1
commit 19072d8be6
4 changed files with 87 additions and 8 deletions

View File

@ -79,13 +79,15 @@ public func SetFuse()
SetAction("Fuse");
}
public func Reset()
{
SetAction("Idle");
}
private func Fusing() {
// Effekt
if(GetActTime() < 120)
{
var h = GetDefHeight()/2;
CastParticles("Spark",1,20,Sin(GetR(),h),-Cos(GetR(),h),15,25,RGB(255,200,0),RGB(255,255,150));
}
CastParticles("Spark",1,20,0,0,15,25,RGB(255,200,0),RGB(255,255,150));
// Explosion
else if(GetActTime() > 140)
DoExplode();

View File

@ -1,5 +1,7 @@
/*-- Dynamite Igniter --*/
#include DYNB
private func Hit()
{
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));
ScheduleCall(this, "Ignite", iIgniteTime, 1, clonk);
RemoveEffect("IntLength", this);
return true;
}

View File

@ -6,11 +6,20 @@ local fHasMessage;
protected func Initialize ()
{
SetProperty("LineColors", [RGB(100,50,0), RGB(1,1,1)]);
// Put the first to vertices on the actual position
SetVertex(0,0,GetX()); SetVertex(0,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)
{
SetAction("Connect", pTarget1, pTarget2);

View File

@ -1,11 +1,19 @@
/*-- Dynamite box --*/
static const DYNA_MaxLength = 400;
static const DYNA_MaxCount = 5;
public func Initialize()
{
iCount = 5;
aDynamites = [0,0,0,0,0];
aWires = [0,0,0,0,0];
SetGraphics("5", this, 1, GFXOV_MODE_Picture);
iCount = DYNA_MaxCount;
aDynamites = CreateArray(iCount);
aWires = CreateArray(iCount);
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()
@ -36,6 +44,9 @@ public func ControlUse(object clonk, int x, int y)
}
if(pWire)
pWire->Connect(aDynamites[iCount], pDyna);
// First? then add Timer
else
AddEffect("IntLength", this, 1, 10, this);
pWire = CreateObject(PIWI);
pWire->Connect(pDyna, this);
@ -59,6 +70,59 @@ public func ControlUse(object clonk, int x, int y)
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) {
SetProperty("Collectible", 1, def);
SetProperty("Name", "$Name$", def);