From: Lukas Krickl Date: Mon, 25 Aug 2025 17:24:42 +0000 (+0200) Subject: mapgen: actor spawning now checks if an actor already exists at the selected position X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=420d3b013f182df55eac469f96b88a6955800010;p=gbrg%2F.git mapgen: actor spawning now checks if an actor already exists at the selected position --- diff --git a/src/mapgen.s b/src/mapgen.s index 4d661ab..f2f4667 100644 --- a/src/mapgen.s +++ b/src/mapgen.s @@ -523,7 +523,7 @@ mapgen_place_actors: ; move to next actor table entry push hl - call mapgent_unit_randomize_or_reaload_position + call mapgent_unit_randomize_position ld hl, act_size add hl, de push hl @@ -533,8 +533,6 @@ mapgen_place_actors: dec b jp nz, @spawn_another - ; TODO: reload flags and positions - ret ; randomizes (or reloads from sram) @@ -542,7 +540,7 @@ mapgen_place_actors: ; inputs: ; de: actor table entry ; preserves all registers -mapgent_unit_randomize_or_reaload_position: +mapgent_unit_randomize_position: push_all @retry: ld hl, act_pos_y @@ -561,11 +559,22 @@ mapgent_unit_randomize_or_reaload_position: ; check if tile is OK to spawn on push bc call map_get_tile - and a, CF_COLLISION + cp a, 0x00 ; check flags pop bc pop hl ; if collision flag is set try again jr nz, @retry REL + + push bc + push hl + ; check if this tile already had an actor + call unit_find_at + ld a, h + or a, l + pop bc + pop hl + cp a, 0 + jr nz, @retry REL ; write y and x positions ld a, b