Skip to content

Commit

Permalink
Adding some pseudo-random noise into roaming.
Browse files Browse the repository at this point in the history
  • Loading branch information
serg-bloim authored Jan 11, 2024
1 parent bd0d26f commit 8bb1156
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/figure/movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "map/routing_terrain.h"
#include "map/terrain.h"

static short global_roaming_noise = 0;

static void advance_tick(figure *f)
{
switch (f->direction) {
Expand Down Expand Up @@ -435,7 +437,7 @@ void figure_movement_roam_ticks(figure *f, int num_ticks)
if (f->direction < 0) f->direction = 6;
} while (dir++ < 4);
} else { // > 2 road tiles
f->direction = (f->roam_random_counter + map_random_get(f->grid_offset)) & 6;
f->direction = (++global_roaming_noise + f->roam_random_counter + map_random_get(f->grid_offset)) & 6;
if (!road_tiles[f->direction] || f->direction == came_from_direction) {
f->roam_ticks_until_next_turn--;
if (f->roam_ticks_until_next_turn <= 0) {
Expand Down

0 comments on commit 8bb1156

Please sign in to comment.