1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 13:07:16 +00:00

relhell:: ads:: four basic lands

This commit is contained in:
Zeno Rogue 2024-10-01 15:13:56 +02:00
parent c4fc004916
commit 135b1d3779
2 changed files with 68 additions and 46 deletions

View File

@ -102,6 +102,7 @@ void run_ads_game_hooks() {
rogueviz::rv_hook(hooks_drawcell, 0, ads_draw_cell);
rogueviz::rv_hook(shmup::hooks_turn, 0, ads_turn);
rogueviz::rv_hook(anims::hooks_anim, 100, replay_animation);
rogueviz::rv_hook(hooks_nextland, 0, ads_nextland);
}
void run_ads_game() {
@ -112,12 +113,11 @@ void run_ads_game() {
hybrid::csteps = 0;
hybrid::reconfigure();
}
run_ads_game_hooks();
start_game();
starting_point = hybrid::get_where(cwt.at).first;
run_ads_game_hooks();
cgi.use_count++;
hybrid::in_underlying_geometry([] {
cgi.use_count++;
@ -167,6 +167,7 @@ void default_settings() {
lps_add(lps_relhell, ccolor::which, &ccolor::random);
lps_add(lps_relhell, ccolor::rwalls, 0);
lps_add(lps_relhell, vid.fov, 150.);
lps_add(lps_relhell, specialland, laCrossroads);
lps_add(lps_relhell_ds_spacetime_klein, pmodel, mdDisk);

View File

@ -68,18 +68,20 @@ void gen_terrain(cell *c, cellinfo& ci, int level = 0) {
if(level == 2) {
int r = hrand(100);
if(r < 3) {
forCellCM(c1, c) if(hrand(100) < 50)
forCellCM(c2, c1) if(hrand(100) < 50)
if(ci_at[c2].type == wtNone) ci_at[c2].type = wtDestructible;
if(r < wall_frequency(c)) {
int t = hrand(2);
if(t == 0)
forCellCM(c1, c) if(hrand(100) < 50) if(c1->land == c->land)
forCellCM(c2, c1) if(hrand(100) < 50) if(c2->land == c->land)
if(ci_at[c2].type == wtNone) ci_at[c2].type = wtDestructible;
if(t == 1)
forCellCM(c1, c) if(hrand(100) < 50) if(c1->land == c->land)
forCellCM(c2, c1) if(hrand(100) < 50) if(c1->land == c->land)
if(ci_at[c2].type < wtSolid)
ci_at[c2].type = wtSolid;
}
else if(r < 6) {
forCellCM(c1, c) if(hrand(100) < 50)
forCellCM(c2, c1) if(hrand(100) < 50)
if(ci_at[c2].type < wtSolid)
ci_at[c2].type = wtSolid;
}
else if(r < 8)
r = hrand(100);
if(r < gate_frequency(c))
ci_at[c].type = wtGate;
}
ci.mpd_terrain = level;
@ -153,8 +155,44 @@ void add_turret(cell *c, cellinfo& ci, const ads_matrix& T) {
ci.rocks.emplace_back(std::move(r));
}
void gen_resource(cell *c, shiftmatrix from, eResourceType rsrc, int expire);
void add_rsrc(cell *c, cellinfo& ci, const ads_matrix& T) {
eResourceType rt = eResourceType(rand() % 6);
gen_resource(c, T, rt, gen_expire());
}
int turrets;
struct placement {
ld alpha;
ld r;
ld shift;
ld spinshift;
ld rapidity;
ads_matrix get() {
return spin(alpha) * twist::uxpush(r/2) * chg_shift(shift) * spin(spinshift) * lorentz(0, 3, rapidity);
};
};
/* if maxr equals cgi.rhexf, any point inside the cell equally likely */
placement get_placement(cell *c, ld maxr, ld max_rapidity) {
cell *c1 = nullptr;
placement p;
while(c1 != c) {
ld vol = randd() * wvolarea_auto(maxr);
p.r = binsearch(0, maxr, [vol] (ld r) { return wvolarea_auto(r) > vol; });
p.alpha = randd() * TAU;
hyperpoint h = spin(p.alpha) * xpush0(p.r);
c1 = c;
virtualRebase(c1, h);
}
p.shift = randd() * TAU;
p.spinshift = randd() * TAU;
p.rapidity = randd() * max_rapidity;
return p;
}
void gen_rocks(cell *c, cellinfo& ci, int radius) {
if(radius <= ci.rock_dist) return;
if(ci.rock_dist < radius - 1) gen_rocks(c, ci, radius-1);
@ -162,44 +200,27 @@ void gen_rocks(cell *c, cellinfo& ci, int radius) {
if(!hyperbolic) { println(hlog, "wrong geometry detected in gen_rocks 1!"); exit(1); }
if(radius == 0) {
int q = rpoisson(rock_density);
int q = rpoisson(rock_density * rock_frequency(c));
for(int i=0; i<q; i++) {
/* any point inside the cell equally likely */
ld maxr = cgi.rhexf;
cell *c1 = nullptr;
ld r, alpha;
while(c1 != c) {
ld vol = randd() * wvolarea_auto(maxr);
r = binsearch(0, maxr, [vol] (ld r) { return wvolarea_auto(r) > vol; });
alpha = randd() * TAU;
hyperpoint h = spin(alpha) * xpush0(r);
c1 = c;
virtualRebase(c1, h);
}
auto p = get_placement(c, cgi.rhexf, rock_max_rapidity);
hybrid::in_actual([&] {
add_rock(c, ci, ads_matrix(spin(alpha) * twist::uxpush(r/2) * chg_shift(randd() * TAU) * spin(randd() * TAU) * lorentz(0, 3, randd() * rock_max_rapidity)));
add_rock(c, ci, p.get());
});
}
q = rpoisson(rock_density / 50);
if(celldist(c) == 2) q += rpoisson(0.1);
for(int i=0; i<q; i++) {
ld maxr = cgi.rhexf;
cell *c1 = nullptr;
ld r, alpha;
while(c1 != c) {
ld vol = randd() * wvolarea_auto(maxr);
r = binsearch(0, maxr, [vol] (ld r) { return wvolarea_auto(r) > vol; });
alpha = randd() * TAU;
hyperpoint h = spin(alpha) * xpush0(r);
c1 = c;
virtualRebase(c1, h);
}
if(ci.type == wtGate && hrand(100) < 20) {
auto p = get_placement(c, cgi.rhexf / 2, rock_max_rapidity / 100);
hybrid::in_actual([&] {
add_turret(c, ci, ads_matrix(spin(alpha) * twist::uxpush(r/2) * chg_shift(randd() * TAU) * spin(randd() * TAU) * lorentz(0, 3, randd() * rock_max_rapidity/10)));
add_rsrc(c, ci, p.get());
});
}
q = rpoisson(rock_density * turret_frequency(c));
// if(celldist(c) == 2) q += rpoisson(0.1);
for(int i=0; i<q; i++) {
auto p = get_placement(c, cgi.rhexf, rock_max_rapidity / 10);
hybrid::in_actual([&] {
add_turret(c, ci, p.get());
turrets++;
});
}