From f9e4cef0b2b313f372539eedeb959562506aaecd Mon Sep 17 00:00:00 2001 From: Clonkonaut Date: Sun, 26 Jan 2014 21:58:19 +0100 Subject: [PATCH] Producer / construction sites handle chunks. Added IsChunk() callback. Changed building material of various building to Chunk_Rock. Chunks enter producers via ForceEnterProducer(), producer will split chunks. --- .../Items.ocd/Chunks.ocd/Coal.ocd/Script.c | 1 + .../Items.ocd/Chunks.ocd/Gold.ocd/Script.c | 6 +- .../Items.ocd/Chunks.ocd/Ore.ocd/Script.c | 6 +- .../Items.ocd/Chunks.ocd/Rock.ocd/Script.c | 2 + .../Libraries.ocd/CarryHeavy.ocd/Script.c | 1 + .../Libraries.ocd/Producer.ocd/Script.c | 56 ++++++++++--------- .../Structures.ocd/Foundry.ocd/DefCore.txt | 2 +- .../Structures.ocd/Foundry.ocd/Script.c | 2 +- .../Structures.ocd/Kitchen.ocd/DefCore.txt | 2 +- .../Structures.ocd/Loom.ocd/DefCore.txt | 2 +- .../Structures.ocd/Sawmill.ocd/DefCore.txt | 2 +- .../Structures.ocd/Sawmill.ocd/Script.c | 1 + .../SteamEngine.ocd/DefCore.txt | 2 +- .../Structures.ocd/StoneDoor.ocd/DefCore.txt | 2 +- .../Structures.ocd/Windmill.ocd/DefCore.txt | 2 +- .../Structures.ocd/Windmill.ocd/Script.c | 2 +- .../WoodenCabin.ocd/DefCore.txt | 2 +- 17 files changed, 55 insertions(+), 38 deletions(-) diff --git a/planet/Objects.ocd/Items.ocd/Chunks.ocd/Coal.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Chunks.ocd/Coal.ocd/Script.c index 0fc2c98ac..c70f9ceec 100644 --- a/planet/Objects.ocd/Items.ocd/Chunks.ocd/Coal.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Chunks.ocd/Coal.ocd/Script.c @@ -13,6 +13,7 @@ protected func Hit(x, y) public func IsFuel() { return true; } public func GetFuelAmount() { return 400; } +public func IsChunk() { return true; } func Definition(def) { SetProperty("PictureTransformation", Trans_Mul(Trans_Rotate(30,0,0,1),Trans_Rotate(-30,1,0,0),Trans_Scale(1300)),def); diff --git a/planet/Objects.ocd/Items.ocd/Chunks.ocd/Gold.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Chunks.ocd/Gold.ocd/Script.c index cdd4e91f4..488160556 100644 --- a/planet/Objects.ocd/Items.ocd/Chunks.ocd/Gold.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Chunks.ocd/Gold.ocd/Script.c @@ -11,8 +11,12 @@ protected func Hit(x, y) return true; } -public func IsFoundryIngredient() { return true; } public func IsValuable(){ return true; } +public func ForceEnterProducer(id id) +{ + if (id == Foundry) return true; +} +public func IsChunk() { return true; } func Definition(def) { SetProperty("PictureTransformation", Trans_Mul(Trans_Rotate(30,0,0,1),Trans_Rotate(-30,1,0,0),Trans_Scale(1300)),def); diff --git a/planet/Objects.ocd/Items.ocd/Chunks.ocd/Ore.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Chunks.ocd/Ore.ocd/Script.c index 4cc4e1cd3..2867414a8 100644 --- a/planet/Objects.ocd/Items.ocd/Chunks.ocd/Ore.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Chunks.ocd/Ore.ocd/Script.c @@ -11,7 +11,11 @@ protected func Hit(x, y) return true; } -public func IsFoundryIngredient() { return true; } +public func ForceEnterProducer(id id) +{ + if (id == Foundry) return true; +} +public func IsChunk() { return true; } func Definition(def) { SetProperty("PictureTransformation", Trans_Mul(Trans_Rotate(30,0,0,1),Trans_Rotate(-30,1,0,0),Trans_Scale(1300)),def); diff --git a/planet/Objects.ocd/Items.ocd/Chunks.ocd/Rock.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Chunks.ocd/Rock.ocd/Script.c index 8abc1d1da..87a6187ca 100644 --- a/planet/Objects.ocd/Items.ocd/Chunks.ocd/Rock.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Chunks.ocd/Rock.ocd/Script.c @@ -11,6 +11,8 @@ protected func Hit(x, y) return true; } +public func IsChunk() { return true; } + func Definition(def) { SetProperty("PictureTransformation", Trans_Mul(Trans_Rotate(30,0,0,1),Trans_Rotate(-30,1,0,0),Trans_Scale(1300)),def); } diff --git a/planet/Objects.ocd/Libraries.ocd/CarryHeavy.ocd/Script.c b/planet/Objects.ocd/Libraries.ocd/CarryHeavy.ocd/Script.c index 9caa300d2..d8884adf0 100644 --- a/planet/Objects.ocd/Libraries.ocd/CarryHeavy.ocd/Script.c +++ b/planet/Objects.ocd/Libraries.ocd/CarryHeavy.ocd/Script.c @@ -165,6 +165,7 @@ func FxIntCarryHeavyStop(object clonk, proplist effect, int reason, bool temp) if (temp) return; clonk->EnableScale(); clonk->EnableHangle(); + Log("hey"); clonk.ThrowSpeed += effect.throw; } diff --git a/planet/Objects.ocd/Libraries.ocd/Producer.ocd/Script.c b/planet/Objects.ocd/Libraries.ocd/Producer.ocd/Script.c index 307f42711..3e0d34cd5 100644 --- a/planet/Objects.ocd/Libraries.ocd/Producer.ocd/Script.c +++ b/planet/Objects.ocd/Libraries.ocd/Producer.ocd/Script.c @@ -159,7 +159,7 @@ public func ProductionCosts(id item_id) { var amount = GetComponent(comp_id, index, nil, item_id); comp_list[index] = [comp_id, amount]; - index++; + index++; } return comp_list; } @@ -347,8 +347,7 @@ private func Produce(id product) { // Already producing? Wait a little. if (IsProducing()) - return false; - + return false; // Check if components are available. if (!CheckComponents(product)) return false; @@ -372,7 +371,7 @@ private func Produce(id product) CheckFuel(product, true); CheckLiquids(product, true); CheckMaterials(product, true); - + // Add production effect. AddEffect("ProcessProduction", this, 100, 2, this, nil, product); @@ -651,6 +650,15 @@ public func RequestObject(id obj_id, int amount) /*-- Storage --*/ +// Split chunks +func Collection2(object obj) +{ + if (obj->~IsChunk()) + Schedule(obj, "Split2Components()", 1); + // 1 frame delay, so the chunk can trigger the appriopriate carry heavy ending calls + // i.e. FxIntCarryHeavyStop +} + protected func RejectCollect(id item, object obj) { // Just return RejectEntrance for this object. @@ -663,10 +671,14 @@ protected func RejectEntrance(object obj) // Products itself may be collected. if (IsProduct(obj_id)) return false; - - // Components of products may be collected. + + // Items may force themselves into containers (for whatever reason they choose) + if (obj->~ForceEnterProducer(this->GetID())) + return false; + for (var product in GetProducts()) { + // Components of products may be collected. var i = 0, comp_id; while (comp_id = GetComponent(nil, i, nil, product)) { @@ -674,27 +686,19 @@ protected func RejectEntrance(object obj) return false; i++; } - } - // Fuel for products may be collected. - if (obj->~IsFuel()) - { - for (var product in GetProducts()) - if (FuelNeed(product) > 0) - return false; - } - // Liquid containers may be collected if a product needs them. - if (obj->~IsLiquidContainer()) - { - for (var product in GetProducts()) - if (LiquidNeed(product)) - return false; - } - // Material containers may be collected if a product needs them. - if (obj->~IsMaterialContainer()) - { - for (var product in GetProducts()) - if (MaterialNeed(product)) + // Fuel for products may be collected. + if (FuelNeed(product) > 0) + if (obj->~IsFuel()) + return false; + // Liquid containers may be collected if a product needs them. + if (LiquidNeed(product)) + if (obj->~IsLiquidContainer()) + return false; + // Material containers may be collected if a product needs them. + if (MaterialNeed(product)) + if (obj->~IsMaterialContainer()) return false; } + return true; } diff --git a/planet/Objects.ocd/Structures.ocd/Foundry.ocd/DefCore.txt b/planet/Objects.ocd/Structures.ocd/Foundry.ocd/DefCore.txt index ebd0d1cc5..5fab8ea2a 100644 --- a/planet/Objects.ocd/Structures.ocd/Foundry.ocd/DefCore.txt +++ b/planet/Objects.ocd/Structures.ocd/Foundry.ocd/DefCore.txt @@ -11,7 +11,7 @@ VertexY=-17,-25,-14,25,25,25 VertexFriction=50,50,50,100,100,100 Value=200 Mass=4500 -Components=Rock=4;Wood=2; +Components=Chunk_Rock=1;Wood=2; Exclusive=1 Construction=1 ContainBlast=1 diff --git a/planet/Objects.ocd/Structures.ocd/Foundry.ocd/Script.c b/planet/Objects.ocd/Structures.ocd/Foundry.ocd/Script.c index f944a9812..fa2a9890f 100644 --- a/planet/Objects.ocd/Structures.ocd/Foundry.ocd/Script.c +++ b/planet/Objects.ocd/Structures.ocd/Foundry.ocd/Script.c @@ -69,7 +69,7 @@ func CollectionZone() func Collection() { Sound("Clonk"); - return; + return _inherited(...); } public func FxSmeltingTimer(object target, proplist effect, int time) diff --git a/planet/Objects.ocd/Structures.ocd/Kitchen.ocd/DefCore.txt b/planet/Objects.ocd/Structures.ocd/Kitchen.ocd/DefCore.txt index ee94b9735..191a5aaab 100644 --- a/planet/Objects.ocd/Structures.ocd/Kitchen.ocd/DefCore.txt +++ b/planet/Objects.ocd/Structures.ocd/Kitchen.ocd/DefCore.txt @@ -11,7 +11,7 @@ VertexY=-17,-25,-14,25,25,25 VertexFriction=50,50,50,100,100,100 Value=200 Mass=4500 -Components=Wood=3;Rock=2;Metal=1 +Components=Wood=3;Chunk_Rock=1;Metal=1 Exclusive=1 Construction=1 ContainBlast=1 diff --git a/planet/Objects.ocd/Structures.ocd/Loom.ocd/DefCore.txt b/planet/Objects.ocd/Structures.ocd/Loom.ocd/DefCore.txt index bc4a246cf..763689d22 100644 --- a/planet/Objects.ocd/Structures.ocd/Loom.ocd/DefCore.txt +++ b/planet/Objects.ocd/Structures.ocd/Loom.ocd/DefCore.txt @@ -11,7 +11,7 @@ VertexY=-4,-3,14,14 VertexFriction=50,50,100,100 Value=100 Mass=1000 -Components=Wood=3;Metal=1;Rock=1 +Components=Wood=3;Metal=1;Chunk_Rock=1 Exclusive=1 Construction=1 ContainBlast=1 diff --git a/planet/Objects.ocd/Structures.ocd/Sawmill.ocd/DefCore.txt b/planet/Objects.ocd/Structures.ocd/Sawmill.ocd/DefCore.txt index ea0c20609..4e0246c96 100644 --- a/planet/Objects.ocd/Structures.ocd/Sawmill.ocd/DefCore.txt +++ b/planet/Objects.ocd/Structures.ocd/Sawmill.ocd/DefCore.txt @@ -11,7 +11,7 @@ VertexY=-14,-13,14,-13,14,14 VertexFriction=50,50,100,50,100,100 Value=50 Mass=1500 -Components=Rock=4;Wood=1; +Components=Chunk_Rock=1;Wood=1; Exclusive=1 Construction=1 ContainBlast=1 diff --git a/planet/Objects.ocd/Structures.ocd/Sawmill.ocd/Script.c b/planet/Objects.ocd/Structures.ocd/Sawmill.ocd/Script.c index 995e52b87..d7334dd83 100644 --- a/planet/Objects.ocd/Structures.ocd/Sawmill.ocd/Script.c +++ b/planet/Objects.ocd/Structures.ocd/Sawmill.ocd/Script.c @@ -122,6 +122,7 @@ func CollectionZone() protected func Collection() { Sound("Clonk"); + return _inherited(...); } public func FxSawingTimer(object target, proplist effect, int time) diff --git a/planet/Objects.ocd/Structures.ocd/SteamEngine.ocd/DefCore.txt b/planet/Objects.ocd/Structures.ocd/SteamEngine.ocd/DefCore.txt index b877be01e..da9c2d8a6 100644 --- a/planet/Objects.ocd/Structures.ocd/SteamEngine.ocd/DefCore.txt +++ b/planet/Objects.ocd/Structures.ocd/SteamEngine.ocd/DefCore.txt @@ -11,7 +11,7 @@ VertexY=-4,-4,24,24,24 VertexFriction=50,50,100,100 Value=180 Mass=4000 -Components=Rock=6;Metal=3 +Components=Chunk_Rock=2;Metal=3 Collection=-33,7,12,12 Exclusive=1 Construction=1 diff --git a/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/DefCore.txt b/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/DefCore.txt index 7709303a2..af90d42e8 100644 --- a/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/DefCore.txt +++ b/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/DefCore.txt @@ -12,5 +12,5 @@ VertexCNAT=4,8 SolidMask=0,0,8,40,0,0 Value=10 Mass=1000 -Components=Rock=10; +Components=Chunk_Rock=3; HorizontalFix=1 \ No newline at end of file diff --git a/planet/Objects.ocd/Structures.ocd/Windmill.ocd/DefCore.txt b/planet/Objects.ocd/Structures.ocd/Windmill.ocd/DefCore.txt index 5996f1897..941a71def 100644 --- a/planet/Objects.ocd/Structures.ocd/Windmill.ocd/DefCore.txt +++ b/planet/Objects.ocd/Structures.ocd/Windmill.ocd/DefCore.txt @@ -11,7 +11,7 @@ VertexY=-10,-20,47,47,-20 VertexFriction=50,50,100,100,50 Value=150 Mass=2500 -Components=Rock=6;Wood=2; +Components=Chunk_Rock=1;Wood=2; Exclusive=1 Construction=1 ContainBlast=1 diff --git a/planet/Objects.ocd/Structures.ocd/Windmill.ocd/Script.c b/planet/Objects.ocd/Structures.ocd/Windmill.ocd/Script.c index 23d47d96b..4c8b45f76 100644 --- a/planet/Objects.ocd/Structures.ocd/Windmill.ocd/Script.c +++ b/planet/Objects.ocd/Structures.ocd/Windmill.ocd/Script.c @@ -106,7 +106,7 @@ func CollectionZone() protected func Collection() { Sound("Clonk"); - return; + return _inherited(...); } public func FxCrushingTimer(object target, proplist effect, int time) diff --git a/planet/Objects.ocd/Structures.ocd/WoodenCabin.ocd/DefCore.txt b/planet/Objects.ocd/Structures.ocd/WoodenCabin.ocd/DefCore.txt index 200993f13..8d844eb61 100644 --- a/planet/Objects.ocd/Structures.ocd/WoodenCabin.ocd/DefCore.txt +++ b/planet/Objects.ocd/Structures.ocd/WoodenCabin.ocd/DefCore.txt @@ -11,7 +11,7 @@ VertexY=-7,-6,19,19,4,19,-4,19 VertexFriction=50,50,100,100 Value=200 Mass=4000 -Components=Wood=5;Rock=4 +Components=Wood=5;Chunk_Rock=1 Entrance=-12,0,13,20 Exclusive=1 Construction=1