forked from Mirrors/openclonk
added BoilingLava and BoilingAcid environmental rules
cleaned up boiling lava and boiling acid rule -Made them adhere to the C4S guidelines, renamed some IDs and made some stuff in scripts more readable. Prettied up the scripts for the boiling liquid environmental rule Changed Bubble Behaviour slightly Und nochmal weil's so schön war Added BoilingAcid which causes bubbles to rise from Acid on the map Dark bubbles are explosive Added boiling Lava environmental ruleshapetextures
parent
358d282ec2
commit
f35a46c61f
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
[DefCore]
|
||||
id=BoilingAcid_Bubble
|
||||
Version=6,0
|
||||
Category=C4D_None
|
||||
Width=8
|
||||
Height=8
|
||||
Offset=-4,-4
|
||||
Vertices=3
|
||||
VertexX=0,2,-2
|
||||
VertexY=1,-1,-1
|
||||
VertexFriction=1
|
||||
Float=1
|
||||
Oversize=1
|
||||
StretchGrowth=1
|
Binary file not shown.
After Width: | Height: | Size: 7.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
Acid bubble
|
||||
Looks dangerous
|
||||
|
||||
@author Win
|
||||
*/
|
||||
|
||||
local Plane = 500;
|
||||
|
||||
local is_explosive = false;
|
||||
|
||||
local grow_time = 2;
|
||||
local grow_timer = 0;
|
||||
|
||||
public func Construction()
|
||||
{
|
||||
AddEffect("Move", this, 1, 2, this);
|
||||
|
||||
// Sometimes bubbles become darker and explosive
|
||||
if (!Random(10))
|
||||
{
|
||||
is_explosive = true;
|
||||
SetGraphics("2");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private func FxMoveTimer(object target, effect fx, int time)
|
||||
{
|
||||
if (!GBackLiquid(0, -3) && !GetEffect("ObjFade", this) || time > 200)
|
||||
{
|
||||
if (!GBackLiquid(0, -3) && !is_explosive)
|
||||
SetGraphics("3");
|
||||
if(!Random(20))
|
||||
Sound("ef_Bubble*");
|
||||
FadeOut(50, true);
|
||||
}
|
||||
|
||||
grow_timer++;
|
||||
|
||||
if (grow_timer >= grow_time)
|
||||
{
|
||||
DoCon(2);
|
||||
grow_timer = 0;
|
||||
}
|
||||
|
||||
// Causes bubbles to repel each other
|
||||
var nearbyBubble = FindObject(Find_Distance(GetCon()/15, 0, 0), Find_ID(GetID()));
|
||||
if (nearbyBubble != nil)
|
||||
{
|
||||
SetXDir(-(nearbyBubble->GetX() - GetX()) / 2);
|
||||
SetYDir(-(nearbyBubble->GetY() - GetY()) / 2);
|
||||
}
|
||||
// Deep green bubbles explode when near a living thing
|
||||
if (is_explosive)
|
||||
{
|
||||
var prey = FindObject(Find_Distance(GetCon()/15, 0, 0), Find_OCF(OCF_Alive));
|
||||
if (prey != nil)
|
||||
Explode(10);
|
||||
}
|
||||
|
||||
// Bubble is faster in acid, moves erratically outside
|
||||
var speed_up = -3;
|
||||
if (GetEffect("ObjFade", this))
|
||||
{
|
||||
speed_up = 0;
|
||||
if (Inside(GetXDir(), -6, 6))
|
||||
SetXDir(GetXDir() + RandomX(-6, 6));
|
||||
}
|
||||
|
||||
|
||||
SetYDir(GetYDir() - RandomX(3, 4) + speed_up - (GetCon() / 50));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// No need to blow up scenario object list with bubble spam.
|
||||
func SaveScenarioObject() { return false; }
|
|
@ -0,0 +1,8 @@
|
|||
[DefCore]
|
||||
id=BoilingAcid
|
||||
Version=5,2,0,1
|
||||
Category=C4D_StaticBack
|
||||
Width=1
|
||||
Height=1
|
||||
Offset=0,0
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
BoilingMagma
|
||||
Causes Acid on the map to bubble
|
||||
|
||||
@author
|
||||
*/
|
||||
|
||||
#include BoilingLava
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
|
||||
// Magic number by which the total map size (in pixels) is divided to get the amount of tries per frame.
|
||||
local intensity_quotient = 50000;
|
||||
|
||||
private func Boiling()
|
||||
{
|
||||
for (var i = 0; i < intensity; i++)
|
||||
{
|
||||
// Checks if there is a deep enough pool of acid at a random location of the map, then creates spawner at a random depth into the pool
|
||||
var x_rand = Random(LandscapeWidth());
|
||||
var y_rand = Random(LandscapeHeight());
|
||||
var mat = MaterialName(GetMaterial(x_rand, y_rand));
|
||||
var random_depth = RandomX(30, 100);
|
||||
var depth_check_mat = MaterialName(GetMaterial(x_rand, y_rand + random_depth));
|
||||
|
||||
if (mat == "Acid" && depth_check_mat == "Acid")
|
||||
if (PathFree(x_rand, y_rand, x_rand, y_rand + random_depth))
|
||||
{
|
||||
var nearbySpawner = FindObject(Find_Distance(RandomX(80, 100), x_rand, y_rand), Find_ID(BoilingAcid_Spawner));
|
||||
|
||||
if (nearbySpawner == nil)
|
||||
{
|
||||
CreateObject(BoilingAcid_Spawner, x_rand, y_rand + random_depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
[DefCore]
|
||||
id=BoilingAcid_Spawner
|
||||
Version=6,0
|
||||
Category=C4D_StaticBack
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
Acid Bubble Spawner
|
||||
Spawns acid bubbles for some time.
|
||||
|
||||
@author Win
|
||||
*/
|
||||
|
||||
local Name = "Acid Bubble Spawner";
|
||||
|
||||
local max_time = 12;
|
||||
local timer = 0;
|
||||
local count = 7;
|
||||
|
||||
public func Construction()
|
||||
{
|
||||
AddTimer("Boil", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
Periodically spawns bubbles until count runs out
|
||||
*/
|
||||
private func Boil()
|
||||
{
|
||||
if (++timer > max_time)
|
||||
{
|
||||
timer = 0;
|
||||
var amount = RandomX(1, 3);
|
||||
count -= amount;
|
||||
|
||||
var bubbles = CastAcidBubbles(amount, RandomX(10, 30), 0, 0);
|
||||
for (var bubble in bubbles)
|
||||
bubble->SetCon(RandomX(30, 40));
|
||||
}
|
||||
|
||||
if (!GBackLiquid(0, 0) || count <= 0)
|
||||
{
|
||||
RemoveObject();
|
||||
}
|
||||
}
|
||||
|
||||
// This is a helper object. Do not save!
|
||||
func SaveScenarioObject() { return false; }
|
|
@ -0,0 +1,2 @@
|
|||
Name=BoilingMagma
|
||||
Description=Causes Lava on the map to boil
|
|
@ -0,0 +1,2 @@
|
|||
Name=BoilingMagma
|
||||
Description=Causes Lava on the map to boil
|
|
@ -0,0 +1,14 @@
|
|||
[DefCore]
|
||||
id=BoilingLava_Bubble
|
||||
Version=6,0
|
||||
Category=C4D_None
|
||||
Width=8
|
||||
Height=8
|
||||
Offset=-4,-4
|
||||
Vertices=3
|
||||
VertexX=0,2,-2
|
||||
VertexY=1,-1,-1
|
||||
VertexFriction=1
|
||||
Float=1
|
||||
Oversize=1
|
||||
StretchGrowth=1
|
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
Lava Bubble
|
||||
Looks dangerous
|
||||
|
||||
@author Win
|
||||
*/
|
||||
|
||||
local Name = "Lava Bubble";
|
||||
local Plane = 500;
|
||||
|
||||
public func Construction()
|
||||
{
|
||||
if (GBackSolid(0, 0))
|
||||
{
|
||||
RemoveObject();
|
||||
return;
|
||||
}
|
||||
|
||||
AddEffect("Move", this, 1, 2, this);
|
||||
Sound("ef_Bubble*");
|
||||
return;
|
||||
}
|
||||
|
||||
private func FxMoveTimer(object target, effect, int time)
|
||||
{
|
||||
if ((!GBackLiquid(0, -3) || time > 108) && !GetEffect("ObjFade", this))
|
||||
FadeOut(50, true);
|
||||
|
||||
// Bubbles burst into smaller bubbles
|
||||
if (!Random(25) && target->GetCon() > 100)
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
var bubble = CreateObjectAbove(GetID());
|
||||
bubble->SetCon(2 * target->GetCon() / 3);
|
||||
bubble->SetYDir(target->GetYDir());
|
||||
}
|
||||
RemoveObject();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Jittery movement
|
||||
SetYDir(GetYDir() - 3 + Random(7));
|
||||
if (Inside(GetXDir(), -6, 6))
|
||||
SetXDir(GetXDir() + 2 * Random(2) - 1);
|
||||
|
||||
// Explodes near living things
|
||||
var prey = FindObject(Find_Distance(GetCon()/15, 0, 0), Find_OCF(OCF_Alive));
|
||||
if(prey != nil)
|
||||
Explode(10);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// No need to blow up scenario object list with bubble spam.
|
||||
func SaveScenarioObject() { return false; }
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,4 @@
|
|||
[DefCore]
|
||||
id=BoilingLava
|
||||
Version=6,0
|
||||
Category=C4D_StaticBack|C4D_Environment
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
BoilingMagma
|
||||
Causes Lava on the map to boil
|
||||
|
||||
@author Win
|
||||
*/
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
|
||||
local intensity;
|
||||
// Magic number by which the total map size (in pixels) is divided to get the amount of tries per frame.
|
||||
local intensity_quotient = 10000;
|
||||
|
||||
public func Place(int amount)
|
||||
{
|
||||
amount = amount ?? 1;
|
||||
|
||||
// The amount directly controls the intensity. More objects would not help.
|
||||
var obj = CreateObject(this, 0, 0, NO_OWNER);
|
||||
obj.intensity *= amount;
|
||||
return [obj];
|
||||
}
|
||||
|
||||
public func Construction()
|
||||
{
|
||||
SetPosition(0, 0);
|
||||
intensity = GetDefaultIntensity();
|
||||
if (intensity <= 0) intensity = 1;
|
||||
AddTimer("Boiling", 1);
|
||||
}
|
||||
|
||||
private func GetDefaultIntensity()
|
||||
{
|
||||
return (LandscapeWidth() * LandscapeHeight()) / this.intensity_quotient;
|
||||
}
|
||||
|
||||
private func Boiling()
|
||||
{
|
||||
for(var i = 0; i < intensity; i++)
|
||||
{
|
||||
// Checks if there is a deep enough pool of lava at a random location of the map, then creates spawner on the surface
|
||||
var x_rand = Random(LandscapeWidth());
|
||||
var y_rand = Random(LandscapeHeight());
|
||||
var mat = MaterialName(GetMaterial(x_rand, y_rand));
|
||||
var above_mat = MaterialName(GetMaterial(x_rand, y_rand - 1));
|
||||
var depth_check_math = MaterialName(GetMaterial(x_rand, y_rand + 30));
|
||||
|
||||
if (mat == "DuroLava" || mat == "Lava")
|
||||
if (above_mat == nil || above_mat == "Tunnel")
|
||||
if (depth_check_math == "DuroLava" || depth_check_math == "Lava")
|
||||
if (PathFree(x_rand, y_rand, x_rand, y_rand + 30))
|
||||
{
|
||||
CreateObject(BoilingLava_Spawner, x_rand, y_rand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Sets the intensity of the lava spawner. An intensity of 3 means that a new random spawn position is tested 3 times per frame.
|
||||
*/
|
||||
public func SetIntensity(int intensity)
|
||||
{
|
||||
this.intensity = intensity ?? GetDefaultIntensity();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Save the intensity IFF it is different from the definition's.
|
||||
public func SaveScenarioObject(props)
|
||||
{
|
||||
if (this.intensity != GetDefaultIntensity())
|
||||
props->AddCall("Intensity", this, "SetIntensity", this.intensity);
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
[DefCore]
|
||||
id=BoilingLava_Spawner
|
||||
Version=6,0
|
||||
Category=C4D_StaticBack
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
Lava Bubble Spawner
|
||||
Spawns lava bubbles for some time.
|
||||
|
||||
@author Win
|
||||
*/
|
||||
|
||||
local Name = "Lava Bubble Spawner";
|
||||
|
||||
local max_time = 2;
|
||||
local timer = 0;
|
||||
local count = 10;
|
||||
|
||||
public func Construction()
|
||||
{
|
||||
AddTimer("Boil", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
Periodically spawns bubbles until count runs out.
|
||||
*/
|
||||
private func Boil()
|
||||
{
|
||||
if (++timer > max_time)
|
||||
{
|
||||
timer = 0;
|
||||
var amount = RandomX(1, 3);
|
||||
count -= amount;
|
||||
|
||||
var bubbles = CastLavaBubbles(amount, RandomX(10, 30), RandomX(-30, 30), 0);
|
||||
for (var bubble in bubbles)
|
||||
bubble->SetCon(RandomX(105, 115));
|
||||
if (count <= 0)
|
||||
RemoveObject();
|
||||
}
|
||||
}
|
||||
|
||||
// This is a helper object. Do not save!
|
||||
func SaveScenarioObject() { return false; }
|
|
@ -0,0 +1,2 @@
|
|||
Name=Kochende Lava
|
||||
Description=Lässt die Lava auf der Karte brodeln
|
|
@ -0,0 +1,2 @@
|
|||
Name=Boiling Laval
|
||||
Description=Causes Lava on the map to boil
|
|
@ -14,3 +14,19 @@ global func LaunchMeteor(int x, int y, int size, int xdir, int ydir, id spawn_id
|
|||
var meteor = CreateObject(meteor_skin);
|
||||
return meteor->Launch(x, y, size, xdir, ydir, spawn_id, spawn_amount);
|
||||
}
|
||||
|
||||
/**
|
||||
Casts lava bubbles that move upwards in lava and explode on contact with living beings.
|
||||
*/
|
||||
global func CastLavaBubbles(int num, int level, int x, int y)
|
||||
{
|
||||
return CastObjects(BoilingLava_Bubble, num, level, x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
Casts acid bubbles that move upwards in lava and explode on contact with living beings.
|
||||
*/
|
||||
global func CastAcidBubbles(int num, int level, int x, int y)
|
||||
{
|
||||
return CastObjects(BoilingAcid_Bubble, num, level, x, y);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue