forked from Mirrors/openclonk
stalactite: fix raindrop, allow placing in sky, fix stalagmite, clean up
parent
e94a0b3c36
commit
42310548d8
|
@ -4,11 +4,11 @@ Version=8,0
|
||||||
Category=C4D_Object
|
Category=C4D_Object
|
||||||
Width=15
|
Width=15
|
||||||
Height=60
|
Height=60
|
||||||
Offset=-7, 0
|
Offset=-7,0
|
||||||
Vertices=2
|
Vertices=2
|
||||||
VertexX=0, 0
|
VertexX=0,0
|
||||||
VertexY=0, 60
|
VertexY=0,60
|
||||||
VertexCNAT=4, 8
|
VertexCNAT=4,8
|
||||||
VertexFriction=300,300
|
VertexFriction=300,300
|
||||||
Mass=35
|
Mass=35
|
||||||
StretchGrowth=1
|
StretchGrowth=1
|
||||||
|
|
|
@ -20,8 +20,6 @@ public func Construction()
|
||||||
transformation = Trans_Rotate(RandomX(-20, 20), 0, 0, 1);
|
transformation = Trans_Rotate(RandomX(-20, 20), 0, 0, 1);
|
||||||
sibling = TransformBone(bone, transformation, 1, Anim_Const(1000), sibling);
|
sibling = TransformBone(bone, transformation, 1, Anim_Const(1000), sibling);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddRainDropEffect(nil, RandomX(80, 120), "Water", RandomX(1, 5));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func Hit()
|
private func Hit()
|
||||||
|
@ -69,14 +67,23 @@ public func Place(int amount, proplist rectangle, proplist settings)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Default parameters.
|
// Default parameters.
|
||||||
|
if (!settings)
|
||||||
|
settings = {};
|
||||||
var loc_area = nil;
|
var loc_area = nil;
|
||||||
if (rectangle)
|
if (rectangle)
|
||||||
loc_area = Loc_InRect(rectangle);
|
loc_area = Loc_InRect(rectangle);
|
||||||
|
var loc_background;
|
||||||
|
if (settings.underground == nil)
|
||||||
|
loc_background = Loc_Or(Loc_Sky(), Loc_Tunnel());
|
||||||
|
else if (settings.underground)
|
||||||
|
loc_background = Loc_Tunnel();
|
||||||
|
else
|
||||||
|
loc_background = Loc_Sky();
|
||||||
|
|
||||||
var stalactites = [];
|
var stalactites = [];
|
||||||
for (var i = 0; i < amount; i++)
|
for (var i = 0; i < amount; i++)
|
||||||
{
|
{
|
||||||
var loc = FindLocation(Loc_Tunnel(), Loc_Not(Loc_Liquid()), Loc_Wall(CNAT_Top), Loc_Space(40, CNAT_Bottom), loc_area);
|
var loc = FindLocation(loc_background, Loc_Not(Loc_Liquid()), Loc_Wall(CNAT_Top), Loc_Space(40, CNAT_Bottom), loc_area);
|
||||||
if (!loc)
|
if (!loc)
|
||||||
continue;
|
continue;
|
||||||
var mat = MaterialName(GetMaterial(loc.x, loc.y - 1));
|
var mat = MaterialName(GetMaterial(loc.x, loc.y - 1));
|
||||||
|
@ -106,7 +113,7 @@ public func Place(int amount, proplist rectangle, proplist settings)
|
||||||
if (ground_y)
|
if (ground_y)
|
||||||
{
|
{
|
||||||
height = ground_y - loc.y;
|
height = ground_y - loc.y;
|
||||||
con = Min(con, BoundBy(100 * height / 60 / 2, 25, 100));
|
con = Min(con, BoundBy(100 * height / 120, 25, 100));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,40 +153,26 @@ private func CreateStalactite(int x, int y, string mat, bool stalagmite)
|
||||||
colour = HSL(hue, 100, 200);
|
colour = HSL(hue, 100, 200);
|
||||||
stalactite->SetClrModulation(colour);
|
stalactite->SetClrModulation(colour);
|
||||||
}
|
}
|
||||||
if (!stalagmite && Random(2))
|
|
||||||
stalactite->DrawWaterSource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stalagmite)
|
if (stalagmite)
|
||||||
{
|
{
|
||||||
stalactite->SetR(180);
|
stalactite->SetR(180);
|
||||||
|
stalactite.MeshTransformation = Trans_Mul(Trans_Translate(0, 10 * stalactite->GetDefHeight() * stalactite->GetCon(), 0), stalactite.MeshTransformation);
|
||||||
|
}
|
||||||
|
else if (mat != "Ice")
|
||||||
|
{
|
||||||
|
// Add rain drop effect for stalactites only.
|
||||||
|
stalactite->AddRainDropEffect(nil, RandomX(80, 120), "Water", RandomX(1, 5), 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stalactite;
|
return stalactite;
|
||||||
}
|
}
|
||||||
|
|
||||||
private func DrawWaterSource()
|
public func OnRainDropCreated(effect fx_drop)
|
||||||
{
|
{
|
||||||
var xold = GetX();
|
if (Random(9))
|
||||||
var yold = GetY() - 2;
|
return;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func OnRainDropCreated()
|
|
||||||
{
|
|
||||||
if (Random(9)) return;
|
|
||||||
Sound("Liquids::Waterdrop*");
|
Sound("Liquids::Waterdrop*");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,30 +88,36 @@ Creates a raindrop effect upon the the calling object.
|
||||||
@strength Specifies how many drops are created in a call.
|
@strength Specifies how many drops are created in a call.
|
||||||
@return The created effect.
|
@return The created effect.
|
||||||
*/
|
*/
|
||||||
|
global func AddRainDropEffect(int duration, int interval, string material, int strength, int offset_x, int offset_y)
|
||||||
global func AddRainDropEffect(int duration, int interval, string material, int strength)
|
|
||||||
{
|
{
|
||||||
if(!this || GetType(this) != C4V_C4Object) FatalError(Format("AddRainDropEffect needs to be called from object context, not from %v", this));
|
if (!this || GetType(this) != C4V_C4Object)
|
||||||
|
FatalError(Format("AddRainDropEffect needs to be called from object context, not from %v", this));
|
||||||
return this->CreateEffect(FxRainDrop, 1, interval ?? 10, duration, material, strength);
|
return this->CreateEffect(FxRainDrop, 1, interval ?? 10, duration, material, strength, [offset_x, offset_y]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const FxRainDrop = new Effect {
|
static const FxRainDrop = new Effect
|
||||||
|
{
|
||||||
duration = nil,
|
duration = nil,
|
||||||
material = nil,
|
material = nil,
|
||||||
strength = nil,
|
strength = nil,
|
||||||
|
offset = [0, 0],
|
||||||
particle_cache = {},
|
particle_cache = {},
|
||||||
|
|
||||||
Construction = func(int duration, string material, int strength) {
|
Construction = func(int duration, string material, int strength, array offset)
|
||||||
|
{
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.material = material ?? "Water";
|
this.material = material ?? "Water";
|
||||||
this.strength = strength ?? 1;
|
this.strength = strength ?? 1;
|
||||||
|
this.offset = offset ?? [0, 0];
|
||||||
},
|
},
|
||||||
|
|
||||||
Timer = func(int time) {
|
Timer = func(int time)
|
||||||
if (!this.Target || (this.duration != nil && time > this.duration)) return FX_Execute_Kill;
|
{
|
||||||
|
if (!this.Target || (this.duration != nil && time > this.duration))
|
||||||
|
return FX_Execute_Kill;
|
||||||
|
|
||||||
if (this.Target->GBackSemiSolid()) return;
|
if (this.Target->GBackSemiSolid(this.offset[0], this.offset[1]))
|
||||||
|
return FX_OK;
|
||||||
|
|
||||||
var con = this.Target->GetCon();
|
var con = this.Target->GetCon();
|
||||||
var wdt = this.Target->GetDefWidth() * con / 500;
|
var wdt = this.Target->GetDefWidth() * con / 500;
|
||||||
|
@ -129,20 +135,18 @@ static const FxRainDrop = new Effect {
|
||||||
|
|
||||||
if (this.material == "Lava" || this.material == "DuroLava")
|
if (this.material == "Lava" || this.material == "DuroLava")
|
||||||
particle_name = "RaindropLava";
|
particle_name = "RaindropLava";
|
||||||
|
|
||||||
else
|
else
|
||||||
particle_name = "Raindrop";
|
particle_name = "Raindrop";
|
||||||
|
|
||||||
this.Target->CreateParticle(
|
this.Target->CreateParticle(
|
||||||
particle_name,
|
particle_name,
|
||||||
PV_Random(-wdt, wdt),
|
PV_Random(this.offset[0] - wdt, this.offset[0] + wdt),
|
||||||
PV_Random(-hgt, hgt),
|
PV_Random(this.offset[1] - hgt, this.offset[1] + hgt),
|
||||||
PV_Random(-5, 5),
|
PV_Random(-5, 5),
|
||||||
PV_Random(10, 30),
|
PV_Random(10, 30),
|
||||||
PV_Random(200, 300),
|
PV_Random(200, 300),
|
||||||
this.particle_cache.particle,
|
this.particle_cache.particle,
|
||||||
this.strength
|
this.strength
|
||||||
);
|
);
|
||||||
|
|
||||||
this.Target->~OnRainDropCreated(this);
|
this.Target->~OnRainDropCreated(this);
|
||||||
return FX_OK;
|
return FX_OK;
|
||||||
|
|
Loading…
Reference in New Issue