- Also fixes a bug with artifact generation
- Extends menu room with new features
- Adds more descriptive text to container openings
- Fixes bug with container loot generation
This commit is contained in:
Linus Probert 2018-08-10 22:31:06 +02:00
parent 62d1bbd49d
commit 4ba301769a
5 changed files with 30 additions and 29 deletions

View File

@ -1,5 +1,7 @@
local room_builder = require "maproombuilder"
local monster_gen = require "monstergen"
local trap_gen = require "trapgen"
local chest_gen = require "chestgen"
map = create_map(CURRENT_LEVEL) -- 'map' needs to be global
@ -10,5 +12,9 @@ local room = room_builder.create_empty_room()
room_builder.build_room(room)
room_builder.add_full_lighting(room)
monster_gen.add_monsters_to_room(room, 0, 0)
trap_gen.add_traps_to_room(room, 0, 0)
chest_gen.add_chests_to_room(room, 0, 0)
room_builder.load_room(map, room)
monster_gen.load_monsters(map, room.monsters)
trap_gen.load_traps(map, room.traps)
chest_gen.load_chests(map, room.chests)

View File

@ -95,20 +95,13 @@ Artifact *
artifact_create_random(Player *p, Uint8 level)
{
int option = -1;
switch (p->stats.lvl) {
case 4:
option = get_random(CHARGE_THROUGH);
break;
case 3:
if (p->stats.lvl >= 4)
option = get_random(LAST_ARTIFACT_EFFECT);
else if (p->stats.lvl >= 3)
option = get_random(INCREASED_STUN);
break;
case 1:
else
option = get_random(FEAR_INDUCING);
break;
default:
option = get_random(LAST_ARTIFACT_EFFECT) - 1;
break;
}
Artifact *a = artifact_create(option);
a->level = level;
return a;

View File

@ -20,6 +20,7 @@
#include "item.h"
#include "util.h"
#include "mixer.h"
#include "gui.h"
Item *
item_create(void)
@ -48,21 +49,22 @@ item_collected(Item *item, Player *player)
if (item->collected || item->opened)
return;
while (item->items) {
Item *subitem = linkedlist_pop(&item->items);
item_collected(subitem, player);
item_destroy(subitem);
if (!item->openable) {
item->collected = true;
} else {
mixer_play_effect(CHEST_OPEN);
gui_log("You open a container");
item->opened = true;
item->sprite->texture_index = 1;
}
if (item->effect != NULL)
item->effect(item, player);
if (!item->openable) {
item->collected = true;
} else {
mixer_play_effect(CHEST_OPEN);
item->opened = true;
item->sprite->texture_index = 1;
while (item->items) {
Item *subitem = linkedlist_pop(&item->items);
item_collected(subitem, player);
item_destroy(subitem);
}
}

View File

@ -115,7 +115,7 @@ create_treasure(int current_level)
unsigned int highest_treasure;
unsigned int value;
amt = (unsigned int) get_random(5*current_level) % 40;
amt = (unsigned int) 1 + get_random(5*current_level) % 40;
if (current_level > 9) {
highest_treasure = TREASURE_COUNT;
@ -125,7 +125,7 @@ create_treasure(int current_level)
highest_treasure = GOLD;
}
value = get_random(highest_treasure) - 1;
value = get_random(highest_treasure);
SDL_Rect clip = CLIP16(0, 0);
switch (value) {

View File

@ -333,11 +333,11 @@ l_add_chest(lua_State *L)
lua_pop(L, 4);
if (get_random(1) == 0)
linkedlist_append(&chest->items, item_builder_build_item(level, TREASURE));
linkedlist_append(&chest->items, item_builder_build_item(TREASURE, level));
if (get_random(4) == 0)
linkedlist_append(&chest->items, item_builder_build_item(level, HEALTH));
linkedlist_append(&chest->items, item_builder_build_item(HEALTH, level));
if (get_random(4) == 0)
linkedlist_append(&chest->items, item_builder_build_item(level, DAGGER));
linkedlist_append(&chest->items, item_builder_build_item(DAGGER, level));
linkedlist_append(&map->items, chest);