2011-04-02 16:17:24 +00:00
|
|
|
/*--
|
|
|
|
Foundry
|
|
|
|
Authors: Ringwaul, Maikel
|
|
|
|
|
|
|
|
Melts iron ore to metal, using some sort of fuel.
|
|
|
|
--*/
|
|
|
|
|
|
|
|
|
|
|
|
#include Library_Producer
|
2011-01-29 07:41:11 +00:00
|
|
|
|
2011-05-30 22:50:07 +00:00
|
|
|
public func Construction()
|
2011-01-29 07:41:11 +00:00
|
|
|
{
|
2011-10-07 15:38:34 +00:00
|
|
|
|
|
|
|
//SetProperty("MeshTransformation",Trans_Rotate(RandomX(-40,20),0,1,0));
|
|
|
|
return _inherited(...);
|
2011-01-29 07:41:11 +00:00
|
|
|
}
|
|
|
|
|
2011-04-07 14:02:35 +00:00
|
|
|
/*-- Production --*/
|
|
|
|
|
2011-10-09 12:13:55 +00:00
|
|
|
private func IsProduct(id product_id)
|
2011-04-02 16:17:24 +00:00
|
|
|
{
|
2011-10-07 15:38:34 +00:00
|
|
|
return product_id->~IsFoundryProduct();
|
|
|
|
}
|
2011-10-09 12:13:55 +00:00
|
|
|
private func ProductionTime() { return 290; }
|
2011-01-29 07:41:11 +00:00
|
|
|
|
2011-04-02 16:17:24 +00:00
|
|
|
public func NeedsRawMaterial(id rawmat_id)
|
2011-01-29 07:41:11 +00:00
|
|
|
{
|
2011-10-15 01:46:53 +00:00
|
|
|
if (rawmat_id->~IsFuel() || rawmat_id == Ore || rawmat_id == Nugget)
|
2011-04-02 16:17:24 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-01-29 07:41:11 +00:00
|
|
|
|
2011-10-09 12:13:55 +00:00
|
|
|
public func OnProductionStart(id product)
|
2011-01-29 07:41:11 +00:00
|
|
|
{
|
2011-10-09 12:13:55 +00:00
|
|
|
AddEffect("Smelting", this, 100, 1, this);
|
2011-10-12 21:09:22 +00:00
|
|
|
Sound("FurnaceStart");
|
2011-10-09 12:13:55 +00:00
|
|
|
return;
|
2011-01-29 07:41:11 +00:00
|
|
|
}
|
|
|
|
|
2011-10-09 12:13:55 +00:00
|
|
|
public func OnProductionHold(id product)
|
2011-04-07 14:02:35 +00:00
|
|
|
{
|
2011-10-09 12:13:55 +00:00
|
|
|
return;
|
2011-04-07 14:02:35 +00:00
|
|
|
}
|
|
|
|
|
2011-10-09 12:13:55 +00:00
|
|
|
public func OnProductionFinish(id product)
|
|
|
|
{
|
|
|
|
RemoveEffect("Smelting", this);
|
|
|
|
return;
|
|
|
|
}
|
2011-04-02 16:17:24 +00:00
|
|
|
|
|
|
|
protected func Collection()
|
2011-01-29 07:41:11 +00:00
|
|
|
{
|
2011-10-12 21:09:22 +00:00
|
|
|
Sound("Clonk");
|
2011-04-02 16:17:24 +00:00
|
|
|
return;
|
2011-01-29 07:41:11 +00:00
|
|
|
}
|
|
|
|
|
2011-10-09 12:13:55 +00:00
|
|
|
public func FxSmeltingTimer(object target, proplist effect, int time)
|
2011-01-29 07:41:11 +00:00
|
|
|
{
|
2011-10-09 12:13:55 +00:00
|
|
|
//Message(Format("Smelting %d",timer));
|
|
|
|
// Fire in the furnace.
|
2011-10-07 15:38:34 +00:00
|
|
|
CreateParticle("Fire",10,20,RandomX(-1,1),RandomX(-1,1),RandomX(25,50),RGB(255,255,255), this);
|
2011-01-29 07:41:11 +00:00
|
|
|
|
2011-10-09 12:13:55 +00:00
|
|
|
// Smoke from the pipes.
|
2011-10-11 12:20:03 +00:00
|
|
|
CreateParticle("ExploSmoke", 9, -31, RandomX(-2,1), -7 + RandomX(-2,2), RandomX(60,125), RGBa(255,255,255,50));
|
|
|
|
CreateParticle("ExploSmoke", 16, -27, RandomX(-1,2), -7 + RandomX(-2,2), RandomX(30,90), RGBa(255,255,255,50));
|
2011-01-29 07:41:11 +00:00
|
|
|
|
2011-10-09 12:13:55 +00:00
|
|
|
// Furnace sound after some time.
|
|
|
|
if (time == 100)
|
2011-10-12 21:09:22 +00:00
|
|
|
Sound("FurnaceLoop", false, 100, nil, +1);
|
2011-10-09 12:13:55 +00:00
|
|
|
|
|
|
|
// Pour after some time.
|
|
|
|
if(time == 244)
|
|
|
|
SetMeshMaterial("MetalFlow", 1);
|
2011-01-29 07:41:11 +00:00
|
|
|
|
|
|
|
//Molten metal hits cast... Sizzling sound
|
2011-10-09 12:13:55 +00:00
|
|
|
if (time == 256)
|
2011-10-12 21:09:22 +00:00
|
|
|
Sound("Sizzle");
|
2011-01-29 07:41:11 +00:00
|
|
|
|
2011-10-09 12:13:55 +00:00
|
|
|
// Fire from the pouring exit.
|
|
|
|
if (Inside(time, 244, 290))
|
2011-10-14 06:00:10 +00:00
|
|
|
CreateParticle("Fire",-17,19,-1 + RandomX(-1,1), 2+ RandomX(-1,1),RandomX(5,15),RGB(255,255,255));
|
2011-01-29 07:41:11 +00:00
|
|
|
|
2011-10-09 12:13:55 +00:00
|
|
|
if (time == 290)
|
2011-01-29 07:41:11 +00:00
|
|
|
{
|
2011-10-09 12:13:55 +00:00
|
|
|
SetMeshMaterial("Metal", 1);
|
2011-10-12 21:09:22 +00:00
|
|
|
Sound("FurnaceLoop", false ,100, nil, -1);
|
|
|
|
Sound("FurnaceStop");
|
2011-01-29 07:41:11 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2011-10-09 12:13:55 +00:00
|
|
|
return 1;
|
2011-01-29 07:41:11 +00:00
|
|
|
}
|
|
|
|
|
2011-10-09 12:13:55 +00:00
|
|
|
public func OnProductEjection(object product)
|
2011-01-29 07:41:11 +00:00
|
|
|
{
|
2011-10-11 12:20:03 +00:00
|
|
|
product->SetPosition(GetX() - 18, GetY() + 16);
|
2011-10-09 12:13:55 +00:00
|
|
|
product->SetSpeed(0, -17);
|
|
|
|
product->SetR(30 - Random(59));
|
2011-10-12 21:09:22 +00:00
|
|
|
Sound("Pop");
|
2011-10-09 12:13:55 +00:00
|
|
|
return;
|
2011-01-29 07:41:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Definition(def) {
|
|
|
|
SetProperty("PictureTransformation", Trans_Mul(Trans_Translate(2000,0,7000),Trans_Rotate(-20,1,0,0),Trans_Rotate(30,0,1,0)), def);
|
|
|
|
}
|
|
|
|
local Name = "$Name$";
|