2009-12-29 13:44:16 +00:00
|
|
|
/*-- Steam engine --*/
|
|
|
|
|
2012-02-18 21:50:18 +00:00
|
|
|
#include Library_Ownable
|
|
|
|
#include Library_PowerProducer
|
2009-12-29 13:44:16 +00:00
|
|
|
|
|
|
|
local iFuelAmount;
|
2012-02-18 21:50:18 +00:00
|
|
|
local power_seconds;
|
2009-12-29 13:44:16 +00:00
|
|
|
|
2011-05-30 22:50:07 +00:00
|
|
|
func Construction()
|
2009-12-29 13:44:16 +00:00
|
|
|
{
|
2010-03-30 16:48:38 +00:00
|
|
|
iFuelAmount = 0;
|
2012-02-18 21:50:18 +00:00
|
|
|
power_seconds = 0;
|
2011-05-30 22:50:07 +00:00
|
|
|
return _inherited(...);
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func ContentsCheck()
|
|
|
|
{
|
2010-03-30 16:48:38 +00:00
|
|
|
// Still active?
|
|
|
|
if(!ActIdle())
|
|
|
|
return true;
|
2009-12-29 13:44:16 +00:00
|
|
|
|
2010-03-30 16:48:38 +00:00
|
|
|
// Still has some fuel?
|
|
|
|
if(iFuelAmount) return SetAction("Work");
|
|
|
|
|
|
|
|
var pFuel;
|
|
|
|
// Search for new fuel
|
|
|
|
if(pFuel = FindObject(Find_Container(this), Find_Func("IsFuel")))
|
|
|
|
{
|
|
|
|
iFuelAmount += pFuel->~GetFuelAmount();
|
|
|
|
pFuel->RemoveObject();
|
|
|
|
SetAction("Work");
|
|
|
|
return 1;
|
|
|
|
}
|
2009-12-29 13:44:16 +00:00
|
|
|
|
2010-03-30 16:48:38 +00:00
|
|
|
//Ejects non fuel items immediately
|
|
|
|
if(pFuel = FindObject(Find_Container(this), !Find_Func("IsFuel"))) {
|
2009-12-29 13:44:16 +00:00
|
|
|
pFuel->Exit(-53,21, -20, -1, -1, -30);
|
|
|
|
Sound("Chuff"); //I think a 'chuff' or 'metal clonk' sound could be good here -Ringwaul
|
2010-03-30 16:48:38 +00:00
|
|
|
}
|
2009-12-29 13:44:16 +00:00
|
|
|
|
2010-03-30 16:48:38 +00:00
|
|
|
return 0;
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func ConsumeFuel()
|
2012-02-18 21:50:18 +00:00
|
|
|
{
|
|
|
|
if(iFuelAmount > 0)
|
|
|
|
{
|
|
|
|
// every fuel unit gives power for ten seconds
|
|
|
|
power_seconds += 10;
|
|
|
|
if(!GetEffect("CreatesPower", this))
|
|
|
|
AddEffect("CreatesPower", this, 1, 36, this);
|
|
|
|
}
|
2010-03-30 16:48:38 +00:00
|
|
|
|
|
|
|
// All used up?
|
|
|
|
if(!iFuelAmount)
|
|
|
|
{
|
|
|
|
SetAction("Idle");
|
|
|
|
ContentsCheck();
|
|
|
|
}
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
|
|
|
|
2012-02-18 21:50:18 +00:00
|
|
|
func FxCreatesPowerStart(target, effect, temp)
|
|
|
|
{
|
|
|
|
if(temp) return;
|
|
|
|
// fixed amount
|
2012-02-19 00:02:17 +00:00
|
|
|
MakePowerProducer(300);
|
2012-02-18 21:50:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func FxCreatesPowerTimer(target, effect)
|
|
|
|
{
|
|
|
|
if(power_seconds == 0) return -1;
|
|
|
|
--power_seconds;
|
|
|
|
}
|
|
|
|
|
|
|
|
func FxCreatesPowerStop(target, effect, reason, temp)
|
|
|
|
{
|
|
|
|
if(temp) return;
|
|
|
|
// fixed amount
|
|
|
|
MakePowerProducer(0);
|
|
|
|
}
|
|
|
|
|
2010-09-09 21:29:11 +00:00
|
|
|
local ActMap = {
|
2009-12-29 13:44:16 +00:00
|
|
|
Work = {
|
2010-03-30 16:48:38 +00:00
|
|
|
Prototype = Action,
|
|
|
|
Name = "Work",
|
|
|
|
Procedure = DFA_NONE,
|
|
|
|
Directions = 2,
|
|
|
|
FlipDir = 1,
|
|
|
|
Length = 20,
|
|
|
|
Delay = 2,
|
|
|
|
X = 0,
|
|
|
|
Y = 0,
|
|
|
|
Wdt = 110,
|
|
|
|
Hgt = 80,
|
|
|
|
NextAction = "Work",
|
|
|
|
Animation = "Work",
|
|
|
|
EndCall = "ConsumeFuel",
|
2010-09-09 21:29:11 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
local Name = "$Name$";
|
2010-12-12 21:38:15 +00:00
|
|
|
|
2011-05-31 01:16:13 +00:00
|
|
|
func Definition(def) {
|
|
|
|
SetProperty("MeshTransformation", Trans_Mul(Trans_Rotate(25,0,1,0), Trans_Scale(625)), def);
|
|
|
|
}
|