2011-10-15 01:47:24 +00:00
|
|
|
/*--
|
|
|
|
Windmill
|
|
|
|
Authors: Ringwaul, Clonkonaut
|
|
|
|
|
2012-02-18 21:50:18 +00:00
|
|
|
Crushes seeds into flour using power - is an own power producer too
|
2011-10-15 01:47:24 +00:00
|
|
|
--*/
|
|
|
|
|
2012-02-18 21:50:18 +00:00
|
|
|
#include Library_Ownable
|
2011-10-15 01:47:24 +00:00
|
|
|
#include Library_Producer
|
2012-02-18 21:50:18 +00:00
|
|
|
#include Library_PowerConsumer
|
|
|
|
#include Library_PowerProducer
|
2011-10-15 01:47:24 +00:00
|
|
|
|
|
|
|
local wind_anim;
|
2012-02-18 21:50:18 +00:00
|
|
|
local last_wind;
|
2011-10-15 01:47:24 +00:00
|
|
|
|
2012-04-21 22:55:44 +00:00
|
|
|
func TurnAnimation(){return "Spin";}
|
2012-04-21 19:09:16 +00:00
|
|
|
func MinRevolutionTime(){return 18000;} // in frames
|
|
|
|
|
2012-04-16 15:31:38 +00:00
|
|
|
protected func Construction(object creator)
|
2011-10-15 06:04:16 +00:00
|
|
|
{
|
|
|
|
SetProperty("MeshTransformation", Trans_Rotate(-30,0,1,0));
|
2012-04-16 15:31:38 +00:00
|
|
|
SetAction("Default");
|
2012-04-21 22:07:02 +00:00
|
|
|
|
|
|
|
if (creator)
|
|
|
|
{
|
|
|
|
var dir = creator->~GetConstructionDirection();
|
|
|
|
if (dir)
|
|
|
|
SetDir(dir);
|
|
|
|
}
|
2012-04-21 19:09:16 +00:00
|
|
|
|
|
|
|
// uses functions of the wind generator
|
|
|
|
this.Wind2TurnEx = WindGenerator.Wind2Turn;
|
|
|
|
this.GetWeightedWind = WindGenerator.GetWeightedWind;
|
2012-05-12 11:17:22 +00:00
|
|
|
AddTimer("CollectionZone", 1);
|
2012-04-21 19:09:16 +00:00
|
|
|
|
2012-04-16 15:31:38 +00:00
|
|
|
return _inherited(creator, ...);
|
2011-10-15 06:04:16 +00:00
|
|
|
}
|
|
|
|
|
2011-10-15 01:47:24 +00:00
|
|
|
protected func Initialize()
|
|
|
|
{
|
2012-04-21 19:09:16 +00:00
|
|
|
// create wheel
|
|
|
|
(this.wheel = CreateObject(WindGenerator_Wheel, 0, 0, NO_OWNER))->Set(this, 150);
|
|
|
|
|
2011-10-15 01:47:24 +00:00
|
|
|
// Set initial position
|
2012-04-21 22:55:44 +00:00
|
|
|
wind_anim = PlayAnimation(TurnAnimation(), 5, this.wheel->Anim_R(GetAnimationLength(TurnAnimation()), 0), Anim_Const(1000));
|
2011-10-15 01:47:24 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
|
|
|
func Wind2Turn()
|
2012-04-16 15:31:38 +00:00
|
|
|
{
|
2012-04-21 19:09:16 +00:00
|
|
|
// dummy, uses the function of the WindGenerator
|
|
|
|
this->Wind2TurnEx();
|
2011-10-15 01:47:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-- Production --*/
|
|
|
|
|
2012-01-19 22:31:05 +00:00
|
|
|
private func IgnoreKnowledge() { return true; }
|
2012-01-16 23:32:46 +00:00
|
|
|
|
2011-10-15 01:47:24 +00:00
|
|
|
private func IsProduct(id product_id)
|
|
|
|
{
|
|
|
|
return product_id->~IsWindmillProduct();
|
|
|
|
}
|
2012-04-15 16:45:43 +00:00
|
|
|
private func ProductionTime(id toProduce) { return 290; }
|
2012-02-18 21:50:18 +00:00
|
|
|
private func PowerNeed() { return 75; }
|
2011-10-15 01:47:24 +00:00
|
|
|
|
2012-01-19 22:31:05 +00:00
|
|
|
public func NeedRawMaterial(id rawmat_id)
|
2011-10-15 01:47:24 +00:00
|
|
|
{
|
|
|
|
if (rawmat_id == Seeds)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public func OnProductionStart(id product)
|
|
|
|
{
|
|
|
|
AddEffect("Crushing", this, 100, 10, this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
public func OnProductionContinued(id product)
|
|
|
|
{
|
|
|
|
AddEffect("Crushing", this, 100, 10, this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
public func OnProductionHold(id product)
|
|
|
|
{
|
|
|
|
RemoveEffect("Crushing", this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
public func OnProductionFinish(id product)
|
|
|
|
{
|
|
|
|
RemoveEffect("Crushing", this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-16 15:31:38 +00:00
|
|
|
// Timer, check for objects to collect in the designated collection zone
|
|
|
|
func CollectionZone()
|
|
|
|
{
|
|
|
|
if (GetCon() < 100) return;
|
|
|
|
|
|
|
|
if (!(FrameCounter() % 35)) Wind2Turn();
|
|
|
|
|
|
|
|
for (var object in FindObjects(Find_InRect(-18 + 21 * GetDir(),35,15,15), Find_OCF(OCF_Collectible), Find_NoContainer(), Find_Layer(GetObjectLayer())))
|
|
|
|
Collect(object);
|
|
|
|
}
|
|
|
|
|
2011-10-15 01:47:24 +00:00
|
|
|
protected func Collection()
|
|
|
|
{
|
|
|
|
Sound("Clonk");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
public func FxCrushingTimer(object target, proplist effect, int time)
|
|
|
|
{
|
2012-04-16 15:31:38 +00:00
|
|
|
CreateParticle("Axe_WoodChip", 12 * GetCalcDir(), 40, -(5 - Random(11)) * GetCalcDir(), RandomX(6,13) * -1, 20, RGB(255,255,255), this);
|
2011-10-15 01:47:24 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public func OnProductEjection(object product)
|
|
|
|
{
|
2012-04-16 15:31:38 +00:00
|
|
|
product->SetPosition(GetX() - 25 * GetCalcDir(), GetY() + 40);
|
2011-10-15 01:47:24 +00:00
|
|
|
product->SetSpeed(0, -17);
|
|
|
|
product->SetR(30 - Random(59));
|
|
|
|
Sound("Pop");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-15 06:04:16 +00:00
|
|
|
protected func RejectCollect(id item, object collect)
|
|
|
|
{
|
|
|
|
if(collect->~IsMillIngredient()) return false;
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-04-15 11:13:14 +00:00
|
|
|
func IsInteractable() { return true; }
|
|
|
|
|
2012-04-16 15:31:38 +00:00
|
|
|
local ActMap = {
|
|
|
|
Default = {
|
|
|
|
Prototype = Action,
|
|
|
|
Name = "Default",
|
|
|
|
Procedure = DFA_NONE,
|
|
|
|
Directions = 2,
|
|
|
|
FlipDir = 1,
|
|
|
|
Length = 1,
|
|
|
|
Delay = 0,
|
|
|
|
FacetBase = 1,
|
|
|
|
NextAction = "Default",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2011-10-15 01:47:24 +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);
|
|
|
|
}
|
2012-04-28 14:17:38 +00:00
|
|
|
local BlastIncinerate = 100;
|
2011-10-15 01:47:24 +00:00
|
|
|
local Name = "$Name$";
|
2012-04-21 22:55:44 +00:00
|
|
|
local Description = "$Description$";
|