openclonk/planet/Objects.ocd/Structures.ocd/Foundry.ocd/Script.c

109 lines
2.3 KiB
C
Raw Normal View History

/*--
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
{
//SetProperty("MeshTransformation",Trans_Rotate(RandomX(-40,20),0,1,0));
return _inherited(...);
2011-01-29 07:41:11 +00:00
}
/*-- Production --*/
private func DisregardsKnowledge() { return true; }
private func IsProduct(id product_id)
{
return product_id->~IsFoundryProduct();
}
private func ProductionTime() { return 290; }
2011-01-29 07:41:11 +00:00
public func NeedsRawMaterial(id rawmat_id)
2011-01-29 07:41:11 +00:00
{
if (rawmat_id->~IsFuel() || rawmat_id == Ore || rawmat_id == Nugget)
return true;
return false;
}
2011-01-29 07:41:11 +00:00
public func OnProductionStart(id product)
2011-01-29 07:41:11 +00:00
{
AddEffect("Smelting", this, 100, 1, this);
Sound("FurnaceStart");
return;
2011-01-29 07:41:11 +00:00
}
public func OnProductionHold(id product)
{
return;
}
public func OnProductionFinish(id product)
{
RemoveEffect("Smelting", this);
return;
}
protected func Collection()
2011-01-29 07:41:11 +00:00
{
Sound("Clonk");
return;
2011-01-29 07:41:11 +00:00
}
public func FxSmeltingTimer(object target, proplist effect, int time)
2011-01-29 07:41:11 +00:00
{
//Message(Format("Smelting %d",timer));
// Fire in the furnace.
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
// Smoke from the pipes.
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
// Furnace sound after some time.
if (time == 100)
Sound("FurnaceLoop", false, 100, nil, +1);
// Pour after some time.
if(time == 244)
SetMeshMaterial("MetalFlow", 1);
2011-01-29 07:41:11 +00:00
//Molten metal hits cast... Sizzling sound
if (time == 256)
Sound("Sizzle");
2011-01-29 07:41:11 +00:00
// Fire from the pouring exit.
if (Inside(time, 244, 290))
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
if (time == 290)
2011-01-29 07:41:11 +00:00
{
SetMeshMaterial("Metal", 1);
Sound("FurnaceLoop", false ,100, nil, -1);
Sound("FurnaceStop");
2011-01-29 07:41:11 +00:00
return -1;
}
return 1;
2011-01-29 07:41:11 +00:00
}
public func OnProductEjection(object product)
2011-01-29 07:41:11 +00:00
{
product->SetPosition(GetX() - 18, GetY() + 16);
product->SetSpeed(0, -17);
product->SetR(30 - Random(59));
Sound("Pop");
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$";