X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/cards/%7B%7Bcard_id%7D%7D/form?a=blobdiff_plain;f=src%2Fobjects_on_map.c;h=f779b5f459a2cd4ab5bf092d0870c5082804693d;hb=8adb91a7c7de0716ce55784322e239415bf06e06;hp=61efcdefc635ba1bb53dc0567ed7e37c0f81013c;hpb=b4bb10b6e9089bd267a513dbf37543c318b5eb1e;p=plomrogue diff --git a/src/objects_on_map.c b/src/objects_on_map.c index 61efcde..f779b5f 100644 --- a/src/objects_on_map.c +++ b/src/objects_on_map.c @@ -23,36 +23,36 @@ extern struct yx_uint16 find_passable_pos (struct Map * map) { extern void move_monster (struct World * world, struct Monster * monster) { // Move monster in random direction, trigger fighting when hindered by player/monster. char d = rrand(0, 0) % 5; - struct yx_uint16 t = mv_yx_in_dir (d, monster->pos); + struct yx_uint16 t = mv_yx_in_dir (d, monster->cmo.pos); if (yx_uint16_cmp (t, world->player->pos)) { update_log (world, "\nThe monster hits you."); return; } struct Monster * other_monster; - for (other_monster = world->monster; other_monster != 0; other_monster = other_monster->next) { + for (other_monster = world->monster; other_monster != 0; other_monster = other_monster->cmo.next) { if (other_monster == monster) continue; - if (yx_uint16_cmp (t, other_monster->pos)) { + if (yx_uint16_cmp (t, other_monster->cmo.pos)) { update_log (world, "\nMonster bumps into monster."); return; } } if (is_passable(world->map, t)) - monster->pos = t; } + monster->cmo.pos = t; } extern void move_player (struct World * world, char d) { // Move player in direction d, update log and turn over to the enemy. struct yx_uint16 t = mv_yx_in_dir (d, world->player->pos); struct Monster * monster; - for (monster = world->monster; monster != 0; monster = monster->next) - if (yx_uint16_cmp (t, monster->pos)) { + for (monster = world->monster; monster != 0; monster = monster->cmo.next) + if (yx_uint16_cmp (t, monster->cmo.pos)) { update_log (world, "\nYou hit the monster."); monster->hitpoints--; if (0 == monster->hitpoints) { update_log (world, "\nYou kill the monster."); if (world->monster == monster) - world->monster = world->monster->next; + world->monster = world->monster->cmo.next; else { struct Monster * m_prev; - for (m_prev = world->monster; m_prev->next != monster; m_prev = m_prev->next); - m_prev->next = monster->next; } + for (m_prev = world->monster; m_prev->cmo.next != monster; m_prev = m_prev->cmo.next); + m_prev->cmo.next = monster->cmo.next; } free(monster); } turn_over (world, d); return; }