forked from Mirrors/openclonk
planet: Normalize line endings
parent
2d3a4981bf
commit
016f626cbe
|
@ -1,2 +1,3 @@
|
|||
* -crlf
|
||||
|
||||
* text=auto
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
{\rtf1\ansi\deff0\adeflang1025
|
||||
{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset1 Times New Roman;}{\f4\froman\fprq0\fcharset1 Times New Roman;}{\f5\fnil\fprq2\fcharset0 Microsoft YaHei;}{\f6\fnil\fprq2\fcharset0 Mangal;}{\f7\fnil\fprq0\fcharset1 Mangal;}}
|
||||
{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
|
||||
{\stylesheet{\s0\snext0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043 Normal;}
|
||||
{\s15\sbasedon0\snext16\sb240\sa120\keepn\dbch\af5\dbch\af6\afs28\loch\f2\fs28 Heading;}
|
||||
{\s16\sbasedon0\snext16\sb0\sa120 Text body;}
|
||||
{\s17\sbasedon16\snext17\sb0\sa120\dbch\af7 List;}
|
||||
{\s18\sbasedon0\snext18\sb120\sa120\noline\i\dbch\af7\afs24\ai\fs24 Caption;}
|
||||
{\s19\sbasedon0\snext19\noline\dbch\af7 Index;}
|
||||
}{\info{\creatim\yr0\mo0\dy0\hr0\min0}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment LibreOffice}{\vern3600}}\deftab720
|
||||
\viewscale100
|
||||
{\*\pgdsctbl
|
||||
{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\pgdscnxt0 Default;}}
|
||||
\formshade{\*\pgdscno0}\paperh15840\paperw12240\margl1800\margr1800\margt1440\margb1440\sectd\sbknone\sectunlocked1\pgndec\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
|
||||
\pgndec\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043\nowidctlpar{\b\kerning1\rtlch \ltrch\loch\fs20\lang1033\loch\f4
|
||||
Arena}
|
||||
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043\nowidctlpar\b\kerning1\rtlch \ltrch\loch\fs20\lang1033\loch\f4
|
||||
|
||||
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043\nowidctlpar{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
Dieser Rundenordner enth\u228\'e4lt }{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
experimentale }{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
Runden }{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
und Runden zum Zwecke von entwicklen}{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
. }{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
Diese Runden k\u246\'f6nnen einfach gespielt werden und wir freuen uns \u252\'fcber Kommentar in das Forum }
|
||||
{\rtf1\ansi\deff0\adeflang1025
|
||||
{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset1 Times New Roman;}{\f4\froman\fprq0\fcharset1 Times New Roman;}{\f5\fnil\fprq2\fcharset0 Microsoft YaHei;}{\f6\fnil\fprq2\fcharset0 Mangal;}{\f7\fnil\fprq0\fcharset1 Mangal;}}
|
||||
{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
|
||||
{\stylesheet{\s0\snext0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043 Normal;}
|
||||
{\s15\sbasedon0\snext16\sb240\sa120\keepn\dbch\af5\dbch\af6\afs28\loch\f2\fs28 Heading;}
|
||||
{\s16\sbasedon0\snext16\sb0\sa120 Text body;}
|
||||
{\s17\sbasedon16\snext17\sb0\sa120\dbch\af7 List;}
|
||||
{\s18\sbasedon0\snext18\sb120\sa120\noline\i\dbch\af7\afs24\ai\fs24 Caption;}
|
||||
{\s19\sbasedon0\snext19\noline\dbch\af7 Index;}
|
||||
}{\info{\creatim\yr0\mo0\dy0\hr0\min0}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment LibreOffice}{\vern3600}}\deftab720
|
||||
\viewscale100
|
||||
{\*\pgdsctbl
|
||||
{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\pgdscnxt0 Default;}}
|
||||
\formshade{\*\pgdscno0}\paperh15840\paperw12240\margl1800\margr1800\margt1440\margb1440\sectd\sbknone\sectunlocked1\pgndec\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
|
||||
\pgndec\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043\nowidctlpar{\b\kerning1\rtlch \ltrch\loch\fs20\lang1033\loch\f4
|
||||
Arena}
|
||||
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043\nowidctlpar\b\kerning1\rtlch \ltrch\loch\fs20\lang1033\loch\f4
|
||||
|
||||
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043\nowidctlpar{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
Dieser Rundenordner enth\u228\'e4lt }{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
experimentale }{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
Runden }{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
und Runden zum Zwecke von entwicklen}{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
. }{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
Diese Runden k\u246\'f6nnen einfach gespielt werden und wir freuen uns \u252\'fcber Kommentar in das Forum }
|
||||
\par }
|
|
@ -1,22 +1,22 @@
|
|||
{\rtf1\ansi\deff0\adeflang1025
|
||||
{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset1 Times New Roman;}{\f4\froman\fprq0\fcharset1 Times New Roman;}{\f5\fnil\fprq2\fcharset0 Microsoft YaHei;}{\f6\fnil\fprq2\fcharset0 Mangal;}{\f7\fnil\fprq0\fcharset1 Mangal;}}
|
||||
{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
|
||||
{\stylesheet{\s0\snext0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043 Normal;}
|
||||
{\s15\sbasedon0\snext16\sb240\sa120\keepn\dbch\af5\dbch\af6\afs28\loch\f2\fs28 Heading;}
|
||||
{\s16\sbasedon0\snext16\sb0\sa120 Text body;}
|
||||
{\s17\sbasedon16\snext17\sb0\sa120\dbch\af7 List;}
|
||||
{\s18\sbasedon0\snext18\sb120\sa120\noline\i\dbch\af7\afs24\ai\fs24 Caption;}
|
||||
{\s19\sbasedon0\snext19\noline\dbch\af7 Index;}
|
||||
}{\info{\creatim\yr0\mo0\dy0\hr0\min0}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment LibreOffice}{\vern3600}}\deftab720
|
||||
\viewscale100
|
||||
{\*\pgdsctbl
|
||||
{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\pgdscnxt0 Default;}}
|
||||
\formshade{\*\pgdscno0}\paperh15840\paperw12240\margl1800\margr1800\margt1440\margb1440\sectd\sbknone\sectunlocked1\pgndec\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
|
||||
\pgndec\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043\nowidctlpar{\b\kerning1\rtlch \ltrch\loch\fs20\lang1033\loch\f4
|
||||
Experimental}
|
||||
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043\nowidctlpar\b\kerning1\rtlch \ltrch\loch\fs20\lang1033\loch\f4
|
||||
|
||||
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043\nowidctlpar{{\*\bkmkstart __DdeLink__2_537781242}\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
This scenario folder contains }{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4{\*\bkmkend __DdeLink__2_537781242}
|
||||
experimental scenarios and scenarios for testing purposes. Feel free to play them and post any feedback in our forums.}
|
||||
{\rtf1\ansi\deff0\adeflang1025
|
||||
{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset1 Times New Roman;}{\f4\froman\fprq0\fcharset1 Times New Roman;}{\f5\fnil\fprq2\fcharset0 Microsoft YaHei;}{\f6\fnil\fprq2\fcharset0 Mangal;}{\f7\fnil\fprq0\fcharset1 Mangal;}}
|
||||
{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
|
||||
{\stylesheet{\s0\snext0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043 Normal;}
|
||||
{\s15\sbasedon0\snext16\sb240\sa120\keepn\dbch\af5\dbch\af6\afs28\loch\f2\fs28 Heading;}
|
||||
{\s16\sbasedon0\snext16\sb0\sa120 Text body;}
|
||||
{\s17\sbasedon16\snext17\sb0\sa120\dbch\af7 List;}
|
||||
{\s18\sbasedon0\snext18\sb120\sa120\noline\i\dbch\af7\afs24\ai\fs24 Caption;}
|
||||
{\s19\sbasedon0\snext19\noline\dbch\af7 Index;}
|
||||
}{\info{\creatim\yr0\mo0\dy0\hr0\min0}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment LibreOffice}{\vern3600}}\deftab720
|
||||
\viewscale100
|
||||
{\*\pgdsctbl
|
||||
{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\pgdscnxt0 Default;}}
|
||||
\formshade{\*\pgdscno0}\paperh15840\paperw12240\margl1800\margr1800\margt1440\margb1440\sectd\sbknone\sectunlocked1\pgndec\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
|
||||
\pgndec\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043\nowidctlpar{\b\kerning1\rtlch \ltrch\loch\fs20\lang1033\loch\f4
|
||||
Experimental}
|
||||
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043\nowidctlpar\b\kerning1\rtlch \ltrch\loch\fs20\lang1033\loch\f4
|
||||
|
||||
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang1043\nowidctlpar{{\*\bkmkstart __DdeLink__2_537781242}\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4
|
||||
This scenario folder contains }{\b0\kerning1\rtlch \ltrch\loch\fs16\lang1043\loch\f4{\*\bkmkend __DdeLink__2_537781242}
|
||||
experimental scenarios and scenarios for testing purposes. Feel free to play them and post any feedback in our forums.}
|
||||
\par }
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
/* Longer loam bridges */
|
||||
|
||||
#appendto Loam
|
||||
|
||||
local BridgeLength = 65;
|
||||
/* Longer loam bridges */
|
||||
|
||||
#appendto Loam
|
||||
|
||||
local BridgeLength = 65;
|
||||
|
|
|
@ -1,177 +1,177 @@
|
|||
/*
|
||||
This script contains the function FindLocation which uses a parameter-system similar to FindObject.
|
||||
This function should mainly be used for placement of objects at the start of a scenario.
|
||||
FindLocation is not guaranteed to always return a spot if a fitting spot exists, it's just best effort.
|
||||
|
||||
Examples:
|
||||
finds a tunnel spot:
|
||||
FindLocation([Loc_Tunnel()]);
|
||||
finds a floor spot but not in front of tunnel:
|
||||
FindLocation([Loc_Not(Find_Tunnel()), Loc_Wall(CNAT_Bottom)]);
|
||||
*/
|
||||
|
||||
static const LOC_INVALID = 0;
|
||||
static const LOC_SOLID = 1;
|
||||
static const LOC_INRECT = 2;
|
||||
static const LOC_TUNNEL = 3;
|
||||
static const LOC_CONDITION = 4;
|
||||
static const LOC_WALL = 5;
|
||||
static const LOC_SPACE = 6;
|
||||
static const LOC_NOT = 7;
|
||||
|
||||
global func Loc_Condition(function)
|
||||
{
|
||||
return [LOC_CONDITION, function];
|
||||
}
|
||||
|
||||
global func Loc_Not(cond)
|
||||
{
|
||||
return [LOC_NOT, cond];
|
||||
}
|
||||
|
||||
global func Loc_InRect(x, int y, int w, int h)
|
||||
{
|
||||
if (x == nil) return [LOC_INVALID];
|
||||
if (GetType(x) == C4V_PropList) return [LOC_INRECT, x];
|
||||
return [LOC_INRECT, Rectangle(x, y, w, h)];
|
||||
}
|
||||
|
||||
global func Loc_Tunnel(bool sky)
|
||||
{
|
||||
return [LOC_TUNNEL, sky ?? false];
|
||||
}
|
||||
global func Loc_Sky() { return Loc_Tunnel(true); }
|
||||
|
||||
global func Loc_Solid()
|
||||
{
|
||||
return [LOC_SOLID];
|
||||
}
|
||||
|
||||
// implies not solid
|
||||
global func Loc_Wall(int direction)
|
||||
{
|
||||
var x = 0, y = 0;
|
||||
if(direction & CNAT_Left) x = -1;
|
||||
else
|
||||
if(direction & CNAT_Right) x = 1;
|
||||
|
||||
if(direction & CNAT_Top) y = -1;
|
||||
else
|
||||
if(direction & CNAT_Bottom) y = 1;
|
||||
return [LOC_WALL, x, y, !!(direction & (CNAT_Left | CNAT_Right)), !!(direction & (CNAT_Top | CNAT_Bottom))];
|
||||
}
|
||||
|
||||
global func Loc_Space(int space, bool vertical)
|
||||
{
|
||||
return [LOC_SPACE, space, vertical];
|
||||
}
|
||||
|
||||
global func FindLocation(array flags, int repeat)
|
||||
{
|
||||
// check for are restriction
|
||||
var rect = nil;
|
||||
var xdir = 0, ydir = 0, xmod = nil, ymod = nil;
|
||||
|
||||
for (var flag in flags)
|
||||
{
|
||||
if (flags[0] == LOC_INRECT)
|
||||
{
|
||||
rect = flags[1];
|
||||
}
|
||||
else if (flags[0] == LOC_WALL)
|
||||
{
|
||||
xdir = flags[1];
|
||||
ydir = flags[2];
|
||||
xmod = flags[3];
|
||||
ymod = flags[4];
|
||||
}
|
||||
}
|
||||
rect = rect ?? Rectangle(0, 0, LandscapeWidth(), LandscapeHeight());
|
||||
|
||||
repeat = repeat ?? 5000;
|
||||
while (repeat-- > 0)
|
||||
{
|
||||
var x = RandomX(rect.x, rect.x + rect.w);
|
||||
var y = RandomX(rect.y, rect.y + rect.h);
|
||||
|
||||
// find wall-spot
|
||||
if(xdir || ydir)
|
||||
{
|
||||
var lx = xdir;
|
||||
var ly = ydir;
|
||||
if (xmod) if (Random(2)) lx *= -1;
|
||||
if (ymod) if (Random(2)) ly *= -1;
|
||||
|
||||
if (GBackSolid(x, y)) continue;
|
||||
var valid = false;
|
||||
var failsafe = 0;
|
||||
do
|
||||
{
|
||||
if (GBackSolid(x + lx, y + ly)) {valid = true; break;}
|
||||
x += lx;
|
||||
y += ly;
|
||||
} while (++failsafe < 100);
|
||||
if (!valid) continue;
|
||||
}
|
||||
|
||||
// check every flag
|
||||
var valid = true;
|
||||
for (var flag in flags)
|
||||
{
|
||||
if(FindLocationConditionCheckIsValid(flag, x, y)) continue;
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
if (valid)
|
||||
{
|
||||
return {x = x, y = y};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global func FindLocationConditionCheckIsValid(flag, x, y)
|
||||
{
|
||||
|
||||
if(flag[0] == LOC_NOT) return !FindLocationConditionCheckIsValid(flag[1]);
|
||||
|
||||
// area restriction
|
||||
if (flag[0] == LOC_SOLID)
|
||||
{
|
||||
if (GBackSolid(x, y)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// in front of "Tunnel"?
|
||||
if (flag[0] == LOC_TUNNEL)
|
||||
{
|
||||
if ((GetMaterial(x, y) == -1) && flag[1]) return true;
|
||||
if (GetMaterial(x, y) == Material("Tunnel")) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// custom condition call
|
||||
if (flag[0] == LOC_CONDITION)
|
||||
{
|
||||
if (Global->Call(flag[1], x, y)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// has some space?
|
||||
if (flag[0] == LOC_SPACE)
|
||||
{
|
||||
var xd = 0, yd = 0;
|
||||
if (flag[2]) yd = flag[1];
|
||||
else xd = flag[1];
|
||||
|
||||
var d1 = PathFree2(x, y, x + xd, y + yd);
|
||||
var d2 = PathFree2(x, y, x - xd, y - yd);
|
||||
var d = 0;
|
||||
if (d1) d += Distance(x, y, d1[0], d1[1]);
|
||||
if (d2) d += Distance(x, y, d2[0], d2[1]);
|
||||
if (d >= flag[1]) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// invalid flag?
|
||||
return true;
|
||||
/*
|
||||
This script contains the function FindLocation which uses a parameter-system similar to FindObject.
|
||||
This function should mainly be used for placement of objects at the start of a scenario.
|
||||
FindLocation is not guaranteed to always return a spot if a fitting spot exists, it's just best effort.
|
||||
|
||||
Examples:
|
||||
finds a tunnel spot:
|
||||
FindLocation([Loc_Tunnel()]);
|
||||
finds a floor spot but not in front of tunnel:
|
||||
FindLocation([Loc_Not(Find_Tunnel()), Loc_Wall(CNAT_Bottom)]);
|
||||
*/
|
||||
|
||||
static const LOC_INVALID = 0;
|
||||
static const LOC_SOLID = 1;
|
||||
static const LOC_INRECT = 2;
|
||||
static const LOC_TUNNEL = 3;
|
||||
static const LOC_CONDITION = 4;
|
||||
static const LOC_WALL = 5;
|
||||
static const LOC_SPACE = 6;
|
||||
static const LOC_NOT = 7;
|
||||
|
||||
global func Loc_Condition(function)
|
||||
{
|
||||
return [LOC_CONDITION, function];
|
||||
}
|
||||
|
||||
global func Loc_Not(cond)
|
||||
{
|
||||
return [LOC_NOT, cond];
|
||||
}
|
||||
|
||||
global func Loc_InRect(x, int y, int w, int h)
|
||||
{
|
||||
if (x == nil) return [LOC_INVALID];
|
||||
if (GetType(x) == C4V_PropList) return [LOC_INRECT, x];
|
||||
return [LOC_INRECT, Rectangle(x, y, w, h)];
|
||||
}
|
||||
|
||||
global func Loc_Tunnel(bool sky)
|
||||
{
|
||||
return [LOC_TUNNEL, sky ?? false];
|
||||
}
|
||||
global func Loc_Sky() { return Loc_Tunnel(true); }
|
||||
|
||||
global func Loc_Solid()
|
||||
{
|
||||
return [LOC_SOLID];
|
||||
}
|
||||
|
||||
// implies not solid
|
||||
global func Loc_Wall(int direction)
|
||||
{
|
||||
var x = 0, y = 0;
|
||||
if(direction & CNAT_Left) x = -1;
|
||||
else
|
||||
if(direction & CNAT_Right) x = 1;
|
||||
|
||||
if(direction & CNAT_Top) y = -1;
|
||||
else
|
||||
if(direction & CNAT_Bottom) y = 1;
|
||||
return [LOC_WALL, x, y, !!(direction & (CNAT_Left | CNAT_Right)), !!(direction & (CNAT_Top | CNAT_Bottom))];
|
||||
}
|
||||
|
||||
global func Loc_Space(int space, bool vertical)
|
||||
{
|
||||
return [LOC_SPACE, space, vertical];
|
||||
}
|
||||
|
||||
global func FindLocation(array flags, int repeat)
|
||||
{
|
||||
// check for are restriction
|
||||
var rect = nil;
|
||||
var xdir = 0, ydir = 0, xmod = nil, ymod = nil;
|
||||
|
||||
for (var flag in flags)
|
||||
{
|
||||
if (flags[0] == LOC_INRECT)
|
||||
{
|
||||
rect = flags[1];
|
||||
}
|
||||
else if (flags[0] == LOC_WALL)
|
||||
{
|
||||
xdir = flags[1];
|
||||
ydir = flags[2];
|
||||
xmod = flags[3];
|
||||
ymod = flags[4];
|
||||
}
|
||||
}
|
||||
rect = rect ?? Rectangle(0, 0, LandscapeWidth(), LandscapeHeight());
|
||||
|
||||
repeat = repeat ?? 5000;
|
||||
while (repeat-- > 0)
|
||||
{
|
||||
var x = RandomX(rect.x, rect.x + rect.w);
|
||||
var y = RandomX(rect.y, rect.y + rect.h);
|
||||
|
||||
// find wall-spot
|
||||
if(xdir || ydir)
|
||||
{
|
||||
var lx = xdir;
|
||||
var ly = ydir;
|
||||
if (xmod) if (Random(2)) lx *= -1;
|
||||
if (ymod) if (Random(2)) ly *= -1;
|
||||
|
||||
if (GBackSolid(x, y)) continue;
|
||||
var valid = false;
|
||||
var failsafe = 0;
|
||||
do
|
||||
{
|
||||
if (GBackSolid(x + lx, y + ly)) {valid = true; break;}
|
||||
x += lx;
|
||||
y += ly;
|
||||
} while (++failsafe < 100);
|
||||
if (!valid) continue;
|
||||
}
|
||||
|
||||
// check every flag
|
||||
var valid = true;
|
||||
for (var flag in flags)
|
||||
{
|
||||
if(FindLocationConditionCheckIsValid(flag, x, y)) continue;
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
if (valid)
|
||||
{
|
||||
return {x = x, y = y};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global func FindLocationConditionCheckIsValid(flag, x, y)
|
||||
{
|
||||
|
||||
if(flag[0] == LOC_NOT) return !FindLocationConditionCheckIsValid(flag[1]);
|
||||
|
||||
// area restriction
|
||||
if (flag[0] == LOC_SOLID)
|
||||
{
|
||||
if (GBackSolid(x, y)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// in front of "Tunnel"?
|
||||
if (flag[0] == LOC_TUNNEL)
|
||||
{
|
||||
if ((GetMaterial(x, y) == -1) && flag[1]) return true;
|
||||
if (GetMaterial(x, y) == Material("Tunnel")) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// custom condition call
|
||||
if (flag[0] == LOC_CONDITION)
|
||||
{
|
||||
if (Global->Call(flag[1], x, y)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// has some space?
|
||||
if (flag[0] == LOC_SPACE)
|
||||
{
|
||||
var xd = 0, yd = 0;
|
||||
if (flag[2]) yd = flag[1];
|
||||
else xd = flag[1];
|
||||
|
||||
var d1 = PathFree2(x, y, x + xd, y + yd);
|
||||
var d2 = PathFree2(x, y, x - xd, y - yd);
|
||||
var d = 0;
|
||||
if (d1) d += Distance(x, y, d1[0], d1[1]);
|
||||
if (d2) d += Distance(x, y, d2[0], d2[1]);
|
||||
if (d >= flag[1]) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// invalid flag?
|
||||
return true;
|
||||
}
|
Loading…
Reference in New Issue