added toolsworkshop, steam engine, windmill, lorry and new energy system (Maikel)

stable-5.2
Richard Gerum 2009-10-05 21:17:50 +02:00
parent ec6f31d5ea
commit d33dab4189
70 changed files with 1112 additions and 1 deletions

View File

@ -345,7 +345,7 @@ func OpenSellMenu(object pClonk, int iSelection, bool fNoListUpdate)
var iIndex;
for(aArray in aSellList) // aArray contains [idDef, iCount, pObj]
{
pClonk->AddMenuItem(Format("$TxtSell$", GetName(aArray[2])), "SellDummy", aArray[0], aArray[1], pClonk, nil, 128+4, aArray[2], GetSellValue(aArray[2]));
pClonk->AddMenuItem(Format("$TxtSell$", aArray[2]->GetName()), "SellDummy", aArray[0], aArray[1], pClonk, nil, 128+4, aArray[2], GetSellValue(aArray[2]));
iIndex++;
}
if(iSelection == iIndex) iSelection--;

View File

@ -0,0 +1,8 @@
[DefCore]
id=PWRC
Version=4,9,0,0
Category=C4D_StaticBack
Width=13
Height=19
Offset=-6,-19
Picture=0,0,64,64

View File

@ -0,0 +1,2 @@
This script should be included by all power consumers.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,106 @@
/*-- Power consumer --*/
#strict 2
/*-- Public calls --*/
// Functions that specify object properties, should be overloaded by the consumer.
// Returns whether the object is a power consumer.
public func IsPowerConsumer()
{
return true;
}
// Returns if a power line can be connected to this object.
public func CanPowerConnect() // Other name?
{
return GetCon() >= 100;
}
/*-- Power consumption --*/
// Checks whether there is enough power to sustain iPowerNeed.
// returns true and substracts iPowerNeed if there is enough power, otherwise false.
// fSubstract determines whether the check substracts iPowerNeed.
// If false it starts showing the power need object.
// If true it stops showing the power need object.
public func CheckPower(int iPowerCheck, bool fNoSubstract)
{
if(!FindObject(Find_ID(ENRG))) // Rule: Consumers do not need power.
return true;
// Check all power generators connected to this consumer and sort them according to priority.
for(var pGenerator in FindObjects(Find_PowerGenerator(), Sort_GeneratorPriority()))
{
var iPower = pGenerator -> GetPower();
if(iPower > iPowerCheck)
{
if(!fNoSubstract)
pGenerator -> DoPower(-iPowerCheck);
RemoveEffect("EnergyNeed", this);
return true;
}
}
AddEffect("EnergyNeed", this, 100, 12, this);
return false;
}
// Finds all power generators connected to pConsumer (can be nil in local calls).
private func Find_PowerGenerator(object pConsumer)
{
if(!pConsumer) pConsumer = this;
return [C4FO_Func, "IsPowerGeneratorFor", pConsumer];
}
// Sorts power generators according to GetGeneratorPriority(), highest return value -> first in array.
private func Sort_GeneratorPriority()
{
return [C4SO_Reverse, [C4SO_Func, "GetGeneratorPriority"]];
}
/*-- Effect to show energy need --*/
private func FxEnergyNeedStart(object pTarget, int iEffectNumber, int iTemp)
{
// Start showing energy need symbol.
pTarget->SetGraphics(0, ENSY, GFX_Overlay, GFXOV_MODE_Base);
pTarget->SetObjDrawTransform(1000, 0, 0, 0, 1000, -500*GetID()->GetDefCoreVal("Height", "DefCore"), GFX_Overlay);
EffectVar(0, pTarget, iEffectNumber) = true; // Effect is showing symbol.
return 1;
}
private func FxEnergyNeedStop(object pTarget, int iEffectNumber, int iReason, bool fTemp)
{
// Stop showing energy need symbol.
pTarget->SetGraphics(0, 0, GFX_Overlay, GFXOV_MODE_Base);
return 1;
}
private func FxEnergyNeedEffect(string szNewEffectName, object pTarget, int iEffectNumber, int iNewEffectNumber)
{
// Only one effect per object.
return -1;
}
private func FxEnergyNeedTimer(object pTarget, int iEffectNumber, int iEffectTime)
{
// Alternate showing of the symbol: iTimerInterval of AddEffect determines alternation time.
if(EffectVar(0, pTarget, iEffectNumber)) // Effect was showing symbol.
{
// Do not show symbol.
pTarget->SetGraphics(nil, nil, GFX_Overlay, GFXOV_MODE_Base);
EffectVar(0, pTarget, iEffectNumber) = false;
}
else // Effect was not showing symbol.
{
// Do show symbol.
pTarget->SetGraphics(nil, PWRC, GFX_Overlay, GFXOV_MODE_Base);
pTarget->SetObjDrawTransform(1000, 0, 0, 0, 1000, -500*GetID()->GetDefCoreVal("Height", "DefCore"), GFX_Overlay);
EffectVar(0, pTarget, iEffectNumber) = true;
}
return 1;
}
func Definition(def) {
SetProperty("Name", "$Name$", def);
}

View File

@ -0,0 +1 @@
Name=Verbraucher

View File

@ -0,0 +1 @@
Name=Consumer

View File

@ -0,0 +1,7 @@
[DefCore]
id=PWRG
Version=4,9,0,0
Category=C4D_StaticBack
Width=1
Height=1
Picture=0,0,64,64

View File

@ -0,0 +1,2 @@
This object should be included by all power generators.

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

View File

@ -0,0 +1,107 @@
/*-- Power generator --*/
#strict 2
// Local variable to keep track of the power level inside the generator.
local iPower;
/*-- Public calls --*/
// Functions that specify object properties, should be overloaded by the generator.
// Maximum amount of power that can be stored in this power generator.
public func GetCapacity()
{
return 0;
}
// This object is a power generator.
public func IsPowerGenerator()
{
return true;
}
// Returns if a power line can be connected to this object.
public func CanPowerConnect() // Other name?
{
return GetCon() >= 100;
}
// Returns the generator's priority, consumers preferably drain from generators with the highest priority.
public func GetGeneratorPriority()
{
return 1;
}
// Returns whether this object is a power genarator connected to pConsumer.
// The other two parameters pNext and pOldLine are only used for recursive purposes.
public func IsPowerGeneratorFor(object pConsumer, object pNext, object pOldLine)
{
if(!pNext) // Initial call to this function.
pNext = pConsumer;
for(var pLine in FindObjects(Find_PowerLine(pNext))) // Check all lines connected to pNext.
{
if(pLine == pOldLine) // Recursive -> Not backwards<->forwards through lines.
continue;
//if(!pLine -> IsConnectedWith(pNext)) // Power line connected with pConsumer.
//continue;
var pEnd = pLine -> GetConnectedObject(pNext); // What is on the line's other end.
if(!pEnd) // Nothing on the other end.
continue;
if(pEnd == pConsumer) // End of a recursive loop.
continue;
if(pEnd == this) // Found this object, i.e. the generator.
return true;
if(IsPowerGeneratorFor(pConsumer, pEnd, pLine)) // This building is not found, continue with next pEnd as next building.
return true;
}
return false;
}
// Finds all power lines connected to pObject (can be nil in local calls).
private func Find_PowerLine(object pObject)
{
if(!pObject) pObject = this;
return [C4FO_Func, "IsConnectedTo", pObject];
}
/*-- Power generation --*/
// Functions that manipulate the power level.
// Returns the current power level of this object.
public func GetPower()
{
return iPower;
}
// Sets the current power level of this object.
public func SetPower(int iSetPower)
{
iPower = BoundBy(iSetPower, 0, GetCapacity());
return;
}
// Adds to the current power level of this object.
public func DoPower(int iDoPower)
{
iPower = BoundBy(iPower + iDoPower, 0, GetCapacity());
return;
}
/*-- Debug --*/
protected func Initialize()
{
AddEffect("ShowPower",this,100,10,this);
return _inherited(...);
}
private func FxShowPowerTimer(object pTarget, int iEffectNumber, int iEffectTime)
{
Message("P:%d", pTarget, pTarget->GetPower());
return true;
}
func Definition(def) {
SetProperty("Name", "$Name$", def);
}

View File

@ -0,0 +1 @@
Name=Generator

View File

@ -0,0 +1 @@
Name=Generator

View File

@ -25,6 +25,8 @@ public func ControlUse(object pByClonk, int iX, int iY)
public func IsTool() { return 1; }
public func IsToolProduct() { return 1; }
func Definition(def) {
SetProperty("Collectible", 1, def);
SetProperty("Name", "$Name$", def);

View File

@ -45,6 +45,8 @@ protected func CreateConstructionSite(idType)
public func IsTool() { return 1; }
public func IsToolProduct() { return 1; }
func Definition(def) {
SetProperty("Collectible", 1, def);
SetProperty("Name", "$Name$", def);

View File

@ -17,6 +17,8 @@ public func ControlUse(object pByClonk, int iX, int iY)
public func IsTool() { return 1; }
public func IsToolProduct() { return 1; }
func Definition(def) {
SetProperty("Collectible", 1, def);
SetProperty("Name", "$Name$", def);

View File

@ -0,0 +1,17 @@
[DefCore]
id=LNKT
Version=4,9,8
Category=C4D_Object|C4D_SelectMaterial|C4D_SelectKnowledge|C4D_SelectHomebase
MaxUserSelect=10
Width=8
Height=6
Offset=-4,-3
Vertices=1
VertexY=1
VertexFriction=50
Value=10
Mass=15
Components=METL=1
Picture=0,6,64,64
Rebuy=1
Collectible=1

View File

@ -0,0 +1,2 @@
Connect by pressing dig double.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -0,0 +1,11 @@
[DefCore]
id=PWRL
Version=4,9,8
Category=C4D_StaticBack
Width=1
Height=1
Vertices=2
Value=10
Mass=15
Picture=0,0,36,32
Line=C4D_LinePower

View File

@ -0,0 +1,2 @@
Leitet Energie.

View File

@ -0,0 +1 @@
Transfers energy.

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

View File

@ -0,0 +1,60 @@
/*-- Power line --*/
#strict 2
protected func Initialize()
{
SetAction("Connect");
SetVertexXY(0, GetX(), GetY());
SetVertexXY(1, GetX(), GetY());
SetPosition(0, 0);
}
// Returns true if this object is a functioning power line.
public func IsPowerLine()
{
return GetAction() == "Connect";
}
// Returns whether this power line is connected to pObject.
public func IsConnectedTo(object pObject)
{
return GetActionTarget(0) == pObject || GetActionTarget(1) == pObject;
}
// Returns the object which is connected to pObject through this power line.
public func GetConnectedObject(object pObject)
{
if(GetActionTarget(0) == pObject)
return GetActionTarget(1);
if(GetActionTarget(1) == pObject)
return GetActionTarget(0);
return;
}
protected func LineBreak(bool fNoMsg)
{
Sound("LineBreak");
if(!fNoMsg) BreakMessage();
}
private func BreakMessage()
{
var pLine = GetActionTarget(0);
if(pLine->GetID() != LNKT) pLine = GetActionTarget(1);
Message("$TxtLinebroke$", pLine);
}
func Definition(def) {
SetProperty("ActMap", {
Connect = {
Prototype = Action,
Name = "Connect",
Length = 0,
Delay = 0,
Procedure = DFA_CONNECT,
NextAction = "Connect",
}, }, def);
SetProperty("Name", "$Name$", def);
}

View File

@ -0,0 +1,2 @@
TxtLinebroke=Leitung gerissen
Name=Energieleitung

View File

@ -0,0 +1,2 @@
TxtLinebroke=Line broke
Name=Power line

View File

@ -0,0 +1,72 @@
/*-- Wire roll --*/
#strict 2
protected func Hit()
{
Sound("RockHit*");
}
public func IsToolProduct() { return 1; }
/*-- Line connection --*/
// Called with double dig: will connect power line to building at the clonk's position.
protected func Activate(object pClonk)
{
[$TxtConnectLine$]
pClonk->SetComDir(COMD_Stop);
// Is there an object which accepts power lines?
var pObj = FindObject(Find_AtPoint(), Find_Func("CanPowerConnect"));
// No such object -> message.
if(!pObj)
return Message("$TxtNoNewLine$", pClonk);
// Is there a power line connected to this wire roll?
var pLine = FindObject(Find_PowerLine());
if(pLine) // There already is a power line.
{
if(pObj == pLine->GetActionTarget(0) || pObj == pLine->GetActionTarget(1)) // Power line is already connected to pObj -> remove line.
{
pLine->RemoveObject();
Sound("Connect");
Message("$TxtLineRemoval$", pClonk);
return true;
}
else // Connect existing power line to pObj.
{
if(pLine->GetActionTarget(0) == this)
pLine->SetActionTargets(pObj, pLine->GetActionTarget(1));
else if(pLine->GetActionTarget(1) == this)
pLine->SetActionTargets(pLine->GetActionTarget(0), pObj);
else
return;
Sound("Connect");
Message("$TxtConnect$", pClonk, pObj->GetName());
RemoveObject();
return true;
}
}
else // A new power line needs to be created.
{
pLine = CreateObject(PWRL, 0, 0, NO_OWNER);
pLine->SetActionTargets(this, pObj);
Sound("Connect");
Message("$TxtConnect$", pClonk, pObj->GetName());
return true;
}
return true;
}
// Finds all power lines connected to pObject (can be nil in local calls).
private func Find_PowerLine(object pObject)
{
if(!pObject) pObject = this;
return [C4FO_Func, "IsConnectedTo", pObject];
}
func Definition(def) {
SetProperty("Name", "$Name$", def);
}

View File

@ -0,0 +1,5 @@
TxtConnectLine=Leitung verbinden
TxtNoNewLine=Hier kann keine neue Leitung verlegt werden.
TxtLineRemoval=Energieleitung abgenommen.
TxtConnect=Energieleitung verbunden|mit %s
Name=Drahtrolle

View File

@ -0,0 +1,5 @@
TxtConnectLine=Connect line
TxtNoNewLine=Cannot create a new line here.
TxtLineRemoval=Power line disconnected.
TxtConnect=Power line connected|to %s
Name=Wireroll

View File

@ -0,0 +1,24 @@
[DefCore]
id=WOOD
Version=4,10,0,0
Category=C4D_Object|C4D_SelectMaterial|C4D_SelectHomebase
MaxUserSelect=25
Width=12
Height=12
Offset=-7,-6
Vertices=3
VertexX=4,-5
VertexY=-1,2
VertexCNAT=1,2
VertexFriction=30,30
Value=2
Mass=6
Components=WOOD=1
ContactIncinerate=1
BlastIncinerate=5
Rebuy=1
Collectible=1
Rotate=1
Float=1
StretchGrowth=1

View File

@ -0,0 +1,2 @@
Geeignet als Bau- oder Brennmaterial.

View File

@ -0,0 +1 @@
Needed for construction or as firing material.

View File

@ -0,0 +1,21 @@
/*--- The Log ---*/
#strict 2
protected func Hit()
{
Sound("WoodHit*");
return 1;
}
func Incineration()
{
SetClrModulation (RGB(48, 32, 32));
}
public func IsFuel() { return 1; }
public func GetFuelAmount() { return 30; }
func Definition(def) {
SetProperty("Name", "$Name$", def);
}

View File

@ -0,0 +1 @@
Name=Holz

View File

@ -0,0 +1 @@
Name=Log

View File

@ -0,0 +1,9 @@
[DefCore]
id=ENRG
Version=4,9,8
Category=C4D_StaticBack|C4D_Rule
MaxUserSelect=1
Width=1
Height=1
Value=1
Picture=0,0,64,64

View File

@ -0,0 +1,2 @@
Power consumers such as the elevator need to be connected to a power source such as the windmill using line construction kits.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1,13 @@
/*-- Power usage --*/
#strict 2
protected func Activate(int iByPlayer)
{
MessageWindow(GetDesc(), iByPlayer);
return true;
}
func Definition(def) {
SetProperty("Name", "$Name$", def);
}

View File

@ -0,0 +1 @@
Name=Energiebedarf

View File

@ -0,0 +1 @@
Name=Power need

View File

@ -0,0 +1,28 @@
[DefCore]
id=POWR
Version=4,9,8
Category=C4D_Structure|C4D_SelectBuilding|C4D_SelectKnowledge
MaxUserSelect=1
TimerCall=ContentsCheck
Width=110
Height=80
Offset=-55,-40
Vertices=5
VertexX=-26,30,-32,32,0
VertexY=-6,-6,40,40,40
VertexFriction=50,50,100,100
Value=180
Mass=4000
Components=ROCK=6;METL=3
Picture=0,0,64,52
Collection=-53,15,15,17
Exclusive=1
BlastIncinerate=130
BurnTo=POWB
LineConnect=C4D_PowerOutput|C4D_PowerGenerator|C4D_LiquidInput
Construction=1
ContainBlast=1
AutoContextMenu=1
[Physical]
Energy=100000

View File

@ -0,0 +1 @@
Energieerzeugung mit fossilen Brennstoffen. Verarbeitet Kohle, Öl und Holz.

View File

@ -0,0 +1 @@
Turns coal, oil, or wood into energy.

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

View File

@ -0,0 +1,83 @@
/*-- Steam engine --*/
#strict 2
#include PWRG
/*-- Power system --*/
public func GetCapacity() { return 500; }
public func GetGeneratorPriority() { return 128; }
local iFuelAmount;
func Initialize()
{
iFuelAmount = 0;
return _inherited();
}
func ContentsCheck()
{
// Still active?
if(!ActIdle())
return true;
// No need for power?
if(GetPower() >= GetCapacity())
return true;
// 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;
}
return 0;
}
func ConsumeFuel()
{
// Are we full? Stop
if(GetPower() >= GetCapacity())
return SetAction("Idle");
// Use up fuel and create power
DoPower(50);
if(iFuelAmount)
iFuelAmount--;
// All used up?
if(!iFuelAmount)
{
SetAction("Idle");
ContentsCheck();
}
}
func Definition(def) {
SetProperty("ActMap", {
Work = {
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",
}, }, def);
SetProperty("Name", "$Name$", def);
}

View File

@ -0,0 +1,2 @@
Name=Dampfmaschine

View File

@ -0,0 +1 @@
Name=Steam engine

View File

@ -0,0 +1,26 @@
[DefCore]
id=TWKS
Version=4,9,8
Category=C4D_Structure|C4D_SelectBuilding|C4D_SelectKnowledge
MaxUserSelect=2
Timer=20
TimerCall=CheckBuild
Width=52
Height=40
Offset=-26,-20
Vertices=4
VertexX=-26,26,-22,23
VertexY=-4,-3,19,19
VertexFriction=50,50,100,100
Value=200
Mass=4500
Components=WOOD=6;METL=3
Entrance=-8,0,25,20
Exclusive=1
BlastIncinerate=100
BurnTo=WRKB
LineConnect=C4D_PowerInput|C4D_PowerOutput|C4D_PowerConsumer
Construction=1
Rotate=1
ContainBlast=1
AutoContextMenu=1

View File

@ -0,0 +1 @@
Fabrik für Fahrzeuge und schwere Waffen.

View File

@ -0,0 +1 @@
Factory for vehicles and heavy weapons.

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -0,0 +1,214 @@
/*-- Tools workshop --*/
#strict 2
#include PWRC
/* Product properties (can be overloaded) */
func ProductType() { return C4D_Vehicle | C4D_Object; }
func ProductCondition() { return "IsToolProduct"; }
public func Initialize()
{
// the entrance is always open
SetEntrance(1);
}
public func NeedsEnergy()
{
if(CheckPower(100, true)) return false;
return true;
}
/* Production */
public func IsProducerOf(caller, def)
{
if (!(def->GetCategory () & ProductType())) return 0;
if (!IsBuilt ()) return 0;
if (!GetPlrKnowledge (caller->GetOwner(), def)) return 0;
if (ProductCondition ())
if (!DefinitionCall (def, ProductCondition ()))
return 0;
// Look for better
if (NeedsEnergy ())
if (FindSuppliedObjectCloseTo (caller)) return 0;
return 1;
}
func FindSuppliedObjectCloseTo (obj, def)
{
var obj2;
if (!def) def = GetID ();
for(var obj2 in FindObjects(Find_ID(def), Find_InRect((obj->GetX () - 1000) - GetX (), (obj->GetY () - 500) - GetY (), 2000, 1000),
Find_OCF(OCF_Fullcon)))
if (FindObject (Find_ID(PWRL),Find_Action("Connect",obj2)))
return obj2;
return 0;
}
public func HowToProduce (clonk, def)
{
if(NeedsEnergy())
{
clonk->AddCommand ("Call", this, def, 0, 0, 0, "HowToProduce");
clonk->AddCommand ("Energy", this);
return 1;
}
clonk->AddCommand ("Wait", 0, 0, 0, 0, 10);
clonk->AddCommand ("Call", this, def, 0, 0, 0, "StartProduction");
clonk->AddCommand ("Enter", this);
return 1;
}
private func MenuProduction(pCaller)
{
// Create menu and fill it with the plans of the player
pCaller->CreateMenu(CXCN,this,1,"$NoPlrKnowledge$");
for(var i=0,idKnowledge; idKnowledge=GetPlrKnowledge(pCaller->GetOwner(),0,i,ProductType ()); ++i)
{
if(ProductCondition())
if(!DefinitionCall(idKnowledge, ProductCondition()))
continue;
pCaller->AddMenuItem("$Construction$: %s", "SelectProduction", idKnowledge, 0, pCaller);
}
return 1;
}
public func SelectProduction(idType,pWorker,bSpecial2)
{
// Start working
pWorker->AddCommand("Call",this,idType,bSpecial2,0,0,"StartProduction", 0, 1);
// but enter the workshop before
pWorker->AddCommand("Enter",this);
return 1;
}
public func StartProduction(pWorker,idType,bSpecial2)
{
var pToBuild;
// Look for half object to finish
pToBuild=FindIncompleteContents(idType);
// If not create new object
if(!pToBuild)
if(!(pToBuild=CreateConstruction(idType,0,0,GetOwner(),1))) return 0;
// Put new object into the workshop
if (pToBuild->Contained()!=this)
pToBuild->Enter(this);
// Inform product
pToBuild->~OnStartProduction(this);
// Order to build
pWorker->AddCommand("Build",pToBuild, 0,0,0,0,0,0, 3);
if(bSpecial2)
pWorker->AppendCommand("Call",this,idType,bSpecial2,0,0,"ProductionComplete", 0, 1);
return 1;
}
public func ProductionCompleteFailed(pWorker,idType,bSpecial2)
{
// Action "Build" can't be executed (resources are missing)
// To recieve the Message "x needs y" execute one more the command "Build"
// so that it fails and puts out the message.
pWorker->AddCommand("Build",FindIncompleteContents(idType));
return 1;
}
public func ProductionComplete(pWorker,idType,bSpecial2)
{
// No continuous production? Stop
if(!bSpecial2) return 0;
// and than start again ... (and wait a bit)
pWorker->AppendCommand("Wait",0,0,0,0,35);
pWorker->AppendCommand("Call",this,idType,bSpecial2,0,0,"StartProduction");
return 1;
}
/* Context */
public func ContextConstruction(pCaller)
{
[$Production$|Image=CXCN|Condition=IsBuilt]
return MenuProduction(pCaller);
}
protected func IsBuilt()
{
return GetCon() >= 100;
}
/* Control */
protected func ContainedUp(pCaller)
{
[$Production$|Image=CXCN]
return MenuProduction(pCaller);
}
/* Activity */
private func CheckBuild()
{
// TimerCall: The workshop starts its own Build-Action, when
// someone works in the workshop. The work in a building only proceeds
// when the building supports this with an own build-action.
var bWorkingClonk=IsWorking();
var bBuildingAction=(GetAction()=="Build");
if(bWorkingClonk && !bBuildingAction) if (ActIdle()) SetAction("Build");
if(!bWorkingClonk && bBuildingAction )
{
SetAction("Idle");
NeedsEnergy();
}
return 1;
}
private func IsWorking()
{
// Does someone work in the workshop?
if (!Contents()) return 0;
return FindObject(Find_Container(this), Find_Func("IsClonk"));//Find_Action("Build"));
}
private func Smoking()
{
if (GetPhase()%3) return 1;
if (Random(6)) Smoke(+16,-14,16);
if (Random(8)) Smoke(10,-14,15+Random(3));
return 1;
}
public func SetSign(id def)
{
var iSize = Max(def->GetDefCoreVal("Picture", "DefCore", 2), def->GetDefCoreVal("Picture", "DefCore", 3));
SetGraphics("", def, 1, 4);
SetObjDrawTransform(200, 0, 460*iSize, 0, 200, 90*iSize, 1);
}
/* Helper functions */
private func FindIncompleteContents(idSearched)
{
for(var i=0,pContent; pContent=Contents(i); ++i)
if(pContent->GetID()==idSearched)
if(pContent->GetCon()<100)
return pContent;
return 0;
}
func Definition(def) {
SetProperty("ActMap", {
Build = {
Prototype = Action,
Name = "Build",
Procedure = DFA_NONE,
Length = 40,
Delay = 1,
FacetBase=1,
NextAction = "Build",
//Animation = "Turn",
PhaseCall="Smoking",
}, }, def);
SetProperty("Name", "$Name$", def);
}

View File

@ -0,0 +1,4 @@
NoPlrKnowledge=Keine Baupläne vorhanden
Construction=Konstruktion
Production=Produktion
Name=Werkzeughütte

View File

@ -0,0 +1,4 @@
NoPlrKnowledge=No construction plans
Construction=Construction
Production=Production
Name=Tools workshop

View File

@ -0,0 +1,25 @@
[DefCore]
id=WMIL
Version=4,9,8
Category=C4D_Structure|C4D_SelectBuilding|C4D_SelectKnowledge
MaxUserSelect=3
TimerCall=Wind2Turn
Timer=10
Width=70
Height=90
Offset=-35,-45
Vertices=5
VertexX=-1,-10,9,-10,10
VertexY=-22,-14,-14,44,44
VertexFriction=50,50,100,100
Value=45
Mass=900
Components=WOOD=4;METL=1
Picture=30,0,80,94
Exclusive=1
ContactIncinerate=4
BlastIncinerate=60
LineConnect=C4D_PowerOutput|C4D_PowerGenerator
Construction=1
Rotate=1
Float=1

View File

@ -0,0 +1 @@
Liefert Energie für andere Gebäude und Maschinen.

View File

@ -0,0 +1 @@
Supplies your settlement with energy.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

@ -0,0 +1,2 @@
DE:Windrad
US:Windmill

View File

@ -0,0 +1,41 @@
/*-- Windmill --*/
#strict 2
#include PWRG
public func GetCapacity() { return 500; }
public func GetGeneratorPriority() { return 256; }
/* Initialisierung */
protected func Initialize()
{
SetAction("Turn");
return _inherited(...);
}
func Wind2Turn()
{
DoPower(Abs(GetWind()/4));
if(Abs(GetWind()) < 10) this["ActMap"]["Turn"]["Delay"] = 0;
else this["ActMap"]["Turn"]["Delay"] = BoundBy(5-Abs(GetWind())/10, 1, 5);
}
func Definition(def) {
SetProperty("ActMap", {
Turn = {
Prototype = Action,
Name = "Turn",
Procedure = DFA_NONE,
Length = 40,
Delay = 1,
X = 0,
Y = 0,
Wdt = 70,
Hgt = 90,
NextAction = "Turn",
//Animation = "Turn",
}, }, def);
SetProperty("Name", "$Name$", def);
}

View File

@ -0,0 +1 @@
Name=Windgenerator

View File

@ -0,0 +1 @@
Name=Wind generator

View File

@ -0,0 +1,24 @@
[DefCore]
id=LORY
Version=4,9,8
Category=C4D_Vehicle|C4D_SelectVehicle|C4D_SelectKnowledge|C4D_SelectHomebase
MaxUserSelect=5
ContactCalls=1
Width=22
Height=16
Offset=-11,-8
Vertices=4
VertexX=-8,7,-8,7
VertexY=-6,-6,7,7
VertexCNAT=5,6,9,10
VertexFriction=80,80,10,10
Value=20
Mass=75
Components=METL=1;WOOD=1;
Collection=-12,-8,24,10
CollectionLimit=51
Rebuy=1
Grab=1
GrabPutGet=C4D_GrabGet|C4D_GrabPut
Rotate=30
UprightAttach=8

View File

@ -0,0 +1 @@
Erleichtert den Transport größerer Materialmengen. Fasst bis zu 50 Objekte.

View File

@ -0,0 +1,2 @@
Useful to transport large amounts of material. Holds up to 50 items.

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -0,0 +1,141 @@
/*-- Lore --*/
#strict 2
/* Status */
public func IsLorry() { return 1; }
public func IsToolProduct() { return 1; }
/* Steuerung */
protected func ContactLeft()
{
if(Stuck() && !Random(5)) SetRDir(RandomX(-7, +7));
}
protected func ContactRight()
{
if(Stuck() && !Random(5)) SetRDir(RandomX(-7, +7));
}
private func ControlElevator(string szCommand, object pObject)
{
// Objekte an dieser Position überprüfen
for(var pElev in FindObjects(Find_AtPoint(1,1), Find_OCF(OCF_Grab), Find_NoContainer()))
// Im Fahrstuhlkorb
if(pElev->~IsElevator())
// Steuerung an Fahrstuhl weiterleiten
return pElev->Call(szCommand,pObject);
return 0;
}
private func ControlElevatorMovement(string szCommand, object pObject)
{
// Objekte an dieser Position überprüfen
for(var pElev in FindObjects(Find_AtPoint(1,1), Find_OCF(OCF_Grab), Find_NoContainer()))
// Fahrstuhlkorb gefunden
if(pElev->~IsElevator())
// Lore ist angehalten
if (GetComDir() == COMD_Stop)
// Steuerung an Fahrstuhl weiterleiten
return pElev->Call(szCommand,pObject);
return 0;
}
private func ControlElevatorStop(string szCommand, object pObject)
{
// Objekte an dieser Position überprüfen
for(var pElev in FindObjects(Find_AtPoint(1,1), Find_OCF(OCF_Grab), Find_NoContainer()))
// Fahrstuhlkorb gefunden
if(pElev->~IsElevator())
// Fahrstuhlkorb bewegt sich
if (pElev->GetComDir() != COMD_Stop)
{
// Fahrstuhlkorb anhalten
pElev->Call(szCommand,pObject);
// Noch nicht aussteigen
pObject->SetComDir(COMD_Stop);
SetComDir(COMD_Stop);
// Bewegunsbefehl abbrechen
return 1;
}
return 0;
}
/* Füllmengenkontrolle */
private func MaxContents() { return 50; }
protected func RejectCollect(id idObj,object pObj)
{
if(ContentsCount() < MaxContents()) { Sound("Clonk"); return 0; }
if(pObj->Contained()) return Message("$TxtLorryisfull$", this);
if(Abs(GetXDir(pObj))>6) SetYDir(-5,pObj);
Sound("WoodHit*");
return 1;
}
/* Automatisches Ausleeren in Gebäuden */
protected func Entrance(object pNewContainer)
{
// Nur in Gebäuden (auch Burgteile)
if (pNewContainer->GetCategory() & (C4D_StaticBack | C4D_Structure))
// Nicht, wenn es das Gebäude verbietet
if (!pNewContainer->~NoLorryEjection(this) && !pNewContainer->~IsStaircase())
{
// Lore entleeren
pNewContainer->GrabContents(this);
}
}
/* Einlade-Helfer */
protected func ContextLoadUp(object pClonk)
{
[$TxtLoadUp$|Image=LRY1]
// Alte Kommandos des Clonks löschen
pClonk->SetCommand("None");
// Lore ist bereits voll
if (ContentsCount() >= MaxContents())
return Message("$TxtLorryisfull$", this);
// Maximale noch mögliche Zuladung bestimmen
var iMaxLoad = MaxContents() - ContentsCount();
// Frei liegende Gegenstände in der Umgebung automatisch einladen
var iRange = 60;
var pObj, iCount;
for(pObj in FindObjects(Find_InRect(-iRange, -iRange/2, iRange*2, iRange*2), Find_OCF(OCF_Collectible), Find_NoContainer()))
if (pObj->GetOCF() & OCF_Available)
{
// Maximale Zuladung berücksichtigen (auch die noch vom Clonk kommt)
if (++iCount > iMaxLoad - pClonk->ContentsCount()) break;
// Einladen
pClonk->AddCommand("Put", this, 0,0, pObj);
}
// Der Clonk soll seine getragenen Objekte auch einladen (ansonsten legt er sie nur irgendwo ab)
for (var i = 0; i < Min(pClonk->ContentsCount(), iMaxLoad); i++)
pClonk->AddCommand("Put", this, 0,0, pClonk->Contents(i));
}
func Definition(def) {
SetProperty("ActMap", {
Drive = {
Prototype = Action,
Name = "Drive",
Procedure = DFA_NONE,
Directions = 2,
FlipDir = 1,
Length = 20,
Delay = 2,
X = 0,
Y = 0,
Wdt = 22,
Hgt = 16,
NextAction = "Drive",
//Animation = "Drive",
}, }, def);
SetProperty("Name", "$Name$", def);
}

View File

@ -0,0 +1,4 @@
TxtControl=Steuerung
TxtLorryisfull=Lore ist|voll.
TxtLoadUp=Einladen
Name=Lore

View File

@ -0,0 +1,4 @@
TxtControl=Control
TxtLorryisfull=Lorry is full!
TxtLoadUp=Load up
Name=Lorry