forked from Mirrors/openclonk
Mining now has a larger tolerance for single pixels when mining large amounts
Also removed some dead code and tuned Iron Peak a little
parent
ba8b011b8c
commit
16c50a07a0
|
@ -41,8 +41,8 @@ overlay MountainMaterials {
|
|||
RandomMat & overlay { mat=Ice; tex=ice3; };
|
||||
RandomMat & overlay { mat=Rock; tex=rock; };
|
||||
RandomMat & overlay { mat=Tunnel; tex=tunnel; };
|
||||
RandomMat & overlay { mat=Sulphur; tex=sulphur; };
|
||||
RandomMat & overlay { mat=Ore; tex=ore; };
|
||||
RandomMat & overlay { mat=Sulphur; tex=sulphur; };
|
||||
RandomMat & overlay { mat=Coal; tex=coal; };
|
||||
// A little more diagonal tunnels.
|
||||
overlay {
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
Resource Extraction
|
||||
Author: Maikel
|
||||
|
||||
Player must extract the resources of the specified type.
|
||||
Player must extract the resources of the specified type, the
|
||||
tolerance of this goal is 5% currently.
|
||||
|
||||
TODO: Expand to liquids and digable materials.
|
||||
--*/
|
||||
|
||||
|
@ -10,10 +12,12 @@
|
|||
#include Library_Goal
|
||||
|
||||
local resource_list; // List of materials to be mined.
|
||||
local tolerance_list; // List of initial counts of materials.
|
||||
|
||||
protected func Initialize()
|
||||
{
|
||||
resource_list = [];
|
||||
tolerance_list = [];
|
||||
return inherited(...);
|
||||
}
|
||||
|
||||
|
@ -23,6 +27,9 @@ public func SetResource(string resource)
|
|||
{
|
||||
var pos = GetLength(resource_list);
|
||||
resource_list[pos] = resource;
|
||||
var mat_cnt = GetMaterialCount(Material(resource));
|
||||
var blast_ratio = GetMaterialVal("Blast2ObjectRatio", "Material", Material(resource));
|
||||
tolerance_list[pos] = Max(1, mat_cnt / blast_ratio / 20);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -34,10 +41,11 @@ public func IsFulfilled()
|
|||
for (var i = 0; i < GetLength(resource_list); i++)
|
||||
{
|
||||
var mat = resource_list[i];
|
||||
var tol = tolerance_list[i];
|
||||
var mat_cnt = GetMaterialCount(Material(mat));
|
||||
var blast_ratio = GetMaterialVal("Blast2ObjectRatio", "Material", Material(mat));
|
||||
// Still solid material to be mined.
|
||||
if (mat_cnt == -1 || mat_cnt > 3 * blast_ratio / 2)
|
||||
if (mat_cnt == -1 || mat_cnt > (2*tol+1) * blast_ratio / 2)
|
||||
return false;
|
||||
var res_id = GetMaterialVal("Blast2Object", "Material", Material(mat));
|
||||
// Still objects of material to be collected.
|
||||
|
@ -71,11 +79,12 @@ public func Activate(int plr)
|
|||
for (var i = 0; i < GetLength(resource_list); i++)
|
||||
{
|
||||
var mat = resource_list[i];
|
||||
var tol = tolerance_list[i];
|
||||
var mat_cnt = GetMaterialCount(Material(mat));
|
||||
var res_id = GetMaterialVal("Blast2Object", "Material", Material(mat));
|
||||
var res_cnt = ObjectCount(Find_ID(res_id));
|
||||
var blast_ratio = GetMaterialVal("Blast2ObjectRatio", "Material", Material(mat));
|
||||
var add_msg = Format("$MsgGoalResource$", res_id, (mat_cnt - blast_ratio / 2) / blast_ratio, res_cnt);
|
||||
var add_msg = Format("$MsgGoalResource$", res_id, (mat_cnt - (2*tol+1) * blast_ratio / 2) / blast_ratio, res_cnt);
|
||||
message = Format("%s%s", message, add_msg);
|
||||
}
|
||||
}
|
||||
|
@ -92,11 +101,12 @@ public func GetShortDescription(int plr)
|
|||
for (var i = 0; i < GetLength(resource_list); i++)
|
||||
{
|
||||
var mat = resource_list[i];
|
||||
var tol = tolerance_list[i];
|
||||
var mat_cnt = GetMaterialCount(Material(mat));
|
||||
var res_id = GetMaterialVal("Blast2Object", "Material", Material(mat));
|
||||
var res_cnt = ObjectCount(Find_ID(res_id));
|
||||
var blast_ratio = GetMaterialVal("Blast2ObjectRatio", "Material", Material(mat));
|
||||
msg = Format("%s{{%i}}: %d ", msg, res_id, (mat_cnt - blast_ratio / 2) / blast_ratio + res_cnt);
|
||||
msg = Format("%s{{%i}}: %d ", msg, res_id, (mat_cnt - (2*tol+1) * blast_ratio / 2) / blast_ratio + res_cnt);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
|
|
@ -51,26 +51,10 @@ public func GetInteractionMetaInfo(object clonk)
|
|||
public func Interact(object clonk)
|
||||
{
|
||||
// Open production menu for the caller.
|
||||
clonk->CreateProductionMenu(this);
|
||||
//OpenProductionMenu(clonk);
|
||||
clonk->CreateProductionMenu(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
private func OpenProductionMenu(object clonk)
|
||||
{
|
||||
// Create menu for the clonk.
|
||||
clonk->CreateMenu(GetID(), this, C4MN_Extra_Components, "Production menu");
|
||||
// Cycle through all definitions to find the ones this producer can produce.
|
||||
var index = 0, product;
|
||||
while (product = GetDefinition(index))
|
||||
{
|
||||
if (IsProduct(product))
|
||||
clonk->AddMenuItem(Format("Produce %s", product->GetName()), "OnProductSelection", product);
|
||||
index++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
protected func OnProductSelection(id product, int par, bool alt)
|
||||
{
|
||||
if (!product)
|
||||
|
|
Loading…
Reference in New Issue