2009-12-29 13:44:16 +00:00
|
|
|
/*-- Steam engine --*/
|
|
|
|
|
2012-05-10 19:20:06 +00:00
|
|
|
#include Library_Structure
|
2012-02-18 21:50:18 +00:00
|
|
|
#include Library_Ownable
|
|
|
|
#include Library_PowerProducer
|
2009-12-29 13:44:16 +00:00
|
|
|
|
2012-02-23 20:44:10 +00:00
|
|
|
static const SteamEngine_produced_power = 300;
|
|
|
|
|
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
|
|
|
|
2012-04-16 15:31:38 +00:00
|
|
|
func Construction(object creator)
|
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;
|
2012-04-16 15:31:38 +00:00
|
|
|
|
|
|
|
SetAction("Default");
|
2013-05-23 16:37:01 +00:00
|
|
|
AddTimer("ContentsCheck", 30);
|
2012-04-16 15:31:38 +00:00
|
|
|
return _inherited(creator, ...);
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
|
|
|
|
2012-02-23 21:35:30 +00:00
|
|
|
public func IsContainer() { return true; }
|
|
|
|
|
2013-05-23 16:37:01 +00:00
|
|
|
func RejectCollect(id item, object obj)
|
2012-02-23 21:35:30 +00:00
|
|
|
{
|
2012-04-16 15:31:38 +00:00
|
|
|
if (obj->~IsFuel())
|
2012-02-23 21:35:30 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-05-23 16:37:01 +00:00
|
|
|
func Collection(object obj, bool put)
|
2012-02-23 21:35:30 +00:00
|
|
|
{
|
2013-05-23 16:37:01 +00:00
|
|
|
Sound("Clonk");
|
2012-02-23 21:35:30 +00:00
|
|
|
}
|
|
|
|
|
2009-12-29 13:44:16 +00:00
|
|
|
func ContentsCheck()
|
|
|
|
{
|
2012-02-23 20:44:10 +00:00
|
|
|
//Ejects non fuel items immediately
|
|
|
|
var fuel;
|
|
|
|
if(fuel = FindObject(Find_Container(this), Find_Not(Find_Func("IsFuel"))))
|
|
|
|
{
|
|
|
|
fuel->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
|
|
|
// Still active?
|
2012-04-16 15:31:38 +00:00
|
|
|
if(GetAction() == "Work") return true;
|
2012-02-23 20:44:10 +00:00
|
|
|
// or still warm water in the tank?!
|
|
|
|
if(GetEffect("CreatesPower", this))
|
2010-03-30 16:48:38 +00:00
|
|
|
return true;
|
2012-02-23 20:44:10 +00:00
|
|
|
|
|
|
|
// not needed?
|
|
|
|
if(GetPendingPowerAmount() == 0)
|
|
|
|
return false;
|
|
|
|
|
2010-03-30 16:48:38 +00:00
|
|
|
// Still has some fuel?
|
|
|
|
if(iFuelAmount) return SetAction("Work");
|
|
|
|
|
|
|
|
// Search for new fuel
|
2012-02-23 20:44:10 +00:00
|
|
|
if(fuel = FindObject(Find_Container(this), Find_Func("IsFuel")))
|
2010-03-30 16:48:38 +00:00
|
|
|
{
|
2012-03-10 16:33:57 +00:00
|
|
|
iFuelAmount += fuel->~GetFuelAmount() / 2;
|
2012-02-23 20:44:10 +00:00
|
|
|
fuel->RemoveObject();
|
2010-03-30 16:48:38 +00:00
|
|
|
SetAction("Work");
|
2012-02-23 20:44:10 +00:00
|
|
|
return true;
|
2010-03-30 16:48:38 +00:00
|
|
|
}
|
2009-12-29 13:44:16 +00:00
|
|
|
|
2012-02-23 20:44:10 +00:00
|
|
|
return false;
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func ConsumeFuel()
|
2012-02-18 21:50:18 +00:00
|
|
|
{
|
|
|
|
if(iFuelAmount > 0)
|
|
|
|
{
|
2012-02-23 20:44:10 +00:00
|
|
|
// every fuel unit gives power for one second
|
|
|
|
--iFuelAmount;
|
|
|
|
power_seconds += 1;
|
2012-02-18 21:50:18 +00:00
|
|
|
if(!GetEffect("CreatesPower", this))
|
|
|
|
AddEffect("CreatesPower", this, 1, 36, this);
|
|
|
|
}
|
2010-03-30 16:48:38 +00:00
|
|
|
|
|
|
|
// All used up?
|
2012-02-23 20:44:10 +00:00
|
|
|
if(!iFuelAmount || ((GetPendingPowerAmount() == 0) && (GetCurrentPowerBalance() >= SteamEngine_produced_power)))
|
2010-03-30 16:48:38 +00:00
|
|
|
{
|
2012-04-16 15:31:38 +00:00
|
|
|
SetAction("Default");
|
2010-03-30 16:48:38 +00:00
|
|
|
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-23 20:44:10 +00:00
|
|
|
MakePowerProducer(SteamEngine_produced_power);
|
|
|
|
|
|
|
|
AddEffect("Smoking", this, 1, 5, this);
|
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;
|
2012-02-23 20:44:10 +00:00
|
|
|
// disable producer
|
2012-02-18 21:50:18 +00:00
|
|
|
MakePowerProducer(0);
|
2012-02-23 20:44:10 +00:00
|
|
|
|
|
|
|
if(GetEffect("Smoking", this))
|
|
|
|
RemoveEffect("Smoking", this);
|
|
|
|
}
|
|
|
|
|
|
|
|
func FxSmokingTimer()
|
|
|
|
{
|
2012-04-16 15:31:38 +00:00
|
|
|
Smoke(-20 * GetCalcDir(), -15, 10);
|
2012-02-23 20:44:10 +00:00
|
|
|
return 1;
|
2012-02-18 21:50:18 +00:00
|
|
|
}
|
|
|
|
|
2010-09-09 21:29:11 +00:00
|
|
|
local ActMap = {
|
2012-04-16 15:31:38 +00:00
|
|
|
Default = {
|
|
|
|
Prototype = Action,
|
|
|
|
Name = "Default",
|
|
|
|
Procedure = DFA_NONE,
|
|
|
|
Directions = 2,
|
|
|
|
FlipDir = 1,
|
|
|
|
Length = 1,
|
|
|
|
Delay = 0,
|
|
|
|
FacetBase=1,
|
|
|
|
NextAction = "Default",
|
|
|
|
},
|
|
|
|
Work = {
|
|
|
|
Prototype = Action,
|
|
|
|
Name = "Work",
|
|
|
|
Procedure = DFA_NONE,
|
|
|
|
Directions = 2,
|
|
|
|
FlipDir = 1,
|
|
|
|
Length = 20,
|
|
|
|
Delay = 2,
|
|
|
|
FacetBase = 1,
|
|
|
|
NextAction = "Work",
|
|
|
|
Animation = "Work",
|
|
|
|
EndCall = "ConsumeFuel",
|
|
|
|
},
|
2010-09-09 21:29:11 +00:00
|
|
|
};
|
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);
|
2012-04-15 11:13:14 +00:00
|
|
|
}
|
2012-04-28 14:17:38 +00:00
|
|
|
local BlastIncinerate = 130;
|
2012-05-10 19:20:06 +00:00
|
|
|
local HitPoints = 100;
|
2012-04-15 11:13:14 +00:00
|
|
|
local Name = "$Name$";
|
|
|
|
local Description = "$Description$";
|