Hot Ice: Spawn and map improvements in "small islands" mode #1623

objectmenu
Sven Eberhardt 2016-01-17 12:22:08 -05:00
parent dd33f8ea31
commit 418964f6e8
2 changed files with 95 additions and 36 deletions

View File

@ -1,10 +1,13 @@
/**
/*
Hot Ice
Ice islands above a lava lake
@authors Sven2
*/
static g_player_spawn_positions;
static g_map_width;
// Called be the engine: draw the complete map here.
public func InitializeMap(proplist map)
{
@ -12,35 +15,77 @@ public func InitializeMap(proplist map)
// Map type 1: Only many small islands
var t = SCENPAR_MapType;
var w = map.Wdt, h=map.Hgt;
g_map_width = w;
// Bottom lava lake
map->Draw("^DuroLava", nil, [0,h*4/5,w,h/5]);
// Big island
if (t == 0)
{
var island = { Algo=MAPALGO_Polygon, X=[0,w,w*6/8,w*2/8], Y=[h*4/10,h*4/10,h*7/10,h*7/10] };
island = { Algo=MAPALGO_Turbulence, Op=island, Amplitude=[0, 8] };
map->Draw("^Ice-ice2", island, [w/10,h*13/20,w*8/10,h*3/20]);
}
// Small islands
var n_islands = [12,37][t];
while(n_islands--)
{
var y = h*2/10 + Random(h*(3+t*2)/10);
var x = w*1/10 + Random(w*8/10);
var szx = t*Random(3);
var szy = 1+t*Random(Random(2));
map->Draw("^Ice-ice2", nil, [x-szx,y,1+2*szx,szy]);
}
// Alternate texctures
var icealt_tex = { Algo=MAPALGO_RndChecker, Wdt=2, Hgt=3 };
icealt_tex = { Algo=MAPALGO_Turbulence, Op=icealt_tex };
icealt_tex = { Algo=MAPALGO_And, Op=[Duplicate("Ice"), icealt_tex]};
map->Draw("^Ice-ice3", icealt_tex);
if (t == 0) DrawBigIslandMap(map);
if (t == 1) DrawSmallIslandsMap(map);
// Alternate texctures
var icealt_tex = { Algo=MAPALGO_RndChecker, Wdt=2, Hgt=3 };
icealt_tex = { Algo=MAPALGO_Turbulence, Op=icealt_tex };
icealt_tex = { Algo=MAPALGO_And, Op=[Duplicate("Ice"), icealt_tex]};
map->Draw("^Ice-ice", icealt_tex);
// Return true to tell the engine a map has been successfully created.
return true;
}
func DrawBigIslandMap(proplist map)
{
var w = map.Wdt, h=map.Hgt;
// Draw one big island as the ground and some smaller islands floating above
// Big
var island = { Algo=MAPALGO_Polygon, X=[0,w,w*6/8,w*2/8], Y=[h*4/10,h*4/10,h*7/10,h*7/10] };
island = { Algo=MAPALGO_Turbulence, Op=island, Amplitude=[0, 8] };
map->Draw("^Ice-ice2", island, [w/10,h*13/20,w*8/10,h*3/20]);
// Make sure one row of inner island is drawn because it's used for player spawns
map->Draw("^Ice-ice2", nil, [w*3/10,h*13/20,w*4/10+1,1]);
// Smaller floating
var n_islands = 12;
while(n_islands--)
{
var x = w*1/10 + Random(w*8/10);
var y = h*2/10 + Random(h*3/10);
map->Draw("^Ice-ice2", nil, [x,y,1,1]);
}
// Player spawns simply in middle of big island
var plrcnt = GetStartupPlayerCount();
g_player_spawn_positions = CreateArray(plrcnt);
for (var i = 0; i < plrcnt; ++i)
{
g_player_spawn_positions[i] = [w*3/10 + i*w*4/10/(plrcnt-1), h*13/20-1];
}
return true;
}
func DrawSmallIslandsMap(proplist map)
{
var w = map.Wdt, h=map.Hgt, x, y, szx, szy;
// Islands in center of map
var n_islands = 35;
while(n_islands--)
{
y = h*3/10 + Random(h*5/10 - 3);
var xrange = w * (y)/(h*9/10);
x = w/2 - xrange/2 + Random(xrange);
szx = Random(3);
szy = 1;
if (y > h/2) szy += Random(2); // lower islands sometimes taller
if (Abs(x-w/2) < w/10) szx += Random(3); // central islands sometimes wider
map->Draw("^Ice-ice2", nil, [x-szx,y,1+2*szx,szy]);
}
// Starting islands for player spawns
var spawn_island_count = GetStartupPlayerCount();
g_player_spawn_positions = CreateArray(spawn_island_count);
for (var i = 0; i < spawn_island_count; ++i)
{
var x = w*2/10 + i * (w*6/10) / (spawn_island_count - 1);
var y = Max(1, h/10) + Abs(x-w/2) * 3*h/10/w;
map->Draw("^Ice-ice2", nil, [x,y,1,1]);
g_player_spawn_positions[i] = [x, y-1];
}
return true;
}

View File

@ -5,9 +5,10 @@ func Initialize()
// Materials: Chests
var i,pos;
var ls_wdt = LandscapeWidth(), ls_hgt = LandscapeHeight();
var top_area_hgt = ls_hgt*[50,80][SCENPAR_MapType]/100;
var chest_area_y = ls_hgt*[0,30][SCENPAR_MapType]/100;
var chest_area_hgt = ls_hgt/2;
for (i=0; i<6; ++i)
if (pos=FindLocation(Loc_InRect(0,0,ls_wdt,top_area_hgt-100), Loc_Wall(CNAT_Bottom))) // Loc_Wall adds us 100 pixels...
if (pos=FindLocation(Loc_InRect(0,chest_area_y,ls_wdt,chest_area_hgt-100), Loc_Wall(CNAT_Bottom))) // Loc_Wall adds us 100 pixels...
{
var chest = CreateObjectAbove(Chest,pos.x,pos.y);
if (chest)
@ -24,27 +25,40 @@ func Initialize()
}
// Materials: Firestones
for (i=0; i<30; ++i)
if (pos=FindLocation(Loc_InRect(0,0,ls_wdt,top_area_hgt), Loc_Solid()))
if (pos=FindLocation(Loc_InRect(0,chest_area_y,ls_wdt,chest_area_hgt), Loc_Solid()))
if (IsFirestoneSpot(pos.x,pos.y))
CreateObjectAbove(Firestone,pos.x,pos.y-1);
// Some firestones in lower half. For ap type 1, more firestones in lower than upper half.
// Some firestones and bombs in lower half. For ap type 1, more firestones in lower than upper half.
for (i=0; i<30; ++i)
if (pos=FindLocation(Loc_InRect(0,ls_hgt/2,ls_wdt,ls_hgt/3), Loc_Solid()))
if (IsFirestoneSpot(pos.x,pos.y))
CreateObjectAbove(Firestone,pos.x,pos.y-1);
CreateObjectAbove([Firestone,IronBomb][Random(Random(3))],pos.x,pos.y-1);
return true;
}
static g_player_spawn_positions, g_map_width, g_player_spawn_index;
func InitializePlayer(int plr)
{
// everything visible
SetFoW(false, plr);
// player positioning. In lower area for both maps becuase starting high is an an advantage.
// Player positioning.
var ls_wdt = LandscapeWidth(), ls_hgt = LandscapeHeight();
var crew = GetCrew(plr);
var start_pos = FindLocation(Loc_InRect(ls_wdt/5,ls_hgt/2,ls_wdt*3/5,ls_hgt/3), Loc_Wall(CNAT_Bottom), Loc_Func(Scenario.IsStartSpot));
if (!start_pos) start_pos = FindLocation(Loc_InRect(ls_wdt/10,0,ls_wdt*8/10,ls_hgt*4/5), Loc_Wall(CNAT_Bottom), Loc_Func(Scenario.IsStartSpot));
if (!start_pos) start_pos = {x=Random(ls_wdt*6/10)+ls_wdt*2/10, y=ls_hgt*58/100};
var crew = GetCrew(plr), start_pos;
// Position by map type?
if (g_player_spawn_positions && g_player_spawn_index < GetLength(g_player_spawn_positions))
{
start_pos = g_player_spawn_positions[g_player_spawn_index++];
var map_zoom = ls_wdt / g_map_width;
start_pos = {x=start_pos[0]*map_zoom+map_zoom/2, y=start_pos[1]*map_zoom};
}
else
{
// Start positions not defined or exhausted: Spawn in lower area for both maps becuase starting high is an an advantage.
start_pos = FindLocation(Loc_InRect(ls_wdt/5,ls_hgt/2,ls_wdt*3/5,ls_hgt/3), Loc_Wall(CNAT_Bottom), Loc_Func(Scenario.IsStartSpot));
if (!start_pos) start_pos = FindLocation(Loc_InRect(ls_wdt/10,0,ls_wdt*8/10,ls_hgt*4/5), Loc_Wall(CNAT_Bottom), Loc_Func(Scenario.IsStartSpot));
if (!start_pos) start_pos = {x=Random(ls_wdt*6/10)+ls_wdt*2/10, y=ls_hgt*58/100};
}
crew->SetPosition(start_pos.x, start_pos.y-10);
// initial material
crew->CreateContents(Shovel);