From 3fabd039a477840df914aab4ae555d2f127e751a Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Wed, 15 Aug 2018 18:16:44 +0200 Subject: [PATCH] Prevents artifacts before level 3 - Also fixes a potential segfault --- src/artifact.c | 2 +- src/monster.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/artifact.c b/src/artifact.c index b04f24d..d4f6e2e 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -96,7 +96,7 @@ artifact_create_random(Player *p, Uint8 level) { int option = -1; if (p->stats.lvl >= 4) - option = get_random(LAST_ARTIFACT_EFFECT); + option = get_random(LAST_ARTIFACT_EFFECT - 1); else if (p->stats.lvl >= 3) option = get_random(INCREASED_STUN); else diff --git a/src/monster.c b/src/monster.c index a46bd2a..6d27f87 100644 --- a/src/monster.c +++ b/src/monster.c @@ -542,7 +542,7 @@ monster_drop_loot(Monster *monster, Map *map, Player *player) linkedlist_append(&map->items, treasure); } - if (get_random(19) == 0) { + if (monster->stats.lvl > 2 && get_random(19) == 0) { Artifact *a = artifact_create_random(player, 1); a->sprite->pos = monster->sprite->pos; linkedlist_append(&map->artifacts, a);