Mivel ezt a funkciót csak egyszer használtuk/használjuk, megosztanám Veletek is, hátha jól jön még valakinek.
Tetszőleges méretű, és tetszőleges számú szigetkomplexumot létrehozni parttal, utakkal együtt, vagy ha szeretnéd hogy a telkeken legyenek fák is, random pozíciókra legenerálja a fákat telkeken belül.
A régi verzióban generált kerítést is, csak nem működött megfelelően ezért kivettem. (kép róla lent)
Kód(ok):Külön-külön is kiszedem, és a legvégén egybe a szkriptet.
Elemek létrehozására szolgáló kód stock Upside_Plot(Float:X, Float:Y, Float:Z) // fennti telek
{
#define X_DIFF 70.0000
#define Y_DIFF 70.0000
CreateObject(19529, X, Y, Z, 0.00, 0.00, 90.00); // ALAP
CreateObject(19532, X, ( Y + Y_DIFF ), Z, 0.00, 0.00, 90.00); //fennti út
CreateObject(19532, X, ( Y - Y_DIFF ), Z, 0.00, 0.00, 90.00); //lennti út
CreateObject(19532, ( X + X_DIFF ), Y, Z, 0.00, 0.00, 0.00); //jobb út
CreateObject(19534, ( X + X_DIFF ), ( Y + Y_DIFF ), Z, 0.00, 0.00, 90.00); //sarok
CreateObject(19534, ( X + X_DIFF ), ( Y - Y_DIFF ), Z, 0.00, 0.00, 90.00); //sarok
objects += 6;
return 1;
}
stock Rightside_Plot(Float:X, Float:Y, Float:Z) // jobb oldali telek
{
#define X_DIFF 70.0000
#define Y_DIFF 70.0000
CreateObject(19529, X, Y, Z, 0.00, 0.00, 90.00); // ALAP
CreateObject(19532, X, ( Y - Y_DIFF ), Z, 0.00, 0.00, 90.00); //lennti út
CreateObject(19532, ( X + X_DIFF ), Y, Z, 0.00, 0.00, 0.00); //jobb út
CreateObject(19534, ( X + X_DIFF ), ( Y - Y_DIFF ), Z, 0.00, 0.00, 90.00); //sarok
objects += 4;
return 1;
}
stock Leftside_Plot(Float:X, Float:Y, Float:Z) //bal oldali
{
#define X_DIFF 70.0000
#define Y_DIFF 70.0000
CreateObject(19529, X, Y, Z, 0.00, 0.00, 90.00); // ALAP
CreateObject(19532, X, ( Y - Y_DIFF ), Z, 0.00, 0.00, 90.00); //alsó út
CreateObject(19532, ( X - X_DIFF ), Y, Z, 0.00, 0.00, 0.00); //bal út
CreateObject(19532, ( X + X_DIFF ), Y, Z, 0.00, 0.00, 0.00); //jobb út
CreateObject(19534, ( X - X_DIFF ), ( Y - Y_DIFF ), Z, 0.00, 0.00, 270.00); //sarok
CreateObject(19534, ( X + X_DIFF ), ( Y - Y_DIFF ), Z, 0.00, 0.00, 270.00); //sarok
objects += 6;
return 1;
}
stock Leftside_Sarok_Plot(Float:X, Float:Y, Float:Z) //utolsó amit lerak
{
#define X_DIFF 70.0000
#define Y_DIFF 70.0000
CreateObject(19529, X, Y, Z, 0.00, 0.00, 90.00); // ALAP
CreateObject(19532, X, ( Y + Y_DIFF ), Z, 0.00, 0.00, 90.00); //fennti út
CreateObject(19532, X, ( Y - Y_DIFF ), Z, 0.00, 0.00, 90.00); //alsó út
CreateObject(19532, ( X - X_DIFF ), Y, Z, 0.00, 0.00, 0.00); //jobb út
CreateObject(19532, ( X + X_DIFF ), Y, Z, 0.00, 0.00, 0.00); //bal út
CreateObject(19534, ( X - X_DIFF ), ( Y - Y_DIFF ), Z, 0.00, 0.00, 90.00); //keresztezodes jobbfennt
CreateObject(19534, ( X - X_DIFF ), ( Y + Y_DIFF ), Z, 0.00, 0.00, 180.00); //sarok jobblent
CreateObject(19534, ( X + X_DIFF ), ( Y + Y_DIFF ), Z, 0.00, 0.00, 180.00); //sarok ballent
CreateObject(19534, ( X + X_DIFF ), ( Y - Y_DIFF ), Z, 0.00, 0.00, 270.00); //keresztezodes fent
objects += 9;
return 1;
}
stock Coach_Large(Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ) //Part1
{
CreateObject(19542, X, Y, Z, rX, rY, rZ);
objects++;
return 1;
}
stock Coach_Small(Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ) //part2
{
CreateObject(19541, X, Y, Z, rX, rY, rZ);
objects++;
return 1;
}
stock Corner(Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ) //sarok
{
CreateObject(19540, X, Y, Z, rX, rY, rZ);
objects++;
return 1;
}
Fák létrehozása
Generate_Random_Tree(Float:xmin, Float:ymin, Float:xmax, Float:ymax, Float:Z, max_darab = 5) //Adott területen belül letesz \'max_darab\' számú fát, random helyre
{
new Float:xx, Float:yy, max_fa;
max_fa = random(max_darab);
if(max_fa == 0) return 0;
for(new i = 0; i < max_fa; i++)
{
xx = random(floatround(xmax, floatround_floor) - floatround(xmin, floatround_floor)) + floatround(xmin, floatround_floor);
yy = random(floatround(ymax, floatround_floor) - floatround(ymin, floatround_floor)) + floatround(ymin, floatround_floor);
CreateObject( 618, xx, yy, Z, 0.00, 0.00, 0.00);
}
return 1;
}
Sziget létrehozása
Generate_Island(Float:X, Float:Y, Float:Z, hossz=10, szelesseg=10) // Egy sziget legenerálása
{
#define PLOT_DIFF 140.0000
#define SAND_DIFF 62.50
new Float:COUNT_X = 0.00, Float:COUNT_Y = 0.00;
new Float:xmin, Float:ymin, Float:xmax, Float:ymax;
// Telek, út, homok része
for(new i = 0; i < hossz; i++)
{
//Legutolsó sor generálása
if(i == (hossz-1))
{
//Fennti rész
Upside_Plot(X, Y + COUNT_Y, Z);
//random fa
xmin = X - ((PLOT_DIFF/2) - 15.0);
ymin = (Y + COUNT_Y) - ((PLOT_DIFF/2) - 15.0);
xmax= X + ((PLOT_DIFF/2) - 15.0);
ymax = (Y + COUNT_Y) + ((PLOT_DIFF/2) - 15.0);
Generate_Random_Tree(xmin, ymin, xmax, ymax, Z);
//Sarok balfennt
Leftside_Sarok_Plot( ( X - ( PLOT_DIFF * (szelesseg-1) ) ), Y + COUNT_Y, Z);
//random fa
xmin = ( X - ( PLOT_DIFF * (szelesseg-1) ) ) - ((PLOT_DIFF/2) - 15.0);
ymin = (Y + COUNT_Y) - ((PLOT_DIFF/2) - 15.0);
xmax= ( X - ( PLOT_DIFF * (szelesseg-1) ) ) + ((PLOT_DIFF/2) - 15.0);
ymax = (Y + COUNT_Y) + ((PLOT_DIFF/2) - 15.0);
Generate_Random_Tree(xmin, ymin, xmax, ymax, Z);
//sarok
Coach_Large( X, ((Y+COUNT_Y)+7.50) + (PLOT_DIFF/2), Z, 0.00, 0.00, 90.00);
Coach_Small( X + (PLOT_DIFF/2) , ((Y+COUNT_Y)+7.50) + (PLOT_DIFF/2), Z, 0.00, 0.00, 90.00);
//sarok2
Coach_Large( ( X - ( PLOT_DIFF * (szelesseg-1) ) ), ((Y+COUNT_Y)+7.50) + (PLOT_DIFF/2), Z, 0.00, 0.00, 90.00);
Coach_Small( ( X - ( PLOT_DIFF * (szelesseg-1) ) ) + (PLOT_DIFF/2), ((Y+COUNT_Y)+7.50) + (PLOT_DIFF/2) , Z, 0.00, 0.00, 90.00);
//legszéle
Coach_Small( ( X - ( PLOT_DIFF * (szelesseg-1) ) ) - (PLOT_DIFF/2), ((Y+COUNT_Y)+7.50) + (PLOT_DIFF/2), Z, 0.00, 0.00, 90.00);
//sarkok
Corner(X + (PLOT_DIFF/2) + 7.50, ((Y+COUNT_Y)+7.50) + (PLOT_DIFF/2), Z, 0.00, 0.00, 0.00);
Corner(( X - ( PLOT_DIFF * (szelesseg-1) ) ) - (PLOT_DIFF/2) - 7.50, ((Y+COUNT_Y)+7.50) + (PLOT_DIFF/2), Z, 0.00, 0.00, 90.00);
}
else
{
Rightside_Plot(X, Y + COUNT_Y, Z);
//random fa
xmin = X - ((PLOT_DIFF/2) - 15.0);
ymin = (Y + COUNT_Y) - ((PLOT_DIFF/2) - 15.0);
xmax= X + ((PLOT_DIFF/2) - 15.0);
ymax = (Y + COUNT_Y) + ((PLOT_DIFF/2) - 15.0);
Generate_Random_Tree(xmin, ymin, xmax, ymax, Z);
Leftside_Plot( ( X - ( PLOT_DIFF * (szelesseg-1) ) ), Y + COUNT_Y, Z);
//random fa
xmin = ( X - ( PLOT_DIFF * (szelesseg-1) ) ) - ((PLOT_DIFF/2) - 15.0);
ymin = (Y + COUNT_Y) - ((PLOT_DIFF/2) - 15.0);
xmax= ( X - ( PLOT_DIFF * (szelesseg-1) ) ) + ((PLOT_DIFF/2) - 15.0);
ymax = (Y + COUNT_Y) + ((PLOT_DIFF/2) - 15.0);
Generate_Random_Tree(xmin, ymin, xmax, ymax, Z);
// Két első szél
if(i == 0)
{
Coach_Small( ( X + (X_DIFF + 7.50) ), (Y + COUNT_Y) - (PLOT_DIFF/2), Z, 0.00, 0.00, 0.00);
Coach_Small( (( X - ( PLOT_DIFF * (szelesseg-1) ) ) - (PLOT_DIFF/2)) - 7.50, (Y + COUNT_Y) - (PLOT_DIFF/2), Z, 0.00, 0.00, 180.00);
//egyk sarok
Coach_Large( (X - COUNT_X), ((Y-COUNT_Y)-7.50) - (PLOT_DIFF/2), Z, 0.00, 0.00, 270.00);
Coach_Small( ( (X - COUNT_X) - (PLOT_DIFF/2) ), ((Y-COUNT_Y)-7.50) - (PLOT_DIFF/2) , Z, 0.00, 0.00, 270.00);
//másik
Coach_Large( ( X - ( PLOT_DIFF * (szelesseg-1) ) ), ((Y-COUNT_Y)-7.50) - (PLOT_DIFF/2), Z, 0.00, 0.00, 270.00);
Coach_Small( ( X - ( PLOT_DIFF * (szelesseg-1) ) ) - (PLOT_DIFF/2), ((Y-COUNT_Y)-7.50) - (PLOT_DIFF/2) , Z, 0.00, 0.00, 270.00);
//legszéle
Coach_Small( ( (X - COUNT_X) + (PLOT_DIFF/2) ), ((Y-COUNT_Y)-7.50) - (PLOT_DIFF/2) , Z, 0.00, 0.00, 270.00);
//sarkok
Corner((X + COUNT_X) + (PLOT_DIFF/2) + 7.50, ((Y-COUNT_Y)-7.50) - (PLOT_DIFF/2), Z, 0.00, 0.00, 270.00);
Corner(( X - ( PLOT_DIFF * (szelesseg-1) ) ) - (PLOT_DIFF/2) - 7.50, ((Y-COUNT_Y)-7.50) - (PLOT_DIFF/2), Z, 0.00, 0.00, 180.00);
}
}
// Szélek jobb (2 nagy, 1 kicsi)
Coach_Large( ( X + (X_DIFF + 7.50) ), ( (Y + COUNT_Y) ), Z, 0.00, 0.00, 0.00);
Coach_Small( ( X + (X_DIFF + 7.50) ), (Y + COUNT_Y) + (PLOT_DIFF/2), Z, 0.00, 0.00, 0.00);
// Szélek bal
Coach_Large( (( X - ( PLOT_DIFF * (szelesseg-1) ) ) - (PLOT_DIFF/2)) - 7.50, ( (Y + COUNT_Y) ), Z, 0.00, 0.00, 180.00);
Coach_Small( (( X - ( PLOT_DIFF * (szelesseg-1) ) ) - (PLOT_DIFF/2)) - 7.50 , (Y + COUNT_Y) + (PLOT_DIFF/2), Z, 0.00, 0.00, 180.00);
COUNT_X = 140.0000;
for(new a = 1; a < (szelesseg-1); a++)
{
if(i == (hossz-1))
{
Upside_Plot(X-COUNT_X, Y+COUNT_Y, Z);
//random fa
xmin = (X-COUNT_X) - ((PLOT_DIFF/2) - 15.0);
ymin = (Y + COUNT_Y) - ((PLOT_DIFF/2) - 15.0);
xmax= (X-COUNT_X) + ((PLOT_DIFF/2) - 15.0);
ymax = (Y + COUNT_Y) + ((PLOT_DIFF/2) - 15.0);
Generate_Random_Tree(xmin, ymin, xmax, ymax, Z);
Coach_Large( ( (X - COUNT_X)), ((Y+COUNT_Y)+7.50) + (PLOT_DIFF/2), Z, 0.00, 0.00, 90.00);
Coach_Small( (X - COUNT_X) + (PLOT_DIFF/2) , ((Y+COUNT_Y)+7.50) + (PLOT_DIFF/2), Z, 0.00, 0.00, 90.00);
}
else
{
Rightside_Plot( X-COUNT_X, Y+COUNT_Y, Z);
//random fa
xmin = (X-COUNT_X) - ((PLOT_DIFF/2) - 15.0);
ymin = (Y + COUNT_Y) - ((PLOT_DIFF/2) - 15.0);
xmax= (X-COUNT_X) + ((PLOT_DIFF/2) - 15.0);
ymax = (Y + COUNT_Y) + ((PLOT_DIFF/2) - 15.0);
Generate_Random_Tree(xmin, ymin, xmax, ymax, Z);
if(i == 0)
{
Coach_Large( ( (X - COUNT_X)), ((Y-COUNT_Y)-7.50) - (PLOT_DIFF/2), Z, 0.00, 0.00, 270.00);
Coach_Small( ( (X - COUNT_X) - (PLOT_DIFF/2) ), ((Y-COUNT_Y)-7.50) - (PLOT_DIFF/2) , Z, 0.00, 0.00, 270.00);
}
}
COUNT_X += PLOT_DIFF;
}
COUNT_Y += PLOT_DIFF;
}
return 1;
}
Játéktér elkészítése:
Generate_Map(numberx, numbery, Float:X, Float:Y, Float:Z, w, h)
{
#define ROAD_DIFF 70.0
new Float: DIFF = CalculatePlotWidth(w)-22.50, Float:X_COUNTER, Float:ROAD_COUNTER;
X_COUNTER = 0.00, ROAD_COUNTER = 0.00;
for(new i = 0; i < numberx; i++)
{
Generate_Island(X-X_COUNTER, Y, Z, w, h);
//utak generálása
if( i < (numberx-1) )
{
for(new k = 0; k <= h; k++)
{
CreateObject(19532, (X-(X_COUNTER+280.00)), (Y - ROAD_DIFF) + ROAD_COUNTER, Z+0.02, 0.00, 0.00, 90.00); //alsó út
ROAD_COUNTER += ROAD_DIFF*2;
printf(\"%i\", k);
}
}
ROAD_COUNTER = 0.00;
X_COUNTER += DIFF;
}
new str[128];
format(str, 128, \"%d objects created. (%i*%i)\", objects, w, h);
printf(str);
}
Egyben a szkript:
http://pastebin.com/ZrXXtQmMHasználjátok egészséggel!