forked from Mirrors/openclonk
stalactite: updated stalactite model and improved placement & renamed "Stalactite1" to "Stalactite"
parent
07cc668f46
commit
250a20ccfc
|
@ -0,0 +1,16 @@
|
|||
[DefCore]
|
||||
id=Stalactite
|
||||
Version=5,2,0,1
|
||||
Category=C4D_Object
|
||||
Width=15
|
||||
Height=60
|
||||
Offset=-7, 0
|
||||
Vertices=2
|
||||
VertexX=0, 0
|
||||
VertexY=0, 60
|
||||
VertexCNAT=4, 8
|
||||
VertexFriction=300,300
|
||||
Mass=35
|
||||
StretchGrowth=1
|
||||
Oversize=1
|
||||
Rotate=1
|
Binary file not shown.
|
@ -0,0 +1,149 @@
|
|||
/**
|
||||
Stalactite
|
||||
Hangs from the ceiling
|
||||
|
||||
@author Armin, Win
|
||||
*/
|
||||
|
||||
public func Construction()
|
||||
{
|
||||
this.MeshTransformation = Trans_Rotate(Random(360), 0, 1, 0);
|
||||
|
||||
var sibling = nil;
|
||||
for (var bone in ["bone1", "bone2", "bone3"])
|
||||
{
|
||||
var transformation;
|
||||
var rand = Random(2);
|
||||
if (rand == 0)
|
||||
transformation = Trans_Rotate(RandomX(-20, 20), 1, 0, 0);
|
||||
else if(rand == 1)
|
||||
transformation = Trans_Rotate(RandomX(-20, 20), 0, 0, 1);
|
||||
sibling = TransformBone(bone, transformation, 1, Anim_Const(1000), sibling);
|
||||
}
|
||||
}
|
||||
|
||||
private func Hit()
|
||||
{
|
||||
RemoveObject();
|
||||
return true;
|
||||
}
|
||||
|
||||
public func Place(int amount, proplist rectangle, proplist settings)
|
||||
{
|
||||
// Only allow definition call.
|
||||
if (GetType(this) != C4V_Def)
|
||||
{
|
||||
FatalError("Stalactite::Place must be called as a definition call!");
|
||||
return;
|
||||
}
|
||||
// Default parameters.
|
||||
var loc_area = nil;
|
||||
if (rectangle)
|
||||
loc_area = Loc_InRect(rectangle);
|
||||
|
||||
var stalactites = [];
|
||||
for (var i = 0; i < amount; i++)
|
||||
{
|
||||
var loc = FindLocation(Loc_Tunnel(), Loc_Not(Loc_Liquid()), Loc_Wall(CNAT_Top), Loc_Space(40, true), loc_area);
|
||||
if (!loc)
|
||||
continue;
|
||||
var mat = MaterialName(GetMaterial(loc.x, loc.y - 1));
|
||||
var stalactite = CreateStalactite(loc.x, loc.y - 2, mat);
|
||||
|
||||
// Find the ground below and scale down in narrow tunnels.
|
||||
var ground_y = nil;
|
||||
for (var y = 10; y < 200; y += 10)
|
||||
{
|
||||
if (!GBackSolid(loc.x, loc.y + y)) continue;
|
||||
|
||||
// Search up and find actual surface.
|
||||
var up = 0;
|
||||
for (; up > -10; up -= 2)
|
||||
if (!GBackSolid(loc.x, loc.y + y + up)) break;
|
||||
|
||||
ground_y = loc.y + y + up;
|
||||
break;
|
||||
}
|
||||
|
||||
var con = 100;
|
||||
// Adjust size if there already is a stalactite very close.
|
||||
if (ObjectCount(Find_AtPoint(loc.x, loc.y), Find_ID(this)) > 1)
|
||||
con = RandomX(20, 50);
|
||||
|
||||
var height;
|
||||
if (ground_y)
|
||||
{
|
||||
height = ground_y - loc.y;
|
||||
con = Min(con, BoundBy(100 * height / 60 / 2, 25, 100));
|
||||
|
||||
}
|
||||
|
||||
stalactite->SetCon(con, nil, true);
|
||||
|
||||
// Create a stalagmite below?
|
||||
if (ground_y && height > 70 && Random(3))
|
||||
{
|
||||
// And place!
|
||||
if (MaterialName(GetMaterial(loc.x, ground_y + 2)) == mat)
|
||||
{
|
||||
var stalagmite = CreateStalactite(loc.x, ground_y + 2, mat, true);
|
||||
stalagmite->SetCon(con);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stalactites;
|
||||
}
|
||||
|
||||
private func CreateStalactite(int x, int y, string mat, bool stalagmite)
|
||||
{
|
||||
var stalactite = CreateObject(this, x, y);
|
||||
|
||||
// Ice stalactites are transparent and never use water sources.
|
||||
if (mat == "Ice")
|
||||
{
|
||||
stalactite->SetClrModulation(RGBa(157, 202, 243, 160));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Keep colour tone of the material, but increase lightness.
|
||||
var colour = GetAverageTextureColor(mat);
|
||||
if (colour != nil)
|
||||
{
|
||||
colour = RGB2HSL(colour);
|
||||
var hue = (colour >> 16) & 0xff;
|
||||
colour = HSL(hue, 100, 200);
|
||||
stalactite->SetClrModulation(colour);
|
||||
}
|
||||
if (!stalagmite && Random(2))
|
||||
stalactite->DrawWaterSource();
|
||||
}
|
||||
|
||||
if (stalagmite)
|
||||
{
|
||||
stalactite->SetR(180);
|
||||
}
|
||||
|
||||
return stalactite;
|
||||
}
|
||||
|
||||
private func DrawWaterSource()
|
||||
{
|
||||
var xold = GetX();
|
||||
var yold = GetY() - 2;
|
||||
var xnew = xold;
|
||||
var ynew = xnew;
|
||||
for (var i = 0; i < RandomX(30, 140); i++)
|
||||
{
|
||||
ynew--;
|
||||
xnew = xold + RandomX(-1, 1);
|
||||
if (GBackSemiSolid(xnew-GetX(), ynew-GetY()))
|
||||
DrawMaterialQuad("Water", xold,yold, xold+1,yold, xold+1,yold+1, xold,yold+1);
|
||||
else
|
||||
return;
|
||||
xold = xnew;
|
||||
yold = ynew;
|
||||
}
|
||||
}
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
|
@ -0,0 +1,40 @@
|
|||
material Stalactite
|
||||
{
|
||||
receive_shadows on
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 1.0 1.0 1.0 1.0
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.25 0.25 0.25 1.0 12.5
|
||||
emissive 0.0 0.0 0.0 1.0
|
||||
|
||||
scene_blend alpha_blend
|
||||
|
||||
texture_unit base
|
||||
{
|
||||
texture Stalactite_UV.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
|
||||
// texture_unit normal
|
||||
// {
|
||||
// texture Stalactite_Normal.png
|
||||
// tex_address_mode wrap
|
||||
// filtering trilinear
|
||||
// }
|
||||
//
|
||||
// vertex_program_ref normal_map_vertex
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// fragment_program_ref normal_map_fragment
|
||||
// {
|
||||
// param_named basemap int 0
|
||||
// param_named normalTex int 1
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 79 KiB |
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
|
@ -1,16 +0,0 @@
|
|||
[DefCore]
|
||||
id=Stalactite1
|
||||
Version=5,2,0,1
|
||||
Category=C4D_Object
|
||||
Width=15
|
||||
Height=60
|
||||
Offset=-7,-30
|
||||
Vertices=4
|
||||
VertexX=-7,0,0,7
|
||||
VertexY=-30,-30,30,-30
|
||||
VertexCNAT=4,4,8,4
|
||||
VertexFriction=300,300,100,300
|
||||
Mass=35
|
||||
StretchGrowth=1
|
||||
Oversize=1
|
||||
Rotate=1
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,28 +0,0 @@
|
|||
// Stalactite1 genrated by blender2ogre 0.6.0
|
||||
|
||||
material stalactite1_3Mat
|
||||
{
|
||||
receive_shadows on
|
||||
|
||||
technique
|
||||
{
|
||||
pass stalactite1_3Mat
|
||||
{
|
||||
cull_hardware none
|
||||
scene_blend alpha_blend
|
||||
|
||||
ambient 1.0 1.0 1.0 1.0
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.0 0.0 0.0 0.0 12.5
|
||||
emissive 0.0 0.0 0.0 0.0
|
||||
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture stalactite.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Stalactite1 genrated by blender2ogre 0.6.0
|
||||
|
||||
material stalactite1_1Mat
|
||||
{
|
||||
receive_shadows on
|
||||
|
||||
technique
|
||||
{
|
||||
pass stalactite1_1Mat
|
||||
{
|
||||
cull_hardware none
|
||||
scene_blend alpha_blend
|
||||
|
||||
ambient 1.0 1.0 1.0 1.0
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.0 0.0 0.0 0.0 12.5
|
||||
emissive 0.0 0.0 0.0 0.0
|
||||
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture stalactite.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Stalactite1 genrated by blender2ogre 0.6.0
|
||||
|
||||
material stalactite1_2Mat
|
||||
{
|
||||
receive_shadows on
|
||||
|
||||
technique
|
||||
{
|
||||
pass stalactite1_2Mat
|
||||
{
|
||||
cull_hardware none
|
||||
scene_blend alpha_blend
|
||||
|
||||
ambient 1.0 1.0 1.0 1.0
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.0 0.0 0.0 0.0 12.5
|
||||
emissive 0.0 0.0 0.0 0.0
|
||||
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture stalactite.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Stalactite1 genrated by blender2ogre 0.6.0
|
||||
|
||||
material stalactite1_4Mat
|
||||
{
|
||||
receive_shadows on
|
||||
|
||||
technique
|
||||
{
|
||||
pass stalactite1_4Mat
|
||||
{
|
||||
cull_hardware none
|
||||
scene_blend alpha_blend
|
||||
|
||||
ambient 1.0 1.0 1.0 1.0
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.0 0.0 0.0 0.0 12.5
|
||||
emissive 0.0 0.0 0.0 0.0
|
||||
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture stalactite.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Stalactite1 genrated by blender2ogre 0.6.0
|
||||
|
||||
material stalactite1_5Mat
|
||||
{
|
||||
receive_shadows on
|
||||
|
||||
technique
|
||||
{
|
||||
pass stalactite1_5Mat
|
||||
{
|
||||
cull_hardware none
|
||||
scene_blend alpha_blend
|
||||
|
||||
ambient 1.0 1.0 1.0 1.0
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.0 0.0 0.0 0.0 12.5
|
||||
emissive 0.0 0.0 0.0 0.0
|
||||
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture stalactite.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
/**
|
||||
Stalactite1
|
||||
Hangs from the ceiling
|
||||
|
||||
@author Armin, Win
|
||||
*/
|
||||
|
||||
private func Initialize()
|
||||
{
|
||||
SetGraphics(Format("%d", Random(6)));
|
||||
SetProperty("MeshTransformation", Trans_Mul(Trans_Scale(600 + Random(900)), Trans_Rotate(-25 + Random(50), 0, 1, 0)));
|
||||
}
|
||||
|
||||
private func Hit()
|
||||
{
|
||||
//Sound();
|
||||
RemoveObject();
|
||||
return true;
|
||||
}
|
||||
|
||||
public func Place(int amount, proplist rectangle, proplist settings)
|
||||
{
|
||||
// Only allow definition call.
|
||||
if (this != Stalactite1)
|
||||
return;
|
||||
// Default parameters.
|
||||
if (!settings)
|
||||
settings = { size = [100, 100] };
|
||||
if (!settings.size)
|
||||
settings.size = [100, 100];
|
||||
var loc_area = nil;
|
||||
if (rectangle)
|
||||
loc_area = Loc_InRect(rectangle);
|
||||
var loc_background = Loc_Tunnel();
|
||||
if (settings.underground)
|
||||
loc_background = Loc_Tunnel();
|
||||
|
||||
var stalactites = [];
|
||||
for (var i = 0; i < amount; i++)
|
||||
{
|
||||
var size = RandomX(settings.size[0], settings.size[1]);
|
||||
var loc = FindLocation(loc_background, Loc_Not(Loc_Liquid()), Loc_Wall(CNAT_Right), Loc_Wall(CNAT_Top), loc_area);
|
||||
if (!loc)
|
||||
continue;
|
||||
var mat = MaterialName(GetMaterial(loc.x, loc.y-30));
|
||||
CreateStalactite(loc.x, loc.y + 25, mat);
|
||||
|
||||
// If possible, try to create a stalagmite below the stalactite.
|
||||
if (Random(3))
|
||||
{
|
||||
var xy = FindConstructionSite(Stalactite1, loc.x, loc.y+60);
|
||||
if (xy)
|
||||
if (MaterialName(GetMaterial(loc.x, xy[1] + 2 + 30)) == mat)
|
||||
CreateStalactite(loc.x, xy[1]-28, mat, true);
|
||||
}
|
||||
}
|
||||
return stalactites;
|
||||
}
|
||||
|
||||
private func CreateStalactite(int x, int y, string mat, bool stalagmite)
|
||||
{
|
||||
var stalactite = CreateObject(Stalactite1, x, y);
|
||||
var tinys = CreateObject(TinyStalactite, x, y - 22);
|
||||
tinys->SetChild(stalactite);
|
||||
|
||||
// Ice stalactites are transparent and never use water sources.
|
||||
if (mat == "Ice")
|
||||
{
|
||||
stalactite->SetClrModulation(RGBa(157, 202, 243, 160));
|
||||
tinys->SetClrModulation(RGBa(157, 202, 243, 160));
|
||||
}
|
||||
else
|
||||
{
|
||||
stalactite->SetClrModulation(GetAverageTextureColor(mat));
|
||||
tinys->SetClrModulation(GetAverageTextureColor(mat));
|
||||
if (!stalagmite && Random(2))
|
||||
tinys->DrawWaterSource();
|
||||
}
|
||||
|
||||
if (stalagmite)
|
||||
{
|
||||
stalactite->SetR(180);
|
||||
tinys->SetPosition(x, y + 22);
|
||||
tinys->SetR(180);
|
||||
}
|
||||
// todo stalactite->AdjustPosition();
|
||||
}
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
|
@ -1,8 +0,0 @@
|
|||
[DefCore]
|
||||
id=TinyStalactite
|
||||
Version=5,2,0,1
|
||||
Category=C4D_StaticBack
|
||||
Width=15
|
||||
Height=16
|
||||
Offset=-7,-8
|
||||
Rotate=1
|
Binary file not shown.
|
@ -1,26 +0,0 @@
|
|||
material stalactiteTinyMat
|
||||
{
|
||||
receive_shadows on
|
||||
|
||||
technique
|
||||
{
|
||||
pass stalactiteTinyMat
|
||||
{
|
||||
cull_hardware none
|
||||
scene_blend alpha_blend
|
||||
|
||||
ambient 1.0 1.0 1.0 1.0
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.0 0.0 0.0 0.0 12.5
|
||||
emissive 0.0 0.0 0.0 0.0
|
||||
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture tinystalactite.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/**
|
||||
TinyStalactite
|
||||
Covers up the base of stalactites
|
||||
|
||||
@author Armin, Win
|
||||
*/
|
||||
|
||||
private func Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
private func SetChild(object target)
|
||||
{
|
||||
child = target;
|
||||
AddEffect("Parent", this, 1, 10, this);
|
||||
}
|
||||
|
||||
private func FxParentTimer(object target, effect, int time)
|
||||
{
|
||||
if (!child)
|
||||
{
|
||||
child = CreateObject(Stalactite1);
|
||||
}
|
||||
//SetPosition(parent->GetX(), parent->GetY());
|
||||
}
|
||||
|
||||
private func DrawWaterSource()
|
||||
{
|
||||
var xold = GetX();
|
||||
var yold = GetY()-8;
|
||||
var xnew = GetX();
|
||||
var ynew = GetY()-8;
|
||||
for (var i = 0; i < RandomX(30, 140); i++)
|
||||
{
|
||||
ynew--;
|
||||
xnew = xold + RandomX(-1, 1);
|
||||
if (GBackSemiSolid(xnew-GetX(), ynew-GetY()))
|
||||
DrawMaterialQuad("Water", xold,yold, xold+1,yold, xold+1,yold+1, xold,yold+1);
|
||||
else
|
||||
return;
|
||||
xold = xnew;
|
||||
yold = ynew;
|
||||
}
|
||||
}
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
local Plane = 500;
|
||||
local child;
|
||||
local mat;
|
|
@ -1,2 +0,0 @@
|
|||
Name=TinyStalactite
|
||||
Description=Covers up the base of stalactites
|
|
@ -1,2 +0,0 @@
|
|||
Name=TinyStalactite
|
||||
Description=Covers up the base of stalactites
|
Binary file not shown.
Before Width: | Height: | Size: 7.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 42 KiB |
Loading…
Reference in New Issue