forked from Mirrors/openclonk
Added clouds and some script fixes:
+Steam engine automatically ejects non-fuel items +Fixed some syntax issues in the CrewSelector script; removed unnecessary nils. It should be mentioned the clouds don't seem to function 100% properly with evaporation for now in OC. Further testing is necessary.
parent
55c86b2001
commit
fcc963d419
|
@ -0,0 +1,18 @@
|
|||
[DefCore]
|
||||
|
||||
id=ACDR
|
||||
|
||||
Version=4,9,8
|
||||
|
||||
Category=C4D_StaticBack|C4D_Environment
|
||||
|
||||
MaxUserSelect=1
|
||||
|
||||
Width=1
|
||||
|
||||
Height=1
|
||||
|
||||
Value=1
|
||||
|
||||
Picture=0,0,64,64
|
||||
|
|
@ -0,0 +1 @@
|
|||
Enables acid rain. Acid rain will only ever occur if there is already acid in the scenario.
|
|
@ -0,0 +1 @@
|
|||
Enables acid rain. Acid rain will only ever occur if there is already acid in the scenario.
|
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
|
@ -0,0 +1,5 @@
|
|||
#strict 2
|
||||
|
||||
func Definition(def) {
|
||||
SetProperty("Name", "$Name$", def);
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Name=Säureregen
|
|
@ -0,0 +1 @@
|
|||
Name=Acid Rain
|
|
@ -0,0 +1,44 @@
|
|||
[DefCore]
|
||||
|
||||
id=CLOD
|
||||
|
||||
Version=4,9,8
|
||||
|
||||
Category=C4D_Vehicle|C4D_Foreground
|
||||
|
||||
MaxUserSelect=25
|
||||
|
||||
Timer=25
|
||||
|
||||
TimerCall=TimedEvents
|
||||
|
||||
Width=128
|
||||
|
||||
Height=64
|
||||
|
||||
Offset=-64,-32
|
||||
|
||||
Vertices=2
|
||||
|
||||
VertexX=-40,40
|
||||
|
||||
VertexY=0,0
|
||||
|
||||
Mass=1
|
||||
|
||||
Picture=0,0,220,110
|
||||
|
||||
Exclusive=1
|
||||
|
||||
Components=CLWD=1
|
||||
|
||||
Oversize=1
|
||||
|
||||
StretchGrowth=1
|
||||
|
||||
|
||||
|
||||
[Physical]
|
||||
|
||||
Float=20
|
||||
|
|
@ -0,0 +1 @@
|
|||
Niederschlag.
|
|
@ -0,0 +1 @@
|
|||
Rains, snows, and evaporates water.
|
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
|
@ -0,0 +1,178 @@
|
|||
/*--- Cloud ---*/
|
||||
|
||||
#strict
|
||||
|
||||
local szMat, iSize, iCondensing;
|
||||
local iSearchY;
|
||||
local iWaitTime;
|
||||
local iAcidity;
|
||||
local iStrikeChance;
|
||||
|
||||
protected func Initialize()
|
||||
{
|
||||
//Cloud defaults and modifiers
|
||||
iCondensing = 0;
|
||||
iSize = RandomX(300,500);
|
||||
SetClrModulation(RGB(255,255,255));
|
||||
iSearchY = 0;
|
||||
var iGrowth = Random(75);
|
||||
iAcidity=0;
|
||||
iWaitTime = RandomX(130,190);
|
||||
var iGraphics = RandomX(1,3);
|
||||
|
||||
if(iGraphics == 1) SetGraphics("");
|
||||
if(iGraphics == 2) SetGraphics("1");
|
||||
if(iGraphics == 3) SetGraphics("2");
|
||||
DoCon(iGrowth);
|
||||
SetAction("Fly");
|
||||
while(MaterialDepthCheck(GetX(),GetY(),"Sky",180)!=true) SetPosition(GetX(),GetY()-1);
|
||||
}
|
||||
|
||||
public func Precipitation()
|
||||
{
|
||||
var iLaunch;
|
||||
|
||||
if (GetTemperature() < 0 && iAcidity==0) szMat="Snow";
|
||||
if (GetTemperature()>=1 && iAcidity==0) szMat="Water";
|
||||
if (iAcidity>=1) szMat="Acid";
|
||||
|
||||
//Reroute function to Evaporation if cloud is growing
|
||||
if(iCondensing == 1) return(Evaporation());
|
||||
if(iSize <= 50 && iAcidity==0) iCondensing = 1;
|
||||
|
||||
//water-snow precipitation
|
||||
if(iWaitTime == 0 && szMat!="Acid")
|
||||
{
|
||||
RainDrop();
|
||||
(iSize = --iSize);
|
||||
}
|
||||
|
||||
//acid precipitation
|
||||
if(iWaitTime == 0 && szMat=="Acid")
|
||||
{
|
||||
RainDrop();
|
||||
(iAcidity = --iAcidity);
|
||||
}
|
||||
//Lightning Strike; only during rain
|
||||
if(iWaitTime <= 0 && iSize >= 650 && Random(100) >= 100-(iStrikeChance/16) && szMat=="Water") LaunchLightning(GetX(), GetY() + 20, -20, 41, +5, 15);
|
||||
}
|
||||
|
||||
public func TimedEvents()
|
||||
{
|
||||
var iRight = LandscapeWidth()-10;
|
||||
|
||||
if(iWaitTime != 0) (iWaitTime = --iWaitTime);
|
||||
WindDirection();
|
||||
CloudShade();
|
||||
//Makes clouds loop around map;
|
||||
if(GetX() >= iRight) SetPosition(12, GetY());
|
||||
if(GetX() <= 10) SetPosition(LandscapeWidth()-12, GetY());
|
||||
if(GetY() <= 5) SetPosition(0,6);
|
||||
if(GetYDir()!=0) SetYDir(0);
|
||||
}
|
||||
|
||||
protected func Evaporation() //Creates a search line every x-amount(currently five) of pixels to check for water beneath the cloud
|
||||
{
|
||||
var iSearchX = GetX();
|
||||
var iPrecision = 5;
|
||||
|
||||
if(iSize >= 700 || iAcidity>=100)
|
||||
{
|
||||
(iCondensing = 0);
|
||||
(iSearchY = 0);
|
||||
(iWaitTime = RandomX(130,190));
|
||||
}
|
||||
//line below prevents clouds evaporating through solids
|
||||
if(GetMaterial(0, iSearchY) != Material("Water") && GetMaterial(0, iSearchY) != Material("Acid") && GetMaterial(0, iSearchY) != Material("Sky")) return(iSearchY=0);
|
||||
if(GetMaterial(0, iSearchY) == Material("Water"))
|
||||
{
|
||||
ExtractLiquid(0, iSearchY) &&
|
||||
(iSize = ++iSize);
|
||||
}
|
||||
if(ObjectCount(Find_ID(ACDR))>=1 && GetMaterial(0, iSearchY) == Material("Acid")) ExtractLiquid(0, iSearchY) &&
|
||||
(iAcidity = ++iAcidity);
|
||||
if(GetMaterial(0, iSearchY) != Material("Water") && GetMaterial(0, iSearchY) != Material("Acid"))
|
||||
iSearchY = iSearchY + iPrecision;
|
||||
if(iSearchY >= LandscapeHeight()-GetY()) (iSearchY = 0);
|
||||
}
|
||||
|
||||
private func CloudShade()
|
||||
{
|
||||
//Shades the clouds based on iSize: the water density value of the cloud.
|
||||
var iShade = iSize*425/1000;
|
||||
var iShade2 = iSize-600;
|
||||
var iShade3 = (iAcidity*255/100)/2;
|
||||
|
||||
if(iSize <= 600) SetObjAlpha(iShade);
|
||||
if(iSize > 600) SetObjAlpha();
|
||||
if(iSize > 600 && szMat=="Water") SetClrModulation(RGBa(255-iShade2,255-iShade2,255-iShade2));
|
||||
if(iAcidity >= 1) SetClrModulation(RGBa(255-iShade3,255,255-iShade3, iShade));
|
||||
}
|
||||
|
||||
public func RainDrop()
|
||||
{
|
||||
CastPXS(szMat, 1, 1, RandomX(-50, 50));
|
||||
}
|
||||
|
||||
//Sven2's alpha function
|
||||
global func SetObjAlpha(int byAlpha, pObj)
|
||||
{
|
||||
var dwClrMod=GetClrModulation(pObj);
|
||||
|
||||
if (!dwClrMod) dwClrMod = byAlpha<<24; else dwClrMod = dwClrMod & 16777215 | byAlpha<<24;
|
||||
return(SetClrModulation(dwClrMod, pObj));
|
||||
}
|
||||
|
||||
//For use as scenario setting. Can work after initialize, if you really want to.
|
||||
global func AdjustLightningFrequency(int iFreq)
|
||||
{
|
||||
for(var Cloud in FindObjects(Find_ID(CLOD)))
|
||||
Cloud->SetLightningFrequency(iFreq);
|
||||
return(iFreq);
|
||||
}
|
||||
|
||||
//Routes the global adjust function's variable to the clouds.
|
||||
public func SetLightningFrequency(int iFreq)
|
||||
{
|
||||
iStrikeChance=iFreq;
|
||||
}
|
||||
|
||||
private func WindDirection()
|
||||
{
|
||||
var iWind = GetWind();
|
||||
|
||||
if(iWind >= 7) SetXDir(355,1000);
|
||||
if(iWind <= -7) SetXDir(-355,1000);
|
||||
if(iWind < 6 && iWind > -6) SetXDir();
|
||||
}
|
||||
|
||||
func Definition(def) {
|
||||
SetProperty("ActMap", {
|
||||
Fly = {
|
||||
Prototype = Action,
|
||||
Name = "Fly",
|
||||
Procedure = DFA_FLOAT,
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Wdt = 220,
|
||||
Hgt = 110,
|
||||
Length = 1,
|
||||
Delay = 15,
|
||||
NextAction = "Fly",
|
||||
TurnAction = "Turn",
|
||||
StartCall = "Precipitation",
|
||||
},
|
||||
Turn = {
|
||||
Prototype = Action,
|
||||
Name = "Turn",
|
||||
Procedure = DFA_FLOAT,
|
||||
Length = 1,
|
||||
Delay = 1,
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Wdt = 220,
|
||||
Hgt = 110,
|
||||
NextAction = "Fly",
|
||||
}, }, def);
|
||||
SetProperty("Name", "Cloud", def);
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Name=Niederschlag
|
|
@ -0,0 +1 @@
|
|||
Name=Precipitation
|
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
|
@ -0,0 +1,9 @@
|
|||
[DefCore]
|
||||
id=CLDP
|
||||
Version=4,9,8
|
||||
Category=C4D_StaticBack|C4D_Environment
|
||||
MaxUserSelect=2
|
||||
Width=1
|
||||
Height=1
|
||||
Value=1
|
||||
Picture=0,0,64,64
|
|
@ -0,0 +1 @@
|
|||
Wolken-erstellung.
|
|
@ -0,0 +1 @@
|
|||
Creates majestic clouds in the sky.
|
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
|
@ -0,0 +1,56 @@
|
|||
/*-- Cloud Placer --*/
|
||||
|
||||
#strict
|
||||
|
||||
//Great thanks to Maikel for the following function provided
|
||||
protected func FindPosInMat(int &iToX, int &iToY, string sMat, int iXStart, int iYStart, int iWidth, int iHeight, int iSize)
|
||||
{
|
||||
var iX, iY;
|
||||
for(var i = 0; i < 500; i++)
|
||||
{
|
||||
iX = iXStart+Random(iWidth);
|
||||
iY = iYStart+Random(iHeight);
|
||||
if(GetMaterial(AbsX(iX),AbsY(iY))==Material(sMat) &&
|
||||
GetMaterial(AbsX(iX+iSize),AbsY(iY+iSize))==Material(sMat) &&
|
||||
GetMaterial(AbsX(iX+iSize),AbsY(iY-iSize))==Material(sMat) &&
|
||||
GetMaterial(AbsX(iX-iSize),AbsY(iY-iSize))==Material(sMat) &&
|
||||
GetMaterial(AbsX(iX-iSize),AbsY(iY+iSize))==Material(sMat))
|
||||
{
|
||||
iToX = iX; iToY = iY;
|
||||
return true; // Location found.
|
||||
}
|
||||
}
|
||||
return false; // No location found.
|
||||
}
|
||||
protected func Initialize()
|
||||
{
|
||||
var iX, iY;
|
||||
var iCount = LandscapeWidth()/65; //Determines how many clouds should be on a map
|
||||
|
||||
while(iCount!=0)
|
||||
{
|
||||
if(FindPosInMat(iX, iY, "Sky", 0,0,LandscapeWidth(), LandscapeHeight()) &&
|
||||
MaterialDepthCheck(iX,iY,"Sky",200)==true) CreateObject(CLOD, iX, iY, NO_OWNER) && (iCount=--iCount);
|
||||
}
|
||||
}
|
||||
|
||||
global func MaterialDepthCheck(int iX,int iY,string szMaterial,int iDepth)
|
||||
{
|
||||
var iTravelled;
|
||||
var iXval = iX;
|
||||
var iYval = iY;
|
||||
|
||||
//If iDepth is equal to zero, the function will always measure the depth of the material.
|
||||
//If iDepth is not equal to zero, the function will return true if the material is as deep or deeper than iDepth (in pixels).
|
||||
if(iDepth==0) iDepth=LandscapeHeight();
|
||||
|
||||
while(iTravelled!=iDepth)
|
||||
{
|
||||
if(GetMaterial(iXval,iYval)==Material(szMaterial)) (iTravelled=++iTravelled) && (iYval=++iYval);
|
||||
if(GetMaterial(iXval,iYval)!=Material(szMaterial)) return(iTravelled);//returns depth of material
|
||||
}
|
||||
if(iTravelled==iDepth) return(true);
|
||||
}
|
||||
func Definition(def) {
|
||||
SetProperty("Name", "$Name$", def);
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Name=Wolken
|
|
@ -0,0 +1 @@
|
|||
Name=Clouds
|
|
@ -146,7 +146,7 @@ public func UpdateRank()
|
|||
var ranky = -15000;
|
||||
|
||||
SetGraphics(nil,RANK,10,GFXOV_MODE_Action,Format("Rank%d",nrank));
|
||||
SetObjDrawTransform(1000,0,rankx,0,1000,ranky, nil, 10);
|
||||
SetObjDrawTransform(1000,0,rankx,0,1000,ranky,10);
|
||||
|
||||
// extra rank (the star if the clonk is too experienced for normal ranks)
|
||||
if(brank > 0)
|
||||
|
@ -246,7 +246,7 @@ private func AddBreathBar()
|
|||
SetBarLayers(4,1);
|
||||
SetBarOffset(0,BarOffset(1),1);
|
||||
SetBarDimensions(GetDefWidth(),BreathBarHeight(),1);
|
||||
SetClrModulation(RGB(0,200,200),nil,5);
|
||||
SetClrModulation(RGBa(0,200,200),5);
|
||||
|
||||
breathbar = true;
|
||||
|
||||
|
|
|
@ -39,6 +39,13 @@ func ContentsCheck()
|
|||
SetAction("Work");
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Ejects non fuel items immediately
|
||||
if(pFuel = FindObject(Find_Container(this), !Find_Func("IsFuel"))) {
|
||||
pFuel->Exit(-53,21, -20, -1, -1, -30);
|
||||
Sound("Chuff"); //I think a 'chuff' or 'metal clonk' sound could be good here -Ringwaul
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue